author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Mon, 7 Feb 2011 07:47:18 +0000 (08:47 +0100) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Mon, 7 Feb 2011 07:47:18 +0000 (08:47 +0100) |
src/exec.c | patch | blob | history | |
src/ntpd.c | patch | blob | history | |
src/utils_threshold.c | patch | blob | history |
diff --git a/src/exec.c b/src/exec.c
index c64f949fc57b4ac5cff424a6b27e7cd283e13184..639b5d45b9dd310509dd0a763404de6e6ffabb7b 100644 (file)
--- a/src/exec.c
+++ b/src/exec.c
ssnprintf (buffer, sizeof (buffer), "COLLECTD_HOSTNAME=%s", hostname_g);
putenv (buffer);
#endif
-
-#ifdef HAVE_SETENV
-#else
-#endif
} /* }}} void set_environment */
__attribute__((noreturn))
diff --git a/src/ntpd.c b/src/ntpd.c
index ecc87c78977dbbdde88e920aa5f6156a1060fc0d..8bbf74d7d965b94ac0d21939fc3a4776116a7539 100644 (file)
--- a/src/ntpd.c
+++ b/src/ntpd.c
0, 0, NULL, /* request data */
&ik_num, &ik_size, (char **) ((void *) &ik), /* response data */
sizeof (struct info_kernel));
-
if (status != 0)
{
- DEBUG ("ntpd_do_query failed with status %i", status);
- return (-1);
+ ERROR ("ntpd plugin: ntpd_do_query (REQ_GET_KERNEL) failed with status %i", status);
+ return (status);
}
- if ((ik == NULL) || (ik_num == 0) || (ik_size == 0))
+ else if ((ik == NULL) || (ik_num == 0) || (ik_size == 0))
{
- DEBUG ("ntpd_do_query returned: ik = %p; ik_num = %i; ik_size = %i;",
+ ERROR ("ntpd plugin: ntpd_do_query returned unexpected data. "
+ "(ik = %p; ik_num = %i; ik_size = %i)",
(void *) ik, ik_num, ik_size);
return (-1);
}
sizeof (struct info_peer_summary));
if (status != 0)
{
- DEBUG ("ntpd_do_query failed with status %i", status);
- return (-1);
+ ERROR ("ntpd plugin: ntpd_do_query (REQ_PEER_LIST_SUM) failed with status %i", status);
+ return (status);
}
- if ((ps == NULL) || (ps_num == 0) || (ps_size == 0))
+ else if ((ps == NULL) || (ps_num == 0) || (ps_size == 0))
{
- DEBUG ("ntpd_do_query returned: ps = %p; ps_num = %i; ps_size = %i;",
+ ERROR ("ntpd plugin: ntpd_do_query returned unexpected data. "
+ "(ps = %p; ps_num = %i; ps_size = %i)",
(void *) ps, ps_num, ps_size);
return (-1);
}
diff --git a/src/utils_threshold.c b/src/utils_threshold.c
index 090cc75206f9c47acdde32dc5c6821bca67201aa..b14c79b5c6005bfdb86b9a3abfebb266a592897e 100644 (file)
--- a/src/utils_threshold.c
+++ b/src/utils_threshold.c
((th->flags & UT_FLAG_PERCENTAGE) != 0) ? "%" : "");
}
}
+ else if (th->flags & UT_FLAG_PERCENTAGE)
+ {
+ gauge_t value;
+ gauge_t sum;
+ int i;
+
+ sum = 0.0;
+ for (i = 0; i < vl->values_len; i++)
+ {
+ if (isnan (values[i]))
+ continue;
+
+ sum += values[i];
+ }
+
+ if (sum == 0.0)
+ value = NAN;
+ else
+ value = 100.0 * values[ds_index] / sum;
+
+ status = ssnprintf (buf, bufsize, ": Data source \"%s\" is currently "
+ "%g (%.2f%%). That is %s the %s threshold of %.2f%%.",
+ ds->ds[ds_index].name, values[ds_index], value,
+ (value < min) ? "below" : "above",
+ (state == STATE_ERROR) ? "failure" : "warning",
+ (value < min) ? min : max);
+ }
else /* is not inverted */
{
status = ssnprintf (buf, bufsize, ": Data source \"%s\" is currently "
- "%f. That is %s the %s threshold of %f%s.",
+ "%f. That is %s the %s threshold of %f.",
ds->ds[ds_index].name, values[ds_index],
(values[ds_index] < min) ? "below" : "above",
(state == STATE_ERROR) ? "failure" : "warning",
- (values[ds_index] < min) ? min : max,
- ((th->flags & UT_FLAG_PERCENTAGE) != 0) ? "%" : "");
+ (values[ds_index] < min) ? min : max);
}
buf += status;
bufsize -= status;