line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::HPUX::Uptime; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
71827615
|
use strict; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
62
|
|
4
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
55
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
396
|
use FusionInventory::Agent::Tools; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
276
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub isEnabled { |
9
|
|
|
|
|
|
|
return |
10
|
0
|
|
0
|
0
|
0
|
|
canRun('uptime') && |
11
|
|
|
|
|
|
|
canRun('uname'); |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub doInventory { |
15
|
0
|
|
|
0
|
0
|
|
my (%params) = @_; |
16
|
|
|
|
|
|
|
|
17
|
0
|
|
|
|
|
|
my $inventory = $params{inventory}; |
18
|
|
|
|
|
|
|
|
19
|
0
|
|
|
|
|
|
my $arch = getFirstLine(command => 'uname -m'); |
20
|
0
|
|
|
|
|
|
my $uptime = _getUptime(command => 'uptime'); |
21
|
0
|
|
|
|
|
|
$inventory->setHardware({ |
22
|
|
|
|
|
|
|
DESCRIPTION => "$arch/$uptime" |
23
|
|
|
|
|
|
|
}); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub _getUptime { |
27
|
0
|
|
|
0
|
|
|
my ($days, $hours, $minutes) = getFirstMatch( |
28
|
|
|
|
|
|
|
pattern => qr/up \s (?:(\d+)\sdays\D+)? (\d{1,2}) : (\d{1,2})/x, |
29
|
|
|
|
|
|
|
@_ |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
my $uptime = 0; |
33
|
0
|
0
|
|
|
|
|
$uptime += $days * 24 * 3600 if $days; |
34
|
0
|
|
|
|
|
|
$uptime += $hours * 3600; |
35
|
0
|
|
|
|
|
|
$uptime += $minutes * 60; |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
return getFormatedGMTTime($uptime); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
1; |