diff --git a/plugins/check_hpjd.c b/plugins/check_hpjd.c
index 56384657ad507b6b5e3d22a4a011133480ee9eb3..6503d52d4defe9aef71cd5450b381c9b26e8e561 100644 (file)
--- a/plugins/check_hpjd.c
+++ b/plugins/check_hpjd.c
int door_open = 0;
int paper_output = 0;
char display_message[MAX_INPUT_BUFFER];
+ char *temp ;
if (process_arguments (argc, argv) != OK)
usage ("Invalid command arguments supplied\n");
HPJD_GD_DOOR_OPEN, HPJD_GD_PAPER_OUTPUT, HPJD_GD_STATUS_DISPLAY);
/* get the command to run */
- sprintf (command_line, "%s -m : -v 1 %s -c %s %s", PATH_TO_SNMPGET, address,
- community, query_string);
+ sprintf (command_line, "%s -m : -v 1 -c %s %s %s", PATH_TO_SNMPGET, community,
+ address, query_string);
/* run the command */
child_process = spopen (command_line);
}
/* WARNING if output found on stderr */
- if (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr))
+ if (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) {
result = max_state (result, STATE_WARNING);
+ /* remove CRLF */
+ if (input_buffer[strlen (input_buffer) - 1] == '\n')
+ input_buffer[strlen (input_buffer) - 1] = 0;
+ sprintf (error_message, "%s", input_buffer );
+ }
+
/* close stderr */
(void) fclose (child_stderr);
/* if there wasn't any output, display an error */
if (line == 0) {
- /*
- result=STATE_UNKNOWN;
- strcpy(error_message,"Error: Could not read plugin output\n");
- */
-
- /* might not be the problem, but most likely is.. */
- result = STATE_UNKNOWN;
- sprintf (error_message, "Timeout: No response from %s\n", address);
+ /* might not be the problem, but most likely is. */
+ result = STATE_UNKNOWN ;
+ asprintf (&temp, error_message);
+ sprintf (error_message, "%s : Timeout from host %s\n", temp, address );
+
}
/* if we had no read errors, check the printer status results... */
}
-/*
- if(argc<2||argc>3){
- printf("Incorrect number of arguments supplied\n");
- print_revision(argv[0],"$Revision$");
- printf("Copyright (c) 1999 Ethan Galstad (nagios@nagios.org)\n");
- printf("License: GPL\n");
- printf("Usage: %s <ip_address> [community]\n",argv[0]);
- printf("Note:\n");
- printf(" <ip_address> = The IP address of the JetDirect card\n");
- printf(" [community] = An optional community string used for SNMP communication\n");
- printf(" with the JetDirect card. The default is 'public'.\n");
- return STATE_UNKNOWN;
- }
- // get the IP address of the JetDirect device
- strcpy(address,argv[1]);
- // get the community name to use for SNMP communication
- if(argc>=3)
- strcpy(community,argv[2]);
- else
- strcpy(community,"public");
-*/
+