diff options
author | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2003-08-08 03:51:02 (GMT) |
---|---|---|
committer | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2003-08-08 03:51:02 (GMT) |
commit | 92cd137176830bcdfbd477f151ba22d456b2e31c (patch) | |
tree | f242bbef29aefa991752da130e182562558934f5 /plugins/check_nt.c | |
parent | ee37af8e56af48faab21a07c0cde1fa1d31c7849 (diff) | |
download | monitoring-plugins-92cd137176830bcdfbd477f151ba22d456b2e31c.tar.gz |
markup for translation
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@661 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/check_nt.c')
-rw-r--r-- | plugins/check_nt.c | 170 |
1 files changed, 94 insertions, 76 deletions
diff --git a/plugins/check_nt.c b/plugins/check_nt.c index 85c6753..91022ba 100644 --- a/plugins/check_nt.c +++ b/plugins/check_nt.c | |||
@@ -64,9 +64,10 @@ int show_all=FALSE; | |||
64 | const char *progname = "check_nt"; | 64 | const char *progname = "check_nt"; |
65 | 65 | ||
66 | int process_arguments(int, char **); | 66 | int process_arguments(int, char **); |
67 | void print_usage(void); | ||
68 | void print_help(void); | ||
69 | void preparelist(char *string); | 67 | void preparelist(char *string); |
68 | int strtoularray(unsigned long *array, char *string, char *delim); | ||
69 | void print_help(void); | ||
70 | void print_usage(void); | ||
70 | 71 | ||
71 | int main(int argc, char **argv){ | 72 | int main(int argc, char **argv){ |
72 | int result; | 73 | int result; |
@@ -91,10 +92,10 @@ int main(int argc, char **argv){ | |||
91 | int uphours=0; | 92 | int uphours=0; |
92 | int upminutes=0; | 93 | int upminutes=0; |
93 | 94 | ||
94 | asprintf(&req_password,"None"); | 95 | asprintf(&req_password, _("None")); |
95 | 96 | ||
96 | if(process_arguments(argc,argv)==ERROR) | 97 | if(process_arguments(argc,argv)==ERROR) |
97 | usage("Could not parse arguments\n"); | 98 | usage(_("Could not parse arguments\n")); |
98 | 99 | ||
99 | /* initialize alarm signal handling */ | 100 | /* initialize alarm signal handling */ |
100 | signal(SIGALRM,socket_timeout_alarm_handler); | 101 | signal(SIGALRM,socket_timeout_alarm_handler); |
@@ -116,15 +117,15 @@ int main(int argc, char **argv){ | |||
116 | else if(vars_to_check==CHECK_CPULOAD){ | 117 | else if(vars_to_check==CHECK_CPULOAD){ |
117 | 118 | ||
118 | if (check_value_list==TRUE) { | 119 | if (check_value_list==TRUE) { |
119 | if (strtolarray(&lvalue_list,value_list,",")==TRUE) { | 120 | if (strtoularray(&lvalue_list,value_list,",")==TRUE) { |
120 | /* -l parameters is present with only integers */ | 121 | /* -l parameters is present with only integers */ |
121 | return_code=STATE_OK; | 122 | return_code=STATE_OK; |
122 | asprintf(&temp_string,"CPU Load"); | 123 | asprintf(&temp_string,_("CPU Load")); |
123 | while (lvalue_list[0+offset]>(unsigned long)0 && | 124 | while (lvalue_list[0+offset]> (unsigned long)0 && |
124 | lvalue_list[0+offset]<=(unsigned long)17280 && | 125 | lvalue_list[0+offset]<=(unsigned long)17280 && |
125 | lvalue_list[1+offset]>=(unsigned long)0 && | 126 | lvalue_list[1+offset]> (unsigned long)0 && |
126 | lvalue_list[1+offset]<=(unsigned long)100 && | 127 | lvalue_list[1+offset]<=(unsigned long)100 && |
127 | lvalue_list[2+offset]>=(unsigned long)0 && | 128 | lvalue_list[2+offset]> (unsigned long)0 && |
128 | lvalue_list[2+offset]<=(unsigned long)100) { | 129 | lvalue_list[2+offset]<=(unsigned long)100) { |
129 | /* loop until one of the parameters is wrong or not present */ | 130 | /* loop until one of the parameters is wrong or not present */ |
130 | 131 | ||
@@ -147,7 +148,7 @@ int main(int argc, char **argv){ | |||
147 | else if(utilization >= lvalue_list[1+offset] && return_code<STATE_WARNING) | 148 | else if(utilization >= lvalue_list[1+offset] && return_code<STATE_WARNING) |
148 | return_code=STATE_WARNING; | 149 | return_code=STATE_WARNING; |
149 | 150 | ||
150 | asprintf(&output_message," %lu%% (%lu min average)", utilization, lvalue_list[0+offset]); | 151 | asprintf(&output_message,_(" %lu%% (%lu min average)"), utilization, lvalue_list[0+offset]); |
151 | asprintf(&temp_string,"%s%s",temp_string,output_message); | 152 | asprintf(&temp_string,"%s%s",temp_string,output_message); |
152 | offset+=3; /* move across the array */ | 153 | offset+=3; /* move across the array */ |
153 | } | 154 | } |
@@ -156,13 +157,13 @@ int main(int argc, char **argv){ | |||
156 | asprintf(&output_message,"%s",temp_string); | 157 | asprintf(&output_message,"%s",temp_string); |
157 | } | 158 | } |
158 | else | 159 | else |
159 | asprintf(&output_message,"%s","not enough values for -l parameters"); | 160 | asprintf(&output_message,"%s",_("not enough values for -l parameters")); |
160 | 161 | ||
161 | } else | 162 | } else |
162 | asprintf(&output_message,"wrong -l parameter."); | 163 | asprintf(&output_message,_("wrong -l parameter.")); |
163 | 164 | ||
164 | } else | 165 | } else |
165 | asprintf(&output_message,"missing -l parameters"); | 166 | asprintf(&output_message,_("missing -l parameters")); |
166 | } | 167 | } |
167 | 168 | ||
168 | else if(vars_to_check==CHECK_UPTIME){ | 169 | else if(vars_to_check==CHECK_UPTIME){ |
@@ -181,7 +182,7 @@ int main(int argc, char **argv){ | |||
181 | updays = uptime / 86400; | 182 | updays = uptime / 86400; |
182 | uphours = (uptime % 86400) / 3600; | 183 | uphours = (uptime % 86400) / 3600; |
183 | upminutes = ((uptime % 86400) % 3600) / 60; | 184 | upminutes = ((uptime % 86400) % 3600) / 60; |
184 | asprintf(&output_message,"System Uptime : %u day(s) %u hour(s) %u minute(s)",updays,uphours, upminutes); | 185 | asprintf(&output_message,_("System Uptime : %u day(s) %u hour(s) %u minute(s)"),updays,uphours, upminutes); |
185 | return_code=STATE_OK; | 186 | return_code=STATE_OK; |
186 | } | 187 | } |
187 | 188 | ||
@@ -205,7 +206,7 @@ int main(int argc, char **argv){ | |||
205 | percent_used_space = ((total_disk_space - free_disk_space) / total_disk_space) * 100; | 206 | percent_used_space = ((total_disk_space - free_disk_space) / total_disk_space) * 100; |
206 | 207 | ||
207 | if (free_disk_space>=0) { | 208 | if (free_disk_space>=0) { |
208 | asprintf(&temp_string,"%s:\\ - total: %.2f Gb - used: %.2f Gb (%.0f%%) - free %.2f Gb (%.0f%%)", | 209 | asprintf(&temp_string,_("%s:\\ - total: %.2f Gb - used: %.2f Gb (%.0f%%) - free %.2f Gb (%.0f%%)"), |
209 | value_list, total_disk_space / 1073741824, (total_disk_space - free_disk_space) / 1073741824, percent_used_space, | 210 | value_list, total_disk_space / 1073741824, (total_disk_space - free_disk_space) / 1073741824, percent_used_space, |
210 | free_disk_space / 1073741824, (free_disk_space / total_disk_space)*100); | 211 | free_disk_space / 1073741824, (free_disk_space / total_disk_space)*100); |
211 | 212 | ||
@@ -221,14 +222,14 @@ int main(int argc, char **argv){ | |||
221 | 222 | ||
222 | } | 223 | } |
223 | else { | 224 | else { |
224 | asprintf(&output_message,"Free disk space : Invalid drive "); | 225 | asprintf(&output_message,_("Free disk space : Invalid drive ")); |
225 | return_code=STATE_UNKNOWN; | 226 | return_code=STATE_UNKNOWN; |
226 | } | 227 | } |
227 | } | 228 | } |
228 | else | 229 | else |
229 | asprintf(&output_message,"wrong -l argument"); | 230 | asprintf(&output_message,_("wrong -l argument")); |
230 | } else | 231 | } else |
231 | asprintf(&output_message,"missing -l parameters"); | 232 | asprintf(&output_message,_("missing -l parameters")); |
232 | 233 | ||
233 | } | 234 | } |
234 | 235 | ||
@@ -237,7 +238,7 @@ int main(int argc, char **argv){ | |||
237 | if (check_value_list==TRUE) { | 238 | if (check_value_list==TRUE) { |
238 | preparelist(value_list); /* replace , between services with & to send the request */ | 239 | preparelist(value_list); /* replace , between services with & to send the request */ |
239 | asprintf(&send_buffer,"%s&%u&%s&%s", req_password,(vars_to_check==CHECK_SERVICESTATE)?5:6, | 240 | asprintf(&send_buffer,"%s&%u&%s&%s", req_password,(vars_to_check==CHECK_SERVICESTATE)?5:6, |
240 | (show_all==TRUE)?"ShowAll":"ShowFail",value_list); | 241 | (show_all==TRUE)?_("ShowAll"):_("ShowFail"),value_list); |
241 | result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer)); | 242 | result=process_tcp_request(server_address,server_port,send_buffer,recv_buffer,sizeof(recv_buffer)); |
242 | if(result!=STATE_OK) | 243 | if(result!=STATE_OK) |
243 | return result; | 244 | return result; |
@@ -251,7 +252,7 @@ int main(int argc, char **argv){ | |||
251 | asprintf(&output_message, "%s",temp_string); | 252 | asprintf(&output_message, "%s",temp_string); |
252 | } | 253 | } |
253 | else | 254 | else |
254 | asprintf(&output_message,"No service/process specified"); | 255 | asprintf(&output_message,_("No service/process specified")); |
255 | } | 256 | } |
256 | 257 | ||
257 | else if(vars_to_check==CHECK_MEMUSE) { | 258 | else if(vars_to_check==CHECK_MEMUSE) { |
@@ -269,7 +270,7 @@ int main(int argc, char **argv){ | |||
269 | mem_commitLimit=atof(strtok(recv_buffer,"&")); | 270 | mem_commitLimit=atof(strtok(recv_buffer,"&")); |
270 | mem_commitByte=atof(strtok(NULL,"&")); | 271 | mem_commitByte=atof(strtok(NULL,"&")); |
271 | percent_used_space = (mem_commitByte / mem_commitLimit) * 100; | 272 | percent_used_space = (mem_commitByte / mem_commitLimit) * 100; |
272 | asprintf(&output_message,"Memory usage: total:%.2f Mb - used: %.2f Mb (%.0f%%) - free: %.2f Mb (%.0f%%)", | 273 | asprintf(&output_message,_("Memory usage: total:%.2f Mb - used: %.2f Mb (%.0f%%) - free: %.2f Mb (%.0f%%)"), |
273 | mem_commitLimit / 1048576, mem_commitByte / 1048567, percent_used_space, | 274 | mem_commitLimit / 1048576, mem_commitByte / 1048567, percent_used_space, |
274 | (mem_commitLimit - mem_commitByte) / 1048576, (mem_commitLimit - mem_commitByte) / mem_commitLimit * 100); | 275 | (mem_commitLimit - mem_commitByte) / 1048576, (mem_commitLimit - mem_commitByte) / mem_commitLimit * 100); |
275 | 276 | ||
@@ -325,7 +326,7 @@ int main(int argc, char **argv){ | |||
325 | 326 | ||
326 | } | 327 | } |
327 | else { | 328 | else { |
328 | asprintf(&output_message,"No counter specified"); | 329 | asprintf(&output_message,_("No counter specified")); |
329 | result=STATE_UNKNOWN; | 330 | result=STATE_UNKNOWN; |
330 | } | 331 | } |
331 | } | 332 | } |
@@ -368,7 +369,7 @@ int main(int argc, char **argv){ | |||
368 | 369 | ||
369 | } | 370 | } |
370 | else { | 371 | else { |
371 | asprintf(&output_message,"No file specified"); | 372 | asprintf(&output_message,_("No file specified")); |
372 | result=STATE_UNKNOWN; | 373 | result=STATE_UNKNOWN; |
373 | } | 374 | } |
374 | } | 375 | } |
@@ -382,6 +383,10 @@ int main(int argc, char **argv){ | |||
382 | } | 383 | } |
383 | 384 | ||
384 | 385 | ||
386 | |||
387 | |||
388 | |||
389 | |||
385 | /* process command-line arguments */ | 390 | /* process command-line arguments */ |
386 | int process_arguments(int argc, char **argv){ | 391 | int process_arguments(int argc, char **argv){ |
387 | int c; | 392 | int c; |
@@ -448,7 +453,7 @@ int process_arguments(int argc, char **argv){ | |||
448 | if (is_intnonneg(optarg)) | 453 | if (is_intnonneg(optarg)) |
449 | server_port=atoi(optarg); | 454 | server_port=atoi(optarg); |
450 | else | 455 | else |
451 | die(STATE_UNKNOWN,"Server port an integer (seconds)\nType '%s -h' for additional help\n",progname); | 456 | die(STATE_UNKNOWN,_("Server port an integer (seconds)\nType '%s -h' for additional help\n"),progname); |
452 | break; | 457 | break; |
453 | case 'v': | 458 | case 'v': |
454 | if(strlen(optarg)<4) | 459 | if(strlen(optarg)<4) |
@@ -505,21 +510,53 @@ int process_arguments(int argc, char **argv){ | |||
505 | } | 510 | } |
506 | 511 | ||
507 | 512 | ||
508 | void print_usage(void) | 513 | |
509 | { | 514 | |
510 | printf("Usage: %s -H host -v variable [-p port] [-w warning] [-c critical] [-l params] [-d SHOWALL] [-t timeout]\n",progname); | 515 | |
516 | |||
517 | int strtoularray(unsigned long *array, char *string, char *delim) { | ||
518 | /* split a <delim> delimited string into a long array */ | ||
519 | int idx=0; | ||
520 | char *t1; | ||
521 | |||
522 | for (idx=0;idx<MAX_VALUE_LIST;idx++) | ||
523 | array[idx]=0; | ||
524 | |||
525 | idx=0; | ||
526 | for(t1 = strtok(string,delim);t1 != NULL; t1 = strtok(NULL, delim)) { | ||
527 | if (is_numeric(t1) && idx<MAX_VALUE_LIST) { | ||
528 | array[idx]=strtoul(t1,NULL,10); | ||
529 | idx++; | ||
530 | } else | ||
531 | return FALSE; | ||
532 | } | ||
533 | return TRUE; | ||
511 | } | 534 | } |
512 | 535 | ||
536 | void preparelist(char *string) { | ||
537 | /* Replace all , with & which is the delimiter for the request */ | ||
538 | int i; | ||
513 | 539 | ||
540 | for (i = 0; (size_t)i < strlen(string); i++) | ||
541 | if (string[i] == ',') { | ||
542 | string[i]='&'; | ||
543 | } | ||
544 | } | ||
545 | |||
546 | |||
547 | |||
548 | |||
549 | |||
550 | |||
514 | void print_help(void) | 551 | void print_help(void) |
515 | { | 552 | { |
516 | print_revision(progname,"$Revision$"); | 553 | print_revision(progname,"$Revision$"); |
517 | printf ("\ | 554 | printf (_("\ |
518 | Copyright (c) 2000 Yves Rubin (rubiyz@yahoo.com)\n\n\ | 555 | Copyright (c) 2000 Yves Rubin (rubiyz@yahoo.com)\n\n\ |
519 | This plugin collects data from the NSClient service running on a\n\ | 556 | This plugin collects data from the NSClient service running on a\n\ |
520 | Windows NT/2000/XP server.\n\n"); | 557 | Windows NT/2000/XP server.\n\n")); |
521 | print_usage(); | 558 | print_usage(); |
522 | printf ("\nOptions:\n\ | 559 | printf (_("\nOptions:\n\ |
523 | -H, --hostname=HOST\n\ | 560 | -H, --hostname=HOST\n\ |
524 | Name of the host to check\n\ | 561 | Name of the host to check\n\ |
525 | -p, --port=INTEGER\n\ | 562 | -p, --port=INTEGER\n\ |
@@ -535,40 +572,40 @@ Windows NT/2000/XP server.\n\n"); | |||
535 | -h, --help\n\ | 572 | -h, --help\n\ |
536 | Print this help screen\n\ | 573 | Print this help screen\n\ |
537 | -V, --version\n\ | 574 | -V, --version\n\ |
538 | Print version information\n", | 575 | Print version information\n"), |
539 | PORT, DEFAULT_SOCKET_TIMEOUT); | 576 | PORT, DEFAULT_SOCKET_TIMEOUT); |
540 | printf ("\ | 577 | printf (_("\ |
541 | -v, --variable=STRING\n\ | 578 | -v, --variable=STRING\n\ |
542 | Variable to check. Valid variables are:\n"); | 579 | Variable to check. Valid variables are:\n")); |
543 | printf ("\ | 580 | printf (_("\ |
544 | CLIENTVERSION = Get the NSClient version\n"); | 581 | CLIENTVERSION = Get the NSClient version\n")); |
545 | printf ("\ | 582 | printf (_("\ |
546 | CPULOAD = Average CPU load on last x minutes.\n\ | 583 | CPULOAD = Average CPU load on last x minutes.\n\ |
547 | Request a -l parameter with the following syntax:\n\ | 584 | Request a -l parameter with the following syntax:\n\ |
548 | -l <minutes range>,<warning threshold>,<critical threshold>.\n\ | 585 | -l <minutes range>,<warning threshold>,<critical threshold>.\n\ |
549 | <minute range> should be less than 24*60.\n\ | 586 | <minute range> should be less than 24*60.\n\ |
550 | Thresholds are percentage and up to 10 requests can be done in one shot.\n\ | 587 | Thresholds are percentage and up to 10 requests can be done in one shot.\n\ |
551 | ie: -l 60,90,95,120,90,95\n"); | 588 | ie: -l 60,90,95,120,90,95\n")); |
552 | printf ("\ | 589 | printf (_("\ |
553 | UPTIME = Get the uptime of the machine.\n\ | 590 | UPTIME = Get the uptime of the machine.\n\ |
554 | No specific parameters. No warning or critical threshold\n"); | 591 | No specific parameters. No warning or critical threshold\n")); |
555 | printf ("\ | 592 | printf (_("\ |
556 | USEDDISKSPACE = Size and percentage of disk use.\n\ | 593 | USEDDISKSPACE = Size and percentage of disk use.\n\ |
557 | Request a -l parameter containing the drive letter only.\n\ | 594 | Request a -l parameter containing the drive letter only.\n\ |
558 | Warning and critical thresholds can be specified with -w and -c.\n"); | 595 | Warning and critical thresholds can be specified with -w and -c.\n")); |
559 | printf ("\ | 596 | printf (_("\ |
560 | MEMUSE = Memory use.\n\ | 597 | MEMUSE = Memory use.\n\ |
561 | Warning and critical thresholds can be specified with -w and -c.\n"); | 598 | Warning and critical thresholds can be specified with -w and -c.\n")); |
562 | printf ("\ | 599 | printf (_("\ |
563 | SERVICESTATE = Check the state of one or several services.\n\ | 600 | SERVICESTATE = Check the state of one or several services.\n\ |
564 | Request a -l parameters with the following syntax:\n\ | 601 | Request a -l parameters with the following syntax:\n\ |
565 | -l <service1>,<service2>,<service3>,...\n\ | 602 | -l <service1>,<service2>,<service3>,...\n\ |
566 | You can specify -d SHOWALL in case you want to see working services\n\ | 603 | You can specify -d SHOWALL in case you want to see working services\n\ |
567 | in the returned string.\n"); | 604 | in the returned string.\n")); |
568 | printf ("\ | 605 | printf (_("\ |
569 | PROCSTATE = Check if one or several process are running.\n\ | 606 | PROCSTATE = Check if one or several process are running.\n\ |
570 | Same syntax as SERVICESTATE.\n"); | 607 | Same syntax as SERVICESTATE.\n")); |
571 | printf ("\ | 608 | printf (_("\ |
572 | COUNTER = Check any performance counter of Windows NT/2000.\n\ | 609 | COUNTER = Check any performance counter of Windows NT/2000.\n\ |
573 | Request a -l parameters with the following syntax:\n\ | 610 | Request a -l parameters with the following syntax:\n\ |
574 | -l \"\\\\<performance object>\\\\counter\",\"<description>\n\ | 611 | -l \"\\\\<performance object>\\\\counter\",\"<description>\n\ |
@@ -576,39 +613,20 @@ Windows NT/2000/XP server.\n\n"); | |||
576 | is given to a printf output command which require a float parameters.\n\ | 613 | is given to a printf output command which require a float parameters.\n\ |
577 | Some examples:\n\ | 614 | Some examples:\n\ |
578 | \"Paging file usage is %%.2f %%%%\"\n\ | 615 | \"Paging file usage is %%.2f %%%%\"\n\ |
579 | \"%%.f %%%% paging file used.\"\n"); | 616 | \"%%.f %%%% paging file used.\"\n")); |
580 | printf ("Notes:\n\ | 617 | printf (_("Notes:\n\ |
581 | - The NSClient service should be running on the server to get any information\n\ | 618 | - The NSClient service should be running on the server to get any information\n\ |
582 | (http://nsclient.ready2run.nl).\n\ | 619 | (http://nsclient.ready2run.nl).\n\ |
583 | - Critical thresholds should be lower than warning thresholds\n"); | 620 | - Critical thresholds should be lower than warning thresholds\n")); |
584 | } | 621 | } |
585 | 622 | ||
586 | int strtolarray(unsigned long *array, char *string, char *delim) { | ||
587 | /* split a <delim> delimited string into a long array */ | ||
588 | int idx=0; | ||
589 | char *t1; | ||
590 | 623 | ||
591 | for (idx=0;idx<MAX_VALUE_LIST;idx++) | ||
592 | array[idx]=-1; | ||
593 | |||
594 | idx=0; | ||
595 | for(t1 = strtok(string,delim);t1 != NULL; t1 = strtok(NULL, delim)) { | ||
596 | if (is_numeric(t1) && idx<MAX_VALUE_LIST) { | ||
597 | array[idx]=strtoul(t1,NULL,10); | ||
598 | idx++; | ||
599 | } else | ||
600 | return FALSE; | ||
601 | } | ||
602 | return TRUE; | ||
603 | } | ||
604 | 624 | ||
605 | void preparelist(char *string) { | ||
606 | /* Replace all , with & which is the delimiter for the request */ | ||
607 | int i; | ||
608 | 625 | ||
609 | for (i = 0; (size_t)i < strlen(string); i++) | 626 | void print_usage(void) |
610 | if (string[i] == ',') { | 627 | { |
611 | string[i]='&'; | 628 | printf(_("\ |
612 | } | 629 | Usage: %s -H host -v variable [-p port] [-w warning] [-c critical]\n\ |
630 | [-l params] [-d SHOWALL] [-t timeout]\n"), progname); | ||
631 | printf (_(UT_HLP_VRS), progname, progname); | ||
613 | } | 632 | } |
614 | |||