[time] script to monitor connections to your ntp server

wayne wayne
Sat Nov 15 02:58:31 UTC 2003



fyi;

Here is a little bash shell script that you can use to monitor
connections to your ntp server.  It isn't anything real fancy and I'm
not sure how portable it is, but I find it kind of fun to check the
stats out every once and a while.  I have found that there is a 10-25%
increase in connections during the day vs at night, which I guess I
hadn't quite expected.  I guess I figured most people who run ntp
servers would be always on, but apparently not.



#!/bin/sh

verbose=0
if [[ "$1" = "-v" ]]
then
	verbose=1
	shift
fi

if [[ $# -ne 1 ]]
then
    echo "Usage: `basename $0` IP-address" 1>&2
    exit 1
fi

tmp=`tempfile -m 0600`

ntp_server=$1
ntp_server_cidr=`echo $ntp_server | sed "s/\.[0-9][0-9]*\.[0-9][0-9]*$//"`

ntpdc -nc monlist $ntp_server \
	| tail +3 \
	| grep -v -e "^$ntp_server_cidr" \
		  -e "^127\.0\.0\.1" \
		  -e "^10\." \
		  -e "^192\.168\." \
	| grep -e " [0-9]  *[0-9][0-9]*$" -e " [0-9][0-9]  *[0-9][0-9]*$" -e " [0-9][0-9][0-9]  *[0-9][0-9]*$" -e " 10[0-2][0-9]  *[0-9][0-9]*$" >$tmp

echo "ntp pool clients active on $ntp_server:" `wc -l <$tmp`

[[ $verbose -eq 1 ]] && cat $tmp | while read ip junk; do echo $ip | sed "s/\.[0-9][0-9]*$//"; done | sort | uniq -c | sort -nr | head -5


rm $tmp



More information about the pool mailing list