Files
pkgsrc-ng/net/cacti/files/solaris_memory.pl
2013-09-26 17:14:40 +02:00

24 lines
456 B
Perl

#!/usr/bin/perl
if (($ARGV[0] =~ /Cached:/) || ($ARGV[0] =~ /SwapFree:/)) {
open(PROCESS, "/bin/df -k swap |");
$s = 0;
while (<PROCESS>) {
if (!/^Device/) {
split();
$s += $_[3];
}
}
print "$s";
}
else { # $ARGV[0] is Buffers:, MemFree:, or anything else
open(PROCESS, "vmstat |");
while (<PROCESS>) {
if (!/p/) { # the numbers line happens not to have "p"
split();
print("$_[4]");
}
}
}
close(PROCESS);