summaryrefslogtreecommitdiffstats
path: root/plugins/check_hpjd.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/check_hpjd.c')
-rw-r--r--plugins/check_hpjd.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/plugins/check_hpjd.c b/plugins/check_hpjd.c
index f159f5a..c4b4417 100644
--- a/plugins/check_hpjd.c
+++ b/plugins/check_hpjd.c
@@ -66,7 +66,8 @@ void print_usage (void);
66 66
67char *community = NULL; 67char *community = NULL;
68char *address = NULL; 68char *address = NULL;
69char *port = NULL; 69unsigned int port = 0;
70int check_paper_out = 1;
70 71
71int 72int
72main (int argc, char **argv) 73main (int argc, char **argv)
@@ -120,8 +121,12 @@ main (int argc, char **argv)
120 HPJD_GD_DOOR_OPEN, HPJD_GD_PAPER_OUTPUT, HPJD_GD_STATUS_DISPLAY); 121 HPJD_GD_DOOR_OPEN, HPJD_GD_PAPER_OUTPUT, HPJD_GD_STATUS_DISPLAY);
121 122
122 /* get the command to run */ 123 /* get the command to run */
123 sprintf (command_line, "%s -OQa -m : -v 1 -c %s %s:%hd %s", PATH_TO_SNMPGET, community, 124 sprintf (command_line, "%s -OQa -m : -v 1 -c %s %s:%u %s",
124 address, port, query_string); 125 PATH_TO_SNMPGET,
126 community,
127 address,
128 port,
129 query_string);
125 130
126 /* run the command */ 131 /* run the command */
127 child_process = spopen (command_line); 132 child_process = spopen (command_line);
@@ -240,7 +245,8 @@ main (int argc, char **argv)
240 strcpy (errmsg, _("Paper Jam")); 245 strcpy (errmsg, _("Paper Jam"));
241 } 246 }
242 else if (paper_out) { 247 else if (paper_out) {
243 result = STATE_WARNING; 248 if (check_paper_out)
249 result = STATE_WARNING;
244 strcpy (errmsg, _("Out of Paper")); 250 strcpy (errmsg, _("Out of Paper"));
245 } 251 }
246 else if (line_status == OFFLINE) { 252 else if (line_status == OFFLINE) {
@@ -325,7 +331,7 @@ process_arguments (int argc, char **argv)
325 331
326 332
327 while (1) { 333 while (1) {
328 c = getopt_long (argc, argv, "+hVH:C:p:", longopts, &option); 334 c = getopt_long (argc, argv, "+hVH:C:p:D", longopts, &option);
329 335
330 if (c == -1 || c == EOF || c == 1) 336 if (c == -1 || c == EOF || c == 1)
331 break; 337 break;
@@ -347,6 +353,8 @@ process_arguments (int argc, char **argv)
347 usage2 (_("Port must be a positive short integer"), optarg); 353 usage2 (_("Port must be a positive short integer"), optarg);
348 else 354 else
349 port = atoi(optarg); 355 port = atoi(optarg);
356 case 'D': /* disable paper out check*/
357 check_paper_out = 0;
350 break; 358 break;
351 case 'V': /* version */ 359 case 'V': /* version */
352 print_revision (progname, NP_VERSION); 360 print_revision (progname, NP_VERSION);
@@ -376,11 +384,8 @@ process_arguments (int argc, char **argv)
376 community = strdup (DEFAULT_COMMUNITY); 384 community = strdup (DEFAULT_COMMUNITY);
377 } 385 }
378 386
379 if (port == NULL) { 387 if (port == 0) {
380 if (argv[c] != NULL ) 388 port = atoi(DEFAULT_PORT);
381 port = argv[c];
382 else
383 port = atoi (DEFAULT_PORT);
384 } 389 }
385 390
386 return validate_arguments (); 391 return validate_arguments ();
@@ -420,6 +425,8 @@ print_help (void)
420 printf (" %s", _("Specify the port to check ")); 425 printf (" %s", _("Specify the port to check "));
421 printf (_("(default=%s)"), DEFAULT_PORT); 426 printf (_("(default=%s)"), DEFAULT_PORT);
422 printf ("\n"); 427 printf ("\n");
428 printf (" %s\n", "-D");
429 printf (" %s", _("Disable paper check "));
423 430
424 printf (UT_SUPPORT); 431 printf (UT_SUPPORT);
425} 432}
@@ -430,5 +437,5 @@ void
430print_usage (void) 437print_usage (void)
431{ 438{
432 printf ("%s\n", _("Usage:")); 439 printf ("%s\n", _("Usage:"));
433 printf ("%s -H host [-C community] [-p port]\n", progname); 440 printf ("%s -H host [-C community] [-p port] [-D]\n", progname);
434} 441}