line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::Solaris::Memory; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
119283540
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
78
|
|
4
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
117
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
15
|
use English qw(-no_match_vars); |
|
2
|
|
|
|
|
89
|
|
|
2
|
|
|
|
|
28
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
2268
|
use FusionInventory::Agent::Tools; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
394
|
|
9
|
2
|
|
|
2
|
|
1291
|
use FusionInventory::Agent::Tools::Solaris; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
1170
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub isEnabled { |
12
|
0
|
|
|
0
|
0
|
0
|
my (%params) = @_; |
13
|
0
|
0
|
|
|
|
0
|
return 0 if $params{no_category}->{memory}; |
14
|
0
|
|
|
|
|
0
|
return 1; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub doInventory { |
18
|
0
|
|
|
0
|
0
|
0
|
my (%params) = @_; |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
0
|
my $inventory = $params{inventory}; |
21
|
0
|
|
|
|
|
0
|
my $logger = $params{logger}; |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
0
|
my $memorySize = getFirstMatch( |
24
|
|
|
|
|
|
|
command => '/usr/sbin/prtconf', |
25
|
|
|
|
|
|
|
logger => $logger, |
26
|
|
|
|
|
|
|
pattern => qr/^Memory\ssize:\s+(\S+)/ |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
0
|
my $swapSize = getFirstMatch( |
30
|
|
|
|
|
|
|
command => '/usr/sbin/swap -l', |
31
|
|
|
|
|
|
|
logger => $logger, |
32
|
|
|
|
|
|
|
pattern => qr/\s+(\d+)$/ |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
0
|
$inventory->setHardware({ |
36
|
|
|
|
|
|
|
MEMORY => $memorySize, |
37
|
|
|
|
|
|
|
SWAP => $swapSize |
38
|
|
|
|
|
|
|
}); |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
0
|
my $zone = getZone(); |
41
|
|
|
|
|
|
|
|
42
|
0
|
0
|
|
|
|
0
|
my @memories = $zone eq 'global' ? |
43
|
|
|
|
|
|
|
_getMemoriesPrtdiag() : |
44
|
|
|
|
|
|
|
_getMemoriesPrctl() ; |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
0
|
foreach my $memory (@memories) { |
47
|
0
|
|
|
|
|
0
|
$inventory->addEntry( |
48
|
|
|
|
|
|
|
section => 'MEMORIES', |
49
|
|
|
|
|
|
|
entry => $memory |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub _getMemoriesPrtdiag { |
55
|
8
|
|
|
8
|
|
2404
|
my $info = getPrtdiagInfos(@_); |
56
|
|
|
|
|
|
|
|
57
|
8
|
50
|
|
|
|
92
|
return $info->{memories} ? @{$info->{memories}} : (); |
|
8
|
|
|
|
|
42
|
|
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub _getMemoriesPrctl { |
61
|
0
|
|
|
0
|
|
|
my $handle = getFileHandle( |
62
|
|
|
|
|
|
|
command => "prctl -n project.max-shm-memory $PID", |
63
|
|
|
|
|
|
|
@_ |
64
|
|
|
|
|
|
|
); |
65
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
my @memories; |
67
|
|
|
|
|
|
|
my $memory; |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
while (my $line = <$handle>) { |
70
|
0
|
0
|
|
|
|
|
$memory->{DESCRIPTION} = $1 if $line =~ /^project.(\S+)$/; |
71
|
0
|
0
|
|
|
|
|
$memory->{CAPACITY} = $1 if $line =~ /^\s*system+\s*(\d+)/; |
72
|
|
|
|
|
|
|
|
73
|
0
|
0
|
0
|
|
|
|
if ($memory->{DESCRIPTION} && $memory->{CAPACITY}){ |
74
|
0
|
|
|
|
|
|
$memory->{CAPACITY} = $memory->{CAPACITY} * 1024; |
75
|
0
|
|
|
|
|
|
$memory->{NUMSLOTS} = 1 ; |
76
|
0
|
|
|
|
|
|
$memory->{DESCRIPTION} = "Memory Allocated"; |
77
|
0
|
|
|
|
|
|
$memory->{CAPTION} = "Memory Share"; |
78
|
0
|
|
|
|
|
|
push @memories, $memory; |
79
|
0
|
|
|
|
|
|
undef $memory; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
} |
82
|
0
|
|
|
|
|
|
close $handle; |
83
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
return @memories; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
1; |