This file is indexed.

/usr/share/munin/plugins/mysql_queries is in munin-node 1.4.6-3ubuntu3.4.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/usr/bin/perl
# -*- perl -*-

=head1 NAME

mysql_queries - Munin plugin to display MySQL query rate.

=head1 APPLICABLE SYSTEMS

Any MySQL platform

=head1 CONFIGURATION

  [mysql*]
     user root
     env.mysqlopts <options-for-mysqladmin-here>
     env.mysqladmin <optional-override-of-mysqladmin-path>

It is most usual that root must run the mysqladmin command.

Only use the .env settings if you need to override the defaults.

=head1 INTERPRETATION

To Be Written

=head1 BUGS

None known

=head1 AUTHOR

Copyright 2003-2008 - Per Andreas Buer

=head1 LICENSE

GPLv2

=head1 VERSION

  $Id: mysql_queries.in 2964 2009-11-12 02:28:47Z janl $

=head1 MAGIC MARKERS

  #%# family=manual
  #%# capabilities=autoconf

=cut

use strict;

my $MYSQLADMIN = $ENV{mysqladmin} || "mysqladmin";
my $COMMAND    = "$MYSQLADMIN $ENV{mysqlopts} extended-status";

my %WANTED = ( "Com_delete"  => "delete", 
			   "Com_insert"  => "insert",
               "Com_select"  => "select", 
               "Com_update"  => "update",
               "Com_replace" => "replace",
               "Qcache_hits" => "cache_hits",
             );

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 0;
}


open(SERVICE, "$COMMAND |")
  or die("Could 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
graph_args --base 1000
graph_vlabel queries / \${graph_period}
graph_category mysql
graph_info Note that this is a old plugin which is no longer installed by default.  It is retained for compatability with old installations.
graph_total total\n");

    for my $key (keys %WANTED) {
        my $title = $WANTED{$key};
        print("$title.label ${title}\n",
              "$title.min 0\n",
              "$title.type DERIVE\n",
              "$title.max 500000\n",
              "$title.draw ", ($num) ? "STACK" : "AREA" ,  "\n",
             );
        $num++;
    }
    
}


sub test_service {
    system ("$MYSQLADMIN --version >/dev/null 2>/dev/null");
    if ($? == 0)
    {
	system ("$COMMAND >/dev/null 2>/dev/null");
	if ($? == 0)
	{
	    print "yes\n";
	}
	else
	{
	    print "no (could not connect to mysql)\n";
	}
    }
    else
    {
	print "no (mysqladmin not found)\n";
    }
    exit 0;
}