X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Fuptime.c;fp=src%2Fuptime.c;h=064c3ceed4752a359c7ec2e5b9d84afa27068543;hp=d2ba9633db290aeb17ac0a064874b3c652742b3a;hb=48096d34f886cdb8b37e999c690260274e1d9449;hpb=8cccaeb8bb9a7edc5c81c335e79bdbc69f66e79d 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 */