summaryrefslogtreecommitdiff
path: root/net/cacti/files/solaris_memory.pl
blob: f956571d8bed061623a884d6f2c195854d24727d (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, "/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);