Collect swap usage on BSD

This commit is contained in:
Jamie Cameron
2013-04-16 21:18:57 -07:00
parent 24b004d8f3
commit 715fa52979

View File

@ -114,8 +114,20 @@ my $mem_cache = $sysctl->{"vm.stats.vm.v_cache_count"} *
$sysctl->{"hw.pagesize"};
my $mem_free = $sysctl->{"vm.stats.vm.v_free_count"} *
$sysctl->{"hw.pagesize"};
my ($swapinfo_output) = &backquote_command("/usr/sbin/swapinfo");
my ($swap_total, $swap_free) = (0, 0);
foreach my $line (split(/\n/, $swapinfo_output)) {
if ($line =~ /^(\S+)\s+(\d+)\s+(\d+)\s+(\d+)/) {
$swap_total += $2 * 1024;
$swap_free += $4 * 1024;
}
}
return ( $sysctl->{"hw.physmem"} / 1024,
($mem_inactive + $mem_cache + $mem_free) / 1024 );
($mem_inactive + $mem_cache + $mem_free) / 1024,
$swap_total,
$swap_free );
}
1;