line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::MacOS::Uptime; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
65879686
|
use strict; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
67
|
|
4
|
1
|
|
|
1
|
|
9
|
use warnings; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
56
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
423
|
use FusionInventory::Agent::Tools; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
274
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub isEnabled { |
9
|
0
|
|
|
0
|
0
|
|
return getFirstLine(command => 'sysctl -n kern.boottime'); |
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub doInventory { |
13
|
0
|
|
|
0
|
0
|
|
my (%params) = @_; |
14
|
|
|
|
|
|
|
|
15
|
0
|
|
|
|
|
|
my $inventory = $params{inventory}; |
16
|
|
|
|
|
|
|
|
17
|
0
|
|
|
|
|
|
my $arch = getFirstLine(command => 'uname -m'); |
18
|
0
|
|
|
|
|
|
my $uptime = _getUptime(command => 'sysctl -n kern.boottime'); |
19
|
0
|
|
|
|
|
|
$inventory->setHardware({ |
20
|
|
|
|
|
|
|
DESCRIPTION => "$arch/$uptime" |
21
|
|
|
|
|
|
|
}); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub _getBootTime { |
25
|
0
|
|
|
0
|
|
|
my $boottime = getFirstMatch( |
26
|
|
|
|
|
|
|
pattern => qr/(\d+)$/, |
27
|
|
|
|
|
|
|
@_, |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
return $boottime; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub _getUptime { |
34
|
0
|
|
|
0
|
|
|
my $boottime = _getBootTime(@_); |
35
|
0
|
0
|
|
|
|
|
return unless $boottime; |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
my $uptime = time() - $boottime; |
38
|
0
|
|
|
|
|
|
return getFormatedGMTTime($uptime); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |