check_iostat pass warn and crit levels to performance data

OBS-URL: https://build.opensuse.org/package/show/server:monitoring/monitoring-plugins-sar-perf?expand=0&rev=10
This commit is contained in:
Ruediger Oertel 2017-11-14 16:13:21 +00:00 committed by Git OBS Bridge
parent e45c8ecb6f
commit 6e8dcaed67

View File

@ -58,10 +58,10 @@ getopts('d:w:c:W:C:X:Y:hv', \%opts);
my $disk = $opts{'d'};
my $warning = $opts{'w'};
my $critical = $opts{'c'};
my $warning_iowait = $opts{'W'};
my $critical_iowait = $opts{'C'};
my $warning_util = $opts{'X'};
my $critical_util = $opts{'Y'};
my $warn_iowait = $opts{'W'};
my $crit_iowait = $opts{'C'};
my $warn_util = $opts{'X'};
my $crit_util = $opts{'Y'};
VERSION_MESSAGE() if $opts{'v'};
HELP_MESSAGE() if $opts{'h'};
@ -92,12 +92,12 @@ if ($warn_tps > $crit_tps || $warn_read > $crit_read || $warn_written > $crit_wr
HELP_MESSAGE();
}
if ($warning_iowait && $critical_iowait && $warning_iowait > $critical_iowait) {
if ($warn_iowait && $crit_iowait && $warn_iowait > $crit_iowait) {
warn "ERROR: critical iowait level must be higher than warning level\n";
HELP_MESSAGE();
}
if ($warning_util && $critical_util && $warning_util > $critical_util) {
if ($warn_util && $crit_util && $warn_util > $crit_util) {
warn "ERROR: critical utilization level must be higher than warning level\n";
HELP_MESSAGE();
}
@ -137,12 +137,12 @@ if ($tps >= $warn_tps || $kbread >= $warn_read || $kbwritten >= $warn_written) {
$status = 1;
}
if ($warning_iowait && $iowait >= $warning_iowait) {
if ($warn_iowait && $iowait >= $warn_iowait) {
$msg = "WARNING";
$status = 1;
}
if ($warning_util && $util >= $warning_util) {
if ($warn_util && $util >= $warn_util) {
$msg = "WARNING";
$status = 1;
}
@ -152,18 +152,53 @@ if ($tps >= $crit_tps || $kbread >= $crit_read || $kbwritten >= $crit_written) {
$status = 2;
}
if ($critical_iowait && $iowait >= $critical_iowait) {
if ($crit_iowait && $iowait >= $crit_iowait) {
$msg = "CRITICAL";
$status = 2;
}
if ($critical_util && $iowait >= $critical_util) {
if ($crit_util && $util >= $crit_util) {
$msg = "CRITICAL";
$status = 2;
}
my $p_tps = $tps;
if ($warn_tps) {
$p_tps .= ";$warn_tps";
if ($crit_tps) {
$p_tps .= ";$crit_tps";
}
}
my $p_kbread = $kbread;
if ($warn_read) {
$p_kbread .= ";$warn_read";
if ($crit_read) {
$p_kbread .= ";$crit_read";
}
}
my $p_kbwritten = $kbwritten;
if($warn_written) {
$p_kbwritten .= ";$warn_written";
if ($crit_written) {
$p_kbwritten .= ";$crit_written";
}
}
my $p_iowait = $iowait;
if ($warn_iowait) {
$p_iowait .= ";$warn_iowait";
if ($crit_iowait) {
$p_iowait .= ";$crit_iowait";
}
}
my $p_util = $util;
if ($warn_util) {
$p_util .= ";$warn_util";
if ($crit_util) {
$p_util .= ";$crit_util";
}
}
# Printing the results:
print "$msg - I/O stats tps=$tps KB_read/s=$kbread KB_written/s=$kbwritten iowait=$iowait util=$util | 'tps'=$tps; 'KB_read/s'=$kbread; 'KB_written/s'=$kbwritten; 'iowait'=$iowait; 'util'=$util\n";
print "$msg - I/O stats tps=$tps KB_read/s=$kbread KB_written/s=$kbwritten iowait=$iowait util=$util | 'tps'=$p_tps; 'KB_read/s'=$p_kbread; 'KB_written/s'=$p_kbwritten; 'iowait'=$p_iowait; 'util'=$p_util\n";
# Bye!
exit $status;