summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0db0153)
raw | patch | inline | side by side (parent: 0db0153)
author | Subhendu Ghosh <sghosh@users.sourceforge.net> | |
Wed, 19 Jun 2002 03:09:10 +0000 (03:09 +0000) | ||
committer | Subhendu Ghosh <sghosh@users.sourceforge.net> | |
Wed, 19 Jun 2002 03:09:10 +0000 (03:09 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@54 f882894a-f735-0410-b71e-b25c423dba1c
plugins/check_disk.c | patch | blob | history | |
plugins/check_ping.c | patch | blob | history | |
plugins/check_procs.c | patch | blob | history |
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index 742942496e80adaa059939a6b87c49d37e945805..9ce4a3248ee72329d78cc4ae5d181d41dc218f47 100644 (file)
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
int used_disk = -1;
int free_disk = -1;
int result = STATE_UNKNOWN;
+ int temp_result = STATE_UNKNOWN;
char *command_line = NULL;
char input_buffer[MAX_INPUT_BUFFER] = "";
char file_system[MAX_INPUT_BUFFER] = "";
|| sscanf (input_buffer, "%s %*s %d %d %d %d%% %s", file_system,
&total_disk, &used_disk, &free_disk, &usp, &mntp) == 6) {
- result = max (result, check_disk (usp, free_disk));
+ /* cannot use max now that STATE_UNKNOWN is greater than STATE_CRITICAL
+ result = max (result, check_disk (usp, free_disk)); */
+ temp_result = check_disk (usp, free_disk) ;
+
+
+ if ( temp_result == STATE_CRITICAL ) {
+ result = STATE_CRITICAL;
+ }
+ else if (temp_result == STATE_WARNING) {
+ if ( !( result == STATE_CRITICAL) ) {
+ result = STATE_WARNING;
+ }
+ }
+ else if (temp_result == STATE_OK) {
+ if ( ! ( result == STATE_CRITICAL || result == STATE_WARNING) ){
+ result = STATE_OK;
+ }
+ }
+ else if (temp_result == STATE_UNKNOWN) {
+ if ( ! ( result == STATE_CRITICAL || result == STATE_WARNING || result == STATE_OK) ){
+ result = STATE_UNKNOWN;
+ }
+ }
+ else {
+ /* don't have a match with the return value from check_disk() */
+ result = STATE_UNKNOWN;
+ }
+
+
+
len =
snprintf (outbuf, MAX_INPUT_BUFFER - 1,
" [%d kB (%d%%) free on %s]", free_disk, 100 - usp,
/* If we get anything on stderr, at least set warning */
while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr))
- result = max (result, STATE_WARNING);
+ /*result = max (result, STATE_WARNING); */
+ if( !( result == STATE_CRITICAL) ) {
+ result = STATE_WARNING;
+ }
/* close stderr */
(void) fclose (child_stderr);
/* close the pipe */
if (spclose (child_process))
- result = max (result, STATE_WARNING);
-
+ /*result = max (result, STATE_WARNING); */
+ if( !( result == STATE_CRITICAL) ) {
+ result = STATE_WARNING;
+ }
if (usp < 0)
printf ("Disk \"%s\" not mounted or nonexistant\n", path);
else if (result == STATE_UNKNOWN)
diff --git a/plugins/check_ping.c b/plugins/check_ping.c
index 5eada4f49c17bf79512f1efc73d2aec0004c71d2..420f148c140bdcf77883e6d083a7b23d5411a6ca 100644 (file)
--- a/plugins/check_ping.c
+++ b/plugins/check_ping.c
else if (pl >= wpl || rta >= wrta)
result = STATE_WARNING;
else if (pl < wpl && rta < wrta && pl >= 0 && rta >= 0)
- result = max (result, STATE_OK);
-
+ /* cannot use the max function because STATE_UNKNOWN is now 3 gt STATE_OK
+ result = max (result, STATE_OK); */
+ if( !( (result == STATE_WARNING) || (result == STATE_CRITICAL) ) ) {
+ result = STATE_OK;
+ }
+
if (display_html == TRUE)
printf ("<A HREF='%s/traceroute.cgi?%s'>", CGIURL, server_address);
if (pl == 100)
while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) {
if (strstr (input_buffer, "(DUP!)")) {
- result = max (result, STATE_WARNING);
+ /* cannot use the max function since STATE_UNKNOWN is max
+ result = max (result, STATE_WARNING); */
+ if( !(result == STATE_CRITICAL) ){
+ result = STATE_WARNING;
+ }
+
warn_text = realloc (warn_text, strlen (WARN_DUPLICATES) + 1);
if (warn_text == NULL)
terminate (STATE_UNKNOWN, "unable to realloc warn_text");
else if (strstr (input_buffer, "Destination Host Unreachable"))
terminate (STATE_CRITICAL, "PING CRITICAL - Host Unreachable (%s)",
server_address);
+ else if (strstr (input_buffer, "unknown host" ) )
+ terminate (STATE_CRITICAL, "PING CRITICAL - Host not found (%s)",
+ server_address);
warn_text =
realloc (warn_text, strlen (warn_text) + strlen (input_buffer) + 2);
sprintf (warn_text, "%s %s", warn_text, input_buffer);
if (strstr (input_buffer, "DUPLICATES FOUND"))
- result = max (result, STATE_WARNING);
+ /* cannot use the max function since STATE_UNKNOWN is max
+ result = max (result, STATE_WARNING); */
+ if( !(result == STATE_CRITICAL) ){
+ result = STATE_WARNING;
+ }
else
- result = max (result, STATE_CRITICAL);
+ /* cannot use the max function since STATE_UNKNOWN is max
+ result = max (result, STATE_CRITICAL); */
+ result = STATE_CRITICAL ;
}
(void) fclose (child_stderr);
return result;
}
-\f
+
void
print_usage (void)
diff --git a/plugins/check_procs.c b/plugins/check_procs.c
index c66d33decd37ea9324446f4265948b681fc0e0a3..9a3dc015f7ab1e7a44ac87947e49fb93d6a779ab 100644 (file)
--- a/plugins/check_procs.c
+++ b/plugins/check_procs.c
/* If we get anything on STDERR, at least set warning */
while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) {
if (verbose)
- printf ("%s", input_buffer);
- result = max (result, STATE_WARNING);
+ printf ("STDERR: %s", input_buffer);
+ /*Cannot use max() any more as STATE_UNKNOWN is gt STATE_CRITICAL
+ result = max (result, STATE_WARNING); */
+ if ( !(result == STATE_CRITICAL) ) {
+ result = STATE_WARNING;
+ }
+ printf ("System call sent warnings to stderr\n");
}
- if (result > STATE_OK)
+
+/* if (result == STATE_UNKNOWN || result == STATE_WARNING)
printf ("System call sent warnings to stderr\n");
-
+*/
(void) fclose (child_stderr);
/* close the pipe */
if (spclose (child_process)) {
printf ("System call returned nonzero status\n");
- return max (result, STATE_WARNING);
+ if ( !(result == STATE_CRITICAL) ) {
+ return STATE_WARNING;
+ }
+ else {
+ return result ;
+ }
}
if (options == ALL)
if (found == 0) { /* no process lines parsed so return STATE_UNKNOWN */
printf ("Unable to read output\n");
- return max (result, STATE_UNKNOWN);
+
+ return result;
}
if (verbose && (options & STAT))
}
else if (wmax >= 0 && procs > wmax) {
printf (format, "WARNING", procs);
- return max (result, STATE_WARNING);
+ if ( !(result == STATE_CRITICAL) ) {
+ return STATE_WARNING;
+ }
+ else {
+ return result ;
+ }
+ /*return max (result, STATE_WARNING); */
}
else if (wmin >= 0 && procs < wmin) {
printf (format, "WARNING", procs);
- return max (result, STATE_WARNING);
+ if ( !(result == STATE_CRITICAL) ) {
+ return STATE_WARNING;
+ }
+ else {
+ return result ;
+ }
+ /*return max (result, STATE_WARNING); */
}
printf (format, "OK", procs);
- return max (result, STATE_OK);
+ if ( result == STATE_UNKNOWN ) {
+ result = STATE_OK;
+ }
+ return result;
}
/* process command-line arguments */