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