implement stats collection with collectd

This commit is contained in:
Astro 2017-02-05 02:50:56 +01:00
parent 9a07ba6ec2
commit 0a443f6ad4
8 changed files with 112 additions and 0 deletions

View File

@ -0,0 +1,14 @@
collectd:
network: client
irq: True
cpu: True
load: True
memory: True
swap: True
entropy: True
disk: True
df: True
processes: True
hddtemp: True
sensors: True
thermal: True

View File

@ -0,0 +1,8 @@
collectd:
network: server
disk: True
df: True
rrdtool:
DataDir: "/var/lib/collectd/rrd"
CacheTimeout: 300
CacheFlush: 600

View File

@ -0,0 +1,8 @@
collectd:
network: client
interface: True
ping:
- google.de
- 8.8.8.8
- www.vodafone.de
conntrack: True

View File

@ -142,3 +142,10 @@ containers:
type: veth
gw: serv-gw
gw6: serv-gw
stats:
interfaces:
serv:
type: veth
gw: serv-gw
gw6: serv-gw

View File

@ -8,6 +8,7 @@ base:
- bird.ospf
- switches
- cpe.aps
- collectd.server1
'priv*-gw':
- dhcp
- bird.radv
@ -23,6 +24,7 @@ base:
- bird.bgp
'upstream*':
- bird.ospf
- collectd.upstream
# for forward-zones in unbound
- bind.dns
'upstream1':
@ -33,5 +35,8 @@ base:
- bird.ospf
- vpn.anon1
- upstream.anon1
- collectd.upstream
'dns':
- bind.dns
'stats':
- collectd.stats-server

View File

@ -0,0 +1,47 @@
Hostname "{{ salt['grains.get']('id') }}"
FQDNLookup false
Interval 10
LoadPlugin logfile
<Plugin logfile>
LogLevel info
File STDOUT
</Plugin>
{%- for plugin, conf in pillar['collectd'].items() %}
{%- if plugin == 'network' and conf == 'client' %}
LoadPlugin network
<Plugin network>
Server "{{ pillar['hosts-inet6']['serv']['stats'] }}" "25826"
</Plugin>
{%- elif plugin == 'network' and conf == 'server' %}
LoadPlugin network
<Plugin network>
Listen "::" "25826"
</Plugin>
{%- elif plugin == 'ping' %}
LoadPlugin ping
<Plugin ping>
{%- for host in conf %}
Host "{{ host }}"
{%- endfor %}
Interval 10
</Plugin>
{%- elif type(conf) == dict %}
LoadPlugin {{ plugin }}
<Plugin {{ plugin }}>
{%- for k, v in conf.items() %}
{{ k }} "{{ v }}"
{%- endfor %}
</Plugin>
{%- else %}
LoadPlugin {{ plugin }}
{%- endif %}
{%- endfor %}

17
salt/collectd/init.sls Normal file
View File

@ -0,0 +1,17 @@
collectd-core:
pkg.installed: []
liboping0:
pkg.installed: []
collectd:
service:
- running
- watch:
- pkg: collectd-core
- file: /etc/collectd/collectd.conf
/etc/collectd/collectd.conf:
file.managed:
- source: salt://collectd/collectd.conf
- template: 'jinja'

View File

@ -6,6 +6,7 @@ base:
- bird
- switches
- cpe
- collectd
'priv*-gw':
- no-ssh
- forwarding
@ -31,6 +32,7 @@ base:
- unbound
- upstream.dhcp
- upstream.shaping
- collectd
'upstream1':
- upstream.6to4
- upstream.nat66
@ -46,6 +48,10 @@ base:
- upstream.masquerade
- upstream.shaping
- upstream.nat66
- collectd
'dns':
- no-ssh
- bind
'stats':
- no-ssh
- collectd