Code

Fix HTTP::Daemon::VERSION to get a fixed header size for tests
[nagiosplug.git] / plugins / check_hpjd.c
index 7ad950a4a9513e6313f89a4d3e63b79b876c0be3..044f08f64a4a2025a044f359a7c2810594e5484c 100644 (file)
@@ -1,25 +1,40 @@
-/******************************************************************************
-*
-* This program is free software; you can redistribute it and/or modify
+/*****************************************************************************
+* 
+* Nagios check_hpjd plugin
+* 
+* License: GPL
+* Copyright (c) 2000-2007 Nagios Plugins Development Team
+* 
+* Last Modified: $Date$
+* 
+* Description:
+* 
+* This file contains the check_hpjd plugin
+* 
+* This plugin tests the STATUS of an HP printer with a JetDirect card.
+* Net-SNMP must be installed on the computer running the plugin.
+* 
+* 
+* This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
+* the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
-*
+* 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
-*
+* 
 * You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*
+* along with this program.  If not, see <http://www.gnu.org/licenses/>.
+* 
 * $Id$
+* 
 *****************************************************************************/
 
 const char *progname = "check_hpjd";
 const char *revision = "$Revision$";
-const char *copyright = "2000-2004";
+const char *copyright = "2000-2007";
 const char *email = "nagiosplug-devel@lists.sourceforge.net";
 
 #include "common.h"
@@ -36,8 +51,8 @@ const char *option_summary = "-H host [-C community]\n";
 #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_PAPER_OUT          ".1.3.6.1.4.1.11.2.3.9.1.1.2.8"
+#define HPJD_GD_PAPER_JAM          ".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"
@@ -85,7 +100,10 @@ main (int argc, char **argv)
        bindtextdomain (PACKAGE, LOCALEDIR);
        textdomain (PACKAGE);
 
-       if (process_arguments (argc, argv) != TRUE)
+       /* Parse extra opts if any */
+       argv=np_extra_opts (&argc, argv, progname);
+
+       if (process_arguments (argc, argv) == ERROR)
                usage4 (_("Could not parse arguments"));
 
        /* removed ' 2>1' at end of command 10/27/1999 - EG */
@@ -134,7 +152,7 @@ main (int argc, char **argv)
                temp_buffer = strtok (input_buffer, "=");
                temp_buffer = strtok (NULL, "=");
 
-               if (temp_buffer == NULL) {
+               if (temp_buffer == NULL && line < 13) {
 
                                result = STATE_UNKNOWN;
                                strcpy (errmsg, input_buffer);
@@ -179,8 +197,9 @@ main (int argc, char **argv)
                        case 12:                                                                                /* display panel message */
                                strcpy (display_message, temp_buffer + 1);
                                break;
-                       default:
-                               break;
+                       default:                                                                                /* fold multiline message */
+                               strncat (display_message, input_buffer, 
+                                               sizeof (display_message) - strlen (display_message) - 1);
                        }
 
                }
@@ -286,7 +305,6 @@ main (int argc, char **argv)
 }
 
 
-
 /* process command-line arguments */
 int
 process_arguments (int argc, char **argv)
@@ -334,9 +352,7 @@ process_arguments (int argc, char **argv)
                        print_help ();
                        exit (STATE_OK);
                case '?':                                                                       /* help */
-                       printf (_("%s: Unknown argument: %s\n\n"), progname, optarg);
-                       print_usage ();
-                       exit (STATE_UNKNOWN);
+                       usage5 ();
                }
        }
 
@@ -361,7 +377,6 @@ process_arguments (int argc, char **argv)
 }
 
 
-
 int
 validate_arguments (void)
 {
@@ -369,7 +384,6 @@ validate_arguments (void)
 }
 
 
-
 void
 print_help (void)
 {
@@ -378,17 +392,26 @@ print_help (void)
        printf ("Copyright (c) 1999 Ethan Galstad <nagios@nagios.org>\n");
        printf (COPYRIGHT, copyright, email);
 
-       printf (_("\
-This plugin tests the STATUS of an HP printer with a JetDirect card.\n\
-Net-snmp must be installed on the computer running the plugin.\n\n"));
+       printf ("%s\n", _("This plugin tests the STATUS of an HP printer with a JetDirect card."));
+       printf ("%s\n", _("Net-snmp must be installed on the computer running the plugin."));
+
+       printf ("\n\n");
 
        print_usage ();
 
        printf (_(UT_HELP_VRSN));
+       printf (_(UT_EXTRA_OPTS));
+
+       printf (" %s\n", "-C, --community=STRING");
+       printf ("    %s", _("The SNMP community name "));
+       printf (_("(default=%s)"), DEFAULT_COMMUNITY);
+       printf ("\n");
 
-       printf (_("\
- -C, --community=STRING\n\
-    The SNMP community name (default=%s)\n"), DEFAULT_COMMUNITY);
+#ifdef NP_EXTRA_OPTS
+       printf ("\n");
+       printf ("%s\n", _("Notes:"));
+       printf (_(UT_EXTRA_OPTS_NOTES));
+#endif
 
        printf (_(UT_SUPPORT));
 }
@@ -398,7 +421,6 @@ 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:"));
+       printf ("%s -H host [-C community]\n", progname);
 }