cabot icon indicating copy to clipboard operation
cabot copied to clipboard

Network port checking plugin

Open ralienpp opened this issue 6 years ago • 17 comments

I would like to have a plugin that checks if a TCP connection to a particular port can be established, at a minimum; and if a certain message was received, as an option.

There are some parts of infrastructure that do not have HTTP interfaces (e.g. Asterisk for VoIP, or CAs with OCSP and CMP facilities, LDAP, etc), it would be great of Cabot could be used for those as well.

ralienpp avatar Aug 24 '17 08:08 ralienpp

@ralienpp That sounds like a good addition.

For inspiration I had a look at the way Ansible does it − just using socket.

Would you be interested in writing a plugin for this @ralienpp ? :)

JeanFred avatar Aug 24 '17 11:08 JeanFred

Yes, I would like to do it - but the documentation doesn't include a guide for writing check plugins, so I need some basic tips on how that should work.

ralienpp avatar Aug 24 '17 11:08 ralienpp

Yes, I would like to do it -

Awesome!

but the documentation doesn't include a guide for writing check plugins, so I need some basic tips on how that should work.

Indeed, we are pretty much in uncharted territories here, given how recent the plugin architecture for Cabot check is (it was just added in #527).

In that PR @as-sergey-m explained that they used [https://gitlab.com/as-public/cabot-check-skeleton cabot-check-skeleton] as test base all you need is to add it to CABOT_CUSTOM_CHECK_PLUGINS in the env file as it seems).

Is that helpful to get you started ? :)

JeanFred avatar Aug 25 '17 10:08 JeanFred

@ralienpp @frankh has partly re-written the Check plugin architecture, and just wrote the cabot-check-cloudwatch plugin. This might be good inspiration!

JeanFred avatar Sep 14 '17 10:09 JeanFred

@JeanFred one small piece of maintenance: is our cabot-check-skeleton copied from or a mirror of the gitlab link above? Would be good to make sure there aren't two different versions out there

dbuxton avatar Sep 27 '17 13:09 dbuxton

@JeanFred one small piece of maintenance: is our cabot-check-skeleton copied from or a mirror of the gitlab link above? Would be good to make sure there aren't two different versions out there

Actually, when building the cloudwatch plugin, @frankh mentionned to me that the skeleton is probably not such a good example anymore :/ We should re-write a skeleton.

JeanFred avatar Sep 27 '17 13:09 JeanFred

Let's just use the cloudwatch as a base and put in some really great comments? Wouldn't that be easier?

dbuxton avatar Sep 27 '17 13:09 dbuxton

Let's just use the cloudwatch as a base and put in some really great comments? Wouldn't that be easier?

I agree a living plugin that we use and maintain is a better bet than a skeleton that is bound to fall out of date.

The cloudwatch is a good one but has some advanced features (like autocompletion) that may make it look complicated. So I had a stab at a plugin for this task at https://github.com/cabotapp/cabot-check-network :)

JeanFred avatar Sep 27 '17 15:09 JeanFred

I started some bare bones documentation at http://cabotapp.com/dev/writing-check-plugins.html − basically pointing to these two plugins.

JeanFred avatar Oct 03 '17 09:10 JeanFred

@ralienpp What would you think of https://github.com/cabotapp/cabot-check-network ? Could you have a look to see if it would fit your usecase? If so then I can proceed to publish it on Pypi.

JeanFred avatar Oct 03 '17 09:10 JeanFred

It looks good.

I would like to extend it with some additional features:

  • to expect a response from the server and consider the case success if a response was received and matches the expected one
  • to send a message and expect a response to that particular message

I can write this logic, but I am clueless about the Django-related part, and how to make these additional checks optional. That is, most often people will just want the basic functionality that you've already implemented, but ocasionally they might need to do the extra things I described.

ralienpp avatar Oct 03 '17 10:10 ralienpp

This is what I mean: https://github.com/ralienpp/cabot-check-network/blob/master/cabot_check_network/models.py

The logic is there, can you add the necessary changes to make it follow the rest of the ideology concerning fields in Django-ORM?

ralienpp avatar Oct 03 '17 10:10 ralienpp

Hey, are there any news about this matter?

ralienpp avatar Nov 30 '17 22:11 ralienpp

Hey, still no progress? I started using Cabot and am quite happy with the way it keeps an eye on my infrastructure, but it would be much better if I could already use that plugin that was written earlier.

ralienpp avatar Dec 26 '17 19:12 ralienpp

Hey @ralienpp − sorry for the lag on this, end of year has been a bit crazy. I’ll try to have a look at this after holiday break, in the next two weeks.

JeanFred avatar Dec 28 '17 21:12 JeanFred

Not having checks for arbitrary ports is limiting, I'd appreciate if this was reviewed and potentially merged sometime

EDIT: Since the time of this post, I have migrated to Icinga

C0rn3j avatar Feb 14 '20 20:02 C0rn3j

Just FYI for people thinking the older plugin might be a real option. I just attempted to install the sample at https://github.com/cabotapp/cabot-check-network . That takes some work if you're doing a compose-based deployment, slight customization to the base docker image. I started with a base of cabotapp/cabot:0.11.12. Migrations/registration of the models/plugin works ok, but it uses the same icon as the "icmp" check, and makes those icons on /checks/ line-wrap (just a cosmetic issue). The bigger problem is that the plugin itself doesn't seem to actually run either on-schedule or on-demand. The rest of my checks are working ok, so I didn't dig into the worker logs to try and find the problem.

I still think the best way to solve this problem might be exposing a more general check type, but a requirement for having a whole external Jenkins with potentially dozens of jobs for port-checks is not realistic. The ansible check type described here would be awesome- https://github.com/arachnys/cabot/issues/564

mattvonrocketstein avatar Jul 03 '21 00:07 mattvonrocketstein