Forum Discussion

Abed_AL-R_26070's avatar
Abed_AL-R_26070
Icon for Nimbostratus rankNimbostratus
Apr 30, 2018

ntp delay notification

Hi

We've configured an NTP status mail notification in te crontab to send email every day at 08:00AM , and its working fine

[root@vipirion:/S1-green-P:Active:Standalone] config  crontab -e
 cron tab for root
1-59/10 * * * * /usr/bin/diskmonitor
0 */4 * * * /usr/bin/diskwearoutstat
32 04 * * * /usr/bin/updatecheck -a
32 04 21 * * /usr/bin/phonehome_activate
MAILTO=""
36 * * * * /usr/bin/copy_rrd save
00 8 * * * ntpq -np | mail -s NTP mail@mydomain.com

But we'd like to do something more advanced.. which is sending mail notification when there is X second/minutes delay in the NTP .. is it possible?

1 Reply

  • You can put in a simple script to gather the offset value, ntpdate with query (-q) should help you. And with the offset value put a condition and action on it.

    OFFSET=`ntpdate -q   |sed 's/.*\(offset\) \([0-9]\.[0-9]\+\).*/\2/'`
    

    Like this,

    OFFSET=`ntpdate -q   |sed 's/.*\(offset\) \([0-9]\.[0-9]\+\).*/\2/'`
    if [[ $OFFSET -gt 0.5 ]]; then
       
    fi