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;
96 char *fds=NULL, *tds=NULL;
98 double total_disk_space=0;
99 double free_disk_space=0;
100 double percent_used_space=0;
101 double warning_used_space=0;
102 double critical_used_space=0;
103 double mem_commitLimit=0;
104 double mem_commitByte=0;
105 double fminval = 0, fmaxval = 0;
106 unsigned long utilization;
107 unsigned long uptime;
108 unsigned long age_in_minutes;
109 double counter_value = 0.0;
110 int offset=0;
111 int updays=0;
112 int uphours=0;
113 int upminutes=0;
115 int isPercent = FALSE;
116 int allRight = FALSE;
118 setlocale (LC_ALL, "");
119 bindtextdomain (PACKAGE, LOCALEDIR);
120 textdomain (PACKAGE);
122 /* Parse extra opts if any */
123 argv=np_extra_opts (&argc, argv, progname);
125 if(process_arguments(argc,argv) == ERROR)
126 usage4 (_("Could not parse arguments"));
128 /* initialize alarm signal handling */
129 signal(SIGALRM,socket_timeout_alarm_handler);
131 /* set socket timeout */
132 alarm(socket_timeout);
134 switch (vars_to_check) {
136 case CHECK_CLIENTVERSION:
138 asprintf(&send_buffer, "%s&1", req_password);
139 fetch_data (server_address, server_port, send_buffer);
140 if (value_list != NULL && strcmp(recv_buffer, value_list) != 0) {
141 asprintf (&output_message, _("Wrong client version - running: %s, required: %s"), recv_buffer, value_list);
142 return_code = STATE_WARNING;
143 } else {
144 asprintf (&output_message, "%s", recv_buffer);
145 return_code = STATE_OK;
146 }
147 break;
149 case CHECK_CPULOAD:
151 if (value_list==NULL)
152 output_message = strdup (_("missing -l parameters"));
153 else if (strtoularray(lvalue_list,value_list,",")==FALSE)
154 output_message = strdup (_("wrong -l parameter."));
155 else {
156 /* -l parameters is present with only integers */
157 return_code=STATE_OK;
158 temp_string = strdup (_("CPU Load"));
159 temp_string_perf = strdup (" ");
161 /* loop until one of the parameters is wrong or not present */
162 while (lvalue_list[0+offset]> (unsigned long)0 &&
163 lvalue_list[0+offset]<=(unsigned long)17280 &&
164 lvalue_list[1+offset]> (unsigned long)0 &&
165 lvalue_list[1+offset]<=(unsigned long)100 &&
166 lvalue_list[2+offset]> (unsigned long)0 &&
167 lvalue_list[2+offset]<=(unsigned long)100) {
169 /* Send request and retrieve data */
170 asprintf(&send_buffer,"%s&2&%lu",req_password,lvalue_list[0+offset]);
171 fetch_data (server_address, server_port, send_buffer);
173 utilization=strtoul(recv_buffer,NULL,10);
175 /* Check if any of the request is in a warning or critical state */
176 if(utilization >= lvalue_list[2+offset])
177 return_code=STATE_CRITICAL;
178 else if(utilization >= lvalue_list[1+offset] && return_code<STATE_WARNING)
179 return_code=STATE_WARNING;
181 asprintf(&output_message,_(" %lu%% (%lu min average)"), utilization, lvalue_list[0+offset]);
182 asprintf(&temp_string,"%s%s",temp_string,output_message);
183 asprintf(&perfdata,_(" '%lu min avg Load'=%lu%%;%lu;%lu;0;100"), lvalue_list[0+offset], utilization,
184 lvalue_list[1+offset], lvalue_list[2+offset]);
185 asprintf(&temp_string_perf,"%s%s",temp_string_perf,perfdata);
186 offset+=3; /* move across the array */
187 }
189 if (strlen(temp_string)>10) { /* we had at least one loop */
190 output_message = strdup (temp_string);
191 perfdata = temp_string_perf;
192 } else
193 output_message = strdup (_("not enough values for -l parameters"));
194 }
195 break;
197 case CHECK_UPTIME:
199 asprintf(&send_buffer, "%s&3", req_password);
200 fetch_data (server_address, server_port, send_buffer);
201 uptime=strtoul(recv_buffer,NULL,10);
202 updays = uptime / 86400;
203 uphours = (uptime % 86400) / 3600;
204 upminutes = ((uptime % 86400) % 3600) / 60;
205 asprintf(&output_message,_("System Uptime - %u day(s) %u hour(s) %u minute(s)"),updays,uphours, upminutes);
206 if (check_critical_value==TRUE && uptime <= critical_value)
207 return_code=STATE_CRITICAL;
208 else if (check_warning_value==TRUE && uptime <= warning_value)
209 return_code=STATE_WARNING;
210 else
211 return_code=STATE_OK;
212 break;
214 case CHECK_USEDDISKSPACE:
216 if (value_list==NULL)
217 output_message = strdup (_("missing -l parameters"));
218 else if (strlen(value_list)!=1)
219 output_message = strdup (_("wrong -l argument"));
220 else {
221 asprintf(&send_buffer,"%s&4&%s", req_password, value_list);
222 fetch_data (server_address, server_port, send_buffer);
223 fds=strtok(recv_buffer,"&");
224 tds=strtok(NULL,"&");
225 if(fds!=NULL)
226 free_disk_space=atof(fds);
227 if(tds!=NULL)
228 total_disk_space=atof(tds);
230 if (total_disk_space>0 && free_disk_space>=0) {
231 percent_used_space = ((total_disk_space - free_disk_space) / total_disk_space) * 100;
232 warning_used_space = ((float)warning_value / 100) * total_disk_space;
233 critical_used_space = ((float)critical_value / 100) * total_disk_space;
235 asprintf(&temp_string,_("%s:\\ - total: %.2f Gb - used: %.2f Gb (%.0f%%) - free %.2f Gb (%.0f%%)"),
236 value_list, total_disk_space / 1073741824, (total_disk_space - free_disk_space) / 1073741824,
237 percent_used_space, free_disk_space / 1073741824, (free_disk_space / total_disk_space)*100);
238 asprintf(&temp_string_perf,_("'%s:\\ Used Space'=%.2fGb;%.2f;%.2f;0.00;%.2f"), value_list,
239 (total_disk_space - free_disk_space) / 1073741824, warning_used_space / 1073741824,
240 critical_used_space / 1073741824, total_disk_space / 1073741824);
242 if(check_critical_value==TRUE && percent_used_space >= critical_value)
243 return_code=STATE_CRITICAL;
244 else if (check_warning_value==TRUE && percent_used_space >= warning_value)
245 return_code=STATE_WARNING;
246 else
247 return_code=STATE_OK;
249 output_message = strdup (temp_string);
250 perfdata = temp_string_perf;
251 } else {
252 output_message = strdup (_("Free disk space : Invalid drive"));
253 return_code=STATE_UNKNOWN;
254 }
255 }
256 break;
258 case CHECK_SERVICESTATE:
259 case CHECK_PROCSTATE:
261 if (value_list==NULL)
262 output_message = strdup (_("No service/process specified"));
263 else {
264 preparelist(value_list); /* replace , between services with & to send the request */
265 asprintf(&send_buffer,"%s&%u&%s&%s", req_password,(vars_to_check==CHECK_SERVICESTATE)?5:6,
266 (show_all==TRUE) ? "ShowAll" : "ShowFail",value_list);
267 fetch_data (server_address, server_port, send_buffer);
268 return_code=atoi(strtok(recv_buffer,"&"));
269 temp_string=strtok(NULL,"&");
270 output_message = strdup (temp_string);
271 }
272 break;
274 case CHECK_MEMUSE:
276 asprintf(&send_buffer,"%s&7", req_password);
277 fetch_data (server_address, server_port, send_buffer);
278 mem_commitLimit=atof(strtok(recv_buffer,"&"));
279 mem_commitByte=atof(strtok(NULL,"&"));
280 percent_used_space = (mem_commitByte / mem_commitLimit) * 100;
281 warning_used_space = ((float)warning_value / 100) * mem_commitLimit;
282 critical_used_space = ((float)critical_value / 100) * mem_commitLimit;
284 /* Divisor should be 1048567, not 3044515, as we are measuring "Commit Charge" here,
285 which equals RAM + Pagefiles. */
286 asprintf(&output_message,_("Memory usage: total:%.2f Mb - used: %.2f Mb (%.0f%%) - free: %.2f Mb (%.0f%%)"),
287 mem_commitLimit / 1048567, mem_commitByte / 1048567, percent_used_space,
288 (mem_commitLimit - mem_commitByte) / 1048567, (mem_commitLimit - mem_commitByte) / mem_commitLimit * 100);
289 asprintf(&perfdata,_("'Memory usage'=%.2fMb;%.2f;%.2f;0.00;%.2f"), mem_commitByte / 1048567,
290 warning_used_space / 1048567, critical_used_space / 1048567, mem_commitLimit / 1048567);
292 return_code=STATE_OK;
293 if(check_critical_value==TRUE && percent_used_space >= critical_value)
294 return_code=STATE_CRITICAL;
295 else if (check_warning_value==TRUE && percent_used_space >= warning_value)
296 return_code=STATE_WARNING;
298 break;
300 case CHECK_COUNTER:
303 /*
304 CHECK_COUNTER has been modified to provide extensive perfdata information.
305 In order to do this, some modifications have been done to the code
306 and some constraints have been introduced.
308 1) For the sake of simplicity of the code, perfdata information will only be
309 provided when the "description" field is added.
311 2) If the counter you're going to measure is percent-based, the code will detect
312 the percent sign in its name and will attribute minimum (0%) and maximum (100%)
313 values automagically, as well the ĀØ%" sign to graph units.
315 3) OTOH, if the counter is "absolute", you'll have to provide the following
316 the counter unit - that is, the dimensions of the counter you're getting. Examples:
317 pages/s, packets transferred, etc.
319 4) If you want, you may provide the minimum and maximum values to expect. They aren't mandatory,
320 but once specified they MUST have the same order of magnitude and units of -w and -c; otherwise.
321 strange things will happen when you make graphs of your data.
322 */
324 if (value_list == NULL)
325 output_message = strdup (_("No counter specified"));
326 else
327 {
328 preparelist (value_list); /* replace , between services with & to send the request */
329 isPercent = (strchr (value_list, '%') != NULL);
331 strtok (value_list, "&"); /* burn the first parameters */
332 description = strtok (NULL, "&");
333 counter_unit = strtok (NULL, "&");
334 asprintf (&send_buffer, "%s&8&%s", req_password, value_list);
335 fetch_data (server_address, server_port, send_buffer);
336 counter_value = atof (recv_buffer);
338 if (description == NULL)
339 asprintf (&output_message, "%.f", counter_value);
340 else if (isPercent)
341 {
342 counter_unit = strdup ("%");
343 allRight = TRUE;
344 }
346 if ((counter_unit != NULL) && (!allRight))
347 {
348 minval = strtok (NULL, "&");
349 maxval = strtok (NULL, "&");
351 /* All parameters specified. Let's check the numbers */
353 fminval = (minval != NULL) ? strtod (minval, &errcvt) : -1;
354 fmaxval = (minval != NULL) ? strtod (maxval, &errcvt) : -1;
356 if ((fminval == 0) && (minval == errcvt))
357 output_message = strdup (_("Minimum value contains non-numbers"));
358 else
359 {
360 if ((fmaxval == 0) && (maxval == errcvt))
361 output_message = strdup (_("Maximum value contains non-numbers"));
362 else
363 allRight = TRUE; /* Everything is OK. */
365 }
366 }
367 else if ((counter_unit == NULL) && (description != NULL))
368 output_message = strdup (_("No unit counter specified"));
370 if (allRight)
371 {
372 /* Let's format the output string, finally... */
373 if (strstr(description, "%") == NULL) {
374 asprintf (&output_message, "%s = %.2f %s", description, counter_value, counter_unit);
375 } else {
376 /* has formatting, will segv if wrong */
377 asprintf (&output_message, description, counter_value);
378 }
379 asprintf (&output_message, "%s |", output_message);
380 asprintf (&output_message,"%s %s", output_message,
381 fperfdata (description, counter_value,
382 counter_unit, 1, warning_value, 1, critical_value,
383 (!(isPercent) && (minval != NULL)), fminval,
384 (!(isPercent) && (minval != NULL)), fmaxval));
385 }
386 }
388 if (critical_value > warning_value)
389 { /* Normal thresholds */
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 else
395 return_code = STATE_OK;
396 }
397 else
398 { /* inverse thresholds */
399 return_code = STATE_OK;
400 if (check_critical_value == TRUE && counter_value <= critical_value)
401 return_code = STATE_CRITICAL;
402 else if (check_warning_value == TRUE && counter_value <= warning_value)
403 return_code = STATE_WARNING;
404 }
405 break;
407 case CHECK_FILEAGE:
409 if (value_list==NULL)
410 output_message = strdup (_("No counter specified"));
411 else {
412 preparelist(value_list); /* replace , between services with & to send the request */
413 asprintf(&send_buffer,"%s&9&%s", req_password,value_list);
414 fetch_data (server_address, server_port, send_buffer);
415 age_in_minutes = atoi(strtok(recv_buffer,"&"));
416 description = strtok(NULL,"&");
417 output_message = strdup (description);
419 if (critical_value > warning_value) { /* Normal thresholds */
420 if(check_critical_value==TRUE && age_in_minutes >= critical_value)
421 return_code=STATE_CRITICAL;
422 else if (check_warning_value==TRUE && age_in_minutes >= warning_value)
423 return_code=STATE_WARNING;
424 else
425 return_code=STATE_OK;
426 }
427 else { /* inverse thresholds */
428 if(check_critical_value==TRUE && age_in_minutes <= critical_value)
429 return_code=STATE_CRITICAL;
430 else if (check_warning_value==TRUE && age_in_minutes <= warning_value)
431 return_code=STATE_WARNING;
432 else
433 return_code=STATE_OK;
434 }
435 }
436 break;
438 case CHECK_INSTANCES:
439 if (value_list==NULL)
440 output_message = strdup (_("No counter specified"));
441 else {
442 asprintf(&send_buffer,"%s&10&%s", req_password,value_list);
443 fetch_data (server_address, server_port, send_buffer);
444 if (!strncmp(recv_buffer,"ERROR",5)) {
445 printf("NSClient - %s\n",recv_buffer);
446 exit(STATE_UNKNOWN);
447 }
448 asprintf(&output_message,"%s",recv_buffer);
449 return_code=STATE_OK;
450 }
451 break;
453 case CHECK_NONE:
454 default:
455 usage4 (_("Please specify a variable to check"));
456 break;
458 }
460 /* reset timeout */
461 alarm(0);
463 if (perfdata==NULL)
464 printf("%s\n",output_message);
465 else
466 printf("%s | %s\n",output_message,perfdata);
467 return return_code;
468 }
472 /* process command-line arguments */
473 int process_arguments(int argc, char **argv){
474 int c;
476 int option = 0;
477 static struct option longopts[] =
478 {
479 {"port", required_argument,0,'p'},
480 {"timeout", required_argument,0,'t'},
481 {"critical", required_argument,0,'c'},
482 {"warning", required_argument,0,'w'},
483 {"variable", required_argument,0,'v'},
484 {"hostname", required_argument,0,'H'},
485 {"params", required_argument,0,'l'},
486 {"secret", required_argument,0,'s'},
487 {"display", required_argument,0,'d'},
488 {"unknown-timeout", no_argument, 0, 'u'},
489 {"version", no_argument, 0,'V'},
490 {"help", no_argument, 0,'h'},
491 {0,0,0,0}
492 };
494 /* no options were supplied */
495 if(argc<2) return ERROR;
497 /* backwards compatibility */
498 if (! is_option(argv[1])) {
499 server_address = strdup(argv[1]);
500 argv[1]=argv[0];
501 argv=&argv[1];
502 argc--;
503 }
505 for (c=1;c<argc;c++) {
506 if(strcmp("-to",argv[c])==0)
507 strcpy(argv[c],"-t");
508 else if (strcmp("-wv",argv[c])==0)
509 strcpy(argv[c],"-w");
510 else if (strcmp("-cv",argv[c])==0)
511 strcpy(argv[c],"-c");
512 }
514 while (1) {
515 c = getopt_long(argc,argv,"+hVH:t:c:w:p:v:l:s:d:u",longopts,&option);
517 if (c==-1||c==EOF||c==1)
518 break;
520 switch (c) {
521 case '?': /* print short usage statement if args not parsable */
522 usage5 ();
523 case 'h': /* help */
524 print_help();
525 exit(STATE_OK);
526 case 'V': /* version */
527 print_revision(progname, NP_VERSION);
528 exit(STATE_OK);
529 case 'H': /* hostname */
530 server_address = optarg;
531 break;
532 case 's': /* password */
533 req_password = optarg;
534 break;
535 case 'p': /* port */
536 if (is_intnonneg(optarg))
537 server_port=atoi(optarg);
538 else
539 die(STATE_UNKNOWN,_("Server port must be an integer\n"));
540 break;
541 case 'v':
542 if(strlen(optarg)<4)
543 return ERROR;
544 if(!strcmp(optarg,"CLIENTVERSION"))
545 vars_to_check=CHECK_CLIENTVERSION;
546 else if(!strcmp(optarg,"CPULOAD"))
547 vars_to_check=CHECK_CPULOAD;
548 else if(!strcmp(optarg,"UPTIME"))
549 vars_to_check=CHECK_UPTIME;
550 else if(!strcmp(optarg,"USEDDISKSPACE"))
551 vars_to_check=CHECK_USEDDISKSPACE;
552 else if(!strcmp(optarg,"SERVICESTATE"))
553 vars_to_check=CHECK_SERVICESTATE;
554 else if(!strcmp(optarg,"PROCSTATE"))
555 vars_to_check=CHECK_PROCSTATE;
556 else if(!strcmp(optarg,"MEMUSE"))
557 vars_to_check=CHECK_MEMUSE;
558 else if(!strcmp(optarg,"COUNTER"))
559 vars_to_check=CHECK_COUNTER;
560 else if(!strcmp(optarg,"FILEAGE"))
561 vars_to_check=CHECK_FILEAGE;
562 else if(!strcmp(optarg,"INSTANCES"))
563 vars_to_check=CHECK_INSTANCES;
564 else
565 return ERROR;
566 break;
567 case 'l': /* value list */
568 value_list = optarg;
569 break;
570 case 'w': /* warning threshold */
571 warning_value=strtoul(optarg,NULL,10);
572 check_warning_value=TRUE;
573 break;
574 case 'c': /* critical threshold */
575 critical_value=strtoul(optarg,NULL,10);
576 check_critical_value=TRUE;
577 break;
578 case 'd': /* Display select for services */
579 if (!strcmp(optarg,"SHOWALL"))
580 show_all = TRUE;
581 break;
582 case 'u':
583 socket_timeout_state=STATE_UNKNOWN;
584 break;
585 case 't': /* timeout */
586 socket_timeout=atoi(optarg);
587 if(socket_timeout<=0)
588 return ERROR;
589 }
591 }
592 if (server_address == NULL)
593 usage4 (_("You must provide a server address or host name"));
595 if (vars_to_check==CHECK_NONE)
596 return ERROR;
598 if (req_password == NULL)
599 req_password = strdup (_("None"));
601 return OK;
602 }
606 void fetch_data (const char *address, int port, const char *sendb) {
607 int result;
609 result=process_tcp_request(address, port, sendb, recv_buffer,sizeof(recv_buffer));
611 if(result!=STATE_OK)
612 die (result, _("could not fetch information from server\n"));
614 if (!strncmp(recv_buffer,"ERROR",5))
615 die (STATE_UNKNOWN, "NSClient - %s\n",recv_buffer);
616 }
618 int strtoularray(unsigned long *array, char *string, const char *delim) {
619 /* split a <delim> delimited string into a long array */
620 int idx=0;
621 char *t1;
623 for (idx=0;idx<MAX_VALUE_LIST;idx++)
624 array[idx]=0;
626 idx=0;
627 for(t1 = strtok(string,delim);t1 != NULL; t1 = strtok(NULL, delim)) {
628 if (is_numeric(t1) && idx<MAX_VALUE_LIST) {
629 array[idx]=strtoul(t1,NULL,10);
630 idx++;
631 } else
632 return FALSE;
633 }
634 return TRUE;
635 }
637 void preparelist(char *string) {
638 /* Replace all , with & which is the delimiter for the request */
639 int i;
641 for (i = 0; (size_t)i < strlen(string); i++)
642 if (string[i] == ',') {
643 string[i]='&';
644 }
645 }
649 void print_help(void)
650 {
651 print_revision(progname, NP_VERSION);
653 printf ("Copyright (c) 2000 Yves Rubin (rubiyz@yahoo.com)\n");
654 printf (COPYRIGHT, copyright, email);
656 printf ("%s\n", _("This plugin collects data from the NSClient service running on a"));
657 printf ("%s\n", _("Windows NT/2000/XP/2003 server."));
659 printf ("\n\n");
661 print_usage();
663 printf (UT_HELP_VRSN);
664 printf (UT_EXTRA_OPTS);
666 printf ("%s\n", _("Options:"));
667 printf (" %s\n", "-H, --hostname=HOST");
668 printf (" %s\n", _("Name of the host to check"));
669 printf (" %s\n", "-p, --port=INTEGER");
670 printf (" %s", _("Optional port number (default: "));
671 printf ("%d)\n", PORT);
672 printf (" %s\n", "-s, --secret=<password>");
673 printf (" %s\n", _("Password needed for the request"));
674 printf (" %s\n", "-w, --warning=INTEGER");
675 printf (" %s\n", _("Threshold which will result in a warning status"));
676 printf (" %s\n", "-c, --critical=INTEGER");
677 printf (" %s\n", _("Threshold which will result in a critical status"));
678 printf (" %s\n", "-t, --timeout=INTEGER");
679 printf (" %s", _("Seconds before connection attempt times out (default: "));
680 printf (" %s\n", "-l, --params=<parameters>");
681 printf (" %s", _("Parameters passed to specified check (see below)"));
682 printf (" %s\n", "-d, --display={SHOWALL}");
683 printf (" %s", _("Display options (currently only SHOWALL works)"));
684 printf (" %s\n", "-u, --unknown-timeout");
685 printf (" %s", _("Return UNKNOWN on timeouts"));
686 printf ("%d)\n", DEFAULT_SOCKET_TIMEOUT);
687 printf (" %s\n", "-h, --help");
688 printf (" %s\n", _("Print this help screen"));
689 printf (" %s\n", "-V, --version");
690 printf (" %s\n", _("Print version information"));
691 printf (" %s\n", "-v, --variable=STRING");
692 printf (" %s\n\n", _("Variable to check"));
693 printf ("%s\n", _("Valid variables are:"));
694 printf (" %s", "CLIENTVERSION =");
695 printf (" %s\n", _("Get the NSClient version"));
696 printf (" %s\n", _("If -l <version> is specified, will return warning if versions differ."));
697 printf (" %s\n", "CPULOAD =");
698 printf (" %s\n", _("Average CPU load on last x minutes."));
699 printf (" %s\n", _("Request a -l parameter with the following syntax:"));
700 printf (" %s\n", _("-l <minutes range>,<warning threshold>,<critical threshold>."));
701 printf (" %s\n", _("<minute range> should be less than 24*60."));
702 printf (" %s\n", _("Thresholds are percentage and up to 10 requests can be done in one shot."));
703 printf (" %s\n", "ie: -l 60,90,95,120,90,95");
704 printf (" %s\n", "UPTIME =");
705 printf (" %s\n", _("Get the uptime of the machine."));
706 printf (" %s\n", _("No specific parameters. No warning or critical threshold"));
707 printf (" %s\n", "USEDDISKSPACE =");
708 printf (" %s\n", _("Size and percentage of disk use."));
709 printf (" %s\n", _("Request a -l parameter containing the drive letter only."));
710 printf (" %s\n", _("Warning and critical thresholds can be specified with -w and -c."));
711 printf (" %s\n", "MEMUSE =");
712 printf (" %s\n", _("Memory use."));
713 printf (" %s\n", _("Warning and critical thresholds can be specified with -w and -c."));
714 printf (" %s\n", "SERVICESTATE =");
715 printf (" %s\n", _("Check the state of one or several services."));
716 printf (" %s\n", _("Request a -l parameters with the following syntax:"));
717 printf (" %s\n", _("-l <service1>,<service2>,<service3>,..."));
718 printf (" %s\n", _("You can specify -d SHOWALL in case you want to see working services"));
719 printf (" %s\n", _("in the returned string."));
720 printf (" %s\n", "PROCSTATE =");
721 printf (" %s\n", _("Check if one or several process are running."));
722 printf (" %s\n", _("Same syntax as SERVICESTATE."));
723 printf (" %s\n", "COUNTER =");
724 printf (" %s\n", _("Check any performance counter of Windows NT/2000."));
725 printf (" %s\n", _("Request a -l parameters with the following syntax:"));
726 printf (" %s\n", _("-l \"\\\\<performance object>\\\\counter\",\"<description>"));
727 printf (" %s\n", _("The <description> parameter is optional and is given to a printf "));
728 printf (" %s\n", _("output command which requires a float parameter."));
729 printf (" %s\n", _("If <description> does not include \"%%\", it is used as a label."));
730 printf (" %s\n", _("Some examples:"));
731 printf (" %s\n", "\"Paging file usage is %%.2f %%%%\"");
732 printf (" %s\n", "\"%%.f %%%% paging file used.\"");
733 printf (" %s\n", "INSTANCES =");
734 printf (" %s\n", _("Check any performance counter object of Windows NT/2000."));
735 printf (" %s\n", _("Syntax: check_nt -H <hostname> -p <port> -v INSTANCES -l <counter object>"));
736 printf (" %s\n", _("<counter object> is a Windows Perfmon Counter object (eg. Process),"));
737 printf (" %s\n", _("if it is two words, it should be enclosed in quotes"));
738 printf (" %s\n", _("The returned results will be a comma-separated list of instances on "));
739 printf (" %s\n", _(" the selected computer for that object."));
740 printf (" %s\n", _("The purpose of this is to be run from command line to determine what instances"));
741 printf (" %s\n", _(" are available for monitoring without having to log onto the Windows server"));
742 printf (" %s\n", _(" to run Perfmon directly."));
743 printf (" %s\n", _("It can also be used in scripts that automatically create Nagios service"));
744 printf (" %s\n", _(" configuration files."));
745 printf (" %s\n", _("Some examples:"));
746 printf (" %s\n\n", _("check_nt -H 192.168.1.1 -p 1248 -v INSTANCES -l Process"));
748 printf ("%s\n", _("Notes:"));
749 printf (" %s\n", _("- The NSClient service should be running on the server to get any information"));
750 printf (" %s\n", "(http://nsclient.ready2run.nl).");
751 printf (" %s\n", _("- Critical thresholds should be lower than warning thresholds"));
752 printf (" %s\n", _("- Default port 1248 is sometimes in use by other services. The error"));
753 printf (" %s\n", _("output when this happens contains \"Cannot map xxxxx to protocol number\"."));
754 printf (" %s\n", _("One fix for this is to change the port to something else on check_nt "));
755 printf (" %s\n", _("and on the client service it\'s connecting to."));
757 printf (UT_SUPPORT);
758 }
762 void print_usage(void)
763 {
764 printf ("%s\n", _("Usage:"));
765 printf ("%s -H host -v variable [-p port] [-w warning] [-c critical]\n",progname);
766 printf ("[-l params] [-d SHOWALL] [-u] [-t timeout]\n");
767 }