alert when a service like POP goes UP

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
rmoreau
Posts: 2
Joined: Fri May 22, 2015 8:03 am

alert when a service like POP goes UP

Post by rmoreau »

Hello, is it possible to put a alert when a services that is already down (exemple POP on exchange or a unused port) goes UP, at this time a notification is sent.

Thanks for helping me
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: alert when a service like POP goes UP

Post by rkennedy »

Yes, let's assume that you have a check using check_tcp on port 80 with 127.0.0.1 as an easy reference.

Code: Select all

[root@localhost libexec]# ./check_tcp -H 127.0.0.1 -p 80
TCP OK - 0.000 second response time on 127.0.0.1 port 80|time=0.000199s;;;0.000000;10.000000
[root@localhost libexec]# echo $?
0
Everything is OK, and the echo $? reports back a 0 (which Nagios takes as an OK exit code)

Now, lets shut down apache and see what happens.

Code: Select all

[root@localhost libexec]# service httpd stop
Stopping httpd:                                            [  OK  ]
[root@localhost libexec]# ./check_tcp -H 127.0.0.1 -p 80
connect to address 127.0.0.1 and port 80: Connection refused
[root@localhost libexec]# echo $?
2
The echo $? reports back a 2, which means this would show as a CRITICAL status in Nagios.

Now, we just need to use the negate plugin to switch around these options, so that OK -> CRITICAL, and CRITICAL -> OK. This is due to the backwardness of the check.

Code: Select all

[root@localhost libexec]# ./negate --ok=CRITICAL --critical=OK ./check_tcp -H 127.0.0.1 -p 80
connect to address 127.0.0.1 and port 80: Connection refused
[root@localhost libexec]# echo $?
0
You can see even though it's critical, the exit code is returning as 0 so Nagios will expect this to be OK.

Now, lets turn apache back on and see what it reports -

Code: Select all

[root@localhost libexec]# service httpd start
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName
                                                           [  OK  ]
[root@localhost libexec]# ./negate --ok=CRITICAL --critical=OK ./check_tcp -H 127.0.0.1 -p 80
TCP OK - 0.000 second response time on 127.0.0.1 port 80|time=0.000272s;;;0.000000;10.000000
[root@localhost libexec]# echo $?
2
Now, we can see that when port 80 is open on the local machine, it is indeed reporting a CRITICAL response (2). We've flipped around the use case for Nagios by simply using the negate plugin.

Hopefully that helps explain the process.
Former Nagios Employee
rmoreau
Posts: 2
Joined: Fri May 22, 2015 8:03 am

Re: alert when a service like POP goes UP

Post by rmoreau »

hey yes good idea thks a lot

Bravo lol
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: alert when a service like POP goes UP

Post by eloyd »

As a side note, you can do some wonderful things with BPI and negate. For instance, you can group a set of things that you DONT want to see happen into a BPI virtual service, then use the negate option on the virtual service so that you'll be notified if ANY of them occur or if a certain PERCENTAGE of them occur.

Negate is your friend.
Trust the computer.
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: alert when a service like POP goes UP

Post by rkennedy »

eloyd wrote:As a side note, you can do some wonderful things with BPI and negate. For instance, you can group a set of things that you DONT want to see happen into a BPI virtual service, then use the negate option on the virtual service so that you'll be notified if ANY of them occur or if a certain PERCENTAGE of them occur.

Negate is your friend.
Trust the computer.
I didn't even think of that, I bet that works well when you have end users to deal with! :)

@rmoreau - no problem! Are we good to mark this one as resolved?
Former Nagios Employee
Locked