collectd - improvements/additions

* enable unix socket for nagios monitoring
 * Add data collection for unbound
This commit is contained in:
Vladimir Vitkov 2015-11-10 15:14:52 +02:00
parent ef4934efb7
commit a90f8076d8
3 changed files with 41 additions and 0 deletions

View File

@ -0,0 +1,7 @@
# unbound-collectd.sh
Simple script to monitor unbound
# Prerequisites
* Unbound
* `/etc/unbound/*.key` and `/etc/unbound/*.pem` should have group unbound
* exec section should execute the script with user unbound

View File

@ -0,0 +1,20 @@
#!/bin/bash
#
# simple script to monitor unbound
# All metrics are gauges
HOSTNAME="${COLLECTD_HOSTNAME:-eric}"
INTERVAL="${COLLECTD_INTERVAL:-10}"
while sleep "$INTERVAL"; do
/usr/sbin/unbound-control stats | while read line;do
INSTANCE=`echo $line | cut -d= -f1 | cut -d. -f1`
STAT=`echo $line | cut -d= -f1 | cut -d. -f2- \
| sed 's/\./-/g' | sed 's/recursion-time-/recursion-time_/g' \
| sed 's/now/time-now/g' | sed 's/up/time-up/g' \
| sed 's/elapsed/time-elapsed/g' `
VALUE=`echo $line | cut -d= -f2`
echo "PUTVAL \"$HOSTNAME/unbound-${INSTANCE}/$STAT\" interval=$INTERVAL N:$VALUE"
done
done

View File

@ -223,6 +223,20 @@ LoadPlugin snmp
</Host>
</Plugin>
# monitor unbound by exec
LoadPlugin exec
<Plugin exec>
Exec "unbound" "/usr/local/bin/unbound-collectd.sh"
</Plugin>
# See collectd.conf(5)
LoadPlugin unixsock
<Plugin unixsock>
SocketFile "/tmp/collectd.sock"
SocketGroup "nagios"
SocketPerms "0770"
</Plugin>
# and finaly save the data in graphite
LoadPlugin write_graphite
<Plugin write_graphite>