--- /dev/null
+# Register the routine with the plugin registry
+$PLUGINS{'ntp'} = \&check_ntp;
+
+# This check will check the status of the NTP service on a system. It uses
+# the ntpdate command to query the service. If the offset is more then 1
+# second, it is a yellow status. If the host is not synchonized, it is red
+# status
+
+
+sub check_ntp {
+ my( $host ) = @_;
+ my( $color, $summary, $message ) = ( "green", "Server OK", "" );
+ my( @output,$line );
+
+ $message = join(//,`$NTPDATE $host 2>&1`);
+ if ( $? != 0 ) {
+ $color = "red"; $summary = "NTP server down";
+ {
+ undef $/;
+ if ($message =~ /server (.*), stratum (.*), offset (.*), delay (.*)/) {
+ my $offset = $3; my $stratum = $2;
+ if ( $stratum eq "16" ) {
+ $color = 'yellow';
+ $summary = "Server is running, but not synchronized";
+ } elsif (abs($offset) >= 1.0) {
+ $color = "yellow"; $summary = "server is $offset seconds off";
+ }
+ }
+ }
+ }
+
+ &debug( "ntp - $host - $color, $summary" );
+ return( $color, $summary, $message );
+}
+
+
+
+1;
+