line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::BSD::Uptime; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
93015466
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
39
|
|
4
|
1
|
|
|
1
|
|
8
|
use warnings; |
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
54
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
399
|
use FusionInventory::Agent::Tools; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
263
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub isEnabled { |
9
|
0
|
|
|
0
|
0
|
|
return canRun('sysctl'); |
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 _getUptime { |
25
|
0
|
|
|
0
|
|
|
my $line = getFirstLine(@_); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# the output of 'sysctl -n kern.boottime' differs between BSD flavours |
28
|
0
|
0
|
|
|
|
|
my $boottime = |
|
|
0
|
|
|
|
|
|
29
|
|
|
|
|
|
|
$line =~ /^(\d+)/ ? $1 : # OpenBSD format |
30
|
|
|
|
|
|
|
$line =~ /sec = (\d+)/ ? $1 : # FreeBSD format |
31
|
|
|
|
|
|
|
undef; |
32
|
0
|
0
|
|
|
|
|
return unless $boottime; |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
my $uptime = $boottime - time(); |
35
|
0
|
|
|
|
|
|
return getFormatedGMTTime($uptime); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
1; |