projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge remote-tracking branch 'github/pr/2285'
[collectd.git]
/
src
/
uptime.c
diff --git
a/src/uptime.c
b/src/uptime.c
index
e7479e8
..
2be9d79
100644
(file)
--- a/
src/uptime.c
+++ b/
src/uptime.c
@@
-60,16
+60,12
@@
static time_t boottime;
extern kstat_ctl_t *kc;
#endif /* #endif HAVE_LIBKSTAT */
extern kstat_ctl_t *kc;
#endif /* #endif HAVE_LIBKSTAT */
-static void uptime_submit(gauge_t uptime) {
- value_t values[1];
+static void uptime_submit(gauge_t value) {
value_list_t vl = VALUE_LIST_INIT;
value_list_t vl = VALUE_LIST_INIT;
- values[0].gauge = uptime;
-
- vl.values = values;
+ vl.values = &(value_t){.gauge = value};
vl.values_len = 1;
vl.values_len = 1;
- sstrncpy(vl.host, hostname_g, sizeof(vl.host));
sstrncpy(vl.plugin, "uptime", sizeof(vl.plugin));
sstrncpy(vl.type, "uptime", sizeof(vl.type));
sstrncpy(vl.plugin, "uptime", sizeof(vl.plugin));
sstrncpy(vl.type, "uptime", sizeof(vl.type));
@@
-103,7
+99,7
@@
static int uptime_init(void) /* {{{ */
char errbuf[1024];
ERROR("uptime plugin: Cannot open " STAT_FILE ": %s",
sstrerror(errno, errbuf, sizeof(errbuf)));
char errbuf[1024];
ERROR("uptime plugin: Cannot open " STAT_FILE ": %s",
sstrerror(errno, errbuf, sizeof(errbuf)));
- return
(-1)
;
+ return
-1
;
}
while (fgets(buffer, 1024, fh) != NULL) {
}
while (fgets(buffer, 1024, fh) != NULL) {
@@
-120,7
+116,7
@@
static int uptime_init(void) /* {{{ */
/* loop done, check if no value has been found/read */
if (ret != 1) {
ERROR("uptime plugin: No value read from " STAT_FILE "");
/* loop done, check if no value has been found/read */
if (ret != 1) {
ERROR("uptime plugin: No value read from " STAT_FILE "");
- return
(-1)
;
+ return
-1
;
}
boottime = (time_t)starttime;
}
boottime = (time_t)starttime;
@@
-128,7
+124,7
@@
static int uptime_init(void) /* {{{ */
if (boottime == 0) {
ERROR("uptime plugin: btime read from " STAT_FILE ", "
"but `boottime' is zero!");
if (boottime == 0) {
ERROR("uptime plugin: btime read from " STAT_FILE ", "
"but `boottime' is zero!");
- return
(-1)
;
+ return
-1
;
}
/* #endif KERNEL_LINUX */
}
/* #endif KERNEL_LINUX */
@@
-143,24
+139,24
@@
static int uptime_init(void) /* {{{ */
* went fine. */
if (kc == NULL) {
ERROR("uptime plugin: kstat chain control structure not available.");
* went fine. */
if (kc == NULL) {
ERROR("uptime plugin: kstat chain control structure not available.");
- return
(-1)
;
+ return
-1
;
}
ksp = kstat_lookup(kc, "unix", 0, "system_misc");
if (ksp == NULL) {
ERROR("uptime plugin: Cannot find unix:0:system_misc kstat.");
}
ksp = kstat_lookup(kc, "unix", 0, "system_misc");
if (ksp == NULL) {
ERROR("uptime plugin: Cannot find unix:0:system_misc kstat.");
- return
(-1)
;
+ return
-1
;
}
if (kstat_read(kc, ksp, NULL) < 0) {
ERROR("uptime plugin: kstat_read failed.");
}
if (kstat_read(kc, ksp, NULL) < 0) {
ERROR("uptime plugin: kstat_read failed.");
- return
(-1)
;
+ return
-1
;
}
knp = (kstat_named_t *)kstat_data_lookup(ksp, "boot_time");
if (knp == NULL) {
ERROR("uptime plugin: kstat_data_lookup (boot_time) failed.");
}
knp = (kstat_named_t *)kstat_data_lookup(ksp, "boot_time");
if (knp == NULL) {
ERROR("uptime plugin: kstat_data_lookup (boot_time) failed.");
- return
(-1)
;
+ return
-1
;
}
boottime = (time_t)knp->value.ui32;
}
boottime = (time_t)knp->value.ui32;
@@
-168,7
+164,7
@@
static int uptime_init(void) /* {{{ */
if (boottime == 0) {
ERROR("uptime plugin: kstat_data_lookup returned success, "
"but `boottime' is zero!");
if (boottime == 0) {
ERROR("uptime plugin: kstat_data_lookup returned success, "
"but `boottime' is zero!");
- return
(-1)
;
+ return
-1
;
}
/* #endif HAVE_LIBKSTAT */
}
/* #endif HAVE_LIBKSTAT */
@@
-187,7
+183,7
@@
static int uptime_init(void) /* {{{ */
char errbuf[1024];
ERROR("uptime plugin: No value read from sysctl interface: %s",
sstrerror(errno, errbuf, sizeof(errbuf)));
char errbuf[1024];
ERROR("uptime plugin: No value read from sysctl interface: %s",
sstrerror(errno, errbuf, sizeof(errbuf)));
- return
(-1)
;
+ return
-1
;
}
boottime = boottv.tv_sec;
}
boottime = boottv.tv_sec;
@@
-195,7
+191,7
@@
static int uptime_init(void) /* {{{ */
if (boottime == 0) {
ERROR("uptime plugin: sysctl(3) returned success, "
"but `boottime' is zero!");
if (boottime == 0) {
ERROR("uptime plugin: sysctl(3) returned success, "
"but `boottime' is zero!");
- return
(-1)
;
+ return
-1
;
}
/* #endif HAVE_SYS_SYSCTL_H */
}
/* #endif HAVE_SYS_SYSCTL_H */
@@
-209,7
+205,7
@@
static int uptime_init(void) /* {{{ */
char errbuf[1024];
ERROR("uptime plugin: perfstat_cpu_total: %s",
sstrerror(errno, errbuf, sizeof(errbuf)));
char errbuf[1024];
ERROR("uptime plugin: perfstat_cpu_total: %s",
sstrerror(errno, errbuf, sizeof(errbuf)));
- return
(-1)
;
+ return
-1
;
}
hertz = sysconf(_SC_CLK_TCK);
}
hertz = sysconf(_SC_CLK_TCK);
@@
-219,7
+215,7
@@
static int uptime_init(void) /* {{{ */
boottime = time(NULL) - cputotal.lbolt / hertz;
#endif /* HAVE_PERFSTAT */
boottime = time(NULL) - cputotal.lbolt / hertz;
#endif /* HAVE_PERFSTAT */
- return
(0)
;
+ return
0
;
} /* }}} int uptime_init */
static int uptime_read(void) {
} /* }}} int uptime_init */
static int uptime_read(void) {
@@
-233,7
+229,7
@@
static int uptime_read(void) {
uptime_submit(uptime);
uptime_submit(uptime);
- return
(0)
;
+ return
0
;
}
void module_register(void) {
}
void module_register(void) {