Woops, line 5 should be: LOCAL=`ntpq -c rv $1 | sed 's/, /\n/g' | grep "leap="`
On Thursday, January 3, 2013 1:49:06 PM UTC-8, [email protected] wrote: > A bit ugly, but this should do the trick in bash: > > > > #!/bin/bash > > > > [[ -n "$1" ]] || { echo "Tests NTP server for pending leap second > insertion."; echo "Usage: $0 <server>"; exit ; } > > > > LOCAL=`ntpq -c rv $n | sed 's/, /\n/g' | grep "leap="` > > case $LOCAL in > > "leap=01"*) echo -e "\tWARNING: Pending leap found on: $1" ;; > > "leap=10"*) echo -e "\tWARNING: Pending leap found on: $1" ;; > > *) echo -e "\tPending leap not foud on: $1"; exit ;; > > esac > > > > echo "Testing Upstream Servers:" > > > > for n in `ntpq -c assoc $1 | tail -n+4 | awk '{print $2}'`; do { > > ASSOC=`ntpq -c "rv $n" $1 | sed 's/, /\n/g' | grep leap` > > case $ASSOC in > > "leap=01"*) echo -e "\tWARNING: Pending leap second found on > associated server: $n" ;; > > "leap=10"*) echo -e "\tWARNING: Pending leap found on > associated server: $n" ;; > > *) echo -e "\tPending leap not foud on assicated server: $n" > ;; > > esac > > } > > done > > > > On Wednesday, January 2, 2013 11:37:47 PM UTC-8, David Taylor wrote: > > > On 02/01/2013 20:34, [email protected] wrote: > > > > > > [] > > > > > > > David, would it be possible to get the flags your sending to ntpq to > > > check for the leap second flag in your program so we can run them using > > > ntpq on a linux system ? I'd like to setup a monitor for this condition > > > in our environment. > > > > > > [] > > > > > > ======================================================== > > > > > > > > > > > > In essence: > > > > > > > > > > > > 1: send 'ntpq -c rv <test-server>' > > > > > > 2: look for 'leap=01' or 'leap=10' > > > > > > 3: leap is pending if either is found > > > > > > 4: send 'ntpq -c assoc <test-server>' > > > > > > 5: for each assoc-id send: 'ntpq -c "rv <assoc-id>" <test-server>' > > > > > > 6: parse the result as in (2) and (3) > > > > > > > > > > > > I hope that helps, and that I haven't misread my own code! The commands > > > > > > are executed on a Windows system. If you come up with the same in a > > > > > > script for another OS I could add it to my Web page to help others. > > > > > > -- > > > > > > Cheers, > > > > > > David > > > > > > Web: http://www.satsignal.eu _______________________________________________ questions mailing list [email protected] http://lists.ntp.org/listinfo/questions
