Home Directory Plugins Operating Systems Windows NRPE Check Windows time against AD or target

Search Exchange

Search All Sites

Nagios Live Webinars

Let our experts show you how Nagios can help your organization.

Contact Us

Phone: 1-888-NAGIOS-1
Email: sales@nagios.com

Login

Remember Me
Don't miss your chance to attend the 2014 Nagios World conference!

Don't miss your chance to attend the 2014 Nagios World Conference, Oct 13-16th. Informative Sessions, Networking, Food and Cocktails! Visit go.nagios.com/conference/ for more information or to register.


Check Windows time against AD or target

Bookmark and Share

Current Version
0.1
Last Release Date
2013-05-06
Compatible With
  • Nagios 3.x
E-mail
License
GPL
Hits
21391
Files:
FileDescription
lotp_check_time.ps1.txtlotp_check_time.ps1.txt
Check local time against a provided source or AD(autodetect) or pool.ntp.org through NRPE / nsclient++.

Windows Server that are not DC can't be tested through NTP by default.
This powershell script is executed locally and compare time with w32tm tool.

Workflow:

-If reference server is provided, it's used directly.
-If no reference server is provided:
-if domain joined:
Try to use logonserver variable, to get closest live DC.
Else auto find a DC (random) which is not itself and compare time.
Else, use pool.ntp.org
-If workgroup:
use pool.ntp.org

Provide performance data (offset jig) to get graphs
###############################################
Tested Setup:

Monitoring Box:
-Centos 6.4 x64
-Nagios 3.4.4
-check_nrpe 2.13
-Centreon 2.4.2

Windows Server:
-Windows Server 2003 / 2008 R2 / 2012
-nsclient++ 0.4.1 x64 and x86
-tested on both Core & GUI Servers

###############################################

Scripts arguments
The script accept 3 arguments:
-refTimeServer (AD find or pool.ntp.org by default)
-maxWarn (Warning if above, in second) (1 by default)
-maxError (Critical if above, in second) (5 by default)

maxWarn and maxCrit but me integer.
The time is compared in absolute, so it works either the shift is positive or negative

###############################################
Local execution example:

PS C:Program FilesNSClient++scripts> . .lotp_check_time.ps1
OK:-00.0307684s - checked against pool.ntp.org|offset=-00.0307684s;1;5;
PS C:Program FilesNSClient++scripts>

NRPE execution:
[root~]# /usr/lib64/nagios/plugins/check_nrpe -H myserver -n -c check_time -a "myPDCServer" 1 5
OK:+00.0671837s - checked against myPDCServer|'offset'=0.06718s;1;5
[root~]#

###############################################
Installation:
On Windows Servers:
-copy script in folder C:Program FilesNSClient++scripts
-enable powershell script execution without signed : Set-ExecutionPolicy RemoteSigned
-Add to nsclient.ini:
[/settings/external scripts/wrapped scripts]
check_time=lotp_check_time.ps1 -refTimeServer $ARG1$ -maxWarn $ARG2$ -maxError $ARG3$

###############################################
Configuration:

For example, on Centreon:
-Add a new command:
$USER1$/check_nrpe -H $HOSTADDRESS$ -n -c check_time -a "$ARG1$" $ARG2$ $ARG3$

Then add monitoring filling the ARGS.
For graph, enable performance data on the monitoring test