From c1e6db895536ee26f66a431c274bbe25207b1098 Mon Sep 17 00:00:00 2001 From: Michael Grote Date: Fri, 14 Jan 2022 23:17:59 +0100 Subject: [PATCH] =?UTF-8?q?Plugin=20dnsmasq=20von=20https://raw.githubuser?= =?UTF-8?q?content.com/notracking/dnsmasq-munin/master/dnsmasq=20hinzugef?= =?UTF-8?q?=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extern/dnsmasq | 112 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 extern/dnsmasq diff --git a/extern/dnsmasq b/extern/dnsmasq new file mode 100644 index 0000000..f89dc78 --- /dev/null +++ b/extern/dnsmasq @@ -0,0 +1,112 @@ +#!/bin/bash +# -*- sh -*- +: <<=cut + +=head1 NAME + +dnsmasq - Plugin to monitor dnsmasq queries - https://raw.githubusercontent.com/notracking/dnsmasq-munin/master/dnsmasq + +=head1 APPLICABLE SYSTEMS + +All systems with "bash", "sed" and "dnsmasq" + +=head1 CONFIGURATION + +The following is the default configuration + + [dnsmasq] + env.logfile /var/log/dnsmasq.log + +The user running this plugin needs read access to the +dnsmasq logfiles: + + [dnsmasq] + user root + +=head1 INTERPRETATION + +This plugin shows a graph with the number of forwarded, cached and +blocked dns queries. + +=head1 MAGIC MARKERS + + #%# family=auto + #%# capabilities=autoconf + +=head1 VERSION + + 1.0.20090423 + +=head1 BUGS + +Needs bash. Uses bashisms ${parm/?/pat/string} and $'...' to avoid +running external programs. + +=head1 AUTHOR + +notracking +Based on fail2ban plugin by: Stig Sandbeck Mathisen + +=head1 LICENSE + +GPLv2 + +=cut + + +############################## +# Configurable variables +logfile=${logfile:-/var/log/dnsmasq.log} + +# Print the munin values +values() { + echo -n "dnsmasq_forwarded.value " + cat ${logfile} |sed -n "/^$(date --date='5 minutes ago' '+%b %_d %H:%M')/,\$p" |grep ": forwarded" |wc -l + + echo -n "dnsmasq_cached.value " + cat ${logfile} |sed -n "/^$(date --date='5 minutes ago' '+%b %_d %H:%M')/,\$p" |grep ": cached" |wc -l + + echo -n "dnsmasq_blocked.value " + cat ${logfile} |sed -n "/^$(date --date='5 minutes ago' '+%b %_d %H:%M')/,\$p" |grep "0\.0\.0\.0" |wc -l +} + +# Print the munin config +config() { + echo 'graph_title Query stats for dnsmasq' + echo 'graph_info This graph shows the number of queries resolved by dnsmasq' + echo 'graph_category network' + echo 'graph_vlabel Number of queries' + + echo 'graph_args --base 1000 -l 0' + echo 'graph_total total' + + echo 'dnsmasq_forwarded.label forwarded' + echo 'dnsmasq_cached.label cached' + echo 'dnsmasq_blocked.label blocked' +} + +# Print autoconfiguration hint +autoconf() { + if [ -f ${logfile} ] + then + echo "yes" + else + echo "no (${logfile} not found)" + fi + exit +} + +############################## +# Main + +case $1 in + config) + config + ;; + autoconf) + autoconf + ;; + *) + values + ;; +esac