line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::Linux; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
25528949
|
use strict; |
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
69
|
|
4
|
1
|
|
|
1
|
|
12
|
use warnings; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
92
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use English qw(-no_match_vars); |
|
1
|
|
|
|
|
33
|
|
|
1
|
|
|
|
|
20
|
|
7
|
1
|
|
|
1
|
|
1402
|
use XML::TreePP; |
|
1
|
|
|
|
|
10834
|
|
|
1
|
|
|
|
|
27
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
752
|
use FusionInventory::Agent::Tools; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
360
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $runAfter = ["FusionInventory::Agent::Task::Inventory::Generic"]; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub isEnabled { |
15
|
0
|
|
|
0
|
0
|
|
return $OSNAME eq 'linux'; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub doInventory { |
19
|
0
|
|
|
0
|
0
|
|
my (%params) = @_; |
20
|
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
|
my $inventory = $params{inventory}; |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
my $kernelVersion = getFirstLine(command => 'uname -v'); |
24
|
0
|
|
|
|
|
|
my $kernelRelease = getFirstLine(command => 'uname -r'); |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
my $systemId = _getRHNSystemId('/etc/sysconfig/rhn/systemid'); |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
my $boottime = |
29
|
|
|
|
|
|
|
time - getFirstMatch(file => '/proc/uptime', pattern => qr/^(\d+)/); |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
$inventory->setHardware({ |
32
|
|
|
|
|
|
|
OSVERSION => $kernelRelease, |
33
|
|
|
|
|
|
|
OSCOMMENTS => $kernelVersion, |
34
|
|
|
|
|
|
|
WINPRODID => $systemId, |
35
|
|
|
|
|
|
|
}); |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
$inventory->setOperatingSystem({ |
38
|
|
|
|
|
|
|
KERNEL_VERSION => $kernelRelease, |
39
|
|
|
|
|
|
|
BOOT_TIME => getFormatedLocalTime($boottime) |
40
|
|
|
|
|
|
|
}); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# Get RedHat Network SystemId |
45
|
|
|
|
|
|
|
sub _getRHNSystemId { |
46
|
0
|
|
|
0
|
|
|
my ($file) = @_; |
47
|
|
|
|
|
|
|
|
48
|
0
|
0
|
|
|
|
|
return unless -f $file; |
49
|
0
|
|
|
|
|
|
my $tpp = XML::TreePP->new(); |
50
|
0
|
|
|
|
|
|
my $h = $tpp->parsefile($file); |
51
|
0
|
|
|
|
|
|
eval { |
52
|
0
|
|
|
|
|
|
foreach (@{$h->{params}{param}{value}{struct}{member}}) { |
|
0
|
|
|
|
|
|
|
53
|
0
|
0
|
|
|
|
|
next unless $_->{name} eq 'system_id'; |
54
|
0
|
|
|
|
|
|
return $_->{value}{string}; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |