Code

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