diff options
Diffstat (limited to 'web/attachments/216487-check_ntp.patch')
-rw-r--r-- | web/attachments/216487-check_ntp.patch | 150 |
1 files changed, 150 insertions, 0 deletions
diff --git a/web/attachments/216487-check_ntp.patch b/web/attachments/216487-check_ntp.patch new file mode 100644 index 0000000..6fbea15 --- /dev/null +++ b/web/attachments/216487-check_ntp.patch | |||
@@ -0,0 +1,150 @@ | |||
1 | *** nagios-plugins-1.4.6-orig/plugins/check_ntp.c 2007-01-28 16:46:40.000000000 -0500 | ||
2 | --- nagios-plugins-1.4.6/plugins/check_ntp.c 2007-02-17 17:17:20.000000000 -0500 | ||
3 | *************** static double ocrit=120; | ||
4 | *** 53,58 **** | ||
5 | --- 53,62 ---- | ||
6 | static short do_jitter=0; | ||
7 | static double jwarn=5000; | ||
8 | static double jcrit=10000; | ||
9 | + static short do_stratum=0; | ||
10 | + static int swarn=4; | ||
11 | + static int scrit=15; | ||
12 | + static int max_stratum=0; | ||
13 | |||
14 | int process_arguments (int, char **); | ||
15 | void print_help (void); | ||
16 | *************** double offset_request(const char *host, | ||
17 | *** 447,452 **** | ||
18 | --- 451,459 ---- | ||
19 | if(verbose) { | ||
20 | printf("offset %.10g\n", servers[i].offset[respnum]); | ||
21 | } | ||
22 | + if (req[i].stratum > max_stratum) { | ||
23 | + max_stratum = req[i].stratum; | ||
24 | + } | ||
25 | servers[i].stratum=req[i].stratum; | ||
26 | servers[i].rtdisp=NTP32asDOUBLE(req[i].rtdisp); | ||
27 | servers[i].rtdelay=NTP32asDOUBLE(req[i].rtdelay); | ||
28 | *************** int process_arguments(int argc, char **a | ||
29 | *** 631,636 **** | ||
30 | --- 638,645 ---- | ||
31 | {"zero-offset", no_argument, 0, 'O'}, | ||
32 | {"jwarn", required_argument, 0, 'j'}, | ||
33 | {"jcrit", required_argument, 0, 'k'}, | ||
34 | + {"swarn", required_argument, 0, 's'}, | ||
35 | + {"scrit", required_argument, 0, 'S'}, | ||
36 | {"timeout", required_argument, 0, 't'}, | ||
37 | {"hostname", required_argument, 0, 'H'}, | ||
38 | {0, 0, 0, 0} | ||
39 | *************** int process_arguments(int argc, char **a | ||
40 | *** 641,647 **** | ||
41 | usage ("\n"); | ||
42 | |||
43 | while (1) { | ||
44 | ! c = getopt_long (argc, argv, "Vhv46w:c:Oj:k:t:H:", longopts, &option); | ||
45 | if (c == -1 || c == EOF || c == 1) | ||
46 | break; | ||
47 | |||
48 | --- 650,656 ---- | ||
49 | usage ("\n"); | ||
50 | |||
51 | while (1) { | ||
52 | ! c = getopt_long (argc, argv, "Vhv46w:c:Oj:k:t:H:s:S:", longopts, &option); | ||
53 | if (c == -1 || c == EOF || c == 1) | ||
54 | break; | ||
55 | |||
56 | *************** int process_arguments(int argc, char **a | ||
57 | *** 671,676 **** | ||
58 | --- 680,693 ---- | ||
59 | do_jitter=1; | ||
60 | jcrit = atof(optarg); | ||
61 | break; | ||
62 | + case 's': | ||
63 | + do_stratum=1; | ||
64 | + swarn = atoi(optarg); | ||
65 | + break; | ||
66 | + case 'S': | ||
67 | + do_stratum=1; | ||
68 | + scrit = atoi(optarg); | ||
69 | + break; | ||
70 | case 'H': | ||
71 | if(is_host(optarg) == FALSE) | ||
72 | usage2(_("Invalid hostname/address"), optarg); | ||
73 | *************** int process_arguments(int argc, char **a | ||
74 | *** 703,712 **** | ||
75 | usage4(_("Critical offset should be larger than warning offset")); | ||
76 | } | ||
77 | |||
78 | ! if (ocrit < owarn){ | ||
79 | usage4(_("Critical jitter should be larger than warning jitter")); | ||
80 | } | ||
81 | |||
82 | if(server_address == NULL){ | ||
83 | usage4(_("Hostname was not supplied")); | ||
84 | } | ||
85 | --- 720,733 ---- | ||
86 | usage4(_("Critical offset should be larger than warning offset")); | ||
87 | } | ||
88 | |||
89 | ! if (jcrit < jwarn){ | ||
90 | usage4(_("Critical jitter should be larger than warning jitter")); | ||
91 | } | ||
92 | |||
93 | + if (scrit < swarn){ | ||
94 | + usage4(_("Critical stratum should be larger than warning stratum")); | ||
95 | + } | ||
96 | + | ||
97 | if(server_address == NULL){ | ||
98 | usage4(_("Hostname was not supplied")); | ||
99 | } | ||
100 | *************** int main(int argc, char *argv[]){ | ||
101 | *** 758,763 **** | ||
102 | --- 779,792 ---- | ||
103 | } | ||
104 | result=max_state(result, jitter_result); | ||
105 | |||
106 | + if(do_stratum){ | ||
107 | + if (max_stratum >= scrit){ | ||
108 | + result - max_state(result, STATE_CRITICAL); | ||
109 | + } else if(max_stratum >= swarn) { | ||
110 | + result = max_state(result, STATE_WARNING); | ||
111 | + } | ||
112 | + } | ||
113 | + | ||
114 | switch (result) { | ||
115 | case STATE_CRITICAL : | ||
116 | printf("NTP CRITICAL: "); | ||
117 | *************** int main(int argc, char *argv[]){ | ||
118 | *** 778,784 **** | ||
119 | if(offset_result==STATE_WARNING){ | ||
120 | printf("Unable to fully sample sync server. "); | ||
121 | } | ||
122 | ! printf("Offset %.10g secs|offset=%.10g", offset, offset); | ||
123 | } | ||
124 | if (do_jitter) printf(" jitter=%f", jitter); | ||
125 | printf("\n"); | ||
126 | --- 807,817 ---- | ||
127 | if(offset_result==STATE_WARNING){ | ||
128 | printf("Unable to fully sample sync server. "); | ||
129 | } | ||
130 | ! printf("Offset %.10g secs", offset); | ||
131 | ! if (do_stratum) { | ||
132 | ! printf(", max Stratum %d", max_stratum); | ||
133 | ! } | ||
134 | ! printf("|offset=%.10g", offset); | ||
135 | } | ||
136 | if (do_jitter) printf(" jitter=%f", jitter); | ||
137 | printf("\n"); | ||
138 | *************** void print_help(void){ | ||
139 | *** 804,809 **** | ||
140 | --- 837,846 ---- | ||
141 | printf (_(UT_HOST_PORT), 'p', "123"); | ||
142 | printf (_(UT_WARN_CRIT)); | ||
143 | printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT); | ||
144 | + printf (" -j, --jwarn=DOUBLE\n Jitter level to result in warning status\n"); | ||
145 | + printf (" -k, --jcrit=DOUBLE\n Jitter level to result in critical status\n"); | ||
146 | + printf (" -s, --swarn=INTEGER\n Stratum clock level to result in warning status\n"); | ||
147 | + printf (" -S, --scrit=INTEGER\n Stratum clock level to result in critical status\n"); | ||
148 | printf (_(UT_VERBOSE)); | ||
149 | printf (_(UT_SUPPORT)); | ||
150 | } | ||