2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00

Initial version

This commit is contained in:
Rodolphe Quiedeville 2007-01-17 10:27:17 +01:00 committed by Steve Schnepp
parent 01e5fd7e7c
commit 6f148b7cb6

123
plugins/other/mysql_qcache Executable file
View 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;
}