diff options
Diffstat (limited to 'plugins/check_hpjd.c')
-rw-r--r-- | plugins/check_hpjd.c | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/plugins/check_hpjd.c b/plugins/check_hpjd.c index 8a60ce8c..f37b2ba4 100644 --- a/plugins/check_hpjd.c +++ b/plugins/check_hpjd.c | |||
@@ -98,6 +98,7 @@ main (int argc, char **argv) | |||
98 | 98 | ||
99 | errmsg = malloc(MAX_INPUT_BUFFER); | 99 | errmsg = malloc(MAX_INPUT_BUFFER); |
100 | 100 | ||
101 | np_set_mynames(argv[0], "HPJD"); | ||
101 | setlocale (LC_ALL, ""); | 102 | setlocale (LC_ALL, ""); |
102 | bindtextdomain (PACKAGE, LOCALEDIR); | 103 | bindtextdomain (PACKAGE, LOCALEDIR); |
103 | textdomain (PACKAGE); | 104 | textdomain (PACKAGE); |
@@ -127,15 +128,12 @@ main (int argc, char **argv) | |||
127 | 128 | ||
128 | /* run the command */ | 129 | /* run the command */ |
129 | child_process = spopen (command_line); | 130 | child_process = spopen (command_line); |
130 | if (child_process == NULL) { | 131 | if (child_process == NULL) |
131 | printf (_("Could not open pipe: %s\n"), command_line); | 132 | np_die(STATE_UNKNOWN, _("Could not open pipe: %s"), command_line); |
132 | return STATE_UNKNOWN; | ||
133 | } | ||
134 | 133 | ||
135 | child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r"); | 134 | child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r"); |
136 | if (child_stderr == NULL) { | 135 | if (child_stderr == NULL) |
137 | printf (_("Could not open stderr for %s\n"), command_line); | 136 | printf (_("Could not open stderr for %s\n"), command_line); |
138 | } | ||
139 | 137 | ||
140 | result = STATE_OK; | 138 | result = STATE_OK; |
141 | 139 | ||
@@ -286,21 +284,13 @@ main (int argc, char **argv) | |||
286 | } | 284 | } |
287 | 285 | ||
288 | if (result == STATE_OK) | 286 | if (result == STATE_OK) |
289 | printf (_("Printer ok - (%s)\n"), display_message); | 287 | np_die(STATE_OK, _("Printer ok - (%s)"), display_message); |
290 | |||
291 | else if (result == STATE_UNKNOWN) { | ||
292 | |||
293 | printf ("%s\n", errmsg); | ||
294 | |||
295 | /* if printer could not be reached, escalate to critical */ | ||
296 | if (strstr (errmsg, "Timeout")) | ||
297 | result = STATE_CRITICAL; | ||
298 | } | ||
299 | |||
300 | else if (result == STATE_WARNING) | 288 | else if (result == STATE_WARNING) |
301 | printf ("%s (%s)\n", errmsg, display_message); | 289 | np_die(STATE_WARNING, "%s (%s)\n", errmsg, display_message); |
302 | 290 | ||
303 | return result; | 291 | /* if printer could not be reached, escalate to critical */ |
292 | np_die(strstr(errmsg, "Timeout") ? STATE_CRITICAL : STATE_UNKNOWN, | ||
293 | "%s", errmsg); | ||
304 | } | 294 | } |
305 | 295 | ||
306 | 296 | ||