This is a script I copied off the old resolvers…

#!/bin/bash
# Last modified 2017-12-05
# This script records stats for unbound in a csv.

export PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'

# set some vars
datefmt=$(date +"%Y-%m-%d")
curhour=$(date +"%H")
curhour=`echo $curhour|sed 's/^0*//'`
curhour=$((curhour +1))
storedir=/root/unbound-stats

# and do some stuff
unbound-control stats > $storedir/tempfile

nummiss=`cat $storedir/tempfile | grep "total.num.cachemiss" | rev | cut -d= -f1 | rev`
numhits=`cat $storedir/tempfile | grep "total.num.cachehits" | rev | cut -d= -f1 | rev`

rm $storedir/tempfile

if [ $curhour -eq 1 ]; then
  echo "Hour,CacheMisses,CacheHits" > $storedir/$datefmt.csv
fi

echo $curhour,$nummiss,$numhits >> $storedir/$datefmt.csv

/etc/init.d/unbound restart
technotes/unbound_stats_script.txt · Last modified: 2024-03-06 19:58 by snork
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki