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
alert when a service like POP goes UP
Re: alert when a service like POP goes UP
Yes, let's assume that you have a check using check_tcp on port 80 with 127.0.0.1 as an easy reference.
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.
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.
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 -
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.
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
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
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
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
Hopefully that helps explain the process.
Former Nagios Employee
Re: alert when a service like POP goes UP
hey yes good idea thks a lot
Bravo lol
Bravo lol
Re: alert when a service like POP goes UP
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.
Negate is your friend.
Trust the computer.
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
Re: alert when a service like POP goes UP
I didn't even think of that, I bet that works well when you have end users to deal with!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.
@rmoreau - no problem! Are we good to mark this one as resolved?
Former Nagios Employee