projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Declare var inside loop (code review change)
[collectd.git]
/
src
/
contextswitch.c
diff --git
a/src/contextswitch.c
b/src/contextswitch.c
index
d91c073
..
acf3a74
100644
(file)
--- a/
src/contextswitch.c
+++ b/
src/contextswitch.c
@@
-23,8
+23,8
@@
#include "collectd.h"
#include "collectd.h"
-#include "common.h"
#include "plugin.h"
#include "plugin.h"
+#include "utils/common/common.h"
#ifdef HAVE_SYS_SYSCTL_H
#include <sys/sysctl.h>
#ifdef HAVE_SYS_SYSCTL_H
#include <sys/sysctl.h>
@@
-48,14
+48,10
@@
#endif
static void cs_submit(derive_t context_switches) {
#endif
static void cs_submit(derive_t context_switches) {
- value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
value_list_t vl = VALUE_LIST_INIT;
- values[0].derive = (derive_t)context_switches;
-
- vl.values = values;
+ vl.values = &(value_t){.derive = context_switches};
vl.values_len = 1;
vl.values_len = 1;
- sstrncpy(vl.host, hostname_g, sizeof(vl.host));
sstrncpy(vl.plugin, "contextswitch", sizeof(vl.plugin));
sstrncpy(vl.type, "contextswitch", sizeof(vl.type));
sstrncpy(vl.plugin, "contextswitch", sizeof(vl.plugin));
sstrncpy(vl.type, "contextswitch", sizeof(vl.type));
@@
-73,7
+69,7
@@
static int cs_read(void) {
if (status != 0) {
ERROR("contextswitch plugin: sysctlbyname "
"(vm.stats.sys.v_swtch) failed");
if (status != 0) {
ERROR("contextswitch plugin: sysctlbyname "
"(vm.stats.sys.v_swtch) failed");
- return
(-1)
;
+ return
-1
;
}
cs_submit(value);
}
cs_submit(value);
@@
-89,9
+85,8
@@
static int cs_read(void) {
fh = fopen("/proc/stat", "r");
if (fh == NULL) {
fh = fopen("/proc/stat", "r");
if (fh == NULL) {
- ERROR("contextswitch plugin: unable to open /proc/stat: %s",
- sstrerror(errno, buffer, sizeof(buffer)));
- return (-1);
+ ERROR("contextswitch plugin: unable to open /proc/stat: %s", STRERRNO);
+ return -1;
}
while (fgets(buffer, sizeof(buffer), fh) != NULL) {
}
while (fgets(buffer, sizeof(buffer), fh) != NULL) {
@@
-130,10
+125,8
@@
static int cs_read(void) {
status =
perfstat_cpu_total(NULL, &perfcputotal, sizeof(perfstat_cpu_total_t), 1);
if (status < 0) {
status =
perfstat_cpu_total(NULL, &perfcputotal, sizeof(perfstat_cpu_total_t), 1);
if (status < 0) {
- char errbuf[1024];
- ERROR("contextswitch plugin: perfstat_cpu_total: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
- return (-1);
+ ERROR("contextswitch plugin: perfstat_cpu_total: %s", STRERRNO);
+ return -1;
}
cs_submit(perfcputotal.pswitch);
}
cs_submit(perfcputotal.pswitch);