Skip to content

Instantly share code, notes, and snippets.

@logikal
Created November 21, 2018 03:24

Revisions

  1. logikal created this gist Nov 21, 2018.
    15 changes: 15 additions & 0 deletions ntp_drift_reporter.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    #!/usr/bin/env bash
    # finds the maximum clock drift in the last 30 days
    # using the stats files kept in /var/log/ntpstats

    # We need somewhere temporary to keep our concatenated results
    TMPFILE=$(mktemp) || exit 1

    FILELIST=$(find /var/log/ntpstats/ -mtime -31 -type f)

    cut -d' ' -f 5 $FILELIST| sort -g > $TMPFILE

    MIN_OFFSET=$(head -n 1 $TMPFILE)
    MAX_OFFSET=$(tail -n 1 $TMPFILE)

    echo "$MIN_OFFSET $MAX_OFFSET"