Src
|
|
No manual entry for xntpdc. xntpdc - query/control program for the Network Time Protocol daemon
Xntpdc is used to query the xntpd.8 daemon about its current state and to request changes in that state. The program may be run either in interactive mode or controlled using command line arguments. Extensive state and statistics information is available through the xntpdc interface. In addition, nearly all the configuration options which can be specified at start up using xntpd's configuration file may also be specified at run time using xntpdc.
Example:
% xntpdc
xntpdc> help
Commands available:
addpeer addrefclock addserver addtrap authinfo
broadcast clkbug clockstat clrtrap controlkey
ctlstats debug delay delrestrict disable
dmpeers enable exit fudge help
host hostnames iostats kerninfo keyid
keytype leapinfo listpeers loopinfo memstats
monlist passwd peers preset pstats
quit readkeys requestkey reset reslist
restrict showpeer sysinfo sysstats timeout
timerstats traps trustedkey unconfig unrestrict
untrustedkey version
xntpdc> host ilon
current host set to ilon
xntpdc> peers
remote local st poll reach delay offset disp
=======================================================================
*navobs1.wustl.e 129.3.20.4 1 128 377 0.06340 -0.013430 0.00851
+192.5.5.250 0.0.0.5 16 1024 0 0.00000 0.000000 16.0000
xntpdc> host yps
current host set to yps
xntpdc> peers
remote local st poll reach delay offset disp
=======================================================================
+ilon 129.3.20.252 2 1024 377 0.00107 -0.005863 0.00504
*gee 129.3.20.252 2 1024 377 0.00162 -0.024842 0.00525
xntpdc> host ilon
current host set to ilon
xntpdc> peers
remote local st poll reach delay offset disp
=======================================================================
*navobs1.wustl.e 129.3.20.4 1 128 377 0.06340 -0.013430 0.01045
+192.5.5.250 0.0.0.5 16 1024 0 0.00000 0.000000 16.0000
xntpdc> host rocky.oswego.edu
current host set to rocky.oswego.edu
xntpdc> peers
xntpdc: read: Connection refused
Problem: Find the time differences from all the machines in a network?
Idea:
% for i in yps ilon pi
> do
> /usr/local/bin/xntpdc -p $i
> done
remote local st poll reach delay offset disp
=======================================================================
+ilon 129.3.20.252 2 512 377 0.00107 -0.012174 0.00867
*gee 129.3.20.252 2 512 377 0.00162 -0.024842 0.00525
remote local st poll reach delay offset disp
=======================================================================
*navobs1.wustl.e 129.3.20.4 1 64 377 0.07159 -0.015819 0.00397
+192.5.5.250 0.0.0.5 16 1024 0 0.00000 0.000000 16.0000
remote local st poll reach delay offset disp
=======================================================================
+ilon 129.3.20.251 2 512 377 0.00107 -0.007660 0.00916
*gee 129.3.20.251 2 512 377 0.00191 -0.017478 0.00227
But I'm looking for an ouput like:
gee has problems with stratum 16 server +192.5.5.250
ilon has problems with stratum 16 server +192.5.5.250
Host with the largest gap: yps with -0.032772 sec.
The following hosts are quiet:
altair
indigo
javalab
Solution:
1 #!/bin/sh
2 #
3 # Module: xntpdiff
4
5
6 PATH=/usr/bin:/opt/gnu/bin:/usr/ucb:$PATH:$HOME/bin
7 export PATH
8
9 AWK=gawk
10 TROFF="groff"
11 PIC=gpic
12
13
14 USAGE="usage: `basename $0` [ -p -h]"
15 TMP1=/tmp/`basename $0`$$.data
16 XNTPDC=/usr/local/bin/xntpdc
17 PRINTFLAG=0
18 LIMIT="1"
19
20
21 help ()
22 {
23 cat << EOF
24
25 Module: xntpdiff
26 Description: askes all cs machines with xntpdc
27 for the time differences.
28 Options: -p generates postScript file
29 -h help
30 EOF
31 }
32
33 fatal ()
34 {
35 echo "`basename $0:` $1" >&2
36 shift
37 while [ $# -gt 1 ]
38 do
39 echo " $1" >&2
40 shift
41 done
42 exit $1
43 }
44
45 create ()
46 {
47 echo "-- $1 --"
48 if [ -f "$1" ]
49 then
50 fatal "$0: file $1 exists!!" 2
51 else
52 touch $1 2>/dev/null;
53 if [ $? -gt 0 ]
54 then
55 fatal "$0: cannot create $1!" 1
56 fi
57 fi
58 }
59
60 print_info ()
61 {
62 $AWK '
63 BEGIN {i=0;
64 print "\n";
65 max = 0}
66 NF == 1 {host = $1;
67 next}
68 NF == 2 {quiet[i]=host;
69 i=i+1;
70 next}
71 (max * max < $3 * $3 ) {
72 max = $3;
73 maxhost = host}
74 $4 > 15 {printf ("%s has problems with stratum %d server %s \n.br\n",host, $1, $2);
75 next}
76 ( $3 <= -'$LIMIT' || $3 >= '$LIMIT' ) {
77 # ( $3 <= -1 || $3 >= 1 ) {
78 printf ("%s has %f sec. time diff. to stratum %d server %s \n\n",host, $3, $1, $2);
79 next}
80 END {printf ("\n\nHost with the largest gap: %s with %f sec.", maxhost, max);
81 printf ("\n\nThe following hosts are quiet:");
82 for ( l in quiet )
83 print "\n ", quiet[l];
84 }' $1
85 }
86
87 while [ $# -gt 0 ]
88 do
89 case "$1"
90 in -p) PRINTFLAG=1
91 ;; -h) help; exit 1;
92 ;; *) echo "$USAGE"; exit 1;
93 esac
94 shift
95 done
96
97 create $TMP1
98
99 echo "asking ..."
100 for i in `gethostname "inf"`
101 do
102 echo "$i" >> $TMP1
103 echo $i
104 $XNTPDC -p "$i" 2> /dev/null | \
105 $AWK ' $1 == "remote" { next } # Output of the columns
106 # stratumnr. remote offset disp
107 NF > 1 { print $3, $1, $7, $8 }
108 END { if (NR ==0) {print " is quiet."}} ' \
109 >> $TMP1
110
111 done
112
113 echo .
114
115 case $PRINTFLAG
116 in 0) print_info $TMP1
117 rm $TMP1
118 ;; 1)
119 ( cat << EOF
120 .G1
121 frame invis ht 1 wid 3
122 label bottom "Time difference to the stratum servern " right .5
123 .G2
124 .G1
125 frame solid ht 3 wid 4
126 ticks bottom off
127 label left "Sec. " left .3
128 label bottom " xntpdiff output from: `date` "
129 EOF
130
131 $AWK '
132 NF == 1 {next}
133 NF == 2 {next}
134 # Offset-Werte fuer Graphik
135 {print $3} ' $TMP1
136
137 echo .G2
138
139 print_info $TMP1 ) | \
140 grap -l > x.pic
141 ## grap -l | $PIC -D | $TROFF | lpr
142 case $?
143 in 0) echo "Printing ..."
144 ;; 1) fatal "grap -l | $PIC -D | $TROFF | lpr failed!" 1
145 esac
146 rm $TMP1
147 ;; *) exit 1;
148 esac
Src
|
|
Last modified: 08/May/98 (11:53)