From: Marco van Tol Date: Fri, 21 Jun 2019 19:30:08 +0000 (+0200) Subject: Change from ips_packets to packets using type_instance X-Git-Tag: collectd-5.11.0~35^2~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c88782324086d78d18d7707f1deb7a2ac804d803;p=thirdparty%2Fcollectd.git Change from ips_packets to packets using type_instance --- diff --git a/src/ipstats.c b/src/ipstats.c index 1fd27dda0..e364935d5 100644 --- a/src/ipstats.c +++ b/src/ipstats.c @@ -37,18 +37,25 @@ #include #endif -static void ipstats_submit(const char *family, const char *type, derive_t rx, - derive_t tx, derive_t fwd) { +static void ipstats_submit(const char *family, derive_t rx, derive_t tx, + derive_t fwd) { value_list_t vl = VALUE_LIST_INIT; - value_t values[] = {{.derive = rx}, {.derive = tx}, {.derive = fwd}}; - - vl.values = values; - vl.values_len = STATIC_ARRAY_SIZE(values); + vl.values_len = 1; sstrncpy(vl.plugin, "ipstats", sizeof(vl.plugin)); sstrncpy(vl.plugin_instance, family, sizeof(vl.plugin_instance)); - sstrncpy(vl.type, type, sizeof(vl.type)); + sstrncpy(vl.type, "packets", sizeof(vl.type)); + + sstrncpy(vl.type_instance, "rx", sizeof(vl.type_instance)); + vl.values = &(value_t){.derive = rx}; + plugin_dispatch_values(&vl); + + sstrncpy(vl.type_instance, "tx", sizeof(vl.type_instance)); + vl.values = &(value_t){.derive = tx}; + plugin_dispatch_values(&vl); + sstrncpy(vl.type_instance, "fwd", sizeof(vl.type_instance)); + vl.values = &(value_t){.derive = fwd}; plugin_dispatch_values(&vl); } /* void ipstats_submit */ @@ -61,7 +68,7 @@ static int ipstats_read(void) { if (sysctlbyname(mib, &ipstat, &ipslen, NULL, 0) != 0) WARNING("ipstats plugin: sysctl \"%s\" failed.", mib); else - ipstats_submit("ipv4", "ips_packets", ipstat.ips_total, ipstat.ips_localout, + ipstats_submit("ipv4", ipstat.ips_total, ipstat.ips_localout, ipstat.ips_forward); struct ip6stat ip6stat; @@ -71,8 +78,8 @@ static int ipstats_read(void) { if (sysctlbyname(mib6, &ip6stat, &ip6slen, NULL, 0) != 0) WARNING("ipstats plugin: sysctl \"%s\" failed.", mib); else - ipstats_submit("ipv6", "ips_packets", ip6stat.ip6s_total, - ip6stat.ip6s_localout, ip6stat.ip6s_forward); + ipstats_submit("ipv6", ip6stat.ip6s_total, ip6stat.ip6s_localout, + ip6stat.ip6s_forward); #endif return 0; diff --git a/src/types.db b/src/types.db index 6dd53b81f..69f59b065 100644 --- a/src/types.db +++ b/src/types.db @@ -127,7 +127,6 @@ io_octets rx:DERIVE:0:U, tx:DERIVE:0:U io_ops read:DERIVE:0:U, write:DERIVE:0:U io_packets rx:DERIVE:0:U, tx:DERIVE:0:U ipc value:GAUGE:0:U -ips_packets rx:DERIVE:0:U, tx:DERIVE:0:U, fwd:DERIVE:0:U ipt_bytes value:DERIVE:0:U ipt_packets value:DERIVE:0:U irq value:DERIVE:0:U