diff options
Diffstat (limited to 'web/attachments/421612-check_mysql_performance.patch')
| -rw-r--r-- | web/attachments/421612-check_mysql_performance.patch | 111 |
1 files changed, 111 insertions, 0 deletions
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 @@ | |||
| 1 | diff --git a/libexec/check_mysql_performance b/libexec/check_mysql_performance | ||
| 2 | index 9a7e0a5..0e59d35 100755 | ||
| 3 | --- a/libexec/check_mysql_performance | ||
| 4 | +++ b/libexec/check_mysql_performance | ||
| 5 | @@ -11,9 +11,9 @@ use Nagios::Plugin; | ||
| 6 | |||
| 7 | my $np = Nagios::Plugin->new( | ||
| 8 | 'usage' => <<EOH, | ||
| 9 | -Usage: %s [-H host] [-d DSN] -u -p --group | ||
| 10 | +Usage: %s [-H host] [-d DSN] [--perfdata ] [[-u] [-p]|--extra-opts=[section][\@file]] --group | ||
| 11 | EOH | ||
| 12 | - 'version' => '1.00', | ||
| 13 | + 'version' => '1.10', | ||
| 14 | 'url' => 'http://www.capside.com', | ||
| 15 | 'extra' => <<EOH, | ||
| 16 | |||
| 17 | @@ -21,16 +21,15 @@ Threshold formats are specified at: | ||
| 18 | http://nagiosplug.sourceforge.net/developer-guidelines.html#THRESHOLDFORMAT | ||
| 19 | |||
| 20 | 'blurb' => qq{Copyright (c) CAPSiDE. | ||
| 21 | - | ||
| 22 | -This plugin montitors the % use of CPU usage on Linux systems for various types of CPU usage. | ||
| 23 | EOH | ||
| 24 | ); | ||
| 25 | |||
| 26 | $np->add_arg( | ||
| 27 | spec => 'perfdata=s', | ||
| 28 | help => <<EOH, | ||
| 29 | ---perfdata performance data to output | ||
| 30 | - Host to query | ||
| 31 | +--perfdata performance data to check and output | ||
| 32 | + e.g. metric[=warn_range;][critcal_range],metric,... | ||
| 33 | + note semicolons will need escaping when entered in the UI | ||
| 34 | EOH | ||
| 35 | required => 0, | ||
| 36 | ); | ||
| 37 | @@ -108,7 +107,8 @@ $SIG{'ALRM'} = sub { | ||
| 38 | $np->nagios_exit( CRITICAL, 'ERROR: Timed out.' ); | ||
| 39 | }; | ||
| 40 | |||
| 41 | -my ( $code, $message ) = ( OK, 'All parameters OK' ); | ||
| 42 | +my ( $code, $message ) = ( undef, undef ); | ||
| 43 | +$np->add_message( OK, "All parameters OK" ); | ||
| 44 | |||
| 45 | my @fields; | ||
| 46 | if ( not $np->opts->perfdata ) { | ||
| 47 | @@ -116,30 +116,50 @@ if ( not $np->opts->perfdata ) { | ||
| 48 | } | ||
| 49 | else { | ||
| 50 | @fields = split( /,/, $np->opts->perfdata ); | ||
| 51 | - | ||
| 52 | - # @fields = split /,/, join ',', @{$np->opts->perfdata}; | ||
| 53 | } | ||
| 54 | |||
| 55 | # Add all performance data | ||
| 56 | +my $thresholds; | ||
| 57 | +my $value; | ||
| 58 | +my $warning; | ||
| 59 | +my $critical; | ||
| 60 | +my $minimum; | ||
| 61 | +my $maximum; | ||
| 62 | foreach my $key (@fields) { | ||
| 63 | + if ( $key =~ /=/ ) { | ||
| 64 | + ($key, $thresholds) = split( /=/, $key ); | ||
| 65 | + ($warning, $critical) = split ( /;/, $thresholds ); | ||
| 66 | + } else { | ||
| 67 | + $thresholds = undef; | ||
| 68 | + $warning = undef; | ||
| 69 | + $critical = undef; | ||
| 70 | + } | ||
| 71 | if ( $mysql->{'stats'}->{$key}->{'type'} eq 'ABS' ) { | ||
| 72 | next if ( not defined $read_data->{$key} ); | ||
| 73 | - $np->add_perfdata( | ||
| 74 | - 'label' => $key, | ||
| 75 | - 'value' => $read_data->{$key}, | ||
| 76 | - 'uom' => '', | ||
| 77 | - ); | ||
| 78 | - } | ||
| 79 | - elsif ( $mysql->{'stats'}->{$key}->{'type'} eq 'DERIVE' ) { | ||
| 80 | + $value = $read_data->{$key}; | ||
| 81 | + } elsif ( $mysql->{'stats'}->{$key}->{'type'} eq 'DERIVE' ) { | ||
| 82 | next if ( not defined $stat->{$key} ); | ||
| 83 | - $np->add_perfdata( | ||
| 84 | - 'label' => $key, | ||
| 85 | - 'value' => $stat->{$key}, | ||
| 86 | - 'uom' => '', | ||
| 87 | + $value = $stat->{$key}; | ||
| 88 | + } | ||
| 89 | + $np->add_perfdata( | ||
| 90 | + 'label' => $key, | ||
| 91 | + 'value' => $value, | ||
| 92 | + 'uom' => '', | ||
| 93 | + 'warning' => $warning, | ||
| 94 | + 'critical' => $critical, | ||
| 95 | + ); | ||
| 96 | + if ( $thresholds ) { | ||
| 97 | + $code = $np->check_threshold( | ||
| 98 | + 'check' => $value, | ||
| 99 | + 'warning' => $warning, | ||
| 100 | + 'critical' => $critical, | ||
| 101 | ); | ||
| 102 | + if ( $code ) { | ||
| 103 | + $np->add_message($code, "$key beyond thresholds,"); | ||
| 104 | + } | ||
| 105 | } | ||
| 106 | } | ||
| 107 | - | ||
| 108 | +($code, $message) = $np->check_messages(); | ||
| 109 | $np->nagios_exit( $code, $message ); | ||
| 110 | |||
| 111 | package MySQL::Stats; | ||
