#!/bin/bash
#
#written by Fabio "krusty" Pardi on June 05, 2007 (1bit@email.it)
#version 0.1 helps and changes are permitted to anyone except Silvio Berlusconi, who does not hate this man??
#tested on Red Hat Enterprise 3

#Il plugin originale - (scritto da Thomas Sluyter (nagios@kilala.nl)) - fungeva  su solaris ma non sul mio pinguino... L'ho cambiato riducendo il codice all'osso e mettendeci del mio. niente di che, ma funziona.. :p
# The original plugin - (written by Thomas Sluyter (nagios@kilala.nl)) - was working well on Solaris, but not on my penguin! so... i changed it.. something stupid but working for me!   :p

# You may have to change this, depending on where you installed your
# Nagios plugins
PATH="/usr/bin:/usr/sbin:/bin:/sbin"
LIBEXEC="/usr/local/nagios/libexec"
. $LIBEXEC/utils.sh

check_process()
{
	PROCESS="0"

#subsitute the _YOUR_SERVER_ADDRESS_! with your server's IP

if [ `/usr/sbin/ntpdate -q _YOUR_SERVER_ADDRESS_  | grep "time server" | wc -l` -eq 1  ]; then PROCESS=1;fi

	if [ $PROCESS -eq 0 ]; then

echo "NTP-S NOK - Time not in synch with higher Stratum."
                exitstatus=$STATE_CRITICAL
                exit $exitstatus
	

else 


echo "NTP-S OK - Everything running like it should"
exitstatus=$STATE_OK

#REMOVE_ME_IF_YOU_WANT   i'm just a supporter of DuffMan and Simpsons!!!
echo " Oh yea! Who does not like DuffMan?????... it's time to drink a beer, dude!"
exit $exitstatus

fi
}

check_process

