X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Fuptime.c;h=0892bda3a7c8ab549a9bdc82e51c8042d7b876f7;hp=d51aa391a09040229113c4accae5bb387375b897;hb=0e1e19f9e05c1b6a17f4a534cd0abd592fcab02e;hpb=4943510c1db22b5cf6342411271eb10255680211 diff --git a/src/uptime.c b/src/uptime.c index d51aa391..0892bda3 100644 --- a/src/uptime.c +++ b/src/uptime.c @@ -21,8 +21,8 @@ #include "collectd.h" -#include "common.h" #include "plugin.h" +#include "utils/common/common.h" #if KERNEL_LINUX #include @@ -53,6 +53,10 @@ * Global variables */ +#if HAVE_KSTAT_H +#include +#endif + #if HAVE_LIBKSTAT extern kstat_ctl_t *kc; #endif /* #endif HAVE_LIBKSTAT */ @@ -87,14 +91,12 @@ static time_t uptime_get_sys(void) { /* {{{ */ status = sysinfo(&info); if (status != 0) { - char errbuf[1024]; - ERROR("uptime plugin: Error calling sysinfo: %s", - sstrerror(errno, errbuf, sizeof(errbuf))); + ERROR("uptime plugin: Error calling sysinfo: %s", STRERRNO); return -1; } result = (time_t)info.uptime; -/* #endif KERNEL_LINUX */ + /* #endif KERNEL_LINUX */ #elif HAVE_LIBKSTAT kstat_t *ksp; @@ -134,7 +136,7 @@ static time_t uptime_get_sys(void) { /* {{{ */ } result = time(NULL) - (time_t)knp->value.ui32; -/* #endif HAVE_LIBKSTAT */ + /* #endif HAVE_LIBKSTAT */ #elif HAVE_SYS_SYSCTL_H struct timeval boottv = {0}; @@ -148,9 +150,7 @@ static time_t uptime_get_sys(void) { /* {{{ */ status = sysctl(mib, STATIC_ARRAY_SIZE(mib), &boottv, &boottv_len, /* new_value = */ NULL, /* new_length = */ 0); if (status != 0) { - char errbuf[1024]; - ERROR("uptime plugin: No value read from sysctl interface: %s", - sstrerror(errno, errbuf, sizeof(errbuf))); + ERROR("uptime plugin: No value read from sysctl interface: %s", STRERRNO); return -1; } @@ -161,7 +161,7 @@ static time_t uptime_get_sys(void) { /* {{{ */ } result = time(NULL) - boottv.tv_sec; -/* #endif HAVE_SYS_SYSCTL_H */ + /* #endif HAVE_SYS_SYSCTL_H */ #elif HAVE_PERFSTAT int status; @@ -170,9 +170,7 @@ static time_t uptime_get_sys(void) { /* {{{ */ 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))); + ERROR("uptime plugin: perfstat_cpu_total: %s", STRERRNO); return -1; }