#!/usr/bin/perl

($it, $w, $c) = @ARGV;

$return = `sar -b 1 3 |grep Average`;
chomp($return);
@split = split(/[ ]+/, $return);
($ignore, $ignore2, $hash{bread},$hash{bwrit},$hash{lread},$hash{lwrit},$hash{rcache},$hash{wcache},$hash{pread},$hash{pread}) = @split;

$curValue = $hash{$it};

if($curValue > $c) {
   print "CRITICO - $it $curValue | $it=$curValue;;;;\n";
   exit(2);
}
elsif($curValue > $w) {
   print "WARNING - $it $curValue | $it=$curValue;;;;\n";
   exit(1);
} else {
   print "OK - $it $curValue | $it=$curValue;;;;\n";
   exit(0);
}

