Use Pillar to chose which interfaces to monitor.
The `linux_netlink.ls` function used a regex to choose which interfaces
to collect metric for.
`_alphanum_re = re.compile(r'^[a-z0-9]+$')`
Unfortunately, by default this excludes vlan and tap interfaces, which
are kind of important. ie `bond0.120` or `tap2a3dab86-fb`.
We also have a problem where even if we update the regex to include
these interfaces... if someone deletes and spawns a new instance then
the tap device name changes on the compute host, which will not be
monitored unless someone re-runs the `collectd` on the compute again.
Less than ideal.
This commit lets us choose `VerboseInterface "all"` using Pillar data
to avoid this problem.
diff --git a/_modules/linux_netlink.py b/_modules/linux_netlink.py
deleted file mode 100644
index 9e6df55..0000000
--- a/_modules/linux_netlink.py
+++ /dev/null
@@ -1,17 +0,0 @@
-# -*- coding: utf-8 -*-
-
-import re
-
-_alphanum_re = re.compile(r'^[a-z0-9]+$')
-_lo_re = re.compile(r'^lo$')
-
-
-def _filter(interface):
- return _alphanum_re.match(interface) and not _lo_re.match(interface)
-
-
-def ls():
- """
- Provide a list of network interfaces.
- """
- return filter(_filter, __salt__['grains.get']('ip_interfaces', {}).keys())
diff --git a/linux/map.jinja b/linux/map.jinja
index 5e865fb..0a6db54 100644
--- a/linux/map.jinja
+++ b/linux/map.jinja
@@ -190,24 +190,28 @@
{% set monitoring = salt['grains.filter_by']({
'default': {
'zombie': {
- 'warn': 3,
- 'crit': 7,
+ 'warn': 3,
+ 'crit': 7,
},
'procs': {
- 'warn': 5000,
- 'crit': 10000,
+ 'warn': 5000,
+ 'crit': 10000,
},
'load': {
- 'warn': '6,4,2',
- 'crit': '12,8,4',
+ 'warn': '6,4,2',
+ 'crit': '12,8,4',
},
'swap': {
- 'warn': '50%',
- 'crit': '20%',
+ 'warn': '50%',
+ 'crit': '20%',
},
'disk': {
- 'warn': '15%',
- 'crit': '5%',
+ 'warn': '15%',
+ 'crit': '5%',
+ },
+ 'netlink': {
+ 'interfaces': ['all'],
+ 'ignore_selected': False,
},
},
}, grain='os_family', merge=salt['pillar.get']('linux:monitoring')) %}
diff --git a/linux/meta/collectd.yml b/linux/meta/collectd.yml
index 0bd2b55..41831b3 100644
--- a/linux/meta/collectd.yml
+++ b/linux/meta/collectd.yml
@@ -1,11 +1,11 @@
+{%- from "linux/map.jinja" import monitoring with context %}
local_plugin:
linux_network_netlink:
plugin: netlink
template: linux/files/collectd_netlink.conf
- ignore_selected: false
- {%- if 'linux_netlink.ls' in salt.keys() %}
+ ignore_selected: {{ monitoring.netlink.ignore_selected }}
interfaces:
- {%- for interface_name in salt['linux_netlink.ls']() %}
+ {%- for interface_name in monitoring.netlink.interfaces|sort %}
- {{ interface_name }}
{%- endfor %}
{%- endif %}