line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::BSD::Memory; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
113845973
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
85
|
|
4
|
1
|
|
|
1
|
|
12
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
82
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
678
|
use FusionInventory::Agent::Tools; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
400
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub isEnabled { |
9
|
0
|
|
|
0
|
0
|
|
my (%params) = @_; |
10
|
0
|
0
|
|
|
|
|
return 0 if $params{no_category}->{memory}; |
11
|
|
|
|
|
|
|
return |
12
|
0
|
|
0
|
|
|
|
canRun('sysctl') && |
13
|
|
|
|
|
|
|
canRun('swapctl'); |
14
|
|
|
|
|
|
|
}; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub doInventory { |
17
|
0
|
|
|
0
|
0
|
|
my (%params) = @_; |
18
|
|
|
|
|
|
|
|
19
|
0
|
|
|
|
|
|
my $inventory = $params{inventory}; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# Swap |
22
|
0
|
|
|
|
|
|
my $swapSize = getFirstMatch( |
23
|
|
|
|
|
|
|
command => 'swapctl -sk', |
24
|
|
|
|
|
|
|
pattern => qr/total:\s*(\d+)/i |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# RAM |
28
|
0
|
|
|
|
|
|
my $memorySize = getFirstLine(command => 'sysctl -n hw.physmem'); |
29
|
0
|
|
|
|
|
|
$memorySize = $memorySize / 1024; |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
$inventory->setHardware({ |
32
|
|
|
|
|
|
|
MEMORY => int($memorySize / 1024), |
33
|
|
|
|
|
|
|
SWAP => int($swapSize / 1024), |
34
|
|
|
|
|
|
|
}); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
1; |