Check_iostat.pl version 0.9.7

Previous version and detaild information
https://sysengineers.wordpress.com/2010/02/05/check_iostat-for-nagios-version-0-9-5/

Application Goal:
Check disk IO using a simple perl script and possibly the counters allready available in the linux /proc/ directory. The program must be able to run under Nagios and should return a ‘Nagios’ correct syntax to the prompt. This way the plugin should be usable for Linux users to monitor their Disk IO within Nagios. The program should also report back performance information in the ‘Nagios’ compatible syntax so that graphing is available in the ‘Nagios’ / Cacti / Centreon add-ons.

Changes
Fixed lacking devision in validated summed results
Added sprintf functions rounding the validated numbers with 2 dimentions
Fixed some declaration problems
Added -debug switch to enable the debugging options
Coded arround the used math::Complex functions and removed the module
Improved the debugging output (readability)
Small fixes in de syntax

Installation
1. Copy the code below to your clipboard (ctr+c or the copy-button inside the code field)
2. Logon to the linuxbox with the nagios or nrpe client.
3. browse to the plugin-dir usually cd /usr/local/nagios/libexec/
4. Create a new file vi ./check_iostat.pl
5. Press insert and paste the code inside (when using putty paste is done with a rightmouse click)
6. save the file (esc > : > rq > enter, when using vi)
7. give the file execute rights using chmod +x ./check_iostat
8. make nagios the owner chown nagios:nagios ./check_iostat
9. Test it using updatedb& ./check_iostat -d sd -dbu -dbuw 70 -dbuc 88 -kbs -kbsw 10000 -kbsc 50000 -p

Next configure a nagios command or use nrpe and have fun🙂

#!/usr/bin/perl
# Written by Chris Gralike @ AMIS.
# Perl based check command to fetch and report the
# TPS (transactions per second) and IO wait times.
# Plugin uses iostat for opperation.
# Verion 0.9.7
#
# Changes post 0.9.7 >> 28-05-2010
# Line 298...303 Prevent devision by zerro else exit because no data was collected  - Bug reported by Epiq.
# Line 380       Correction of a type that prevented pref data of r/s w/s from being printed. - Bug reported by Epiq.
# Line 40        Added dm as possible device input used by the linux LVM. - Suggested by Epiq.
# Line 269       Extended the device if/pragmatch validation to match more devices - Added by Jean Ventura.
#
###########################
use Switch;
use warnings;

my($numArgs,
   $debug,	# Print debugging information.
   $DevType,	# Used to match a certain devicetype from the resulting IOstat rows.
   $IOBIN,	# Is used to store a path to the iostat binairy for execution.
   $Samples,	# Used to store the initial Samples returned by iostat.
   @SampleRows, # Used to store the rows generated by the splitted samples.
   $firstseen,  # Used to keep track of the found devices (IOstat might return a set of devices i.e sda, sdb, sdc etc.)
   $Items,      # Used in the foreach to store the row being parsed.
   @cols,       # Used to store the columns in a row after an split.
   $dev,	# Used to create a symbolic link to dynamicly create a var.
   $rqm,
   $val,
   $devtypes,
   $rws, $rws_warn, $rws_crit,
   $kbs, $kbs_warn, $kbs_crit,
   $awt, $awt_warn, $awt_crit,
   $svc, $svc_warn, $svc_crit,
   $devices, $itd,$v1,$v2,$v3,
   $v4,$v5,$v6,$v7,$v8,$v9,$v10,$v11,
   $dbu, $dbu_warn, $dbu_crit
   );

# Preparing to collect the dangerious user input.
# Here is a list of known device types. Please add any device you would like to monitor..
$devtypes=";sd;hd;dm;";
$numArgs = $#ARGV + 1;
$critical_global = 0;
$warning_global = 0;

if($numArgs gt '0'){
	for($i=0;$i<$numArgs;$i++){
	# Process our command line arguments and do some basic testing.
	# Could be make human save in the future.
	switch ($ARGV[$i]) {
		# Enable debugging.
		case '-debug'{
				$debug = 1;
			     }
		# Handle device type
		case '-d'    {
				$val=$ARGV[$i+1];
		 		if( (index($devtypes, $val)) gt '-1'){
					$DevType=$val;
					$i++;
		  		}else{
					print "Ivalid Disktype found. Typo?\n"; exit 1;
		  		}
			     }
		# Do we need to check rqm?
		case '-rqm'  { $rqm='1'; }
		# What is the warning treshold?
		case '-rqmw' {
				$val=$ARGV[$i+1];
				# Is the value nummeric?
				if($val=~m/[0-9]*/){
					$rqm_warn= int $val;
					$i++;
				}else{
				# Possible type?
					print "Non Numeric value used in rqmw, typo? \n"; exit 1;
				}
			     }
		case '-rqmc' {
				$val=$ARGV[$i+1];
                                # Is the value nummeric?
                                if($val=~m/[0-9]*/){
                                        $rqm_crit= int $val;
					$i++;
                                }else{
                                # Possible type?
                                        print "Non Numeric value used in rqmc, typo? \n"; exit 1;
                                }
			     }
		# Do we need to check rws?
		case '-rws'  { $rws='1'; }
		case '-rwsw' {
				$val=$ARGV[$i+1];
                                # Is the value nummeric?
                                if($val=~m/[0-9]*/){
                                        $rws_warn= int $val;
                                        $i++;
                                }else{
                                # Possible type?
                                        print "Non Numeric value used in rwsw, typo? \n"; exit 1;
                                }
			     }
		case '-rwsc' {
				$val=$ARGV[$i+1];
                                # Is the value nummeric?
                                if($val=~m/[0-9]*/){
                                        $rws_crit= int $val;
                                        $i++;
                                }else{
                                # Possible type?
                                        print "Non Numeric value used in rwsc, typo? \n"; exit 1;
                                }
			     }
		# Do we need to check kbs?
		case '-kbs'  { $kbs='1'; }
		case '-kbsw' {
				$val=$ARGV[$i+1];
                                # Is the value nummeric?
                                if($val=~m/[0-9]*/){
                                        $kbs_warn= int $val;
                                        $i++;
                                }else{
                                # Possible type?
                                        print "Non Numeric value used in kbsw, typo? \n"; exit 1;
                                }
			     }
		case '-kbsc' {
				$val=$ARGV[$i+1];
                                # Is the value nummeric?
                                if($val=~m/[0-9]*/){
                                        $kbs_crit= int $val;
                                        $i++;
                                }else{
                                # Possible type?
                                        print "Non Numeric value used in kbsc, typo? \n"; exit 1;
                                }
			     }
		# Do we need to check awt?
		case '-awt'  { $awt='1'; }
		case '-awtw' {
				$val=$ARGV[$i+1];
                                # Is the value nummeric?
                                if($val=~m/[0-9]*/){
                                        $awt_warn= int $val;
                                        $i++;
                                }else{
                                # Possible type?
                                        print "Non Numeric value used in awtw, typo? \n"; exit 1;
                                }
			     }
		case '-awtc' {
				$val=$ARGV[$i+1];
                                # Is the value nummeric?
                                if($val=~m/[0-9]*/){
                                        $awt_crit= int $val;
                                        $i++;
                                }else{
                                # Possible type?
                                        print "Non Numeric value used in awtc, typo? \n"; exit 1;
                                }
			     }
		# Do we need to check svc?
		case '-svc'  { $svc='1'; }
		case '-svcw' {
				$val=$ARGV[$i+1];
                                # Is the value nummeric?
                                if($val=~m/[0-9]*/){
                                        $svc_warn= int $val;
                                        $i++;
                                }else{
                                # Possible type?
                                        print "Non Numeric value used in svcw, typo? \n"; exit 1;
                                }
			     }
		case '-svcc' {
				$val=$ARGV[$i+1];
                                # Is the value nummeric?
                                if($val=~m/[0-9]*/){
                                        $svc_crit= int $val;
                                        $i++;
                                }else{
                                # Possible type?
                                        print "Non Numeric value used in svcc, typo? \n"; exit 1;
                                }
			     }
		# Do we need to check dbu?
		case '-dbu'  { $dbu='1'; }
		case '-dbuw' {
				$val=$ARGV[$i+1];
                                # Is the value nummeric?
                                if($val=~m/[0-9]*/){
                                        $dbu_warn= int $val;
                                        $i++;
                                }else{
                                # Possible type?
                                        print "Non Numeric value used in dbuw, typo? \n"; exit 1;
                                }
			     }
		case '-dbuc' {
				$val=$ARGV[$i+1];
                                # Is the value nummeric?
                                if($val=~m/[0-9]*/){
                                        $dbu_crit= int $val;
                                        $i++;
                                }else{
                                # Possible type?
                                        print "Non Numeric value used in dbuc, typo? \n"; exit 1;
                                }
			     }
		# performance data. Might make the string human unreadable.. ow well, no loss there <img src="https://s-ssl.wordpress.com/wp-includes/images/smilies/icon_smile.gif" alt=":)" class="wp-smiley">
		case '-p'    { $prf='1'; }
		# Print full messages per device overview.
		#case '-m'    { $fms='1'; }
		# Most used help switches.
		case '--help'{ USAGE(); }
		case '-h'    { USAGE(); }
	}
	}
	# Check if the basic requirements are met.
	if(!($DevType) ||  !(($rqm || $rws || $kbs || $awt || $svc || $dbu))){
		print "Minimal requiremens, device and checktype are not met\n";
		USAGE();
	}
}else{
	# No input was given. Show the Usage();
	USAGE();
}

# Locate the IOBin binairy needed to fetch the stats.
chomp($IOBIN=`which iostat`);

if( !(-f $IOBIN) || !(-x $IOBIN)){
	print "A working iostat command is needed for this script to work \n";
	print "Also make sure the sysstat service is running! /etc/init.d/sysstat \n";
	exit 1;
}

if($DevType){
	# IF IOStat is found, lets collect some data.
	chomp($Samples=`$IOBIN -d -x -k 1 5 | grep $DevType`);
}else{
	print "Please select a valid devicetype \n";
	exit 1;
}

# Break the samples up in lines so we can evaluate them.
# The first set of samples are avg. values counted from boot.
# We need to discard them and collect the remaining samples.
@SampleRows=split(/\n/, $Samples);

# Firstseen is used to track de device names and to skip the first itteration of iostat that contains
# avg stats counted from system boot time, stats we cant use here sadly <img src="https://s-ssl.wordpress.com/wp-includes/images/smilies/icon_smile.gif" alt=":)" class="wp-smiley">
$firstseen='';
$CT=0;
$Devices=0;

# Print Debugging information
if($debug){
	    print "### Data collected ###\n";
	    print "dev|rrqm|wrqm|r/s|w/s|rKB/s|wKB/s|rq-sz|qu-sz|await|svctm|util%|\n";
}

foreach $Items (@SampleRows){
	 # Break the latter up in usable columns.
        @cols=split(/\s+/,$Items);
	 # We only want a certain device type. So lets match what we know.
	 # Disks usualy have a prefix for example (scsi = sd) its set using
	 # the DevType var.
         if($cols[0]=~m/$DevType-[0-9]$/ || $cols[0]=~m/$DevType[a-z]$/ || $cols[0]=~m/$DevType[a-z][0-9]$/){

		$dev=$cols[0];
		if((rindex $firstseen, $dev) gt '-1'){
			#Declare new $$
			#my @$dev;
			# Store the collected data in the correct (dynamic) vars.
			$$dev[1]+=$cols[1];	# rrqm/s   Read Requests Merged per Second.
			$$dev[2]+=$cols[2];	# wrqm/s   Write Requests Merged per Second.
			$$dev[3]+=$cols[3];	# r/s      Number of read requests issued per Second
			$$dev[4]+=$cols[4];	# w/s      Number of write requests issued per Second
			$$dev[5]+=$cols[5];	# rKB/s    Number of Kilobytes read per Second.
			$$dev[6]+=$cols[6];	# wKB/s    Number of Kilobytes written per Second.
			$$dev[7]+=$cols[7];	# Avgrq-sz Avarage size (in sectors) of the issued requests.
			$$dev[8]+=$cols[8];	# Avgqu-sz Avarage Queue length of the requests issued.
			$$dev[9]+=$cols[9];	# Await	  Avarage wait time in ms for IO requests to be served.
			$$dev[10]+=$cols[10];	# svctm    Avarage service time in ms for IO requests that where issued.
			$$dev[11]+=$cols[11];   # %util    Precentage of CPU time during IO requests (bandwidth util), saturation at 90~100%
			$CT++; # Add a new itteration to the count
			# Print some debugging vars if requested. to show the data is collected.
			if($debug){
				    print "$dev|$cols[1]|$cols[2]|$cols[3]|$cols[4]|$cols[5]|$cols[6]|$cols[7]|$cols[8]|$cols[9]|$cols[10]|$cols[11]|\n";
			}
		}else{
			$Devices++;
			$firstseen.="$dev;";
		}
	}
}

# Prevent $itd (itterations / disk) from becomming zerro and exit when no devices are found.
# on line 299.
if($Devices > 0){
	$itd = ($CT / $Devices);
}else{
	print "No performance data was captured. Please check if the device name is correct\n"; exit 1;
}

# Print debugging information
if($debug){
	print "###Devices Counted###\n";
	print "Number of devices : $Devices\n";
	print "Number of itterations per device : $itd\n";
	print "Total Number of Itterations : $CT\n";
}
# Lets collect the device information from the firstseen var
# and start processing it for some perf check/data
# Lets also recycle some previously used vars for this.
@cols=split(/;/,$firstseen);
foreach $Items (@cols){
	# Items now contains the devicenames needed to access the data again.
	# We now need to check them against some basic tresholds
	# Print a nice table with the calculated values when we are in debug.

  	# Print debugging information
	if($debug){
		   print "### Counted Values ###\n";
		   print "$Items|$$Items[1]|$$Items[2]|$$Items[3]|$$Items[4]|$$Items[5]|$$Items[6]|$$Items[7]|$$Items[8]|$$Items[9]|$$Items[10]|$$Items[11]|\n";
        }

	#What do we want to check against a treshold?
	#First check the selection if any.
	if($rqm || $rws || $kbs || $awt || $svc || $dbu){

		#Set the counts to zerro
		$critical_state='0';
		$warning_state='0';
		$ok_state='0';
		# Devide
		$round="%.2f";
		$v1 = sprintf($round, ($$Items[1] / $itd));
        $v2 = sprintf($round, ($$Items[2] / $itd));
		$v3 = sprintf($round, ($$Items[3] / $itd));
        $v4 = sprintf($round, ($$Items[4] / $itd));
		$v5 = sprintf($round, ($$Items[5] / $itd));
        $v6 = sprintf($round, ($$Items[6] / $itd));
		$v7 = sprintf($round, ($$Items[7] / $itd));
        $v8 = sprintf($round, ($$Items[8] / $itd));
		$v9 = sprintf($round, ($$Items[9] / $itd));
        $v10 = sprintf($round, ($$Items[10] / $itd));
        $v11 = sprintf($round, ($$Items[11] / $itd));

		# Requests Merged per second.
		if($rqm){
			# Critical
			if(($v1 >= $rqm_crit) || ($v2 >= $rqm_crit)){
				$critical_state+='1';
			# Warning?
			}elsif(($v1 >= $rqm_warn) || ($v2 >= $rqm_warn)){
				$warning_state+='1';
			# Ok
			}else{
				$ok_state+='1';
			}
			# Add the counters to the performance vars
			$perf.="$Items-rrqm/s=$v1; $Items-wrqm/s=$v2;";
		}
		# Reads / Writes per second.
		if($rws){
			if(($v3 >= $rws_crit) || ($v4 >= $rws_crit)){
	                    	$critical_state+='1';
             		# Warning?
               	 	}elsif(($v3 >= $rws_warn) || ($v4 >= $rws_warn)){
                        	$warning_state+='1';
                	# Ok
                	}else{
                        	$ok_state+='1';
                	}
			# Add the counters to the performance var.
			$perf.="$Items-r/s=$v3; $Items-w/s=$v4; ";
		}
		# KB Read/Writes per second.
		if($kbs){
			if(($v5 >= $kbs_crit) || ($v6 >= $kbs_crit)){
	                        $critical_state+='1';
	                # Warning?
       	         	}elsif(($v5 >= $kbs_warn) || ($v6 >= $kbs_warn)){
                        	$warning_state+='1';
                	# Ok
                	}else{
                       	 	$ok_state+='1';
                	}
			$perf.="$Items-rKB/s=$v5; $Items-wKB/s=$v6; ";
		}
		# Avarage wait time
		if($awt){
			if(($v9 >= $awt_crit)){
                        	$critical_state+='1';
                	# Warning?
                	}elsif(($v9 >= $awt_warn)){
                        	$warning_state+='1';
                	# Ok
                	}else{
                        	$ok_state+='1';
                	}
			$perf.="$Items-await=$v9; ";
		}
		# Avarage service time issuing time
		if($svc){
			if($v10 >= $svc_crit){
       	                	$critical_state+='1';
                	# Warning?
                	}elsif($v10 >= $svc_warn){
                        	$warning_state+='1';
                	# Ok
                	}else{
                        	$ok_state+='1';
                	}
			$perf.="$Items-svctm=$v10; "
		}
		# Disk bandwidth Utilization
		if($dbu){
			if($v11 >= $dbu_crit){
                	        $critical_state+='1';
              	  	# Warning?
               	 	}elsif($v11 >= $dbu_warn){
                        	$warning_state+='1';
                	# Ok
                	}else{
                        	$ok_state+='1';
                	}
			$perf.="$Items-util=$v11%; ";
		}
	}else{
		print "At least select a value to measure..\n";
		exit 1;
	}
	# Print Debugging information about the validated values.
	if($debug){ print "### validated Devisions ###\n";
                    print "$Items|$v1|$v2|$v3|$v4|$v5|$v6|$v7|$v8|$v9|$v10|$v11|\n";
	}

	# Create a messages var.
	$mgs.="$Items=O:$ok_state,W:$warning_state,C:$critical_state; ";

	# Track the global state (1 crit 1 warn)
	if(($critical_state gt '0') || ( $critical_global gt '0')){
		$critical_global+='1';
	}
	if(($warning_state gt '0') || ( $warning_global gt '0')){
		$warning_global+='1';
	}
}

# Compose a nice nagios output.
if($critical_global >= '1'){
	print "CRITICAL:";
	$exit=2;
}elsif($warning_global >= '1'){
	print "WARNING:";
	$exit=1;
}else{
	print "OK:";
	$exit=0;
}
# Print the remainder, the most important data was processed.
print $mgs; if($prf){ print "|$perf"; } print "\n";
exit $exit;

###Subroutines
sub USAGE{
	print "
                Usage : $0 -d [Dev] [options]

		-p Print performance data about the measured samples.

		-d {grep string used on IOstat}
		examples;
                 sd     #All scsi devices.
                 hd     #All Cdrom devices.
		 sda	#Only device sda

                [Available Measurement Options]
                -rqm -rqmw val -rqmc val        # read/write merged             [#]
                -rws -rwsw val -rwsc val        # read/write per second.        [s]
                -kbs -kbsw val -kbsc val        # KBs read/written per second.  [s]
                -awt -awtw val -awtc val        # Avarage IO wait time.         [ms]
                -svc -svcw val -svcc val        # Avarage service IO wait time. [s]
                -dbu -dbuw val -dbuc val        # Disk utilization              [%]\n";
        exit 1;
}

About Chris Gralike

Momenteel ben ik manager van de afdeling business continuity bij de zakelijke IT dienstverlener AMIS Services BV. Sinds 2003 ben ik actief in de ICT branche. Tussen 2003 en nu heb ik verschillende rollen vervuld. In de rollen: systeem- en netwerkbeheer, system engineer, servicemanager en nu practice manager ben ik in contact gekomen met uiteenlopende technologieën, methodologieën, ideeën, oplossingen en innovaties. Een rijke ervaring waarmee ik de klanten van Conclusion en AMIS elke dag probeer te ondersteunen. Mijn credo: 'Altijd opzoek een win-win tussen business en technologie.'

Posted on May 27, 2010, in centreon, Linux, Linux Commands, Nagios / Centreon, Network Monitoring, Perl and tagged , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , . Bookmark the permalink. 20 Comments.

  1. Corrected the code on line : 371

    Thanks to ‘Epiq’ for pointing the bug out.

  2. if selecting dm it comes back with error : “No performance data was captured. Please check if the device name is correct”

    Edited line 269 and changed it to:

    if($cols[0]=~m/$DevType-[0-9]$/ || $cols[0]=~m/$DevType[a-z]$/ || $cols[0]=~m/$DevType[a-z][0-9]$/){

    Then works ok for sda/sda1/dm-1 etc which you would want for a multipathed device mapper environment

  3. added the change to the code,

    Thanks for the relay🙂

    Rgrds, Chris

  4. Hi,
    Escuse me but this script don’t work in my office.
    If i do a iostat command on my aix 5.3, the result it’s like this:

    System configuration: lcpu=4 disk=9

    tty: tin tout avg-cpu: % user % sys % idle % iowait
    0.2 23.2 8.5 1.8 89.4 0.3

    Disks: % tm_act Kbps tps Kb_read Kb_wrtn
    hdisk8 1.2 10.6 2.4 x x
    hdisk0 1.2 12.8 2.5 x x
    hdisk5 5.6 213.5 16.9 x x
    hdisk6 2.0 118.1 5.9 x x
    hdisk7 1.7 53.7 3.6 x x
    hdisk2 6.6 253.7 21.8 x x
    hdisk4 2.9 132.8 10.5 x x
    hdisk3 5.3 228.4 21.6 x x
    cd0 0.0 0.0 0.0 0 0

    It is possible to have a patch for my problem?
    hdisk is not a classic form?

    Thx a lot for this script and good continuation.
    Regards

  5. Hi Disciplus,

    The whole script is written arround the output format given back by iostat. You might be able to “rewrite” this script to the output given back by iostat on your aix machine.

    Ill try to explain how the script functions so you might figure out where to apply the changes (which i cant script for you because i dont have aix available here)

    How the collection works,

    Starting from rule 239 – 246 the shell command is executed using the parameters collected in $IOBIN (which to locate the iostat command) and $DevType which is is given on the commandline by the user and tested against all listed available devtypes in rule 42. (hdisk should work from the hd; option listed there)

    In the codeblock the iostat command is executed using the linux (RHEL5x) options -d -k -x 1 5 | grep (some device)
    The output should look like this;

    [root@ovux105 ~]# iostat -d -k -x 1 5
    Linux 2.6.18-194.0.0.0.3.el5 (ux105) 10/11/2010

    Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await svctm %util
    xvda 0.00 0.25 0.01 0.42 0.10 2.67 13.13 0.00 1.02 0.35 0.01
    xvda1 0.00 0.00 0.00 0.00 0.00 0.00 8.70 0.00 3.64 0.94 0.00
    xvda2 0.00 0.25 0.01 0.42 0.10 2.67 13.13 0.00 1.02 0.35 0.01

    All the output is next collected in a variable called $Samples which is exploded based on the newline (\n) to break the collected samples up in rows which are saved in an array called @SampleRows.

    Next an foreach will walk through the collected rows and breaks each row up in columns based on the whitespaces between each metric (‘\s+’). Then the metrics are saved in an ordered array in rule 277-289. (This is the array to work with later on)

    The following code simply picks up the various metrics and adds/devides them to get correct measurements. Baseline is, when you are able to organize this array based on the data collected from aix you should be able to collect and measure this data.

    • Thank you Chris,
      I will take the time to modifiy your script.

      See you later.

      • The modification is to complex for me, the perl command is not the same (in the first view).
        I have modified a other script (check_aix_hdisk) for check io only.
        It’s not optimise but it’s working on my AIX.
        If you wan’t i can put my script here?

  6. Gavin Williams

    HI there,

    Firstly, great script, exactly what I have been looking for…

    Though I had to make a few tweaks to make it work with our HP servers with Raid arrays.
    The dev names pattern is ‘c0d[0-9]’.

    Tweaked line 42:
    $devtypes=”;sd;hd;dm;c0d;”;

    Tweak line 270 to become:
    if($cols[0]=~m/$DevType-[0-9]$/ || $cols[0]=~m/$DevType[a-z]$/ || $cols[0]=~m/$DevType[a-z][0-9]$/ || $cols[0]=~m/$DevType[0-9]$/){

    Cheers again
    Gavin

  7. it’s not working for SAN connections disk.

    ./check_iostat2.pl -d emcpowerd -dbu -dbuw 1 -dbuc 5 -p
    No performance data was captured. Please check if the device name is correct

    I added emcpowerd in the line
    $devtypes=”;sd;hd;dm;emcpowerd;”;

  8. ok working only define emcpower

  9. To make the script work for ‘non-defined’ disks, you need to tweak the following lines to match your device name…

    LINE 42 “Add the full device name to make the script accept it from the commandline”
    LINE 270 “Add a regular expression to match your devicename so the script is able to filter out the ‘header’ from the captured samples correctly”.

    Hope this helps future users😉

    Any tips on how to improve the script are more then welcome🙂

    Regards,

  10. Hallo,

    my sysstat is a “,” and not a “.”

    /usr/lib64/sa/sadc -V
    sysstat version 7.0.2
    (C) Sebastien Godard

    iostat -d -k -x 1 5
    Linux 2.6.18-164.15.1.el5 (xx) 28.11.2011

    Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await svctm %util
    sda 0,03 0,01 0,29 0,16 10,31 5,51 70,13 0,00 2,08 1,07 0,05
    sda1 0,03 0,01 0,29 0,16 10,31 5,51 70,13 0,00 2,08 1,07 0,05

    The script say

    ./check_iostat -d sd -dbu -dbuw 70 -dbuc 88 -kbs -kbsw 10000 -kbsc 50000 -p
    Argument “0,00” isn’t numeric in addition (+) at ./check_iostat line 277.
    Argument “0,00” isn’t numeric in addition (+) at ./check_iostat line 278.
    Argument “0,00” isn’t numeric in addition (+) at ./check_iostat line 279.
    Argument “0,00” isn’t numeric in addition (+) at ./check_iostat line 280.
    Argument “0,00” isn’t numeric in addition (+) at ./check_iostat line 281.
    Argument “0,00” isn’t numeric in addition (+) at ./check_iostat line 282.
    Argument “0,00” isn’t numeric in addition (+) at ./check_iostat line 283.
    Argument “0,00” isn’t numeric in addition (+) at ./check_iostat line 284.
    Argument “0,00” isn’t numeric in addition (+) at ./check_iostat line 285.
    Argument “0,00” isn’t numeric in addition (+) at ./check_iostat line 286.
    Argument “0,00” isn’t numeric in addition (+) at ./check_iostat line 287.
    Argument “0,00” isn’t numeric in addition (+) at ./check_iostat line 277.

    can i help?

  11. Hi. First, thanks for this plugin. But there are some issues for me: when using certain device, for example sda, it says that it is not found. When adding “sda” to devtypes inside plugin, there is another error: “No performance data was captured. Please check if the device name is correct”. I’ve found that if i comment check for device, line:
    “270 if($cols[0]=~m/$DevType-[0-9]$/ || $cols[0]=~m/$DevType[a-z]$/ || $cols[0]=~m/$DevType[a-z][0-9]$/){”
    then it is working fine. I’m just beginner at Perl programming, so no time to investigate this for now.

  12. Checking *all* devices works, but selecting a single disk from that list fails:

    # ./check_iostat.pl -d sd -dbu -dbuw 50 -dbuc 90
    OK:sda=O:1,W:0,C:0; sda1=O:1,W:0,C:0; sda2=O:1,W:0,C:0; sdb=O:1,W:0,C:0; sdb1=O:1,W:0,C:0; sdc=O:1,W:0,C:0; sdc1=O:1,W:0,C:0; sdd=O:1,W:0,C:0; sdd1=O:1,W:0,C:0;

    # ./check_iostat.pl -d sdb -dbu -dbuw 50 -dbuc 90
    Ivalid Disktype found. Typo?

    • My iostat output:

      # iostat -x 1 2
      Linux 2.6.18-194.el5 (db2) 06/08/2012

      avg-cpu: %user %nice %system %iowait %steal %idle
      0.71 0.01 0.15 0.44 0.00 98.70

      Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm %util
      sda 0.55 38.62 1.27 2.40 158.82 328.14 132.94 0.08 21.97 0.70 0.26
      sda1 0.00 0.00 0.00 0.00 0.00 0.00 5.07 0.00 6.20 6.14 0.00
      sda2 0.55 38.62 1.27 2.40 158.82 328.14 132.94 0.08 21.97 0.70 0.26
      sdb 68.22 13.49 5.28 19.76 692.68 862.09 62.09 0.04 1.58 0.72 1.80
      sdb1 68.22 13.49 5.28 19.76 692.68 862.09 62.09 0.04 1.58 0.72 1.80
      sdc 0.00 25.19 0.20 11.48 1.60 649.18 55.74 0.01 0.62 0.28 0.33
      sdc1 0.00 25.19 0.20 11.48 1.60 649.18 55.74 0.01 0.62 0.28 0.33
      dm-0 0.00 0.00 1.51 40.77 156.30 326.16 11.41 0.01 0.15 0.04 0.18
      dm-1 0.00 0.00 0.31 0.25 2.52 1.98 8.00 0.05 90.93 1.39 0.08
      dm-2 0.00 0.00 2.98 32.95 128.67 861.34 27.55 0.01 0.31 0.44 1.59
      sdd 3.69 68.74 5.25 0.77 1532.24 556.09 346.79 0.07 11.95 3.14 1.89
      sdd1 3.69 68.74 5.25 0.77 1532.24 556.09 346.79 0.07 11.95 3.14 1.89

  13. same problem here, selecting a disk doesn’t work

    iostat -d -x -k 1 1
    Linux 2.6.32-279.el6.i686 (monitor) 02/19/2013 _i686_ (4 CPU)

    Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await svctm %util
    scd0 0.00 0.00 0.00 0.00 0.00 0.00 40.42 0.00 1.67 1.55 0.00
    sda 0.01 46.69 0.04 36.57 0.70 165.03 9.05 0.06 1.51 0.51 1.88
    dm-0 0.00 0.00 0.04 83.26 0.70 165.03 3.98 0.11 1.30 0.23 1.89
    dm-1 0.00 0.00 0.00 0.00 0.00 0.00 8.00 0.00 1.16 0.90 0.00
    sdb 0.00 10.29 0.45 0.11 68.33 41.60 396.98 0.01 18.46 1.15 0.06
    dm-2 0.00 0.00 0.71 19.77 116.15 79.32 19.09 0.00 0.05 0.05 0.11
    sdc 0.00 9.28 0.27 0.09 47.83 37.72 483.97 0.01 28.17 1.19 0.04

    Check_iostat.pl -d sd -rws -rwsw 500 -rwsc 1000 -p
    OK:sda=O:1,W:0,C:0; sdb=O:1,W:0,C:0; sdc=O:1,W:0,C:0; |sda-r/s=0.00; sda-w/s=5.00; sdb-r/s=0.00; sdb-w/s=0.00; sdc-r/s=0.00; sdc-w/s=0.00;

    Check_iostat.pl -d sda -rws -rwsw 500 -rwsc 1000 -p
    Invalid Disktype found. Typo?

    • Hi,

      Please consult the earlier article comments.

      You need to tweak the script to match your environment.

      —–
      LINE 42 “Add the full device name to make the script accept it from the commandline”
      LINE 270 “Add a regular expression to match your devicename so the script is able to filter out the ‘header’ from the captured samples correctly”.

      —-

      Rgrds,

  14. Help me ??

    ./check_iostat.pl -d sd -dbu -dbuw 70 -dbuc 88 -kbs -kbsw 10000 -kbsc 50000 -p
    Argument “0,00” isn’t numeric in addition (+) at ./check_iostat.pl line 281.
    Argument “1,98” isn’t numeric in addition (+) at ./check_iostat.pl line 282.
    Argument “0,00” isn’t numeric in addition (+) at ./check_iostat.pl line 283.
    Argument “58,42” isn’t numeric in addition (+) at ./check_iostat.pl line 284.
    Argument “0,00” isn’t numeric in addition (+) at ./check_iostat.pl line 285.
    Argument “241,58” isn’t numeric in addition (+) at ./check_iostat.pl line 286.
    Argument “8,27” isn’t numeric in addition (+) at ./check_iostat.pl line 287.
    Argument “16,35” isn’t numeric in addition (+) at ./check_iostat.pl line 288.
    Argument “56,20” isn’t numeric in addition (+) at ./check_iostat.pl line 289.
    Argument “0,00” isn’t numeric in addition (+) at ./check_iostat.pl line 290.
    Argument “56,20” isn’t numeric in addition (+) at ./check_iostat.pl line 291.
    Argument “0,00” isn’t numeric in addition (+) at ./check_iostat.pl line 281.
    Argument “0,00” isn’t numeric in addition (+) at ./check_iostat.pl line 282.
    Argument “0,00” isn’t numeric in addition (+) at ./check_iostat.pl line 283.
    Argument “106,38” isn’t numeric in addition (+) at ./check_iostat.pl line 284.
    Argument “0,00” isn’t numeric in addition (+) at ./check_iostat.pl line 285.
    Argument “425,53” isn’t numeric in addition (+) at ./check_iostat.pl line 286.
    Argument “8,00” isn’t numeric in addition (+) at ./check_iostat.pl line 287.
    Argument “6,63” isn’t numeric in addition (+) at ./check_iostat.pl line 288.
    Argument “194,28” isn’t numeric in addition (+) at ./check_iostat.pl line 289.
    Argument “0,00” isn’t numeric in addition (+) at ./check_iostat.pl line 290.
    Argument “194,28” isn’t numeric in addition (+) at ./check_iostat.pl line 291.
    Argument “0,00” isn’t numeric in addition (+) at ./check_iostat.pl line 281.
    Argument “0,00” isn’t numeric in addition (+) at ./check_iostat.pl line 282.
    Argument “0,00” isn’t numeric in addition (+) at ./check_iostat.pl line 283.
    Argument “0,00” isn’t numeric in addition (+) at ./check_iostat.pl line 284.
    Argument “0,00” isn’t numeric in addition (+) at ./check_iostat.pl line 285.
    Argument “0,00” isn’t numeric in addition (+) at ./check_iostat.pl line 286.
    Argument “0,00” isn’t numeric in addition (+) at ./check_iostat.pl line 287.
    Argument “0,00” isn’t numeric in addition (+) at ./check_iostat.pl line 288.
    Argument “0,00” isn’t numeric in addition (+) at ./check_iostat.pl line 289.
    Argument “0,00” isn’t numeric in addition (+) at ./check_iostat.pl line 290.
    Argument “0,00” isn’t numeric in addition (+) at ./check_iostat.pl line 291.
    Argument “0,00” isn’t numeric in addition (+) at ./check_iostat.pl line 281.
    Argument “0,00” isn’t numeric in addition (+) at ./check_iostat.pl line 282.
    Argument “0,00” isn’t numeric in addition (+) at ./check_iostat.pl line 283.
    Argument “0,00” isn’t numeric in addition (+) at ./check_iostat.pl line 284.
    Argument “0,00” isn’t numeric in addition (+) at ./check_iostat.pl line 285.
    Argument “0,00” isn’t numeric in addition (+) at ./check_iostat.pl line 286.
    Argument “0,00” isn’t numeric in addition (+) at ./check_iostat.pl line 287.
    Argument “0,00” isn’t numeric in addition (+) at ./check_iostat.pl line 288.
    Argument “0,00” isn’t numeric in addition (+) at ./check_iostat.pl line 289.
    Argument “0,00” isn’t numeric in addition (+) at ./check_iostat.pl line 290.
    Argument “0,00” isn’t numeric in addition (+) at ./check_iostat.pl line 291.
    OK:sda=O:2,W:0,C:0; |sda-rKB/s=0.00; sda-wKB/s=166.50; sda-util=62.50%;

    • My script doesn’t check the delimiter used for floating point values and assumes its delimited by a dot.
      You might therefor want to consider replacing the Comma’s , with dots . in the return values. Sadly this requires some perl coding on your part.

      Adding something like:
      Performing a regex search-and-replace is just as easy:
      $string =~ s/regex/replacement/g;

      On the var holding the iostat results will help you do that.

  1. Pingback: check_iostat / check_io for nagios Version 0.9.5 « SE Stuff and the like…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: