projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Treewide: use bool instead of _Bool
[collectd.git]
/
src
/
load.c
diff --git
a/src/load.c
b/src/load.c
index
585b1f9
..
ac07fa6
100644
(file)
--- a/
src/load.c
+++ b/
src/load.c
@@
-55,7
+55,7
@@
#include <sys/protosw.h>
#endif /* HAVE_PERFSTAT */
#include <sys/protosw.h>
#endif /* HAVE_PERFSTAT */
-static
_B
ool report_relative_load = 0;
+static
b
ool report_relative_load = 0;
static const char *config_keys[] = {"ReportRelative"};
static int config_keys_num = STATIC_ARRAY_SIZE(config_keys);
static const char *config_keys[] = {"ReportRelative"};
static int config_keys_num = STATIC_ARRAY_SIZE(config_keys);
@@
-69,19
+69,15
@@
static int load_config(const char *key, const char *value) {
"is not available, because I can't determine the "
"number of CPUS on this system. Sorry.");
#endif
"is not available, because I can't determine the "
"number of CPUS on this system. Sorry.");
#endif
- return
(-1)
;
+ return
-1
;
}
static void load_submit(gauge_t snum, gauge_t mnum, gauge_t lnum) {
}
static void load_submit(gauge_t snum, gauge_t mnum, gauge_t lnum) {
- value_t values[3];
- value_list_t vl = VALUE_LIST_INIT;
int cores = 0;
int cores = 0;
- char errbuf[1024];
#ifdef _SC_NPROCESSORS_ONLN
if (report_relative_load) {
if ((cores = sysconf(_SC_NPROCESSORS_ONLN)) < 1) {
#ifdef _SC_NPROCESSORS_ONLN
if (report_relative_load) {
if ((cores = sysconf(_SC_NPROCESSORS_ONLN)) < 1) {
- WARNING("load: sysconf failed : %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("load: sysconf failed : %s", STRERRNO);
}
}
#endif
}
}
#endif
@@
-91,14
+87,14
@@
static void load_submit(gauge_t snum, gauge_t mnum, gauge_t lnum) {
lnum /= cores;
}
lnum /= cores;
}
- values[0].gauge = snum;
- values[1].gauge = mnum;
- values[2].gauge = lnum;
+ value_list_t vl = VALUE_LIST_INIT;
+ value_t values[] = {
+ {.gauge = snum}, {.gauge = mnum}, {.gauge = lnum},
+ };
vl.values = values;
vl.values_len = STATIC_ARRAY_SIZE(values);
vl.values = values;
vl.values_len = STATIC_ARRAY_SIZE(values);
- sstrncpy(vl.host, hostname_g, sizeof(vl.host));
sstrncpy(vl.plugin, "load", sizeof(vl.plugin));
sstrncpy(vl.type, "load", sizeof(vl.type));
sstrncpy(vl.plugin, "load", sizeof(vl.plugin));
sstrncpy(vl.type, "load", sizeof(vl.type));
@@
-116,9
+112,7
@@
static int load_read(void) {
if (getloadavg(load, 3) == 3)
load_submit(load[LOADAVG_1MIN], load[LOADAVG_5MIN], load[LOADAVG_15MIN]);
else {
if (getloadavg(load, 3) == 3)
load_submit(load[LOADAVG_1MIN], load[LOADAVG_5MIN], load[LOADAVG_15MIN]);
else {
- char errbuf[1024];
- WARNING("load: getloadavg failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("load: getloadavg failed: %s", STRERRNO);
}
/* #endif HAVE_GETLOADAVG */
}
/* #endif HAVE_GETLOADAVG */
@@
-131,27
+125,24
@@
static int load_read(void) {
int numfields;
if ((loadavg = fopen("/proc/loadavg", "r")) == NULL) {
int numfields;
if ((loadavg = fopen("/proc/loadavg", "r")) == NULL) {
- char errbuf[1024];
- WARNING("load: fopen: %s", sstrerror(errno, errbuf, sizeof(errbuf)));
- return (-1);
+ WARNING("load: fopen: %s", STRERRNO);
+ return -1;
}
if (fgets(buffer, 16, loadavg) == NULL) {
}
if (fgets(buffer, 16, loadavg) == NULL) {
- char errbuf[1024];
- WARNING("load: fgets: %s", sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("load: fgets: %s", STRERRNO);
fclose(loadavg);
fclose(loadavg);
- return
(-1)
;
+ return
-1
;
}
if (fclose(loadavg)) {
}
if (fclose(loadavg)) {
- char errbuf[1024];
- WARNING("load: fclose: %s", sstrerror(errno, errbuf, sizeof(errbuf)));
+ WARNING("load: fclose: %s", STRERRNO);
}
numfields = strsplit(buffer, fields, 8);
if (numfields < 3)
}
numfields = strsplit(buffer, fields, 8);
if (numfields < 3)
- return
(-1)
;
+ return
-1
;
snum = atof(fields[0]);
mnum = atof(fields[1]);
snum = atof(fields[0]);
mnum = atof(fields[1]);
@@
-179,10
+170,8
@@
static int load_read(void) {
if (perfstat_cpu_total(NULL, &cputotal, sizeof(perfstat_cpu_total_t), 1) <
0) {
if (perfstat_cpu_total(NULL, &cputotal, sizeof(perfstat_cpu_total_t), 1) <
0) {
- char errbuf[1024];
- WARNING("load: perfstat_cpu : %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
- return (-1);
+ WARNING("load: perfstat_cpu : %s", STRERRNO);
+ return -1;
}
snum = (float)cputotal.loadavg[0] / (float)(1 << SBITS);
}
snum = (float)cputotal.loadavg[0] / (float)(1 << SBITS);
@@
-195,7
+184,7
@@
static int load_read(void) {
#error "No applicable input method."
#endif
#error "No applicable input method."
#endif
- return
(0)
;
+ return
0
;
}
void module_register(void) {
}
void module_register(void) {