Changeset e049e1e82b3ac014945cf6c82ad5bdc5bc439b8f

Show
Ignore:
Timestamp:
04/25/10 23:44:35 (4 years ago)
Author:
Jason Dixon <jdixon@omniti.com>
git-committer:
Jason Dixon <jdixon@omniti.com> 1272239075 +0000
git-parent:

[1e9cbdd94a2d45398067ad440286e70b4fcd6d33]

git-author:
Jason Dixon <jdixon@omniti.com> 1272239075 +0000
Message:

use sysctl for freebsd instead of vmstat

git-svn-id: https://labs.omniti.com/resmon/branches/resmon2@330 8c0face9-b7db-6ec6-c4b3-d5f7145c7d55

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • lib/Core/Memstat.pm

    r1e9cbdd re049e1e  
    6363Linux configurations use /proc/meminfo for memory statistics. 
    6464 
     65=head1 SYSCTL METRICS 
     66 
     67FreeBSD configurations use sysctl to extract the most common memory 
     68statistics.  With the exception of hw.physmem, all metrics are pulled 
     69from the vm.stats.vm branch. 
     70 
    6571=back 
    6672 
     
    105111    } elsif ($osname eq 'linux') { 
    106112        my %metrics; 
    107         open(MEMINFO, '/proc/meminfo') || die "Unable to read: /proc/meminfo\n"; 
     113        open(MEMINFO, '/proc/meminfo') || die "Unable to read proc: $!\n"; 
    108114        while (<MEMINFO>) { 
    109115            /(\w+)\:\s+(\d+).*/; 
     
    112118        close(MEMINFO); 
    113119        return \%metrics; 
    114     } elsif ($osname eq 'openbsd' || $osname eq 'freebsd') { 
     120    } elsif ($osname eq 'freebsd') { 
     121        my %metrics; 
     122        open(SYSCTL, 'sysctl hw.physmem vm.stats.vm |') || die "Unable to read sysctl: $!\n"; 
     123        while (<SYSCTL>) { 
     124            /(.*)\:\s+(\d+).*/; 
     125            $metrics{$1} = [$2, 'i']; 
     126        } 
     127        for my $page qw( cache inactive active wire free page ) { 
     128            $metrics{"vm.stats.vm.v_${page}_count"}->[0] *= ($metrics{'vm.stats.vm.v_page_size'}->[0] / 1024); 
     129        } 
     130        close(SYSCTL); 
     131        return \%metrics; 
     132    } elsif ($osname eq 'openbsd') { 
    115133        my $output = run_command("$vmstat_path"); 
    116134        if ($output =~ /.*cs\s+us\s+sy\s+id\n\s+\d+\s+\d+\s+\d+\s+(\d+)\s+(\d+).*/) {