#!/usr/bin/perl # Linux version! use strict; my $warning=$ARGV[0]; my $critical=$ARGV[1]; my $str=`free -m | awk 'NR > 3 {print}'`; $str=~/^.*?[0-9.]+.*?([0-9.]+).*?$/; if($1>=$critical){ print "Swap $1 MB"; exit(2); } if($2>=$warning){ print "Swap $1 MB"; exit(1); } print "Swap below threshold"; exit(0);