- check_iostat: get field numbers from iostat dynamically
by parsing header line (r/s and w/s fields move between versions) OBS-URL: https://build.opensuse.org/package/show/server:monitoring/monitoring-plugins-sar-perf?expand=0&rev=12
This commit is contained in:
parent
77bb1e171a
commit
315c48ab46
21
check_iostat
21
check_iostat
@ -105,6 +105,11 @@ if ($warn_util && $crit_util && $warn_util > $crit_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[3,4,5,6,13];
|
||||
($rps,$wps,$kbread,$kbwritten,$util) = @stats[$field_rps,$field_wps,$field_rmbps,$field_wmbps,$field_util];
|
||||
$tps = $rps + $wps;
|
||||
last;
|
||||
}
|
||||
|
@ -1,3 +1,9 @@
|
||||
-------------------------------------------------------------------
|
||||
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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user