Page tree

Welcome to FreeSoftwareServers Confluence Wiki

Skip to end of metadata
Go to start of metadata

Note: XYMon alteady can do NTP checks, and timedatectl isn't on old servers, but I like this output better. If you put an NTP tag in xymon/hosts.cfg it will use IT'S test and not this one, if you do that, you'd need to drop that test and re-do this one.

Install NTP

Ubuntu 14 :

cat << 'EOL' >/usr/lib/xymon/client/ext/ntp.sh
#!/bin/sh

COLUMN=ntp                             
COLOR=green                             
MSG="timedatectl | grep {TimeZone,NTP Enabled,NTP Synchronized}"  

#In this test, if var = empty = RED
var="$(timedatectl | grep "Timezone: America/New_York")"
var1="$(timedatectl | grep "NTP enabled: yes")"
var2="$(timedatectl | grep "NTP synchronized: yes")"
cmd="$(timedatectl && echo "" && ntpq -p)"

if [ -z "$var" ] || [ -z "$var1" ]  || [ -z "$var2" ]

then

COLOR=red
MSG="${MSG}
FAILED
"${cmd}"
"
else

MSG="${MSG}
SUCCESS
"${cmd}"
"
fi

# Leave the rest of script alone
# Tell Xymon about it
$XYMON $XYMSRV "status $MACHINE.$COLUMN $COLOR `date`

${MSG}
"

exit 0
EOL


chown xymon:xymon /usr/lib/xymon/client/ext/ntp.sh
chmod 777 /usr/lib/xymon/client/ext/ntp.sh
 

cat << 'EOL' >/etc/xymon/clientlaunch.d/ntp.cfg
[ntp]
 ENVFILE $XYMONCLIENTHOME/etc/xymonclient.cfg
 CMD $XYMONCLIENTHOME/ext/ntp.sh
 LOGFILE $XYMONCLIENTHOME/logs/ntp.log
 INTERVAL 15m
EOL
 
/usr/lib/xymon/client/bin/xymoncmd /usr/lib/xymon/client/ext/ntp.sh

service xymon-client restart

Ubuntu 16:

cat << 'EOL' >/usr/lib/xymon/client/ext/ntp.sh
#!/bin/sh

COLUMN=ntp                             
COLOR=green                             
MSG="timedatectl | grep {TimeZone,NTP Enabled,NTP Synchronized}"  

#In this test, if var = empty = RED
var="$(timedatectl | grep "Time zone: America/New_York")"
var1="$(timedatectl | grep "Network time on: yes")"
var2="$(timedatectl | grep "NTP synchronized: yes")"
cmd="$(timedatectl && echo "" && ntpq -p)"

if [ -z "$var" ] || [ -z "$var1" ]  || [ -z "$var2" ]

then

COLOR=red
MSG="${MSG}
FAILED
"${cmd}"
"
else

MSG="${MSG}
SUCCESS
"${cmd}"
"
fi

# Leave the rest of script alone
# Tell Xymon about it
$XYMON $XYMSRV "status $MACHINE.$COLUMN $COLOR `date`

${MSG}
"

exit 0
EOL


chown xymon:xymon /usr/lib/xymon/client/ext/ntp.sh
chmod 777 /usr/lib/xymon/client/ext/ntp.sh
 

cat << 'EOL' >/etc/xymon/clientlaunch.d/ntp.cfg
[ntp]
 ENVFILE $XYMONCLIENTHOME/etc/xymonclient.cfg
 CMD $XYMONCLIENTHOME/ext/ntp.sh
 LOGFILE $XYMONCLIENTHOME/logs/ntp.log
 INTERVAL 15m
EOL
 
/usr/lib/xymon/client/bin/xymoncmd /usr/lib/xymon/client/ext/ntp.sh

service xymon-client restart

CentOS

  • See Install Script for CentOS 7
cat << 'EOL' >/usr/share/xymon-client/ext/ntp.sh
#!/bin/sh

COLUMN=ntp                             
COLOR=green                             
MSG="timedatectl | grep {TimeZone,NTP Enabled,NTP Synchronized}"  

#In this test, if var = empty = RED
var="$(timedatectl | grep "Time zone: America/New_York")"
var1="$(timedatectl | grep "NTP enabled: yes")"
var2="$(timedatectl | grep "NTP synchronized: yes")"
cmd="$(timedatectl && echo "" && ntpq -p && echo "" && ntpstat)"

if [ -z "$var" ] || [ -z "$var1" ]  || [ -z "$var2" ]

then

COLOR=red
MSG="${MSG}
FAILED
"${cmd}"
"
else

MSG="${MSG}
SUCCESS
"${cmd}"
"
fi

# Leave the rest of script alone
# Tell Xymon about it
$XYMON $XYMSRV "status $MACHINE.$COLUMN $COLOR `date`

${MSG}
"

exit 0
EOL


chown xymon:xymon /usr/share/xymon-client/ext/ntp.sh
chmod 777 /usr/share/xymon-client/ext/ntp.sh
 

cat << 'EOL' >/etc/xymon-client/client.d/ntp.cfg
[ntp]
 ENVFILE $XYMONCLIENTHOME/etc/xymonclient.cfg
 CMD $XYMONCLIENTHOME/ext/ntp.sh
 LOGFILE $XYMONCLIENTHOME/logs/ntp.log
 INTERVAL 15m
EOL
 
/usr/share/xymon-client/bin/xymoncmd /usr/share/xymon-client/ext/ntp.sh

service xymon-client restart
  • No labels