mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-22 02:51:03 +00:00
- have some dirs
This commit is contained in:
parent
0b089ea777
commit
08346aac58
687 changed files with 0 additions and 0 deletions
141
plugins/mysql/mysql_connections
Executable file
141
plugins/mysql/mysql_connections
Executable file
|
@ -0,0 +1,141 @@
|
|||
#!/usr/bin/perl
|
||||
#
|
||||
# Copyright (C) 2008 Rackspace US, Inc. <http://www.rackspace.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; version 2 dated June,
|
||||
# 1991.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
|
||||
#
|
||||
#
|
||||
# This plugin is based off of the Connection Usage
|
||||
# section of the MySQL Connection Health Page
|
||||
#
|
||||
# http://dev.mysql.com/doc/administrator/en/mysql-administrator-health-connection-health.html
|
||||
#
|
||||
# To enable, link mysql_connections to this file. E.g.
|
||||
#
|
||||
# ln -s /usr/share/node/node/plugins/mysql_connections /etc/munin/plugins/mysql_connections
|
||||
#
|
||||
# Revision 1.0 2007/08/03
|
||||
# Created by Justin Shepherd <galstrom21@gmail.com>
|
||||
#
|
||||
# Parameters:
|
||||
#
|
||||
# config
|
||||
# autoconf
|
||||
#
|
||||
# Configuration variables
|
||||
#
|
||||
# mysqlopts - Options to pass to mysql
|
||||
# mysqladmin - Override location of mysqladmin
|
||||
# warning - Override default warning limit
|
||||
# critical - Override default critical limit
|
||||
#
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
use strict;
|
||||
|
||||
# Define the mysqladmin paths, and commands
|
||||
my $MYSQLADMIN = $ENV{mysqladmin} || "mysqladmin";
|
||||
my $TEST_COMMAND = "$MYSQLADMIN $ENV{mysqlopts} extended-status";
|
||||
my $MYSQL_VARIABLES = "$MYSQLADMIN $ENV{mysqlopts} extended-status variables";
|
||||
my $warning = $ENV{warning} || "80";
|
||||
my $critical = $ENV{critical} || "90";
|
||||
|
||||
# Pull in any arguments
|
||||
my $arg = shift();
|
||||
|
||||
# Check to see how the script was called
|
||||
if ($arg eq 'config') {
|
||||
print_graph_information();
|
||||
exit();
|
||||
} elsif ($arg eq 'autoconf') {
|
||||
if (test_service()) { print "yes\n"; }
|
||||
else { print "no\n"; }
|
||||
exit;
|
||||
} else {
|
||||
# Define the values that are returned to munin
|
||||
my ($available, $current, $upper_limit) = (0,0,0);
|
||||
|
||||
# Gather the values from mysqladmin
|
||||
$current = poll_variables($MYSQL_VARIABLES,"Threads_connected");
|
||||
$upper_limit = poll_variables($MYSQL_VARIABLES,"max_connections");
|
||||
$available = $upper_limit - $current;
|
||||
|
||||
# Return the values to Munin
|
||||
print "current.value $current\n";
|
||||
print "available.value $available\n";
|
||||
}
|
||||
|
||||
|
||||
sub poll_variables {
|
||||
my $command = shift;
|
||||
my $expression = shift;
|
||||
my $ret = 0;
|
||||
open(SERVICE, "$command |")
|
||||
or die("Coult not execute '$command': $!");
|
||||
while (<SERVICE>) {
|
||||
my ($field, $value) = (m/(\w+).*?(\d+(?:\.\d+)?)/);
|
||||
next unless ($field);
|
||||
if ($field eq $expression ) {
|
||||
$ret = "$value";
|
||||
}
|
||||
}
|
||||
close(SERVICE);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
sub print_graph_information {
|
||||
print <<EOM;
|
||||
graph_title MySQL Connections
|
||||
graph_args --base 1000 --lower-limit 0
|
||||
graph_vlabel Connections
|
||||
graph_info The number of current connections with respect to the max_connections setting.
|
||||
graph_category mysql
|
||||
graph_order current available
|
||||
graph_total Total
|
||||
current.label In Use
|
||||
current.draw AREA
|
||||
current.info The number of current threads connected
|
||||
current.warning $warning
|
||||
current.critical $critical
|
||||
available.label Available
|
||||
available.draw STACK
|
||||
available.info The current value of the "max_connections" variable
|
||||
EOM
|
||||
}
|
||||
|
||||
|
||||
sub test_service {
|
||||
my $return = 1;
|
||||
system ("$MYSQLADMIN --version >/dev/null 2>/dev/null");
|
||||
if ($? == 0)
|
||||
{
|
||||
system ("$TEST_COMMAND >/dev/null 2>/dev/null");
|
||||
if ($? == 0)
|
||||
{
|
||||
print "yes\n";
|
||||
$return = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
print "no (could not connect to mysql)\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print "no (mysqladmin not found)\n";
|
||||
}
|
||||
exit $return;
|
||||
}
|
64
plugins/mysql/mysql_innodb
Executable file
64
plugins/mysql/mysql_innodb
Executable file
|
@ -0,0 +1,64 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Munin plugin to monitor free space in MySQL's InnoDB tablespace.
|
||||
# Mostly useful if you use InnoDB on a block device, or if you for
|
||||
# some reason don't want to do autoextend on the last file.
|
||||
#
|
||||
# 2007-03-18 Stig Sandbeck Mathisen <ssm@fnord.no>
|
||||
#
|
||||
# Configuration parameters for /etc/munin/plugin-conf.d/mysql_innodb,
|
||||
# if you need to override the defaults below:
|
||||
#
|
||||
# [mysql_innodb]
|
||||
# env.mysqlopts - Options to pass to mysql (host, username, password)
|
||||
# env.warning - Generate a warning if free space goes below this level
|
||||
# env.critical - Generate a critical if free space goes below this level
|
||||
#
|
||||
# For security reasons, this plugin uses its own schema with a simple,
|
||||
# empty table using the InnoDB engine.
|
||||
#
|
||||
# You need to run this to get this plugin to work:
|
||||
# mysql> CREATE DATABASE munin_innodb;
|
||||
# mysql> USE munin_innodb
|
||||
# mysql> CREATE TABLE something (anything int) ENGINE=InnoDB;
|
||||
|
||||
## Tunable parameters with defaults
|
||||
MYSQL="${mysql:-/usr/bin/mysql}"
|
||||
MYSQLOPTS="${mysqlopts:---user=munin --password=munin --host=localhost}"
|
||||
|
||||
WARNING=${warning:-2147483648} # 2GB
|
||||
CRITICAL=${critical:-1073741824} # 1GB
|
||||
|
||||
## No user serviceable parts below
|
||||
if [ "$1" = "config" ]; then
|
||||
echo 'graph_title MySQL InnoDB free tablespace'
|
||||
echo 'graph_args --base 1024'
|
||||
echo 'graph_vlabel Bytes'
|
||||
echo 'graph_category mysql'
|
||||
echo 'graph_info Amount of free bytes in the InnoDB tablespace'
|
||||
echo 'free.label Bytes free'
|
||||
echo 'free.type GAUGE'
|
||||
echo 'free.min 0'
|
||||
echo 'free.warning' $WARNING:
|
||||
echo 'free.critical' $CRITICAL:
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Get freespace from mysql
|
||||
freespace=$($MYSQL $MYSQLOPTS --batch --skip-column-names --execute \
|
||||
"SELECT table_comment FROM tables WHERE TABLE_SCHEMA = 'munin_innodb'" \
|
||||
information_schema);
|
||||
retval=$?
|
||||
|
||||
# Sanity checks
|
||||
if (( retval > 0 )); then
|
||||
echo "Error: mysql command returned status $retval" 1>&2
|
||||
exit -1
|
||||
fi
|
||||
if [ -z "$freespace" ]; then
|
||||
echo "Error: mysql command returned no output" 1>&2
|
||||
exit -1
|
||||
fi
|
||||
|
||||
# Return freespace
|
||||
echo $freespace | awk '/InnoDB free:/ {print "free.value", $3 * 1024}'
|
123
plugins/mysql/mysql_qcache
Executable file
123
plugins/mysql/mysql_qcache
Executable file
|
@ -0,0 +1,123 @@
|
|||
#!/usr/bin/perl
|
||||
#
|
||||
# Copyright (C) 2006 - Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
# Copyright (C) 2003-2004 - Andreas Buer
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; version 2 dated June,
|
||||
# 1991.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# $Log$
|
||||
# Revision 1.0 2006/04/26 16:04:01 rodo
|
||||
# Created by Rodolphe Quiedeville
|
||||
#
|
||||
# Parameters:
|
||||
#
|
||||
# config
|
||||
# autoconf
|
||||
#
|
||||
# Configuration variables
|
||||
#
|
||||
# mysqlopts - Options to pass to mysql
|
||||
# mysqladmin - Override location of mysqladmin
|
||||
#
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
use strict;
|
||||
|
||||
my $MYSQLADMIN = $ENV{mysqladmin} || "mysqladmin";
|
||||
my $COMMAND = "$MYSQLADMIN $ENV{mysqlopts} extended-status";
|
||||
|
||||
my %WANTED = ( "Qcache_queries_in_cache" => "queries");
|
||||
|
||||
my %WANTEDTYPE = ( "Qcache_queries_in_cache" => "GAUGE");
|
||||
|
||||
my $arg = shift();
|
||||
|
||||
if ($arg eq 'config') {
|
||||
print_config();
|
||||
exit();
|
||||
} elsif ($arg eq 'autoconf') {
|
||||
unless (test_service() ) {
|
||||
print "yes\n";
|
||||
} else {
|
||||
print "no\n";
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
open(SERVICE, "$COMMAND |")
|
||||
or die("Coult not execute '$COMMAND': $!");
|
||||
|
||||
while (<SERVICE>) {
|
||||
my ($k, $v) = (m/(\w+).*?(\d+(?:\.\d+)?)/);
|
||||
next unless ($k);
|
||||
if (exists $WANTED{$k} ) {
|
||||
print("$WANTED{$k}.value $v\n");
|
||||
}
|
||||
}
|
||||
|
||||
close(SERVICE);
|
||||
|
||||
|
||||
sub print_config {
|
||||
|
||||
my $num = 0;
|
||||
|
||||
print('graph_title MySQL Queries in cache
|
||||
graph_args --base 1000
|
||||
graph_vlabel queries
|
||||
graph_category mysql
|
||||
graph_info Plugin available at <a href="http://rodolphe.quiedeville.org/hack/munin/">http://rodolphe.quiedeville.org/hack/munin/</a>
|
||||
');
|
||||
|
||||
for my $key (keys %WANTED) {
|
||||
my $title = $WANTED{$key};
|
||||
print("$title.label ${title}\n",
|
||||
"$title.min 0\n",
|
||||
"$title.type ".$WANTEDTYPE{$key}."\n",
|
||||
"$title.max 500000\n",
|
||||
"$title.draw ", ($num) ? "STACK" : "AREA" , "\n",
|
||||
);
|
||||
$num++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
sub test_service {
|
||||
|
||||
my $return = 1;
|
||||
|
||||
system ("$MYSQLADMIN --version >/dev/null 2>/dev/null");
|
||||
if ($? == 0)
|
||||
{
|
||||
system ("$COMMAND >/dev/null 2>/dev/null");
|
||||
if ($? == 0)
|
||||
{
|
||||
print "yes\n";
|
||||
$return = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
print "no (could not connect to mysql)\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print "no (mysqladmin not found)\n";
|
||||
}
|
||||
exit $return;
|
||||
}
|
129
plugins/mysql/mysql_qcache_mem
Executable file
129
plugins/mysql/mysql_qcache_mem
Executable file
|
@ -0,0 +1,129 @@
|
|||
#!/usr/bin/perl
|
||||
#
|
||||
# Copyright (C) 2006 - Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
# Copyright (C) 2003-2004 - Andreas Buer
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; version 2 dated June,
|
||||
# 1991.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# $Log$
|
||||
# Revision 1.0 2006/04/28 09:04:01 rodo
|
||||
# Add lower limit fixed to 0
|
||||
#
|
||||
# Revision 1.0 2006/04/26 16:04:01 rodo
|
||||
# Created by Rodolphe Quiedeville
|
||||
#
|
||||
# Parameters:
|
||||
#
|
||||
# config
|
||||
# autoconf
|
||||
#
|
||||
# Configuration variables
|
||||
#
|
||||
# mysqlopts - Options to pass to mysql
|
||||
# mysqladmin - Override location of mysqladmin
|
||||
#
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
use strict;
|
||||
|
||||
my $MYSQLADMIN = $ENV{mysqladmin} || "mysqladmin";
|
||||
my $COMMAND = "$MYSQLADMIN $ENV{mysqlopts} extended-status";
|
||||
my $COMMANDSIZE = "$MYSQLADMIN $ENV{mysqlopts} variables";
|
||||
|
||||
my %WANTED = ( "Qcache_free_memory" => "free" );
|
||||
|
||||
my $arg = shift();
|
||||
|
||||
if ($arg eq 'config') {
|
||||
print_config();
|
||||
exit();
|
||||
} elsif ($arg eq 'autoconf') {
|
||||
unless (test_service() ) {
|
||||
print "yes\n";
|
||||
} else {
|
||||
print "no\n";
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
my ($free, $used) = (0,0);
|
||||
|
||||
open(SERVICE, "$COMMAND |")
|
||||
or die("Coult not execute '$COMMAND': $!");
|
||||
|
||||
while (<SERVICE>) {
|
||||
my ($k, $v) = (m/(\w+).*?(\d+(?:\.\d+)?)/);
|
||||
next unless ($k);
|
||||
if (exists $WANTED{$k} ) {
|
||||
$free = $v;
|
||||
print("$WANTED{$k}.value $v\n");
|
||||
}
|
||||
}
|
||||
close(SERVICE);
|
||||
|
||||
open(SERVICE, "$COMMANDSIZE |")
|
||||
or die("Coult not execute '$COMMANDSIZE': $!");
|
||||
|
||||
while (<SERVICE>) {
|
||||
my ($k, $v) = (m/(\w+).*?(\d+(?:\.\d+)?)/);
|
||||
|
||||
next unless ($k);
|
||||
if ($k eq "query_cache_size" ) {
|
||||
print("used.value ",($v-$free),"\n");
|
||||
}
|
||||
}
|
||||
close(SERVICE);
|
||||
|
||||
sub print_config {
|
||||
|
||||
print('graph_title MySQL Queries Cache Size
|
||||
graph_args --base 1024 -l 0
|
||||
graph_vlabel bytes
|
||||
graph_category mysql
|
||||
graph_order used free
|
||||
graph_total Total
|
||||
graph_info Plugin available at <a href="http://rodolphe.quiedeville.org/hack/munin/">http://rodolphe.quiedeville.org/hack/munin/</a>
|
||||
used.label Used
|
||||
used.draw AREA
|
||||
free.label Free
|
||||
free.draw STACK
|
||||
');
|
||||
}
|
||||
|
||||
sub test_service {
|
||||
|
||||
my $return = 1;
|
||||
|
||||
system ("$MYSQLADMIN --version >/dev/null 2>/dev/null");
|
||||
if ($? == 0)
|
||||
{
|
||||
system ("$COMMAND >/dev/null 2>/dev/null");
|
||||
if ($? == 0)
|
||||
{
|
||||
print "yes\n";
|
||||
$return = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
print "no (could not connect to mysql)\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print "no (mysqladmin not found)\n";
|
||||
}
|
||||
exit $return;
|
||||
}
|
161
plugins/mysql/mysql_report
Executable file
161
plugins/mysql/mysql_report
Executable file
|
@ -0,0 +1,161 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Plugin to graph numeric result of the specified MySQL queries.
|
||||
#
|
||||
# Parameters:
|
||||
#
|
||||
# config (required)
|
||||
# autoconf (optional - used by lrrd-config)
|
||||
#
|
||||
# Configuration example
|
||||
#
|
||||
# [mysql_report]
|
||||
# env.names query1 query2
|
||||
# env.hostname www.example.com
|
||||
# env.database mysql
|
||||
# env.username report
|
||||
# env.password secret
|
||||
# env.errorvalue 60
|
||||
# env.max 120
|
||||
#
|
||||
# env.label_query1 Example query#1 (number of users)
|
||||
# env.hostname_query1 www1.example.com
|
||||
# env.draw_query1 AREA
|
||||
# env.colour_query1 FF0000
|
||||
# env.database_query1 mysql
|
||||
# env.username_query1 user1
|
||||
# env.password_query1 secret1
|
||||
# env.query_query1 select count(*) from `exampledb`.`users`
|
||||
# env.warning_query1 5
|
||||
# env.critical_query1 8
|
||||
#
|
||||
# env.label_query2 Example query#2 (number of successful logins)
|
||||
# env.query_query2 select count(*) from `exampledb`.`login_log`
|
||||
# env.type_query2 DERIVE
|
||||
# env.draw_query2 LINE2
|
||||
# env.colour_query2 000080
|
||||
# env.mysqlopts_query2 --defaults-extra-file=/etc/mysql/debian.cnf --port=4507
|
||||
#
|
||||
# env.cdefnames cdef1
|
||||
# env.cdef_cdef1 result1,result2,+
|
||||
# env.cdeflbl_cdef1 Users and successful logins sum
|
||||
|
||||
#
|
||||
# $Log$
|
||||
#
|
||||
# Revision 1.0 2010/04/19 14:18:32 muzso@muzso.hu
|
||||
# Initial version
|
||||
#
|
||||
# Revision 1.01 2010/7/14 oded@pageonce.com
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
mysqlbin=$(which mysql)
|
||||
|
||||
default_errorvalue=30
|
||||
default_title="Results from MySQL queries"
|
||||
default_category="mysql"
|
||||
default_vlabel="value / sec"
|
||||
default_info="This graph shows results of one or more SQL queries."
|
||||
default_args="--base 1000 -l 0"
|
||||
default_scale="no"
|
||||
|
||||
if [ "${1}" = "autoconf" ]; then
|
||||
result=0
|
||||
if [ -z "${mysqlbin}" ]; then
|
||||
echo "no"
|
||||
else
|
||||
echo "yes"
|
||||
fi
|
||||
exit $result
|
||||
fi
|
||||
|
||||
if [ -z "${names}" ]; then
|
||||
echo "Configuration required"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
[ -n "${errorvalue}" ] || errorvalue=${default_errorvalue}
|
||||
[ -n "${title}" ] || title="${default_title}"
|
||||
[ -n "${category}" ] || category="${default_category}"
|
||||
[ -n "${vlabel}" ] || vlabel="${default_vlabel}"
|
||||
[ -n "${info}" ] || info="${default_info}"
|
||||
[ -n "${args}" ] || args="${default_args}"
|
||||
[ -n "${scale}" ] || scale="${default_scale}"
|
||||
|
||||
if [ "${1}" = "config" ]; then
|
||||
cat << EOH1
|
||||
graph_title ${title}
|
||||
graph_args ${args}
|
||||
graph_scale ${scale}
|
||||
graph_vlabel ${vlabel}
|
||||
graph_category ${category}
|
||||
graph_info ${info}
|
||||
EOH1
|
||||
[[ -n "${period}" ]] && echo "graph_period ${period}"
|
||||
I=1
|
||||
for name in ${names}; do
|
||||
eval iquery='${query_'${name}'}'
|
||||
if [ -n "${iquery}" ]; then
|
||||
eval ilabel='${label_'${name}':-host${I}}'
|
||||
eval iwarning='${warning_'${name}':-${warning}}'
|
||||
eval icritical='${critical_'${name}':-${critical}}'
|
||||
eval imax='${max_'${name}':-${max}}'
|
||||
eval itype='${type_'${name}':-${type}}'
|
||||
eval idraw='${draw_'${name}':-${draw}}'
|
||||
eval icolour='${colour_'${name}':-${colour}}'
|
||||
iquery=$(echo "${iquery}" | tr '\n\r' ' ')
|
||||
cat << EOH2
|
||||
result${I}.label ${ilabel}
|
||||
result${I}.info Result of the query: ${iquery}
|
||||
result${I}.min 0
|
||||
EOH2
|
||||
[ -n "${imax}" ] && echo "result${I}.max ${imax}"
|
||||
[ -n "${itype}" ] && echo "result${I}.type ${itype}"
|
||||
[ -n "${idraw}" ] && echo "result${I}.draw ${idraw}"
|
||||
[ -n "${icolour}" ] && echo "result${I}.colour ${icolour}"
|
||||
[ -n "${iwarning}" ] && echo "result${I}.warning ${iwarning}"
|
||||
[ -n "${icritical}" ] && echo "result${I}.critical ${icritical}"
|
||||
I=$((I+1))
|
||||
fi
|
||||
done
|
||||
for cdefname in ${cdefnames} ;do
|
||||
eval icdef='${cdef_'${cdefname}'}'
|
||||
if [ -n "${icdef}" ]; then
|
||||
eval icdeflbl='${cdeflbl_'${cdefname}':-${cdeflbl}}'
|
||||
cat << EOH4
|
||||
${cdefname}.cdef ${icdef}
|
||||
${cdefname}.label ${icdeflbl}
|
||||
EOH4
|
||||
fi
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
|
||||
I=1
|
||||
for name in ${names}; do
|
||||
eval iquery='${query_'${name}'}'
|
||||
if [ -n "${iquery}" ]; then
|
||||
eval ihostname='${hostname_'${name}':-${hostname}}'
|
||||
[ -n "${ihostname}" ] && opts="${opts} --host=${ihostname}"
|
||||
eval idatabase='${database_'${name}':-${database}}'
|
||||
eval iusername='${username_'${name}':-${username}}'
|
||||
[ -n "${iusername}" ] && opts="${opts} --user=${iusername}"
|
||||
eval ipassword='${password_'${name}':-${password}}'
|
||||
[ -n "${ipassword}" ] && opts="${opts} --password=${ipassword}"
|
||||
eval ierrorvalue='${errorvalue_'${name}':-${errorvalue}}'
|
||||
eval imysqlopts='${mysqlopts_'${name}':-${mysqlopts}}'
|
||||
iquery=$(echo "${iquery}" | tr '\n\r' ' ')
|
||||
#echo "The command to be executed: echo \"${iquery}\" | ${mysqlbin} ${imysqlopts} --batch --skip-column-names ${opts} ${idatabase} 2>&1"
|
||||
output=$(echo "${iquery}" | ${mysqlbin} ${imysqlopts} --batch --skip-column-names ${opts} ${idatabase} 2>&1)
|
||||
if [ $? -ne 0 -a ${ierrorvalue} -ne 0 ]; then
|
||||
result=${ierrorvalue}
|
||||
else
|
||||
result=$(echo "${output}" | head -n 1 | sed 's/^\([0-9]\+\).*/\1/')
|
||||
fi
|
||||
echo "result${I}.value ${result}"
|
||||
I=$((I+1))
|
||||
fi
|
||||
done
|
||||
|
||||
|
157
plugins/mysql/mysql_size_
Executable file
157
plugins/mysql/mysql_size_
Executable file
|
@ -0,0 +1,157 @@
|
|||
#!/usr/bin/perl
|
||||
#
|
||||
# Copyright (C) 2007 - Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
# Copyright (C) 2003-2004 - Andreas Buer
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; version 2 dated June,
|
||||
# 1991.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# $Log$
|
||||
# Revision 1.1 2007/01/17 10:41:01 rodo
|
||||
# Change incorrect family
|
||||
#
|
||||
# Revision 1.0 2007/01/16 15:57:01 rodo
|
||||
# Created by Rodolphe Quiedeville
|
||||
#
|
||||
# Parameters:
|
||||
#
|
||||
# config
|
||||
# autoconf
|
||||
#
|
||||
# Configuration variables
|
||||
#
|
||||
# mysqlopts - Options to pass to mysql
|
||||
# mysqladmin - Override location of mysqladmin
|
||||
#
|
||||
#%# family=manual
|
||||
#%# capabilities=autoconf
|
||||
|
||||
use strict;
|
||||
|
||||
unless ($0 =~ /mysql_size(?:_([^_]+)|)_(.+)\s*$/)
|
||||
{
|
||||
die "Could not parse name $0.\n";
|
||||
}
|
||||
my $db = $2;
|
||||
|
||||
my $MYSQLADMIN = $ENV{mysqladmin} || "mysql";
|
||||
|
||||
my %WANTED = ( "Index" => "index",
|
||||
"Datas" => "datas",
|
||||
);
|
||||
|
||||
my $arg = shift();
|
||||
|
||||
if ($arg eq 'config') {
|
||||
print_config();
|
||||
exit();
|
||||
} elsif ($arg eq 'autoconf') {
|
||||
unless (test_service() ) {
|
||||
print "yes\n";
|
||||
} else {
|
||||
print "no\n";
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
my $datas = 0;
|
||||
my $indexes = 0;
|
||||
my (@infos,$info,$i_data,$i_index);
|
||||
|
||||
my $COMMAND = "$MYSQLADMIN $ENV{mysqlopts} $db -e 'show table status;' | grep 'Data'";
|
||||
|
||||
open(SERVICE, "$COMMAND |")
|
||||
or die("Coult not execute '$COMMAND': $!");
|
||||
|
||||
while (<SERVICE>) {
|
||||
(@infos) = split;
|
||||
}
|
||||
close(SERVICE);
|
||||
|
||||
my $i = 0;
|
||||
foreach $info (@infos) {
|
||||
$i++;
|
||||
if ($info eq 'Data_length') {
|
||||
$i_data = $i;
|
||||
next;
|
||||
}
|
||||
if ($info eq 'Index_length') {
|
||||
$i_index = $i;
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
$COMMAND = "$MYSQLADMIN $ENV{mysqlopts} $db -e 'show table status;' | cut -f $i_data,$i_index | grep -v leng";
|
||||
|
||||
open(SERVICE, "$COMMAND |")
|
||||
or die("Coult not execute '$COMMAND': $!");
|
||||
|
||||
while (<SERVICE>) {
|
||||
(m/(\d+).*?(\d+(?:\.\d+)?)/);
|
||||
$datas += $1;
|
||||
$indexes += $2;
|
||||
}
|
||||
close(SERVICE);
|
||||
|
||||
print("datas.value $datas\n");
|
||||
print("index.value $indexes\n");
|
||||
|
||||
|
||||
sub print_config {
|
||||
|
||||
my $num = 0;
|
||||
|
||||
print("graph_title MySQL database $db size\n");
|
||||
print ('graph_args --base 1024 -l 0
|
||||
graph_vlabel bytes
|
||||
graph_category mysql
|
||||
graph_info Plugin available at <a href="http://rodolphe.quiedeville.org/hack/munin/">http://rodolphe.quiedeville.org/hack/munin/</a>
|
||||
');
|
||||
|
||||
for my $key (keys %WANTED) {
|
||||
my $title = $WANTED{$key};
|
||||
print("$title.label ${title}\n",
|
||||
"$title.min 0\n",
|
||||
"$title.type GAUGE\n",
|
||||
"$title.draw ", ($num) ? "STACK" : "AREA" , "\n",
|
||||
);
|
||||
$num++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sub test_service {
|
||||
|
||||
my $return = 1;
|
||||
|
||||
system ("$MYSQLADMIN --version >/dev/null 2>/dev/null");
|
||||
if ($? == 0)
|
||||
{
|
||||
system ("$COMMAND >/dev/null 2>/dev/null");
|
||||
if ($? == 0)
|
||||
{
|
||||
print "yes\n";
|
||||
$return = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
print "no (could not connect to mysql)\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print "no (mysqladmin not found)\n";
|
||||
}
|
||||
exit $return;
|
||||
}
|
179
plugins/mysql/mysql_size_all
Executable file
179
plugins/mysql/mysql_size_all
Executable file
|
@ -0,0 +1,179 @@
|
|||
#!/usr/bin/perl
|
||||
#
|
||||
# Copyright (C) 2007 - Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
# Copyright (C) 2003-2004 - Andreas Buer
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; version 2 dated June,
|
||||
# 1991.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# $Log$
|
||||
# Revision 1.1 2007/01/17 10:41:01 rodo
|
||||
# Change incorrect family
|
||||
#
|
||||
# Revision 1.0 2007/01/16 15:57:01 rodo
|
||||
# Created by Rodolphe Quiedeville
|
||||
#
|
||||
# Parameters:
|
||||
#
|
||||
# config
|
||||
# autoconf
|
||||
#
|
||||
# Configuration variables
|
||||
#
|
||||
# mysqlopts - Options to pass to mysql
|
||||
# mysqladmin - Override location of mysqladmin
|
||||
#
|
||||
#%# family=manual
|
||||
#%# capabilities=autoconf
|
||||
|
||||
use strict;
|
||||
|
||||
# unless ($0 =~ /mysql_size(?:_([^_]+)|)_(.+)\s*$/)
|
||||
# {
|
||||
# die "Could not parse name $0.\n";
|
||||
# }
|
||||
# my $db = $2;
|
||||
|
||||
my $COMMAND;
|
||||
my $MYSQLADMIN = $ENV{mysqladmin} || "mysql";
|
||||
|
||||
my %WANTED = ( "Index" => "index",
|
||||
"Datas" => "datas",
|
||||
);
|
||||
|
||||
my $arg = shift();
|
||||
|
||||
if ($arg eq 'config') {
|
||||
print_config();
|
||||
exit();
|
||||
} elsif ($arg eq 'autoconf') {
|
||||
unless (test_service() ) {
|
||||
print "yes\n";
|
||||
} else {
|
||||
print "no\n";
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
sub getDBList;
|
||||
foreach my $db (getDBList()) {
|
||||
|
||||
my $datas = 0;
|
||||
my $indexes = 0;
|
||||
my (@infos,$info,$i_data,$i_index);
|
||||
|
||||
$COMMAND = "$MYSQLADMIN $ENV{mysqlopts} $db -e 'show table status;' | head -n 1";
|
||||
|
||||
open(SERVICE, "$COMMAND |")
|
||||
or die("Coult not execute '$COMMAND': $!");
|
||||
|
||||
while (<SERVICE>) {
|
||||
(@infos) = split;
|
||||
}
|
||||
close(SERVICE);
|
||||
|
||||
my $i = 0;
|
||||
foreach $info (@infos) {
|
||||
$i++;
|
||||
if ($info eq 'Data_length') {
|
||||
$i_data = $i;
|
||||
next;
|
||||
}
|
||||
if ($info eq 'Index_length') {
|
||||
$i_index = $i;
|
||||
last;
|
||||
}
|
||||
}
|
||||
my $total_size = 0;
|
||||
if ($i_data>0 && $i_index>0) {
|
||||
$COMMAND = "$MYSQLADMIN $ENV{mysqlopts} $db -e 'show table status;' | cut -f $i_data,$i_index | grep -v leng";
|
||||
|
||||
open(SERVICE, "$COMMAND |")
|
||||
or die("Coult not execute '$COMMAND': $!");
|
||||
|
||||
while (<SERVICE>) {
|
||||
(m/(\d+).*?(\d+(?:\.\d+)?)/);
|
||||
$datas += $1;
|
||||
$indexes += $2;
|
||||
}
|
||||
close(SERVICE);
|
||||
|
||||
$total_size = $datas+$indexes;
|
||||
}
|
||||
print("$db.value $total_size\n");
|
||||
# print("datas.value $datas\n");
|
||||
# print("index.value $indexes\n");
|
||||
}
|
||||
|
||||
|
||||
sub print_config {
|
||||
|
||||
my $num = 0;
|
||||
|
||||
my @dbs = getDBList;
|
||||
|
||||
print("graph_title MySQL databases size\n");
|
||||
print ('graph_args --base 1024 -l 0
|
||||
graph_vlabel bytes
|
||||
graph_category mysql
|
||||
graph_info Plugin available at <a href="http://rodolphe.quiedeville.org/hack/munin/">http://rodolphe.quiedeville.org/hack/munin/</a>
|
||||
');
|
||||
|
||||
for my $db (@dbs) {
|
||||
my $title = "$db";
|
||||
print("$title.label ${title}\n",
|
||||
"$title.min 0\n",
|
||||
"$title.type GAUGE\n",
|
||||
"$title.draw ", ($num) ? "STACK" : "AREA" , "\n",
|
||||
);
|
||||
$num++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sub test_service {
|
||||
|
||||
my $return = 1;
|
||||
|
||||
system ("$MYSQLADMIN --version >/dev/null 2>/dev/null");
|
||||
if ($? == 0)
|
||||
{
|
||||
system ("$COMMAND >/dev/null 2>/dev/null");
|
||||
if ($? == 0)
|
||||
{
|
||||
print "yes\n";
|
||||
$return = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
print "no (could not connect to mysql)\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print "no (mysqladmin not found)\n";
|
||||
}
|
||||
exit $return;
|
||||
}
|
||||
|
||||
sub getDBList {
|
||||
my @dbs;
|
||||
foreach my $f (glob("/var/lib/mysql/*")) {
|
||||
if (-d $f) {
|
||||
$f =~ s!.*/!!;
|
||||
@dbs[$#dbs+1]=$f };
|
||||
}
|
||||
return @dbs;
|
||||
}
|
||||
|
139
plugins/mysql/mysql_slave
Executable file
139
plugins/mysql/mysql_slave
Executable file
|
@ -0,0 +1,139 @@
|
|||
#!/usr/bin/perl
|
||||
#
|
||||
# Copyright (C) 2008 - Nathan Haneysmith <nathan@hjksolutions.com>
|
||||
# Copyright (C) 2007 - Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
# Copyright (C) 2003-2004 - Andreas Buer
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; version 2 dated June,
|
||||
# 1991.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# $Log$
|
||||
# Revision 1.2 2008/06/18 Nathan Haneysmith
|
||||
# Massive rewrite to check and graph MySQL Slave status
|
||||
#
|
||||
# Revision 1.1 2007/01/17 10:41:01 rodo
|
||||
# Change incorrect family
|
||||
#
|
||||
# Revision 1.0 2007/01/16 15:57:01 rodo
|
||||
# Created by Rodolphe Quiedeville
|
||||
#
|
||||
# Parameters:
|
||||
#
|
||||
# config
|
||||
# autoconf
|
||||
#
|
||||
# Configuration variables
|
||||
#
|
||||
# mysqlopts - Options to pass to mysql
|
||||
# mysqladmin - Override location of mysqladmin
|
||||
#
|
||||
#%# family=manual
|
||||
#%# capabilities=autoconf
|
||||
|
||||
use strict;
|
||||
|
||||
my $MYSQLADMIN = $ENV{mysqladmin} || "mysql";
|
||||
my $MYSQLOPTS = $ENV{mysqlopts} || "";
|
||||
|
||||
my %WANTED = ( "Seconds" => "seconds",
|
||||
);
|
||||
|
||||
my $arg = shift();
|
||||
|
||||
if ($arg eq 'config') {
|
||||
print_config();
|
||||
exit();
|
||||
} elsif ($arg eq 'autoconf') {
|
||||
unless (test_service() ) {
|
||||
print "yes\n";
|
||||
} else {
|
||||
print "no\n";
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
my $seconds = 0;
|
||||
my (@infos,$info,$i_seconds);
|
||||
|
||||
my $COMMAND = "$MYSQLADMIN $MYSQLOPTS -e 'show slave status;' | grep 'Slave'";
|
||||
|
||||
open(SERVICE, "$COMMAND |")
|
||||
or die("Coult not execute '$COMMAND': $!");
|
||||
|
||||
while (<SERVICE>) {
|
||||
(@infos) = split;
|
||||
}
|
||||
close(SERVICE);
|
||||
|
||||
my $i = 0;
|
||||
foreach $info (@infos) {
|
||||
$i++;
|
||||
if ($info eq 'Seconds_Behind_Master') {
|
||||
$i_seconds = $i;
|
||||
next;
|
||||
}
|
||||
}
|
||||
|
||||
$COMMAND = "$MYSQLADMIN $MYSQLOPTS -e 'show slave status;' | cut -f $i_seconds | grep -v leng";
|
||||
|
||||
open(SERVICE, "$COMMAND |")
|
||||
or die("Coult not execute '$COMMAND': $!");
|
||||
|
||||
while (<SERVICE>) {
|
||||
(m/(\d+).*?(\d+(?:\.\d+)?)/);
|
||||
$seconds += $1;
|
||||
}
|
||||
close(SERVICE);
|
||||
|
||||
print("seconds.value $seconds\n");
|
||||
|
||||
|
||||
sub print_config {
|
||||
|
||||
print "graph_title MySQL Slave Status\n";
|
||||
print "graph_args --base 1000 -l 0\n";
|
||||
print "graph_vlabel Seconds\n";
|
||||
print "graph_category mysql\n";
|
||||
print "seconds.label Seconds behind master\n";
|
||||
print "seconds.min 0\n";
|
||||
print "seconds.draw LINE2\n";
|
||||
print "graph_info Plugin available at <a href='http://oss.hjksolutions.com/munin/'>http://oss.hjksolutions.com/munin/</a>\n";
|
||||
|
||||
}
|
||||
|
||||
|
||||
sub test_service {
|
||||
|
||||
my $return = 1;
|
||||
|
||||
system ("$MYSQLADMIN --version >/dev/null 2>/dev/null");
|
||||
if ($? == 0)
|
||||
{
|
||||
system ("$COMMAND >/dev/null 2>/dev/null");
|
||||
if ($? == 0)
|
||||
{
|
||||
print "yes\n";
|
||||
$return = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
print "no (could not connect to mysql)\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print "no (mysqladmin not found)\n";
|
||||
}
|
||||
exit $return;
|
||||
}
|
49
plugins/mysql/mysql_slave_threads
Executable file
49
plugins/mysql/mysql_slave_threads
Executable file
|
@ -0,0 +1,49 @@
|
|||
#!/usr/bin/perl
|
||||
# Munin plugin for MySQL slave threads monitoring
|
||||
# Copyright © 2009 Eutech SSII
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# Plugin producing state graphes for a MySQL slave server (1 if
|
||||
# I/O or SQL thread is running, 0 otherwise). Can be used to
|
||||
# trigger a warning when a replication failure occurs.
|
||||
|
||||
use strict;
|
||||
|
||||
my $MYSQL = $ENV{mysql} || "mysql";
|
||||
my $MYSQLOPTS = $ENV{mysqlopts} || "";
|
||||
|
||||
if(defined $ARGV[0] && $ARGV[0] eq 'config') {
|
||||
print <<EOC
|
||||
graph_title MySQL Slave Threads
|
||||
graph_vlabel Running
|
||||
graph_category mysql
|
||||
graph_args -l 0
|
||||
io.label I/O Thread
|
||||
io.critical 1:1
|
||||
sql.label SQL Thread
|
||||
sql.critical 1:1
|
||||
EOC
|
||||
;
|
||||
exit 0;
|
||||
}
|
||||
|
||||
my $status = `$MYSQL $MYSQLOPTS -e 'SHOW SLAVE STATUS\\G'`;
|
||||
|
||||
$status =~ /Slave_IO_Running: (\w+)/;
|
||||
print 'io.value '.($1 eq 'Yes' ? 1 : 0)."\n";
|
||||
$status =~ /Slave_SQL_Running: (\w+)/;
|
||||
print 'sql.value '.($1 eq 'Yes' ? 1 : 0)."\n";
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue