Reverted check_procs for solaris back to using pst3 due to truncation
[monitoring-plugins.git] / plugins / check_nt.c
blob60d58fd09e33b58f2e265c259584c7889ea28b6a
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 * Last Modified: $Date$
11 * Description:
13 * This file contains the check_nt plugin
15 * This plugin collects data from the NSClient service running on a
16 * Windows NT/2000/XP/2003 server.
17 * This plugin requires NSClient software to run on NT
18 * (http://nsclient.ready2run.nl/)
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 3 of the License, or
24 * (at your option) any later version.
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.
31 * You should have received a copy of the GNU General Public License
32 * along with this program. If not, see <http://www.gnu.org/licenses/>.
34 * $Id$
36 *****************************************************************************/
38 const char *progname = "check_nt";
39 const char *revision = "$Revision$";
40 const char *copyright = "2000-2007";
41 const char *email = "nagiosplug-devel@lists.sourceforge.net";
43 #include "common.h"
44 #include "netutils.h"
45 #include "utils.h"
47 enum checkvars {
48 CHECK_NONE,
49 CHECK_CLIENTVERSION,
50 CHECK_CPULOAD,
51 CHECK_UPTIME,
52 CHECK_USEDDISKSPACE,
53 CHECK_SERVICESTATE,
54 CHECK_PROCSTATE,
55 CHECK_MEMUSE,
56 CHECK_COUNTER,
57 CHECK_FILEAGE,
58 CHECK_INSTANCES
61 enum {
62 MAX_VALUE_LIST = 30,
63 PORT = 1248
66 char *server_address=NULL;
67 char *volume_name=NULL;
68 int server_port=PORT;
69 char *value_list=NULL;
70 char *req_password=NULL;
71 unsigned long lvalue_list[MAX_VALUE_LIST];
72 unsigned long warning_value=0L;
73 unsigned long critical_value=0L;
74 int check_warning_value=FALSE;
75 int check_critical_value=FALSE;
76 enum checkvars vars_to_check = CHECK_NONE;
77 int show_all=FALSE;
79 char recv_buffer[MAX_INPUT_BUFFER];
81 void fetch_data (const char* address, int port, const char* sendb);
82 int process_arguments(int, char **);
83 void preparelist(char *string);
84 int strtoularray(unsigned long *array, char *string, const char *delim);
85 void print_help(void);
86 void print_usage(void);
88 int main(int argc, char **argv){
90 /* should be int result = STATE_UNKNOWN; */
92 int return_code = STATE_UNKNOWN;
93 char *send_buffer=NULL;
94 char *output_message=NULL;
95 char *perfdata=NULL;
96 char *temp_string=NULL;
97 char *temp_string_perf=NULL;
98 char *description=NULL,*counter_unit = NULL;
99 char *minval = NULL, *maxval = NULL, *errcvt = NULL;
101 double total_disk_space=0;
102 double free_disk_space=0;
103 double percent_used_space=0;
104 double warning_used_space=0;
105 double critical_used_space=0;
106 double mem_commitLimit=0;
107 double mem_commitByte=0;
108 double fminval = 0, fmaxval = 0;
109 unsigned long utilization;
110 unsigned long uptime;
111 unsigned long age_in_minutes;
112 double counter_value = 0.0;
113 int offset=0;
114 int updays=0;
115 int uphours=0;
116 int upminutes=0;
118 int isPercent = FALSE;
119 int allRight = FALSE;
121 setlocale (LC_ALL, "");
122 bindtextdomain (PACKAGE, LOCALEDIR);
123 textdomain (PACKAGE);
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;
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 */
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"));
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 free_disk_space=atof(strtok(recv_buffer,"&"));
219 total_disk_space=atof(strtok(NULL,"&"));
220 percent_used_space = ((total_disk_space - free_disk_space) / total_disk_space) * 100;
221 warning_used_space = ((float)warning_value / 100) * total_disk_space;
222 critical_used_space = ((float)critical_value / 100) * total_disk_space;
224 if (free_disk_space>=0) {
225 asprintf(&temp_string,_("%s:\\ - total: %.2f Gb - used: %.2f Gb (%.0f%%) - free %.2f Gb (%.0f%%)"),
226 value_list, total_disk_space / 1073741824, (total_disk_space - free_disk_space) / 1073741824,
227 percent_used_space, free_disk_space / 1073741824, (free_disk_space / total_disk_space)*100);
228 asprintf(&temp_string_perf,_("'%s:\\ Used Space'=%.2fGb;%.2f;%.2f;0.00;%.2f"), value_list,
229 (total_disk_space - free_disk_space) / 1073741824, warning_used_space / 1073741824,
230 critical_used_space / 1073741824, total_disk_space / 1073741824);
232 if(check_critical_value==TRUE && percent_used_space >= critical_value)
233 return_code=STATE_CRITICAL;
234 else if (check_warning_value==TRUE && percent_used_space >= warning_value)
235 return_code=STATE_WARNING;
236 else
237 return_code=STATE_OK;
239 output_message = strdup (temp_string);
240 perfdata = temp_string_perf;
241 } else {
242 output_message = strdup (_("Free disk space : Invalid drive "));
243 return_code=STATE_UNKNOWN;
246 break;
248 case CHECK_SERVICESTATE:
249 case CHECK_PROCSTATE:
251 if (value_list==NULL)
252 output_message = strdup (_("No service/process specified"));
253 else {
254 preparelist(value_list); /* replace , between services with & to send the request */
255 asprintf(&send_buffer,"%s&%u&%s&%s", req_password,(vars_to_check==CHECK_SERVICESTATE)?5:6,
256 (show_all==TRUE) ? "ShowAll" : "ShowFail",value_list);
257 fetch_data (server_address, server_port, send_buffer);
258 return_code=atoi(strtok(recv_buffer,"&"));
259 temp_string=strtok(NULL,"&");
260 output_message = strdup (temp_string);
262 break;
264 case CHECK_MEMUSE:
266 asprintf(&send_buffer,"%s&7", req_password);
267 fetch_data (server_address, server_port, send_buffer);
268 mem_commitLimit=atof(strtok(recv_buffer,"&"));
269 mem_commitByte=atof(strtok(NULL,"&"));
270 percent_used_space = (mem_commitByte / mem_commitLimit) * 100;
271 warning_used_space = ((float)warning_value / 100) * mem_commitLimit;
272 critical_used_space = ((float)critical_value / 100) * mem_commitLimit;
274 /* Divisor should be 1048567, not 3044515, as we are measuring "Commit Charge" here,
275 which equals RAM + Pagefiles. */
276 asprintf(&output_message,_("Memory usage: total:%.2f Mb - used: %.2f Mb (%.0f%%) - free: %.2f Mb (%.0f%%)"),
277 mem_commitLimit / 1048567, mem_commitByte / 1048567, percent_used_space,
278 (mem_commitLimit - mem_commitByte) / 1048567, (mem_commitLimit - mem_commitByte) / mem_commitLimit * 100);
279 asprintf(&perfdata,_("'Memory usage'=%.2fMb;%.2f;%.2f;0.00;%.2f"), mem_commitByte / 1048567,
280 warning_used_space / 1048567, critical_used_space / 1048567, mem_commitLimit / 1048567);
282 return_code=STATE_OK;
283 if(check_critical_value==TRUE && percent_used_space >= critical_value)
284 return_code=STATE_CRITICAL;
285 else if (check_warning_value==TRUE && percent_used_space >= warning_value)
286 return_code=STATE_WARNING;
288 break;
290 case CHECK_COUNTER:
294 CHECK_COUNTER has been modified to provide extensive perfdata information.
295 In order to do this, some modifications have been done to the code
296 and some constraints have been introduced.
298 1) For the sake of simplicity of the code, perfdata information will only be
299 provided when the "description" field is added.
301 2) If the counter you're going to measure is percent-based, the code will detect
302 the percent sign in its name and will attribute minimum (0%) and maximum (100%)
303 values automagically, as well the ¨%" sign to graph units.
305 3) OTOH, if the counter is "absolute", you'll have to provide the following
306 the counter unit - that is, the dimensions of the counter you're getting. Examples:
307 pages/s, packets transferred, etc.
309 4) If you want, you may provide the minimum and maximum values to expect. They aren't mandatory,
310 but once specified they MUST have the same order of magnitude and units of -w and -c; otherwise.
311 strange things will happen when you make graphs of your data.
314 if (value_list == NULL)
315 output_message = strdup (_("No counter specified"));
316 else
318 preparelist (value_list); /* replace , between services with & to send the request */
319 isPercent = (strchr (value_list, '%') != NULL);
321 strtok (value_list, "&"); /* burn the first parameters */
322 description = strtok (NULL, "&");
323 counter_unit = strtok (NULL, "&");
324 asprintf (&send_buffer, "%s&8&%s", req_password, value_list);
325 fetch_data (server_address, server_port, send_buffer);
326 counter_value = atof (recv_buffer);
329 if (description == NULL)
330 asprintf (&output_message, "%.f", counter_value);
331 else if (isPercent)
333 counter_unit = strdup ("%");
334 allRight = TRUE;
337 if ((counter_unit != NULL) && (!allRight))
339 minval = strtok (NULL, "&");
340 maxval = strtok (NULL, "&");
342 /* All parameters specified. Let's check the numbers */
344 fminval = (minval != NULL) ? strtod (minval, &errcvt) : -1;
345 fmaxval = (minval != NULL) ? strtod (maxval, &errcvt) : -1;
347 if ((fminval == 0) && (minval == errcvt))
348 output_message = strdup (_("Minimum value contains non-numbers"));
349 else
351 if ((fmaxval == 0) && (maxval == errcvt))
352 output_message = strdup (_("Maximum value contains non-numbers"));
353 else
354 allRight = TRUE; /* Everything is OK. */
358 else if ((counter_unit == NULL) && (description != NULL))
359 output_message = strdup (_("No unit counter specified"));
361 if (allRight)
363 /* Let's format the output string, finally... */
364 if (strstr(description, "%") == NULL) {
365 asprintf (&output_message, "%s = %.2f %s", description, counter_value, counter_unit);
366 } else {
367 /* has formatting, will segv if wrong */
368 asprintf (&output_message, description, counter_value);
370 asprintf (&output_message, "%s |", output_message);
371 asprintf (&output_message,"%s %s", output_message,
372 fperfdata (description, counter_value,
373 counter_unit, 1, warning_value, 1, critical_value,
374 (!(isPercent) && (minval != NULL)), fminval,
375 (!(isPercent) && (minval != NULL)), fmaxval));
379 if (critical_value > warning_value)
380 { /* Normal thresholds */
381 if (check_critical_value == TRUE && counter_value >= critical_value)
382 return_code = STATE_CRITICAL;
383 else if (check_warning_value == TRUE && counter_value >= warning_value)
384 return_code = STATE_WARNING;
385 else
386 return_code = STATE_OK;
388 else
389 { /* inverse thresholds */
390 return_code = STATE_OK;
391 if (check_critical_value == TRUE && counter_value <= critical_value)
392 return_code = STATE_CRITICAL;
393 else if (check_warning_value == TRUE && counter_value <= warning_value)
394 return_code = STATE_WARNING;
396 break;
398 case CHECK_FILEAGE:
400 if (value_list==NULL)
401 output_message = strdup (_("No counter specified"));
402 else {
403 preparelist(value_list); /* replace , between services with & to send the request */
404 asprintf(&send_buffer,"%s&9&%s", req_password,value_list);
405 fetch_data (server_address, server_port, send_buffer);
406 age_in_minutes = atoi(strtok(recv_buffer,"&"));
407 description = strtok(NULL,"&");
408 output_message = strdup (description);
410 if (critical_value > warning_value) { /* Normal thresholds */
411 if(check_critical_value==TRUE && age_in_minutes >= critical_value)
412 return_code=STATE_CRITICAL;
413 else if (check_warning_value==TRUE && age_in_minutes >= warning_value)
414 return_code=STATE_WARNING;
415 else
416 return_code=STATE_OK;
418 else { /* inverse thresholds */
419 if(check_critical_value==TRUE && age_in_minutes <= critical_value)
420 return_code=STATE_CRITICAL;
421 else if (check_warning_value==TRUE && age_in_minutes <= warning_value)
422 return_code=STATE_WARNING;
423 else
424 return_code=STATE_OK;
427 break;
429 case CHECK_INSTANCES:
430 if (value_list==NULL)
431 output_message = strdup (_("No counter specified"));
432 else {
433 asprintf(&send_buffer,"%s&10&%s", req_password,value_list);
434 fetch_data (server_address, server_port, send_buffer);
435 if (!strncmp(recv_buffer,"ERROR",5)) {
436 printf("NSClient - %s\n",recv_buffer);
437 exit(STATE_UNKNOWN);
439 asprintf(&output_message,"%s",recv_buffer);
440 return_code=STATE_OK;
442 break;
444 case CHECK_NONE:
445 default:
446 usage4 (_("Please specify a variable to check"));
447 break;
451 /* reset timeout */
452 alarm(0);
454 if (perfdata==NULL)
455 printf("%s\n",output_message);
456 else
457 printf("%s | %s\n",output_message,perfdata);
458 return return_code;
463 /* process command-line arguments */
464 int process_arguments(int argc, char **argv){
465 int c;
467 int option = 0;
468 static struct option longopts[] =
470 {"port", required_argument,0,'p'},
471 {"timeout", required_argument,0,'t'},
472 {"critical", required_argument,0,'c'},
473 {"warning", required_argument,0,'w'},
474 {"variable", required_argument,0,'v'},
475 {"hostname", required_argument,0,'H'},
476 {"version", no_argument, 0,'V'},
477 {"help", no_argument, 0,'h'},
478 {0,0,0,0}
481 /* no options were supplied */
482 if(argc<2) return ERROR;
484 /* backwards compatibility */
485 if (! is_option(argv[1])) {
486 server_address = strdup(argv[1]);
487 argv[1]=argv[0];
488 argv=&argv[1];
489 argc--;
492 for (c=1;c<argc;c++) {
493 if(strcmp("-to",argv[c])==0)
494 strcpy(argv[c],"-t");
495 else if (strcmp("-wv",argv[c])==0)
496 strcpy(argv[c],"-w");
497 else if (strcmp("-cv",argv[c])==0)
498 strcpy(argv[c],"-c");
501 while (1) {
502 c = getopt_long(argc,argv,"+hVH:t:c:w:p:v:l:s:d:",longopts,&option);
504 if (c==-1||c==EOF||c==1)
505 break;
507 switch (c) {
508 case '?': /* print short usage statement if args not parsable */
509 usage5 ();
510 case 'h': /* help */
511 print_help();
512 exit(STATE_OK);
513 case 'V': /* version */
514 print_revision(progname,revision);
515 exit(STATE_OK);
516 case 'H': /* hostname */
517 if (server_address) free(server_address);
518 server_address = optarg;
519 break;
520 case 's': /* password */
521 req_password = optarg;
522 break;
523 case 'p': /* port */
524 if (is_intnonneg(optarg))
525 server_port=atoi(optarg);
526 else
527 die(STATE_UNKNOWN,_("Server port must be an integer\n"));
528 break;
529 case 'v':
530 if(strlen(optarg)<4)
531 return ERROR;
532 if(!strcmp(optarg,"CLIENTVERSION"))
533 vars_to_check=CHECK_CLIENTVERSION;
534 else if(!strcmp(optarg,"CPULOAD"))
535 vars_to_check=CHECK_CPULOAD;
536 else if(!strcmp(optarg,"UPTIME"))
537 vars_to_check=CHECK_UPTIME;
538 else if(!strcmp(optarg,"USEDDISKSPACE"))
539 vars_to_check=CHECK_USEDDISKSPACE;
540 else if(!strcmp(optarg,"SERVICESTATE"))
541 vars_to_check=CHECK_SERVICESTATE;
542 else if(!strcmp(optarg,"PROCSTATE"))
543 vars_to_check=CHECK_PROCSTATE;
544 else if(!strcmp(optarg,"MEMUSE"))
545 vars_to_check=CHECK_MEMUSE;
546 else if(!strcmp(optarg,"COUNTER"))
547 vars_to_check=CHECK_COUNTER;
548 else if(!strcmp(optarg,"FILEAGE"))
549 vars_to_check=CHECK_FILEAGE;
550 else if(!strcmp(optarg,"INSTANCES"))
551 vars_to_check=CHECK_INSTANCES;
552 else
553 return ERROR;
554 break;
555 case 'l': /* value list */
556 value_list = optarg;
557 break;
558 case 'w': /* warning threshold */
559 warning_value=strtoul(optarg,NULL,10);
560 check_warning_value=TRUE;
561 break;
562 case 'c': /* critical threshold */
563 critical_value=strtoul(optarg,NULL,10);
564 check_critical_value=TRUE;
565 break;
566 case 'd': /* Display select for services */
567 if (!strcmp(optarg,"SHOWALL"))
568 show_all = TRUE;
569 break;
570 case 't': /* timeout */
571 socket_timeout=atoi(optarg);
572 if(socket_timeout<=0)
573 return ERROR;
578 if (vars_to_check==CHECK_NONE)
579 return ERROR;
581 if (req_password == NULL)
582 req_password = strdup (_("None"));
584 return OK;
589 void fetch_data (const char *address, int port, const char *sendb) {
590 int result;
592 result=process_tcp_request(address, port, sendb, recv_buffer,sizeof(recv_buffer));
594 if(result!=STATE_OK)
595 die (result, _("could not fetch information from server\n"));
597 if (!strncmp(recv_buffer,"ERROR",5))
598 die (STATE_UNKNOWN, "NSClient - %s\n",recv_buffer);
601 int strtoularray(unsigned long *array, char *string, const char *delim) {
602 /* split a <delim> delimited string into a long array */
603 int idx=0;
604 char *t1;
606 for (idx=0;idx<MAX_VALUE_LIST;idx++)
607 array[idx]=0;
609 idx=0;
610 for(t1 = strtok(string,delim);t1 != NULL; t1 = strtok(NULL, delim)) {
611 if (is_numeric(t1) && idx<MAX_VALUE_LIST) {
612 array[idx]=strtoul(t1,NULL,10);
613 idx++;
614 } else
615 return FALSE;
617 return TRUE;
620 void preparelist(char *string) {
621 /* Replace all , with & which is the delimiter for the request */
622 int i;
624 for (i = 0; (size_t)i < strlen(string); i++)
625 if (string[i] == ',') {
626 string[i]='&';
632 void print_help(void)
634 print_revision(progname,revision);
636 printf ("Copyright (c) 2000 Yves Rubin (rubiyz@yahoo.com)\n");
637 printf (COPYRIGHT, copyright, email);
639 printf ("%s\n", _("This plugin collects data from the NSClient service running on a"));
640 printf ("%s\n", _("Windows NT/2000/XP/2003 server."));
642 printf ("\n\n");
644 print_usage();
646 printf (_(UT_HELP_VRSN));
648 printf ("%s\n", _("Options:"));
649 printf (" %s\n", "-H, --hostname=HOST");
650 printf (" %s\n", _("Name of the host to check"));
651 printf (" %s\n", "-p, --port=INTEGER");
652 printf (" %s", _("Optional port number (default: "));
653 printf ("%d)\n", PORT);
654 printf (" %s\n", "-s <password>");
655 printf (" %s\n", _("Password needed for the request"));
656 printf (" %s\n", "-w, --warning=INTEGER");
657 printf (" %s\n", _("Threshold which will result in a warning status"));
658 printf (" %s\n", "-c, --critical=INTEGER");
659 printf (" %s\n", _("Threshold which will result in a critical status"));
660 printf (" %s\n", "-t, --timeout=INTEGER");
661 printf (" %s", _("Seconds before connection attempt times out (default: "));
662 printf ("%d)\n", DEFAULT_SOCKET_TIMEOUT);
663 printf (" %s\n", "-h, --help");
664 printf (" %s\n", _("Print this help screen"));
665 printf (" %s\n", "-V, --version");
666 printf (" %s\n", _("Print version information"));
667 printf (" %s\n", "-v, --variable=STRING");
668 printf (" %s\n\n", _("Variable to check"));
669 printf ("%s\n", _("Valid variables are:"));
670 printf (" %s", "CLIENTVERSION =");
671 printf (" %s\n", _("Get the NSClient version"));
672 printf (" %s\n", _("If -l <version> is specified, will return warning if versions differ."));
673 printf (" %s\n", "CPULOAD =");
674 printf (" %s\n", _("Average CPU load on last x minutes."));
675 printf (" %s\n", _("Request a -l parameter with the following syntax:"));
676 printf (" %s\n", _("-l <minutes range>,<warning threshold>,<critical threshold>."));
677 printf (" %s\n", _("<minute range> should be less than 24*60."));
678 printf (" %s\n", _("Thresholds are percentage and up to 10 requests can be done in one shot."));
679 printf (" %s\n", "ie: -l 60,90,95,120,90,95");
680 printf (" %s\n", "UPTIME =");
681 printf (" %s\n", _("Get the uptime of the machine."));
682 printf (" %s\n", _("No specific parameters. No warning or critical threshold"));
683 printf (" %s\n", "USEDDISKSPACE =");
684 printf (" %s\n", _("Size and percentage of disk use."));
685 printf (" %s\n", _("Request a -l parameter containing the drive letter only."));
686 printf (" %s\n", _("Warning and critical thresholds can be specified with -w and -c."));
687 printf (" %s\n", "MEMUSE =");
688 printf (" %s\n", _("Memory use."));
689 printf (" %s\n", _("Warning and critical thresholds can be specified with -w and -c."));
690 printf (" %s\n", "SERVICESTATE =");
691 printf (" %s\n", _("Check the state of one or several services."));
692 printf (" %s\n", _("Request a -l parameters with the following syntax:"));
693 printf (" %s\n", _("-l <service1>,<service2>,<service3>,..."));
694 printf (" %s\n", _("You can specify -d SHOWALL in case you want to see working services"));
695 printf (" %s\n", _("in the returned string."));
696 printf (" %s\n", "PROCSTATE =");
697 printf (" %s\n", _("Check if one or several process are running."));
698 printf (" %s\n", _("Same syntax as SERVICESTATE."));
699 printf (" %s\n", "COUNTER =");
700 printf (" %s\n", _("Check any performance counter of Windows NT/2000."));
701 printf (" %s\n", _("Request a -l parameters with the following syntax:"));
702 printf (" %s\n", _("-l \"\\\\<performance object>\\\\counter\",\"<description>"));
703 printf (" %s\n", _("The <description> parameter is optional and is given to a printf "));
704 printf (" %s\n", _("output command which requires a float parameter."));
705 printf (" %s\n", _("If <description> does not include \"%%\", it is used as a label."));
706 printf (" %s\n", _("Some examples:"));
707 printf (" %s\n", "\"Paging file usage is %%.2f %%%%\"");
708 printf (" %s\n", "\"%%.f %%%% paging file used.\"");
709 printf (" %s\n", "INSTANCES =");
710 printf (" %s\n", _("Check any performance counter object of Windows NT/2000."));
711 printf (" %s\n", _("Syntax: check_nt -H <hostname> -p <port> -v INSTANCES -l <counter object>"));
712 printf (" %s\n", _("<counter object> is a Windows Perfmon Counter object (eg. Process),"));
713 printf (" %s\n", _("if it is two words, it should be enclosed in quotes"));
714 printf (" %s\n", _("The returned results will be a comma-separated list of instances on "));
715 printf (" %s\n", _(" the selected computer for that object."));
716 printf (" %s\n", _("The purpose of this is to be run from command line to determine what instances"));
717 printf (" %s\n", _(" are available for monitoring without having to log onto the Windows server"));
718 printf (" %s\n", _(" to run Perfmon directly."));
719 printf (" %s\n", _("It can also be used in scripts that automatically create Nagios service"));
720 printf (" %s\n", _(" configuration files."));
721 printf (" %s\n", _("Some examples:"));
722 printf (" %s\n\n", _("check_nt -H 192.168.1.1 -p 1248 -v INSTANCES -l Process"));
723 printf (_("Notes:"));
724 printf (" %s\n", _("- The NSClient service should be running on the server to get any information"));
725 printf (" %s\n", "(http://nsclient.ready2run.nl).");
726 printf (" %s\n", _("- Critical thresholds should be lower than warning thresholds"));
727 printf (" %s\n", _("- Default port 1248 is sometimes in use by other services. The error"));
728 printf (" %s\n", _("output when this happens contains \"Cannot map xxxxx to protocol number\"."));
729 printf (" %s\n", _("One fix for this is to change the port to something else on check_nt "));
730 printf (" %s\n", _("and on the client service it\'s connecting to."));
735 void print_usage(void)
737 printf (_("Usage:"));
738 printf ("%s -H host -v variable [-p port] [-w warning] [-c critical]",progname);
739 printf ("[-l params] [-d SHOWALL] [-t timeout]\n");