summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: eda2991)
raw | patch | inline | side by side (parent: eda2991)
author | Florian Forster <octo@huhu.verplant.org> | |
Wed, 30 Jun 2010 08:47:07 +0000 (10:47 +0200) | ||
committer | Florian Forster <octo@huhu.verplant.org> | |
Wed, 30 Jun 2010 08:47:07 +0000 (10:47 +0200) |
src/collectd-nagios.c | patch | blob | history | |
src/collectd-nagios.pod | patch | blob | history |
diff --git a/src/collectd-nagios.c b/src/collectd-nagios.c
index 45162bd3de607170e3b34399e078b851fd4a58bd..b190d6ee7a7f118bdcebea121856339ebc7542ca 100644 (file)
--- a/src/collectd-nagios.c
+++ b/src/collectd-nagios.c
/**
* collectd-nagios - src/collectd-nagios.c
- * Copyright (C) 2008 Florian octo Forster
+ * Copyright (C) 2008-2010 Florian octo Forster
*
* 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
static range_t range_critical_g;
static range_t range_warning_g;
static int consolitation_g = CON_NONE;
+static _Bool nan_is_error_g = 0;
static char **match_ds_g = NULL;
static int match_ds_num_g = 0;
" -H <host> Hostname to query the values for.\n"
" -c <range> Critical range\n"
" -w <range> Warning range\n"
+ " -m Treat \"Not a Number\" (NaN) as critical (default: warning)\n"
"\n"
"Consolidation functions:\n"
" none: Apply the warning- and critical-ranges to each data-source\n"
for (i = 0; i < values_num; i++)
{
if (isnan (values[i]))
- num_warning++;
+ {
+ if (nan_is_error_g)
+ num_critical++;
+ else
+ num_warning++;
+ }
else if (match_range (&range_critical_g, values[i]) != 0)
num_critical++;
else if (match_range (&range_warning_g, values[i]) != 0)
total_num = 0;
for (i = 0; i < values_num; i++)
{
- if (!isnan (values[i]))
+ if (isnan (values[i]))
{
- total += values[i];
- total_num++;
+ if (!nan_is_error_g)
+ continue;
+
+ printf ("CRITICAL: Data source \"%s\" is NaN\n",
+ values_names[i]);
+ return (RET_CRITICAL);
}
+
+ total += values[i];
+ total_num++;
}
if (total_num == 0)
total_num = 0;
for (i = 0; i < values_num; i++)
{
- if (!isnan (values[i]))
+ if (isnan (values[i]))
{
- total += values[i];
- total_num++;
+ if (!nan_is_error_g)
+ continue;
+
+ printf ("CRITICAL: Data source \"%s\" is NaN\n",
+ values_names[i]);
+ return (RET_CRITICAL);
}
+
+ total += values[i];
+ total_num++;
}
if (total_num == 0)
}
for (i = 0; i < values_num; i++)
- if (!isnan (values[i]))
- sum += values[i];
+ {
+ if (isnan (values[i]))
+ {
+ if (!nan_is_error_g)
+ continue;
+
+ printf ("CRITICAL: Data source \"%s\" is NaN\n",
+ values_names[i]);
+ return (RET_CRITICAL);
+ }
+
+ sum += values[i];
+ }
if (sum == 0.0)
{
{
int c;
- c = getopt (argc, argv, "w:c:s:n:H:g:d:h");
+ c = getopt (argc, argv, "w:c:s:n:H:g:d:hm");
if (c < 0)
break;
match_ds_num_g++;
break;
}
+ case 'm':
+ nan_is_error_g = 1;
+ break;
default:
usage (argv[0]);
} /* switch (c) */
index c6347eac9361746c8f60b6b33713983d466da241..d7c749cd3391aefc86369c208193063111655fe6 100644 (file)
--- a/src/collectd-nagios.pod
+++ b/src/collectd-nagios.pod
I<min> is then assumed to be zero. If I<max> (but not the trailing colon) is
omitted, I<max> is assumed to be positive infinity.
+=item B<-m>
+
+If this option is given, "Not a Number" (NaN) is treated as I<critical>. By
+default, the I<none> consolidation reports NaNs as I<warning>. Other
+consolidations simply ignore NaN values.
+
=back
=head1 RETURN VALUE