summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 20686f9)
raw | patch | inline | side by side (parent: 20686f9)
author | Rinigus <rinigus.git@gmail.com> | |
Wed, 3 Aug 2016 21:41:25 +0000 (00:41 +0300) | ||
committer | Rinigus <rinigus.git@gmail.com> | |
Wed, 3 Aug 2016 21:41:25 +0000 (00:41 +0300) |
configure.ac | patch | blob | history | |
src/collectd.conf.pod | patch | blob | history | |
src/cpusleep.c | patch | blob | history | |
src/types.db | patch | blob | history |
diff --git a/configure.ac b/configure.ac
index 949f04071f47b0a3d928e5aea87bcc9d91d15bf7..d66a3b4c9fc20a28dbac21d62566c573cb652eda 100644 (file)
--- a/configure.ac
+++ b/configure.ac
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"]))
diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod
index c3e239b643913b634b5dbd4e1e161941a83144d5..16138fef6a81a4bb82c49512600e0fbe746d6854 100644 (file)
--- a/src/collectd.conf.pod
+++ b/src/collectd.conf.pod
=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>
diff --git a/src/cpusleep.c b/src/cpusleep.c
index 7dcde8a19698606af63995d28b71588a769b188f..7cf222720b57b2f79800d140301f07a46961abb5 100644 (file)
--- a/src/cpusleep.c
+++ b/src/cpusleep.c
* 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);
diff --git a/src/types.db b/src/types.db
index e5719bc302618662efb1827a978c1e6a59cb541e..77a9d06f68e02a0eb86e140824f902d1872c1e34 100644 (file)
--- a/src/types.db
+++ b/src/types.db
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