#!/usr/bin/perl

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

$rt = `/usr/bin/vmstat |/usr/bin/tail -1`;
@temp = split(/[ ]+/,$rt);

if( $type eq "in" ) {
	$value = $temp[9];
} else {
	$value = $temp[10];
}

$exitcode = 0;
$exitcode = 1 if( $value > $w );
$exitcode = 2 if( $value > $c );


print "Memory swapped $type = $value | memory_swp_$type=$value;$w;$c;0;\n";
exit($exitcode);

