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 return_code=STATE_OK;
207 break;
209 case CHECK_USEDDISKSPACE:
211 if (value_list==NULL)
212 output_message = strdup (_("missing -l parameters"));
213 else if (strlen(value_list)!=1)
214 output_message = strdup (_("wrong -l argument"));
215 else {
216 asprintf(&send_buffer,"%s&4&%s", req_password, value_list);
217 fetch_data (server_address, server_port, send_buffer);
218 fds=strtok(recv_buffer,"&");
219 tds=strtok(NULL,"&");
220 if(fds!=NULL)
221 free_disk_space=atof(fds);
222 if(tds!=NULL)
223 total_disk_space=atof(tds);
225 if (total_disk_space>0 && free_disk_space>=0) {
226 percent_used_space = ((total_disk_space - free_disk_space) / total_disk_space) * 100;
227 warning_used_space = ((float)warning_value / 100) * total_disk_space;
228 critical_used_space = ((float)critical_value / 100) * total_disk_space;
230 asprintf(&temp_string,_("%s:\\ - total: %.2f Gb - used: %.2f Gb (%.0f%%) - free %.2f Gb (%.0f%%)"),
231 value_list, total_disk_space / 1073741824, (total_disk_space - free_disk_space) / 1073741824,
232 percent_used_space, free_disk_space / 1073741824, (free_disk_space / total_disk_space)*100);
233 asprintf(&temp_string_perf,_("'%s:\\ Used Space'=%.2fGb;%.2f;%.2f;0.00;%.2f"), value_list,
234 (total_disk_space - free_disk_space) / 1073741824, warning_used_space / 1073741824,
235 critical_used_space / 1073741824, total_disk_space / 1073741824);
237 if(check_critical_value==TRUE && percent_used_space >= critical_value)
238 return_code=STATE_CRITICAL;
239 else if (check_warning_value==TRUE && percent_used_space >= warning_value)
240 return_code=STATE_WARNING;
241 else
242 return_code=STATE_OK;
244 output_message = strdup (temp_string);
245 perfdata = temp_string_perf;
246 } else {
247 output_message = strdup (_("Free disk space : Invalid drive"));
248 return_code=STATE_UNKNOWN;
249 }
250 }
251 break;
253 case CHECK_SERVICESTATE:
254 case CHECK_PROCSTATE:
256 if (value_list==NULL)
257 output_message = strdup (_("No service/process specified"));
258 else {
259 preparelist(value_list); /* replace , between services with & to send the request */
260 asprintf(&send_buffer,"%s&%u&%s&%s", req_password,(vars_to_check==CHECK_SERVICESTATE)?5:6,
261 (show_all==TRUE) ? "ShowAll" : "ShowFail",value_list);
262 fetch_data (server_address, server_port, send_buffer);
263 return_code=atoi(strtok(recv_buffer,"&"));
264 temp_string=strtok(NULL,"&");
265 output_message = strdup (temp_string);
266 }
267 break;
269 case CHECK_MEMUSE:
271 asprintf(&send_buffer,"%s&7", req_password);
272 fetch_data (server_address, server_port, send_buffer);
273 mem_commitLimit=atof(strtok(recv_buffer,"&"));
274 mem_commitByte=atof(strtok(NULL,"&"));
275 percent_used_space = (mem_commitByte / mem_commitLimit) * 100;
276 warning_used_space = ((float)warning_value / 100) * mem_commitLimit;
277 critical_used_space = ((float)critical_value / 100) * mem_commitLimit;
279 /* Divisor should be 1048567, not 3044515, as we are measuring "Commit Charge" here,
280 which equals RAM + Pagefiles. */
281 asprintf(&output_message,_("Memory usage: total:%.2f Mb - used: %.2f Mb (%.0f%%) - free: %.2f Mb (%.0f%%)"),
282 mem_commitLimit / 1048567, mem_commitByte / 1048567, percent_used_space,
283 (mem_commitLimit - mem_commitByte) / 1048567, (mem_commitLimit - mem_commitByte) / mem_commitLimit * 100);
284 asprintf(&perfdata,_("'Memory usage'=%.2fMb;%.2f;%.2f;0.00;%.2f"), mem_commitByte / 1048567,
285 warning_used_space / 1048567, critical_used_space / 1048567, mem_commitLimit / 1048567);
287 return_code=STATE_OK;
288 if(check_critical_value==TRUE && percent_used_space >= critical_value)
289 return_code=STATE_CRITICAL;
290 else if (check_warning_value==TRUE && percent_used_space >= warning_value)
291 return_code=STATE_WARNING;
293 break;
295 case CHECK_COUNTER:
298 /*
299 CHECK_COUNTER has been modified to provide extensive perfdata information.
300 In order to do this, some modifications have been done to the code
301 and some constraints have been introduced.
303 1) For the sake of simplicity of the code, perfdata information will only be
304 provided when the "description" field is added.
306 2) If the counter you're going to measure is percent-based, the code will detect
307 the percent sign in its name and will attribute minimum (0%) and maximum (100%)
308 values automagically, as well the ĀØ%" sign to graph units.
310 3) OTOH, if the counter is "absolute", you'll have to provide the following
311 the counter unit - that is, the dimensions of the counter you're getting. Examples:
312 pages/s, packets transferred, etc.
314 4) If you want, you may provide the minimum and maximum values to expect. They aren't mandatory,
315 but once specified they MUST have the same order of magnitude and units of -w and -c; otherwise.
316 strange things will happen when you make graphs of your data.
317 */
319 if (value_list == NULL)
320 output_message = strdup (_("No counter specified"));
321 else
322 {
323 preparelist (value_list); /* replace , between services with & to send the request */
324 isPercent = (strchr (value_list, '%') != NULL);
326 strtok (value_list, "&"); /* burn the first parameters */
327 description = strtok (NULL, "&");
328 counter_unit = strtok (NULL, "&");
329 asprintf (&send_buffer, "%s&8&%s", req_password, value_list);
330 fetch_data (server_address, server_port, send_buffer);
331 counter_value = atof (recv_buffer);
333 if (description == NULL)
334 asprintf (&output_message, "%.f", counter_value);
335 else if (isPercent)
336 {
337 counter_unit = strdup ("%");
338 allRight = TRUE;
339 }
341 if ((counter_unit != NULL) && (!allRight))
342 {
343 minval = strtok (NULL, "&");
344 maxval = strtok (NULL, "&");
346 /* All parameters specified. Let's check the numbers */
348 fminval = (minval != NULL) ? strtod (minval, &errcvt) : -1;
349 fmaxval = (minval != NULL) ? strtod (maxval, &errcvt) : -1;
351 if ((fminval == 0) && (minval == errcvt))
352 output_message = strdup (_("Minimum value contains non-numbers"));
353 else
354 {
355 if ((fmaxval == 0) && (maxval == errcvt))
356 output_message = strdup (_("Maximum value contains non-numbers"));
357 else
358 allRight = TRUE; /* Everything is OK. */
360 }
361 }
362 else if ((counter_unit == NULL) && (description != NULL))
363 output_message = strdup (_("No unit counter specified"));
365 if (allRight)
366 {
367 /* Let's format the output string, finally... */
368 if (strstr(description, "%") == NULL) {
369 asprintf (&output_message, "%s = %.2f %s", description, counter_value, counter_unit);
370 } else {
371 /* has formatting, will segv if wrong */
372 asprintf (&output_message, description, counter_value);
373 }
374 asprintf (&output_message, "%s |", output_message);
375 asprintf (&output_message,"%s %s", output_message,
376 fperfdata (description, counter_value,
377 counter_unit, 1, warning_value, 1, critical_value,
378 (!(isPercent) && (minval != NULL)), fminval,
379 (!(isPercent) && (minval != NULL)), fmaxval));
380 }
381 }
383 if (critical_value > warning_value)
384 { /* Normal thresholds */
385 if (check_critical_value == TRUE && counter_value >= critical_value)
386 return_code = STATE_CRITICAL;
387 else if (check_warning_value == TRUE && counter_value >= warning_value)
388 return_code = STATE_WARNING;
389 else
390 return_code = STATE_OK;
391 }
392 else
393 { /* inverse thresholds */
394 return_code = STATE_OK;
395 if (check_critical_value == TRUE && counter_value <= critical_value)
396 return_code = STATE_CRITICAL;
397 else if (check_warning_value == TRUE && counter_value <= warning_value)
398 return_code = STATE_WARNING;
399 }
400 break;
402 case CHECK_FILEAGE:
404 if (value_list==NULL)
405 output_message = strdup (_("No counter specified"));
406 else {
407 preparelist(value_list); /* replace , between services with & to send the request */
408 asprintf(&send_buffer,"%s&9&%s", req_password,value_list);
409 fetch_data (server_address, server_port, send_buffer);
410 age_in_minutes = atoi(strtok(recv_buffer,"&"));
411 description = strtok(NULL,"&");
412 output_message = strdup (description);
414 if (critical_value > warning_value) { /* Normal thresholds */
415 if(check_critical_value==TRUE && age_in_minutes >= critical_value)
416 return_code=STATE_CRITICAL;
417 else if (check_warning_value==TRUE && age_in_minutes >= warning_value)
418 return_code=STATE_WARNING;
419 else
420 return_code=STATE_OK;
421 }
422 else { /* inverse thresholds */
423 if(check_critical_value==TRUE && age_in_minutes <= critical_value)
424 return_code=STATE_CRITICAL;
425 else if (check_warning_value==TRUE && age_in_minutes <= warning_value)
426 return_code=STATE_WARNING;
427 else
428 return_code=STATE_OK;
429 }
430 }
431 break;
433 case CHECK_INSTANCES:
434 if (value_list==NULL)
435 output_message = strdup (_("No counter specified"));
436 else {
437 asprintf(&send_buffer,"%s&10&%s", req_password,value_list);
438 fetch_data (server_address, server_port, send_buffer);
439 if (!strncmp(recv_buffer,"ERROR",5)) {
440 printf("NSClient - %s\n",recv_buffer);
441 exit(STATE_UNKNOWN);
442 }
443 asprintf(&output_message,"%s",recv_buffer);
444 return_code=STATE_OK;
445 }
446 break;
448 case CHECK_NONE:
449 default:
450 usage4 (_("Please specify a variable to check"));
451 break;
453 }
455 /* reset timeout */
456 alarm(0);
458 if (perfdata==NULL)
459 printf("%s\n",output_message);
460 else
461 printf("%s | %s\n",output_message,perfdata);
462 return return_code;
463 }
467 /* process command-line arguments */
468 int process_arguments(int argc, char **argv){
469 int c;
471 int option = 0;
472 static struct option longopts[] =
473 {
474 {"port", required_argument,0,'p'},
475 {"timeout", required_argument,0,'t'},
476 {"critical", required_argument,0,'c'},
477 {"warning", required_argument,0,'w'},
478 {"variable", required_argument,0,'v'},
479 {"hostname", required_argument,0,'H'},
480 {"params", required_argument,0,'l'},
481 {"secret", required_argument,0,'s'},
482 {"display", required_argument,0,'d'},
483 {"unknown-timeout", no_argument, 0, 'u'},
484 {"version", no_argument, 0,'V'},
485 {"help", no_argument, 0,'h'},
486 {0,0,0,0}
487 };
489 /* no options were supplied */
490 if(argc<2) return ERROR;
492 /* backwards compatibility */
493 if (! is_option(argv[1])) {
494 server_address = strdup(argv[1]);
495 argv[1]=argv[0];
496 argv=&argv[1];
497 argc--;
498 }
500 for (c=1;c<argc;c++) {
501 if(strcmp("-to",argv[c])==0)
502 strcpy(argv[c],"-t");
503 else if (strcmp("-wv",argv[c])==0)
504 strcpy(argv[c],"-w");
505 else if (strcmp("-cv",argv[c])==0)
506 strcpy(argv[c],"-c");
507 }
509 while (1) {
510 c = getopt_long(argc,argv,"+hVH:t:c:w:p:v:l:s:d:u",longopts,&option);
512 if (c==-1||c==EOF||c==1)
513 break;
515 switch (c) {
516 case '?': /* print short usage statement if args not parsable */
517 usage5 ();
518 case 'h': /* help */
519 print_help();
520 exit(STATE_OK);
521 case 'V': /* version */
522 print_revision(progname, NP_VERSION);
523 exit(STATE_OK);
524 case 'H': /* hostname */
525 if (server_address) free(server_address);
526 server_address = optarg;
527 break;
528 case 's': /* password */
529 req_password = optarg;
530 break;
531 case 'p': /* port */
532 if (is_intnonneg(optarg))
533 server_port=atoi(optarg);
534 else
535 die(STATE_UNKNOWN,_("Server port must be an integer\n"));
536 break;
537 case 'v':
538 if(strlen(optarg)<4)
539 return ERROR;
540 if(!strcmp(optarg,"CLIENTVERSION"))
541 vars_to_check=CHECK_CLIENTVERSION;
542 else if(!strcmp(optarg,"CPULOAD"))
543 vars_to_check=CHECK_CPULOAD;
544 else if(!strcmp(optarg,"UPTIME"))
545 vars_to_check=CHECK_UPTIME;
546 else if(!strcmp(optarg,"USEDDISKSPACE"))
547 vars_to_check=CHECK_USEDDISKSPACE;
548 else if(!strcmp(optarg,"SERVICESTATE"))
549 vars_to_check=CHECK_SERVICESTATE;
550 else if(!strcmp(optarg,"PROCSTATE"))
551 vars_to_check=CHECK_PROCSTATE;
552 else if(!strcmp(optarg,"MEMUSE"))
553 vars_to_check=CHECK_MEMUSE;
554 else if(!strcmp(optarg,"COUNTER"))
555 vars_to_check=CHECK_COUNTER;
556 else if(!strcmp(optarg,"FILEAGE"))
557 vars_to_check=CHECK_FILEAGE;
558 else if(!strcmp(optarg,"INSTANCES"))
559 vars_to_check=CHECK_INSTANCES;
560 else
561 return ERROR;
562 break;
563 case 'l': /* value list */
564 value_list = optarg;
565 break;
566 case 'w': /* warning threshold */
567 warning_value=strtoul(optarg,NULL,10);
568 check_warning_value=TRUE;
569 break;
570 case 'c': /* critical threshold */
571 critical_value=strtoul(optarg,NULL,10);
572 check_critical_value=TRUE;
573 break;
574 case 'd': /* Display select for services */
575 if (!strcmp(optarg,"SHOWALL"))
576 show_all = TRUE;
577 break;
578 case 'u':
579 socket_timeout_state=STATE_UNKNOWN;
580 break;
581 case 't': /* timeout */
582 socket_timeout=atoi(optarg);
583 if(socket_timeout<=0)
584 return ERROR;
585 }
587 }
589 if (vars_to_check==CHECK_NONE)
590 return ERROR;
592 if (req_password == NULL)
593 req_password = strdup (_("None"));
595 return OK;
596 }
600 void fetch_data (const char *address, int port, const char *sendb) {
601 int result;
603 result=process_tcp_request(address, port, sendb, recv_buffer,sizeof(recv_buffer));
605 if(result!=STATE_OK)
606 die (result, _("could not fetch information from server\n"));
608 if (!strncmp(recv_buffer,"ERROR",5))
609 die (STATE_UNKNOWN, "NSClient - %s\n",recv_buffer);
610 }
612 int strtoularray(unsigned long *array, char *string, const char *delim) {
613 /* split a <delim> delimited string into a long array */
614 int idx=0;
615 char *t1;
617 for (idx=0;idx<MAX_VALUE_LIST;idx++)
618 array[idx]=0;
620 idx=0;
621 for(t1 = strtok(string,delim);t1 != NULL; t1 = strtok(NULL, delim)) {
622 if (is_numeric(t1) && idx<MAX_VALUE_LIST) {
623 array[idx]=strtoul(t1,NULL,10);
624 idx++;
625 } else
626 return FALSE;
627 }
628 return TRUE;
629 }
631 void preparelist(char *string) {
632 /* Replace all , with & which is the delimiter for the request */
633 int i;
635 for (i = 0; (size_t)i < strlen(string); i++)
636 if (string[i] == ',') {
637 string[i]='&';
638 }
639 }
643 void print_help(void)
644 {
645 print_revision(progname, NP_VERSION);
647 printf ("Copyright (c) 2000 Yves Rubin (rubiyz@yahoo.com)\n");
648 printf (COPYRIGHT, copyright, email);
650 printf ("%s\n", _("This plugin collects data from the NSClient service running on a"));
651 printf ("%s\n", _("Windows NT/2000/XP/2003 server."));
653 printf ("\n\n");
655 print_usage();
657 printf (_(UT_HELP_VRSN));
658 printf (_(UT_EXTRA_OPTS));
660 printf ("%s\n", _("Options:"));
661 printf (" %s\n", "-H, --hostname=HOST");
662 printf (" %s\n", _("Name of the host to check"));
663 printf (" %s\n", "-p, --port=INTEGER");
664 printf (" %s", _("Optional port number (default: "));
665 printf ("%d)\n", PORT);
666 printf (" %s\n", "-s, --secret=<password>");
667 printf (" %s\n", _("Password needed for the request"));
668 printf (" %s\n", "-w, --warning=INTEGER");
669 printf (" %s\n", _("Threshold which will result in a warning status"));
670 printf (" %s\n", "-c, --critical=INTEGER");
671 printf (" %s\n", _("Threshold which will result in a critical status"));
672 printf (" %s\n", "-t, --timeout=INTEGER");
673 printf (" %s", _("Seconds before connection attempt times out (default: "));
674 printf (" %s\n", "-l, --params=<parameters>");
675 printf (" %s", _("Parameters passed to specified check (see below)"));
676 printf (" %s\n", "-d, --display={SHOWALL}");
677 printf (" %s", _("Display options (currently only SHOWALL works)"));
678 printf (" %s\n", "-u, --unknown-timeout");
679 printf (" %s", _("Return UNKNOWN on timeouts"));
680 printf ("%d)\n", DEFAULT_SOCKET_TIMEOUT);
681 printf (" %s\n", "-h, --help");
682 printf (" %s\n", _("Print this help screen"));
683 printf (" %s\n", "-V, --version");
684 printf (" %s\n", _("Print version information"));
685 printf (" %s\n", "-v, --variable=STRING");
686 printf (" %s\n\n", _("Variable to check"));
687 printf ("%s\n", _("Valid variables are:"));
688 printf (" %s", "CLIENTVERSION =");
689 printf (" %s\n", _("Get the NSClient version"));
690 printf (" %s\n", _("If -l <version> is specified, will return warning if versions differ."));
691 printf (" %s\n", "CPULOAD =");
692 printf (" %s\n", _("Average CPU load on last x minutes."));
693 printf (" %s\n", _("Request a -l parameter with the following syntax:"));
694 printf (" %s\n", _("-l <minutes range>,<warning threshold>,<critical threshold>."));
695 printf (" %s\n", _("<minute range> should be less than 24*60."));
696 printf (" %s\n", _("Thresholds are percentage and up to 10 requests can be done in one shot."));
697 printf (" %s\n", "ie: -l 60,90,95,120,90,95");
698 printf (" %s\n", "UPTIME =");
699 printf (" %s\n", _("Get the uptime of the machine."));
700 printf (" %s\n", _("No specific parameters. No warning or critical threshold"));
701 printf (" %s\n", "USEDDISKSPACE =");
702 printf (" %s\n", _("Size and percentage of disk use."));
703 printf (" %s\n", _("Request a -l parameter containing the drive letter only."));
704 printf (" %s\n", _("Warning and critical thresholds can be specified with -w and -c."));
705 printf (" %s\n", "MEMUSE =");
706 printf (" %s\n", _("Memory use."));
707 printf (" %s\n", _("Warning and critical thresholds can be specified with -w and -c."));
708 printf (" %s\n", "SERVICESTATE =");
709 printf (" %s\n", _("Check the state of one or several services."));
710 printf (" %s\n", _("Request a -l parameters with the following syntax:"));
711 printf (" %s\n", _("-l <service1>,<service2>,<service3>,..."));
712 printf (" %s\n", _("You can specify -d SHOWALL in case you want to see working services"));
713 printf (" %s\n", _("in the returned string."));
714 printf (" %s\n", "PROCSTATE =");
715 printf (" %s\n", _("Check if one or several process are running."));
716 printf (" %s\n", _("Same syntax as SERVICESTATE."));
717 printf (" %s\n", "COUNTER =");
718 printf (" %s\n", _("Check any performance counter of Windows NT/2000."));
719 printf (" %s\n", _("Request a -l parameters with the following syntax:"));
720 printf (" %s\n", _("-l \"\\\\<performance object>\\\\counter\",\"<description>"));
721 printf (" %s\n", _("The <description> parameter is optional and is given to a printf "));
722 printf (" %s\n", _("output command which requires a float parameter."));
723 printf (" %s\n", _("If <description> does not include \"%%\", it is used as a label."));
724 printf (" %s\n", _("Some examples:"));
725 printf (" %s\n", "\"Paging file usage is %%.2f %%%%\"");
726 printf (" %s\n", "\"%%.f %%%% paging file used.\"");
727 printf (" %s\n", "INSTANCES =");
728 printf (" %s\n", _("Check any performance counter object of Windows NT/2000."));
729 printf (" %s\n", _("Syntax: check_nt -H <hostname> -p <port> -v INSTANCES -l <counter object>"));
730 printf (" %s\n", _("<counter object> is a Windows Perfmon Counter object (eg. Process),"));
731 printf (" %s\n", _("if it is two words, it should be enclosed in quotes"));
732 printf (" %s\n", _("The returned results will be a comma-separated list of instances on "));
733 printf (" %s\n", _(" the selected computer for that object."));
734 printf (" %s\n", _("The purpose of this is to be run from command line to determine what instances"));
735 printf (" %s\n", _(" are available for monitoring without having to log onto the Windows server"));
736 printf (" %s\n", _(" to run Perfmon directly."));
737 printf (" %s\n", _("It can also be used in scripts that automatically create Nagios service"));
738 printf (" %s\n", _(" configuration files."));
739 printf (" %s\n", _("Some examples:"));
740 printf (" %s\n\n", _("check_nt -H 192.168.1.1 -p 1248 -v INSTANCES -l Process"));
742 printf ("%s\n", _("Notes:"));
743 printf (" %s\n", _("- The NSClient service should be running on the server to get any information"));
744 printf (" %s\n", "(http://nsclient.ready2run.nl).");
745 printf (" %s\n", _("- Critical thresholds should be lower than warning thresholds"));
746 printf (" %s\n", _("- Default port 1248 is sometimes in use by other services. The error"));
747 printf (" %s\n", _("output when this happens contains \"Cannot map xxxxx to protocol number\"."));
748 printf (" %s\n", _("One fix for this is to change the port to something else on check_nt "));
749 printf (" %s\n", _("and on the client service it\'s connecting to."));
750 #ifdef NP_EXTRA_OPTS
751 printf (" -%s", _(UT_EXTRA_OPTS_NOTES));
752 #endif
754 printf (_(UT_SUPPORT));
755 }
759 void print_usage(void)
760 {
761 printf (_("Usage:"));
762 printf ("%s -H host -v variable [-p port] [-w warning] [-c critical]\n",progname);
763 printf ("[-l params] [-d SHOWALL] [-u] [-t timeout]\n");
764 }