line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::Generic::Dmidecode::Battery; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
152580082
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
105
|
|
4
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
181
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
747
|
use FusionInventory::Agent::Tools; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
411
|
|
7
|
2
|
|
|
2
|
|
1220
|
use FusionInventory::Agent::Tools::Generic; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
1263
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub isEnabled { |
10
|
0
|
|
|
0
|
0
|
0
|
my (%params) = @_; |
11
|
0
|
0
|
|
|
|
0
|
return 0 if $params{no_category}->{battery}; |
12
|
0
|
|
|
|
|
0
|
return 1; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub doInventory { |
16
|
0
|
|
|
0
|
0
|
0
|
my (%params) = @_; |
17
|
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
0
|
my $inventory = $params{inventory}; |
19
|
0
|
|
|
|
|
0
|
my $logger = $params{logger}; |
20
|
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
0
|
my $battery = _getBattery(logger => $logger); |
22
|
|
|
|
|
|
|
|
23
|
0
|
0
|
|
|
|
0
|
return unless $battery; |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
0
|
$inventory->addEntry( |
26
|
|
|
|
|
|
|
section => 'BATTERIES', |
27
|
|
|
|
|
|
|
entry => $battery |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _getBattery { |
32
|
11
|
|
|
11
|
|
3776
|
my $infos = getDmidecodeInfos(@_); |
33
|
|
|
|
|
|
|
|
34
|
11
|
100
|
|
|
|
145
|
return unless $infos->{22}; |
35
|
|
|
|
|
|
|
|
36
|
3
|
|
|
|
|
6
|
my $info = $infos->{22}->[0]; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my $battery = { |
39
|
|
|
|
|
|
|
NAME => $info->{'Name'}, |
40
|
|
|
|
|
|
|
MANUFACTURER => $info->{'Manufacturer'}, |
41
|
|
|
|
|
|
|
SERIAL => $info->{'Serial Number'} || |
42
|
|
|
|
|
|
|
$info->{'SBDS Serial Number'}, |
43
|
|
|
|
|
|
|
CHEMISTRY => $info->{'Chemistry'} || |
44
|
3
|
|
66
|
|
|
33
|
$info->{'SBDS Chemistry'}, |
|
|
|
66
|
|
|
|
|
45
|
|
|
|
|
|
|
}; |
46
|
|
|
|
|
|
|
|
47
|
3
|
100
|
|
|
|
15
|
if ($info->{'Manufacture Date'}) { |
|
|
50
|
|
|
|
|
|
48
|
1
|
|
|
|
|
4
|
$battery->{DATE} = _parseDate($info->{'Manufacture Date'}); |
49
|
|
|
|
|
|
|
} elsif ($info->{'SBDS Manufacture Date'}) { |
50
|
2
|
|
|
|
|
13
|
$battery->{DATE} = _parseDate($info->{'SBDS Manufacture Date'}); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
3
|
50
|
33
|
|
|
29
|
if ($info->{'Design Capacity'} && |
54
|
|
|
|
|
|
|
$info->{'Design Capacity'} =~ /(\d+) \s m[WA]h$/x) { |
55
|
3
|
|
|
|
|
9
|
$battery->{CAPACITY} = $1; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
3
|
50
|
33
|
|
|
24
|
if ($info->{'Design Voltage'} && |
59
|
|
|
|
|
|
|
$info->{'Design Voltage'} =~ /(\d+) \s mV$/x) { |
60
|
3
|
|
|
|
|
10
|
$battery->{VOLTAGE} = $1; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
3
|
|
|
|
|
9
|
return $battery; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub _parseDate { |
67
|
3
|
|
|
3
|
|
5
|
my ($string) = @_; |
68
|
|
|
|
|
|
|
|
69
|
3
|
|
|
|
|
6
|
my ($day, $month, $year); |
70
|
3
|
50
|
|
|
|
17
|
if ($string =~ /(\d{1,2}) [\/-] (\d{1,2}) [\/-] (\d{2})/x) { |
|
|
0
|
|
|
|
|
|
71
|
3
|
|
|
|
|
9
|
$day = $1; |
72
|
3
|
|
|
|
|
7
|
$month = $2; |
73
|
3
|
50
|
|
|
|
17
|
$year = ($3 > 90 ? "19" : "20" ) . $3; |
74
|
3
|
|
|
|
|
13
|
return "$day/$month/$year"; |
75
|
|
|
|
|
|
|
} elsif ($string =~ /(\d{4}) [\/-] (\d{1,2}) [\/-] (\d{1,2})/x) { |
76
|
0
|
|
|
|
|
|
$year = $1; |
77
|
0
|
|
|
|
|
|
$day = $2; |
78
|
0
|
|
|
|
|
|
$month = $3; |
79
|
0
|
|
|
|
|
|
return "$day/$month/$year"; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
return; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1; |