line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::Linux::Memory; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
47343261
|
use strict; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
138
|
|
4
|
1
|
|
|
1
|
|
12
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
81
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
670
|
use FusionInventory::Agent::Tools; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
399
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub isEnabled { |
9
|
0
|
|
|
0
|
0
|
|
my (%params) = @_; |
10
|
0
|
0
|
|
|
|
|
return 0 if $params{no_category}->{memory}; |
11
|
0
|
|
|
|
|
|
return -r '/proc/meminfo'; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub doInventory { |
15
|
0
|
|
|
0
|
0
|
|
my (%params) = @_; |
16
|
|
|
|
|
|
|
|
17
|
0
|
|
|
|
|
|
my $inventory = $params{inventory}; |
18
|
0
|
|
|
|
|
|
my $logger = $params{logger}; |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
my $handle = getFileHandle(file => '/proc/meminfo', logger => $logger); |
21
|
0
|
0
|
|
|
|
|
return unless $handle; |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
my $memorySize; |
24
|
|
|
|
|
|
|
my $swapSize; |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
while (my $line = <$handle>) { |
27
|
0
|
0
|
|
|
|
|
$memorySize = $1 if $line =~ /^MemTotal:\s*(\S+)/; |
28
|
0
|
0
|
|
|
|
|
$swapSize = $1 if $line =~ /^SwapTotal:\s*(\S+)/; |
29
|
|
|
|
|
|
|
} |
30
|
0
|
|
|
|
|
|
close $handle; |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
$inventory->setHardware({ |
33
|
|
|
|
|
|
|
MEMORY => int($memorySize/ 1024), |
34
|
|
|
|
|
|
|
SWAP => int($swapSize / 1024), |
35
|
|
|
|
|
|
|
}); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
1; |