Notification when service _IS_ running?

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
pbernardi
Posts: 20
Joined: Thu Apr 08, 2010 11:57 am

Notification when service _IS_ running?

Post by pbernardi »

I have a server running IIS. It is setup to check between 6am and 5:55pm and it notifies me when it is down.

I have a job that shuts down IIS at 6pm because I do not want it to run overnight. Is there a way to setup a monitor that checks that a service is down and to send a notification if the service is running?

Thanks in advance.
mmestnik
Posts: 972
Joined: Mon Feb 15, 2010 2:23 pm

Re: Notification when service _IS_ running?

Post by mmestnik »

Notifications are sent during state changes and there are notifications for "This host is now up". So you could manage this service backwards.

There is another option, it's more difficult but the result should be cleaner. Wrap your check command in a inverting script, like so:

Code: Select all

#!/bin/bash
check_command "$@"
ret=$?
[ $ret == 0 ] && exit 2
[ $ret == 1 ] && exit 1
[ $ret == 2 ] && exit 0
# any exit code other then 3 should be an error, though we should pass it on.  That is this is "exit 3".
exit $ret
pbernardi
Posts: 20
Joined: Thu Apr 08, 2010 11:57 am

Re: Notification when service _IS_ running?

Post by pbernardi »

Ok, lets pretend that I only know how to use the GUI config manager. :D
How would I go about using that script in a check command?
mmestnik
Posts: 972
Joined: Mon Feb 15, 2010 2:23 pm

Re: Notification when service _IS_ running?

Post by mmestnik »

As I'd always be unaware of your current skill level and after many years of tech support I've discovered that it's better to confuse the confusable then it is to insult a God Like Entity of All Things Technical(GLEATT).

That said if you choose the High Road you should look into crossing this learning curve, you ready?
http://en.wikipedia.org/wiki/Secure_Shell
http://www.chiark.greenend.org.uk/~sgtatham/putty/
http://filezilla-project.org/

Welcome to the wonder full world of the club(a bash pun of course). Now, how to properly use this tool.
http://www.gnu.org/software/bash/manual/bashref.html
http://nagiosplug.sourceforge.net/devel ... lines.html
http://exchange.nagios.org/directory/Do ... ns/details

If you do things correctly you might be able to skip right to the end here, fix up(the second line needs a bit of editing) what I gave you for your check command and then upload it using the GUI. Though I'd think your chances for success would be greatly hindered if your only tool was the GUI.

This should explain some of the Voodoo(actually it's an example right from the manual) on that second line.
http://www.gnu.org/software/bash/manual ... Parameters

"Unix in a Nutshell" is one of the most powerful books you will ever have around. It leasts in alphabetical order every command and it's usage. I'd say it averages 75% of a page for each command with some taking 3 pages. What I did was read the first sentence or so of each command and then afterwards I was able to seek right to the command I needed to use.
pbernardi
Posts: 20
Joined: Thu Apr 08, 2010 11:57 am

Re: Notification when service _IS_ running?

Post by pbernardi »

ok, I am very familiar with ssh, putty and ftp. Unix shell scripting is where I am lacking...
I'll take a look and see what I can learn.
mmestnik
Posts: 972
Joined: Mon Feb 15, 2010 2:23 pm

Re: Notification when service _IS_ running?

Post by mmestnik »

You could use whatever language you are familiar with, I was just able to type up a shell script faster then a C program.
pbernardi
Posts: 20
Joined: Thu Apr 08, 2010 11:57 am

Re: Notification when service _IS_ running?

Post by pbernardi »

Well, I have successfully avoided learning scripting. ;) I did a little research and found out that this is possible with some modification to the NSCClient++ and using check_npre.

I setup the following command and named it 'CheckServiceState' : $USER1$/check_nrpe -H $HOSTADDRESS$ -p 5666 -c CheckServiceState -a ShowAll $ARG1$ $ARG2$=stopped

When I setup a new check with the Core Config Manager and want to check a service that is running i use ARG1, if I want to check that a service is not running I use ARG2.

Details can be found using the links below:
http://nsclient.org/nscp/wiki/doc/usage/nagios/nrpe
http://nsclient.org/nscp/wiki/CheckServiceState

One last question that have about this, though. I wanted this to run overnight so for the Time Period I specified "00:00-05:55,18:05-24:00". That should work, yes?
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Notification when service _IS_ running?

Post by Box293 »

Using NSClient you can create custom scripts using any language you are familiar with. Batch, VBS, PowerShell can all be issued via check_nrpe.

There are example scipts in the NSClient++\scripts folder on the windows host.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked