From d0e994f52025a333481ec5d7ac4333362c1ed559 Mon Sep 17 00:00:00 2001 From: Guillaume Thouvenin Date: Wed, 17 Aug 2016 14:45:38 +0200 Subject: [PATCH] Use netlink plugin instead of interface This patch replaces the 'interface' collectd plugin by the 'netlink' one. The 'netlink' plugin can get the same information than 'interface' but it can also give other details like the number of dropped packets. This new metrics will be used to generate alarms based on the number of packets dropped by an interface. Change-Id: I4e74e1e6c981a924946306192c296baef0404f95 --- .../modules/lma_collector/.fixtures.yml | 2 +- .../files/plugins/decoders/collectd.lua | 20 ++++++++++++-- .../lma_collector/manifests/collectd/base.pp | 15 +++++++++-- .../modules/lma_collector/metadata.json | 2 +- .../lma_collector_collectd_base_spec.rb | 4 +-- doc/user/source/metrics/system.rst | 27 +++++++++++++++++++ 6 files changed, 62 insertions(+), 8 deletions(-) diff --git a/deployment_scripts/puppet/modules/lma_collector/.fixtures.yml b/deployment_scripts/puppet/modules/lma_collector/.fixtures.yml index 3ff3a6326..7fa6b2625 100644 --- a/deployment_scripts/puppet/modules/lma_collector/.fixtures.yml +++ b/deployment_scripts/puppet/modules/lma_collector/.fixtures.yml @@ -8,7 +8,7 @@ fixtures: ref: "1.2.4" collectd: repo: "git://github.com/puppet-community/puppet-collectd" - ref: "v4.1.2" + ref: "v4.3.0" apache: repo: "git://github.com/puppetlabs/puppetlabs-apache" ref: "1.4.0" diff --git a/deployment_scripts/puppet/modules/lma_collector/files/plugins/decoders/collectd.lua b/deployment_scripts/puppet/modules/lma_collector/files/plugins/decoders/collectd.lua index b95894b82..338aa8117 100644 --- a/deployment_scripts/puppet/modules/lma_collector/files/plugins/decoders/collectd.lua +++ b/deployment_scripts/puppet/modules/lma_collector/files/plugins/decoders/collectd.lua @@ -114,8 +114,24 @@ function process_message () msg['Fields']['name'] = 'cpu' .. sep .. sample['type_instance'] msg['Fields']['cpu_number'] = sample['plugin_instance'] msg['Fields']['tag_fields'] = { 'cpu_number' } - elseif metric_source == 'interface' then - msg['Fields']['name'] = sample['type'] .. sep .. sample['dsnames'][i] + elseif metric_source == 'netlink' then + local netlink_metric = sample['type'] + + if netlink_metric == 'if_rx_errors' then + netlink_metric = 'if_errors_rx' + elseif netlink_metric == 'if_tx_errors' then + netlink_metric = 'if_errors_tx' + end + + -- Netlink plugin can send one or two values. Use dsnames only when needed. + if sample['dsnames'][i] ~= 'value' then + netlink_metric = netlink_metric .. sep .. sample['dsnames'][i] + end + -- and type of errors is set in type_instance + if sample['type_instance'] ~= '' then + netlink_metric = netlink_metric .. sep .. sample['type_instance'] + end + msg['Fields']['name'] = netlink_metric msg['Fields']['interface'] = sample['plugin_instance'] msg['Fields']['tag_fields'] = { 'interface' } elseif metric_source == 'processes' then diff --git a/deployment_scripts/puppet/modules/lma_collector/manifests/collectd/base.pp b/deployment_scripts/puppet/modules/lma_collector/manifests/collectd/base.pp index 42749e2b9..ed9156b37 100644 --- a/deployment_scripts/puppet/modules/lma_collector/manifests/collectd/base.pp +++ b/deployment_scripts/puppet/modules/lma_collector/manifests/collectd/base.pp @@ -34,6 +34,17 @@ class lma_collector::collectd::base ( before => Class['::collectd'], } + # Netlink library is required by the netlink collectd plugin + if $::osfamily == 'RedHat' { + $netlink_pkg_name = 'libmnl' + } else { + $netlink_pkg_name = 'libmnl0' + } + package { $netlink_pkg_name: + ensure => present, + before => Class['::collectd'], + } + $port = $lma_collector::params::collectd_port class { '::collectd': purge => $purge, @@ -86,8 +97,8 @@ class lma_collector::collectd::base ( disks => [ "/^${ block_devices }$/" ], } - class { 'collectd::plugin::interface': - interfaces => reject(grep(split($::interfaces, ','), '^[a-z0-9]+$'), '^lo$') + class { 'collectd::plugin::netlink': + verboseinterfaces => reject(grep(split($::interfaces, ','), '^[a-z0-9]+$'), '^lo$'), } class { 'collectd::plugin::load': diff --git a/deployment_scripts/puppet/modules/lma_collector/metadata.json b/deployment_scripts/puppet/modules/lma_collector/metadata.json index 7ea53be70..490126124 100644 --- a/deployment_scripts/puppet/modules/lma_collector/metadata.json +++ b/deployment_scripts/puppet/modules/lma_collector/metadata.json @@ -20,7 +20,7 @@ "description": "Puppet module for configuring the LMA collector service", "dependencies": [ {"name": "mirantis/heka", "version_requirement": "1.x"}, - {"name": "puppet/collectd", "version_requirement": ">= 4.1.2"}, + {"name": "puppet/collectd", "version_requirement": ">= 4.3.0"}, {"name": "puppetlabs/apache", "version_requirement": ">= 1.4.0"}, {"name": "puppetlabs/inifile", "version_requirement": ">= 1.4.2"}, {"name": "puppetlabs/stdlib", "version_requirement": "4.x"} diff --git a/deployment_scripts/puppet/modules/lma_collector/spec/classes/lma_collector_collectd_base_spec.rb b/deployment_scripts/puppet/modules/lma_collector/spec/classes/lma_collector_collectd_base_spec.rb index b6fdc6fa9..69cba8b04 100644 --- a/deployment_scripts/puppet/modules/lma_collector/spec/classes/lma_collector_collectd_base_spec.rb +++ b/deployment_scripts/puppet/modules/lma_collector/spec/classes/lma_collector_collectd_base_spec.rb @@ -23,7 +23,7 @@ describe 'lma_collector::collectd::base' do it { is_expected.to contain_class('collectd') } end - describe 'with defaults' do + describe 'with interfaces' do let(:facts) do {:kernel => 'Linux', :operatingsystem => 'Ubuntu', :osfamily => 'Debian', :concat_basedir => '/foo', @@ -31,6 +31,6 @@ describe 'lma_collector::collectd::base' do end it { is_expected.to contain_class('collectd').with_purge(false) } - it { is_expected.to contain_class('collectd::plugin::interface').with_interfaces(['en0', 'bond0']) } + it { is_expected.to contain_class('collectd::plugin::netlink').with_verboseinterfaces(['en0', 'bond0']) } end end diff --git a/doc/user/source/metrics/system.rst b/doc/user/source/metrics/system.rst index 5ffe78c6f..40fb39c55 100644 --- a/doc/user/source/metrics/system.rst +++ b/doc/user/source/metrics/system.rst @@ -77,10 +77,37 @@ Network Metrics have an ``interface`` field that contains the interface name the metric applies to. For example, 'eth0', 'eth1', and others. +* ``if_collisions``, the number of collisions per second per interface. +* ``if_dropped_rx``, the number of dropped packets per second when receiving + from the interface. +* ``if_dropped_tx``, the number of dropped packets per second when transmitting + from the interface. * ``if_errors_rx``, the number of errors per second detected when receiving from the interface. +* ``if_errors_rx_crc``, the number of received frames with wrong CRC (cyclic + redundancy check) per second. +* ``if_errors_rx_fifo``, the number of received frames dropped per second due to + FIFO buffer overflows. +* ``if_errors_rx_frame``, the number of received frames with invalid frame + checksum (FCS). +* ``if_errors_rx_length``, the number of received frames with a length that + doesn't comply with the Ethernet specification. +* ``if_errors_rx_missed``, the number of missed packets when receiving from the + interface. +* ``if_errors_rx_over``, the number of received frames per second that were + dropped due to an hardware port receive buffer overflow. * ``if_errors_tx``, the number of errors per second detected when transmitting from the interface. +* ``if_errors_tx_aborted``, the number of aborted frames per second when + transmitting from the interface +* ``if_errors_tx_carrier``, the number of times per second the interface has + lost its link connection to the switch. +* ``if_errors_tx_fifo``, the number of transmitted frames per second dropped + due to FIFO buffer overflows. +* ``if_errors_tx_heartbeat``, the number of heartbeat errors per second. +* ``if_errors_tx_window``, the number of late collisions per second when + transmitting from the interface. +* ``if_multicast``, the number of multicast packets per second per interface. * ``if_octets_rx``, the number of octets (bytes) received per second by the interface. * ``if_octets_tx``, the number of octets (bytes) transmitted per second by the