Tuesday, April 21, 2015

ntp check running as cron job

$ more check_ntpd.sh
#!/bin/sh
###################################################################################
#
#  SCRIPT: check_ntpd.sh
#  Author:  Sam
#  Date:    Fri Apr 17 15:10:02 EDT 2015
#  Usage:   ./check_ntpd.sh
#  Detail:  Include hosts that you want to check ntp status on ntp.chk file and run the script
#  $ more ntp.chk
#  server01
#  server02
#  server03
#  --------------- Change Log ----------------
#
#
###################################################################################
#
for i in `cat ntp.chk`
do
        ssh -tq $i '/usr/bin/sudo tail -50 /var/log/messages | grep -i ntp | grep "slew\|synchronized" | tail -1'
        #ssh -tq $i '/usr/bin/sudo tail -50 /var/log/messages | grep -i ntp | grep "slew\synchronized" | tail -1'
        #echo $i; ssh -tq $i /usr/sbin/ntpdate -q ntp1.ecap.cciio | grep -v stratum |  awk -F] '{print $1"]"}' | tr "\n" " "
        #echo "Checking: $i:"; ssh -tq $i /usr/sbin/ntpdate -q ntp1.ecap.cciio | grep -v stratum |  awk -F] '{print $1"]"}' | tr "\n"
" "
        #ssh -tq $i /usr/sbin/ntpdate -q ntp1.ecap.cciio | grep -v stratum |  awk -F] '{print $1"]"}' | tr "\n" " \t"
        #echo "on host: $i"
        # sudo tail --lines=40 /var/log/messages | grep -i ntp | grep "slew\|synchronized" | tail --lines=1
done

No comments:

Post a Comment