line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::Linux; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
33852676
|
use strict; |
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
84
|
|
4
|
2
|
|
|
2
|
|
22
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
117
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
774
|
use English qw(-no_match_vars); |
|
2
|
|
|
|
|
4315
|
|
|
2
|
|
|
|
|
47
|
|
7
|
2
|
|
|
2
|
|
3714
|
use XML::TreePP; |
|
2
|
|
|
|
|
20380
|
|
|
2
|
|
|
|
|
73
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
1660
|
use FusionInventory::Agent::Tools; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
961
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $runAfter = ["FusionInventory::Agent::Task::Inventory::Generic"]; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub isEnabled { |
15
|
0
|
|
|
0
|
0
|
0
|
return $OSNAME eq 'linux'; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub doInventory { |
19
|
0
|
|
|
0
|
0
|
0
|
my (%params) = @_; |
20
|
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
0
|
my $inventory = $params{inventory}; |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
0
|
my $kernelVersion = getFirstLine(command => 'uname -v'); |
24
|
0
|
|
|
|
|
0
|
my $kernelRelease = getFirstLine(command => 'uname -r'); |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
0
|
my $systemId = _getRHNSystemId('/etc/sysconfig/rhn/systemid'); |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
0
|
my $boottime = |
29
|
|
|
|
|
|
|
time - getFirstMatch(file => '/proc/uptime', pattern => qr/^(\d+)/); |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
0
|
$inventory->setHardware({ |
32
|
|
|
|
|
|
|
OSVERSION => $kernelRelease, |
33
|
|
|
|
|
|
|
OSCOMMENTS => $kernelVersion, |
34
|
|
|
|
|
|
|
WINPRODID => $systemId, |
35
|
|
|
|
|
|
|
}); |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
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
|
1
|
|
|
1
|
|
177
|
my ($file) = @_; |
47
|
|
|
|
|
|
|
|
48
|
1
|
50
|
|
|
|
41
|
return unless -f $file; |
49
|
1
|
|
|
|
|
10
|
my $tpp = XML::TreePP->new(); |
50
|
1
|
|
|
|
|
11
|
my $h = $tpp->parsefile($file); |
51
|
1
|
|
|
|
|
6038
|
eval { |
52
|
1
|
|
|
|
|
2
|
foreach (@{$h->{params}{param}{value}{struct}{member}}) { |
|
1
|
|
|
|
|
4
|
|
53
|
6
|
100
|
|
|
|
19
|
next unless $_->{name} eq 'system_id'; |
54
|
1
|
|
|
|
|
12
|
return $_->{value}{string}; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |