Page 1 of 1

check_nt Uptime

Posted: Fri Jan 30, 2015 11:57 am
by szkoda
Is there a way to use check_nt uptime to generate a warning/critical alert if the uptime is below a minute?

I'm trying to work out a way to monitor whether a server has rebooted or has rebooted itself.

Re: check_nt Uptime

Posted: Fri Jan 30, 2015 1:00 pm
by slansing
Well, one way to check that could be through the windows event logs, that would be pretty sure-fire. Uptime? You should be able to define min and max warning and critical levels:

http://www.nsclient.org/nscp/wiki/Check ... heckUpTime

Re: check_nt Uptime

Posted: Sun Feb 01, 2015 7:48 am
by szkoda
I use check_nt for the uptime check and tried adding "-c 1" to send me a critical alert when uptime is 1 minute but it doesn't work.

Could you tell me the correct syntax for the command please?

Also how simple is it to get nagios to look at the windows event log to detect a reboot - is there a plugin that can do this?

Re: check_nt Uptime

Posted: Sun Feb 01, 2015 10:36 pm
by Box293

Code: Select all

 UPTIME =
  Get the uptime of the machine.
  -l <unit> 
  <unit> = seconds, minutes, hours, or days. (default: minutes)
  Thresholds will use the unit specified above.
The default unit is minutes, so when you use "-c 1" you are saying only report critical if it's been up for less than a minute. If you're doing five minute service checks then it's likely you'll miss this.

Here's a machine that has been up for 20 minutes. I tried with a critical of 19 and it generates an OK status (0).

Code: Select all

Command:
./check_nt -H win2008r2-01 -p 12489 -v UPTIME -c 19

Output:
System Uptime - 0 day(s) 0 hour(s) 20 minute(s) |uptime=20

Command:
echo $?

Output:
0
Here's a machine that has been up for 21 minutes. I tried with a critical of 22 and it generates a CRITICAL status (2).

Code: Select all

Command:
./check_nt -H win2008r2-01 -p 12489 -v UPTIME -c 22

Output:
System Uptime - 0 day(s) 0 hour(s) 21 minute(s) |uptime=21

Command:
echo $?

Output:
2
szkoda wrote:Also how simple is it to get nagios to look at the windows event log to detect a reboot - is there a plugin that can do this?
NSClient++ can do this differently with different versions:
0.3.9: https://mbrownnyc.wordpress.com/2011/08 ... -nagios-2/
0.4.x: http://www.medin.name/blog/2012/03/20/r ... -nsclient/

Although personally Nagios Log Server is a good solution as the logs are stored away from the original server and can be searched later. If someone clears the event logs on the original box it doesn't matter.

Re: check_nt Uptime

Posted: Mon Feb 02, 2015 8:52 am
by szkoda
Thankyou, I've set it to 10 mins now and its working exactly as expected.

You can mark this as solved.