Accepting request 544408 from server:monitoring
Automatic submission by obs-autosubmit OBS-URL: https://build.opensuse.org/request/show/544408 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/monitoring-plugins-sar-perf?expand=0&rev=3
This commit is contained in:
commit
bf50496515
80
check_iostat
80
check_iostat
@ -33,7 +33,7 @@ sub VERSION_MESSAGE {
|
||||
sub HELP_MESSAGE {
|
||||
print "\n\tThis plugin shows the I/O usage of the specified disk, using the iostat external program.\n";
|
||||
print "\tIt prints three statistics: Transactions per second (tps), Kilobytes per second\n";
|
||||
print "tread from the disk (KB_read/s) and and written to the disk (KB_written/s)\n\n";
|
||||
print "read from the disk (KB_read/s) and and written to the disk (KB_written/s)\n\n";
|
||||
print "$progname:\n\t-d <disk>\t\tDevice to be checked (without the full path, eg. sda)\n";
|
||||
print "\t\t\t\t(also accepted are device mapper names)\n";
|
||||
print "\t-c <tps>,<read>,<wrtn>\tSets the CRITICAL level for tps, KB_read/s and KB_written/s, respectively\n";
|
||||
@ -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();
|
||||
}
|
||||
@ -105,6 +105,11 @@ if ($warning_util && $critical_util && $warning_util > $critical_util) {
|
||||
my ($tps,$rps,$wps,$kbread,$kbwritten,$iowait,$util);
|
||||
my $seen_usage = 0;
|
||||
my $seen_disk = 0;
|
||||
my $field_rps = 3;
|
||||
my $field_wps = 4;
|
||||
my $field_rmbps = 5;
|
||||
my $field_wmbps = 6;
|
||||
my $field_util = 13;
|
||||
|
||||
# Doing the actual check:
|
||||
open (IOSTAT,"-|","$iostat -kx $disk 5 2");
|
||||
@ -117,11 +122,25 @@ while (<IOSTAT>) {
|
||||
$iowait = $stats[4];
|
||||
next;
|
||||
}
|
||||
if (/^Device:/) {
|
||||
my @hdrs = split('\s+', $_);
|
||||
my ($search_rps) = grep { $hdrs[$_] eq "r/s" } 0..$#hdrs;
|
||||
$field_rps = $search_rps if $search_rps;
|
||||
my ($search_wps) = grep { $hdrs[$_] eq "w/s" } 0..$#hdrs;
|
||||
$field_wps = $search_wps if $search_wps;
|
||||
my ($search_rmbps) = grep { $hdrs[$_] eq "rkB/s" } 0..$#hdrs;
|
||||
$field_rmbps = $search_rmbps if $search_rmbps;
|
||||
my ($search_wmbps) = grep { $hdrs[$_] eq "wkB/s" } 0..$#hdrs;
|
||||
$field_wmbps = $search_wmbps if $search_wmbps;
|
||||
my ($search_util) = grep { $hdrs[$_] eq "%util" } 0..$#hdrs;
|
||||
$field_util = $search_util if $search_util;
|
||||
next;
|
||||
}
|
||||
if (/^$disk /) {
|
||||
$seen_disk++;
|
||||
next if $seen_disk < 2;
|
||||
my (@stats) = split ('\s+', $_);
|
||||
($rps,$wps,$kbread,$kbwritten,$util) = @stats[1,2,5,6,13];
|
||||
($rps,$wps,$kbread,$kbwritten,$util) = @stats[$field_rps,$field_wps,$field_rmbps,$field_wmbps,$field_util];
|
||||
$tps = $rps + $wps;
|
||||
last;
|
||||
}
|
||||
@ -137,12 +156,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 +171,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;
|
||||
|
@ -1,3 +1,15 @@
|
||||
-------------------------------------------------------------------
|
||||
Wed Nov 15 12:52:11 CET 2017 - ro@suse.de
|
||||
|
||||
- check_iostat: get field numbers from iostat dynamically
|
||||
by parsing header line (r/s and w/s fields move between versions)
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Nov 14 17:27:19 CET 2017 - ro@suse.de
|
||||
|
||||
- check_iostat: pass warning and critical level to perfdata
|
||||
- use iostat fields r/s and w/s for tps calculation
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon Apr 24 12:33:08 CEST 2017 - ro@suse.de
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user