1 /*****************************************************************************
2 *
3 * Nagios check_nt plugin
4 *
5 * License: GPL
6 * Copyright (c) 2000-2002 Yves Rubin (rubiyz@yahoo.com)
7 * Copyright (c) 2003-2007 Nagios Plugins Development Team
8 *
9 * Description:
10 *
11 * This file contains the check_nt plugin
12 *
13 * This plugin collects data from the NSClient service running on a
14 * Windows NT/2000/XP/2003 server.
15 * This plugin requires NSClient software to run on NT
16 * (http://nsclient.ready2run.nl/)
17 *
18 *
19 * This program is free software: you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published by
21 * the Free Software Foundation, either version 3 of the License, or
22 * (at your option) any later version.
23 *
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
28 *
29 * You should have received a copy of the GNU General Public License
30 * along with this program. If not, see <http://www.gnu.org/licenses/>.
31 *
32 *
33 *****************************************************************************/
35 const char *progname = "check_nt";
36 const char *copyright = "2000-2007";
37 const char *email = "nagiosplug-devel@lists.sourceforge.net";
39 #include "common.h"
40 #include "netutils.h"
41 #include "utils.h"
43 enum checkvars {
44 CHECK_NONE,
45 CHECK_CLIENTVERSION,
46 CHECK_CPULOAD,
47 CHECK_UPTIME,
48 CHECK_USEDDISKSPACE,
49 CHECK_SERVICESTATE,
50 CHECK_PROCSTATE,
51 CHECK_MEMUSE,
52 CHECK_COUNTER,
53 CHECK_FILEAGE,
54 CHECK_INSTANCES
55 };
57 enum {
58 MAX_VALUE_LIST = 30,
59 PORT = 1248
60 };
62 char *server_address=NULL;
63 char *volume_name=NULL;
64 int server_port=PORT;
65 char *value_list=NULL;
66 char *req_password=NULL;
67 unsigned long lvalue_list[MAX_VALUE_LIST];
68 unsigned long warning_value=0L;
69 unsigned long critical_value=0L;
70 int check_warning_value=FALSE;
71 int check_critical_value=FALSE;
72 enum checkvars vars_to_check = CHECK_NONE;
73 int show_all=FALSE;
75 char recv_buffer[MAX_INPUT_BUFFER];
77 void fetch_data (const char* address, int port, const char* sendb);
78 int process_arguments(int, char **);
79 void preparelist(char *string);
80 int strtoularray(unsigned long *array, char *string, const char *delim);
81 void print_help(void);
82 void print_usage(void);
84 int main(int argc, char **argv){
86 /* should be int result = STATE_UNKNOWN; */
88 int return_code = STATE_UNKNOWN;
89 char *send_buffer=NULL;
90 char *output_message=NULL;
91 char *perfdata=NULL;
92 char *temp_string=NULL;
93 char *temp_string_perf=NULL;
94 char *description=NULL,*counter_unit = NULL;
95 char *minval = NULL, *maxval = NULL, *errcvt = NULL;
97 double total_disk_space=0;
98 double free_disk_space=0;
99 double percent_used_space=0;
100 double warning_used_space=0;
101 double critical_used_space=0;
102 double mem_commitLimit=0;
103 double mem_commitByte=0;
104 double fminval = 0, fmaxval = 0;
105 unsigned long utilization;
106 unsigned long uptime;
107 unsigned long age_in_minutes;
108 double counter_value = 0.0;
109 int offset=0;
110 int updays=0;
111 int uphours=0;
112 int upminutes=0;
114 int isPercent = FALSE;
115 int allRight = FALSE;
117 setlocale (LC_ALL, "");
118 bindtextdomain (PACKAGE, LOCALEDIR);
119 textdomain (PACKAGE);
121 /* Parse extra opts if any */
122 argv=np_extra_opts (&argc, argv, progname);
124 if(process_arguments(argc,argv) == ERROR)
125 usage4 (_("Could not parse arguments"));
127 /* initialize alarm signal handling */
128 signal(SIGALRM,socket_timeout_alarm_handler);
130 /* set socket timeout */
131 alarm(socket_timeout);
133 switch (vars_to_check) {
135 case CHECK_CLIENTVERSION:
137 asprintf(&send_buffer, "%s&1", req_password);
138 fetch_data (server_address, server_port, send_buffer);
139 if (value_list != NULL && strcmp(recv_buffer, value_list) != 0) {
140 asprintf (&output_message, _("Wrong client version - running: %s, required: %s"), recv_buffer, value_list);
141 return_code = STATE_WARNING;
142 } else {
143 asprintf (&output_message, "%s", recv_buffer);
144 return_code = STATE_OK;
145 }
146 break;
148 case CHECK_CPULOAD:
150 if (value_list==NULL)
151 output_message = strdup (_("missing -l parameters"));
152 else if (strtoularray(lvalue_list,value_list,",")==FALSE)
153 output_message = strdup (_("wrong -l parameter."));
154 else {
155 /* -l parameters is present with only integers */
156 return_code=STATE_OK;
157 temp_string = strdup (_("CPU Load"));
158 temp_string_perf = strdup (" ");
160 /* loop until one of the parameters is wrong or not present */
161 while (lvalue_list[0+offset]> (unsigned long)0 &&
162 lvalue_list[0+offset]<=(unsigned long)17280 &&
163 lvalue_list[1+offset]> (unsigned long)0 &&
164 lvalue_list[1+offset]<=(unsigned long)100 &&
165 lvalue_list[2+offset]> (unsigned long)0 &&
166 lvalue_list[2+offset]<=(unsigned long)100) {
168 /* Send request and retrieve data */
169 asprintf(&send_buffer,"%s&2&%lu",req_password,lvalue_list[0+offset]);
170 fetch_data (server_address, server_port, send_buffer);
172 utilization=strtoul(recv_buffer,NULL,10);
174 /* Check if any of the request is in a warning or critical state */
175 if(utilization >= lvalue_list[2+offset])
176 return_code=STATE_CRITICAL;
177 else if(utilization >= lvalue_list[1+offset] && return_code<STATE_WARNING)
178 return_code=STATE_WARNING;
180 asprintf(&output_message,_(" %lu%% (%lu min average)"), utilization, lvalue_list[0+offset]);
181 asprintf(&temp_string,"%s%s",temp_string,output_message);
182 asprintf(&perfdata,_(" '%lu min avg Load'=%lu%%;%lu;%lu;0;100"), lvalue_list[0+offset], utilization,
183 lvalue_list[1+offset], lvalue_list[2+offset]);
184 asprintf(&temp_string_perf,"%s%s",temp_string_perf,perfdata);
185 offset+=3; /* move across the array */
186 }
188 if (strlen(temp_string)>10) { /* we had at least one loop */
189 output_message = strdup (temp_string);
190 perfdata = temp_string_perf;
191 } else
192 output_message = strdup (_("not enough values for -l parameters"));
193 }
194 break;
196 case CHECK_UPTIME:
198 asprintf(&send_buffer, "%s&3", req_password);
199 fetch_data (server_address, server_port, send_buffer);
200 uptime=strtoul(recv_buffer,NULL,10);
201 updays = uptime / 86400;
202 uphours = (uptime % 86400) / 3600;
203 upminutes = ((uptime % 86400) % 3600) / 60;
204 asprintf(&output_message,_("System Uptime - %u day(s) %u hour(s) %u minute(s)"),updays,uphours, upminutes);
205 return_code=STATE_OK;
206 break;
208 case CHECK_USEDDISKSPACE:
210 if (value_list==NULL)
211 output_message = strdup (_("missing -l parameters"));
212 else if (strlen(value_list)!=1)
213 output_message = strdup (_("wrong -l argument"));
214 else {
215 asprintf(&send_buffer,"%s&4&%s", req_password, value_list);
216 fetch_data (server_address, server_port, send_buffer);
217 free_disk_space=atof(strtok(recv_buffer,"&"));
218 total_disk_space=atof(strtok(NULL,"&"));
219 percent_used_space = ((total_disk_space - free_disk_space) / total_disk_space) * 100;
220 warning_used_space = ((float)warning_value / 100) * total_disk_space;
221 critical_used_space = ((float)critical_value / 100) * total_disk_space;
223 if (free_disk_space>=0) {
224 asprintf(&temp_string,_("%s:\\ - total: %.2f Gb - used: %.2f Gb (%.0f%%) - free %.2f Gb (%.0f%%)"),
225 value_list, total_disk_space / 1073741824, (total_disk_space - free_disk_space) / 1073741824,
226 percent_used_space, free_disk_space / 1073741824, (free_disk_space / total_disk_space)*100);
227 asprintf(&temp_string_perf,_("'%s:\\ Used Space'=%.2fGb;%.2f;%.2f;0.00;%.2f"), value_list,
228 (total_disk_space - free_disk_space) / 1073741824, warning_used_space / 1073741824,
229 critical_used_space / 1073741824, total_disk_space / 1073741824);
231 if(check_critical_value==TRUE && percent_used_space >= critical_value)
232 return_code=STATE_CRITICAL;
233 else if (check_warning_value==TRUE && percent_used_space >= warning_value)
234 return_code=STATE_WARNING;
235 else
236 return_code=STATE_OK;
238 output_message = strdup (temp_string);
239 perfdata = temp_string_perf;
240 } else {
241 output_message = strdup (_("Free disk space : Invalid drive "));
242 return_code=STATE_UNKNOWN;
243 }
244 }
245 break;
247 case CHECK_SERVICESTATE:
248 case CHECK_PROCSTATE:
250 if (value_list==NULL)
251 output_message = strdup (_("No service/process specified"));
252 else {
253 preparelist(value_list); /* replace , between services with & to send the request */
254 asprintf(&send_buffer,"%s&%u&%s&%s", req_password,(vars_to_check==CHECK_SERVICESTATE)?5:6,
255 (show_all==TRUE) ? "ShowAll" : "ShowFail",value_list);
256 fetch_data (server_address, server_port, send_buffer);
257 return_code=atoi(strtok(recv_buffer,"&"));
258 temp_string=strtok(NULL,"&");
259 output_message = strdup (temp_string);
260 }
261 break;
263 case CHECK_MEMUSE:
265 asprintf(&send_buffer,"%s&7", req_password);
266 fetch_data (server_address, server_port, send_buffer);
267 mem_commitLimit=atof(strtok(recv_buffer,"&"));
268 mem_commitByte=atof(strtok(NULL,"&"));
269 percent_used_space = (mem_commitByte / mem_commitLimit) * 100;
270 warning_used_space = ((float)warning_value / 100) * mem_commitLimit;
271 critical_used_space = ((float)critical_value / 100) * mem_commitLimit;
273 /* Divisor should be 1048567, not 3044515, as we are measuring "Commit Charge" here,
274 which equals RAM + Pagefiles. */
275 asprintf(&output_message,_("Memory usage: total:%.2f Mb - used: %.2f Mb (%.0f%%) - free: %.2f Mb (%.0f%%)"),
276 mem_commitLimit / 1048567, mem_commitByte / 1048567, percent_used_space,
277 (mem_commitLimit - mem_commitByte) / 1048567, (mem_commitLimit - mem_commitByte) / mem_commitLimit * 100);
278 asprintf(&perfdata,_("'Memory usage'=%.2fMb;%.2f;%.2f;0.00;%.2f"), mem_commitByte / 1048567,
279 warning_used_space / 1048567, critical_used_space / 1048567, mem_commitLimit / 1048567);
281 return_code=STATE_OK;
282 if(check_critical_value==TRUE && percent_used_space >= critical_value)
283 return_code=STATE_CRITICAL;
284 else if (check_warning_value==TRUE && percent_used_space >= warning_value)
285 return_code=STATE_WARNING;
287 break;
289 case CHECK_COUNTER:
292 /*
293 CHECK_COUNTER has been modified to provide extensive perfdata information.
294 In order to do this, some modifications have been done to the code
295 and some constraints have been introduced.
297 1) For the sake of simplicity of the code, perfdata information will only be
298 provided when the "description" field is added.
300 2) If the counter you're going to measure is percent-based, the code will detect
301 the percent sign in its name and will attribute minimum (0%) and maximum (100%)
302 values automagically, as well the ĀØ%" sign to graph units.
304 3) OTOH, if the counter is "absolute", you'll have to provide the following
305 the counter unit - that is, the dimensions of the counter you're getting. Examples:
306 pages/s, packets transferred, etc.
308 4) If you want, you may provide the minimum and maximum values to expect. They aren't mandatory,
309 but once specified they MUST have the same order of magnitude and units of -w and -c; otherwise.
310 strange things will happen when you make graphs of your data.
311 */
313 if (value_list == NULL)
314 output_message = strdup (_("No counter specified"));
315 else
316 {
317 preparelist (value_list); /* replace , between services with & to send the request */
318 isPercent = (strchr (value_list, '%') != NULL);
320 strtok (value_list, "&"); /* burn the first parameters */
321 description = strtok (NULL, "&");
322 counter_unit = strtok (NULL, "&");
323 asprintf (&send_buffer, "%s&8&%s", req_password, value_list);
324 fetch_data (server_address, server_port, send_buffer);
325 counter_value = atof (recv_buffer);
328 if (description == NULL)
329 asprintf (&output_message, "%.f", counter_value);
330 else if (isPercent)
331 {
332 counter_unit = strdup ("%");
333 allRight = TRUE;
334 }
336 if ((counter_unit != NULL) && (!allRight))
337 {
338 minval = strtok (NULL, "&");
339 maxval = strtok (NULL, "&");
341 /* All parameters specified. Let's check the numbers */
343 fminval = (minval != NULL) ? strtod (minval, &errcvt) : -1;
344 fmaxval = (minval != NULL) ? strtod (maxval, &errcvt) : -1;
346 if ((fminval == 0) && (minval == errcvt))
347 output_message = strdup (_("Minimum value contains non-numbers"));
348 else
349 {
350 if ((fmaxval == 0) && (maxval == errcvt))
351 output_message = strdup (_("Maximum value contains non-numbers"));
352 else
353 allRight = TRUE; /* Everything is OK. */
355 }
356 }
357 else if ((counter_unit == NULL) && (description != NULL))
358 output_message = strdup (_("No unit counter specified"));
360 if (allRight)
361 {
362 /* Let's format the output string, finally... */
363 if (strstr(description, "%") == NULL) {
364 asprintf (&output_message, "%s = %.2f %s", description, counter_value, counter_unit);
365 } else {
366 /* has formatting, will segv if wrong */
367 asprintf (&output_message, description, counter_value);
368 }
369 asprintf (&output_message, "%s |", output_message);
370 asprintf (&output_message,"%s %s", output_message,
371 fperfdata (description, counter_value,
372 counter_unit, 1, warning_value, 1, critical_value,
373 (!(isPercent) && (minval != NULL)), fminval,
374 (!(isPercent) && (minval != NULL)), fmaxval));
375 }
376 }
378 if (critical_value > warning_value)
379 { /* Normal thresholds */
380 if (check_critical_value == TRUE && counter_value >= critical_value)
381 return_code = STATE_CRITICAL;
382 else if (check_warning_value == TRUE && counter_value >= warning_value)
383 return_code = STATE_WARNING;
384 else
385 return_code = STATE_OK;
386 }
387 else
388 { /* inverse thresholds */
389 return_code = STATE_OK;
390 if (check_critical_value == TRUE && counter_value <= critical_value)
391 return_code = STATE_CRITICAL;
392 else if (check_warning_value == TRUE && counter_value <= warning_value)
393 return_code = STATE_WARNING;
394 }
395 break;
397 case CHECK_FILEAGE:
399 if (value_list==NULL)
400 output_message = strdup (_("No counter specified"));
401 else {
402 preparelist(value_list); /* replace , between services with & to send the request */
403 asprintf(&send_buffer,"%s&9&%s", req_password,value_list);
404 fetch_data (server_address, server_port, send_buffer);
405 age_in_minutes = atoi(strtok(recv_buffer,"&"));
406 description = strtok(NULL,"&");
407 output_message = strdup (description);
409 if (critical_value > warning_value) { /* Normal thresholds */
410 if(check_critical_value==TRUE && age_in_minutes >= critical_value)
411 return_code=STATE_CRITICAL;
412 else if (check_warning_value==TRUE && age_in_minutes >= warning_value)
413 return_code=STATE_WARNING;
414 else
415 return_code=STATE_OK;
416 }
417 else { /* inverse thresholds */
418 if(check_critical_value==TRUE && age_in_minutes <= critical_value)
419 return_code=STATE_CRITICAL;
420 else if (check_warning_value==TRUE && age_in_minutes <= warning_value)
421 return_code=STATE_WARNING;
422 else
423 return_code=STATE_OK;
424 }
425 }
426 break;
428 case CHECK_INSTANCES:
429 if (value_list==NULL)
430 output_message = strdup (_("No counter specified"));
431 else {
432 asprintf(&send_buffer,"%s&10&%s", req_password,value_list);
433 fetch_data (server_address, server_port, send_buffer);
434 if (!strncmp(recv_buffer,"ERROR",5)) {
435 printf("NSClient - %s\n",recv_buffer);
436 exit(STATE_UNKNOWN);
437 }
438 asprintf(&output_message,"%s",recv_buffer);
439 return_code=STATE_OK;
440 }
441 break;
443 case CHECK_NONE:
444 default:
445 usage4 (_("Please specify a variable to check"));
446 break;
448 }
450 /* reset timeout */
451 alarm(0);
453 if (perfdata==NULL)
454 printf("%s\n",output_message);
455 else
456 printf("%s | %s\n",output_message,perfdata);
457 return return_code;
458 }
462 /* process command-line arguments */
463 int process_arguments(int argc, char **argv){
464 int c;
466 int option = 0;
467 static struct option longopts[] =
468 {
469 {"port", required_argument,0,'p'},
470 {"timeout", required_argument,0,'t'},
471 {"critical", required_argument,0,'c'},
472 {"warning", required_argument,0,'w'},
473 {"variable", required_argument,0,'v'},
474 {"hostname", required_argument,0,'H'},
475 {"params", required_argument,0,'l'},
476 {"secret", required_argument,0,'s'},
477 {"display", required_argument,0,'d'},
478 {"version", no_argument, 0,'V'},
479 {"help", no_argument, 0,'h'},
480 {0,0,0,0}
481 };
483 /* no options were supplied */
484 if(argc<2) return ERROR;
486 /* backwards compatibility */
487 if (! is_option(argv[1])) {
488 server_address = strdup(argv[1]);
489 argv[1]=argv[0];
490 argv=&argv[1];
491 argc--;
492 }
494 for (c=1;c<argc;c++) {
495 if(strcmp("-to",argv[c])==0)
496 strcpy(argv[c],"-t");
497 else if (strcmp("-wv",argv[c])==0)
498 strcpy(argv[c],"-w");
499 else if (strcmp("-cv",argv[c])==0)
500 strcpy(argv[c],"-c");
501 }
503 while (1) {
504 c = getopt_long(argc,argv,"+hVH:t:c:w:p:v:l:s:d:",longopts,&option);
506 if (c==-1||c==EOF||c==1)
507 break;
509 switch (c) {
510 case '?': /* print short usage statement if args not parsable */
511 usage5 ();
512 case 'h': /* help */
513 print_help();
514 exit(STATE_OK);
515 case 'V': /* version */
516 print_revision(progname, NP_VERSION);
517 exit(STATE_OK);
518 case 'H': /* hostname */
519 if (server_address) free(server_address);
520 server_address = optarg;
521 break;
522 case 's': /* password */
523 req_password = optarg;
524 break;
525 case 'p': /* port */
526 if (is_intnonneg(optarg))
527 server_port=atoi(optarg);
528 else
529 die(STATE_UNKNOWN,_("Server port must be an integer\n"));
530 break;
531 case 'v':
532 if(strlen(optarg)<4)
533 return ERROR;
534 if(!strcmp(optarg,"CLIENTVERSION"))
535 vars_to_check=CHECK_CLIENTVERSION;
536 else if(!strcmp(optarg,"CPULOAD"))
537 vars_to_check=CHECK_CPULOAD;
538 else if(!strcmp(optarg,"UPTIME"))
539 vars_to_check=CHECK_UPTIME;
540 else if(!strcmp(optarg,"USEDDISKSPACE"))
541 vars_to_check=CHECK_USEDDISKSPACE;
542 else if(!strcmp(optarg,"SERVICESTATE"))
543 vars_to_check=CHECK_SERVICESTATE;
544 else if(!strcmp(optarg,"PROCSTATE"))
545 vars_to_check=CHECK_PROCSTATE;
546 else if(!strcmp(optarg,"MEMUSE"))
547 vars_to_check=CHECK_MEMUSE;
548 else if(!strcmp(optarg,"COUNTER"))
549 vars_to_check=CHECK_COUNTER;
550 else if(!strcmp(optarg,"FILEAGE"))
551 vars_to_check=CHECK_FILEAGE;
552 else if(!strcmp(optarg,"INSTANCES"))
553 vars_to_check=CHECK_INSTANCES;
554 else
555 return ERROR;
556 break;
557 case 'l': /* value list */
558 value_list = optarg;
559 break;
560 case 'w': /* warning threshold */
561 warning_value=strtoul(optarg,NULL,10);
562 check_warning_value=TRUE;
563 break;
564 case 'c': /* critical threshold */
565 critical_value=strtoul(optarg,NULL,10);
566 check_critical_value=TRUE;
567 break;
568 case 'd': /* Display select for services */
569 if (!strcmp(optarg,"SHOWALL"))
570 show_all = TRUE;
571 break;
572 case 't': /* timeout */
573 socket_timeout=atoi(optarg);
574 if(socket_timeout<=0)
575 return ERROR;
576 }
578 }
580 if (vars_to_check==CHECK_NONE)
581 return ERROR;
583 if (req_password == NULL)
584 req_password = strdup (_("None"));
586 return OK;
587 }
591 void fetch_data (const char *address, int port, const char *sendb) {
592 int result;
594 result=process_tcp_request(address, port, sendb, recv_buffer,sizeof(recv_buffer));
596 if(result!=STATE_OK)
597 die (result, _("could not fetch information from server\n"));
599 if (!strncmp(recv_buffer,"ERROR",5))
600 die (STATE_UNKNOWN, "NSClient - %s\n",recv_buffer);
601 }
603 int strtoularray(unsigned long *array, char *string, const char *delim) {
604 /* split a <delim> delimited string into a long array */
605 int idx=0;
606 char *t1;
608 for (idx=0;idx<MAX_VALUE_LIST;idx++)
609 array[idx]=0;
611 idx=0;
612 for(t1 = strtok(string,delim);t1 != NULL; t1 = strtok(NULL, delim)) {
613 if (is_numeric(t1) && idx<MAX_VALUE_LIST) {
614 array[idx]=strtoul(t1,NULL,10);
615 idx++;
616 } else
617 return FALSE;
618 }
619 return TRUE;
620 }
622 void preparelist(char *string) {
623 /* Replace all , with & which is the delimiter for the request */
624 int i;
626 for (i = 0; (size_t)i < strlen(string); i++)
627 if (string[i] == ',') {
628 string[i]='&';
629 }
630 }
634 void print_help(void)
635 {
636 print_revision(progname, NP_VERSION);
638 printf ("Copyright (c) 2000 Yves Rubin (rubiyz@yahoo.com)\n");
639 printf (COPYRIGHT, copyright, email);
641 printf ("%s\n", _("This plugin collects data from the NSClient service running on a"));
642 printf ("%s\n", _("Windows NT/2000/XP/2003 server."));
644 printf ("\n\n");
646 print_usage();
648 printf (_(UT_HELP_VRSN));
649 printf (_(UT_EXTRA_OPTS));
651 printf ("%s\n", _("Options:"));
652 printf (" %s\n", "-H, --hostname=HOST");
653 printf (" %s\n", _("Name of the host to check"));
654 printf (" %s\n", "-p, --port=INTEGER");
655 printf (" %s", _("Optional port number (default: "));
656 printf ("%d)\n", PORT);
657 printf (" %s\n", "-s, --secret=<password>");
658 printf (" %s\n", _("Password needed for the request"));
659 printf (" %s\n", "-w, --warning=INTEGER");
660 printf (" %s\n", _("Threshold which will result in a warning status"));
661 printf (" %s\n", "-c, --critical=INTEGER");
662 printf (" %s\n", _("Threshold which will result in a critical status"));
663 printf (" %s\n", "-t, --timeout=INTEGER");
664 printf (" %s", _("Seconds before connection attempt times out (default: "));
665 printf (" %s\n", "-l, --params=<parameters>");
666 printf (" %s", _("Parameters passed to specified check (see below)"));
667 printf (" %s\n", "-d, --display={SHOWALL}");
668 printf (" %s", _("Display options (currently only SHOWALL works)"));
669 printf ("%d)\n", DEFAULT_SOCKET_TIMEOUT);
670 printf (" %s\n", "-h, --help");
671 printf (" %s\n", _("Print this help screen"));
672 printf (" %s\n", "-V, --version");
673 printf (" %s\n", _("Print version information"));
674 printf (" %s\n", "-v, --variable=STRING");
675 printf (" %s\n\n", _("Variable to check"));
676 printf ("%s\n", _("Valid variables are:"));
677 printf (" %s", "CLIENTVERSION =");
678 printf (" %s\n", _("Get the NSClient version"));
679 printf (" %s\n", _("If -l <version> is specified, will return warning if versions differ."));
680 printf (" %s\n", "CPULOAD =");
681 printf (" %s\n", _("Average CPU load on last x minutes."));
682 printf (" %s\n", _("Request a -l parameter with the following syntax:"));
683 printf (" %s\n", _("-l <minutes range>,<warning threshold>,<critical threshold>."));
684 printf (" %s\n", _("<minute range> should be less than 24*60."));
685 printf (" %s\n", _("Thresholds are percentage and up to 10 requests can be done in one shot."));
686 printf (" %s\n", "ie: -l 60,90,95,120,90,95");
687 printf (" %s\n", "UPTIME =");
688 printf (" %s\n", _("Get the uptime of the machine."));
689 printf (" %s\n", _("No specific parameters. No warning or critical threshold"));
690 printf (" %s\n", "USEDDISKSPACE =");
691 printf (" %s\n", _("Size and percentage of disk use."));
692 printf (" %s\n", _("Request a -l parameter containing the drive letter only."));
693 printf (" %s\n", _("Warning and critical thresholds can be specified with -w and -c."));
694 printf (" %s\n", "MEMUSE =");
695 printf (" %s\n", _("Memory use."));
696 printf (" %s\n", _("Warning and critical thresholds can be specified with -w and -c."));
697 printf (" %s\n", "SERVICESTATE =");
698 printf (" %s\n", _("Check the state of one or several services."));
699 printf (" %s\n", _("Request a -l parameters with the following syntax:"));
700 printf (" %s\n", _("-l <service1>,<service2>,<service3>,..."));
701 printf (" %s\n", _("You can specify -d SHOWALL in case you want to see working services"));
702 printf (" %s\n", _("in the returned string."));
703 printf (" %s\n", "PROCSTATE =");
704 printf (" %s\n", _("Check if one or several process are running."));
705 printf (" %s\n", _("Same syntax as SERVICESTATE."));
706 printf (" %s\n", "COUNTER =");
707 printf (" %s\n", _("Check any performance counter of Windows NT/2000."));
708 printf (" %s\n", _("Request a -l parameters with the following syntax:"));
709 printf (" %s\n", _("-l \"\\\\<performance object>\\\\counter\",\"<description>"));
710 printf (" %s\n", _("The <description> parameter is optional and is given to a printf "));
711 printf (" %s\n", _("output command which requires a float parameter."));
712 printf (" %s\n", _("If <description> does not include \"%%\", it is used as a label."));
713 printf (" %s\n", _("Some examples:"));
714 printf (" %s\n", "\"Paging file usage is %%.2f %%%%\"");
715 printf (" %s\n", "\"%%.f %%%% paging file used.\"");
716 printf (" %s\n", "INSTANCES =");
717 printf (" %s\n", _("Check any performance counter object of Windows NT/2000."));
718 printf (" %s\n", _("Syntax: check_nt -H <hostname> -p <port> -v INSTANCES -l <counter object>"));
719 printf (" %s\n", _("<counter object> is a Windows Perfmon Counter object (eg. Process),"));
720 printf (" %s\n", _("if it is two words, it should be enclosed in quotes"));
721 printf (" %s\n", _("The returned results will be a comma-separated list of instances on "));
722 printf (" %s\n", _(" the selected computer for that object."));
723 printf (" %s\n", _("The purpose of this is to be run from command line to determine what instances"));
724 printf (" %s\n", _(" are available for monitoring without having to log onto the Windows server"));
725 printf (" %s\n", _(" to run Perfmon directly."));
726 printf (" %s\n", _("It can also be used in scripts that automatically create Nagios service"));
727 printf (" %s\n", _(" configuration files."));
728 printf (" %s\n", _("Some examples:"));
729 printf (" %s\n\n", _("check_nt -H 192.168.1.1 -p 1248 -v INSTANCES -l Process"));
731 printf ("%s\n", _("Notes:"));
732 printf (" %s\n", _("- The NSClient service should be running on the server to get any information"));
733 printf (" %s\n", "(http://nsclient.ready2run.nl).");
734 printf (" %s\n", _("- Critical thresholds should be lower than warning thresholds"));
735 printf (" %s\n", _("- Default port 1248 is sometimes in use by other services. The error"));
736 printf (" %s\n", _("output when this happens contains \"Cannot map xxxxx to protocol number\"."));
737 printf (" %s\n", _("One fix for this is to change the port to something else on check_nt "));
738 printf (" %s\n", _("and on the client service it\'s connecting to."));
739 #ifdef NP_EXTRA_OPTS
740 printf (" -%s", _(UT_EXTRA_OPTS_NOTES));
741 #endif
743 printf (_(UT_SUPPORT));
744 }
748 void print_usage(void)
749 {
750 printf (_("Usage:"));
751 printf ("%s -H host -v variable [-p port] [-w warning] [-c critical]\n",progname);
752 printf ("[-l params] [-d SHOWALL] [-t timeout]\n");
753 }