AC_CACHE_CHECK([whether clock_boottime and clock_monotonic are supported],
[c_cv_have_clock_boottime_monotonic],
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
-[[[
+[[
#include <time.h>
-]]],
-[[[
+]],
+[[
struct timespec b, m;
clock_gettime(CLOCK_BOOTTIME, &b );
clock_gettime(CLOCK_MONOTONIC, &m );
-]]]
+]]
)],
[c_cv_have_clock_boottime_monotonic="yes"],
[c_cv_have_clock_boottime_monotonic="no"]))
=head2 Plugin C<cpusleep>
This plugin doesn't have any options. It reads CLOCK_BOOTTIME and
-CLOCK_MONOTONIC and reports the differences between these
-clocks. Since BOOTTIME clock increments while device is suspended and
-MONOTONIC clock does not, the derivative of the difference between
-these clocks gives the relative amount of time the device has spent in
-suspend state. The recorded value is in milliseconds / seconds.
+CLOCK_MONOTONIC and reports the difference between these clocks. Since
+BOOTTIME clock increments while device is suspended and MONOTONIC
+clock does not, the derivative of the difference between these clocks
+gives the relative amount of time the device has spent in suspend
+state. The recorded value is in milliseconds of sleep per seconds of
+wall clock.
=head2 Plugin C<csv>
* Authors:
* rinigus <http://github.com/rinigus>
- CPU sleep is reported in milliseconds / s. For that, derive type was
- selected and the time difference between BOOT and MONOTONIC clocks
- fed to RRD
+ CPU sleep is reported in milliseconds of sleep per second of wall
+ time. For that, the time difference between BOOT and MONOTONIC clocks
+ is reported using derive type.
**/
vl.values_len = 1;
sstrncpy(vl.host, hostname_g, sizeof (vl.host));
sstrncpy(vl.plugin, "cpusleep", sizeof (vl.plugin));
- sstrncpy(vl.type, "cpusleep", sizeof (vl.type));
+ sstrncpy(vl.type, "total_time_in_ms", sizeof (vl.type));
plugin_dispatch_values(&vl);
}
return (-1);
}
- double db = b.tv_sec + 1e-9 * b.tv_nsec;
- double dm = m.tv_sec + 1e-9 * m.tv_nsec;
-
// to avoid false positives in counter overflow due to reboot,
// derive is used
- derive_t sleep = (derive_t) ((db-dm) * 1000);
+ derive_t sleep = (derive_t) ((b.tv_sec - m.tv_sec)*1e3 + (b.tv_nsec - m.tv_nsec)*1e-6);
cpusleep_submit(sleep);
counter value:COUNTER:U:U
cpu value:DERIVE:0:U
cpufreq value:GAUGE:0:U
-cpusleep value:DERIVE:0:U
current value:GAUGE:U:U
current_connections value:GAUGE:0:U
current_sessions value:GAUGE:0:U