summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8cccaeb)
raw | patch | inline | side by side (parent: 8cccaeb)
author | Manuel Luis SanmartĂn Rozada <manuel.luis@gmail.com> | |
Wed, 5 Sep 2012 12:01:40 +0000 (14:01 +0200) | ||
committer | Florian Forster <octo@collectd.org> | |
Tue, 2 Oct 2012 20:02:12 +0000 (22:02 +0200) |
configure.in | patch | blob | history | |
src/uptime.c | patch | blob | history |
diff --git a/configure.in b/configure.in
index 50f5fd5a124c87b5aa411be265a19748112224d2..bc5330eb355ed2f89fa725161f79be084230618b 100644 (file)
--- a/configure.in
+++ b/configure.in
plugin_swap="yes"
plugin_interface="yes"
plugin_load="yes"
+ plugin_uptime="yes"
fi
if test "x$with_procinfo" = "xyes"
diff --git a/src/uptime.c b/src/uptime.c
index d2ba9633db290aeb17ac0a064874b3c652742b3a..064c3ceed4752a359c7ec2e5b9d84afa27068543 100644 (file)
--- a/src/uptime.c
+++ b/src/uptime.c
/* Using sysctl interface to retrieve the boot time on *BSD / Darwin / OS X systems */
/* #endif HAVE_SYS_SYSCTL_H */
+#elif HAVE_PERFSTAT
+# include <sys/protosw.h>
+# include <libperfstat.h>
+/* Using perfstat_cpu_total to retrive the boot time in AIX */
+/* #endif HAVE_PERFSTAT */
+
#else
# error "No applicable input method."
#endif
"but `boottime' is zero!");
return (-1);
}
-#endif /* HAVE_SYS_SYSCTL_H */
+/* #endif HAVE_SYS_SYSCTL_H */
+
+#elif HAVE_PERFSTAT
+ int status;
+ perfstat_cpu_total_t cputotal;
+ int hertz;
+
+ status = perfstat_cpu_total(NULL, &cputotal,
+ sizeof(perfstat_cpu_total_t), 1);
+ if (status < 0)
+ {
+ char errbuf[1024];
+ ERROR ("uptime plugin: perfstat_cpu_total: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
+ return (-1);
+ }
+
+ hertz = sysconf(_SC_CLK_TCK);
+ if (hertz <= 0)
+ hertz = HZ;
+
+ boottime = time(NULL) - cputotal.lbolt / hertz;
+#endif /* HAVE_PERFSTAT */
return (0);
} /* }}} int uptime_init */