diff --git a/roles/munin_client/files/nsd b/roles/munin_client/files/nsd new file mode 100644 index 0000000..7dd9cb5 --- /dev/null +++ b/roles/munin_client/files/nsd @@ -0,0 +1,127 @@ +#!/bin/sh + +: << =cut + +=head1 NAME + +nsd - Plugin to monitor nsd DNS server + +=head1 CONFIGURATION + +No configuration + +=head1 AUTHOR + +Kim Heino + +=head1 LICENSE + +GPLv2 + +=head1 MAGIC MARKERS + + #%# family=auto + #%# capabilities=autoconf + +=cut + +if [ "$1" = "autoconf" ]; then + if [ -x /usr/sbin/nsd-control ]; then + echo "yes" + exit 0 + else + echo "no (no /usr/sbin/nsd-control)" + exit 0 + fi +fi + +if [ "$1" = "config" ]; then + echo 'graph_title NSD queries' + echo 'graph_vlabel queries / second' + echo 'graph_category dns' + echo 'graph_info Queries per second, by query type' + echo 'a.label A' + echo 'a.type DERIVE' + echo 'a.min 0' + echo 'aaaa.label AAAA' + echo 'aaaa.type DERIVE' + echo 'aaaa.min 0' + echo 'ptr.label PTR' + echo 'ptr.type DERIVE' + echo 'ptr.min 0' + echo 'cname.label CNAME' + echo 'cname.type DERIVE' + echo 'cname.min 0' + echo 'mx.label MX' + echo 'mx.type DERIVE' + echo 'mx.min 0' + echo 'txt.label TXT' + echo 'txt.type DERIVE' + echo 'txt.min 0' + echo 'soa.label SOA' + echo 'soa.type DERIVE' + echo 'soa.min 0' + echo 'ns.label NS' + echo 'ns.type DERIVE' + echo 'ns.min 0' + echo 'srv.label SRV' + echo 'srv.type DERIVE' + echo 'srv.min 0' + echo 'dnskey.label DNSKEY' + echo 'dnskey.type DERIVE' + echo 'dnskey.min 0' + echo 'axfr.label AXFR' + echo 'axfr.type DERIVE' + echo 'axfr.min 0' + echo 'snxd.label NXDOMAIN' + echo 'snxd.type DERIVE' + echo 'snxd.min 0' + echo 'rq.label Total Successful' + echo 'rq.type DERIVE' + echo 'rq.min 0' + exit 0 +fi + +/usr/sbin/nsd-control stats_noreset | sed 's/=/ /; s/\.//g' | ( + numtypeA=0 + numtypeAAAA=0 + numtypePTR=0 + numtypeCNAME=0 + numtypeMX=0 + numtypeTXT=0 + numtypeSOA=0 + numtypeNS=0 + numtypeSRV=0 + numtypeDNSKEY=0 + numraxfr=0 + numrcodeNXDOMAIN=0 + numqueries=0 + while read -r key value rest; do + [ "${key}" = "numtypeA" ] && numtypeA=${value} + [ "${key}" = "numtypeAAAA" ] && numtypeAAAA=${value} + [ "${key}" = "numtypePTR" ] && numtypePTR=${value} + [ "${key}" = "numtypeCNAME" ] && numtypeCNAME=${value} + [ "${key}" = "numtypeMX" ] && numtypeMX=${value} + [ "${key}" = "numtypeTXT" ] && numtypeTXT=${value} + [ "${key}" = "numtypeSOA" ] && numtypeSOA=${value} + [ "${key}" = "numtypeNS" ] && numtypeNS=${value} + [ "${key}" = "numtypeSRV" ] && numtypeSRV=${value} + [ "${key}" = "numtypeDNSKEY" ] && numtypeDNSKEY=${value} + [ "${key}" = "numraxfr" ] && numraxfr=${value} + [ "${key}" = "numrcodeNXDOMAIN" ] && numrcodeNXDOMAIN=${value} + [ "${key}" = "numqueries" ] && numqueries=${value} + done + echo "a.value ${numtypeA}" + echo "aaaa.value ${numtypeAAAA}" + echo "ptr.value ${numtypePTR}" + echo "cname.value ${numtypeCNAME}" + echo "mx.value ${numtypeMX}" + echo "txt.value ${numtypeTXT}" + echo "soa.value ${numtypeSOA}" + echo "ns.value ${numtypeNS}" + echo "srv.value ${numtypeSRV}" + echo "dnskey.value ${numtypeDNSKEY}" + echo "axfr.value ${numraxfr}" + echo "snxd.value ${numrcodeNXDOMAIN}" + echo "rq.value ${numqueries}" +) diff --git a/roles/munin_client/tasks/main.yml b/roles/munin_client/tasks/main.yml index 2ef7007..8bd5384 100644 --- a/roles/munin_client/tasks/main.yml +++ b/roles/munin_client/tasks/main.yml @@ -120,3 +120,8 @@ - name: Execute specific garage commands ansible.builtin.include_tasks: garage.yml when: "'garage1' in inventory_hostname" + +# Specific nsd commands +- name: Execute specific nsd commands + ansible.builtin.include_tasks: nsd.yml + when: "'dns' in inventory_hostname" diff --git a/roles/munin_client/tasks/nsd.yml b/roles/munin_client/tasks/nsd.yml new file mode 100644 index 0000000..b06cc35 --- /dev/null +++ b/roles/munin_client/tasks/nsd.yml @@ -0,0 +1,21 @@ +--- + +- name: Put nsd plugin configuration + ansible.builtin.template: + src: nsd.j2 + dest: /etc/munin/plugin-conf.d/nsd + owner: root + group: root + mode: "0o640" + notify: + - Restart munin-node + +- name: Put nsd scripts + ansible.builtin.copy: + src: files/nsd + dest: /etc/munin/plugins/nsd + owner: root + group: root + mode: "0o755" + notify: + - Restart munin-node diff --git a/roles/munin_client/templates/nsd.j2 b/roles/munin_client/templates/nsd.j2 new file mode 100644 index 0000000..14b746c --- /dev/null +++ b/roles/munin_client/templates/nsd.j2 @@ -0,0 +1,2 @@ +[nsd] +user root