Skip to content

Instantly share code, notes, and snippets.

@hgdeoro
Created June 25, 2013 18:32
Show Gist options
  • Save hgdeoro/5861046 to your computer and use it in GitHub Desktop.
Save hgdeoro/5861046 to your computer and use it in GitHub Desktop.
Wraps original `check_ntp` to check NTP server by hostname instead of IP
#!/bin/bash
TMP=$(mktemp)
for IP in $(dig +short 1.south-america.pool.ntp.org) ; do
rm -f $TMP > /dev/null 2> /dev/null
/usr/lib/nagios/plugins/check_ntp -H $IP > $TMP 2>&1
EXIT_STATUS=$?
if [ "$EXIT_STATUS" -eq 0 ] ; then
break
fi
done
cat $TMP
rm -f $TMP > /dev/null 2> /dev/null
exit $EXIT_STATUS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment