Merge branch 'pull/master'
[collectd.git] / src / netlink.c
index eefc674..1a053d2 100644 (file)
@@ -223,8 +223,8 @@ static int link_filter (const struct sockaddr_nl *sa, struct nlmsghdr *nmh,
   if (check_ignorelist (dev, "interface", NULL) == 0)
   {
     submit_two (dev, "if_octets", NULL, stats->rx_bytes, stats->tx_bytes);
-    submit_two (dev, "if_packets", NULL, stats->rx_bytes, stats->tx_bytes);
-    submit_two (dev, "if_errors", NULL, stats->rx_bytes, stats->tx_bytes);
+    submit_two (dev, "if_packets", NULL, stats->rx_packets, stats->tx_packets);
+    submit_two (dev, "if_errors", NULL, stats->rx_errors, stats->tx_errors);
   }
   else
   {
@@ -233,10 +233,22 @@ static int link_filter (const struct sockaddr_nl *sa, struct nlmsghdr *nmh,
 
   if (check_ignorelist (dev, "if_detail", NULL) == 0)
   {
-    submit_two (dev, "if_dropped", NULL, stats->rx_bytes, stats->tx_bytes);
+    submit_two (dev, "if_dropped", NULL, stats->rx_dropped, stats->tx_dropped);
     submit_one (dev, "if_multicast", NULL, stats->multicast);
     submit_one (dev, "if_collisions", NULL, stats->collisions);
-    /* FIXME: Add the rest */
+
+    submit_one (dev, "if_rx_errors", "length", stats->rx_length_errors);
+    submit_one (dev, "if_rx_errors", "over", stats->rx_over_errors);
+    submit_one (dev, "if_rx_errors", "crc", stats->rx_crc_errors);
+    submit_one (dev, "if_rx_errors", "frame", stats->rx_frame_errors);
+    submit_one (dev, "if_rx_errors", "fifo", stats->rx_fifo_errors);
+    submit_one (dev, "if_rx_errors", "missed", stats->rx_missed_errors);
+
+    submit_one (dev, "if_tx_errors", "aborted", stats->tx_aborted_errors);
+    submit_one (dev, "if_tx_errors", "carrier", stats->tx_carrier_errors);
+    submit_one (dev, "if_tx_errors", "fifo", stats->tx_fifo_errors);
+    submit_one (dev, "if_tx_errors", "heartbeat", stats->tx_heartbeat_errors);
+    submit_one (dev, "if_tx_errors", "window", stats->tx_window_errors);
   }
   else
   {
@@ -259,8 +271,6 @@ static int qos_filter (const struct sockaddr_nl *sa, struct nlmsghdr *nmh,
   char *tc_type;
   char tc_inst[DATA_MAX_NAME_LEN];
 
-  printf ("=== qos_filter ===\n");
-
   if (nmh->nlmsg_type == RTM_NEWQDISC)
     tc_type = "qdisc";
   else if (nmh->nlmsg_type == RTM_NEWTCLASS)
@@ -303,9 +313,20 @@ static int qos_filter (const struct sockaddr_nl *sa, struct nlmsghdr *nmh,
     ERROR ("netlink plugin: qos_filter: attrs[TCA_KIND] == NULL\n");
     return (-1);
   }
-  snprintf (tc_inst, sizeof (tc_inst), "%s-%x",
-      (const char *) RTA_DATA (attrs[TCA_KIND]), (msg->tcm_handle >> 16));
-  tc_inst[sizeof (tc_inst) - 1] = '\0';
+
+  { /* The the ID */
+    uint32_t numberic_id;
+
+    numberic_id = msg->tcm_handle;
+    if (strcmp (tc_type, "filter") == 0)
+      numberic_id = msg->tcm_parent;
+
+    snprintf (tc_inst, sizeof (tc_inst), "%s-%x:%x",
+       (const char *) RTA_DATA (attrs[TCA_KIND]),
+       numberic_id >> 16,
+       numberic_id & 0x0000FFFF);
+    tc_inst[sizeof (tc_inst) - 1] = '\0';
+  }
   
   if (check_ignorelist (dev, tc_type, tc_inst))
     return (0);
@@ -330,7 +351,7 @@ static int qos_filter (const struct sockaddr_nl *sa, struct nlmsghdr *nmh,
       memcpy (&bs, RTA_DATA (attrs_stats[TCA_STATS_BASIC]),
          MIN (RTA_PAYLOAD (attrs_stats[TCA_STATS_BASIC]), sizeof(bs)));
 
-      submit_one (dev, "ipt_octets", type_instance, bs.bytes);
+      submit_one (dev, "ipt_bytes", type_instance, bs.bytes);
       submit_one (dev, "ipt_packets", type_instance, bs.packets);
     }
   }