pkgsrc-wip/cacti/files/bsd_memory.pl
Fredrik Pettai 9763d23277 Import cacti-0.8.7b as wip/cacti.
Cacti is a complete frontend to rrdtool, it stores all of the necessary
information to create graphs and populates them with data in a MySQL
database. The frontend is completely PHP driven. Along with being able
to maintain Graphs, Data Sources, and Round Robin Archives in a
database, cacti handles the data gathering also. There is also SNMP
support for those used to creating traffic graphs with MRTG.
2008-09-27 18:08:40 +00:00

23 lines
450 B
Perl

#!/usr/bin/perl
if (($ARGV[0] =~ /Cached:/) || ($ARGV[0] =~ /SwapFree:/)) {
open(PROCESS, "pstat -ks |");
$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);