Windows

Check Windows Time Offset (check_windows_time.bat)

Description:

This plugin will check a windows system against a specified time source. Meant to be used via check_nrpe.

To make installation simple it is just a .bat file that is basically a glorified nagios wrapper for w32tm. Tested on Windows 2k3/2k8/2k8r2. While a bit raw, it does return some common errors (i.e. – server not found)

A windows domain controller can used as a time source as well as a other NTP servers.

Current Version

Last Release Date

July 23, 2012

Compatible With

License

GPL


Project Files
Project Notes
To get the plugin going, copy the check_windows_time.bat file to your nagios client /scripts folder on the Windows machine and define the script in your nsc.ini. Don't forget to enable command arguments if you wish to pass the ntp source and other arguments from check_nrpe. check_windows_time.bat - Nagios plugin that checks time offset against a specified ntp server. Usage: check_windows_time.bat timeserver warning critical * warning and critical in seconds C:>check_windows_time.bat pool.ntp.org 180 300 OK: Time is -01.0821202s from pool.ntp.org|'Offset'=01s;180;300;0 $ /usr/local/nagios/libexec/check_nrpe -H my-server.domain.local -c check_windows_time -a pool.ntp.org 180 300 OK: Time is +00.0120138s from pool.ntp.org|'Offset'=00s;180;300;0
Reviews (8) Add a Review
Question urgently help needed
by Morello, September 30, 2016

Hi all, This script works great but i can not see check_time on nagios server when i open the gui, i should be able to see it as listed services. I can only see modules like checkdisk, currentload, check, checkservice, checkprocess etc these are all listed under modules and set to 1 in nsclient.ini file. Any ideas? Thanks in advance. BR,



Works great, thanks!
by scubacat3, April 30, 2015

To allow arguments from Windows, add this section above the definition in nsclient.ini: [/settings/external scripts] allow arguments = 1



Noob install instructions
by dknigh, March 31, 2015

I am a Noob and here is my instructions for getting it to work. This will hard code the arguments ( I am still trying to figure out why I get errors passing arguments ) Tested on NSClient++ 0.4.1.101 on client machine 1. Open C:Program FilesNSClient++nsclient.ini add to the bottom: [/settings/external scripts/wrapped scripts] ; check_windows_time - check_windows_time = check_windows_time.bat pool.ntp.org 30 10 2. Copy check_windows_time.bat to C:Program FilesNSClient++scripts 3. Restart NSClient++ service 4. open command prompt Navigate to script folder Check with this command(check_windows_time.bat pool.ntp.org 30 10) C:Program FilesNSClient++scripts>check_windows_time.bat pool.ntp.org 30 10 You should see C:Program FilesNSClient++scripts>check_windows_time.bat pool.ntp.org 30 10 OK: Time is -00.0274625s from pool.ntp.org|'Offset'=00s;30;10;0 On Nagios server 1. Go to Nagios server and setup the check without arguments ( they are hard coded in the nsclient.ini file on client machine ). $USER1$/check_nrpe -H $HOSTADDRESS$ -p 5666 -c check_windows_time To test from nagios server in Putty cd /usr/local/nagios/libexec ./check_nrpe -H YOUR_SERVER_TO_CHECK -c check_windows_time You should see OK: Time is -00.1961396s from ralpdc01|'Offset'=0s;30;10;0 I hope this helps If anyone has the Noob steps to allow arguments to be passed from Nagios server to client that could be added to this it would be great if you shared it. Thanks.



Do not round numbers
by fmdupre, October 31, 2014

I made the following change to no longer be rounding the numbers a point lower to 1. Do not round numbers for /f "tokens=*" %%t in ('w32tm /stripchart /computer:%time_server% /samples:1 /dataonly') do set output=%%t if not "x%output:0x80072af9=%"=="x%output%" goto host_error if not "x%output:0x800705B4=%"=="x%output%" goto comm_error if not "x%output:error=%"=="x%output%" goto unknown_error if not "x%output:)=%"=="x%output%" goto unknown_error set time_org=%output:*, =% set time=%time_org% rem set time=%time_org:~1,-9%



Working!!
by felawx, October 31, 2014

Thank you, worked perfectly!



missing check windows version
by arigaud, July 31, 2014

Excellent ! Add check windows version, tested ont w2k, w2003, 2008, 7 (not in xp) for /f "tokens=2 delims=[]" %%x in ('ver') do set cmdver=%%x set cmdver=%cmdver:Version =% for /f "tokens=1,2,3* delims=." %%g in ("%cmdver%") do ( set major=%%g set minor=%%h set build=%%i ) rem Windows 3.1,95,95 OSR2,NT 4.0,98,98 SE,ME IF %major% LEQ 4 goto ver_false rem Windows 2000 echo %cmdver% | FINDSTR /C:"5.0" > nul IF %ERRORLEVEL% EQU 0 goto ver_false :ver_false echo UNKNOWN: OS Version not supported [%cmdver%] exit /b 3 heklp source : http://ss64.org/viewtopic.php?pid=3151#p3151



Set NSC.INI
by pestigarribia, November 30, 2012

This was very useful, only one note that I have to do: NSC.INI I have to enable: ; Script to check external scripts and/or internal aliases. CheckExternalScripts.dll



Works for me ! Thanks !
by staso, September 30, 2012

Works for me ! Thanks !



Add a Review

You must be logged in to submit a review.

Thank you for your review!

Your review has been submitted and is pending approval.

Recommend

To:


From:


Thank you for your recommendation!

Your recommendation has been sent.

Project Stats
Rating
4.8 (10)
Favorites
3
Views
100,030