Windows Server Uptime alert in Nagios - NSClient

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
sify_nagios
Posts: 54
Joined: Thu Aug 20, 2015 8:01 am

Windows Server Uptime alert in Nagios - NSClient

Post by sify_nagios »

Hi Team,

I would like to get alert whenever uptime of windows server is less than 2 hours or specified.
I can see nagios xi fetching the Uptime value by using below command.

/usr/local/nagios/libexec/check_nt -H 172.20.30.13 -s "" -p 12489 -v UPTIME

But it does trigger alerts.

Kindly guide us to achieve the same.

Thanks
Srini.
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Windows Server Uptime alert in Nagios - NSClient

Post by Box293 »

Code: Select all

/usr/local/nagios/libexec/check_nt --help
Usage:
check_nt -H host -v variable [-p port] [-w warning] [-c critical]
[-l params] [-d SHOWALL] [-u] [-t timeout]

Options:
-w, --warning=INTEGER
Threshold which will result in a warning status
-c, --critical=INTEGER
Threshold which will result in a critical status

UPTIME =
Get the uptime of the machine.
-l <unit>
<unit> = seconds, minutes, hours, or days. (default: minutes)
Thresholds will use the unit specified above.

Code: Select all

/usr/local/nagios/libexec/check_nt -H 172.20.30.13 -s "" -p 12489 -v UPTIME -w 120
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
sify_nagios
Posts: 54
Joined: Thu Aug 20, 2015 8:01 am

Re: Windows Server Uptime alert in Nagios - NSClient

Post by sify_nagios »

Hi,

The given command doesn't return critical or warning whenever the server is down.
It simply display the uptime of server.

Code: Select all

[root@Nagiosprimary perfdata]# /usr/local/nagios/libexec/check_nt -H 192.168.50.200 -p 12489 -v UPTIME -w 120
System Uptime - 0 day(s) 0 hour(s) 6 minute(s) |uptime=6
You have new mail in /var/spool/mail/root
[root@Nagiosprimary perfdata]#
I need the uptime should send a notification and alert.

Kindly guide us.

Regards
Srini.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Windows Server Uptime alert in Nagios - NSClient

Post by lmiltchev »

Did you include the warning or the critical threshold in your command? The state of the service will change, and you will receive notification if the value is below the threshold...

The following command should give you "OK" state (no thresholds specified):

Code: Select all

/usr/local/nagios/libexec/check_nt -H 192.168.50.200 -p 12489 -v UPTIME
You can check it out by running:

Code: Select all

echo $?
This will give you WARNING:

Code: Select all

/usr/local/nagios/libexec/check_nt -H 192.168.50.200 -p 12489 -v UPTIME -w 120
and this - CRITICAL:

Code: Select all

/usr/local/nagios/libexec/check_nt -H 192.168.50.200 -p 12489 -v UPTIME -c 120
You check command should look like this (if you want to receive a WARNING notification)

Code: Select all

check_command			check_xi_service_nsclient!password!UPTIME!-w 120
Be sure to check out our Knowledgebase for helpful articles and solutions!
sify_nagios
Posts: 54
Joined: Thu Aug 20, 2015 8:01 am

Re: Windows Server Uptime alert in Nagios - NSClient

Post by sify_nagios »

Hi,

Code which i have mentioned in the earlier reply was taken from CLI.
[root@Nagiosprimary perfdata]# /usr/local/nagios/libexec/check_nt -H 192.168.50.200 -p 12489 -v UPTIME -w 120
System Uptime - 0 day(s) 0 hour(s) 6 minute(s) |uptime=6
You have new mail in /var/spool/mail/root
[root@Nagiosprimary perfdata]#
It doesn't return the warning or critical even though the server uptime below threshold and threshold mentioned.
Kindly check and let us know whether it will return state in CLI or not.

Note: I haven't tested it in GUI since not succeed on CLI.

Regards
Srini.
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Windows Server Uptime alert in Nagios - NSClient

Post by Box293 »

sify_nagios wrote:It doesn't return the warning or critical even though the server uptime below threshold and threshold mentioned.
Kindly check and let us know whether it will return state in CLI or not.
Execute the command above.
Then immediately execute this command:

Code: Select all

echo $?
This will return either 0, 1, 2, 3
These codes are what informs Nagios as to the state of the check.

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

The words on the screen are just there for us humans to see what the data is. Unfortunately in this case it does not say "WARNING", but that's not important as it is the exit code which tells Nagios what the state is.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
WillemDH
Posts: 2320
Joined: Wed Mar 20, 2013 5:49 am
Location: Ghent
Contact:

Re: Windows Server Uptime alert in Nagios - NSClient

Post by WillemDH »

You could consider using check_nrpe which has better output and more options. Check out Troy's site here: http://sites.box293.com/nagios/guides/c ... cks/uptime which explains how to do that.
For example if you say:

Code: Select all

check_nrpe -H 192.168.142.1 -t 30 -c Check_Uptime -a show-all 'warning=uptime<1d' 'critical=uptime<1d'
Output:

Code: Select all

critical(uptime: 01:39h, boot: 2015-Jan-06 05:38:27 (UTC))|'uptime'=5980s;86400;86400
Grtz

Willem
Nagios XI 5.8.1
https://outsideit.net
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Windows Server Uptime alert in Nagios - NSClient

Post by tgriep »

sify_nagios, let us know if you need any more help on this.
Be sure to check out our Knowledgebase for helpful articles and solutions!
sify_nagios
Posts: 54
Joined: Thu Aug 20, 2015 8:01 am

Re: Windows Server Uptime alert in Nagios - NSClient

Post by sify_nagios »

Hi Team,

Its working now. Thanks a lot for your support.

Rgds
Srini
Locked