Browse Source

Keep regex as default but still allow overrides.

pull/113/head
Jaymes Mosher 7 years ago
parent
commit
603e62ab9e
3 changed files with 26 additions and 2 deletions
  1. +16
    -0
      _modules/linux_netlink.py
  2. +3
    -1
      linux/map.jinja
  3. +7
    -1
      linux/meta/collectd.yml

+ 16
- 0
_modules/linux_netlink.py View File

# -*- coding: utf-8 -*-

import re


def ls(regex=r'^[a-z0-9]+$'):
"""
Provide a list of network interfaces.
"""
_lo_re = re.compile(r'^lo$')
_alphanum_re = re.compile(regex)

def _filter(interface):
return _alphanum_re.match(interface) and not _lo_re.match(interface)

return filter(_filter, __salt__['grains.get']('ip_interfaces', {}).keys())

+ 3
- 1
linux/map.jinja View File

'crit': '5%', 'crit': '5%',
}, },
'netlink': { 'netlink': {
'interfaces': ['all'],
'interface_override': False,
'interfaces': [],
'interface_regex': '^[a-z0-9]+$',
'ignore_selected': False, 'ignore_selected': False,
}, },
}, },

+ 7
- 1
linux/meta/collectd.yml View File

plugin: netlink plugin: netlink
template: linux/files/collectd_netlink.conf template: linux/files/collectd_netlink.conf
ignore_selected: {{ monitoring.netlink.ignore_selected }} ignore_selected: {{ monitoring.netlink.ignore_selected }}
{%- if monitoring.netlink.interface_override and monitoring.netlink.interfaces is list %}
{%- set interfaces = monitoring.netlink.interfaces %}
{%- else %}
{%- set interfaces = salt['linux_netlink.ls'](monitoring.netlink.interface_regex) %}
{%- endif %}
{%- if interfaces %}
interfaces: interfaces:
{%- for interface_name in monitoring.netlink.interfaces|sort %}
{%- for interface_name in interfaces|sort %}
- {{ interface_name }} - {{ interface_name }}
{%- endfor %} {%- endfor %}
{%- endif %} {%- endif %}

Loading…
Cancel
Save