summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 67d29e6)
raw | patch | inline | side by side (parent: 67d29e6)
author | Florian Forster <octo@huhu.verplant.org> | |
Wed, 4 Jul 2007 21:06:24 +0000 (23:06 +0200) | ||
committer | Florian Forster <octo@huhu.verplant.org> | |
Wed, 4 Jul 2007 21:06:24 +0000 (23:06 +0200) |
src/collectd-nagios.c | patch | blob | history |
diff --git a/src/collectd-nagios.c b/src/collectd-nagios.c
index fca9f18ca06e05ff4f38f5a426507480a82415ee..63effd5528bd706a30426d0b22cb557fd91faee9 100644 (file)
--- a/src/collectd-nagios.c
+++ b/src/collectd-nagios.c
num_okay++;
}
- if ((num_critical != 0) || (values_num == 0))
+ printf ("%i critical, %i warning, %i okay",
+ num_critical, num_warning, num_okay);
+ if (values_num > 0)
{
- printf ("CRITICAL: %i critical, %i warning, %i okay\n",
- num_critical, num_warning, num_okay);
- return (RET_CRITICAL);
+ printf (" |");
+ for (i = 0; i < values_num; i++)
+ printf (" %s=%lf;;;;", values_names[i], values[i]);
}
+ printf ("\n");
+
+ if ((num_critical != 0) || (values_num == 0))
+ return (RET_CRITICAL);
else if (num_warning != 0)
- {
- printf ("WARNING: %i warning, %i okay\n",
- num_warning, num_okay);
return (RET_WARNING);
- }
- else
- {
- printf ("OKAY: %i okay\n", num_okay);
- return (RET_OKAY);
- }
- return (RET_UNKNOWN);
+ return (RET_OKAY);
} /* int do_check_con_none */
int do_check_con_average (int values_num, double *values, char **values_names)
int i;
double total;
int total_num;
+ double average;
total = 0.0;
total_num = 0;
@@ -333,31 +331,23 @@ int do_check_con_average (int values_num, double *values, char **values_names)
}
if (total_num == 0)
- {
- printf ("WARNING: No defined values found\n");
+ average = NAN;
+ else
+ average = total / total_num;
+ printf ("%lf average |", average);
+ for (i = 0; i < values_num; i++)
+ printf (" %s=%lf;;;;", values_names[i], values[i]);
+
+ if (total_num == 0)
return (RET_WARNING);
- }
- if (match_range (&range_critical_g, total / total_num) != 0)
- {
- printf ("CRITICAL: Average = %lf\n",
- (double) (total / total_num));
+ if (isnan (average)
+ || match_range (&range_critical_g, average))
return (RET_CRITICAL);
- }
- else if (match_range (&range_warning_g, total / total_num) != 0)
- {
- printf ("WARNING: Average = %lf\n",
- (double) (total / total_num));
+ else if (match_range (&range_warning_g, average) != 0)
return (RET_WARNING);
- }
- else
- {
- printf ("OKAY: Average = %lf\n",
- (double) (total / total_num));
- return (RET_OKAY);
- }
- return (RET_UNKNOWN);
+ return (RET_OKAY);
} /* int do_check_con_average */
int do_check_con_sum (int values_num, double *values, char **values_names)
return (do_check_con_sum (values_num, values, values_names));
free (values);
- free (values_names);
+ free (values_names); /* FIXME? */
return (RET_UNKNOWN);
}