Hello community,

here is the log from the commit of package monitoring-plugins-sar-perf for 
openSUSE:Factory checked in at 2017-11-23 09:44:11
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/monitoring-plugins-sar-perf (Old)
 and      /work/SRC/openSUSE:Factory/.monitoring-plugins-sar-perf.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "monitoring-plugins-sar-perf"

Thu Nov 23 09:44:11 2017 rev:3 rq:544408 version:0.1

Changes:
--------
--- 
/work/SRC/openSUSE:Factory/monitoring-plugins-sar-perf/monitoring-plugins-sar-perf.changes
  2017-05-02 08:54:59.653464773 +0200
+++ 
/work/SRC/openSUSE:Factory/.monitoring-plugins-sar-perf.new/monitoring-plugins-sar-perf.changes
     2017-11-23 09:44:27.716409443 +0100
@@ -1,0 +2,12 @@
+Wed Nov 15 12:52:11 CET 2017 - r...@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 - r...@suse.de
+
+- check_iostat: pass warning and critical level to perfdata
+- use iostat fields r/s and w/s for tps calculation 
+
+-------------------------------------------------------------------

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ check_iostat ++++++
--- /var/tmp/diff_new_pack.bZKpQr/_old  2017-11-23 09:44:28.184392365 +0100
+++ /var/tmp/diff_new_pack.bZKpQr/_new  2017-11-23 09:44:28.184392365 +0100
@@ -33,7 +33,7 @@
 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 @@
 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 @@
     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 @@
 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 @@
         $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 @@
    $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 @@
    $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;


Reply via email to