Code

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