3
# $Id: mysql_queries.in,v 1.5 2004/04/27 18:58:53 jimmyo Exp $
5
# Copyright 2003-2004 - Per Andreas Buer
7
# $Log: mysql_queries.in,v $
8
# Revision 1.5 2004/04/27 18:58:53 jimmyo
9
# Fixed bug in mysql-plugins (Deb#233762).
11
# Revision 1.4 2004/01/29 18:49:55 jimmyo
12
# Bugfix in plugin mysql_queries - insertions were no longer graphed. (SF#881483).
14
# Revision 1.3 2004/01/29 17:36:20 jimmyo
15
# Updated copyright information
17
# Revision 1.2 2004/01/15 16:35:43 jimmyo
18
# Bugfix from Dagfinn I. Manns�ker, closing SF#876443, SF#865125.
20
# Revision 1.1 2004/01/02 18:50:00 jimmyo
21
# Renamed occurrances of lrrd -> munin
23
# Revision 1.1.1.1 2004/01/02 15:18:07 jimmyo
24
# Import of LRRD CVS tree after renaming to Munin
26
# Revision 1.8 2003/12/01 13:31:37 jimmyo
27
# Bugfix to make stack/area right
29
# Revision 1.7 2003/11/08 00:10:13 jimmyo
30
# New mysql_queries plugin
38
# Configuration variables
40
# mysqlopts - Options to pass to mysql
41
# mysqladmin - Override location of mysqladmin
44
#%# capabilities=autoconf
48
my $MYSQLADMIN = $ENV{mysqladmin} || "mysqladmin";
49
my $COMMAND = "$MYSQLADMIN $ENV{mysqlopts} extended-status";
52
my %WANTED = ( "Com_delete" => "delete",
53
"Com_insert" => "insert",
54
"Com_select" => "select",
55
"Com_update" => "update",
56
"Com_replace" => "replace",
57
"Qcache_hits" => "cache_hits",
62
if ($arg eq 'config') {
65
} elsif ($arg eq 'autoconf') {
66
unless (test_service() ) {
75
open(SERVICE, "$COMMAND |")
76
or die("Coult not execute '$COMMAND': $!");
79
my ($k, $v) = (m/(\w+).*?(\d+(?:\.\d+)?)/);
81
if (exists $WANTED{$k} ) {
82
print("$WANTED{$k}.value $v\n");
93
print("graph_title MySQL queries
94
graph_args --base 1000
95
graph_vlabel queries / sec
96
graph_total total\n");
98
for my $key (keys %WANTED) {
99
my $title = $WANTED{$key};
100
print("$title.label ${title}\n",
101
"$title.type COUNTER\n",
102
"$title.max 500000\n",
103
"$title.draw ", ($num) ? "STACK" : "AREA" , "\n",
115
system ("$MYSQLADMIN --version >/dev/null 2>/dev/null");
118
system ("$COMMAND >/dev/null 2>/dev/null");
126
print "no (could not connect to mysql)\n";
131
print "no (mysqadmin not found)\n";