Page 1 of 1

Alert if port is active on 2 hosts

Posted: Thu Sep 30, 2021 2:55 pm
by spcmidrange
Hey Everyone

Thought i would post this question to see if anyone has any ideas. We need to monitor a port on 2 servers, but we only want an alert if port is ACTIVE on BOTH servers. If its active on only one, then that is fine as that is how it should be, but we cannot have both ports active

Anyone have any suggestions best way to monitor/alert with this?

Thanks in advance

Cheers!

Re: Alert if port is active on 2 hosts

Posted: Thu Sep 30, 2021 4:48 pm
by kfanselow
Hi Spcmidrange,

The easiest solution might be to write your own plugin in bash ( or perl or python if you prefer). Writing your own plugin isn't all that difficult and would give you some flexibility in terms of logic and behavior (e.g. - introduce vary a delay between the two ports). One of the advantages of nagios is you can use the existing plugins in your script. For example give this a try on the command line:

/usr/local/nagios/libexec/check_tcp -H 127.0.0.1 -p 22

Here are a couple of resources to help you get started:

https://exchange.nagios.org/directory/T ... pt/details

https://nagios-plugins.org/doc/guidelines.html

https://assets.nagios.com/downloads/nag ... ugins.html

Please let us know if that's helpful.

Re: Alert if port is active on 2 hosts

Posted: Fri Oct 01, 2021 1:05 pm
by spcmidrange
Thank you for your reply kfanselow.
We were already thinking that route, but thought we would put it out here to the forum to see if anyone else had other suggestions.

Cheers!

Re: Alert if port is active on 2 hosts

Posted: Mon Oct 04, 2021 4:38 pm
by benjaminsmith
Hi,

Thanks for posting this. Yeah, a wrapper script to handle the logic would be the recommended approach.

Let us know if you need anything else or if it's okay to close this out.

--Benjamin

Re: Alert if port is active on 2 hosts

Posted: Wed Nov 03, 2021 12:18 pm
by spcmidrange
Sorry for the late reply

Thank you for your suggestions. You can close this request

Cheers!