source: ocsinventory-agent/trunk/fuentes/lib/Ocsinventory/Agent/Backend/OS/BSD/Mem.pm @ 468

Last change on this file since 468 was 468, checked in by mabarracus, 4 years ago

Copyt trusty code

File size: 662 bytes
Line 
1package Ocsinventory::Agent::Backend::OS::BSD::Mem;
2use strict;
3
4sub check {     
5        `which sysctl 2>&1`;
6        return 0 if($? >> 8);
7        `which swapctl 2>&1`;
8        return 0 if($? >> 8);
9        1;
10};
11
12sub run {
13  my $params = shift;
14  my $common = $params->{common};
15
16  my $PhysicalMemory;
17  my $SwapFileSize;
18
19# Swap
20        my @bsd_swapctl= `swapctl -sk`;
21        for(@bsd_swapctl){
22                $SwapFileSize=$1 if /total:\s*(\d+)/i;
23        }
24# RAM
25        chomp($PhysicalMemory=`sysctl -n hw.physmem`);
26        $PhysicalMemory=$PhysicalMemory/1024;
27       
28# Send it to inventory object
29  $common->setHardware({
30
31      MEMORY =>  sprintf("%i",$PhysicalMemory/1024),
32      SWAP =>    sprintf("%i", $SwapFileSize/1024),
33
34    });
35}
361;
Note: See TracBrowser for help on using the repository browser.