diff options
Diffstat (limited to 'web/attachments/103460-check_ups-NUT2.0.diff')
-rw-r--r-- | web/attachments/103460-check_ups-NUT2.0.diff | 588 |
1 files changed, 588 insertions, 0 deletions
diff --git a/web/attachments/103460-check_ups-NUT2.0.diff b/web/attachments/103460-check_ups-NUT2.0.diff new file mode 100644 index 0000000..e28c718 --- /dev/null +++ b/web/attachments/103460-check_ups-NUT2.0.diff | |||
@@ -0,0 +1,588 @@ | |||
1 | diff -ru nagiosplug/AUTHORS nagiosplug_AQ/AUTHORS | ||
2 | --- nagiosplug/AUTHORS 2004-08-23 23:59:37.000000000 +0200 | ||
3 | +++ nagiosplug_AQ/AUTHORS 2004-09-30 10:23:42.000000000 +0200 | ||
4 | @@ -119,3 +119,5 @@ | ||
5 | Sean Finney | ||
6 | Bill Kunkel | ||
7 | Paulo Afonso Graner Fessel | ||
8 | +Alain Richard | ||
9 | +Arnaud Quette | ||
10 | diff -ru nagiosplug/command.cfg.in nagiosplug_AQ/command.cfg.in | ||
11 | --- nagiosplug/command.cfg.in 2003-06-12 06:46:10.000000000 +0200 | ||
12 | +++ nagiosplug_AQ/command.cfg.in 2004-10-01 12:31:15.000000000 +0200 | ||
13 | @@ -91,6 +91,7 @@ | ||
14 | command[check_procs_zombie]=@libexecdir@/check_procs -w $ARG1$ -c $ARG2$ -s Z | ||
15 | command[check_procs_httpd]=@libexecdir@/check_procs -w 5:$ARG1$ -c 1:$ARG2$ -C httpd | ||
16 | command[check_procs_vsz]=@libexecdir@/check_procs -w 8096 -c 16182 -C httpd --metric VSZ | ||
17 | +command[check_ups]=@libexecdir@/check_ups -H $HOSTADDRESS$ -u $UPS$ | ||
18 | |||
19 | # An example of using check_by_ssh as an active service check | ||
20 | command[ssh_disk]=@libexecdir@/check_by_ssh -H $HOSTADDRESS$ -C '@libexecdir@/check_disk -w 85% -c 95% -p $ARG1$' | ||
21 | diff -ru nagiosplug/plugins/check_ups.c nagiosplug_AQ/plugins/check_ups.c | ||
22 | --- nagiosplug/plugins/check_ups.c 2004-03-14 05:09:19.000000000 +0100 | ||
23 | +++ nagiosplug_AQ/plugins/check_ups.c 2004-10-01 11:35:19.000000000 +0200 | ||
24 | @@ -1,26 +1,35 @@ | ||
25 | /****************************************************************************** | ||
26 | - | ||
27 | - This program is free software; you can redistribute it and/or modify | ||
28 | - it under the terms of the GNU General Public License as published by | ||
29 | - the Free Software Foundation; either version 2 of the License, or (at | ||
30 | - your option) any later version. | ||
31 | - | ||
32 | - This program is distributed in the hope that it will be useful, but | ||
33 | - WITHOUT ANY WARRANTY; without even the implied warranty of | ||
34 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
35 | - General Public License for more details. | ||
36 | - | ||
37 | - You should have received a copy of the GNU General Public License | ||
38 | - along with this program; if not, write to the Free Software | ||
39 | - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
40 | - | ||
41 | -******************************************************************************/ | ||
42 | + * | ||
43 | + * check_ups | ||
44 | + * | ||
45 | + * Program: Network UPS Tools plugin for Nagios | ||
46 | + * License: GPL | ||
47 | + * Copyright (c) 2000 Tom Shields | ||
48 | + * 2004 Alain Richard <alain.richard@equation.fr> | ||
49 | + * 2004 Arnaud Quette <arnaud.quette@mgeups.com> | ||
50 | + * | ||
51 | + * This program is free software; you can redistribute it and/or modify | ||
52 | + * it under the terms of the GNU General Public License as published by | ||
53 | + * the Free Software Foundation; either version 2 of the License, or (at | ||
54 | + * your option) any later version. | ||
55 | + * | ||
56 | + * This program is distributed in the hope that it will be useful, but | ||
57 | + * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
58 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
59 | + * General Public License for more details. | ||
60 | + * | ||
61 | + * You should have received a copy of the GNU General Public License | ||
62 | + * along with this program; if not, write to the Free Software | ||
63 | + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
64 | + * | ||
65 | + ******************************************************************************/ | ||
66 | |||
67 | const char *progname = "check_ups"; | ||
68 | -const char *revision = "$Revision: 1.14 $"; | ||
69 | -const char *copyright = "2000-2002"; | ||
70 | +const char *revision = "$Revision: 1.20 $"; | ||
71 | +const char *copyright = "2000-2004"; | ||
72 | const char *email = "nagiosplug-devel@lists.sourceforge.net"; | ||
73 | |||
74 | +#include <locale.h> | ||
75 | #include "common.h" | ||
76 | #include "netutils.h" | ||
77 | #include "utils.h" | ||
78 | @@ -38,14 +47,22 @@ | ||
79 | #define UPS_TEMP 8 /* supports UPS temperature */ | ||
80 | #define UPS_LOADPCT 16 /* supports load percent */ | ||
81 | |||
82 | -#define UPSSTATUS_NONE 0 | ||
83 | -#define UPSSTATUS_OFF 1 | ||
84 | -#define UPSSTATUS_OL 2 | ||
85 | -#define UPSSTATUS_OB 4 | ||
86 | -#define UPSSTATUS_LB 8 | ||
87 | -#define UPSSTATUS_CAL 16 | ||
88 | -#define UPSSTATUS_RB 32 /*Replace Battery */ | ||
89 | -#define UPSSTATUS_UNKOWN 64 | ||
90 | +#define UPSSTATUS_NONE 0 | ||
91 | +#define UPSSTATUS_OFF 1 | ||
92 | +#define UPSSTATUS_OL 2 | ||
93 | +#define UPSSTATUS_OB 4 | ||
94 | +#define UPSSTATUS_LB 8 | ||
95 | +#define UPSSTATUS_CAL 16 | ||
96 | +#define UPSSTATUS_RB 32 /*Replace Battery */ | ||
97 | +#define UPSSTATUS_BYPASS 64 | ||
98 | +#define UPSSTATUS_OVER 128 | ||
99 | +#define UPSSTATUS_TRIM 256 | ||
100 | +#define UPSSTATUS_BOOST 512 | ||
101 | +#define UPSSTATUS_CHRG 1024 | ||
102 | +#define UPSSTATUS_DISCHRG 2048 | ||
103 | +#define UPSSTATUS_UNKOWN 4096 | ||
104 | + | ||
105 | +enum { NOSUCHVAR = ERROR-1 }; | ||
106 | |||
107 | int server_port = PORT; | ||
108 | char *server_address; | ||
109 | @@ -63,9 +80,9 @@ | ||
110 | double ups_load_percent = 0.0; | ||
111 | double ups_temperature = 0.0; | ||
112 | char *ups_status; | ||
113 | +int temp_output_c = 0; | ||
114 | |||
115 | int determine_status (void); | ||
116 | -int determine_supported_vars (void); | ||
117 | int get_ups_variable (const char *, char *, size_t); | ||
118 | |||
119 | int process_arguments (int, char **); | ||
120 | @@ -73,7 +90,7 @@ | ||
121 | void print_help (void); | ||
122 | void print_usage (void); | ||
123 | |||
124 | -int | ||
125 | + int | ||
126 | main (int argc, char **argv) | ||
127 | { | ||
128 | int result = STATE_OK; | ||
129 | @@ -81,6 +98,7 @@ | ||
130 | char *data; | ||
131 | char temp_buffer[MAX_INPUT_BUFFER]; | ||
132 | double ups_utility_deviation = 0.0; | ||
133 | + int res; | ||
134 | |||
135 | setlocale (LC_ALL, ""); | ||
136 | bindtextdomain (PACKAGE, LOCALEDIR); | ||
137 | @@ -88,6 +106,7 @@ | ||
138 | |||
139 | ups_status = strdup ("N/A"); | ||
140 | data = strdup (""); | ||
141 | + message = strdup (""); | ||
142 | |||
143 | if (process_arguments (argc, argv) != OK) | ||
144 | usage ("Invalid command arguments supplied\n"); | ||
145 | @@ -98,15 +117,11 @@ | ||
146 | /* set socket timeout */ | ||
147 | alarm (socket_timeout); | ||
148 | |||
149 | - /* determine what variables the UPS supports */ | ||
150 | - if (determine_supported_vars () != OK) | ||
151 | - return STATE_CRITICAL; | ||
152 | - | ||
153 | /* get the ups status if possible */ | ||
154 | + if (determine_status () != OK) | ||
155 | + return STATE_CRITICAL; | ||
156 | if (supported_options & UPS_STATUS) { | ||
157 | |||
158 | - if (determine_status () != OK) | ||
159 | - return STATE_CRITICAL; | ||
160 | ups_status = strdup (""); | ||
161 | result = STATE_OK; | ||
162 | |||
163 | @@ -138,6 +153,24 @@ | ||
164 | asprintf (&ups_status, "%s%s", ups_status, ", Replace Battery"); | ||
165 | result = STATE_WARNING; | ||
166 | } | ||
167 | + if (status & UPSSTATUS_BYPASS) { | ||
168 | + asprintf (&ups_status, "%s%s", ups_status, ", On Bypass"); | ||
169 | + } | ||
170 | + if (status & UPSSTATUS_OVER) { | ||
171 | + asprintf (&ups_status, "%s%s", ups_status, ", Overload"); | ||
172 | + } | ||
173 | + if (status & UPSSTATUS_TRIM) { | ||
174 | + asprintf (&ups_status, "%s%s", ups_status, ", Trimming"); | ||
175 | + } | ||
176 | + if (status & UPSSTATUS_BOOST) { | ||
177 | + asprintf (&ups_status, "%s%s", ups_status, ", Boosting"); | ||
178 | + } | ||
179 | + if (status & UPSSTATUS_CHRG) { | ||
180 | + asprintf (&ups_status, "%s%s", ups_status, ", Charging"); | ||
181 | + } | ||
182 | + if (status & UPSSTATUS_DISCHRG) { | ||
183 | + asprintf (&ups_status, "%s%s", ups_status, ", Discharging"); | ||
184 | + } | ||
185 | if (status & UPSSTATUS_UNKOWN) { | ||
186 | asprintf (&ups_status, "%s%s", ups_status, ", Unknown"); | ||
187 | } | ||
188 | @@ -146,10 +179,12 @@ | ||
189 | } | ||
190 | |||
191 | /* get the ups utility voltage if possible */ | ||
192 | - if (supported_options & UPS_UTILITY) { | ||
193 | - | ||
194 | - if (get_ups_variable ("UTILITY", temp_buffer, sizeof (temp_buffer)) != OK) | ||
195 | - return STATE_CRITICAL; | ||
196 | + res=get_ups_variable ("input.voltage", temp_buffer, sizeof (temp_buffer)); | ||
197 | + if (res == NOSUCHVAR) supported_options &= ~UPS_UTILITY; | ||
198 | + else if (res != OK) | ||
199 | + return STATE_CRITICAL; | ||
200 | + else { | ||
201 | + supported_options |= UPS_UTILITY; | ||
202 | |||
203 | ups_utility_voltage = atof (temp_buffer); | ||
204 | asprintf (&message, "%sUtility=%3.1fV ", message, ups_utility_voltage); | ||
205 | @@ -167,23 +202,24 @@ | ||
206 | result = max_state (result, STATE_WARNING); | ||
207 | } | ||
208 | asprintf (&data, "%s", | ||
209 | - fperfdata ("voltage", ups_utility_voltage, "V", | ||
210 | - check_warn, warning_value, | ||
211 | - check_crit, critical_value, | ||
212 | + perfdata ("voltage", (long)(1000*ups_utility_voltage), "mV", | ||
213 | + check_warn, (long)(1000*warning_value), | ||
214 | + check_crit, (long)(1000*critical_value), | ||
215 | TRUE, 0, FALSE, 0)); | ||
216 | } else { | ||
217 | asprintf (&data, "%s", | ||
218 | - fperfdata ("voltage", ups_utility_voltage, "V", | ||
219 | + perfdata ("voltage", (long)(1000*ups_utility_voltage), "mV", | ||
220 | FALSE, 0, FALSE, 0, TRUE, 0, FALSE, 0)); | ||
221 | } | ||
222 | } | ||
223 | |||
224 | /* get the ups battery percent if possible */ | ||
225 | - if (supported_options & UPS_BATTPCT) { | ||
226 | - | ||
227 | - if (get_ups_variable ("BATTPCT", temp_buffer, sizeof (temp_buffer)) != OK) | ||
228 | - return STATE_CRITICAL; | ||
229 | - | ||
230 | + res=get_ups_variable ("battery.charge", temp_buffer, sizeof (temp_buffer)); | ||
231 | + if (res == NOSUCHVAR) supported_options &= ~UPS_BATTPCT; | ||
232 | + else if ( res != OK) | ||
233 | + return STATE_CRITICAL; | ||
234 | + else { | ||
235 | + supported_options |= UPS_BATTPCT; | ||
236 | ups_battery_percent = atof (temp_buffer); | ||
237 | asprintf (&message, "%sBatt=%3.1f%% ", message, ups_battery_percent); | ||
238 | |||
239 | @@ -207,11 +243,12 @@ | ||
240 | } | ||
241 | |||
242 | /* get the ups load percent if possible */ | ||
243 | - if (supported_options & UPS_LOADPCT) { | ||
244 | - | ||
245 | - if (get_ups_variable ("LOADPCT", temp_buffer, sizeof (temp_buffer)) != OK) | ||
246 | - return STATE_CRITICAL; | ||
247 | - | ||
248 | + res=get_ups_variable ("ups.load", temp_buffer, sizeof (temp_buffer)); | ||
249 | + if ( res == NOSUCHVAR ) supported_options &= ~UPS_LOADPCT; | ||
250 | + else if ( res != OK) | ||
251 | + return STATE_CRITICAL; | ||
252 | + else { | ||
253 | + supported_options |= UPS_LOADPCT; | ||
254 | ups_load_percent = atof (temp_buffer); | ||
255 | asprintf (&message, "%sLoad=%3.1f%% ", message, ups_load_percent); | ||
256 | |||
257 | @@ -235,13 +272,20 @@ | ||
258 | } | ||
259 | |||
260 | /* get the ups temperature if possible */ | ||
261 | - if (supported_options & UPS_TEMP) { | ||
262 | - | ||
263 | - if (get_ups_variable ("UPSTEMP", temp_buffer, sizeof (temp_buffer)) != OK) | ||
264 | - return STATE_CRITICAL; | ||
265 | - | ||
266 | - ups_temperature = (atof (temp_buffer) * 1.8) + 32; | ||
267 | - asprintf (&message, "%sTemp=%3.1fF", message, ups_temperature); | ||
268 | + res=get_ups_variable ("ups.temperature", temp_buffer, sizeof (temp_buffer)); | ||
269 | + if ( res == NOSUCHVAR ) supported_options &= ~UPS_TEMP; | ||
270 | + else if ( res != OK) | ||
271 | + return STATE_CRITICAL; | ||
272 | + else { | ||
273 | + supported_options |= UPS_TEMP; | ||
274 | + if (temp_output_c) { | ||
275 | + ups_temperature = atof (temp_buffer); | ||
276 | + asprintf (&message, "%sTemp=%3.1fC", message, ups_temperature); | ||
277 | + } | ||
278 | + else { | ||
279 | + ups_temperature = (atof (temp_buffer) * 1.8) + 32; | ||
280 | + asprintf (&message, "%sTemp=%3.1fF", message, ups_temperature); | ||
281 | + } | ||
282 | |||
283 | if (check_variable == UPS_TEMP) { | ||
284 | if (check_crit==TRUE && ups_temperature>=critical_value) { | ||
285 | @@ -284,15 +328,17 @@ | ||
286 | char recv_buffer[MAX_INPUT_BUFFER]; | ||
287 | char temp_buffer[MAX_INPUT_BUFFER]; | ||
288 | char *ptr; | ||
289 | - | ||
290 | - if (get_ups_variable ("STATUS", recv_buffer, sizeof (recv_buffer)) != | ||
291 | - STATE_OK) { | ||
292 | + int res; | ||
293 | + | ||
294 | + res=get_ups_variable ("ups.status", recv_buffer, sizeof (recv_buffer)); | ||
295 | + if (res == NOSUCHVAR) return OK; | ||
296 | + if (res != STATE_OK) { | ||
297 | printf ("Invalid response received from hostn"); | ||
298 | return ERROR; | ||
299 | } | ||
300 | - | ||
301 | - recv_buffer[strlen (recv_buffer) - 1] = 0; | ||
302 | - | ||
303 | + | ||
304 | + supported_options |= UPS_STATUS; | ||
305 | + | ||
306 | strcpy (temp_buffer, recv_buffer); | ||
307 | for (ptr = (char *) strtok (temp_buffer, " "); ptr != NULL; | ||
308 | ptr = (char *) strtok (NULL, " ")) { | ||
309 | @@ -308,6 +354,18 @@ | ||
310 | status |= UPSSTATUS_CAL; | ||
311 | else if (!strcmp (ptr, "RB")) | ||
312 | status |= UPSSTATUS_RB; | ||
313 | + else if (!strcmp (ptr, "BYPASS")) | ||
314 | + status |= UPSSTATUS_BYPASS; | ||
315 | + else if (!strcmp (ptr, "OVER")) | ||
316 | + status |= UPSSTATUS_OVER; | ||
317 | + else if (!strcmp (ptr, "TRIM")) | ||
318 | + status |= UPSSTATUS_TRIM; | ||
319 | + else if (!strcmp (ptr, "BOOST")) | ||
320 | + status |= UPSSTATUS_BOOST; | ||
321 | + else if (!strcmp (ptr, "CHRG")) | ||
322 | + status |= UPSSTATUS_CHRG; | ||
323 | + else if (!strcmp (ptr, "DISCHRG")) | ||
324 | + status |= UPSSTATUS_DISCHRG; | ||
325 | else | ||
326 | status |= UPSSTATUS_UNKOWN; | ||
327 | } | ||
328 | @@ -316,55 +374,6 @@ | ||
329 | } | ||
330 | |||
331 | |||
332 | -/* determines what options are supported by the UPS */ | ||
333 | -int | ||
334 | -determine_supported_vars (void) | ||
335 | -{ | ||
336 | - char send_buffer[MAX_INPUT_BUFFER]; | ||
337 | - char recv_buffer[MAX_INPUT_BUFFER]; | ||
338 | - char temp_buffer[MAX_INPUT_BUFFER]; | ||
339 | - char *ptr; | ||
340 | - | ||
341 | - | ||
342 | - /* get the list of variables that this UPS supports */ | ||
343 | - if (ups_name) | ||
344 | - sprintf (send_buffer, "LISTVARS %s\r\n", ups_name); | ||
345 | - else | ||
346 | - sprintf (send_buffer, "LISTVARS\r\n"); | ||
347 | - if (process_tcp_request | ||
348 | - (server_address, server_port, send_buffer, recv_buffer, | ||
349 | - sizeof (recv_buffer)) != STATE_OK) { | ||
350 | - printf ("Invalid response received from host\n"); | ||
351 | - return ERROR; | ||
352 | - } | ||
353 | - | ||
354 | - recv_buffer[strlen (recv_buffer) - 1] = 0; | ||
355 | - | ||
356 | - if (ups_name) | ||
357 | - ptr = recv_buffer + 5 + strlen (ups_name) + 2; | ||
358 | - else | ||
359 | - ptr = recv_buffer + 5; | ||
360 | - | ||
361 | - strcpy (temp_buffer, recv_buffer); | ||
362 | - | ||
363 | - for (ptr = (char *) strtok (temp_buffer, " "); ptr != NULL; | ||
364 | - ptr = (char *) strtok (NULL, " ")) { | ||
365 | - if (!strcmp (ptr, "UTILITY")) | ||
366 | - supported_options |= UPS_UTILITY; | ||
367 | - else if (!strcmp (ptr, "BATTPCT")) | ||
368 | - supported_options |= UPS_BATTPCT; | ||
369 | - else if (!strcmp (ptr, "LOADPCT")) | ||
370 | - supported_options |= UPS_LOADPCT; | ||
371 | - else if (!strcmp (ptr, "STATUS")) | ||
372 | - supported_options |= UPS_STATUS; | ||
373 | - else if (!strcmp (ptr, "UPSTEMP")) | ||
374 | - supported_options |= UPS_TEMP; | ||
375 | - } | ||
376 | - | ||
377 | - return OK; | ||
378 | -} | ||
379 | - | ||
380 | - | ||
381 | /* gets a variable value for a specific UPS */ | ||
382 | int | ||
383 | get_ups_variable (const char *varname, char *buf, size_t buflen) | ||
384 | @@ -373,12 +382,12 @@ | ||
385 | char temp_buffer[MAX_INPUT_BUFFER]; | ||
386 | char send_buffer[MAX_INPUT_BUFFER]; | ||
387 | char *ptr; | ||
388 | + int len; | ||
389 | |||
390 | + *buf=0; | ||
391 | + | ||
392 | /* create the command string to send to the UPS daemon */ | ||
393 | - if (ups_name) | ||
394 | - sprintf (send_buffer, "REQ %s@%s\n", varname, ups_name); | ||
395 | - else | ||
396 | - sprintf (send_buffer, "REQ %s\n", varname); | ||
397 | + sprintf (send_buffer, "GET VAR %s %s\n", ups_name, varname); | ||
398 | |||
399 | /* send the command to the daemon and get a response back */ | ||
400 | if (process_tcp_request | ||
401 | @@ -388,40 +397,43 @@ | ||
402 | return ERROR; | ||
403 | } | ||
404 | |||
405 | - if (ups_name) | ||
406 | - ptr = temp_buffer + strlen (varname) + 5 + strlen (ups_name) + 1; | ||
407 | - else | ||
408 | - ptr = temp_buffer + strlen (varname) + 5; | ||
409 | - | ||
410 | - if (!strcmp (ptr, "NOT-SUPPORTED")) { | ||
411 | - printf ("Error: Variable '%s' is not supported\n", varname); | ||
412 | + ptr = temp_buffer; | ||
413 | + len = strlen(ptr); | ||
414 | + if (len > 0 && ptr[len-1] == '\n') ptr[len-1]=0; | ||
415 | + if (strcmp (ptr, "ERR UNKNOWN-UPS") == 0) { | ||
416 | + printf ("Error: no such ups '%s' on that host\n", ups_name); | ||
417 | return ERROR; | ||
418 | } | ||
419 | |||
420 | - if (!strcmp (ptr, "DATA-STALE")) { | ||
421 | + if (strcmp (ptr, "ERR VAR-NOT-SUPPORTED") == 0) { | ||
422 | + //printf ("Error: Variable '%s' is not supported\n", varname); | ||
423 | + return NOSUCHVAR; | ||
424 | + } | ||
425 | + | ||
426 | + if (strcmp (ptr, "ERR DATA-STALE") == 0) { | ||
427 | printf ("Error: UPS data is stale\n"); | ||
428 | return ERROR; | ||
429 | } | ||
430 | |||
431 | - if (!strcmp (ptr, "UNKNOWN-UPS")) { | ||
432 | - if (ups_name) | ||
433 | - printf ("Error: UPS '%s' is unknown\n", ups_name); | ||
434 | - else | ||
435 | - printf ("Error: UPS is unknown\n"); | ||
436 | + if (strncmp (ptr, "ERR", 3) == 0) { | ||
437 | + printf ("Unkown error: %s\n", ptr); | ||
438 | return ERROR; | ||
439 | } | ||
440 | |||
441 | - strncpy (buf, ptr, buflen - 1); | ||
442 | - buf[buflen - 1] = 0; | ||
443 | + ptr = temp_buffer + strlen (varname) + strlen (ups_name) + 6; | ||
444 | + len = strlen(ptr); | ||
445 | + if (len < 2 || ptr[0] != '"' || ptr[len-1] != '"') { | ||
446 | + printf ("Error: unable to parse variable\n"); | ||
447 | + return ERROR; | ||
448 | + } | ||
449 | + strncpy (buf, ptr+1, len - 2); | ||
450 | + buf[len - 2] = 0; | ||
451 | |||
452 | return OK; | ||
453 | } | ||
454 | |||
455 | |||
456 | - | ||
457 | - | ||
458 | - | ||
459 | -/* Command line: CHECK_UPS <host_address> [-u ups] [-p port] [-v variable] | ||
460 | +/* Command line: CHECK_UPS -H <host_address> -u ups [-p port] [-v variable] | ||
461 | [-wv warn_value] [-cv crit_value] [-to to_sec] */ | ||
462 | |||
463 | |||
464 | @@ -439,6 +451,7 @@ | ||
465 | {"critical", required_argument, 0, 'c'}, | ||
466 | {"warning", required_argument, 0, 'w'}, | ||
467 | {"timeout", required_argument, 0, 't'}, | ||
468 | + {"temperature", no_argument, 0, 'T'}, | ||
469 | {"variable", required_argument, 0, 'v'}, | ||
470 | {"version", no_argument, 0, 'V'}, | ||
471 | {"help", no_argument, 0, 'h'}, | ||
472 | @@ -458,7 +471,7 @@ | ||
473 | } | ||
474 | |||
475 | while (1) { | ||
476 | - c = getopt_long (argc, argv, "hVH:u:p:v:c:w:t:", longopts, | ||
477 | + c = getopt_long (argc, argv, "hVTH:u:p:v:c:w:t:", longopts, | ||
478 | &option); | ||
479 | |||
480 | if (c == -1 || c == EOF) | ||
481 | @@ -475,6 +488,9 @@ | ||
482 | usage2 ("Invalid host name", optarg); | ||
483 | } | ||
484 | break; | ||
485 | + case 'T': /* FIXME: to be improved (ie "-T C" for Celsius or "-T F" for Farenheit) */ | ||
486 | + temp_output_c = 1; | ||
487 | + break; | ||
488 | case 'u': /* ups name */ | ||
489 | ups_name = optarg; | ||
490 | break; | ||
491 | @@ -525,7 +541,7 @@ | ||
492 | } | ||
493 | break; | ||
494 | case 'V': /* version */ | ||
495 | - print_revision (progname, "$Revision: 1.14 $"); | ||
496 | + print_revision (progname, revision); | ||
497 | exit (STATE_OK); | ||
498 | case 'h': /* help */ | ||
499 | print_help (); | ||
500 | @@ -548,20 +564,17 @@ | ||
501 | } | ||
502 | |||
503 | |||
504 | - | ||
505 | - | ||
506 | - | ||
507 | int | ||
508 | validate_arguments (void) | ||
509 | { | ||
510 | - return OK; | ||
511 | + if (! ups_name) { | ||
512 | + printf ("Error : no ups indicated\n"); | ||
513 | + return ERROR; | ||
514 | + } | ||
515 | + return OK; | ||
516 | } | ||
517 | |||
518 | |||
519 | - | ||
520 | - | ||
521 | - | ||
522 | - | ||
523 | void | ||
524 | print_help (void) | ||
525 | { | ||
526 | @@ -571,11 +584,13 @@ | ||
527 | print_revision (progname, revision); | ||
528 | |||
529 | printf (_("Copyright (c) 2000 Tom Shields")); | ||
530 | + printf (_("Copyright (c) 2004 Alain Richard <alain.richard@equation.fr>\n")); | ||
531 | + printf (_("Copyright (c) 2004 Arnaud Quette <arnaud.quette@mgeups.com>\n")); | ||
532 | printf (_(COPYRIGHT), copyright, email); | ||
533 | |||
534 | printf (_("This plugin tests the UPS service on the specified host.\n\ | ||
535 | -Network UPS Tools from www.exploits.org must be running for this plugin to\n\ | ||
536 | -work.\n\n")); | ||
537 | +Network UPS Tools from www.networkupstools.org must be running for this \n\ | ||
538 | +plugin to work.\n\n")); | ||
539 | |||
540 | print_usage (); | ||
541 | |||
542 | @@ -587,6 +602,9 @@ | ||
543 | -u, --ups=STRING\n\ | ||
544 | Name of UPS\n")); | ||
545 | |||
546 | + printf (_("-T, --temperature\n\ | ||
547 | + Output of temperatures in Celsius\n")); | ||
548 | + | ||
549 | printf (_(UT_WARN_CRIT)); | ||
550 | |||
551 | printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT); | ||
552 | @@ -607,10 +625,10 @@ | ||
553 | will have to use the [ups] option to specify which UPS to check.\n\n")); | ||
554 | |||
555 | printf (_("Notes:\n\n\ | ||
556 | -This plugin requires that the UPSD daemon distributed with Russel Kroll's\n\ | ||
557 | -Smart UPS Tools be installed on the remote host. If you do not have the\n\ | ||
558 | +This plugin requires that the UPSD daemon distributed with the NUT - Network\n\ | ||
559 | +UPS Tools to be installed on the remote host. If you do not have the\n\ | ||
560 | package installed on your system, you can download it from\n\ | ||
561 | -http://www.exploits.org/nut\n\n")); | ||
562 | +http://www.networkupstools.org\n\n")); | ||
563 | |||
564 | printf (_(UT_SUPPORT)); | ||
565 | } | ||
566 | @@ -622,7 +640,7 @@ | ||
567 | print_usage (void) | ||
568 | { | ||
569 | printf (_("\ | ||
570 | -Usage: %s -H host [-e expect] [-p port] [-w warn] [-c crit]\n\ | ||
571 | - [-t timeout] [-v]\n"), progname); | ||
572 | +Usage: %s -H host -u ups [-p port] [-v variable] [-wv warn_value] [-cv crit_value] [-to to_sec] [-T]\n"), progname); | ||
573 | printf (_(UT_HLP_VRS), progname, progname); | ||
574 | } | ||
575 | + | ||
576 | diff -ru nagiosplug/REQUIREMENTS nagiosplug_AQ/REQUIREMENTS | ||
577 | --- nagiosplug/REQUIREMENTS 2004-04-29 13:12:20.000000000 +0200 | ||
578 | +++ nagiosplug_AQ/REQUIREMENTS 2004-10-01 12:42:55.000000000 +0200 | ||
579 | @@ -65,6 +65,9 @@ | ||
580 | - Requires NSClient to run on the NT server to monitor | ||
581 | http://nsclient.ready2run.nl/ | ||
582 | |||
583 | +check_ups: | ||
584 | + - Requires Network UPS Tools (>= 1.4) to run on the server to monitor | ||
585 | + http://www.networkupstools.org/ | ||
586 | |||
587 | OS Specific Issues | ||
588 | ------------------ | ||