summaryrefslogtreecommitdiffstats
path: root/plugins/check_ups.c
diff options
context:
space:
mode:
authorBenoit Mortier <opensides@users.sourceforge.net>2004-12-25 23:17:46 (GMT)
committerBenoit Mortier <opensides@users.sourceforge.net>2004-12-25 23:17:46 (GMT)
commite9ccc6b21a1152bbf150302c4a29a6df79d75bd7 (patch)
tree91bf1ebb6f927fd628b298df2ac5a89580282591 /plugins/check_ups.c
parent71656b2aafffb69716620bf08cce76c925dc8fa3 (diff)
downloadmonitoring-plugins-e9ccc6b21a1152bbf150302c4a29a6df79d75bd7.tar.gz
various fixes for localization
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1061 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/check_ups.c')
-rw-r--r--plugins/check_ups.c59
1 files changed, 27 insertions, 32 deletions
diff --git a/plugins/check_ups.c b/plugins/check_ups.c
index a4d7650..1cdf9e9 100644
--- a/plugins/check_ups.c
+++ b/plugins/check_ups.c
@@ -133,48 +133,48 @@ main (int argc, char **argv)
133 } 133 }
134 else if ((status & (UPSSTATUS_OB | UPSSTATUS_LB)) == 134 else if ((status & (UPSSTATUS_OB | UPSSTATUS_LB)) ==
135 (UPSSTATUS_OB | UPSSTATUS_LB)) { 135 (UPSSTATUS_OB | UPSSTATUS_LB)) {
136 asprintf (&ups_status, "On Battery, Low Battery"); 136 asprintf (&ups_status, _("On Battery, Low Battery"));
137 result = STATE_CRITICAL; 137 result = STATE_CRITICAL;
138 } 138 }
139 else { 139 else {
140 if (status & UPSSTATUS_OL) { 140 if (status & UPSSTATUS_OL) {
141 asprintf (&ups_status, "%s%s", ups_status, "Online"); 141 asprintf (&ups_status, "%s%s", ups_status, _("Online"));
142 } 142 }
143 if (status & UPSSTATUS_OB) { 143 if (status & UPSSTATUS_OB) {
144 asprintf (&ups_status, "%s%s", ups_status, "On Battery"); 144 asprintf (&ups_status, "%s%s", ups_status, _("On Battery"));
145 result = STATE_WARNING; 145 result = STATE_WARNING;
146 } 146 }
147 if (status & UPSSTATUS_LB) { 147 if (status & UPSSTATUS_LB) {
148 asprintf (&ups_status, "%s%s", ups_status, ", Low Battery"); 148 asprintf (&ups_status, "%s%s", ups_status, _(", Low Battery"));
149 result = STATE_WARNING; 149 result = STATE_WARNING;
150 } 150 }
151 if (status & UPSSTATUS_CAL) { 151 if (status & UPSSTATUS_CAL) {
152 asprintf (&ups_status, "%s%s", ups_status, ", Calibrating"); 152 asprintf (&ups_status, "%s%s", ups_status, _(", Calibrating"));
153 } 153 }
154 if (status & UPSSTATUS_RB) { 154 if (status & UPSSTATUS_RB) {
155 asprintf (&ups_status, "%s%s", ups_status, ", Replace Battery"); 155 asprintf (&ups_status, "%s%s", ups_status, _(", Replace Battery"));
156 result = STATE_WARNING; 156 result = STATE_WARNING;
157 } 157 }
158 if (status & UPSSTATUS_BYPASS) { 158 if (status & UPSSTATUS_BYPASS) {
159 asprintf (&ups_status, "%s%s", ups_status, ", On Bypass"); 159 asprintf (&ups_status, "%s%s", ups_status, _(", On Bypass"));
160 } 160 }
161 if (status & UPSSTATUS_OVER) { 161 if (status & UPSSTATUS_OVER) {
162 asprintf (&ups_status, "%s%s", ups_status, ", Overload"); 162 asprintf (&ups_status, "%s%s", ups_status, _(", Overload"));
163 } 163 }
164 if (status & UPSSTATUS_TRIM) { 164 if (status & UPSSTATUS_TRIM) {
165 asprintf (&ups_status, "%s%s", ups_status, ", Trimming"); 165 asprintf (&ups_status, "%s%s", ups_status, _(", Trimming"));
166 } 166 }
167 if (status & UPSSTATUS_BOOST) { 167 if (status & UPSSTATUS_BOOST) {
168 asprintf (&ups_status, "%s%s", ups_status, ", Boosting"); 168 asprintf (&ups_status, "%s%s", ups_status, _(", Boosting"));
169 } 169 }
170 if (status & UPSSTATUS_CHRG) { 170 if (status & UPSSTATUS_CHRG) {
171 asprintf (&ups_status, "%s%s", ups_status, ", Charging"); 171 asprintf (&ups_status, "%s%s", ups_status, _(", Charging"));
172 } 172 }
173 if (status & UPSSTATUS_DISCHRG) { 173 if (status & UPSSTATUS_DISCHRG) {
174 asprintf (&ups_status, "%s%s", ups_status, ", Discharging"); 174 asprintf (&ups_status, "%s%s", ups_status, _(", Discharging"));
175 } 175 }
176 if (status & UPSSTATUS_UNKOWN) { 176 if (status & UPSSTATUS_UNKOWN) {
177 asprintf (&ups_status, "%s%s", ups_status, ", Unknown"); 177 asprintf (&ups_status, "%s%s", ups_status, _(", Unknown"));
178 } 178 }
179 } 179 }
180 asprintf (&message, "%sStatus=%s ", message, ups_status); 180 asprintf (&message, "%sStatus=%s ", message, ups_status);
@@ -311,7 +311,7 @@ main (int argc, char **argv)
311 /* if the UPS does not support any options we are looking for, report an error */ 311 /* if the UPS does not support any options we are looking for, report an error */
312 if (supported_options == UPS_NONE) { 312 if (supported_options == UPS_NONE) {
313 result = STATE_CRITICAL; 313 result = STATE_CRITICAL;
314 asprintf (&message, "UPS does not support any available options\n"); 314 asprintf (&message, _("UPS does not support any available options\n"));
315 } 315 }
316 316
317 /* reset timeout */ 317 /* reset timeout */
@@ -335,7 +335,7 @@ determine_status (void)
335 res=get_ups_variable ("ups.status", recv_buffer, sizeof (recv_buffer)); 335 res=get_ups_variable ("ups.status", recv_buffer, sizeof (recv_buffer));
336 if (res == NOSUCHVAR) return OK; 336 if (res == NOSUCHVAR) return OK;
337 if (res != STATE_OK) { 337 if (res != STATE_OK) {
338 printf ("Invalid response received from host\n"); 338 printf (_("Invalid response received from host\n"));
339 return ERROR; 339 return ERROR;
340 } 340 }
341 341
@@ -395,7 +395,7 @@ get_ups_variable (const char *varname, char *buf, size_t buflen)
395 if (process_tcp_request 395 if (process_tcp_request
396 (server_address, server_port, send_buffer, temp_buffer, 396 (server_address, server_port, send_buffer, temp_buffer,
397 sizeof (temp_buffer)) != STATE_OK) { 397 sizeof (temp_buffer)) != STATE_OK) {
398 printf ("Invalid response received from host\n"); 398 printf (_("Invalid response received from host\n"));
399 return ERROR; 399 return ERROR;
400 } 400 }
401 401
@@ -403,7 +403,7 @@ get_ups_variable (const char *varname, char *buf, size_t buflen)
403 len = strlen(ptr); 403 len = strlen(ptr);
404 if (len > 0 && ptr[len-1] == '\n') ptr[len-1]=0; 404 if (len > 0 && ptr[len-1] == '\n') ptr[len-1]=0;
405 if (strcmp (ptr, "ERR UNKNOWN-UPS") == 0) { 405 if (strcmp (ptr, "ERR UNKNOWN-UPS") == 0) {
406 printf ("CRITICAL - no such ups '%s' on that host\n", ups_name); 406 printf (_("CRITICAL - no such ups '%s' on that host\n"), ups_name);
407 return ERROR; 407 return ERROR;
408 } 408 }
409 409
@@ -413,19 +413,19 @@ get_ups_variable (const char *varname, char *buf, size_t buflen)
413 } 413 }
414 414
415 if (strcmp (ptr, "ERR DATA-STALE") == 0) { 415 if (strcmp (ptr, "ERR DATA-STALE") == 0) {
416 printf ("CRITICAL - UPS data is stale\n"); 416 printf (_("CRITICAL - UPS data is stale\n"));
417 return ERROR; 417 return ERROR;
418 } 418 }
419 419
420 if (strncmp (ptr, "ERR", 3) == 0) { 420 if (strncmp (ptr, "ERR", 3) == 0) {
421 printf ("Unknown error: %s\n", ptr); 421 printf (_("Unknown error: %s\n"), ptr);
422 return ERROR; 422 return ERROR;
423 } 423 }
424 424
425 ptr = temp_buffer + strlen (varname) + strlen (ups_name) + 6; 425 ptr = temp_buffer + strlen (varname) + strlen (ups_name) + 6;
426 len = strlen(ptr); 426 len = strlen(ptr);
427 if (len < 2 || ptr[0] != '"' || ptr[len-1] != '"') { 427 if (len < 2 || ptr[0] != '"' || ptr[len-1] != '"') {
428 printf ("Error: unable to parse variable\n"); 428 printf (_("Error: unable to parse variable\n"));
429 return ERROR; 429 return ERROR;
430 } 430 }
431 strncpy (buf, ptr+1, len - 2); 431 strncpy (buf, ptr+1, len - 2);
@@ -481,9 +481,7 @@ process_arguments (int argc, char **argv)
481 481
482 switch (c) { 482 switch (c) {
483 case '?': /* help */ 483 case '?': /* help */
484 printf (_("%s: Unknown argument: %s\n\n"), progname, optarg); 484 usage2 (_("Unknown argument"), optarg);
485 print_usage ();
486 exit (STATE_UNKNOWN);
487 case 'H': /* hostname */ 485 case 'H': /* hostname */
488 if (is_host (optarg)) { 486 if (is_host (optarg)) {
489 server_address = optarg; 487 server_address = optarg;
@@ -503,7 +501,7 @@ process_arguments (int argc, char **argv)
503 server_port = atoi (optarg); 501 server_port = atoi (optarg);
504 } 502 }
505 else { 503 else {
506 usage2 ("Port must be a positive integer", optarg); 504 usage2 (_("Port must be a positive integer"), optarg);
507 } 505 }
508 break; 506 break;
509 case 'c': /* critical time threshold */ 507 case 'c': /* critical time threshold */
@@ -512,7 +510,7 @@ process_arguments (int argc, char **argv)
512 check_crit = TRUE; 510 check_crit = TRUE;
513 } 511 }
514 else { 512 else {
515 usage2 ("Critical time must be a positive integer", optarg); 513 usage2 (_("Critical time must be a positive integer"), optarg);
516 } 514 }
517 break; 515 break;
518 case 'w': /* warning time threshold */ 516 case 'w': /* warning time threshold */
@@ -521,7 +519,7 @@ process_arguments (int argc, char **argv)
521 check_warn = TRUE; 519 check_warn = TRUE;
522 } 520 }
523 else { 521 else {
524 usage2 ("Warning time must be a positive integer", optarg); 522 usage2 (_("Warning time must be a positive integer"), optarg);
525 } 523 }
526 break; 524 break;
527 case 'v': /* variable */ 525 case 'v': /* variable */
@@ -534,14 +532,14 @@ process_arguments (int argc, char **argv)
534 else if (!strcmp (optarg, "LOADPCT")) 532 else if (!strcmp (optarg, "LOADPCT"))
535 check_variable = UPS_LOADPCT; 533 check_variable = UPS_LOADPCT;
536 else 534 else
537 usage2 ("Unrecognized UPS variable", optarg); 535 usage2 (_("Unrecognized UPS variable"), optarg);
538 break; 536 break;
539 case 't': /* timeout */ 537 case 't': /* timeout */
540 if (is_intnonneg (optarg)) { 538 if (is_intnonneg (optarg)) {
541 socket_timeout = atoi (optarg); 539 socket_timeout = atoi (optarg);
542 } 540 }
543 else { 541 else {
544 usage ("Time interval must be a positive integer\n"); 542 usage4 (_("Timeout interval must be a positive integer"));
545 } 543 }
546 break; 544 break;
547 case 'V': /* version */ 545 case 'V': /* version */
@@ -568,19 +566,17 @@ process_arguments (int argc, char **argv)
568} 566}
569 567
570 568
571
572int 569int
573validate_arguments (void) 570validate_arguments (void)
574{ 571{
575 if (! ups_name) { 572 if (! ups_name) {
576 printf ("Error : no ups indicated\n"); 573 printf (_("Error : no ups indicated\n"));
577 return ERROR; 574 return ERROR;
578 } 575 }
579 return OK; 576 return OK;
580} 577}
581 578
582 579
583
584void 580void
585print_help (void) 581print_help (void)
586{ 582{
@@ -641,7 +637,6 @@ http://www.networkupstools.org\n\n"));
641} 637}
642 638
643 639
644
645void 640void
646print_usage (void) 641print_usage (void)
647{ 642{