Merge branch 'master' into add_ovs_stats_bonds_3
authorAndrew Bays <andrew.bays@gmail.com>
Mon, 19 Nov 2018 13:50:59 +0000 (08:50 -0500)
committerGitHub <noreply@github.com>
Mon, 19 Nov 2018 13:50:59 +0000 (08:50 -0500)
1  2 
src/collectd.conf.pod
src/ovs_stats.c

Simple merge
diff --cc src/ovs_stats.c
@@@ -229,198 -223,6 +233,198 @@@ static void ovs_stats_submit_two(const 
    plugin_dispatch_values(&vl);
  }
  
-     ovs_stats_submit_two(devname, "if_packets", "1024_to_1518_packets",
 +static void ovs_stats_submit_interfaces(bridge_list_t *bridge,
 +                                        port_list_t *port) {
 +  char devname[PORT_NAME_SIZE_MAX * 2];
 +
 +  for (interface_list_t *iface = port->iface; iface != NULL;
 +       iface = iface->next) {
 +    meta_data_t *meta = meta_data_create();
 +    if (meta != NULL) {
 +      meta_data_add_string(meta, "uuid", iface->iface_uuid);
 +
 +      if (strlen(iface->ex_vm_id))
 +        meta_data_add_string(meta, "vm-uuid", iface->ex_vm_id);
 +
 +      if (strlen(iface->ex_iface_id))
 +        meta_data_add_string(meta, "iface-id", iface->ex_iface_id);
 +    }
 +    snprintf(devname, sizeof(devname), "%s.%s.%s", bridge->name, port->name,
 +             iface->name);
 +    ovs_stats_submit_one(devname, "if_collisions", NULL,
 +                         iface->stats[collisions], meta);
 +    ovs_stats_submit_two(devname, "if_dropped", NULL, iface->stats[rx_dropped],
 +                         iface->stats[tx_dropped], meta);
 +    ovs_stats_submit_two(devname, "if_errors", NULL, iface->stats[rx_errors],
 +                         iface->stats[tx_errors], meta);
 +    ovs_stats_submit_two(devname, "if_packets", NULL, iface->stats[rx_packets],
 +                         iface->stats[tx_packets], meta);
 +    ovs_stats_submit_one(devname, "if_rx_errors", "crc",
 +                         iface->stats[rx_crc_err], meta);
 +    ovs_stats_submit_one(devname, "if_rx_errors", "frame",
 +                         iface->stats[rx_frame_err], meta);
 +    ovs_stats_submit_one(devname, "if_rx_errors", "over",
 +                         iface->stats[rx_over_err], meta);
 +    ovs_stats_submit_one(devname, "if_rx_octets", NULL, iface->stats[rx_bytes],
 +                         meta);
 +    ovs_stats_submit_one(devname, "if_tx_octets", NULL, iface->stats[tx_bytes],
 +                         meta);
 +    ovs_stats_submit_two(devname, "if_packets", "1_to_64_packets",
 +                         iface->stats[rx_1_to_64_packets],
 +                         iface->stats[tx_1_to_64_packets], meta);
 +    ovs_stats_submit_two(devname, "if_packets", "65_to_127_packets",
 +                         iface->stats[rx_65_to_127_packets],
 +                         iface->stats[tx_65_to_127_packets], meta);
 +    ovs_stats_submit_two(devname, "if_packets", "128_to_255_packets",
 +                         iface->stats[rx_128_to_255_packets],
 +                         iface->stats[tx_128_to_255_packets], meta);
 +    ovs_stats_submit_two(devname, "if_packets", "256_to_511_packets",
 +                         iface->stats[rx_256_to_511_packets],
 +                         iface->stats[tx_256_to_511_packets], meta);
 +    ovs_stats_submit_two(devname, "if_packets", "512_to_1023_packets",
 +                         iface->stats[rx_512_to_1023_packets],
 +                         iface->stats[tx_512_to_1023_packets], meta);
-       devname, "if_packets", "1024_to_1518_packets",
++    ovs_stats_submit_two(devname, "if_packets", "1024_to_1522_packets",
 +                         iface->stats[rx_1024_to_1522_packets],
 +                         iface->stats[tx_1024_to_1522_packets], meta);
 +    ovs_stats_submit_two(devname, "if_packets", "1523_to_max_packets",
 +                         iface->stats[rx_1523_to_max_packets],
 +                         iface->stats[tx_1523_to_max_packets], meta);
 +    ovs_stats_submit_two(devname, "if_packets", "broadcast_packets",
 +                         iface->stats[rx_broadcast_packets],
 +                         iface->stats[tx_broadcast_packets], meta);
 +    ovs_stats_submit_one(devname, "if_multicast", "tx_multicast_packets",
 +                         iface->stats[tx_multicast_packets], meta);
 +    ovs_stats_submit_one(devname, "if_rx_errors", "rx_undersized_errors",
 +                         iface->stats[rx_undersized_errors], meta);
 +    ovs_stats_submit_one(devname, "if_rx_errors", "rx_oversize_errors",
 +                         iface->stats[rx_oversize_errors], meta);
 +    ovs_stats_submit_one(devname, "if_rx_errors", "rx_fragmented_errors",
 +                         iface->stats[rx_fragmented_errors], meta);
 +    ovs_stats_submit_one(devname, "if_rx_errors", "rx_jabber_errors",
 +                         iface->stats[rx_jabber_errors], meta);
 +
 +    meta_data_destroy(meta);
 +  }
 +}
 +
 +static int ovs_stats_get_port_stat_value(port_list_t *port,
 +                                         iface_counter index) {
 +  if (port == NULL)
 +    return 0;
 +
 +  int value = 0;
 +
 +  for (interface_list_t *iface = port->iface; iface != NULL;
 +       iface = iface->next) {
 +    value = value + iface->stats[index];
 +  }
 +
 +  return value;
 +}
 +
 +static void ovs_stats_submit_port(bridge_list_t *bridge, port_list_t *port) {
 +  char devname[PORT_NAME_SIZE_MAX * 2];
 +
 +  meta_data_t *meta = meta_data_create();
 +  if (meta != NULL) {
 +    char key_str[DATA_MAX_NAME_LEN];
 +    int i = 0;
 +
 +    for (interface_list_t *iface = port->iface; iface != NULL;
 +         iface = iface->next) {
 +      memset(key_str, '\0', DATA_MAX_NAME_LEN);
 +      snprintf(key_str, 6, "uuid%d", i);
 +      meta_data_add_string(meta, key_str, iface->iface_uuid);
 +
 +      if (strlen(iface->ex_vm_id)) {
 +        memset(key_str, '\0', DATA_MAX_NAME_LEN);
 +        snprintf(key_str, 9, "vm-uuid%d", i);
 +        meta_data_add_string(meta, key_str, iface->ex_vm_id);
 +      }
 +
 +      if (strlen(iface->ex_iface_id)) {
 +        memset(key_str, '\0', DATA_MAX_NAME_LEN);
 +        snprintf(key_str, 10, "iface-id%d", i);
 +        meta_data_add_string(meta, key_str, iface->ex_iface_id);
 +      }
 +
 +      i++;
 +    }
 +  }
 +  snprintf(devname, sizeof(devname), "%s.%s", bridge->name, port->name);
 +  ovs_stats_submit_one(devname, "if_collisions", NULL,
 +                       ovs_stats_get_port_stat_value(port, collisions), meta);
 +  ovs_stats_submit_two(devname, "if_dropped", NULL,
 +                       ovs_stats_get_port_stat_value(port, rx_dropped),
 +                       ovs_stats_get_port_stat_value(port, tx_dropped), meta);
 +  ovs_stats_submit_two(devname, "if_errors", NULL,
 +                       ovs_stats_get_port_stat_value(port, rx_errors),
 +                       ovs_stats_get_port_stat_value(port, tx_errors), meta);
 +  ovs_stats_submit_two(devname, "if_packets", NULL,
 +                       ovs_stats_get_port_stat_value(port, rx_packets),
 +                       ovs_stats_get_port_stat_value(port, tx_packets), meta);
 +  ovs_stats_submit_one(devname, "if_rx_errors", "crc",
 +                       ovs_stats_get_port_stat_value(port, rx_crc_err), meta);
 +  ovs_stats_submit_one(devname, "if_rx_errors", "frame",
 +                       ovs_stats_get_port_stat_value(port, rx_frame_err), meta);
 +  ovs_stats_submit_one(devname, "if_rx_errors", "over",
 +                       ovs_stats_get_port_stat_value(port, rx_over_err), meta);
 +  ovs_stats_submit_one(devname, "if_rx_octets", NULL,
 +                       ovs_stats_get_port_stat_value(port, rx_bytes), meta);
 +  ovs_stats_submit_one(devname, "if_tx_octets", NULL,
 +                       ovs_stats_get_port_stat_value(port, tx_bytes), meta);
 +  ovs_stats_submit_two(devname, "if_packets", "1_to_64_packets",
 +                       ovs_stats_get_port_stat_value(port, rx_1_to_64_packets),
 +                       ovs_stats_get_port_stat_value(port, tx_1_to_64_packets),
 +                       meta);
 +  ovs_stats_submit_two(
 +      devname, "if_packets", "65_to_127_packets",
 +      ovs_stats_get_port_stat_value(port, rx_65_to_127_packets),
 +      ovs_stats_get_port_stat_value(port, tx_65_to_127_packets), meta);
 +  ovs_stats_submit_two(
 +      devname, "if_packets", "128_to_255_packets",
 +      ovs_stats_get_port_stat_value(port, rx_128_to_255_packets),
 +      ovs_stats_get_port_stat_value(port, tx_128_to_255_packets), meta);
 +  ovs_stats_submit_two(
 +      devname, "if_packets", "256_to_511_packets",
 +      ovs_stats_get_port_stat_value(port, rx_256_to_511_packets),
 +      ovs_stats_get_port_stat_value(port, tx_256_to_511_packets), meta);
 +  ovs_stats_submit_two(
 +      devname, "if_packets", "512_to_1023_packets",
 +      ovs_stats_get_port_stat_value(port, rx_512_to_1023_packets),
 +      ovs_stats_get_port_stat_value(port, tx_512_to_1023_packets), meta);
 +  ovs_stats_submit_two(
++      devname, "if_packets", "1024_to_1522_packets",
 +      ovs_stats_get_port_stat_value(port, rx_1024_to_1522_packets),
 +      ovs_stats_get_port_stat_value(port, tx_1024_to_1522_packets), meta);
 +  ovs_stats_submit_two(
 +      devname, "if_packets", "1523_to_max_packets",
 +      ovs_stats_get_port_stat_value(port, rx_1523_to_max_packets),
 +      ovs_stats_get_port_stat_value(port, tx_1523_to_max_packets), meta);
 +  ovs_stats_submit_two(
 +      devname, "if_packets", "broadcast_packets",
 +      ovs_stats_get_port_stat_value(port, rx_broadcast_packets),
 +      ovs_stats_get_port_stat_value(port, tx_broadcast_packets), meta);
 +  ovs_stats_submit_one(
 +      devname, "if_multicast", "tx_multicast_packets",
 +      ovs_stats_get_port_stat_value(port, tx_multicast_packets), meta);
 +  ovs_stats_submit_one(
 +      devname, "if_rx_errors", "rx_undersized_errors",
 +      ovs_stats_get_port_stat_value(port, rx_undersized_errors), meta);
 +  ovs_stats_submit_one(devname, "if_rx_errors", "rx_oversize_errors",
 +                       ovs_stats_get_port_stat_value(port, rx_oversize_errors),
 +                       meta);
 +  ovs_stats_submit_one(
 +      devname, "if_rx_errors", "rx_fragmented_errors",
 +      ovs_stats_get_port_stat_value(port, rx_fragmented_errors), meta);
 +  ovs_stats_submit_one(devname, "if_rx_errors", "rx_jabber_errors",
 +                       ovs_stats_get_port_stat_value(port, rx_jabber_errors),
 +                       meta);
 +
 +  meta_data_destroy(meta);
 +}
 +
  static port_list_t *ovs_stats_get_port(const char *uuid) {
    if (uuid == NULL)
      return NULL;
@@@ -1296,11 -923,72 +1300,11 @@@ static int ovs_stats_plugin_read(__attr
               * is called after Interface Table update callback but before
               * Port table Update callback. Will add this port on next read */
              continue;
 -          meta_data_t *meta = meta_data_create();
 -          if (meta != NULL) {
 -            meta_data_add_string(meta, "uuid", port->iface_uuid);
 -            if (strlen(port->ex_vm_id))
 -              meta_data_add_string(meta, "vm-uuid", port->ex_vm_id);
 -            if (strlen(port->ex_iface_id))
 -              meta_data_add_string(meta, "iface-id", port->ex_iface_id);
 -          }
 -          snprintf(devname, sizeof(devname), "%s.%s", bridge->name, port->name);
 -          ovs_stats_submit_one(devname, "if_collisions", NULL,
 -                               port->stats[collisions], meta);
 -          ovs_stats_submit_two(devname, "if_dropped", NULL,
 -                               port->stats[rx_dropped], port->stats[tx_dropped],
 -                               meta);
 -          ovs_stats_submit_two(devname, "if_errors", NULL,
 -                               port->stats[rx_errors], port->stats[tx_errors],
 -                               meta);
 -          ovs_stats_submit_two(devname, "if_packets", NULL,
 -                               port->stats[rx_packets], port->stats[tx_packets],
 -                               meta);
 -          ovs_stats_submit_one(devname, "if_rx_errors", "crc",
 -                               port->stats[rx_crc_err], meta);
 -          ovs_stats_submit_one(devname, "if_rx_errors", "frame",
 -                               port->stats[rx_frame_err], meta);
 -          ovs_stats_submit_one(devname, "if_rx_errors", "over",
 -                               port->stats[rx_over_err], meta);
 -          ovs_stats_submit_one(devname, "if_rx_octets", NULL,
 -                               port->stats[rx_bytes], meta);
 -          ovs_stats_submit_one(devname, "if_tx_octets", NULL,
 -                               port->stats[tx_bytes], meta);
 -          ovs_stats_submit_two(devname, "if_packets", "1_to_64_packets",
 -                               port->stats[rx_1_to_64_packets],
 -                               port->stats[tx_1_to_64_packets], meta);
 -          ovs_stats_submit_two(devname, "if_packets", "65_to_127_packets",
 -                               port->stats[rx_65_to_127_packets],
 -                               port->stats[tx_65_to_127_packets], meta);
 -          ovs_stats_submit_two(devname, "if_packets", "128_to_255_packets",
 -                               port->stats[rx_128_to_255_packets],
 -                               port->stats[tx_128_to_255_packets], meta);
 -          ovs_stats_submit_two(devname, "if_packets", "256_to_511_packets",
 -                               port->stats[rx_256_to_511_packets],
 -                               port->stats[tx_256_to_511_packets], meta);
 -          ovs_stats_submit_two(devname, "if_packets", "512_to_1023_packets",
 -                               port->stats[rx_512_to_1023_packets],
 -                               port->stats[tx_512_to_1023_packets], meta);
 -          ovs_stats_submit_two(devname, "if_packets", "1024_to_1522_packets",
 -                               port->stats[rx_1024_to_1522_packets],
 -                               port->stats[tx_1024_to_1522_packets], meta);
 -          ovs_stats_submit_two(devname, "if_packets", "1523_to_max_packets",
 -                               port->stats[rx_1523_to_max_packets],
 -                               port->stats[tx_1523_to_max_packets], meta);
 -          ovs_stats_submit_two(devname, "if_packets", "broadcast_packets",
 -                               port->stats[rx_broadcast_packets],
 -                               port->stats[tx_broadcast_packets], meta);
 -          ovs_stats_submit_one(devname, "if_multicast", "tx_multicast_packets",
 -                               port->stats[tx_multicast_packets], meta);
 -          ovs_stats_submit_one(devname, "if_rx_errors", "rx_undersized_errors",
 -                               port->stats[rx_undersized_errors], meta);
 -          ovs_stats_submit_one(devname, "if_rx_errors", "rx_oversize_errors",
 -                               port->stats[rx_oversize_errors], meta);
 -          ovs_stats_submit_one(devname, "if_rx_errors", "rx_fragmented_errors",
 -                               port->stats[rx_fragmented_errors], meta);
 -          ovs_stats_submit_one(devname, "if_rx_errors", "rx_jabber_errors",
 -                               port->stats[rx_jabber_errors], meta);
--
 -          meta_data_destroy(meta);
++          
 +          ovs_stats_submit_port(bridge, port);
 +
 +          if (interface_stats)
 +            ovs_stats_submit_interfaces(bridge, port);
          }
      } else
        continue;