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