Code

print_help and print_usage() cleanup
[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-2004";
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;
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) != TRUE)
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... */
359                                 asprintf (&output_message, "%s = %.2f %s", description, counter_value, counter_unit);
360                                 output_message = strcat (output_message, "|");
361                                 output_message = strcat (output_message,
362                                                         fperfdata (description, counter_value, counter_unit,
363                                                                    1, warning_value, 1, critical_value,
364                                                                    (!(isPercent) && (minval != NULL)), fminval,
365                                                                    (!(isPercent) && (minval != NULL)), fmaxval));
366                         }
367                 }
369                 if (critical_value > warning_value)
370                 {                       /* Normal thresholds */
371                         if (check_critical_value == TRUE && counter_value >= critical_value)
372                              return_code = STATE_CRITICAL;
373                         else if (check_warning_value == TRUE && counter_value >= warning_value)
374                                 return_code = STATE_WARNING;
375                              else
376                                 return_code = STATE_OK;
377                 }
378                 else
379                 {                       /* inverse thresholds */
380                         return_code = STATE_OK;
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                 }
386         break;
387                 
388         case CHECK_FILEAGE:
390                 if (value_list==NULL)
391                         output_message = strdup (_("No counter specified"));
392                 else {
393                         preparelist(value_list);                /* replace , between services with & to send the request */
394                         asprintf(&send_buffer,"%s&9&%s", req_password,value_list);
395                         fetch_data (server_address, server_port, send_buffer);
396                         age_in_minutes = atoi(strtok(recv_buffer,"&"));
397                         description = strtok(NULL,"&");
398                         output_message = strdup (description);
399         
400                         if (critical_value > warning_value) {        /* Normal thresholds */
401                                 if(check_critical_value==TRUE && age_in_minutes >= critical_value)
402                                         return_code=STATE_CRITICAL;
403                                 else if (check_warning_value==TRUE && age_in_minutes >= warning_value)
404                                         return_code=STATE_WARNING;      
405                                 else
406                                         return_code=STATE_OK;   
407                         } 
408                         else {                                       /* inverse thresholds */
409                                 if(check_critical_value==TRUE && age_in_minutes <= critical_value)
410                                         return_code=STATE_CRITICAL;
411                                 else if (check_warning_value==TRUE && age_in_minutes <= warning_value)
412                                         return_code=STATE_WARNING;      
413                                 else
414                                         return_code=STATE_OK;   
415                         }
416                 }
417                 break;
419         case CHECK_NONE:
420         default:
421                 usage (_("Please specify a variable to check"));
422                 break;
424         }
426         /* reset timeout */
427         alarm(0);
429         if (perfdata==NULL)
430                 printf("%s\n",output_message);
431         else
432                 printf("%s | %s\n",output_message,perfdata);
433         return return_code;
438 /* process command-line arguments */
439 int process_arguments(int argc, char **argv){
440         int c;
442         int option = 0;
443         static struct option longopts[] =
444         { 
445                 {"port",     required_argument,0,'p'},
446                 {"timeout",  required_argument,0,'t'},
447                 {"critical", required_argument,0,'c'},
448                 {"warning",  required_argument,0,'w'},
449                 {"variable", required_argument,0,'v'},
450                 {"hostname", required_argument,0,'H'},
451                 {"version",  no_argument,      0,'V'},
452                 {"help",     no_argument,      0,'h'},
453                 {0,0,0,0}
454         };
456         /* no options were supplied */
457         if(argc<2) return ERROR;
459         /* backwards compatibility */
460         if (! is_option(argv[1])) {
461                 server_address = strdup(argv[1]);
462                 argv[1]=argv[0];
463                 argv=&argv[1];
464                 argc--;
465         }
467   for (c=1;c<argc;c++) {
468     if(strcmp("-to",argv[c])==0)
469       strcpy(argv[c],"-t");
470     else if (strcmp("-wv",argv[c])==0)
471       strcpy(argv[c],"-w");
472     else if (strcmp("-cv",argv[c])==0)
473       strcpy(argv[c],"-c");
474         }
476         while (1){
477                 c = getopt_long(argc,argv,"+hVH:t:c:w:p:v:l:s:d:",longopts,&option);
479                 if (c==-1||c==EOF||c==1)
480                         break;
482                 switch (c)
483                         {
484                         case '?': /* print short usage statement if args not parsable */
485                                 printf("%s: Unknown argument: %s\n\n",progname,optarg);
486                                 print_usage();
487                                 exit(STATE_UNKNOWN);
488                         case 'h': /* help */
489                                 print_help();
490                                 exit(STATE_OK);
491                         case 'V': /* version */
492                                 print_revision(progname,"$Revision$");
493                                 exit(STATE_OK);
494                         case 'H': /* hostname */
495                                 if (server_address)     free(server_address);
496                                 server_address = optarg;
497                                 break;
498                         case 's': /* password */
499                                 req_password = optarg;
500                                 break;
501                         case 'p': /* port */
502                                 if (is_intnonneg(optarg))
503                                         server_port=atoi(optarg);
504                                 else
505                                         die(STATE_UNKNOWN,_("Server port an integer (seconds)\nType '%s -h' for additional help\n"),progname);
506                                 break;
507                         case 'v':
508                                 if(strlen(optarg)<4)
509                                         return ERROR;
510                                 if(!strcmp(optarg,"CLIENTVERSION"))
511                                         vars_to_check=CHECK_CLIENTVERSION;
512                                 else if(!strcmp(optarg,"CPULOAD"))
513                                         vars_to_check=CHECK_CPULOAD;
514                                 else if(!strcmp(optarg,"UPTIME"))
515                                         vars_to_check=CHECK_UPTIME;
516                                 else if(!strcmp(optarg,"USEDDISKSPACE"))
517                                         vars_to_check=CHECK_USEDDISKSPACE;
518                                 else if(!strcmp(optarg,"SERVICESTATE"))
519                                         vars_to_check=CHECK_SERVICESTATE;
520                                 else if(!strcmp(optarg,"PROCSTATE"))
521                                         vars_to_check=CHECK_PROCSTATE;
522                                 else if(!strcmp(optarg,"MEMUSE"))
523                                         vars_to_check=CHECK_MEMUSE;
524                                 else if(!strcmp(optarg,"COUNTER"))
525                                         vars_to_check=CHECK_COUNTER;
526                                 else if(!strcmp(optarg,"FILEAGE"))
527                                         vars_to_check=CHECK_FILEAGE;
528                                 else
529                                         return ERROR;
530                                 break;
531                         case 'l': /* value list */
532                                 value_list = optarg;
533                                 break;
534                         case 'w': /* warning threshold */
535                                 warning_value=strtoul(optarg,NULL,10);
536                                 check_warning_value=TRUE;
537                                 break;
538                         case 'c': /* critical threshold */
539                                 critical_value=strtoul(optarg,NULL,10);
540                                 check_critical_value=TRUE;
541                                 break;
542                         case 'd': /* Display select for services */
543                                 if (!strcmp(optarg,"SHOWALL"))
544                                         show_all = TRUE;
545                                 break;
546                         case 't': /* timeout */
547                                 socket_timeout=atoi(optarg);
548                                 if(socket_timeout<=0)
549                                         return ERROR;
550                         }
552         }
554         if (vars_to_check==CHECK_NONE)
555                 return ERROR;
557         if (req_password == NULL)
558                 req_password = strdup (_("None"));
560         return OK;
565 void fetch_data (const char *address, int port, const char *sendb) {
566         int result;
568         result=process_tcp_request(address, port, sendb, recv_buffer,sizeof(recv_buffer));
570         if(result!=STATE_OK)
571                 die (result, "could not fetch information from server\n");
572                 
573         if (!strncmp(recv_buffer,"ERROR",5))
574                 die (STATE_UNKNOWN, "NSClient - %s\n",recv_buffer);
577 int strtoularray(unsigned long *array, char *string, const char *delim) {
578         /* split a <delim> delimited string into a long array */
579         int idx=0;
580         char *t1;
582         for (idx=0;idx<MAX_VALUE_LIST;idx++)
583                 array[idx]=0;
584         
585         idx=0;
586         for(t1 = strtok(string,delim);t1 != NULL; t1 = strtok(NULL, delim)) {
587                 if (is_numeric(t1) && idx<MAX_VALUE_LIST) {
588                         array[idx]=strtoul(t1,NULL,10);
589                         idx++;
590                 } else  
591                         return FALSE;
592         }               
593         return TRUE;
596 void preparelist(char *string) {
597         /* Replace all , with & which is the delimiter for the request */
598         int i;
600         for (i = 0; (size_t)i < strlen(string); i++)
601                 if (string[i] == ',') {
602                         string[i]='&';
603                 }
608 void print_help(void)
610         print_revision(progname,revision);
611         
612         printf (_("Copyright (c) 2000 Yves Rubin (rubiyz@yahoo.com)\n"));
613         printf (COPYRIGHT, copyright, email);
614         
615         printf (_("This plugin collects data from the NSClient service running on a\n\
616 Windows NT/2000/XP/2003 server.\n\n"));
618         print_usage();
619         
620   printf (_("\nOptions:\n\
621 -H, --hostname=HOST\n\
622   Name of the host to check\n\
623 -p, --port=INTEGER\n\
624   Optional port number (default: %d)\n\
625 -s <password>\n\
626   Password needed for the request\n\
627 -w, --warning=INTEGER\n\
628   Threshold which will result in a warning status\n\
629 -c, --critical=INTEGER\n\
630   Threshold which will result in a critical status\n\
631 -t, --timeout=INTEGER\n\
632   Seconds before connection attempt times out (default: %d)\n\
633 -h, --help\n\
634   Print this help screen\n\
635 -V, --version\n\
636   Print version information\n"), PORT, DEFAULT_SOCKET_TIMEOUT);
637         
638   printf (_("\
639 -v, --variable=STRING\n\
640   Variable to check.  Valid variables are:\n"));
641   printf (_("\
642    CLIENTVERSION = Get the NSClient version\n\
643      If -l <version> is specified, will return warning if versions differ.\n"));
644   printf (_("\
645    CPULOAD = Average CPU load on last x minutes.\n\
646      Request a -l parameter with the following syntax:\n\
647      -l <minutes range>,<warning threshold>,<critical threshold>.\n\
648      <minute range> should be less than 24*60.\n\
649      Thresholds are percentage and up to 10 requests can be done in one shot.\n\
650      ie: -l 60,90,95,120,90,95\n"));
651   printf (_("\
652    UPTIME = Get the uptime of the machine.\n\
653      No specific parameters. No warning or critical threshold\n"));
654   printf (_("\
655    USEDDISKSPACE = Size and percentage of disk use.\n\
656      Request a -l parameter containing the drive letter only.\n\
657      Warning and critical thresholds can be specified with -w and -c.\n"));
658   printf (_("\
659    MEMUSE = Memory use.\n\
660      Warning and critical thresholds can be specified with -w and -c.\n"));
661   printf (_("\
662    SERVICESTATE = Check the state of one or several services.\n\
663      Request a -l parameters with the following syntax:\n\
664      -l <service1>,<service2>,<service3>,...\n\
665      You can specify -d SHOWALL in case you want to see working services\n\
666                  in the returned string.\n"));
667   printf (_("\
668    PROCSTATE = Check if one or several process are running.\n\
669      Same syntax as SERVICESTATE.\n"));
670   printf (_("\
671    COUNTER = Check any performance counter of Windows NT/2000.\n\
672      Request a -l parameters with the following syntax:\n\
673                  -l \"\\\\<performance object>\\\\counter\",\"<description>\n\
674      The <description> parameter is optional and \n\
675      is given to a printf output command which require a float parameters.\n\
676      Some examples:\n\
677        \"Paging file usage is %%.2f %%%%\"\n\
678        \"%%.f %%%% paging file used.\"\n"));
679   printf (_("Notes:\n\
680  - The NSClient service should be running on the server to get any information\n\
681    (http://nsclient.ready2run.nl).\n\
682  - Critical thresholds should be lower than warning thresholds\n"));
687 void print_usage(void)
689         printf("\
690 Usage: %s -H host -v variable [-p port] [-w warning] [-c critical]\n\
691                   [-l params] [-d SHOWALL] [-t timeout]\n", progname);