瀏覽代碼

Use netlink collectd plugin instead of interface

This patch replaces the "interface" collectd plugin by the "netlink" one. The
"netlink" plugin provides the same metrics as "interface" but plus other
metrics such as the number of dropped packets.
tags/2016.12
Éric Lemoine 8 年之前
父節點
當前提交
1c39744e43
共有 4 個檔案被更改,包括 36 行新增3 行删除
  1. +17
    -0
      _modules/netlink.py
  2. +10
    -0
      linux/files/collectd_netlink.conf
  3. +1
    -1
      linux/map.jinja
  4. +8
    -2
      linux/meta/collectd.yml

+ 17
- 0
_modules/netlink.py 查看文件

@@ -0,0 +1,17 @@
# -*- 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())

+ 10
- 0
linux/files/collectd_netlink.conf 查看文件

@@ -0,0 +1,10 @@
<LoadPlugin netlink>
Globals false
</LoadPlugin>

<Plugin netlink>
{%- for interface_name in plugin.get('interfaces', []) %}
VerboseInterface "{{ interface_name }}"
{%- endfor %}
IgnoreSelected {{ plugin.get('ignore_selected', False)|lower }}
</Plugin>

+ 1
- 1
linux/map.jinja 查看文件

@@ -15,7 +15,7 @@
'doc_validity_pkgs': ['python-yaml'],
},
'Debian': {
'pkgs': ['python-apt','vim-nox', 'apt-transport-https'],
'pkgs': ['python-apt','vim-nox', 'apt-transport-https', 'libmnl0'],
'utc': true,
'user': {},
'group': {},

+ 8
- 2
linux/meta/collectd.yml 查看文件

@@ -1,6 +1,12 @@
local_plugin:
linux_network_interface:
plugin: interface
linux_network_netlink:
plugin: netlink
template: linux/files/collectd_netlink.conf
ignore_selected: false
interfaces:
{%- for interface_name in salt['netlink.ls']() %}
- {{ interface_name }}
{%- endfor %}
linux_system_cpu:
plugin: cpu
linux_system_entropy:

Loading…
取消
儲存