xref: /freebsd/contrib/ntp/scripts/stats/psummary.awk (revision f4b37ed0f8b307b1f3f0f630ca725d68f1dff30d)
1# program to scan peer_summary file and produce summary of daily summaries
2#
3# usage: awk -f psummary.awk peer_summary
4#
5# format of input records
6# peerstats.19960706
7#        ident     cnt     mean     rms      max     delay     dist     disp
8# ==========================================================================
9# 140.173.112.2     85   -0.509    1.345    4.606   80.417   49.260    1.092
10# 128.4.1.20      1364    0.058    0.364    4.465    3.712   10.540    1.101
11# ...
12#
13# format of output records (actual data from rackety.udel.edu)
14#        host     days     mean       rms       max   >1  >5 >10 >50
15# ==================================================================
16# 127.127.22.1    1090     0.001     0.401    99.800  19  14  13  10
17# 127.0.0.1       1188     0.060     1.622   105.004  78  65  51  32
18# 127.127.4.1      586     0.000     0.000     0.000   0   0   0   0
19# 140.173.64.1     975    -0.010     2.552   257.595 399 192 114   8
20# 128.175.1.3     1121     0.447     8.637   204.123 479 460 397 147
21# 140.173.16.1    1106     0.027     1.014   267.857 242  38  31  23
22# 128.4.1.4       1119     0.023     1.037   267.748 223  41  34  23
23# 128.4.1.2        850     1.202     1.654   267.704 196  53  45  34
24# 128.4.1.20      1101     0.088     1.139   268.322 430 111  83  16
25# 140.173.32.1     979    -0.949     2.344   257.671 396 217 136   7
26# 140.173.112.2   1066     0.040     2.111   152.969 442 315 152  16
27# 140.173.80.1    1059     0.019     1.858    87.690 438 348 150   9
28# 140.173.96.1    1015     0.110     2.007   266.744 399 314 170  17
29# 140.173.128.1   1103    -0.002     2.600   257.672 465 262 132  13
30# 140.222.135.1    347    -4.626     8.804   196.394 135 135 134  95
31# 140.173.128.2   1081    -0.046     2.967   261.448 463 342 172  17
32# 140.222.141.1    354     0.820     8.809   195.333 142 141 139 100
33# 140.173.144.2   1058    -0.107     2.805   270.498 448 341 163  17
34# 140.222.134.1    354    -0.056     8.479   172.458 142 141 141 100
35# 140.222.144.1    415    -1.456     9.964   191.684 161 161 161 123
36# 140.222.136.1    234     0.902     7.707   182.431  62  62  62  48
37# 128.175.1.1      774     0.890     4.838   266.799 358 291 200  83
38# 127.127.10.1    1086    -0.002     1.462   231.128 240 239  60  57
39# 140.173.48.2     576     0.016     4.092   350.512 213 126  88  16
40# 128.4.1.11         3     0.000     0.000     0.000   0   0   0   0
41# 128.4.1.26       386    -1.363    20.251   341.284 164 164 161 132
42#
43# select table beginning with "ident"
44{
45	if (NF < 8 || $1 == "ident")
46		continue
47	i = n
48	for (j = 0; j < n; j++) {
49		if ($1 == peer_ident[j])
50			i = j
51	}
52	if (i == n) {
53		peer_ident[i] = $1
54		n++
55	}
56	peer_count[i]++
57	if (($7 - $6 / 2) < 400) {
58		peer_count[i]++
59		peer_mean[i] += $3
60		peer_var[i] += $4 * $4
61		if ($5 > peer_max[i])
62			peer_max[i] = $5
63		if ($5 > 1)
64			peer_1[i]++
65		if ($5 > 5)
66			peer_2[i]++
67		if ($5 > 10)
68			peer_3[i]++
69		if ($5 > 50)
70			peer_4[i]++
71	}
72} END {
73	printf "       host     days    mean       rms       max   >1  >5 >10 >50\n"
74	printf "==================================================================\n"
75	for (i = 0; i < n; i++) {
76		if (peer_count[i] <= 0)
77			continue
78		peer_mean[i] /= peer_count[i]
79		peer_var[i] = sqrt(peer_var[i] / peer_count[i])
80		printf "%-15s%4d%10.3f%10.3f%10.3f%4d%4d%4d%4d\n", peer_ident[i], peer_count[i], peer_mean[i], peer_var[i], peer_max[i], peer_1[i], peer_2[i], peer_3[i], peer_4[i]
81	}
82}
83