line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Cisco::UCS::Common::EthernetPort; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
23
|
|
4
|
1
|
|
|
1
|
|
2
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
15
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
2
|
use Carp qw(croak); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
35
|
|
7
|
1
|
|
|
1
|
|
3
|
use Scalar::Util qw(weaken); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
285
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.51'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our @ATTRIBUTES = qw( dn epDn mac mode type); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our %ATTRIBUTES = ( |
14
|
|
|
|
|
|
|
admin_state => 'adminState', |
15
|
|
|
|
|
|
|
chassis_id => 'chassisId', |
16
|
|
|
|
|
|
|
if_role => 'ifRole', |
17
|
|
|
|
|
|
|
if_type => 'ifType', |
18
|
|
|
|
|
|
|
label => 'usrLabel', |
19
|
|
|
|
|
|
|
license_state => 'licState', |
20
|
|
|
|
|
|
|
oper_state => 'operState', |
21
|
|
|
|
|
|
|
oper_speed => 'operSpeed', |
22
|
|
|
|
|
|
|
peer_dn => 'peerDn', |
23
|
|
|
|
|
|
|
peer_port_id => 'peerPortId', |
24
|
|
|
|
|
|
|
rcvr_type => 'xcvrType', |
25
|
|
|
|
|
|
|
switch_id => 'switchId', |
26
|
|
|
|
|
|
|
id => 'portId' |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
our %STATS = ( |
30
|
|
|
|
|
|
|
err => 'etherErrStats', |
31
|
|
|
|
|
|
|
rx => 'etherRxStats', |
32
|
|
|
|
|
|
|
tx => 'etherTxStats' |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
our %TX_STATS = our %RX_STATS = ( |
36
|
|
|
|
|
|
|
intervals => 'intervals', |
37
|
|
|
|
|
|
|
timestamp => 'timeCollected', |
38
|
|
|
|
|
|
|
suspect => 'suspect', |
39
|
|
|
|
|
|
|
update => 'update', |
40
|
|
|
|
|
|
|
broadcast_packets => 'broadcastPackets', |
41
|
|
|
|
|
|
|
broadcast_packets_delta => 'broadcastPacketsDelta', |
42
|
|
|
|
|
|
|
broadcast_packets_delta_avg => 'broadcastPacketsDeltaAvg', |
43
|
|
|
|
|
|
|
broadcast_packets_delta_min => 'broadcastPacketsDeltaMin', |
44
|
|
|
|
|
|
|
broadcast_packets_delta_max => 'broadcastPacketsDeltaMax', |
45
|
|
|
|
|
|
|
jumbo_packets => 'jumboPackets', |
46
|
|
|
|
|
|
|
jumbo_packets_delta => 'jumboPacketsDelta', |
47
|
|
|
|
|
|
|
jumbo_packets_delta_avg => 'jumboPacketsDeltaAvg', |
48
|
|
|
|
|
|
|
jumbo_packets_delta_min => 'jumboPacketsDeltaMin', |
49
|
|
|
|
|
|
|
jumbo_packets_delta_max => 'jumboPacketsDeltaMax', |
50
|
|
|
|
|
|
|
multicast_packets => 'multicastPackets', |
51
|
|
|
|
|
|
|
multicast_packets_delta => 'multicastPacketsDelta', |
52
|
|
|
|
|
|
|
multicast_packets_delta_avg => 'multicastPacketsDeltaAvg', |
53
|
|
|
|
|
|
|
multicast_packets_delta_min => 'multicastPacketsDeltaMin', |
54
|
|
|
|
|
|
|
multicast_packets_delta_max => 'multicastPacketsDeltaMax', |
55
|
|
|
|
|
|
|
total_bytes => 'totalBytes', |
56
|
|
|
|
|
|
|
total_bytes_delta => 'totalBytesDelta', |
57
|
|
|
|
|
|
|
total_bytes_delta_avg => 'totalBytesDeltaAvg', |
58
|
|
|
|
|
|
|
total_bytes_delta_min => 'totalBytesDeltaMin', |
59
|
|
|
|
|
|
|
total_bytes_delta_max => 'totalBytesDeltaMax', |
60
|
|
|
|
|
|
|
total_packets => 'totalPackets', |
61
|
|
|
|
|
|
|
total_packets_delta => 'totalPacketsDelta', |
62
|
|
|
|
|
|
|
total_packets_delta_avg => 'totalPacketsDeltaAvg', |
63
|
|
|
|
|
|
|
total_packets_delta_min => 'totalPacketsDeltaMin', |
64
|
|
|
|
|
|
|
total_packets_delta_max => 'totalPacketsDeltaMax', |
65
|
|
|
|
|
|
|
unicast_packets => 'unicastPackets', |
66
|
|
|
|
|
|
|
unicast_packets_delta => 'unicastPacketsDelta', |
67
|
|
|
|
|
|
|
unicast_packets_delta_avg => 'unicastPacketsDeltaAvg', |
68
|
|
|
|
|
|
|
unicast_packets_delta_min => 'unicastPacketsDeltaMin', |
69
|
|
|
|
|
|
|
unicast_packets_delta_max => 'unicastPacketsDeltaMax' |
70
|
|
|
|
|
|
|
); |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
our %ERR_STATS = ( |
73
|
|
|
|
|
|
|
intervals => 'intervals', |
74
|
|
|
|
|
|
|
update => 'update', |
75
|
|
|
|
|
|
|
suspect => 'suspect', |
76
|
|
|
|
|
|
|
timestamp => 'timeCollected', |
77
|
|
|
|
|
|
|
align => 'align', |
78
|
|
|
|
|
|
|
align_delta => 'alignDelta', |
79
|
|
|
|
|
|
|
align_delta_avg => 'alignDeltaAvg', |
80
|
|
|
|
|
|
|
align_delta_min => 'alignDeltaMin', |
81
|
|
|
|
|
|
|
align_delta_max => 'alignDeltaMax', |
82
|
|
|
|
|
|
|
deferred_tx => 'deferredTx', |
83
|
|
|
|
|
|
|
deferred_tx_delta => 'deferredTxDelta', |
84
|
|
|
|
|
|
|
deferred_tx_delta_avg => 'deferredTxDeltaAvg', |
85
|
|
|
|
|
|
|
deferred_tx_delta_min => 'deferredTxDeltaMin', |
86
|
|
|
|
|
|
|
deferred_tx_delta_max => 'deferredTxDeltaMax', |
87
|
|
|
|
|
|
|
fcs => 'fcs', |
88
|
|
|
|
|
|
|
fcs_delta => 'fcsDelta', |
89
|
|
|
|
|
|
|
fcs_delta_avg => 'fcsDeltaAvg', |
90
|
|
|
|
|
|
|
fcs_delta_min => 'fcsDeltaMin', |
91
|
|
|
|
|
|
|
fcs_delta_max => 'fcsDeltaMax', |
92
|
|
|
|
|
|
|
int_mac_tx => 'intMacTx', |
93
|
|
|
|
|
|
|
int_mac_tx_delta => 'intMacTxDelta', |
94
|
|
|
|
|
|
|
int_mac_tx_delta_avg => 'intMacTxDeltaAvg', |
95
|
|
|
|
|
|
|
int_mac_tx_delta_min => 'intMacTxDeltaMin', |
96
|
|
|
|
|
|
|
int_mac_tx_delta_max => 'intMacTxDeltaMax', |
97
|
|
|
|
|
|
|
int_mac_rx => 'intMacRx', |
98
|
|
|
|
|
|
|
int_mac_rx_delta => 'intMacRxDelta', |
99
|
|
|
|
|
|
|
int_mac_rx_delta_avg => 'intMacRxDeltaAvg', |
100
|
|
|
|
|
|
|
int_mac_rx_delta_min => 'intMacRxDeltaMin', |
101
|
|
|
|
|
|
|
int_mac_rx_delta_max => 'intMacRxDeltaMax', |
102
|
|
|
|
|
|
|
out_discard => 'outDiscard', |
103
|
|
|
|
|
|
|
out_discard_delta => 'outDiscardDelta', |
104
|
|
|
|
|
|
|
out_discard_delta_avg => 'outDiscardDeltaAvg', |
105
|
|
|
|
|
|
|
out_discard_delta_min => 'outDiscardDeltaMin', |
106
|
|
|
|
|
|
|
out_discard_delta_max => 'outDiscardDeltaMax', |
107
|
|
|
|
|
|
|
rcv => 'rcv', |
108
|
|
|
|
|
|
|
rcv_delta => 'rcvDelta', |
109
|
|
|
|
|
|
|
rcv_delta_avg => 'rcvDeltaAvg', |
110
|
|
|
|
|
|
|
rcv_delta_min => 'rcvDeltaMin', |
111
|
|
|
|
|
|
|
rcv_delta_max => 'rcvDeltaMax', |
112
|
|
|
|
|
|
|
undersize => 'underSize', |
113
|
|
|
|
|
|
|
undersize_delta => 'underSizeDelta', |
114
|
|
|
|
|
|
|
undersize_delta_avg => 'underSizeDeltaAvg', |
115
|
|
|
|
|
|
|
undersize_delta_min => 'underSizeDeltaMin', |
116
|
|
|
|
|
|
|
undersize_delta_max => 'underSizeDeltaMax', |
117
|
|
|
|
|
|
|
xmit => 'xmit', |
118
|
|
|
|
|
|
|
xmit_delta => 'xmitDelta', |
119
|
|
|
|
|
|
|
xmit_delta_avg => 'xmitDeltaAvg', |
120
|
|
|
|
|
|
|
xmit_delta_min => 'xmitDeltaMin', |
121
|
|
|
|
|
|
|
xmit_delta_max => 'xmitDeltaMax' |
122
|
|
|
|
|
|
|
); |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub new { |
125
|
0
|
|
|
0
|
0
|
|
my ( $class, %args ) = @_; |
126
|
|
|
|
|
|
|
|
127
|
0
|
|
|
|
|
|
my $self = {}; |
128
|
0
|
|
|
|
|
|
bless $self, $class; |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
defined $args{dn} |
131
|
|
|
|
|
|
|
? $self->{dn} = $args{dn} |
132
|
0
|
0
|
|
|
|
|
: croak 'dn not defined'; |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
defined $args{ucs} |
135
|
|
|
|
|
|
|
? weaken( $self->{ucs} = $args{ucs} ) |
136
|
0
|
0
|
|
|
|
|
: croak 'ucs not defined'; |
137
|
|
|
|
|
|
|
|
138
|
0
|
|
|
|
|
|
my %attr = %{ $self->{ucs}->resolve_dn( |
139
|
|
|
|
|
|
|
dn => $self->{dn} |
140
|
0
|
|
|
|
|
|
)->{outConfig}->{etherPIo}}; |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
{ |
143
|
1
|
|
|
1
|
|
3
|
no strict 'refs'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
20
|
|
|
0
|
|
|
|
|
|
|
144
|
1
|
|
|
1
|
|
3
|
no warnings qw(redefine); |
|
1
|
|
|
|
|
0
|
|
|
1
|
|
|
|
|
240
|
|
145
|
|
|
|
|
|
|
|
146
|
0
|
|
|
|
|
|
while ( my ( $pseudo, $attribute ) = each %STATS ) { |
147
|
0
|
|
|
|
|
|
*{ __PACKAGE__ . '::' . 'get_' . $pseudo . '_stats' } = sub { |
148
|
0
|
|
|
0
|
|
|
my $self = shift; |
149
|
0
|
|
|
|
|
|
return $self->_get_stats( $pseudo, $attribute ) |
150
|
|
|
|
|
|
|
} |
151
|
0
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
|
154
|
0
|
|
|
|
|
|
while ( my ( $k, $v ) = each %attr ) { $self->{$k} = $v } |
|
0
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
|
156
|
0
|
|
|
|
|
|
return $self; |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
sub _get_stats { |
160
|
0
|
|
|
0
|
|
|
my ( $self, $type, $class ) = @_; |
161
|
|
|
|
|
|
|
|
162
|
0
|
|
|
|
|
|
my %stats = %{ ( $self->{ucs}->resolve_dn( |
163
|
|
|
|
|
|
|
dn => "$self->{dn}/$type-stats" |
164
|
0
|
|
|
|
|
|
) )->{outConfig}->{$class} }; |
165
|
|
|
|
|
|
|
|
166
|
0
|
|
|
|
|
|
while ( my ( $k, $v ) = each %stats ) { $self->{$type}->{$k} = $v } |
|
0
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
|
168
|
0
|
|
|
|
|
|
return %stats |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
{ |
172
|
1
|
|
|
1
|
|
4
|
no strict 'refs'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
245
|
|
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
while ( my ( $pseudo, $attribute ) = each %ATTRIBUTES ) { |
175
|
|
|
|
|
|
|
*{ __PACKAGE__ . '::' . $pseudo } = sub { |
176
|
0
|
|
|
0
|
|
|
my $self = shift; |
177
|
0
|
|
|
|
|
|
return $self->{$attribute} |
178
|
|
|
|
|
|
|
} |
179
|
|
|
|
|
|
|
} |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
foreach my $attribute ( @ATTRIBUTES ) { |
182
|
|
|
|
|
|
|
*{ __PACKAGE__ . '::' . $attribute } = sub { |
183
|
0
|
|
|
0
|
|
|
my $self = shift; |
184
|
0
|
|
|
|
|
|
return $self->{$attribute} |
185
|
|
|
|
|
|
|
} |
186
|
|
|
|
|
|
|
} |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
foreach my $type ( keys %STATS ) { |
189
|
|
|
|
|
|
|
my $type_stats = uc( $type ) . '_STATS'; |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
while ( my ( $pseudo, $attribute ) = each %{$type_stats} ) { |
192
|
|
|
|
|
|
|
*{ __PACKAGE__ . '::' . $type . "_$pseudo" } = sub { |
193
|
0
|
|
|
0
|
|
|
my $self = shift; |
194
|
|
|
|
|
|
|
|
195
|
0
|
|
|
|
|
|
my $method = "get_$type" . "_$pseudo"; |
196
|
0
|
0
|
|
|
|
|
defined $self->{$type}->{$attribute} or $self->$method; |
197
|
0
|
|
|
|
|
|
return $self->{$type}->{$attribute}; |
198
|
|
|
|
|
|
|
}; |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
*{ __PACKAGE__ . '::' . "get_$type" . "_$pseudo" } = sub { |
201
|
0
|
|
|
0
|
|
|
my $self = shift; |
202
|
|
|
|
|
|
|
|
203
|
0
|
|
|
|
|
|
my $method = "get_$type" . '_stats'; |
204
|
0
|
|
|
|
|
|
$self->$method; |
205
|
0
|
|
|
|
|
|
return $self->{$type}->{$attribute} |
206
|
|
|
|
|
|
|
} |
207
|
|
|
|
|
|
|
} |
208
|
|
|
|
|
|
|
} |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
} |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
1; |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
__END__ |