| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::Solaris::Networks; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
86347923
|
use strict; |
|
|
1
|
|
|
|
|
7
|
|
|
|
1
|
|
|
|
|
80
|
|
|
4
|
1
|
|
|
1
|
|
12
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
74
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
#ce5: flags=1000843 mtu 1500 index 3 |
|
7
|
|
|
|
|
|
|
# inet 55.37.101.171 netmask fffffc00 broadcast 55.37.103.255 |
|
8
|
|
|
|
|
|
|
# ether 0:3:ba:24:9b:bf |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
#aggr40001:2: flags=201000843 mtu 1500 index 3 |
|
11
|
|
|
|
|
|
|
# inet 55.37.101.172 netmask ffffff00 broadcast 223.0.146.255 |
|
12
|
|
|
|
|
|
|
#NDD=/usr/sbin/ndd |
|
13
|
|
|
|
|
|
|
#KSTAT=/usr/bin/kstat |
|
14
|
|
|
|
|
|
|
#IFC=/sbin/ifconfig |
|
15
|
|
|
|
|
|
|
#DLADM=/usr/sbin/dladm |
|
16
|
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
410
|
use FusionInventory::Agent::Tools; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
227
|
|
|
18
|
1
|
|
|
1
|
|
602
|
use FusionInventory::Agent::Tools::Solaris; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
81
|
|
|
19
|
1
|
|
|
1
|
|
494
|
use FusionInventory::Agent::Tools::Network; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
232
|
|
|
20
|
1
|
|
|
1
|
|
598
|
use FusionInventory::Agent::Tools::Unix; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
1729
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub isEnabled { |
|
23
|
0
|
|
|
0
|
0
|
|
my (%params) = @_; |
|
24
|
0
|
0
|
|
|
|
|
return 0 if $params{no_category}->{network}; |
|
25
|
0
|
|
|
|
|
|
return canRun('ifconfig'); |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub doInventory { |
|
29
|
0
|
|
|
0
|
0
|
|
my (%params) = @_; |
|
30
|
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
my $inventory = $params{inventory}; |
|
32
|
0
|
|
|
|
|
|
my $logger = $params{logger}; |
|
33
|
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
my $routes = getRoutingTable(logger => $logger); |
|
35
|
0
|
|
|
|
|
|
my $default = $routes->{'0.0.0.0'}; |
|
36
|
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
my @interfaces = _getInterfaces(logger => $logger); |
|
38
|
0
|
|
|
|
|
|
foreach my $interface (@interfaces) { |
|
39
|
|
|
|
|
|
|
# if the default gateway address and the interface address belongs to |
|
40
|
|
|
|
|
|
|
# the same network, that's the gateway for this network |
|
41
|
0
|
0
|
|
|
|
|
$interface->{IPGATEWAY} = $default if isSameNetwork( |
|
42
|
|
|
|
|
|
|
$default, $interface->{IPADDRESS}, $interface->{IPMASK} |
|
43
|
|
|
|
|
|
|
); |
|
44
|
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
$inventory->addEntry( |
|
46
|
|
|
|
|
|
|
section => 'NETWORKS', |
|
47
|
|
|
|
|
|
|
entry => $interface |
|
48
|
|
|
|
|
|
|
); |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
$inventory->setHardware({ |
|
52
|
0
|
|
|
|
|
|
DEFAULTGATEWAY => $default |
|
53
|
|
|
|
|
|
|
}); |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub _getInterfaces { |
|
57
|
0
|
|
|
0
|
|
|
my (%params) = @_; |
|
58
|
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
my @interfaces = _parseIfconfig( |
|
60
|
|
|
|
|
|
|
command => 'ifconfig -a', |
|
61
|
|
|
|
|
|
|
@_ |
|
62
|
|
|
|
|
|
|
); |
|
63
|
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
foreach my $interface (@interfaces) { |
|
65
|
0
|
|
|
|
|
|
$interface->{IPSUBNET} = getSubnetAddress( |
|
66
|
|
|
|
|
|
|
$interface->{IPADDRESS}, |
|
67
|
|
|
|
|
|
|
$interface->{IPMASK} |
|
68
|
|
|
|
|
|
|
); |
|
69
|
|
|
|
|
|
|
|
|
70
|
0
|
0
|
|
|
|
|
if ($interface->{DESCRIPTION} =~ /^(\S+)(\d+)/) { |
|
71
|
0
|
|
|
|
|
|
my $nic = $1; |
|
72
|
0
|
|
|
|
|
|
my $num = $2; |
|
73
|
|
|
|
|
|
|
|
|
74
|
0
|
0
|
|
|
|
|
$interface->{SPEED} = |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
$nic =~ /aggr/ ? undef : |
|
76
|
|
|
|
|
|
|
$nic =~ /dmfe/ ? undef : |
|
77
|
|
|
|
|
|
|
$nic =~ /bge/ ? _check_bge_nic($nic, $num) : |
|
78
|
|
|
|
|
|
|
$nic =~ /nxge/ ? _check_nxge_nic($nic, $num) : |
|
79
|
|
|
|
|
|
|
$nic =~ /ce/ ? _check_ce_nic($nic, $num) : |
|
80
|
|
|
|
|
|
|
$nic =~ /ipge/ ? _check_ce_nic($nic, $num) : |
|
81
|
|
|
|
|
|
|
$nic =~ /e1000g/ ? _check_ce_nic($nic, $num) : |
|
82
|
|
|
|
|
|
|
_check_nic($nic, $num); |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
my $zone = getZone(); |
|
87
|
0
|
|
|
|
|
|
my $OSLevel = getFirstLine(command => 'uname -r'); |
|
88
|
|
|
|
|
|
|
|
|
89
|
0
|
0
|
0
|
|
|
|
if ($zone && $OSLevel && $OSLevel =~ /5.10/) { |
|
|
|
|
0
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
push @interfaces, _parseDladm( |
|
91
|
|
|
|
|
|
|
command => '/usr/sbin/dladm show-aggr', |
|
92
|
|
|
|
|
|
|
logger => $params{logger} |
|
93
|
|
|
|
|
|
|
); |
|
94
|
|
|
|
|
|
|
|
|
95
|
0
|
|
|
|
|
|
push @interfaces, _parsefcinfo( |
|
96
|
|
|
|
|
|
|
command => '/usr/sbin/fcinfo hba-port', |
|
97
|
|
|
|
|
|
|
logger => $params{logger} |
|
98
|
|
|
|
|
|
|
); |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
|
|
101
|
0
|
|
|
|
|
|
return @interfaces; |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
# Function to test Quad Fast-Ethernet, Fast-Ethernet, and |
|
106
|
|
|
|
|
|
|
# Gigabit-Ethernet (i.e. qfe_, hme_, ge_, fjgi_) |
|
107
|
|
|
|
|
|
|
sub _check_nic { |
|
108
|
0
|
|
|
0
|
|
|
my ($nic, $num) = @_; |
|
109
|
|
|
|
|
|
|
|
|
110
|
0
|
|
|
|
|
|
my $speed = getFirstMatch( |
|
111
|
|
|
|
|
|
|
command => "/usr/sbin/ndd -get /dev/$nic link_speed", |
|
112
|
|
|
|
|
|
|
pattern => qr/^(\d+)/ |
|
113
|
|
|
|
|
|
|
); |
|
114
|
|
|
|
|
|
|
|
|
115
|
0
|
|
|
|
|
|
my $duplex = getFirstMatch( |
|
116
|
|
|
|
|
|
|
command => "/usr/sbin/ndd -get /dev/$nic link_mode", |
|
117
|
|
|
|
|
|
|
pattern => qr/^(\d+)/ |
|
118
|
|
|
|
|
|
|
); |
|
119
|
|
|
|
|
|
|
|
|
120
|
0
|
0
|
|
|
|
|
my $arg = $nic =~ /ge/ ? 'adv_1000autoneg_cap' : 'adv_autoneg_cap'; |
|
121
|
0
|
|
|
|
|
|
my $auto = getFirstMatch( |
|
122
|
|
|
|
|
|
|
command => "/usr/sbin/ndd -get /dev/$nic $arg", |
|
123
|
|
|
|
|
|
|
pattern => qr/^(\d+)/ |
|
124
|
|
|
|
|
|
|
); |
|
125
|
|
|
|
|
|
|
|
|
126
|
0
|
|
|
|
|
|
return _get_link_info($speed, $duplex, $auto); |
|
127
|
|
|
|
|
|
|
} |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
# Function to test a Gigabit-Ethernet (i.e. ce_). |
|
130
|
|
|
|
|
|
|
# Function to test a Intel 82571-based ethernet controller port (i.e. ipge_). |
|
131
|
|
|
|
|
|
|
sub _check_ce_nic { |
|
132
|
0
|
|
|
0
|
|
|
my ($nic, $num) = @_; |
|
133
|
|
|
|
|
|
|
|
|
134
|
0
|
|
|
|
|
|
my $speed = getFirstMatch( |
|
135
|
|
|
|
|
|
|
command => "/usr/bin/kstat -m $nic -i $num -s link_speed", |
|
136
|
|
|
|
|
|
|
pattern => qr/^\s*link_speed+\s*(\d+)/ |
|
137
|
|
|
|
|
|
|
); |
|
138
|
|
|
|
|
|
|
|
|
139
|
0
|
|
|
|
|
|
my $duplex = getFirstMatch( |
|
140
|
|
|
|
|
|
|
command => "/usr/bin/kstat -m $nic -i $num -s link_duplex", |
|
141
|
|
|
|
|
|
|
pattern => qr/^\s*link_duplex+\s*(\d+)/ |
|
142
|
|
|
|
|
|
|
); |
|
143
|
|
|
|
|
|
|
|
|
144
|
0
|
|
|
|
|
|
my $auto = getFirstMatch( |
|
145
|
|
|
|
|
|
|
command => "/usr/bin/kstat -m $nic -i $num -s cap_autoneg", |
|
146
|
|
|
|
|
|
|
pattern => qr/^\s*cap_autoneg+\s*(\d+)/ |
|
147
|
|
|
|
|
|
|
); |
|
148
|
|
|
|
|
|
|
|
|
149
|
0
|
|
|
|
|
|
return _get_link_info($speed, $duplex, $auto); |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
} |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
# Function to test Sun BGE interface on Sun Fire V210 and V240. |
|
154
|
|
|
|
|
|
|
# The BGE is a Broadcom BCM5704 chipset. There are four interfaces |
|
155
|
|
|
|
|
|
|
# on the V210 and V240. (i.e. bge_) |
|
156
|
|
|
|
|
|
|
sub _check_bge_nic { |
|
157
|
0
|
|
|
0
|
|
|
my ($nic, $num) = @_; |
|
158
|
|
|
|
|
|
|
|
|
159
|
0
|
|
|
|
|
|
my $speed = getFirstMatch( |
|
160
|
|
|
|
|
|
|
command => "/usr/sbin/ndd -get /dev/$nic$num link_speed", |
|
161
|
|
|
|
|
|
|
pattern => qr/^(\d+)/ |
|
162
|
|
|
|
|
|
|
); |
|
163
|
|
|
|
|
|
|
|
|
164
|
0
|
|
|
|
|
|
my $duplex = getFirstMatch( |
|
165
|
|
|
|
|
|
|
command => "/usr/sbin/ndd -get /dev/$nic$num link_duplex", |
|
166
|
|
|
|
|
|
|
pattern => qr/^(\d+)/ |
|
167
|
|
|
|
|
|
|
); |
|
168
|
|
|
|
|
|
|
|
|
169
|
0
|
|
|
|
|
|
my $auto = getFirstMatch( |
|
170
|
|
|
|
|
|
|
command => "/usr/sbin/ndd -get /dev/$nic$num adv_autoneg_cap", |
|
171
|
|
|
|
|
|
|
pattern => qr/^(\d+)/ |
|
172
|
|
|
|
|
|
|
); |
|
173
|
|
|
|
|
|
|
|
|
174
|
0
|
|
|
|
|
|
return _get_link_info($speed, $duplex, $auto); |
|
175
|
|
|
|
|
|
|
} |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
# Function to test Sun NXGE interface on Sun Fire Tx000. |
|
179
|
|
|
|
|
|
|
sub _check_nxge_nic { |
|
180
|
0
|
|
|
0
|
|
|
my ($nic, $num) = @_; |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
#nxge0 link: up speed: 1000 Mbps duplex: full |
|
183
|
0
|
|
|
|
|
|
my ($speed, $unit, $duplex) = getFirstMatch( |
|
184
|
|
|
|
|
|
|
command => "/usr/sbin/dladm show-dev $nic$num", |
|
185
|
|
|
|
|
|
|
pattern => qr/ |
|
186
|
|
|
|
|
|
|
$nic$num \s+ |
|
187
|
|
|
|
|
|
|
link: \s \S+ \s+ |
|
188
|
|
|
|
|
|
|
speed: \s (\d+) \s+ (\S+) \s+ |
|
189
|
|
|
|
|
|
|
duplex: \s (\S+) |
|
190
|
|
|
|
|
|
|
/x |
|
191
|
|
|
|
|
|
|
); |
|
192
|
0
|
|
|
|
|
|
return $speed . ' ' . $unit . ' ' . $duplex; |
|
193
|
|
|
|
|
|
|
} |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
sub _get_link_info { |
|
196
|
0
|
|
|
0
|
|
|
my ($speed, $duplex, $auto) = @_; |
|
197
|
|
|
|
|
|
|
|
|
198
|
0
|
|
|
|
|
|
my $info; |
|
199
|
|
|
|
|
|
|
|
|
200
|
0
|
0
|
|
|
|
|
if ($speed) { |
|
201
|
0
|
0
|
|
|
|
|
$info = |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
$speed == 0 ? "10 Mb/s" : |
|
203
|
|
|
|
|
|
|
$speed == 10 ? "10 Mb/s" : |
|
204
|
|
|
|
|
|
|
$speed == 100 ? "100 Mb/s" : |
|
205
|
|
|
|
|
|
|
$speed == 1000 ? "1 Gb/s" : |
|
206
|
|
|
|
|
|
|
"ERROR" ; |
|
207
|
|
|
|
|
|
|
} |
|
208
|
|
|
|
|
|
|
|
|
209
|
0
|
0
|
|
|
|
|
if ($duplex) { |
|
210
|
0
|
0
|
|
|
|
|
$info .= |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
$duplex == 2 ? " FDX" : |
|
212
|
|
|
|
|
|
|
$duplex == 1 ? " HDX" : |
|
213
|
|
|
|
|
|
|
$duplex == 0 ? " UNKNOWN" : |
|
214
|
|
|
|
|
|
|
" ERROR" ; |
|
215
|
|
|
|
|
|
|
} |
|
216
|
|
|
|
|
|
|
|
|
217
|
0
|
0
|
|
|
|
|
if ($auto) { |
|
218
|
0
|
0
|
|
|
|
|
$info .= |
|
|
|
0
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
$auto == 0 ? " AUTOSPEED ON" : |
|
220
|
|
|
|
|
|
|
$auto == 1 ? " AUTOSPEED OFF" : |
|
221
|
|
|
|
|
|
|
" ERROR" ; |
|
222
|
|
|
|
|
|
|
} |
|
223
|
|
|
|
|
|
|
|
|
224
|
0
|
|
|
|
|
|
return $info; |
|
225
|
|
|
|
|
|
|
} |
|
226
|
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
sub _parseIfconfig { |
|
228
|
0
|
|
|
0
|
|
|
my $handle = getFileHandle(@_); |
|
229
|
0
|
0
|
|
|
|
|
return unless $handle; |
|
230
|
|
|
|
|
|
|
|
|
231
|
0
|
|
|
|
|
|
my @interfaces; |
|
232
|
|
|
|
|
|
|
my $interface; |
|
233
|
|
|
|
|
|
|
|
|
234
|
0
|
|
|
|
|
|
while (my $line = <$handle>) { |
|
235
|
0
|
0
|
|
|
|
|
if ($line =~ /^(\S+):(\S+):/) { |
|
|
|
0
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
# new interface |
|
237
|
0
|
0
|
|
|
|
|
push @interfaces, $interface if $interface; |
|
238
|
|
|
|
|
|
|
# quick assertion: nothing else as ethernet interface |
|
239
|
0
|
|
|
|
|
|
$interface = { |
|
240
|
|
|
|
|
|
|
STATUS => 'Down', |
|
241
|
|
|
|
|
|
|
DESCRIPTION => $1 . ':' . $2, |
|
242
|
|
|
|
|
|
|
TYPE => 'ethernet' |
|
243
|
|
|
|
|
|
|
}; |
|
244
|
|
|
|
|
|
|
} elsif ($line =~ /^(\S+):/) { |
|
245
|
|
|
|
|
|
|
# new interface |
|
246
|
0
|
0
|
|
|
|
|
push @interfaces, $interface if $interface; |
|
247
|
|
|
|
|
|
|
# quick assertion: nothing else as ethernet interface |
|
248
|
0
|
|
|
|
|
|
$interface = { |
|
249
|
|
|
|
|
|
|
STATUS => 'Down', |
|
250
|
|
|
|
|
|
|
DESCRIPTION => $1, |
|
251
|
|
|
|
|
|
|
TYPE => 'ethernet' |
|
252
|
|
|
|
|
|
|
}; |
|
253
|
|
|
|
|
|
|
} |
|
254
|
|
|
|
|
|
|
|
|
255
|
0
|
0
|
|
|
|
|
if ($line =~ /inet ($ip_address_pattern)/) { |
|
256
|
0
|
|
|
|
|
|
$interface->{IPADDRESS} = $1; |
|
257
|
|
|
|
|
|
|
} |
|
258
|
0
|
0
|
|
|
|
|
if ($line =~ /netmask ($hex_ip_address_pattern)/i) { |
|
259
|
0
|
|
|
|
|
|
$interface->{IPMASK} = hex2canonical($1); |
|
260
|
|
|
|
|
|
|
} |
|
261
|
0
|
0
|
|
|
|
|
if ($line =~ /ether\s+(\S+)/i) { |
|
262
|
|
|
|
|
|
|
# https://sourceforge.net/tracker/?func=detail&atid=487492&aid=1819948&group_id=58373 |
|
263
|
0
|
|
|
|
|
|
$interface->{MACADDR} = |
|
264
|
|
|
|
|
|
|
sprintf "%02x:%02x:%02x:%02x:%02x:%02x" , map hex, split /\:/, $1; |
|
265
|
|
|
|
|
|
|
} |
|
266
|
0
|
0
|
|
|
|
|
if ($line =~ /
|
|
267
|
0
|
|
|
|
|
|
$interface->{STATUS} = "Up"; |
|
268
|
|
|
|
|
|
|
} |
|
269
|
|
|
|
|
|
|
} |
|
270
|
0
|
|
|
|
|
|
close $handle; |
|
271
|
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
# last interface |
|
273
|
0
|
0
|
|
|
|
|
push @interfaces, $interface if $interface; |
|
274
|
|
|
|
|
|
|
|
|
275
|
0
|
|
|
|
|
|
return @interfaces; |
|
276
|
|
|
|
|
|
|
} |
|
277
|
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
sub _parseDladm { |
|
279
|
0
|
|
|
0
|
|
|
my $handle = getFileHandle(@_); |
|
280
|
0
|
0
|
|
|
|
|
return unless $handle; |
|
281
|
|
|
|
|
|
|
|
|
282
|
0
|
|
|
|
|
|
my @interfaces; |
|
283
|
0
|
|
|
|
|
|
while (my $line = <$handle>) { |
|
284
|
0
|
0
|
|
|
|
|
next if $line =~ /device/; |
|
285
|
0
|
0
|
|
|
|
|
next if $line =~ /key/; |
|
286
|
0
|
|
|
|
|
|
my $interface = { |
|
287
|
|
|
|
|
|
|
STATUS => 'Down', |
|
288
|
|
|
|
|
|
|
IPADDRESS => "0.0.0.0", |
|
289
|
|
|
|
|
|
|
}; |
|
290
|
|
|
|
|
|
|
next unless |
|
291
|
0
|
0
|
|
|
|
|
$line =~ /(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)/; |
|
292
|
0
|
|
|
|
|
|
$interface->{DESCRIPTION} = $1; |
|
293
|
0
|
|
|
|
|
|
$interface->{MACADDR} = $2; |
|
294
|
0
|
|
|
|
|
|
$interface->{SPEED} = $3 . " " . $4 . " " . $5; |
|
295
|
0
|
0
|
|
|
|
|
$interface->{STATUS} = 'Up' if $line =~ /UP/; |
|
296
|
0
|
|
|
|
|
|
push @interfaces, $interface; |
|
297
|
|
|
|
|
|
|
} |
|
298
|
0
|
|
|
|
|
|
close $handle; |
|
299
|
|
|
|
|
|
|
|
|
300
|
0
|
|
|
|
|
|
return @interfaces; |
|
301
|
|
|
|
|
|
|
} |
|
302
|
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
sub _parsefcinfo { |
|
304
|
0
|
|
|
0
|
|
|
my $handle = getFileHandle(@_); |
|
305
|
0
|
0
|
|
|
|
|
return unless $handle; |
|
306
|
|
|
|
|
|
|
|
|
307
|
0
|
|
|
|
|
|
my @interfaces; |
|
308
|
0
|
|
|
|
|
|
my $inc = 1; |
|
309
|
0
|
|
|
|
|
|
my $interface; |
|
310
|
0
|
|
|
|
|
|
while (my $line = <$handle>) { |
|
311
|
0
|
0
|
|
|
|
|
$interface->{DESCRIPTION} = "HBA_Port_WWN_" . $inc |
|
312
|
|
|
|
|
|
|
if $line =~ /HBA Port WWN:\s+(\S+)/; |
|
313
|
0
|
0
|
|
|
|
|
$interface->{DESCRIPTION} .= " " . $1 |
|
314
|
|
|
|
|
|
|
if $line =~ /OS Device Name:\s+(\S+)/; |
|
315
|
0
|
0
|
|
|
|
|
$interface->{SPEED} = $1 |
|
316
|
|
|
|
|
|
|
if $line =~ /Current Speed:\s+(\S+)/; |
|
317
|
0
|
0
|
|
|
|
|
$interface->{WWN} = $1 |
|
318
|
|
|
|
|
|
|
if $line =~ /Node WWN:\s+(\S+)/; |
|
319
|
0
|
0
|
|
|
|
|
$interface->{DRIVER} = $1 |
|
320
|
|
|
|
|
|
|
if $line =~ /Driver Name:\s+(\S+)/i; |
|
321
|
0
|
0
|
|
|
|
|
$interface->{MANUFACTURER} = $1 |
|
322
|
|
|
|
|
|
|
if $line =~ /Manufacturer:\s+(.*)$/; |
|
323
|
0
|
0
|
|
|
|
|
$interface->{MODEL} = $1 |
|
324
|
|
|
|
|
|
|
if $line =~ /Model:\s+(.*)$/; |
|
325
|
0
|
0
|
|
|
|
|
$interface->{FIRMWARE} = $1 |
|
326
|
|
|
|
|
|
|
if $line =~ /Firmware Version:\s+(.*)$/; |
|
327
|
0
|
0
|
|
|
|
|
$interface->{STATUS} = 'Up' |
|
328
|
|
|
|
|
|
|
if $line =~ /online/; |
|
329
|
|
|
|
|
|
|
|
|
330
|
0
|
0
|
0
|
|
|
|
if ($interface->{DESCRIPTION} && $interface->{WWN}) { |
|
331
|
0
|
0
|
|
|
|
|
$interface->{STATUS} = 'Down' if !$interface->{STATUS}; |
|
332
|
|
|
|
|
|
|
|
|
333
|
0
|
|
|
|
|
|
push @interfaces, $interface; |
|
334
|
0
|
|
|
|
|
|
$interface = {}; |
|
335
|
0
|
|
|
|
|
|
$inc++; |
|
336
|
|
|
|
|
|
|
} |
|
337
|
|
|
|
|
|
|
} |
|
338
|
0
|
|
|
|
|
|
close $handle; |
|
339
|
|
|
|
|
|
|
|
|
340
|
0
|
|
|
|
|
|
return @interfaces; |
|
341
|
|
|
|
|
|
|
} |
|
342
|
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
1; |