2016/monitoring/collectd/scripts/unbound-collectd/unbound-collectd.sh
Vladimir Vitkov a90f8076d8 collectd - improvements/additions
* enable unix socket for nagios monitoring
 * Add data collection for unbound
2015-11-10 15:14:52 +02:00

21 lines
755 B
Bash

#!/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