arachnys / cabot

Self-hosted, easily-deployable monitoring and alerts service - like a lightweight PagerDuty
MIT License
5.6k stars 594 forks source link

Network port checking plugin #545

Open ralienpp opened 7 years ago

ralienpp commented 7 years ago

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.

JeanFred commented 7 years ago

@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 ? :)

ralienpp commented 7 years ago

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.

JeanFred commented 7 years ago

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 commented 7 years ago

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

dbuxton commented 7 years ago

@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

JeanFred commented 7 years ago

@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.

dbuxton commented 7 years ago

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

JeanFred commented 7 years ago

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 commented 7 years ago

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

JeanFred commented 7 years ago

@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.

ralienpp commented 7 years ago

It looks good.

I would like to extend it with some additional features:

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 commented 7 years ago

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 commented 6 years ago

Hey, are there any news about this matter?

ralienpp commented 6 years ago

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.

JeanFred commented 6 years ago

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.

C0rn3j commented 4 years ago

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

mattvonrocketstein commented 3 years ago

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