Skip to content

Instantly share code, notes, and snippets.

@gunkaaa
Created March 12, 2014 06:05
Show Gist options
  • Save gunkaaa/9501723 to your computer and use it in GitHub Desktop.
Save gunkaaa/9501723 to your computer and use it in GitHub Desktop.
#!/bin/bash
HOSTNAME="${COLLECTD_HOSTNAME:-`hostname -f`}"
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment