#!/usr/bin/perl use Getopt::Std; if (!getopts("w:c:")) { print "active_mem UNKNOWN: incorrect arguments given\n"; exit 3; } if (!open(MEM, "/proc/meminfo")) { print "active_mem UNKNOWN: unable to open /proc/meminfo\n"; exit 3; } while () { if (/^MemTotal/) { chomp; @a = split; $tot = $a[1]; } if (/^Active/) { chomp; @a = split; $act = $a[1]; } } $pct = int($act * 100 / $tot); if (defined($opt_c) and $pct > $opt_c) { print "active_mem CRITICAL: pct=$pct |active_mem=$pct%\n"; exit 2; } if (defined($opt_w) and $pct > $opt_w) { print "active_mem WARNING: pct=$pct |active_mem=$pct%\n"; exit 2; } print "active_mem OK: pct=$pct |active_mem=$pct%\n";