[-]
[+]
|
Added |
nagios-plugins-mysql-health.changes
|
|
[-]
[+]
|
Changed |
nagios-plugins-mysql-health.spec
^
|
|
[-]
[+]
|
Changed |
check_mysql_health-2.1.7.tar.bz2/ChangeLog
^
|
@@ -2,6 +2,16 @@
# Changelog of the check_mysql_health plugin #
###############################################
+2.1.7 2011-08-23
+- innodb modes now detect problems with the innodb engine
+
+2.1.6 2011-08-12
+- fix a bug with statefilesdir and capital letters
+- add --labelformat so that groundwork no longer complains (max label length is 19 characters)
+
+2.1.5.2 2011-06-03
+- sites in an OMD (http://omdistro.org) environment have now private statefile directories
+
2.1.5.1 2011-01-03
- bugfix in --mode sql (numeric vs. regexp result)
|
[-]
[+]
|
Changed |
check_mysql_health-2.1.7.tar.bz2/configure
^
|
@@ -1,7 +1,7 @@
#! /bin/sh
# From configure.in .
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.59 for check_mysql_health 2.1.5.1.
+# Generated by GNU Autoconf 2.59 for check_mysql_health 2.1.7.
#
# Copyright (C) 2003 Free Software Foundation, Inc.
# This configure script is free software; the Free Software Foundation
@@ -268,8 +268,8 @@
# Identity of this package.
PACKAGE_NAME='check_mysql_health'
PACKAGE_TARNAME='check_mysql_health'
-PACKAGE_VERSION='2.1.5.1'
-PACKAGE_STRING='check_mysql_health 2.1.5.1'
+PACKAGE_VERSION='2.1.7'
+PACKAGE_STRING='check_mysql_health 2.1.7'
PACKAGE_BUGREPORT=''
ac_default_prefix=/usr/local/nagios
@@ -722,7 +722,7 @@
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures check_mysql_health 2.1.5.1 to adapt to many kinds of systems.
+\`configure' configures check_mysql_health 2.1.7 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -788,7 +788,7 @@
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of check_mysql_health 2.1.5.1:";;
+ short | recursive ) echo "Configuration of check_mysql_health 2.1.7:";;
esac
cat <<\_ACEOF
@@ -897,7 +897,7 @@
test -n "$ac_init_help" && exit 0
if $ac_init_version; then
cat <<\_ACEOF
-check_mysql_health configure 2.1.5.1
+check_mysql_health configure 2.1.7
generated by GNU Autoconf 2.59
Copyright (C) 2003 Free Software Foundation, Inc.
@@ -911,7 +911,7 @@
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by check_mysql_health $as_me 2.1.5.1, which was
+It was created by check_mysql_health $as_me 2.1.7, which was
generated by GNU Autoconf 2.59. Invocation command line was
$ $0 $@
@@ -1554,7 +1554,7 @@
# Define the identity of the package.
PACKAGE='check_mysql_health'
- VERSION='2.1.5.1'
+ VERSION='2.1.7'
cat >>confdefs.h <<_ACEOF
@@ -2725,7 +2725,7 @@
} >&5
cat >&5 <<_CSEOF
-This file was extended by check_mysql_health $as_me 2.1.5.1, which was
+This file was extended by check_mysql_health $as_me 2.1.7, which was
generated by GNU Autoconf 2.59. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -2780,7 +2780,7 @@
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
-check_mysql_health config.status 2.1.5.1
+check_mysql_health config.status 2.1.7
configured by $0, generated by GNU Autoconf 2.59,
with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
|
[-]
[+]
|
Changed |
check_mysql_health-2.1.7.tar.bz2/configure.in
^
|
@@ -1,7 +1,7 @@
dnl Process this file with autoconf to produce a configure script.
AC_REVISION ($Revision: 1.150 $)
AC_PREREQ(2.58)
-AC_INIT(check_mysql_health,2.1.5.1)
+AC_INIT(check_mysql_health,2.1.7)
AM_INIT_AUTOMAKE([1.9 tar-pax])
AC_CANONICAL_HOST
|
[-]
[+]
|
Changed |
check_mysql_health-2.1.7.tar.bz2/plugins-scripts/Nagios/DBD/MySQL/Server.pm
^
|
@@ -48,6 +48,7 @@
criticalrange => $params{criticalrange},
verbose => $params{verbose},
report => $params{report},
+ labelformat => $params{labelformat},
version => 'unknown',
instance => undef,
handle => undef,
@@ -362,6 +363,7 @@
sub calculate_result {
my $self = shift;
+ my $labels = shift || {};
my $multiline = 0;
map {
$self->{nagios_level} = $ERRORS{$_} if
@@ -403,7 +405,25 @@
} elsif ($self->{report} eq "html") {
$self->{nagios_message} .= $all_messages_short."\n".$all_messages_html;
}
- $self->{perfdata} = join(" ", @{$self->{nagios}->{perfdata}});
+ if ($self->{labelformat} eq "pnp4nagios") {
+ $self->{perfdata} = join(" ", @{$self->{nagios}->{perfdata}});
+ } else {
+ $self->{perfdata} = join(" ", map {
+ my $perfdata = $_;
+ if ($perfdata =~ /^(.*?)=(.*)/) {
+ my $label = $1;
+ my $data = $2;
+ if (exists $labels->{$label} &&
+ exists $labels->{$label}->{$self->{labelformat}}) {
+ $labels->{$label}->{$self->{labelformat}}."=".$data;
+ } else {
+ $perfdata;
+ }
+ } else {
+ $perfdata;
+ }
+ } @{$self->{nagios}->{perfdata}});
+ }
}
sub set_global_db_thresholds {
@@ -572,9 +592,30 @@
my $self = shift;
my %params = @_;
my $extension = "";
- mkdir $params{statefilesdir} unless -d $params{statefilesdir};
- my $statefile = sprintf "%s/%s_%s",
- $params{statefilesdir}, $params{hostname}, $params{mode};
+ my $mode = $params{mode};
+ if ($params{connect} && $params{connect} =~ /(\w+)\/(\w+)@(\w+)/) {
+ $params{connect} = $3;
+ } elsif ($params{connect}) {
+ # just to be sure
+ $params{connect} =~ s/\//_/g;
+ }
+ if ($^O =~ /MSWin/) {
+ $mode =~ s/::/_/g;
+ $params{statefilesdir} = $self->system_vartmpdir();
+ }
+ if (! -d $params{statefilesdir}) {
+ eval {
+ use File::Path;
+ mkpath $params{statefilesdir};
+ };
+ }
+ if ($@ || ! -w $params{statefilesdir}) {
+ $self->add_nagios($ERRORS{CRITICAL},
+ sprintf "statefilesdir %s does not exist or is not writable\n",
+ $params{statefilesdir});
+ return;
+ }
+ my $statefile = sprintf "%s_%s", $params{hostname}, $mode;
$extension .= $params{differenciator} ? "_".$params{differenciator} : "";
$extension .= $params{socket} ? "_".$params{socket} : "";
$extension .= $params{port} ? "_".$params{port} : "";
@@ -589,12 +630,17 @@
$extension =~ s/\s/_/g;
$statefile .= $extension;
$statefile = lc $statefile;
- open(STATE, ">$statefile");
- if ((ref($params{save}) eq "HASH") && exists $params{save}->{timestamp}) {
- $params{save}->{localtime} = scalar localtime $params{save}->{timestamp};
+ $statefile = sprintf "%s/%s", $params{statefilesdir}, $statefile;
+ if (open(STATE, ">$statefile")) {
+ if ((ref($params{save}) eq "HASH") && exists $params{save}->{timestamp}) {
+ $params{save}->{localtime} = scalar localtime $params{save}->{timestamp};
+ }
+ printf STATE Data::Dumper::Dumper($params{save});
+ close STATE;
+ } else {
+ $self->add_nagios($ERRORS{CRITICAL},
+ sprintf "statefile %s is not writable", $statefile);
}
- printf STATE Data::Dumper::Dumper($params{save});
- close STATE;
$self->debug(sprintf "saved %s to %s",
Data::Dumper::Dumper($params{save}), $statefile);
}
@@ -603,8 +649,18 @@
my $self = shift;
my %params = @_;
my $extension = "";
- my $statefile = sprintf "%s/%s_%s",
- $params{statefilesdir}, $params{hostname}, $params{mode};
+ my $mode = $params{mode};
+ if ($params{connect} && $params{connect} =~ /(\w+)\/(\w+)@(\w+)/) {
+ $params{connect} = $3;
+ } elsif ($params{connect}) {
+ # just to be sure
+ $params{connect} =~ s/\//_/g;
+ }
+ if ($^O =~ /MSWin/) {
+ $mode =~ s/::/_/g;
+ $params{statefilesdir} = $self->system_vartmpdir();
+ }
+ my $statefile = sprintf "%s_%s", $params{hostname}, $mode;
$extension .= $params{differenciator} ? "_".$params{differenciator} : "";
$extension .= $params{socket} ? "_".$params{socket} : "";
$extension .= $params{port} ? "_".$params{port} : "";
@@ -619,13 +675,15 @@
$extension =~ s/\s/_/g;
$statefile .= $extension;
$statefile = lc $statefile;
+ $statefile = sprintf "%s/%s", $params{statefilesdir}, $statefile;
if ( -f $statefile) {
our $VAR1;
eval {
require $statefile;
};
if($@) {
-printf "rumms\n";
+ $self->add_nagios($ERRORS{CRITICAL},
+ sprintf "statefile %s is corrupt", $statefile);
}
$self->debug(sprintf "load %s", Data::Dumper::Dumper($VAR1));
return $VAR1;
|
[-]
[+]
|
Changed |
check_mysql_health-2.1.7.tar.bz2/plugins-scripts/Nagios/DBD/MySQL/Server/Instance/Innodb.pm
^
|
@@ -58,6 +58,7 @@
bufferpool_hitrate => undef,
wait_free => undef,
log_waits => undef,
+ have_innodb => undef,
warningrange => $params{warningrange},
criticalrange => $params{criticalrange},
};
@@ -73,7 +74,15 @@
my $dummy;
$self->debug("enter init");
$self->init_nagios();
- if ($params{mode} =~ /server::instance::innodb::bufferpool::hitrate/) {
+ ($dummy, $self->{have_innodb})
+ = $self->{handle}->fetchrow_array(q{
+ SHOW VARIABLES LIKE 'have_innodb'
+ });
+ if ($self->{have_innodb} eq "NO") {
+ $self->add_nagios_critical("the innodb engine has a problem (have_innodb=no)");
+ } elsif ($self->{have_innodb} eq "DISABLED") {
+ # add_nagios_ok later
+ } elsif ($params{mode} =~ /server::instance::innodb::bufferpool::hitrate/) {
($dummy, $self->{bufferpool_reads})
= $self->{handle}->fetchrow_array(q{
SHOW /*!50000 global */ STATUS LIKE 'Innodb_buffer_pool_reads'
@@ -136,7 +145,9 @@
my $self = shift;
my %params = @_;
my $now = $params{lookback} ? '_now' : '';
- if (! $self->{nagios_level}) {
+ if ($self->{have_innodb} eq "DISABLED") {
+ $self->add_nagios_ok("the innodb engine has been disabled");
+ } elsif (! $self->{nagios_level}) {
if ($params{mode} =~ /server::instance::innodb::bufferpool::hitrate/) {
my $refkey = 'bufferpool_hitrate'.($params{lookback} ? '_now' : '');
$self->add_nagios(
|
[-]
[+]
|
Changed |
check_mysql_health-2.1.7.tar.bz2/plugins-scripts/check_mysql_health.pl
^
|
@@ -108,6 +108,67 @@
'any sql command returning a single number' ],
);
+# rrd data store names are limited to 19 characters
+my %labels = (
+ bufferpool_hitrate => {
+ groundwork => 'bp_hitrate',
+ },
+ bufferpool_hitrate_now => {
+ groundwork => 'bp_hitrate_now',
+ },
+ bufferpool_free_waits_rate => {
+ groundwork => 'bp_freewaits',
+ },
+ innodb_log_waits_rate => {
+ groundwork => 'inno_log_waits',
+ },
+ keycache_hitrate => {
+ groundwork => 'kc_hitrate',
+ },
+ keycache_hitrate_now => {
+ groundwork => 'kc_hitrate_now',
+ },
+ threads_created_per_sec => {
+ groundwork => 'thrds_creat_per_s',
+ },
+ connects_aborted_per_sec => {
+ groundwork => 'conn_abrt_per_s',
+ },
+ clients_aborted_per_sec => {
+ groundwork => 'clnt_abrt_per_s',
+ },
+ thread_cache_hitrate => {
+ groundwork => 'tc_hitrate',
+ },
+ thread_cache_hitrate_now => {
+ groundwork => 'tc_hitrate_now',
+ },
+ qcache_lowmem_prunes_rate => {
+ groundwork => 'qc_lowm_prnsrate',
+ },
+ slow_queries_rate => {
+ groundwork => 'slow_q_rate',
+ },
+ tablecache_hitrate => {
+ groundwork => 'tac_hitrate',
+ },
+ tablecache_fillrate => {
+ groundwork => 'tac_fillrate',
+ },
+ tablelock_contention => {
+ groundwork => 'tl_contention',
+ },
+ tablelock_contention_now => {
+ groundwork => 'tl_contention_now',
+ },
+ pct_tmp_table_on_disk => {
+ groundwork => 'tmptab_on_disk',
+ },
+ pct_tmp_table_on_disk_now => {
+ groundwork => 'tmptab_on_disk_now',
+ },
+);
+
sub print_usage () {
print <<EOUS;
Usage:
@@ -160,6 +221,9 @@
--units
one of %, KB, MB, GB. This is used for a better output of mode=sql
and for specifying thresholds for mode=tablespace-free
+ --labelformat
+ one of pnp4nagios (which is the default) or groundwork.
+ It is used to shorten performance data labels to 19 characters.
In mode sql you can url-encode the statement so you will not have to mess
around with special characters in your Nagios service definitions.
@@ -250,8 +314,10 @@
"units=s",
"lookback=i",
"3",
+ "statefilesdir=s",
"with-mymodules-dyn-dir=s",
"report=s",
+ "labelformat=s",
"extra-opts:s");
if (! GetOptions(\%commandline, @params)) {
@@ -321,6 +387,12 @@
$commandline{report} = "long";
}
+if (exists $commandline{labelformat}) {
+ # groundwork
+} else {
+ $commandline{labelformat} = "pnp4nagios";
+}
+
if (exists $commandline{'with-mymodules-dyn-dir'}) {
$DBD::MySQL::Server::my_modules_dyn_dir = $commandline{'with-mymodules-dyn-dir'};
} else {
@@ -402,6 +474,14 @@
system("/bin/sh");
}
+if (! exists $commandline{statefilesdir}) {
+ if (exists $ENV{OMD_ROOT}) {
+ $commandline{statefilesdir} = $ENV{OMD_ROOT}."/var/tmp/check_mysql_health";
+ } else {
+ $commandline{statefilesdir} = $STATEFILESDIR;
+ }
+}
+
if (exists $commandline{name}) {
# objects can be encoded like an url
# with s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
@@ -479,9 +559,10 @@
units => $commandline{units},
lookback => $commandline{lookback} || 0,
eyecandy => $commandline{eyecandy},
- statefilesdir => $STATEFILESDIR,
+ statefilesdir => $commandline{statefilesdir},
verbose => $commandline{verbose},
report => $commandline{report},
+ labelformat => $commandline{labelformat},
);
my $server = undef;
@@ -490,14 +571,14 @@
if ($params{mode} =~ /^(server|my)/) {
$server = DBD::MySQL::Server->new(%params);
$server->nagios(%params);
- $server->calculate_result();
+ $server->calculate_result(\%labels);
$nagios_message = $server->{nagios_message};
$nagios_level = $server->{nagios_level};
$perfdata = $server->{perfdata};
} elsif ($params{mode} =~ /^cluster/) {
$cluster = DBD::MySQL::Cluster->new(%params);
$cluster->nagios(%params);
- $cluster->calculate_result();
+ $cluster->calculate_result(\%labels);
$nagios_message = $cluster->{nagios_message};
$nagios_level = $cluster->{nagios_level};
$perfdata = $cluster->{perfdata};
|