You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Princeton/pu/libexec/check_linux_active_mem.pl

43 lines
690 B
Perl

#!/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 (<MEM>) {
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";