Skip to content

Commit

Permalink
Merge branch 'collectd-5.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
octo committed Feb 7, 2011
2 parents 801389e + 4dc9287 commit 738d948
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 16 deletions.
4 changes: 0 additions & 4 deletions src/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
19 changes: 10 additions & 9 deletions src/ntpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down
32 changes: 29 additions & 3 deletions src/threshold.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 738d948

Please sign in to comment.