1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-21 18:41:03 +00:00

Gallery: single dirname shall show up as second level heading

This commit is contained in:
dipohl 2017-02-22 00:57:32 +01:00
parent 4a87dd9cba
commit abd4092268
22 changed files with 0 additions and 0 deletions

140
plugins/bind/bind95_ Executable file
View file

@ -0,0 +1,140 @@
#!/usr/bin/perl
#
# Copyright Jean-Samuel Reynaud <js.reynaud@free.fr>
# Licenced under GPL v2
#
# We use this script to produce graph with munin for dns requests
# This script must have his name start with bind95_
# bind95_ : Global bind statistic
# bind95_test.com : Bind statistic for test.com zone (no view)
# bind95_test.com@internal : Bind statistic for test.com zone (view internal)
# This version work with bind 9.5
#
# Thanks for Benjamin Pineau for perl cleaning and corrections
#
# You should have to add the following lines to you plugin configuration
# (/etc/munin/plugin-conf.d/munin-node):
#[bind95_*]
#user root
#stat_file /var/cache/bind/named.stats
#rndc /usr/sbin/rndc
#
#
# Magic markers
#%# family=auto
#%# capabilities=autoconf
use strict;
use warnings;
use Digest::MD5 qw(md5_hex);
# change those to reflect your bind configuration (use plugin configuration)
# stat file
my $stat_file = $ENV{'stat_file'} || "/var/cache/bind/named.stats";
# rndc path
my $rndc = $ENV{'rndc'} || "/usr/sbin/rndc";
my $domain = $0;
if ($domain =~ m/^.*bind95_[\w\d\._\-]+@[\w\d\._\-]+?$/) {
$domain =~ s/^.*bind95_([\w\d\._\-]*)@([\w\d\._\-]+)?$/$1 (view: $2)/;
} elsif ($domain =~ m/^.*bind95_[\w\d\._\-]+$/) {
$domain =~ s/^.*bind95_([\w\d\._\-]+)$/$1/;
} else {
$domain = "View: _bind";
}
my @counters = (
'IPv4 requests received',
'requests with EDNS(0) received',
'TCP requests received',
'auth queries rejected',
'recursive queries rejected',
'transfer requests rejected',
'update requests rejected',
'responses sent',
'truncated responses sent',
'responses with EDNS(0) sent',
'queries resulted in successful answer',
'queries resulted in authoritative answer',
'queries resulted in non authoritative answer',
'queries resulted in referral answer',
'queries resulted in nxrrset',
'queries resulted in SERVFAIL',
'queries resulted in NXDOMAIN',
'queries caused recursion',
'duplicate queries received',
'queries dropped',
'other query failures',
'requested transfers completed',
'transfer requests succeeded',
'IPv4 notifies sent',
'IPv4 notifies received',
'notifies rejected',
'IPv4 SOA queries sent',
'IPv4 IXFR requested'
);
# Parse the statistic file
sub parseFile {
my $dom = shift @_;
open(IN,"<$stat_file") or die "Can't open $stat_file : $!";
my $current_zone = "";
while (<IN>) {
chomp;
my $l = $_;
if ($l =~ /\[/ ) {
$l =~ s/\[//g;
$l =~ s/\]//g;
$current_zone = $l;
} else {
$l =~ s/^ *//g;
if ($l =~ /^[0-9]/ && $current_zone eq $domain) {
my ($val,$desc) = split(' ',$l,2);
if (grep { $desc eq $_ } @counters) {
printf "%s.value %u\n",md5_hex($desc),$val;
}
}
}
}
close(IN);
}
# Config mode
if ( defined($ARGV[0]) && $ARGV[0] eq "config" ) {
printf "graph_title Dns requests %s\n",($domain eq "View: _bind" ? " all domains":$domain);
printf "graph_vlabel requests/s\n";
printf "graph_category dns\n";
printf "graph_info This graph display dns requests for %s\n",($domain eq "View: _bind" ? "all domains":$domain);
foreach(@counters) {
my $s = $_;
printf "%s.label %s\n",md5_hex($s),$s;
printf "%s.type DERIVE\n",md5_hex($s);
printf "%s.min 0\n",md5_hex($s);
}
exit 0;
}
if ( defined($ARGV[0]) && $ARGV[0] eq "autoconf" ) {
if (! -f $stat_file) {
printf "Unable to file bind stat file on %s",$stat_file;
exit 1;
}
if (! -f $rndc) {
printf "Unable to file rndc tool (configured : %s)",$rndc;
exit 1;
}
exit 0;
}
# Remove old stat file
unlink ($stat_file);
# Ask to bind to build new one
`$rndc stats`;
# Parse the stat file and return result
parseFile($domain);

View file

@ -0,0 +1,95 @@
#!/bin/bash
#
# Plugin to monitor Bind9 Name Server Resolver Stats
#
# Author:
# Dave Fennell <dave@microtux.co.uk>
#
# Created:
# 20th December 2012
#
# License:
# GPLv2
#
# Usage:
# Place in /etc/munin/plugins/ (or link it there using ln -s)
#
# change those to reflect your bind configuration (use plugin configuration)
# stat file
if [ "$stat_file" = "" ]; then
stat_file="/var/cache/bind/named.stats"
fi
# rndc path
if [ "$rndc" = "" ]; then
rndc="/usr/sbin/rndc"
fi
# Blank the stats file (else stats are appended not replaced)
rm ${stat_file}
# Ask to bind to build new one
${rndc} stats
# The section we are looking for in the stats.
section="Resolver Statistics"
# Get all the lines in the section:
# - cat the file
# - use sed to get lines after (and excluding) the section start tag
# - use sed to get lines up to (and excluding) the next section start tag
# - use grep to remove any lines starting with a [
cmd='cat "/var/cache/bind/named.stats" | sed "0,/^\+\+ '${section}' \+\+/d" | sed -e "/^\+\+/,\$d" | grep -v "^\["'
# Config mode.
if [ "$1" = "config" ]; then
echo 'graph_args --lower-limit 0'
echo 'graph_category dns'
echo 'graph_info '${section}' for the Bind9 Name Server'
echo 'graph_scale no'
echo 'graph_title Bind9 '${section}
echo 'graph_vlabel requests/${graph_period}'
# Output the stat configs.
eval ${cmd} | while read num name
do
# Shorten some names.
label=${name//queries with /}
label=${label//</below}
label=${label//>/above}
# All lowercase.
label=$(echo "$label" | tr 'A-Z' 'a-z')
# Now change names to all have no spaces.
key=${label//[ -]/_}
echo ${key}.label ${label}
echo ${key}.info ${name}
echo ${key}.type COUNTER
done
# If dirty config capability is enabled then fall through
# to output the data with the config information.
if [ "$MUNIN_CAP_DIRTYCONFIG" = "" ]; then
exit 0
fi
fi
# Output the stats.
eval ${cmd} | while read num name
do
# Shorten some names.
label=${name//queries with /}
label=${label//</below}
label=${label//>/above}
# All lowercase.
label=$(echo "$label" | tr 'A-Z' 'a-z')
# Now change names to all have no spaces.
key=${label//[ -]/_}
echo ${key}.value ${num}
done

137
plugins/bind/bind9_rr Executable file
View file

@ -0,0 +1,137 @@
#!/usr/bin/perl -w
# -*- perl -*-
=head1 NAME
bind9_rr - Plugin to monitor usage of bind 9 servers
=head1 CONFIGURATION
This plugin is configurable environment variables. The following
shows the default settings:
[bind9_rr]
env.logfile /var/log/bind9/query.log
You must also configure query logging in your named.conf. Use a stanza
such as this:
logging {
channel query {
file "query.log" versions 2 size 1m;
print-time yes;
severity info;
};
category queries { query; };
};
=head1 SEE ALSO
=over
=item * L<http://blog.larsstrand.org/2008/02/how-to-monitor-bind-with-munin.html>
=item * BIND Administrator Reference Manual
=back
=head1 AUTHOR
Nicolai Langfeldt
Remi Paulmier
=head1 LICENSE
GPLv2
=head1 MAGIC MARKERS
#%# family=manual
=cut
use strict;
my $QUERYLOG = $ENV{logfile} || '/var/log/bind9/query.log';
my $STATEFILE= "$ENV{MUNIN_PLUGSTATE}/bind9_rr.state";
my $OTHER=0;
my %IN;
sub get_state {
if (! -f $STATEFILE) {
open(Q, ">", $STATEFILE);
close(Q);
}
open(Q,"< $STATEFILE") or die ("Cannot open state file");
while (<Q>) {
chomp;
my ($q,$n) = split(/\s+/,$_,2);
$IN{$q}=$n unless defined($IN{$q});
}
close(Q);
}
sub do_stats {
my $k;
open(Q,"< $QUERYLOG") or die "$!";
while (<Q>) {
chomp;
if (/: (view \S+\: |)query\: (\S+) (\w+) (\w+)/) {
if ($3 eq 'IN' and $4 !~ /^TYPE/) {
my $crr = lc $2;
$IN{$crr}++;
}
}
}
close(Q);
get_state;
my @INkeys = sort { $IN{$b} <=> $IN{$a} } keys %IN;
open(Q,"> $STATEFILE") or die;
foreach $k (@INkeys[0 .. 19]) {
next if not defined $k;
my $l = $k; $k =~ tr/\./_/;
print "rr_$k.value ",$IN{$l},"\n";
print Q "$l ",$IN{$l},"\n";
}
close(Q);
}
sub do_config {
my $k;
print "graph_title DNS Queries by RR
graph_category dns
graph_vlabel Queries / \${graph_period}
";
get_state;
my @INkeys = sort { $IN{$b} <=> $IN{$a} } keys %IN;
foreach $k (@INkeys[0 .. 19]) {
next if not defined $k;
my $l = $k; $k =~ tr/\./_/;
print "rr_$k.label $l
rr_$k.type DERIVE
rr_$k.min 0
rr_$k.draw STACK
";
}
};
if (defined($ARGV[0]) and ($ARGV[0] eq 'config')) {
do_config;
exit(0);
}
do_stats;
# vim:syntax=perl

93
plugins/bind/bind9_server_stats Executable file
View file

@ -0,0 +1,93 @@
#!/bin/bash
#
# Plugin to monitor Bind9 Name Server Stats
#
# Author:
# Dave Fennell <dave@microtux.co.uk>
#
# Created:
# 20th December 2012
#
# License:
# GPLv2
#
# Usage:
# Place in /etc/munin/plugins/ (or link it there using ln -s)
#
# change those to reflect your bind configuration (use plugin configuration)
# stat file
if [ "$stat_file" = "" ]; then
stat_file="/var/cache/bind/named.stats"
fi
# rndc path
if [ "$rndc" = "" ]; then
rndc="/usr/sbin/rndc"
fi
# Blank the stats file (else stats are appended not replaced)
rm ${stat_file}
# Ask to bind to build new one
${rndc} stats
# The section we are looking for in the stats.
section="Name Server Statistics"
# Get all the lines in the section:
# - cat the file
# - use sed to get lines after (and excluding) the section start tag
# - use sed to get lines up to (and excluding) the next section start tag
# - use grep to remove any lines starting with a [
cmd='cat "/var/cache/bind/named.stats" | sed "0,/^\+\+ '${section}' \+\+/d" | sed -e "/^\+\+/,\$d" | grep -v "^\["'
# Config mode.
if [ "$1" = "config" ]; then
echo 'graph_args --lower-limit 0'
echo 'graph_category dns'
echo 'graph_info '${section}' for the Bind9 Name Server'
echo 'graph_scale no'
echo 'graph_title Bind9 '${section}
echo 'graph_vlabel requests/${graph_period}'
# Output the stat configs.
eval ${cmd} | while read num name
do
# Shorten some names.
label=${name//queries resulted in /}
label=${label// answer/}
# All lowercase.
label=$(echo "$label" | tr 'A-Z' 'a-z')
# Now change names to all have no spaces.
key=${label// /_}
echo ${key}.label ${label}
echo ${key}.info ${name}
echo ${key}.type COUNTER
done
# If dirty config capability is enabled then fall through
# to output the data with the config information.
if [ "$MUNIN_CAP_DIRTYCONFIG" = "" ]; then
exit 0
fi
fi
# Output the stats.
eval ${cmd} | while read num name
do
# Shorten some names.
label=${name//queries resulted in /}
label=${label// answer/}
# All lowercase.
label=$(echo "$label" | tr 'A-Z' 'a-z')
# Now change names to all have no spaces.
key=${label// /_}
echo ${key}.value ${num}
done

87
plugins/bind/bind9_socket_stats Executable file
View file

@ -0,0 +1,87 @@
#!/bin/bash
#
# Plugin to monitor Bind9 Name Server Socket Stats
#
# Author:
# Dave Fennell <dave@microtux.co.uk>
#
# Created:
# 20th December 2012
#
# License:
# GPLv2
#
# Usage:
# Place in /etc/munin/plugins/ (or link it there using ln -s)
#
# change those to reflect your bind configuration (use plugin configuration)
# stat file
if [ "$stat_file" = "" ]; then
stat_file="/var/cache/bind/named.stats"
fi
# rndc path
if [ "$rndc" = "" ]; then
rndc="/usr/sbin/rndc"
fi
# Blank the stats file (else stats are appended not replaced)
rm ${stat_file}
# Ask to bind to build new one
${rndc} stats
# The section we are looking for in the stats.
section="Socket I/O Statistics"
# Get all the lines in the section:
# - cat the file
# - use sed to get lines after (and excluding) the section start tag
# - use sed to get lines up to (and excluding) the next section start tag
# - use grep to remove any lines starting with a [
cmd='cat "/var/cache/bind/named.stats" | sed "0,/^\+\+ '${section//\//\\/}' \+\+/d" | sed -e "/^\+\+/,\$d" | grep -v "^\["'
# Config mode.
if [ "$1" = "config" ]; then
echo 'graph_args --lower-limit 0'
echo 'graph_category dns'
echo 'graph_info '${section}' for the Bind9 Name Server'
echo 'graph_scale no'
echo 'graph_title Bind9 '${section}
echo 'graph_vlabel requests/${graph_period}'
# Output the stat configs.
eval ${cmd} | while read num name
do
label=${name}
# All lowercase.
key=$(echo "$name" | tr 'A-Z' 'a-z')
# Now change names to all have no spaces.
key=${key//[\/ - ]/_}
echo ${key}.label ${label}
echo ${key}.info ${name}
echo ${key}.type COUNTER
done
# If dirty config capability is enabled then fall through
# to output the data with the config information.
if [ "$MUNIN_CAP_DIRTYCONFIG" = "" ]; then
exit 0
fi
fi
# Output the stats.
eval ${cmd} | while read num name
do
# All lowercase.
key=$(echo "$name" | tr 'A-Z' 'a-z')
# Now change names to all have no spaces.
key=${key//[\/ - ]/_}
echo ${key}.value ${num}
done

115
plugins/bind/bind_ Executable file
View file

@ -0,0 +1,115 @@
#!/usr/bin/perl
#
# Copyright Jean-Samuel Reynaud <js.reynaud@free.fr>
# Licenced under GPL v2
#
# We use this script to produce graph with munin for dns requests
# This script must have his name start with bind_
# bind_ : Global bind statistic
# bind_test.com : Bind statistic for test.com zone
#
# "env.bind_stat_file" is the path to the bind statistic file
# (/var/cache/bind/named.stats by default).
#
# "env.bind_rndc" is the path to the rndc tool
# (/usr/sbin/rndc by default).
#
# Thanks for Benjamin Pineau for perl cleaning and correction in non root
# running
# Thanks to Immanuel Klinkenberg for adding config parameter by using munin config
#
# Magic markers
#%# family=auto
#%# capabilities=autoconf
use strict;
use warnings;
# change those to reflect your bind configuration
# stat file
my $stat_file = # DB directory
defined $ENV{'bind_stat_file'} ? $ENV{'bind_stat_file'} : '/var/cache/bind/named.stats';
# rndc path
my $rndc = # rndc path
defined $ENV{'bind_rndc'} ? $ENV{'bind_rndc'} : '/usr/sbin/rndc';
my $lst = { "success" => 1,
"referral" => 1,
"nxrrset" => 1,
"nxdomain" => 1,
"recursion" => 1,
"failure" => 1};
my $domain = $0;
$domain =~ s/^.*bind_([\w\d\._\-]*)$/$1/;
# Parse the statistic file
sub parseFile {
my $dom = shift @_;
open(IN,"<$stat_file") or die "Can't open $stat_file : $!";
while (<IN>) {
chomp;
my ($type,$count,$zone) = split(/ /,$_);
$zone = defined($zone) ? $zone : "";
if ($zone eq $dom) {
if (defined $lst->{$type}) {
# only keep the latest occurrence for each value
$lst->{$type} = $count;
}
}
}
close(IN);
printf "%s.value %u\n", $_, $lst->{$_} foreach (keys %$lst);
}
# Config mode
if ( defined($ARGV[0]) && $ARGV[0] eq "config" ) {
printf "graph_title Dns requests %s\n",($domain eq "" ? " all domains":$domain);
printf "graph_vlabel requests/s\n";
printf "graph_category dns\n";
printf "graph_info This graph display dns requests for %s\n",($domain eq "" ? " all domains":$domain);
printf "success.label Success\n";
printf "success.type COUNTER\n";
printf "referral.label Referral\n";
printf "referral.type COUNTER\n";
printf "nxrrset.label Nx RR set\n";
printf "nxrrset.type COUNTER\n";
printf "nxdomain.label NX domain\n";
printf "nxdomain.type COUNTER\n";
printf "recursion.label Recursion\n";
printf "recursion.type COUNTER\n";
printf "failure.label Failure\n";
printf "failure.type COUNTER\n";
exit 0;
}
if ( defined($ARGV[0]) && $ARGV[0] eq "autoconf" ) {
if (! -f $stat_file) {
printf "Unable to file bind stat file on %s",$stat_file;
exit 1;
}
if (! -f $rndc) {
printf "Unable to file rndc tool (configured : %s)",$rndc;
exit 1;
}
exit 0;
}
# Remove old stat file
unlink ($stat_file);
# Ask to bind to build new one
`$rndc stats`;
# Parse the stat file and return result
parseFile($domain);