]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
Change from ips_packets to packets using type_instance
authorMarco van Tol <marco@tols.org>
Fri, 21 Jun 2019 19:30:08 +0000 (21:30 +0200)
committerMarco van Tol <marco@tols.org>
Fri, 21 Jun 2019 19:30:08 +0000 (21:30 +0200)
src/ipstats.c
src/types.db

index 1fd27dda0e6d790ad110eb6e0d1235af6db02f2d..e364935d58564c22b3d9c83dbc1b61b198c9abb4 100644 (file)
 #include <netinet6/ip6_var.h>
 #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;
index 6dd53b81f12ddf01ed0649b7013074f18bc945cf..69f59b06595fab9d40ec5a4abe80d4bb21e2306a 100644 (file)
@@ -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