scripts/monitoring/check_ntppool_score

46 lines
727 B
Text
Raw Normal View History

2017-09-10 15:29:47 +02:00
#!/bin/sh
2018-03-06 23:02:21 +01:00
OPTIND=1
2017-09-10 15:29:47 +02:00
2018-03-06 23:02:21 +01:00
while getopts "H:" opt; do
case "$opt" in
H)
hostname=$OPTARG
;;
esac
done
shift $((OPTIND-1))
[ "$1" = "--" ] && shift
if [ -z $hostname ]
then
echo "ERROR: please provide IP with -H: $0 -H <IP>"
exit 3
fi
score=`curl --silent "http://www.pool.ntp.org/scores/$hostname/log?limit=1" 2>&1 | tail -1 | cut -f 5 -d ","`
2017-09-10 15:29:47 +02:00
if [ $score == "" ]
then
echo "UNKNOWN: unable to parse result"
exit 3
fi
2018-03-06 21:46:43 +01:00
result=`echo "$score >= 20" | bc`
2017-09-10 15:29:47 +02:00
if [ $result == 1 ]
then
echo "OK: score=$score|score=$score;;;;"
exit 0
2018-03-06 21:46:43 +01:00
fi
result=`echo "$score > 10" | bc`
if [ $result == 1 ]
then
echo "WARNING: score=$score|score=$score;;;;"
exit 1
2017-09-10 15:29:47 +02:00
else
echo "CRITICAL: score=$score|score=$score;;;;"
exit 2
fi