summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/check_hpjd.c114
1 files changed, 48 insertions, 66 deletions
diff --git a/plugins/check_hpjd.c b/plugins/check_hpjd.c
index 6503d52..cb93a36 100644
--- a/plugins/check_hpjd.c
+++ b/plugins/check_hpjd.c
@@ -19,29 +19,46 @@
19#include "common.h" 19#include "common.h"
20#include "popen.h" 20#include "popen.h"
21#include "utils.h" 21#include "utils.h"
22#include "netutils.h"
23
24#define DEFAULT_COMMUNITY "public"
22 25
23const char *progname = "check_hpjd"; 26const char *progname = "check_hpjd";
24const char *revision = "$Revision$"; 27const char *revision = "$Revision$";
25const char *authors = "Nagios Plugin Development Team";
26const char *email = "nagiosplug-devel@lists.sourceforge.net";
27const char *copyright = "2000-2003"; 28const char *copyright = "2000-2003";
29const char *email = "nagiosplug-devel@lists.sourceforge.net";
28 30
29const char *summary = "\ 31const char *option_summary = "-H host [-C community]\n";
32void
33print_usage (void)
34{
35 printf (_("\
36Usage: %s -H host [-C community]\n"), progname);
37 printf (_(UT_HLP_VRS), progname, progname);
38}
39
40void
41print_help (void)
42{
43 print_revision (progname, revision);
44
45 printf (_(COPYRIGHT), copyright, email);
46
47 printf (_("\
30This plugin tests the STATUS of an HP printer with a JetDirect card.\n\ 48This plugin tests the STATUS of an HP printer with a JetDirect card.\n\
31Net-snmp must be installed on the computer running the plugin.\n\n"; 49Net-snmp must be installed on the computer running the plugin.\n\n"));
32 50
33const char *option_summary = "-H host [-C community]\n"; 51 print_usage ();
52
53 printf (_(UT_HELP_VRSN));
34 54
35const char *options = "\ 55 printf (_("\
36 -H, --hostname=STRING or IPADDRESS\n\
37 Check server on the indicated host\n\
38 -C, --community=STRING\n\ 56 -C, --community=STRING\n\
39 The SNMP community name (default=%s)\n\ 57 The SNMP community name (default=%s)\n"), DEFAULT_COMMUNITY);
40 -h, --help\n\
41 Print detailed help screen\n\
42 -V, --version\n\
43 Print version information\n\n";
44 58
59 printf (_(UT_SUPPORT));
60}
61
45#define HPJD_LINE_STATUS ".1.3.6.1.4.1.11.2.3.9.1.1.2.1" 62#define HPJD_LINE_STATUS ".1.3.6.1.4.1.11.2.3.9.1.1.2.1"
46#define HPJD_PAPER_STATUS ".1.3.6.1.4.1.11.2.3.9.1.1.2.2" 63#define HPJD_PAPER_STATUS ".1.3.6.1.4.1.11.2.3.9.1.1.2.2"
47#define HPJD_INTERVENTION_REQUIRED ".1.3.6.1.4.1.11.2.3.9.1.1.2.3" 64#define HPJD_INTERVENTION_REQUIRED ".1.3.6.1.4.1.11.2.3.9.1.1.2.3"
@@ -58,17 +75,12 @@ const char *options = "\
58#define ONLINE 0 75#define ONLINE 0
59#define OFFLINE 1 76#define OFFLINE 1
60 77
61#define DEFAULT_COMMUNITY "public"
62
63int process_arguments (int, char **); 78int process_arguments (int, char **);
64int validate_arguments (void); 79int validate_arguments (void);
65void print_help (void);
66void print_usage (void);
67 80
68char *community = DEFAULT_COMMUNITY; 81char *community = DEFAULT_COMMUNITY;
69char *address = NULL; 82char *address = NULL;
70 83
71
72int 84int
73main (int argc, char **argv) 85main (int argc, char **argv)
74{ 86{
@@ -94,7 +106,7 @@ main (int argc, char **argv)
94 char *temp ; 106 char *temp ;
95 107
96 if (process_arguments (argc, argv) != OK) 108 if (process_arguments (argc, argv) != OK)
97 usage ("Invalid command arguments supplied\n"); 109 usage (_("Invalid command arguments supplied\n"));
98 110
99 /* removed ' 2>1' at end of command 10/27/1999 - EG */ 111 /* removed ' 2>1' at end of command 10/27/1999 - EG */
100 /* create the query string */ 112 /* create the query string */
@@ -119,13 +131,13 @@ main (int argc, char **argv)
119 /* run the command */ 131 /* run the command */
120 child_process = spopen (command_line); 132 child_process = spopen (command_line);
121 if (child_process == NULL) { 133 if (child_process == NULL) {
122 printf ("Could not open pipe: %s\n", command_line); 134 printf (_("Could not open pipe: %s\n"), command_line);
123 return STATE_UNKNOWN; 135 return STATE_UNKNOWN;
124 } 136 }
125 137
126 child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r"); 138 child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r");
127 if (child_stderr == NULL) { 139 if (child_stderr == NULL) {
128 printf ("Could not open stderr for %s\n", command_line); 140 printf (_("Could not open stderr for %s\n"), command_line);
129 } 141 }
130 142
131 result = STATE_OK; 143 result = STATE_OK;
@@ -293,54 +305,54 @@ main (int argc, char **argv)
293 305
294 if (paper_jam) { 306 if (paper_jam) {
295 result = STATE_WARNING; 307 result = STATE_WARNING;
296 strcpy (error_message, "Paper Jam"); 308 strcpy (error_message, _("Paper Jam"));
297 } 309 }
298 else if (paper_out) { 310 else if (paper_out) {
299 result = STATE_WARNING; 311 result = STATE_WARNING;
300 strcpy (error_message, "Out of Paper"); 312 strcpy (error_message, _("Out of Paper"));
301 } 313 }
302 else if (line_status == OFFLINE) { 314 else if (line_status == OFFLINE) {
303 if (strcmp (error_message, "POWERSAVE ON") != 0) { 315 if (strcmp (error_message, "POWERSAVE ON") != 0) {
304 result = STATE_WARNING; 316 result = STATE_WARNING;
305 strcpy (error_message, "Printer Offline"); 317 strcpy (error_message, _("Printer Offline"));
306 } 318 }
307 } 319 }
308 else if (peripheral_error) { 320 else if (peripheral_error) {
309 result = STATE_WARNING; 321 result = STATE_WARNING;
310 strcpy (error_message, "Peripheral Error"); 322 strcpy (error_message, _("Peripheral Error"));
311 } 323 }
312 else if (intervention_required) { 324 else if (intervention_required) {
313 result = STATE_WARNING; 325 result = STATE_WARNING;
314 strcpy (error_message, "Intervention Required"); 326 strcpy (error_message, _("Intervention Required"));
315 } 327 }
316 else if (toner_low) { 328 else if (toner_low) {
317 result = STATE_WARNING; 329 result = STATE_WARNING;
318 strcpy (error_message, "Toner Low"); 330 strcpy (error_message, _("Toner Low"));
319 } 331 }
320 else if (memory_out) { 332 else if (memory_out) {
321 result = STATE_WARNING; 333 result = STATE_WARNING;
322 strcpy (error_message, "Insufficient Memory"); 334 strcpy (error_message, _("Insufficient Memory"));
323 } 335 }
324 else if (door_open) { 336 else if (door_open) {
325 result = STATE_WARNING; 337 result = STATE_WARNING;
326 strcpy (error_message, "A Door is Open"); 338 strcpy (error_message, _("A Door is Open"));
327 } 339 }
328 else if (paper_output) { 340 else if (paper_output) {
329 result = STATE_WARNING; 341 result = STATE_WARNING;
330 strcpy (error_message, "Output Tray is Full"); 342 strcpy (error_message, _("Output Tray is Full"));
331 } 343 }
332 else if (page_punt) { 344 else if (page_punt) {
333 result = STATE_WARNING; 345 result = STATE_WARNING;
334 strcpy (error_message, "Data too Slow for Engine"); 346 strcpy (error_message, _("Data too Slow for Engine"));
335 } 347 }
336 else if (paper_status) { 348 else if (paper_status) {
337 result = STATE_WARNING; 349 result = STATE_WARNING;
338 strcpy (error_message, "Unknown Paper Error"); 350 strcpy (error_message, _("Unknown Paper Error"));
339 } 351 }
340 } 352 }
341 353
342 if (result == STATE_OK) 354 if (result == STATE_OK)
343 printf ("Printer ok - (%s)\n", display_message); 355 printf (_("Printer ok - (%s)\n"), display_message);
344 356
345 else if (result == STATE_UNKNOWN) { 357 else if (result == STATE_UNKNOWN) {
346 358
@@ -395,7 +407,7 @@ process_arguments (int argc, char **argv)
395 address = strscpy(address, optarg) ; 407 address = strscpy(address, optarg) ;
396 } 408 }
397 else { 409 else {
398 usage ("Invalid host name\n"); 410 usage (_("Invalid host name\n"));
399 } 411 }
400 break; 412 break;
401 case 'C': /* community */ 413 case 'C': /* community */
@@ -408,7 +420,7 @@ process_arguments (int argc, char **argv)
408 print_help (); 420 print_help ();
409 exit (STATE_OK); 421 exit (STATE_OK);
410 case '?': /* help */ 422 case '?': /* help */
411 usage ("Invalid argument\n"); 423 usage (_("Invalid argument\n"));
412 } 424 }
413 } 425 }
414 426
@@ -418,7 +430,7 @@ process_arguments (int argc, char **argv)
418 address = argv[c++]; 430 address = argv[c++];
419 } 431 }
420 else { 432 else {
421 usage ("Invalid host name"); 433 usage (_("Invalid host name"));
422 } 434 }
423 } 435 }
424 436
@@ -438,33 +450,3 @@ validate_arguments (void)
438{ 450{
439 return OK; 451 return OK;
440} 452}
441
442
443
444
445
446void
447print_help (void)
448{
449 print_revision (progname, revision);
450 printf ("Copyright (c) %s %s\n\t<%s>\n\n", copyright, authors, email);
451 printf (summary);
452 print_usage ();
453 printf ("\nOptions:\n");
454 printf (options, DEFAULT_COMMUNITY);
455 support ();
456}
457
458void
459print_usage (void)
460{
461 printf ("\
462Usage:\n\
463 %s %s\n\
464 %s (-h | --help) for detailed help\n\
465 %s (-V | --version) for version information\n",
466 progname, option_summary, progname, progname);
467}
468
469
470