wiki:PluginPortrait/mysql_status_
#!/usr/bin/perl

use strict;
use warnings;

use File::Basename;

my $variable = basename $0;
$variable =~ s/^mysql_status_//;
$variable or die "no variable";

if ($ARGV[0] && $ARGV[0] eq 'config') {
   print <<END;
graph_title MySQL $variable
graph_vlabel $variable
$variable.label $variable
END

   exit;
}

open(MYSQL, '/usr/bin/mysqladmin extended-status |') or die $!;

while (<MYSQL>) {
   my (undef, $name, undef, $value) = split;

   if ($name && $value && lc $name eq $variable) {
      printf("%s.value %d\n", $variable, $value);
      exit;
   }
}
Last modified at 2006-06-28T08:51:15+02:00 Last modified on 2006-06-28T08:51:15+02:00