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