line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::Linux::Networks::FibreChannel; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
115526345
|
use strict; |
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
76
|
|
4
|
1
|
|
|
1
|
|
10
|
use warnings; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
68
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
432
|
use FusionInventory::Agent::Tools; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
386
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub isEnabled { |
9
|
0
|
|
|
0
|
0
|
|
return canRun('systool'); |
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub doInventory { |
13
|
0
|
|
|
0
|
0
|
|
my (%params) = @_; |
14
|
|
|
|
|
|
|
|
15
|
0
|
|
|
|
|
|
my $inventory = $params{inventory}; |
16
|
0
|
|
|
|
|
|
my $logger = $params{logger}; |
17
|
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
|
my @interfaces = _getInterfacesFromFcHost(logger => $logger); |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
foreach my $interface (@interfaces) { |
21
|
0
|
|
|
|
|
|
$inventory->addEntry( |
22
|
|
|
|
|
|
|
section => 'NETWORKS', |
23
|
|
|
|
|
|
|
entry => $interface |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub _getInterfacesFromFcHost { |
29
|
0
|
|
|
0
|
|
|
my (%params) = ( |
30
|
|
|
|
|
|
|
command => 'systool -c fc_host -v', |
31
|
|
|
|
|
|
|
@_ |
32
|
|
|
|
|
|
|
); |
33
|
0
|
|
|
|
|
|
my $handle = getFileHandle(%params); |
34
|
0
|
0
|
|
|
|
|
return unless $handle; |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
my @interfaces; |
37
|
|
|
|
|
|
|
my $interface; |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
while (my $line = <$handle>) { |
40
|
0
|
0
|
|
|
|
|
if ($line =~ /Class Device = "(.+)"/) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
$interface = { |
42
|
|
|
|
|
|
|
DESCRIPTION => $1, |
43
|
|
|
|
|
|
|
TYPE => 'fibrechannel' |
44
|
|
|
|
|
|
|
}; |
45
|
|
|
|
|
|
|
} elsif ($line =~ /port_name\s+= "0x(\w+)"/) { |
46
|
0
|
|
|
|
|
|
$interface->{'WWN'} = join(':', unpack '(A2)*', $1); |
47
|
|
|
|
|
|
|
} elsif ($line =~ /port_state\s+= "(\w+)"/) { |
48
|
0
|
0
|
|
|
|
|
if ($1 eq 'Online') { |
|
|
0
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
$interface->{'STATUS'} = 'Up'; |
50
|
|
|
|
|
|
|
} elsif ($1 eq 'Linkdown') { |
51
|
0
|
|
|
|
|
|
$interface->{'STATUS'} = 'Down'; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
} elsif ($line =~ /speed\s+= "(.+)"/) { |
54
|
0
|
0
|
|
|
|
|
$interface->{'SPEED'} = $1 if ($1 ne 'unknown'); |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
push @interfaces, $interface; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
return @interfaces; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |