blob: 13befcb45cb93e2ae1f294e2198ca210827a7e30 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
#!/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);
|