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 {"version", no_argument, 0,'V'},
484 {"help", no_argument, 0,'h'},
485 {0,0,0,0}
486 };
488 /* no options were supplied */
489 if(argc<2) return ERROR;
491 /* backwards compatibility */
492 if (! is_option(argv[1])) {
493 server_address = strdup(argv[1]);
494 argv[1]=argv[0];
495 argv=&argv[1];
496 argc--;
497 }
499 for (c=1;c<argc;c++) {
500 if(strcmp("-to",argv[c])==0)
501 strcpy(argv[c],"-t");
502 else if (strcmp("-wv",argv[c])==0)
503 strcpy(argv[c],"-w");
504 else if (strcmp("-cv",argv[c])==0)
505 strcpy(argv[c],"-c");
506 }
508 while (1) {
509 c = getopt_long(argc,argv,"+hVH:t:c:w:p:v:l:s:d:",longopts,&option);
511 if (c==-1||c==EOF||c==1)
512 break;
514 switch (c) {
515 case '?': /* print short usage statement if args not parsable */
516 usage5 ();
517 case 'h': /* help */
518 print_help();
519 exit(STATE_OK);
520 case 'V': /* version */
521 print_revision(progname, NP_VERSION);
522 exit(STATE_OK);
523 case 'H': /* hostname */
524 if (server_address) free(server_address);
525 server_address = optarg;
526 break;
527 case 's': /* password */
528 req_password = optarg;
529 break;
530 case 'p': /* port */
531 if (is_intnonneg(optarg))
532 server_port=atoi(optarg);
533 else
534 die(STATE_UNKNOWN,_("Server port must be an integer\n"));
535 break;
536 case 'v':
537 if(strlen(optarg)<4)
538 return ERROR;
539 if(!strcmp(optarg,"CLIENTVERSION"))
540 vars_to_check=CHECK_CLIENTVERSION;
541 else if(!strcmp(optarg,"CPULOAD"))
542 vars_to_check=CHECK_CPULOAD;
543 else if(!strcmp(optarg,"UPTIME"))
544 vars_to_check=CHECK_UPTIME;
545 else if(!strcmp(optarg,"USEDDISKSPACE"))
546 vars_to_check=CHECK_USEDDISKSPACE;
547 else if(!strcmp(optarg,"SERVICESTATE"))
548 vars_to_check=CHECK_SERVICESTATE;
549 else if(!strcmp(optarg,"PROCSTATE"))
550 vars_to_check=CHECK_PROCSTATE;
551 else if(!strcmp(optarg,"MEMUSE"))
552 vars_to_check=CHECK_MEMUSE;
553 else if(!strcmp(optarg,"COUNTER"))
554 vars_to_check=CHECK_COUNTER;
555 else if(!strcmp(optarg,"FILEAGE"))
556 vars_to_check=CHECK_FILEAGE;
557 else if(!strcmp(optarg,"INSTANCES"))
558 vars_to_check=CHECK_INSTANCES;
559 else
560 return ERROR;
561 break;
562 case 'l': /* value list */
563 value_list = optarg;
564 break;
565 case 'w': /* warning threshold */
566 warning_value=strtoul(optarg,NULL,10);
567 check_warning_value=TRUE;
568 break;
569 case 'c': /* critical threshold */
570 critical_value=strtoul(optarg,NULL,10);
571 check_critical_value=TRUE;
572 break;
573 case 'd': /* Display select for services */
574 if (!strcmp(optarg,"SHOWALL"))
575 show_all = TRUE;
576 break;
577 case 't': /* timeout */
578 socket_timeout=atoi(optarg);
579 if(socket_timeout<=0)
580 return ERROR;
581 }
583 }
585 if (vars_to_check==CHECK_NONE)
586 return ERROR;
588 if (req_password == NULL)
589 req_password = strdup (_("None"));
591 return OK;
592 }
596 void fetch_data (const char *address, int port, const char *sendb) {
597 int result;
599 result=process_tcp_request(address, port, sendb, recv_buffer,sizeof(recv_buffer));
601 if(result!=STATE_OK)
602 die (result, _("could not fetch information from server\n"));
604 if (!strncmp(recv_buffer,"ERROR",5))
605 die (STATE_UNKNOWN, "NSClient - %s\n",recv_buffer);
606 }
608 int strtoularray(unsigned long *array, char *string, const char *delim) {
609 /* split a <delim> delimited string into a long array */
610 int idx=0;
611 char *t1;
613 for (idx=0;idx<MAX_VALUE_LIST;idx++)
614 array[idx]=0;
616 idx=0;
617 for(t1 = strtok(string,delim);t1 != NULL; t1 = strtok(NULL, delim)) {
618 if (is_numeric(t1) && idx<MAX_VALUE_LIST) {
619 array[idx]=strtoul(t1,NULL,10);
620 idx++;
621 } else
622 return FALSE;
623 }
624 return TRUE;
625 }
627 void preparelist(char *string) {
628 /* Replace all , with & which is the delimiter for the request */
629 int i;
631 for (i = 0; (size_t)i < strlen(string); i++)
632 if (string[i] == ',') {
633 string[i]='&';
634 }
635 }
639 void print_help(void)
640 {
641 print_revision(progname, NP_VERSION);
643 printf ("Copyright (c) 2000 Yves Rubin (rubiyz@yahoo.com)\n");
644 printf (COPYRIGHT, copyright, email);
646 printf ("%s\n", _("This plugin collects data from the NSClient service running on a"));
647 printf ("%s\n", _("Windows NT/2000/XP/2003 server."));
649 printf ("\n\n");
651 print_usage();
653 printf (_(UT_HELP_VRSN));
654 printf (_(UT_EXTRA_OPTS));
656 printf ("%s\n", _("Options:"));
657 printf (" %s\n", "-H, --hostname=HOST");
658 printf (" %s\n", _("Name of the host to check"));
659 printf (" %s\n", "-p, --port=INTEGER");
660 printf (" %s", _("Optional port number (default: "));
661 printf ("%d)\n", PORT);
662 printf (" %s\n", "-s, --secret=<password>");
663 printf (" %s\n", _("Password needed for the request"));
664 printf (" %s\n", "-w, --warning=INTEGER");
665 printf (" %s\n", _("Threshold which will result in a warning status"));
666 printf (" %s\n", "-c, --critical=INTEGER");
667 printf (" %s\n", _("Threshold which will result in a critical status"));
668 printf (" %s\n", "-t, --timeout=INTEGER");
669 printf (" %s", _("Seconds before connection attempt times out (default: "));
670 printf (" %s\n", "-l, --params=<parameters>");
671 printf (" %s", _("Parameters passed to specified check (see below)"));
672 printf (" %s\n", "-d, --display={SHOWALL}");
673 printf (" %s", _("Display options (currently only SHOWALL works)"));
674 printf ("%d)\n", DEFAULT_SOCKET_TIMEOUT);
675 printf (" %s\n", "-h, --help");
676 printf (" %s\n", _("Print this help screen"));
677 printf (" %s\n", "-V, --version");
678 printf (" %s\n", _("Print version information"));
679 printf (" %s\n", "-v, --variable=STRING");
680 printf (" %s\n\n", _("Variable to check"));
681 printf ("%s\n", _("Valid variables are:"));
682 printf (" %s", "CLIENTVERSION =");
683 printf (" %s\n", _("Get the NSClient version"));
684 printf (" %s\n", _("If -l <version> is specified, will return warning if versions differ."));
685 printf (" %s\n", "CPULOAD =");
686 printf (" %s\n", _("Average CPU load on last x minutes."));
687 printf (" %s\n", _("Request a -l parameter with the following syntax:"));
688 printf (" %s\n", _("-l <minutes range>,<warning threshold>,<critical threshold>."));
689 printf (" %s\n", _("<minute range> should be less than 24*60."));
690 printf (" %s\n", _("Thresholds are percentage and up to 10 requests can be done in one shot."));
691 printf (" %s\n", "ie: -l 60,90,95,120,90,95");
692 printf (" %s\n", "UPTIME =");
693 printf (" %s\n", _("Get the uptime of the machine."));
694 printf (" %s\n", _("No specific parameters. No warning or critical threshold"));
695 printf (" %s\n", "USEDDISKSPACE =");
696 printf (" %s\n", _("Size and percentage of disk use."));
697 printf (" %s\n", _("Request a -l parameter containing the drive letter only."));
698 printf (" %s\n", _("Warning and critical thresholds can be specified with -w and -c."));
699 printf (" %s\n", "MEMUSE =");
700 printf (" %s\n", _("Memory use."));
701 printf (" %s\n", _("Warning and critical thresholds can be specified with -w and -c."));
702 printf (" %s\n", "SERVICESTATE =");
703 printf (" %s\n", _("Check the state of one or several services."));
704 printf (" %s\n", _("Request a -l parameters with the following syntax:"));
705 printf (" %s\n", _("-l <service1>,<service2>,<service3>,..."));
706 printf (" %s\n", _("You can specify -d SHOWALL in case you want to see working services"));
707 printf (" %s\n", _("in the returned string."));
708 printf (" %s\n", "PROCSTATE =");
709 printf (" %s\n", _("Check if one or several process are running."));
710 printf (" %s\n", _("Same syntax as SERVICESTATE."));
711 printf (" %s\n", "COUNTER =");
712 printf (" %s\n", _("Check any performance counter of Windows NT/2000."));
713 printf (" %s\n", _("Request a -l parameters with the following syntax:"));
714 printf (" %s\n", _("-l \"\\\\<performance object>\\\\counter\",\"<description>"));
715 printf (" %s\n", _("The <description> parameter is optional and is given to a printf "));
716 printf (" %s\n", _("output command which requires a float parameter."));
717 printf (" %s\n", _("If <description> does not include \"%%\", it is used as a label."));
718 printf (" %s\n", _("Some examples:"));
719 printf (" %s\n", "\"Paging file usage is %%.2f %%%%\"");
720 printf (" %s\n", "\"%%.f %%%% paging file used.\"");
721 printf (" %s\n", "INSTANCES =");
722 printf (" %s\n", _("Check any performance counter object of Windows NT/2000."));
723 printf (" %s\n", _("Syntax: check_nt -H <hostname> -p <port> -v INSTANCES -l <counter object>"));
724 printf (" %s\n", _("<counter object> is a Windows Perfmon Counter object (eg. Process),"));
725 printf (" %s\n", _("if it is two words, it should be enclosed in quotes"));
726 printf (" %s\n", _("The returned results will be a comma-separated list of instances on "));
727 printf (" %s\n", _(" the selected computer for that object."));
728 printf (" %s\n", _("The purpose of this is to be run from command line to determine what instances"));
729 printf (" %s\n", _(" are available for monitoring without having to log onto the Windows server"));
730 printf (" %s\n", _(" to run Perfmon directly."));
731 printf (" %s\n", _("It can also be used in scripts that automatically create Nagios service"));
732 printf (" %s\n", _(" configuration files."));
733 printf (" %s\n", _("Some examples:"));
734 printf (" %s\n\n", _("check_nt -H 192.168.1.1 -p 1248 -v INSTANCES -l Process"));
736 printf ("%s\n", _("Notes:"));
737 printf (" %s\n", _("- The NSClient service should be running on the server to get any information"));
738 printf (" %s\n", "(http://nsclient.ready2run.nl).");
739 printf (" %s\n", _("- Critical thresholds should be lower than warning thresholds"));
740 printf (" %s\n", _("- Default port 1248 is sometimes in use by other services. The error"));
741 printf (" %s\n", _("output when this happens contains \"Cannot map xxxxx to protocol number\"."));
742 printf (" %s\n", _("One fix for this is to change the port to something else on check_nt "));
743 printf (" %s\n", _("and on the client service it\'s connecting to."));
744 #ifdef NP_EXTRA_OPTS
745 printf (" -%s", _(UT_EXTRA_OPTS_NOTES));
746 #endif
748 printf (_(UT_SUPPORT));
749 }
753 void print_usage(void)
754 {
755 printf (_("Usage:"));
756 printf ("%s -H host -v variable [-p port] [-w warning] [-c critical]\n",progname);
757 printf ("[-l params] [-d SHOWALL] [-t timeout]\n");
758 }