line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::Solaris::Memory; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
90713085
|
use strict; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
69
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
98
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
8
|
use English qw(-no_match_vars); |
|
1
|
|
|
|
|
35
|
|
|
1
|
|
|
|
|
22
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
1157
|
use FusionInventory::Agent::Tools; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
232
|
|
9
|
1
|
|
|
1
|
|
731
|
use FusionInventory::Agent::Tools::Solaris; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
762
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub isEnabled { |
12
|
0
|
|
|
0
|
0
|
|
my (%params) = @_; |
13
|
0
|
0
|
|
|
|
|
return 0 if $params{no_category}->{memory}; |
14
|
0
|
|
|
|
|
|
return 1; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub doInventory { |
18
|
0
|
|
|
0
|
0
|
|
my (%params) = @_; |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
my $inventory = $params{inventory}; |
21
|
0
|
|
|
|
|
|
my $logger = $params{logger}; |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
my $memorySize = getFirstMatch( |
24
|
|
|
|
|
|
|
command => '/usr/sbin/prtconf', |
25
|
|
|
|
|
|
|
logger => $logger, |
26
|
|
|
|
|
|
|
pattern => qr/^Memory\ssize:\s+(\S+)/ |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
my $swapSize = getFirstMatch( |
30
|
|
|
|
|
|
|
command => '/usr/sbin/swap -l', |
31
|
|
|
|
|
|
|
logger => $logger, |
32
|
|
|
|
|
|
|
pattern => qr/\s+(\d+)$/ |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
$inventory->setHardware({ |
36
|
|
|
|
|
|
|
MEMORY => $memorySize, |
37
|
|
|
|
|
|
|
SWAP => $swapSize |
38
|
|
|
|
|
|
|
}); |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
my $zone = getZone(); |
41
|
|
|
|
|
|
|
|
42
|
0
|
0
|
|
|
|
|
my @memories = $zone eq 'global' ? |
43
|
|
|
|
|
|
|
_getMemoriesPrtdiag() : |
44
|
|
|
|
|
|
|
_getMemoriesPrctl() ; |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
foreach my $memory (@memories) { |
47
|
0
|
|
|
|
|
|
$inventory->addEntry( |
48
|
|
|
|
|
|
|
section => 'MEMORIES', |
49
|
|
|
|
|
|
|
entry => $memory |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub _getMemoriesPrtdiag { |
55
|
0
|
|
|
0
|
|
|
my $info = getPrtdiagInfos(@_); |
56
|
|
|
|
|
|
|
|
57
|
0
|
0
|
|
|
|
|
return $info->{memories} ? @{$info->{memories}} : (); |
|
0
|
|
|
|
|
|
|
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; |