X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins%2Fcheck_hpjd.c;h=dd49893b8f955011a3e26964bab39113d49f1ee6;hb=6ecaa524bf28b5fb861b161ea075a11119cb3bd2;hp=edde341e9e3dce5d4a9102a027a33034c359bda8;hpb=f4f92be60c94fd4e0dd4b2b4b3101543eedb706a;p=nagiosplug.git diff --git a/plugins/check_hpjd.c b/plugins/check_hpjd.c index edde341..dd49893 100644 --- a/plugins/check_hpjd.c +++ b/plugins/check_hpjd.c @@ -14,8 +14,14 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * +* $Id$ *****************************************************************************/ +const char *progname = "check_hpjd"; +const char *revision = "$Revision$"; +const char *copyright = "2000-2004"; +const char *email = "nagiosplug-devel@lists.sourceforge.net"; + #include "common.h" #include "popen.h" #include "utils.h" @@ -23,25 +29,21 @@ #define DEFAULT_COMMUNITY "public" -const char *progname = "check_hpjd"; -const char *revision = "$Revision$"; -const char *copyright = "2000-2003"; -const char *email = "nagiosplug-devel@lists.sourceforge.net"; const char *option_summary = "-H host [-C community]\n"; -#define HPJD_LINE_STATUS ".1.3.6.1.4.1.11.2.3.9.1.1.2.1" -#define HPJD_PAPER_STATUS ".1.3.6.1.4.1.11.2.3.9.1.1.2.2" -#define HPJD_INTERVENTION_REQUIRED ".1.3.6.1.4.1.11.2.3.9.1.1.2.3" -#define HPJD_GD_PERIPHERAL_ERROR ".1.3.6.1.4.1.11.2.3.9.1.1.2.6" -#define HPJD_GD_PAPER_JAM ".1.3.6.1.4.1.11.2.3.9.1.1.2.8" -#define HPJD_GD_PAPER_OUT ".1.3.6.1.4.1.11.2.3.9.1.1.2.9" -#define HPJD_GD_TONER_LOW ".1.3.6.1.4.1.11.2.3.9.1.1.2.10" -#define HPJD_GD_PAGE_PUNT ".1.3.6.1.4.1.11.2.3.9.1.1.2.11" -#define HPJD_GD_MEMORY_OUT ".1.3.6.1.4.1.11.2.3.9.1.1.2.12" -#define HPJD_GD_DOOR_OPEN ".1.3.6.1.4.1.11.2.3.9.1.1.2.17" -#define HPJD_GD_PAPER_OUTPUT ".1.3.6.1.4.1.11.2.3.9.1.1.2.19" -#define HPJD_GD_STATUS_DISPLAY ".1.3.6.1.4.1.11.2.3.9.1.1.3" +#define HPJD_LINE_STATUS ".1.3.6.1.4.1.11.2.3.9.1.1.2.1" +#define HPJD_PAPER_STATUS ".1.3.6.1.4.1.11.2.3.9.1.1.2.2" +#define HPJD_INTERVENTION_REQUIRED ".1.3.6.1.4.1.11.2.3.9.1.1.2.3" +#define HPJD_GD_PERIPHERAL_ERROR ".1.3.6.1.4.1.11.2.3.9.1.1.2.6" +#define HPJD_GD_PAPER_JAM ".1.3.6.1.4.1.11.2.3.9.1.1.2.8" +#define HPJD_GD_PAPER_OUT ".1.3.6.1.4.1.11.2.3.9.1.1.2.9" +#define HPJD_GD_TONER_LOW ".1.3.6.1.4.1.11.2.3.9.1.1.2.10" +#define HPJD_GD_PAGE_PUNT ".1.3.6.1.4.1.11.2.3.9.1.1.2.11" +#define HPJD_GD_MEMORY_OUT ".1.3.6.1.4.1.11.2.3.9.1.1.2.12" +#define HPJD_GD_DOOR_OPEN ".1.3.6.1.4.1.11.2.3.9.1.1.2.17" +#define HPJD_GD_PAPER_OUTPUT ".1.3.6.1.4.1.11.2.3.9.1.1.2.19" +#define HPJD_GD_STATUS_DISPLAY ".1.3.6.1.4.1.11.2.3.9.1.1.3" #define ONLINE 0 #define OFFLINE 1 @@ -58,7 +60,7 @@ int main (int argc, char **argv) { char command_line[1024]; - int result; + int result = STATE_UNKNOWN; int line; char input_buffer[MAX_INPUT_BUFFER]; char query_string[512]; @@ -79,8 +81,12 @@ main (int argc, char **argv) errmsg = malloc(MAX_INPUT_BUFFER); - if (process_arguments (argc, argv) != OK) - usage (_("Invalid command arguments supplied\n")); + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + + if (process_arguments (argc, argv) == ERROR) + usage4 (_("Could not parse arguments")); /* removed ' 2>1' at end of command 10/27/1999 - EG */ /* create the query string */ @@ -99,7 +105,7 @@ main (int argc, char **argv) HPJD_GD_DOOR_OPEN, HPJD_GD_PAPER_OUTPUT, HPJD_GD_STATUS_DISPLAY); /* get the command to run */ - sprintf (command_line, "%s -m : -v 1 -c %s %s %s", PATH_TO_SNMPGET, community, + sprintf (command_line, "%s -OQa -m : -v 1 -c %s %s %s", PATH_TO_SNMPGET, community, address, query_string); /* run the command */ @@ -128,7 +134,7 @@ main (int argc, char **argv) temp_buffer = strtok (input_buffer, "="); temp_buffer = strtok (NULL, "="); - if (temp_buffer != NULL) { + if (temp_buffer == NULL) { result = STATE_UNKNOWN; strcpy (errmsg, input_buffer); @@ -280,9 +286,6 @@ main (int argc, char **argv) } - - - /* process command-line arguments */ int process_arguments (int argc, char **argv) @@ -317,7 +320,7 @@ process_arguments (int argc, char **argv) address = strscpy(address, optarg) ; } else { - usage (_("Invalid host name\n")); + usage2 (_("Invalid hostname/address"), optarg); } break; case 'C': /* community */ @@ -330,7 +333,7 @@ process_arguments (int argc, char **argv) print_help (); exit (STATE_OK); case '?': /* help */ - usage (_("Invalid argument\n")); + usage2 (_("Unknown argument"), optarg); } } @@ -340,7 +343,7 @@ process_arguments (int argc, char **argv) address = argv[c++]; } else { - usage (_("Invalid host name")); + usage2 (_("Invalid hostname/address"), argv[c]); } } @@ -355,9 +358,6 @@ process_arguments (int argc, char **argv) } - - - int validate_arguments (void) { @@ -365,16 +365,13 @@ validate_arguments (void) } - - - - void print_help (void) { print_revision (progname, revision); - printf (_(COPYRIGHT), copyright, email); + printf ("Copyright (c) 1999 Ethan Galstad \n"); + printf (COPYRIGHT, copyright, email); printf (_("\ This plugin tests the STATUS of an HP printer with a JetDirect card.\n\ @@ -393,11 +390,8 @@ Net-snmp must be installed on the computer running the plugin.\n\n")); - void print_usage (void) { - printf (_("\ -Usage: %s -H host [-C community]\n"), progname); - printf (_(UT_HLP_VRS), progname, progname); + printf ("Usage: %s -H host [-C community]\n", progname); }