line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::MacOS::Uptime; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
87520260
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
80
|
|
4
|
2
|
|
|
2
|
|
17
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
109
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
1289
|
use FusionInventory::Agent::Tools; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
788
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub isEnabled { |
9
|
0
|
|
|
0
|
0
|
0
|
return getFirstLine(command => 'sysctl -n kern.boottime'); |
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub doInventory { |
13
|
0
|
|
|
0
|
0
|
0
|
my (%params) = @_; |
14
|
|
|
|
|
|
|
|
15
|
0
|
|
|
|
|
0
|
my $inventory = $params{inventory}; |
16
|
|
|
|
|
|
|
|
17
|
0
|
|
|
|
|
0
|
my $arch = getFirstLine(command => 'uname -m'); |
18
|
0
|
|
|
|
|
0
|
my $uptime = _getUptime(command => 'sysctl -n kern.boottime'); |
19
|
0
|
|
|
|
|
0
|
$inventory->setHardware({ |
20
|
|
|
|
|
|
|
DESCRIPTION => "$arch/$uptime" |
21
|
|
|
|
|
|
|
}); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub _getBootTime { |
25
|
2
|
|
|
2
|
|
552
|
my $boottime = getFirstMatch( |
26
|
|
|
|
|
|
|
pattern => qr/(\d+)$/, |
27
|
|
|
|
|
|
|
@_, |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
2
|
|
|
|
|
7
|
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; |