From: Manuel Luis SanmartĂ­n Rozada Date: Wed, 5 Sep 2012 12:01:40 +0000 (+0200) Subject: Add AIX support for uptime plugin. X-Git-Tag: collectd-5.2.0~49^2~1 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=48096d34f886cdb8b37e999c690260274e1d9449;p=collectd.git Add AIX support for uptime plugin. --- diff --git a/configure.in b/configure.in index 50f5fd5a..bc5330eb 100644 --- a/configure.in +++ b/configure.in @@ -4642,6 +4642,7 @@ then 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 d2ba9633..064c3cee 100644 --- a/src/uptime.c +++ b/src/uptime.c @@ -37,6 +37,12 @@ /* Using sysctl interface to retrieve the boot time on *BSD / Darwin / OS X systems */ /* #endif HAVE_SYS_SYSCTL_H */ +#elif HAVE_PERFSTAT +# include +# include +/* Using perfstat_cpu_total to retrive the boot time in AIX */ +/* #endif HAVE_PERFSTAT */ + #else # error "No applicable input method." #endif @@ -203,7 +209,29 @@ static int uptime_init (void) /* {{{ */ "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 */