line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::AIX::Memory; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
78223290
|
use strict; |
|
1
|
|
|
|
|
12
|
|
|
1
|
|
|
|
|
88
|
|
4
|
1
|
|
|
1
|
|
11
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
69
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
455
|
use FusionInventory::Agent::Tools; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
153
|
|
7
|
1
|
|
|
1
|
|
503
|
use FusionInventory::Agent::Tools::AIX; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
487
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub isEnabled { |
10
|
0
|
|
|
0
|
0
|
|
my (%params) = @_; |
11
|
0
|
0
|
|
|
|
|
return 0 if $params{no_category}->{memory}; |
12
|
0
|
|
|
|
|
|
return 1; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub doInventory { |
16
|
0
|
|
|
0
|
0
|
|
my (%params) = @_; |
17
|
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
|
my $inventory = $params{inventory}; |
19
|
0
|
|
|
|
|
|
my $logger = $params{logger}; |
20
|
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
|
foreach my $memory (_getMemories()) { |
22
|
0
|
|
|
|
|
|
$inventory->addEntry( |
23
|
|
|
|
|
|
|
section => 'MEMORIES', |
24
|
|
|
|
|
|
|
entry => $memory |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
#Memory informations |
29
|
|
|
|
|
|
|
#lsdev -Cc memory -F 'name' -t totmem |
30
|
|
|
|
|
|
|
#lsattr -EOlmem0 |
31
|
0
|
|
|
|
|
|
my $memorySize = 0; |
32
|
0
|
|
|
|
|
|
my @lsdev = getAllLines( |
33
|
|
|
|
|
|
|
command => 'lsdev -Cc memory -F "name" -t totmem', |
34
|
|
|
|
|
|
|
logger => $logger |
35
|
|
|
|
|
|
|
); |
36
|
0
|
|
|
|
|
|
foreach (@lsdev){ |
37
|
0
|
|
|
|
|
|
my @lsattr = getAllLines( |
38
|
|
|
|
|
|
|
command => "lsattr -EOl $_", |
39
|
|
|
|
|
|
|
logger => $logger |
40
|
|
|
|
|
|
|
); |
41
|
0
|
|
|
|
|
|
foreach (@lsattr) { |
42
|
0
|
0
|
|
|
|
|
if (! /^#/){ |
43
|
|
|
|
|
|
|
# See: http://forge.fusioninventory.org/issues/399 |
44
|
|
|
|
|
|
|
# TODO: the regex should be improved here |
45
|
0
|
|
|
|
|
|
/^(.+):(\d+)/; |
46
|
0
|
|
|
|
|
|
$memorySize += $2; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
#Paging Space |
52
|
0
|
|
|
|
|
|
my $swapSize; |
53
|
0
|
|
|
|
|
|
my @grep = getAllLines(command => 'lsps -s', logger => $logger); |
54
|
0
|
|
|
|
|
|
foreach (@grep){ |
55
|
0
|
0
|
|
|
|
|
if ( ! /^Total/){ |
56
|
0
|
|
|
|
|
|
/^\s*(\d+)\w*\s+\d+.+/; |
57
|
0
|
|
|
|
|
|
$swapSize = $1; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
$inventory->setHardware({ |
62
|
0
|
|
|
|
|
|
MEMORY => $memorySize, |
63
|
|
|
|
|
|
|
SWAP => $swapSize |
64
|
|
|
|
|
|
|
}); |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub _getMemories { |
69
|
0
|
|
|
0
|
|
|
my @infos = getLsvpdInfos(@_); |
70
|
0
|
|
|
|
|
|
my @memories; |
71
|
0
|
|
|
|
|
|
my $numslots = 0; |
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
foreach my $info (@infos) { |
74
|
0
|
0
|
|
|
|
|
next unless $info->{DS} eq 'Memory DIMM'; |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
push @memories, { |
77
|
|
|
|
|
|
|
DESCRIPTION => $info->{DS}, |
78
|
|
|
|
|
|
|
CAPACITY => $info->{SZ}, |
79
|
|
|
|
|
|
|
CAPTION => 'Slot ' . $info->{YL}, |
80
|
|
|
|
|
|
|
SERIALNUMBER=> $info->{SN}, |
81
|
|
|
|
|
|
|
NUMSLOTS => $numslots++ |
82
|
|
|
|
|
|
|
}; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
return @memories; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
1; |