Page 1 of 1
Windows Server Uptime alert in Nagios - NSClient
Posted: Tue Apr 19, 2016 1:04 am
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.
Re: Windows Server Uptime alert in Nagios - NSClient
Posted: Tue Apr 19, 2016 1:14 am
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
Re: Windows Server Uptime alert in Nagios - NSClient
Posted: Wed Apr 27, 2016 6:46 am
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.
Re: Windows Server Uptime alert in Nagios - NSClient
Posted: Wed Apr 27, 2016 9:43 am
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:
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
Re: Windows Server Uptime alert in Nagios - NSClient
Posted: Thu Apr 28, 2016 1:25 am
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.
Re: Windows Server Uptime alert in Nagios - NSClient
Posted: Thu Apr 28, 2016 2:21 am
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:
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.
Re: Windows Server Uptime alert in Nagios - NSClient
Posted: Fri Apr 29, 2016 10:35 am
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
Re: Windows Server Uptime alert in Nagios - NSClient
Posted: Fri Apr 29, 2016 1:10 pm
by tgriep
sify_nagios, let us know if you need any more help on this.
Re: Windows Server Uptime alert in Nagios - NSClient
Posted: Mon Jun 20, 2016 6:34 am
by sify_nagios
Hi Team,
Its working now. Thanks a lot for your support.
Rgds
Srini