mirror of
https://github.com/munin-monitoring/contrib.git
synced 2018-11-08 00:59:34 +01:00
Merge pull request #230 from unluckypixie/master
3 New Bind9 Plugins + 3 New PgBouncer plugins
This commit is contained in:
commit
0628832aef
95
plugins/network/dns/bind9_resolver_stats
Executable file
95
plugins/network/dns/bind9_resolver_stats
Executable 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
|
93
plugins/network/dns/bind9_server_stats
Executable file
93
plugins/network/dns/bind9_server_stats
Executable 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/network/dns/bind9_socket_stats
Executable file
87
plugins/network/dns/bind9_socket_stats
Executable 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
|
70
plugins/postgresql/pgbouncer_client_connections
Executable file
70
plugins/postgresql/pgbouncer_client_connections
Executable file
@ -0,0 +1,70 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Plugin to monitor PgBouncer total client connections for all pools.
|
||||
#
|
||||
# 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)
|
||||
#
|
||||
|
||||
dbserver='' # '-h localhost'
|
||||
dbuser='postgres'
|
||||
|
||||
# Pgbouncer Port Number
|
||||
port=6432
|
||||
|
||||
# The psql command to use.
|
||||
cmd="psql ${dbserver} -U ${dbuser} -p ${port} pgbouncer -tc 'SHOW POOLS;' | grep -v '^$'"
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
echo 'graph_args --lower-limit 0'
|
||||
echo 'graph_category pgbouncer'
|
||||
echo 'graph_info The sum of the active and waiting clients for each pool on the server.'
|
||||
echo 'graph_scale no'
|
||||
echo 'graph_title PgBouncer Pool Total Client Connections'
|
||||
echo 'graph_vlabel client connections'
|
||||
|
||||
eval ${cmd} | while read pool sep user junk
|
||||
do
|
||||
# Skip pgbouncer database itself.
|
||||
if [ "$user" = "pgbouncer" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
test -z "${pool}" && continue
|
||||
|
||||
echo ${pool}.label ${pool}
|
||||
echo ${pool}.info ${pool} connection pool
|
||||
echo ${pool}.type GAUGE
|
||||
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 looks like this:
|
||||
# database | user | cl_active | cl_waiting | sv_active | sv_idle | sv_used | sv_tested | sv_login | maxwait
|
||||
|
||||
eval ${cmd} | while read pool sep user sep cl_active sep cl_waiting sep sv_active sep sv_idle sep sv_used sep sv_tested sep sv_login sep maxwait
|
||||
do
|
||||
# Skip pgbouncer database itself.
|
||||
if [ "$user" = "pgbouncer" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
total=$(echo ${cl_active} + ${cl_waiting} | bc)
|
||||
|
||||
echo ${pool}.value ${total}
|
||||
done
|
||||
|
68
plugins/postgresql/pgbouncer_maxwait
Executable file
68
plugins/postgresql/pgbouncer_maxwait
Executable file
@ -0,0 +1,68 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Plugin to monitor PgBouncer max wait stat for all pools.
|
||||
#
|
||||
# Author:
|
||||
# Dave Fennell <dave@microtux.co.uk>
|
||||
#
|
||||
# License:
|
||||
# GPLv2
|
||||
#
|
||||
# Created:
|
||||
# 20th December 2012
|
||||
#
|
||||
# Usage:
|
||||
# Place in /etc/munin/plugins/ (or link it there using ln -s)
|
||||
#
|
||||
|
||||
dbserver='' # '-h localhost'
|
||||
dbuser='postgres'
|
||||
|
||||
# Pgbouncer Port Number
|
||||
port=6432
|
||||
|
||||
# The psql command to use.
|
||||
cmd="psql ${dbserver} -U ${dbuser} -p ${port} pgbouncer -tc 'SHOW POOLS;' | grep -v '^$'"
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
echo 'graph_args --lower-limit 0'
|
||||
echo 'graph_category pgbouncer'
|
||||
echo 'graph_info PgBouncer Pool Maximum Wait'
|
||||
echo 'graph_scale no'
|
||||
echo 'graph_title PgBouncer Pool Maximum Wait'
|
||||
echo 'graph_vlabel maximum wait (secs)'
|
||||
|
||||
eval ${cmd} | while read pool sep user junk
|
||||
do
|
||||
# Skip pgbouncer database itself.
|
||||
if [ "$user" = "pgbouncer" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
test -z "${pool}" && continue
|
||||
|
||||
echo ${pool}.label ${pool}
|
||||
echo ${pool}.info ${pool} connection pool
|
||||
echo ${pool}.type GAUGE
|
||||
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 looks like this:
|
||||
# database | user | cl_active | cl_waiting | sv_active | sv_idle | sv_used | sv_tested | sv_login | maxwait
|
||||
|
||||
eval ${cmd} | while read pool sep user sep cl_active sep cl_waiting sep sv_active sep sv_idle sep sv_used sep sv_tested sep sv_login sep maxwait
|
||||
do
|
||||
# Skip pgbouncer database itself.
|
||||
if [ "$user" = "pgbouncer" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
echo ${pool}.value ${maxwait}
|
||||
done
|
||||
|
69
plugins/postgresql/pgbouncer_server_connections
Executable file
69
plugins/postgresql/pgbouncer_server_connections
Executable file
@ -0,0 +1,69 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Plugin to monitor PgBouncer total server connections for all pools.
|
||||
#
|
||||
# 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)
|
||||
#
|
||||
|
||||
dbserver='' # '-h localhost'
|
||||
dbuser='postgres'
|
||||
|
||||
# Pgbouncer Port Number
|
||||
port=6432
|
||||
|
||||
# The psql command to use.
|
||||
cmd="psql ${dbserver} -U ${dbuser} -p ${port} pgbouncer -tc 'SHOW POOLS;' | grep -v '^$'"
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
echo 'graph_args --lower-limit 0'
|
||||
echo 'graph_category pgbouncer'
|
||||
echo 'graph_info The sum of the active and idle server connections for each pool on the server.'
|
||||
echo 'graph_scale no'
|
||||
echo 'graph_title PgBouncer Pool Total Server Connections'
|
||||
echo 'graph_vlabel server connections'
|
||||
|
||||
eval ${cmd} | while read pool sep user junk
|
||||
do
|
||||
# Skip pgbouncer database itself.
|
||||
if [ "$user" = "pgbouncer" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
test -z "${pool}" && continue
|
||||
|
||||
echo ${pool}.label ${pool}
|
||||
echo ${pool}.info ${pool} connection pool
|
||||
echo ${pool}.type GAUGE
|
||||
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 looks like this:
|
||||
# database | user | cl_active | cl_waiting | sv_active | sv_idle | sv_used | sv_tested | sv_login | maxwait
|
||||
|
||||
eval ${cmd} | while read pool sep user sep cl_active sep cl_waiting sep sv_active sep sv_idle sep sv_used sep sv_tested sep sv_login sep maxwait
|
||||
do
|
||||
# Skip pgbouncer database itself.
|
||||
if [ "$user" = "pgbouncer" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
total=$(echo ${sv_active} + ${sv_idle} | bc)
|
||||
|
||||
echo ${pool}.value ${total}
|
||||
done
|
Loading…
Reference in New Issue
Block a user