From 0b6423f9c99d9edf8c96fefd0f6c453859395aa1 Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Mon, 30 Sep 2013 00:03:24 +0200 Subject: Import Nagios Plugins site Import the Nagios Plugins web site, Cronjobs, infrastructure scripts, and configuration files. --- .../421612-check_mysql_performance.patch | 111 +++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 web/attachments/421612-check_mysql_performance.patch (limited to 'web/attachments/421612-check_mysql_performance.patch') diff --git a/web/attachments/421612-check_mysql_performance.patch b/web/attachments/421612-check_mysql_performance.patch new file mode 100644 index 0000000..79945e5 --- /dev/null +++ b/web/attachments/421612-check_mysql_performance.patch @@ -0,0 +1,111 @@ +diff --git a/libexec/check_mysql_performance b/libexec/check_mysql_performance +index 9a7e0a5..0e59d35 100755 +--- a/libexec/check_mysql_performance ++++ b/libexec/check_mysql_performance +@@ -11,9 +11,9 @@ use Nagios::Plugin; + + my $np = Nagios::Plugin->new( + 'usage' => < '1.00', ++ 'version' => '1.10', + 'url' => 'http://www.capside.com', + 'extra' => < qq{Copyright (c) CAPSiDE. +- +-This plugin montitors the % use of CPU usage on Linux systems for various types of CPU usage. + EOH + ); + + $np->add_arg( + spec => 'perfdata=s', + help => < 0, + ); +@@ -108,7 +107,8 @@ $SIG{'ALRM'} = sub { + $np->nagios_exit( CRITICAL, 'ERROR: Timed out.' ); + }; + +-my ( $code, $message ) = ( OK, 'All parameters OK' ); ++my ( $code, $message ) = ( undef, undef ); ++$np->add_message( OK, "All parameters OK" ); + + my @fields; + if ( not $np->opts->perfdata ) { +@@ -116,30 +116,50 @@ if ( not $np->opts->perfdata ) { + } + else { + @fields = split( /,/, $np->opts->perfdata ); +- +- # @fields = split /,/, join ',', @{$np->opts->perfdata}; + } + + # Add all performance data ++my $thresholds; ++my $value; ++my $warning; ++my $critical; ++my $minimum; ++my $maximum; + foreach my $key (@fields) { ++ if ( $key =~ /=/ ) { ++ ($key, $thresholds) = split( /=/, $key ); ++ ($warning, $critical) = split ( /;/, $thresholds ); ++ } else { ++ $thresholds = undef; ++ $warning = undef; ++ $critical = undef; ++ } + if ( $mysql->{'stats'}->{$key}->{'type'} eq 'ABS' ) { + next if ( not defined $read_data->{$key} ); +- $np->add_perfdata( +- 'label' => $key, +- 'value' => $read_data->{$key}, +- 'uom' => '', +- ); +- } +- elsif ( $mysql->{'stats'}->{$key}->{'type'} eq 'DERIVE' ) { ++ $value = $read_data->{$key}; ++ } elsif ( $mysql->{'stats'}->{$key}->{'type'} eq 'DERIVE' ) { + next if ( not defined $stat->{$key} ); +- $np->add_perfdata( +- 'label' => $key, +- 'value' => $stat->{$key}, +- 'uom' => '', ++ $value = $stat->{$key}; ++ } ++ $np->add_perfdata( ++ 'label' => $key, ++ 'value' => $value, ++ 'uom' => '', ++ 'warning' => $warning, ++ 'critical' => $critical, ++ ); ++ if ( $thresholds ) { ++ $code = $np->check_threshold( ++ 'check' => $value, ++ 'warning' => $warning, ++ 'critical' => $critical, + ); ++ if ( $code ) { ++ $np->add_message($code, "$key beyond thresholds,"); ++ } + } + } +- ++($code, $message) = $np->check_messages(); + $np->nagios_exit( $code, $message ); + + package MySQL::Stats; -- cgit v1.2.3-74-g34f1