projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
configure.ac: keep the list of plugins sorted
[collectd.git]
/
src
/
ethstat.c
diff --git
a/src/ethstat.c
b/src/ethstat.c
index
bd55252
..
f8bc5b5
100644
(file)
--- a/
src/ethstat.c
+++ b/
src/ethstat.c
@@
-24,9
+24,9
@@
#include "collectd.h"
#include "collectd.h"
-#include "common.h"
#include "plugin.h"
#include "plugin.h"
-#include "utils_avltree.h"
+#include "utils/avltree/avltree.h"
+#include "utils/common/common.h"
#include "utils_complain.h"
#if HAVE_SYS_IOCTL_H
#include "utils_complain.h"
#if HAVE_SYS_IOCTL_H
@@
-48,12
+48,12
@@
struct value_map_s {
};
typedef struct value_map_s value_map_t;
};
typedef struct value_map_s value_map_t;
-static char **interfaces
= NULL
;
-static size_t interfaces_num
= 0
;
+static char **interfaces;
+static size_t interfaces_num;
-static c_avl_tree_t *value_map
= NULL
;
+static c_avl_tree_t *value_map;
-static
_Bool collect_mapped_only = 0
;
+static
bool collect_mapped_only
;
static int ethstat_add_interface(const oconfig_item_t *ci) /* {{{ */
{
static int ethstat_add_interface(const oconfig_item_t *ci) /* {{{ */
{
@@
-62,19
+62,19
@@
static int ethstat_add_interface(const oconfig_item_t *ci) /* {{{ */
tmp = realloc(interfaces, sizeof(*interfaces) * (interfaces_num + 1));
if (tmp == NULL)
tmp = realloc(interfaces, sizeof(*interfaces) * (interfaces_num + 1));
if (tmp == NULL)
- return
(-1)
;
+ return
-1
;
interfaces = tmp;
interfaces[interfaces_num] = NULL;
status = cf_util_get_string(ci, interfaces + interfaces_num);
if (status != 0)
interfaces = tmp;
interfaces[interfaces_num] = NULL;
status = cf_util_get_string(ci, interfaces + interfaces_num);
if (status != 0)
- return
(status)
;
+ return
status
;
interfaces_num++;
INFO("ethstat plugin: Registered interface %s",
interfaces[interfaces_num - 1]);
interfaces_num++;
INFO("ethstat plugin: Registered interface %s",
interfaces[interfaces_num - 1]);
- return
(0)
;
+ return
0
;
} /* }}} int ethstat_add_interface */
static int ethstat_add_map(const oconfig_item_t *ci) /* {{{ */
} /* }}} int ethstat_add_interface */
static int ethstat_add_map(const oconfig_item_t *ci) /* {{{ */
@@
-90,20
+90,20
@@
static int ethstat_add_map(const oconfig_item_t *ci) /* {{{ */
ERROR("ethstat plugin: The %s option requires "
"two or three string arguments.",
ci->key);
ERROR("ethstat plugin: The %s option requires "
"two or three string arguments.",
ci->key);
- return
(-1)
;
+ return
-1
;
}
key = strdup(ci->values[0].value.string);
if (key == NULL) {
ERROR("ethstat plugin: strdup(3) failed.");
}
key = strdup(ci->values[0].value.string);
if (key == NULL) {
ERROR("ethstat plugin: strdup(3) failed.");
- return
(ENOMEM)
;
+ return
ENOMEM
;
}
map = calloc(1, sizeof(*map));
if (map == NULL) {
sfree(key);
ERROR("ethstat plugin: calloc failed.");
}
map = calloc(1, sizeof(*map));
if (map == NULL) {
sfree(key);
ERROR("ethstat plugin: calloc failed.");
- return
(ENOMEM)
;
+ return
ENOMEM
;
}
sstrncpy(map->type, ci->values[1].value.string, sizeof(map->type));
}
sstrncpy(map->type, ci->values[1].value.string, sizeof(map->type));
@@
-117,7
+117,7
@@
static int ethstat_add_map(const oconfig_item_t *ci) /* {{{ */
sfree(map);
sfree(key);
ERROR("ethstat plugin: c_avl_create() failed.");
sfree(map);
sfree(key);
ERROR("ethstat plugin: c_avl_create() failed.");
- return
(-1)
;
+ return
-1
;
}
}
}
}
@@
-132,10
+132,10
@@
static int ethstat_add_map(const oconfig_item_t *ci) /* {{{ */
sfree(map);
sfree(key);
sfree(map);
sfree(key);
- return
(-1)
;
+ return
-1
;
}
}
- return
(0)
;
+ return
0
;
} /* }}} int ethstat_add_map */
static int ethstat_config(oconfig_item_t *ci) /* {{{ */
} /* }}} int ethstat_add_map */
static int ethstat_config(oconfig_item_t *ci) /* {{{ */
@@
-154,7
+154,7
@@
static int ethstat_config(oconfig_item_t *ci) /* {{{ */
child->key);
}
child->key);
}
- return
(0)
;
+ return
0
;
} /* }}} */
static void ethstat_submit_value(const char *device, const char *type_instance,
} /* }}} */
static void ethstat_submit_value(const char *device, const char *type_instance,
@@
-204,9
+204,7
@@
static int ethstat_read_interface(char *device) {
fd = socket(AF_INET, SOCK_DGRAM, /* protocol = */ 0);
if (fd < 0) {
fd = socket(AF_INET, SOCK_DGRAM, /* protocol = */ 0);
if (fd < 0) {
- char errbuf[1024];
- ERROR("ethstat plugin: Failed to open control socket: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("ethstat plugin: Failed to open control socket: %s", STRERRNO);
return 1;
}
return 1;
}
@@
-218,19
+216,18
@@
static int ethstat_read_interface(char *device) {
status = ioctl(fd, SIOCETHTOOL, &req);
if (status < 0) {
status = ioctl(fd, SIOCETHTOOL, &req);
if (status < 0) {
- char errbuf[1024];
close(fd);
ERROR("ethstat plugin: Failed to get driver information "
"from %s: %s",
close(fd);
ERROR("ethstat plugin: Failed to get driver information "
"from %s: %s",
- device,
sstrerror(errno, errbuf, sizeof(errbuf))
);
- return
(-1)
;
+ device,
STRERRNO
);
+ return
-1
;
}
n_stats = (size_t)drvinfo.n_stats;
if (n_stats < 1) {
close(fd);
ERROR("ethstat plugin: No stats available for %s", device);
}
n_stats = (size_t)drvinfo.n_stats;
if (n_stats < 1) {
close(fd);
ERROR("ethstat plugin: No stats available for %s", device);
- return
(-1)
;
+ return
-1
;
}
strings_size = sizeof(struct ethtool_gstrings) + (n_stats * ETH_GSTRING_LEN);
}
strings_size = sizeof(struct ethtool_gstrings) + (n_stats * ETH_GSTRING_LEN);
@@
-243,7
+240,7
@@
static int ethstat_read_interface(char *device) {
sfree(strings);
sfree(stats);
ERROR("ethstat plugin: malloc failed.");
sfree(strings);
sfree(stats);
ERROR("ethstat plugin: malloc failed.");
- return
(-1)
;
+ return
-1
;
}
strings->cmd = ETHTOOL_GSTRINGS;
}
strings->cmd = ETHTOOL_GSTRINGS;
@@
-252,13
+249,11
@@
static int ethstat_read_interface(char *device) {
req.ifr_data = (void *)strings;
status = ioctl(fd, SIOCETHTOOL, &req);
if (status < 0) {
req.ifr_data = (void *)strings;
status = ioctl(fd, SIOCETHTOOL, &req);
if (status < 0) {
- char errbuf[1024];
close(fd);
free(strings);
free(stats);
close(fd);
free(strings);
free(stats);
- ERROR("ethstat plugin: Cannot get strings from %s: %s", device,
- sstrerror(errno, errbuf, sizeof(errbuf)));
- return (-1);
+ ERROR("ethstat plugin: Cannot get strings from %s: %s", device, STRERRNO);
+ return -1;
}
stats->cmd = ETHTOOL_GSTATS;
}
stats->cmd = ETHTOOL_GSTATS;
@@
-266,13
+261,12
@@
static int ethstat_read_interface(char *device) {
req.ifr_data = (void *)stats;
status = ioctl(fd, SIOCETHTOOL, &req);
if (status < 0) {
req.ifr_data = (void *)stats;
status = ioctl(fd, SIOCETHTOOL, &req);
if (status < 0) {
- char errbuf[1024];
close(fd);
free(strings);
free(stats);
ERROR("ethstat plugin: Reading statistics from %s failed: %s", device,
close(fd);
free(strings);
free(stats);
ERROR("ethstat plugin: Reading statistics from %s failed: %s", device,
-
sstrerror(errno, errbuf, sizeof(errbuf))
);
- return
(-1)
;
+
STRERRNO
);
+ return
-1
;
}
for (size_t i = 0; i < n_stats; i++) {
}
for (size_t i = 0; i < n_stats; i++) {
@@
-292,7
+286,7
@@
static int ethstat_read_interface(char *device) {
sfree(strings);
sfree(stats);
sfree(strings);
sfree(stats);
- return
(0)
;
+ return
0
;
} /* }}} ethstat_read_interface */
static int ethstat_read(void) {
} /* }}} ethstat_read_interface */
static int ethstat_read(void) {
@@
-307,7
+301,7
@@
static int ethstat_shutdown(void) {
void *value = NULL;
if (value_map == NULL)
void *value = NULL;
if (value_map == NULL)
- return
(0)
;
+ return
0
;
while (c_avl_pick(value_map, &key, &value) == 0) {
sfree(key);
while (c_avl_pick(value_map, &key, &value) == 0) {
sfree(key);
@@
-317,7
+311,7
@@
static int ethstat_shutdown(void) {
c_avl_destroy(value_map);
value_map = NULL;
c_avl_destroy(value_map);
value_map = NULL;
- return
(0)
;
+ return
0
;
}
void module_register(void) {
}
void module_register(void) {
@@
-325,5
+319,3
@@
void module_register(void) {
plugin_register_read("ethstat", ethstat_read);
plugin_register_shutdown("ethstat", ethstat_shutdown);
}
plugin_register_read("ethstat", ethstat_read);
plugin_register_shutdown("ethstat", ethstat_shutdown);
}
-
-/* vim: set sw=2 sts=2 et fdm=marker : */