From: Florian Forster Date: Mon, 7 Feb 2011 07:47:35 +0000 (+0100) Subject: Merge branch 'collectd-4.10' into collectd-5.0 X-Git-Tag: collectd-5.0.0~5 X-Git-Url: https://git.octo.it/?p=collectd.git;a=commitdiff_plain;h=4dc9287f4de0283ae986444377075dcbdada2871;hp=ef3c8ce93f6cfb2517a2b2d6ea7c07a81e8c41f3 Merge branch 'collectd-4.10' into collectd-5.0 --- diff --git a/src/exec.c b/src/exec.c index 8d5ae9c3..0d33b290 100644 --- a/src/exec.c +++ b/src/exec.c @@ -283,10 +283,6 @@ static void set_environment (void) /* {{{ */ 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 ecc87c78..8bbf74d7 100644 --- a/src/ntpd.c +++ b/src/ntpd.c @@ -784,15 +784,15 @@ static int ntpd_read (void) 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); } @@ -820,12 +820,13 @@ static int ntpd_read (void) 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/threshold.c b/src/threshold.c index 369051a2..277b4538 100644 --- a/src/threshold.c +++ b/src/threshold.c @@ -717,15 +717,41 @@ static int ut_report_state (const data_set_t *ds, ((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;