Pārlūkot izejas kodu

Keep regex as default but still allow overrides.

pull/113/head
Jaymes Mosher pirms 7 gadiem
vecāks
revīzija
603e62ab9e
3 mainītis faili ar 26 papildinājumiem un 2 dzēšanām
  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 Parādīt failu

@@ -0,0 +1,16 @@
# -*- 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 Parādīt failu

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

+ 7
- 1
linux/meta/collectd.yml Parādīt failu

@@ -4,8 +4,14 @@ local_plugin:
plugin: netlink
template: linux/files/collectd_netlink.conf
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:
{%- for interface_name in monitoring.netlink.interfaces|sort %}
{%- for interface_name in interfaces|sort %}
- {{ interface_name }}
{%- endfor %}
{%- endif %}

Notiek ielāde…
Atcelt
Saglabāt