summaryrefslogtreecommitdiffstats
path: root/plugins/check_hpjd.c
diff options
context:
space:
mode:
authorKarl DeBisschop <kdebisschop@users.sourceforge.net>2003-04-09 03:46:26 (GMT)
committerKarl DeBisschop <kdebisschop@users.sourceforge.net>2003-04-09 03:46:26 (GMT)
commitd8a0b8512bfd62a4cec79964aa3af84a0430066b (patch)
tree8b8331d48325b3a03fd1dbefe66dab87d3f91422 /plugins/check_hpjd.c
parent7726dc6863d745360a78aa8095ef36b63cbc8016 (diff)
downloadmonitoring-plugins-d8a0b8512bfd62a4cec79964aa3af84a0430066b.tar.gz
cleanup to suppress various strict compiler warnings
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@483 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/check_hpjd.c')
-rw-r--r--plugins/check_hpjd.c112
1 files changed, 34 insertions, 78 deletions
diff --git a/plugins/check_hpjd.c b/plugins/check_hpjd.c
index 9d8fae2..5638465 100644
--- a/plugins/check_hpjd.c
+++ b/plugins/check_hpjd.c
@@ -1,50 +1,5 @@
1/****************************************************************************** 1/******************************************************************************
2* 2*
3* CHECK_HPJD.C
4*
5* Program: HP printer plugin for Nagios
6* License: GPL
7* Copyright (c) 1999 Ethan Galstad (nagios@nagios.org)
8*
9* Last Modified: $Date$
10*
11* Command line: CHECK_HPJD <ip_address> [community]
12*
13* Description:
14*
15* This plugin will attempt to check the status of an HP printer. The
16* printer must have a JetDirect card installed and TCP/IP protocol
17* stack enabled. This plugin has only been tested on a few printers
18* and may not work well on all models of JetDirect cards. Multiple
19* port JetDirect devices must have an IP address assigned to each
20* port in order to be monitored.
21*
22* Dependencies:
23*
24* This plugin used the 'snmpget' command included with the UCD-SNMP
25* package. If you don't have the package installed you will need to
26* download it from http://ucd-snmp.ucdavis.edu before you can use
27* this plugin.
28*
29* Return Values:
30*
31* UNKNOWN = The plugin could not read/process the output from the printer
32* OK = Printer looks normal
33* WARNING = Low toner, paper jam, intervention required, paper out, etc.
34* CRITICAL = The printer could not be reached (it's probably turned off)
35*
36* Acknowledgements:
37*
38* The idea for the plugin (as well as some code) were taken from Jim
39* Trocki's pinter alert script in his "mon" utility, found at
40* http://www.kernel.org/software/mon
41*
42* Notes:
43* 'JetDirect' is copyrighted by Hewlett-Packard.
44* HP, please don't sue me... :-)
45*
46* License Information:
47*
48* This program is free software; you can redistribute it and/or modify 3* This program is free software; you can redistribute it and/or modify
49* it under the terms of the GNU General Public License as published by 4* it under the terms of the GNU General Public License as published by
50* the Free Software Foundation; either version 2 of the License, or 5* the Free Software Foundation; either version 2 of the License, or
@@ -66,8 +21,26 @@
66#include "utils.h" 21#include "utils.h"
67 22
68const char *progname = "check_hpjd"; 23const char *progname = "check_hpjd";
69#define REVISION "$Revision$" 24const char *revision = "$Revision$";
70#define COPYRIGHT "2000-2002" 25const char *authors = "Nagios Plugin Development Team";
26const char *email = "nagiosplug-devel@lists.sourceforge.net";
27const char *copyright = "2000-2003";
28
29const char *summary = "\
30This 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";
32
33const char *option_summary = "-H host [-C community]\n";
34
35const char *options = "\
36 -H, --hostname=STRING or IPADDRESS\n\
37 Check server on the indicated host\n\
38 -C, --community=STRING\n\
39 The SNMP community name (default=%s)\n\
40 -h, --help\n\
41 Print detailed help screen\n\
42 -V, --version\n\
43 Print version information\n\n";
71 44
72#define HPJD_LINE_STATUS ".1.3.6.1.4.1.11.2.3.9.1.1.2.1" 45#define HPJD_LINE_STATUS ".1.3.6.1.4.1.11.2.3.9.1.1.2.1"
73#define HPJD_PAPER_STATUS ".1.3.6.1.4.1.11.2.3.9.1.1.2.2" 46#define HPJD_PAPER_STATUS ".1.3.6.1.4.1.11.2.3.9.1.1.2.2"
@@ -425,7 +398,7 @@ process_arguments (int argc, char **argv)
425 community = strscpy (community, optarg); 398 community = strscpy (community, optarg);
426 break; 399 break;
427 case 'V': /* version */ 400 case 'V': /* version */
428 print_revision (progname, REVISION); 401 print_revision (progname, revision);
429 exit (STATE_OK); 402 exit (STATE_OK);
430 case 'h': /* help */ 403 case 'h': /* help */
431 print_help (); 404 print_help ();
@@ -469,60 +442,43 @@ validate_arguments (void)
469void 442void
470print_help (void) 443print_help (void)
471{ 444{
472 print_revision (progname, REVISION); 445 print_revision (progname, revision);
473 printf 446 printf ("Copyright (c) %s %s\n\t<%s>\n\n", copyright, authors, email);
474 ("Copyright (c) 2000 Ethan Galstad/Karl DeBisschop\n\n" 447 printf (summary);
475 "This plugin tests the STATUS of an HP printer with a JetDirect card.\n"
476 "Net-snmp must be installed on the computer running the plugin.\n\n");
477 print_usage (); 448 print_usage ();
478 printf 449 printf ("\nOptions:\n");
479 ("\nOptions:\n" 450 printf (options, DEFAULT_COMMUNITY);
480 " -H, --hostname=STRING or IPADDRESS\n"
481 " Check server on the indicated host\n"
482 " -C, --community=STRING\n"
483 " The SNMP community name (default=%s)\n"
484 " -h, --help\n"
485 " Print detailed help screen\n"
486 " -V, --version\n" " Print version information\n\n",DEFAULT_COMMUNITY);
487 support (); 451 support ();
488} 452}
489 453
490
491
492
493
494void 454void
495print_usage (void) 455print_usage (void)
496{ 456{
497 printf 457 printf ("\
498 ("Usage: %s -H host [-C community]\n" 458Usage:\n\
499 " %s --help\n" 459 %s %s\n\
500 " %s --version\n", progname, progname, progname); 460 %s (-h | --help) for detailed help\n\
461 %s (-V | --version) for version information\n",
462 progname, option_summary, progname, progname);
501} 463}
502 464
503 465
504/* 466/*
505 if(argc<2||argc>3){ 467 if(argc<2||argc>3){
506 printf("Incorrect number of arguments supplied\n"); 468 printf("Incorrect number of arguments supplied\n");
507 printf("\n");
508 print_revision(argv[0],"$Revision$"); 469 print_revision(argv[0],"$Revision$");
509 printf("Copyright (c) 1999 Ethan Galstad (nagios@nagios.org)\n"); 470 printf("Copyright (c) 1999 Ethan Galstad (nagios@nagios.org)\n");
510 printf("License: GPL\n"); 471 printf("License: GPL\n");
511 printf("\n");
512 printf("Usage: %s <ip_address> [community]\n",argv[0]); 472 printf("Usage: %s <ip_address> [community]\n",argv[0]);
513 printf("\n");
514 printf("Note:\n"); 473 printf("Note:\n");
515 printf(" <ip_address> = The IP address of the JetDirect card\n"); 474 printf(" <ip_address> = The IP address of the JetDirect card\n");
516 printf(" [community] = An optional community string used for SNMP communication\n"); 475 printf(" [community] = An optional community string used for SNMP communication\n");
517 printf(" with the JetDirect card. The default is 'public'.\n"); 476 printf(" with the JetDirect card. The default is 'public'.\n");
518 printf("\n");
519 return STATE_UNKNOWN; 477 return STATE_UNKNOWN;
520 } 478 }
521 479 // get the IP address of the JetDirect device
522 /* get the IP address of the JetDirect device */
523 strcpy(address,argv[1]); 480 strcpy(address,argv[1]);
524 481 // get the community name to use for SNMP communication
525 /* get the community name to use for SNMP communication */
526 if(argc>=3) 482 if(argc>=3)
527 strcpy(community,argv[2]); 483 strcpy(community,argv[2]);
528 else 484 else