| 1 |
# |
| 2 |
# Copyright 2024 Centreon (http://www.centreon.com/) |
| 3 |
# |
| 4 |
# Centreon is a full-fledged industry-strength solution that meets |
| 5 |
# the needs in IT infrastructure and application monitoring for |
| 6 |
# service performance. |
| 7 |
# |
| 8 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
| 9 |
# you may not use this file except in compliance with the License. |
| 10 |
# You may obtain a copy of the License at |
| 11 |
# |
| 12 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 13 |
# |
| 14 |
# Unless required by applicable law or agreed to in writing, software |
| 15 |
# distributed under the License is distributed on an "AS IS" BASIS, |
| 16 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 |
# See the License for the specific language governing permissions and |
| 18 |
# limitations under the License. |
| 19 |
# |
| 20 |
|
| 21 |
package network::mrv::optiswitch::snmp::mode::interfaces; |
| 22 |
|
| 23 |
use base qw(snmp_standard::mode::interfaces); |
| 24 |
|
| 25 |
use strict; |
| 26 |
use warnings; |
| 27 |
|
| 28 |
sub custom_status_output { |
| 29 |
my ($self, %options) = @_; |
| 30 |
|
| 31 |
my $msg = 'Status : ' . $self->{result_values}->{linkstatus} . ' (oper: ' . $self->{result_values}->{opstatus} . ', ' . 'admin: ' . $self->{result_values}->{admstatus} . ')'; |
| 32 |
if (defined($self->{instance_mode}->{option_results}->{add_duplex_status})) { |
| 33 |
$msg .= ' (duplex: ' . $self->{result_values}->{duplexstatus} . ')'; |
| 34 |
} |
| 35 |
|
| 36 |
return $msg; |
| 37 |
} |
| 38 |
|
| 39 |
sub custom_status_calc { |
| 40 |
my ($self, %options) = @_; |
| 41 |
|
| 42 |
$self->{result_values}->{linkstatus} = $options{new_datas}->{$self->{instance} . '_linkstatus'}; |
| 43 |
$self->{result_values}->{opstatus} = $options{new_datas}->{$self->{instance} . '_opstatus'}; |
| 44 |
$self->{result_values}->{admstatus} = $options{new_datas}->{$self->{instance} . '_admstatus'}; |
| 45 |
$self->{result_values}->{duplexstatus} = $options{new_datas}->{$self->{instance} . '_duplexstatus'}; |
| 46 |
$self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; |
| 47 |
return 0; |
| 48 |
} |
| 49 |
|
| 50 |
sub set_counters_global { |
| 51 |
my ($self, %options) = @_; |
| 52 |
|
| 53 |
$self->SUPER::set_counters_global(%options); |
| 54 |
|
| 55 |
push @{$self->{maps_counters}->{global}}, |
| 56 |
{ label => 'total-link-up', filter => 'add_global', nlabel => 'total.interfaces.link.up.count', set => { |
| 57 |
key_values => [ { name => 'global_link_up' }, { name => 'total_port' } ], |
| 58 |
output_template => 'LinkStatus Up : %s', output_error_template => 'LinkStatus Up : %s', |
| 59 |
output_use => 'global_link_up', threshold_use => 'global_link_up', |
| 60 |
perfdatas => [ |
| 61 |
{ label => 'total_link_up', value => 'global_link_up', template => '%s', |
| 62 |
min => 0, max => 'total_port' } |
| 63 |
] |
| 64 |
} |
| 65 |
}, |
| 66 |
{ label => 'total-link-down', filter => 'add_global', nlabel => 'total.interfaces.link.down.count', set => { |
| 67 |
key_values => [ { name => 'global_link_down' }, { name => 'total_port' } ], |
| 68 |
output_template => 'LinkStatus Down : %s', output_error_template => 'LinkStatus Down : %s', |
| 69 |
output_use => 'global_link_down', threshold_use => 'global_link_down', |
| 70 |
perfdatas => [ |
| 71 |
{ label => 'total_link_down', value => 'global_link_down', template => '%s', |
| 72 |
min => 0, max => 'total_port' } |
| 73 |
] |
| 74 |
} |
| 75 |
} |
| 76 |
; |
| 77 |
} |
| 78 |
|
| 79 |
sub set_counters_errors { |
| 80 |
my ($self, %options) = @_; |
| 81 |
|
| 82 |
push @{$self->{maps_counters}->{int}}, |
| 83 |
{ label => 'in-crc', filter => 'add_errors', nlabel => 'interface.packets.in.crc.count', set => { |
| 84 |
key_values => [ { name => 'incrc', diff => 1 }, { name => 'total_in_packets', diff => 1 }, { name => 'display' }, { name => 'mode_cast' } ], |
| 85 |
closure_custom_calc => $self->can('custom_errors_calc'), closure_custom_calc_extra_options => { label_ref1 => 'in', label_ref2 => 'crc' }, |
| 86 |
closure_custom_output => $self->can('custom_errors_output'), output_error_template => 'Packets In Crc : %s', |
| 87 |
closure_custom_perfdata => $self->can('custom_errors_perfdata'), |
| 88 |
closure_custom_threshold_check => $self->can('custom_errors_threshold') |
| 89 |
} |
| 90 |
} |
| 91 |
; |
| 92 |
} |
| 93 |
|
| 94 |
sub set_key_values_status { |
| 95 |
my ($self, %options) = @_; |
| 96 |
|
| 97 |
return [ { name => 'linkstatus' }, { name => 'opstatus' }, { name => 'admstatus' }, { name => 'duplexstatus' }, { name => 'display' } ]; |
| 98 |
} |
| 99 |
|
| 100 |
sub set_oids_status { |
| 101 |
my ($self, %options) = @_; |
| 102 |
|
| 103 |
$self->{oid_linkstatus} = '.1.3.6.1.4.1.6926.2.1.2.1.5'; |
| 104 |
$self->{oid_linkstatus_mapping} = { |
| 105 |
1 => 'true', 2 => 'false', |
| 106 |
}; |
| 107 |
$self->{oid_adminstatus} = '.1.3.6.1.4.1.6926.2.1.2.1.10'; |
| 108 |
$self->{oid_adminstatus_mapping} = { |
| 109 |
1 => 'other', 2 => 'enable', 3 => 'disableByMgmt', |
| 110 |
}; |
| 111 |
$self->{oid_opstatus} = '.1.3.6.1.4.1.6926.2.1.2.1.11'; |
| 112 |
$self->{oid_opstatus_mapping} = { |
| 113 |
1 => 'other', 2 => 'enabled', 3 => 'disabledByMgmt', 4 => 'disabledByReboot', 5 => 'isolatedByLinkFlapGuard', |
| 114 |
6 => 'isolatedByLinkReflection', 7 => 'isolatedByLinkProtection', 8 => 'isolatedByStpLinkReflection', |
| 115 |
9 => 'isolatedByHotSwap', 10 => 'isolatedByHa', 11 => 'isolatedByStpPortLoop', 12 => 'isolatedByStpOverRate', |
| 116 |
13 => 'isolatedByEthoamOverRate', 14 => 'isolatedByEfmOverRate', 15 => 'isolatedByDot1xOverRate', |
| 117 |
16 => 'isolatedByDot1agOverRate', 17 => 'isolatedByLacpOverRate', 18 => 'isolatedByAhOverRate', |
| 118 |
19 => 'isolatedByUdld', 20 => 'isolatedByShdslLinkDown', |
| 119 |
}; |
| 120 |
|
| 121 |
$self->{oid_duplexstatus} = '.1.3.6.1.4.1.6926.2.1.2.1.9'; |
| 122 |
$self->{oid_duplexstatus_mapping} = { |
| 123 |
1 => 'other', 3 => 'fullDuplex', 4 => 'halfDuplex', |
| 124 |
}; |
| 125 |
} |
| 126 |
|
| 127 |
sub set_oids_traffic { |
| 128 |
my ($self, %options) = @_; |
| 129 |
|
| 130 |
$self->{oid_speed64} = '.1.3.6.1.4.1.6926.2.1.2.1.7'; # in Mb/s |
| 131 |
$self->{oid_in64} = '.1.3.6.1.4.1.6926.2.1.5.1.3'; # in B |
| 132 |
$self->{oid_out64} = '.1.3.6.1.4.1.6926.2.1.5.1.8'; # in B |
| 133 |
} |
| 134 |
|
| 135 |
sub set_oids_speed { |
| 136 |
my ($self, %options) = @_; |
| 137 |
|
| 138 |
$self->{oid_speed64} = '.1.3.6.1.4.1.6926.2.1.2.1.7'; # in Mb/s |
| 139 |
} |
| 140 |
|
| 141 |
sub set_oids_errors { |
| 142 |
my ($self, %options) = @_; |
| 143 |
|
| 144 |
$self->{oid_ifInCrc} = '.1.3.6.1.4.1.6926.2.1.5.1.13'; # osPortCntRecvCRCorAlignmentErrs |
| 145 |
} |
| 146 |
|
| 147 |
sub set_oids_cast { |
| 148 |
my ($self, %options) = @_; |
| 149 |
|
| 150 |
$self->{oid_ifHCInUcastPkts} = '.1.3.6.1.4.1.6926.2.1.5.1.5'; |
| 151 |
$self->{oid_ifHCInMulticastPkts} = '.1.3.6.1.4.1.6926.2.1.5.1.7'; |
| 152 |
$self->{oid_ifHCInBroadcastPkts} = '.1.3.6.1.4.1.6926.2.1.5.1.6'; |
| 153 |
$self->{oid_ifHCOutUcastPkts} = '.1.3.6.1.4.1.6926.2.1.5.1.10'; |
| 154 |
$self->{oid_ifHCOutMulticastPkts} = '.1.3.6.1.4.1.6926.2.1.5.1.12'; |
| 155 |
$self->{oid_ifHCOutBroadcastPkts} = '.1.3.6.1.4.1.6926.2.1.5.1.11'; |
| 156 |
} |
| 157 |
|
| 158 |
sub default_check_metrics { |
| 159 |
my ($self, %options) = @_; |
| 160 |
|
| 161 |
return '%{opstatus} eq "enabled" and %{linkstatus} eq "true"'; |
| 162 |
} |
| 163 |
|
| 164 |
sub default_warning_status { |
| 165 |
my ($self, %options) = @_; |
| 166 |
|
| 167 |
return ''; |
| 168 |
} |
| 169 |
|
| 170 |
sub default_critical_status { |
| 171 |
my ($self, %options) = @_; |
| 172 |
|
| 173 |
return '%{admstatus} eq "enable" and %{opstatus} eq "enabled" and %{linkstatus} ne "true"'; |
| 174 |
} |
| 175 |
|
| 176 |
sub default_global_link_up_rule { |
| 177 |
my ($self, %options) = @_; |
| 178 |
|
| 179 |
return '%{linkstatus} eq "true"'; |
| 180 |
} |
| 181 |
|
| 182 |
sub default_global_link_down_rule { |
| 183 |
my ($self, %options) = @_; |
| 184 |
|
| 185 |
return '%{linkstatus} eq "false"'; |
| 186 |
} |
| 187 |
|
| 188 |
sub default_global_admin_up_rule { |
| 189 |
my ($self, %options) = @_; |
| 190 |
|
| 191 |
return '%{admstatus} eq "enable"'; |
| 192 |
} |
| 193 |
|
| 194 |
sub default_global_admin_down_rule { |
| 195 |
my ($self, %options) = @_; |
| 196 |
|
| 197 |
return '%{admstatus} ne "enable"'; |
| 198 |
} |
| 199 |
|
| 200 |
sub default_global_oper_up_rule { |
| 201 |
my ($self, %options) = @_; |
| 202 |
|
| 203 |
return '%{opstatus} eq "enabled"'; |
| 204 |
} |
| 205 |
|
| 206 |
sub default_global_oper_down_rule { |
| 207 |
my ($self, %options) = @_; |
| 208 |
|
| 209 |
return '%{opstatus} ne "enabled"'; |
| 210 |
} |
| 211 |
|
| 212 |
sub new { |
| 213 |
my ($class, %options) = @_; |
| 214 |
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_set_errors => 1); |
| 215 |
bless $self, $class; |
| 216 |
|
| 217 |
$options{options}->add_options(arguments => { |
| 218 |
"global-link-up-rule:s" => { name => 'global_link_up_rule', default => $self->default_global_link_up_rule() }, |
| 219 |
"global-link-down-rule:s" => { name => 'global_link_down_rule', default => $self->default_global_link_down_rule() }, |
| 220 |
}); |
| 221 |
|
| 222 |
return $self; |
| 223 |
} |
| 224 |
|
| 225 |
sub load_status { |
| 226 |
my ($self, %options) = @_; |
| 227 |
|
| 228 |
$self->set_oids_status(); |
| 229 |
my $oids = [$self->{oid_linkstatus}, $self->{oid_adminstatus}, $self->{oid_opstatus}]; |
| 230 |
if (defined($self->{option_results}->{add_duplex_status})) { |
| 231 |
push @$oids, $self->{oid_duplexstatus}; |
| 232 |
} |
| 233 |
|
| 234 |
$self->{snmp}->load(oids => $oids, instances => $self->{array_interface_selected}); |
| 235 |
} |
| 236 |
|
| 237 |
sub load_traffic { |
| 238 |
my ($self, %options) = @_; |
| 239 |
|
| 240 |
if ($self->{snmp}->is_snmpv1()) { |
| 241 |
$self->{output}->add_option_msg(short_msg => "Can't check SNMP 64 bits counters with SNMPv1."); |
| 242 |
$self->{output}->option_exit(); |
| 243 |
} |
| 244 |
|
| 245 |
$self->set_oids_traffic(); |
| 246 |
|
| 247 |
$self->{snmp}->load(oids => [$self->{oid_in64}, $self->{oid_out64}], instances => $self->{array_interface_selected}); |
| 248 |
if ($self->{get_speed} == 1) { |
| 249 |
$self->{snmp}->load(oids => [$self->{oid_speed64}], instances => $self->{array_interface_selected}); |
| 250 |
} |
| 251 |
} |
| 252 |
|
| 253 |
sub load_cast { |
| 254 |
my ($self, %options) = @_; |
| 255 |
|
| 256 |
if ($self->{snmp}->is_snmpv1()) { |
| 257 |
$self->{output}->add_option_msg(short_msg => "Can't check SNMP 64 bits counters with SNMPv1."); |
| 258 |
$self->{output}->option_exit(); |
| 259 |
} |
| 260 |
|
| 261 |
$self->set_oids_cast(); |
| 262 |
|
| 263 |
$self->{snmp}->load( |
| 264 |
oids => [ |
| 265 |
$self->{oid_ifHCInUcastPkts}, $self->{oid_ifHCInMulticastPkts}, $self->{oid_ifHCInBroadcastPkts}, |
| 266 |
$self->{oid_ifHCOutUcastPkts}, $self->{oid_ifHCOutMulticastPkts}, $self->{oid_ifHCOutBroadcastPkts} |
| 267 |
], |
| 268 |
instances => $self->{array_interface_selected} |
| 269 |
); |
| 270 |
} |
| 271 |
|
| 272 |
sub load_errors { |
| 273 |
my ($self, %options) = @_; |
| 274 |
|
| 275 |
$self->set_oids_errors(); |
| 276 |
$self->{snmp}->load( |
| 277 |
oids => [ |
| 278 |
$self->{oid_ifInCrc} |
| 279 |
], |
| 280 |
instances => $self->{array_interface_selected} |
| 281 |
); |
| 282 |
} |
| 283 |
|
| 284 |
sub load_speed { |
| 285 |
my ($self, %options) = @_; |
| 286 |
|
| 287 |
if ($self->{snmp}->is_snmpv1()) { |
| 288 |
$self->{output}->add_option_msg(short_msg => "Can't check SNMP 64 bits counters with SNMPv1."); |
| 289 |
$self->{output}->option_exit(); |
| 290 |
} |
| 291 |
|
| 292 |
$self->set_oids_speed(); |
| 293 |
|
| 294 |
$self->{snmp}->load(oids => [$self->{oid_speed64}], instances => $self->{array_interface_selected}); |
| 295 |
} |
| 296 |
|
| 297 |
sub load_volume { |
| 298 |
my ($self, %options) = @_; |
| 299 |
|
| 300 |
if ($self->{snmp}->is_snmpv1()) { |
| 301 |
$self->{output}->add_option_msg(short_msg => "Can't check SNMP 64 bits counters with SNMPv1."); |
| 302 |
$self->{output}->option_exit(); |
| 303 |
} |
| 304 |
|
| 305 |
$self->set_oids_traffic(); |
| 306 |
|
| 307 |
$self->{snmp}->load(oids => [$self->{oid_in64}, $self->{oid_out64}], instances => $self->{array_interface_selected}); |
| 308 |
} |
| 309 |
|
| 310 |
sub add_result_global { |
| 311 |
my ($self, %options) = @_; |
| 312 |
|
| 313 |
foreach (('global_link_up_rule', 'global_link_down_rule', 'global_admin_up_rule', 'global_admin_down_rule', 'global_oper_up_rule', 'global_oper_down_rule')) { |
| 314 |
if (defined($self->{option_results}->{$_})) { |
| 315 |
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$$1/g; |
| 316 |
} |
| 317 |
} |
| 318 |
|
| 319 |
$self->{global} = { total_port => 0, global_link_up => 0, global_link_down => 0, global_admin_up => 0, |
| 320 |
global_admin_down => 0, global_oper_up => 0, global_oper_down => 0}; |
| 321 |
foreach (@{$self->{array_interface_selected}}) { |
| 322 |
my $values = { |
| 323 |
linkstatus => $self->{oid_linkstatus_mapping}->{$self->{results}->{$self->{oid_linkstatus} . '.' . $_}}, |
| 324 |
opstatus => $self->{oid_opstatus_mapping}->{$self->{results}->{$self->{oid_opstatus} . '.' . $_}}, |
| 325 |
admstatus => $self->{oid_adminstatus_mapping}->{$self->{results}->{$self->{oid_adminstatus} . '.' . $_}} |
| 326 |
}; |
| 327 |
foreach (('global_link_up', 'global_link_down', 'global_admin_up', 'global_admin_down', 'global_oper_up', 'global_oper_down')) { |
| 328 |
if (defined($self->{option_results}->{$_ . '_rule'}) && $self->{option_results}->{$_ . '_rule'} ne '' && |
| 329 |
$self->{output}->test_eval(test => $self->{option_results}->{$_ . '_rule'}, values => $values)) { |
| 330 |
$self->{global}->{$_}++; |
| 331 |
} |
| 332 |
} |
| 333 |
$self->{global}->{total_port}++; |
| 334 |
} |
| 335 |
} |
| 336 |
|
| 337 |
sub add_result_status { |
| 338 |
my ($self, %options) = @_; |
| 339 |
|
| 340 |
$self->{int}->{$options{instance}}->{linkstatus} = defined($self->{results}->{$self->{oid_linkstatus} . '.' . $options{instance}}) ? $self->{oid_linkstatus_mapping}->{$self->{results}->{$self->{oid_linkstatus} . '.' . $options{instance}}} : undef; |
| 341 |
$self->{int}->{$options{instance}}->{opstatus} = defined($self->{results}->{$self->{oid_opstatus} . '.' . $options{instance}}) ? $self->{oid_opstatus_mapping}->{$self->{results}->{$self->{oid_opstatus} . '.' . $options{instance}}} : undef; |
| 342 |
$self->{int}->{$options{instance}}->{admstatus} = defined($self->{results}->{$self->{oid_adminstatus} . '.' . $options{instance}}) ? $self->{oid_adminstatus_mapping}->{$self->{results}->{$self->{oid_adminstatus} . '.' . $options{instance}}} : undef; |
| 343 |
$self->{int}->{$options{instance}}->{duplexstatus} = defined($self->{results}->{$self->{oid_duplexstatus} . '.' . $options{instance}}) ? $self->{oid_duplexstatus_mapping}->{$self->{results}->{$self->{oid_duplexstatus} . '.' . $options{instance}}} : 'n/a'; |
| 344 |
} |
| 345 |
|
| 346 |
sub add_result_traffic { |
| 347 |
my ($self, %options) = @_; |
| 348 |
|
| 349 |
$self->{int}->{$options{instance}}->{mode_traffic} = 64; |
| 350 |
$self->{int}->{$options{instance}}->{in} = $self->{results}->{$self->{oid_in64} . '.' . $options{instance}}; |
| 351 |
$self->{int}->{$options{instance}}->{out} = $self->{results}->{$self->{oid_out64} . '.' . $options{instance}}; |
| 352 |
$self->{int}->{$options{instance}}->{in} *= 8 if (defined($self->{int}->{$options{instance}}->{in})); |
| 353 |
$self->{int}->{$options{instance}}->{out} *= 8 if (defined($self->{int}->{$options{instance}}->{out})); |
| 354 |
$self->{int}->{$options{instance}}->{speed_in} = 0; |
| 355 |
$self->{int}->{$options{instance}}->{speed_out} = 0; |
| 356 |
if ($self->{get_speed} == 0) { |
| 357 |
if (defined($self->{option_results}->{speed}) && $self->{option_results}->{speed} ne '') { |
| 358 |
$self->{int}->{$options{instance}}->{speed_in} = $self->{option_results}->{speed} * 1000000; |
| 359 |
$self->{int}->{$options{instance}}->{speed_out} = $self->{option_results}->{speed} * 1000000; |
| 360 |
} |
| 361 |
$self->{int}->{$options{instance}}->{speed_in} = $self->{option_results}->{speed_in} * 1000000 if (defined($self->{option_results}->{speed_in}) && $self->{option_results}->{speed_in} ne ''); |
| 362 |
$self->{int}->{$options{instance}}->{speed_out} = $self->{option_results}->{speed_out} * 1000000 if (defined($self->{option_results}->{speed_out}) && $self->{option_results}->{speed_out} ne ''); |
| 363 |
} else { |
| 364 |
my $interface_speed = 0; |
| 365 |
$interface_speed = $self->{results}->{$self->{oid_speed64} . "." . $options{instance}} * 1000000; |
| 366 |
$self->{int}->{$options{instance}}->{speed_in} = $interface_speed; |
| 367 |
$self->{int}->{$options{instance}}->{speed_out} = $interface_speed; |
| 368 |
$self->{int}->{$options{instance}}->{speed_in} = $self->{option_results}->{speed_in} * 1000000 if (defined($self->{option_results}->{speed_in}) && $self->{option_results}->{speed_in} ne ''); |
| 369 |
$self->{int}->{$options{instance}}->{speed_out} = $self->{option_results}->{speed_out} * 1000000 if (defined($self->{option_results}->{speed_out}) && $self->{option_results}->{speed_out} ne ''); |
| 370 |
} |
| 371 |
} |
| 372 |
|
| 373 |
sub add_result_cast { |
| 374 |
my ($self, %options) = @_; |
| 375 |
|
| 376 |
my $iucast = $self->{results}->{$self->{oid_ifHCInUcastPkts} . '.' . $options{instance}}; |
| 377 |
if (defined($iucast) && $iucast =~ /[1-9]/) { |
| 378 |
$self->{int}->{$options{instance}}->{iucast} = $iucast; |
| 379 |
$self->{int}->{$options{instance}}->{imcast} = defined($self->{results}->{$self->{oid_ifHCInMulticastPkts} . '.' . $options{instance}}) ? $self->{results}->{$self->{oid_ifHCInMulticastPkts} . '.' . $options{instance}} : 0; |
| 380 |
$self->{int}->{$options{instance}}->{ibcast} = defined($self->{results}->{$self->{oid_ifHCInBroadcastPkts} . '.' . $options{instance}}) ? $self->{results}->{$self->{oid_ifHCInBroadcastPkts} . '.' . $options{instance}} : 0; |
| 381 |
$self->{int}->{$options{instance}}->{oucast} = $self->{results}->{$self->{oid_ifHCOutUcastPkts} . '.' . $options{instance}}; |
| 382 |
$self->{int}->{$options{instance}}->{omcast} = defined($self->{results}->{$self->{oid_ifHCOutMulticastPkts} . '.' . $options{instance}}) ? $self->{results}->{$self->{oid_ifHCOutMulticastPkts} . '.' . $options{instance}} : 0; |
| 383 |
$self->{int}->{$options{instance}}->{obcast} = defined($self->{results}->{$self->{oid_ifHCOutBroadcastPkts} . '.' . $options{instance}}) ? $self->{results}->{$self->{oid_ifHCOutBroadcastPkts} . '.' . $options{instance}} : 0; |
| 384 |
$self->{int}->{$options{instance}}->{mode_cast} = 64; |
| 385 |
} |
| 386 |
|
| 387 |
foreach (('iucast', 'imcast', 'ibcast', 'oucast', 'omcast', 'obcast')) { |
| 388 |
$self->{int}->{$options{instance}}->{$_} = 0 if (!defined($self->{int}->{$options{instance}}->{$_})); |
| 389 |
} |
| 390 |
|
| 391 |
$self->{int}->{$options{instance}}->{total_in_packets} = $self->{int}->{$options{instance}}->{iucast} + $self->{int}->{$options{instance}}->{imcast} + $self->{int}->{$options{instance}}->{ibcast}; |
| 392 |
$self->{int}->{$options{instance}}->{total_out_packets} = $self->{int}->{$options{instance}}->{oucast} + $self->{int}->{$options{instance}}->{omcast} + $self->{int}->{$options{instance}}->{obcast}; |
| 393 |
} |
| 394 |
|
| 395 |
sub add_result_errors { |
| 396 |
my ($self, %options) = @_; |
| 397 |
|
| 398 |
$self->{int}->{$options{instance}}->{incrc} = $self->{results}->{$self->{oid_ifInCrc} . '.' . $options{instance}}; |
| 399 |
} |
| 400 |
|
| 401 |
sub add_result_speed { |
| 402 |
my ($self, %options) = @_; |
| 403 |
|
| 404 |
my $interface_speed = 0; |
| 405 |
$interface_speed = $self->{results}->{$self->{oid_speed64} . "." . $options{instance}} * 1000000; |
| 406 |
|
| 407 |
$self->{int}->{$options{instance}}->{speed} = $interface_speed; |
| 408 |
} |
| 409 |
|
| 410 |
sub add_result_volume { |
| 411 |
my ($self, %options) = @_; |
| 412 |
|
| 413 |
$self->{int}->{$options{instance}}->{in_volume} = $self->{results}->{$self->{oid_in64} . '.' . $options{instance}}; |
| 414 |
$self->{int}->{$options{instance}}->{out_volume} = $self->{results}->{$self->{oid_out64} . '.' . $options{instance}}; |
| 415 |
} |
| 416 |
|
| 417 |
1; |
| 418 |
|
| 419 |
__END__ |
| 420 |
|
| 421 |
=head1 MODE |
| 422 |
|
| 423 |
Check interfaces (OS-PORT-MIB). |
| 424 |
|
| 425 |
=over 8 |
| 426 |
|
| 427 |
=item B<--add-global> |
| 428 |
|
| 429 |
Check global port statistics. |
| 430 |
|
| 431 |
=item B<--add-status> |
| 432 |
|
| 433 |
Check interface status (by default if no --add-* option is set). |
| 434 |
|
| 435 |
=item B<--add-duplex-status> |
| 436 |
|
| 437 |
Check duplex status (with --warning-status and --critical-status). |
| 438 |
|
| 439 |
=item B<--add-traffic> |
| 440 |
|
| 441 |
Check interface traffic. |
| 442 |
|
| 443 |
=item B<--add-errors> |
| 444 |
|
| 445 |
Check interface errors. |
| 446 |
|
| 447 |
=item B<--add-cast> |
| 448 |
|
| 449 |
Check interface cast. |
| 450 |
|
| 451 |
=item B<--add-speed> |
| 452 |
|
| 453 |
Check interface speed. |
| 454 |
|
| 455 |
=item B<--add-volume> |
| 456 |
|
| 457 |
Check interface data volume between two checks (not supposed to be graphed, useful for BI reporting). |
| 458 |
|
| 459 |
=item B<--check-metrics> |
| 460 |
|
| 461 |
If the expression is true, metrics are checked (default: '%{opstatus} eq "enabled" and %{linkstatus} eq "true"'). |
| 462 |
|
| 463 |
=item B<--warning-status> |
| 464 |
|
| 465 |
Define the conditions to match for the status to be WARNING. |
| 466 |
You can use the following variables: %{linkstatus}, %{admstatus}, %{opstatus}, %{duplexstatus}, %{display} |
| 467 |
|
| 468 |
=item B<--critical-status> |
| 469 |
|
| 470 |
Define the conditions to match for the status to be CRITICAL (default: '%{admstatus} eq "enable" and %{opstatus} eq "enabled" and %{linkstatus} ne "true"'). |
| 471 |
You can use the following variables: %{linkstatus}, %{admstatus}, %{opstatus}, %{duplexstatus}, %{display} |
| 472 |
|
| 473 |
=item B<--warning-*> B<--critical-*> |
| 474 |
|
| 475 |
Thresholds. |
| 476 |
Can be: 'total-port', 'total-admin-up', 'total-admin-down', 'total-oper-up', 'total-oper-down', 'total-link-up', 'total-link-down', |
| 477 |
'in-traffic', 'out-traffic', 'in-crc', 'in-ucast', 'in-bcast', 'in-mcast', 'out-ucast', 'out-bcast', 'out-mcast', |
| 478 |
'speed' (b/s). |
| 479 |
|
| 480 |
=item B<--units-traffic> |
| 481 |
|
| 482 |
Units of thresholds for the traffic (default: 'percent_delta') ('percent_delta', 'bps', 'counter'). |
| 483 |
|
| 484 |
=item B<--units-errors> |
| 485 |
|
| 486 |
Units of thresholds for errors/discards (default: 'percent_delta') ('percent_delta', 'percent', 'delta', 'deltaps', 'counter'). |
| 487 |
|
| 488 |
=item B<--units-cast> |
| 489 |
|
| 490 |
Units of thresholds for communication types (default: 'percent_delta') ('percent_delta', 'percent', 'delta', 'deltaps', 'counter'). |
| 491 |
|
| 492 |
=item B<--nagvis-perfdata> |
| 493 |
|
| 494 |
Display traffic perfdata to be compatible with nagvis widget. |
| 495 |
|
| 496 |
=item B<--interface> |
| 497 |
|
| 498 |
Set the interface (number expected) example: 1,2,... (empty means 'check all interfaces'). |
| 499 |
|
| 500 |
=item B<--name> |
| 501 |
|
| 502 |
Allows you to define the interface (in option --interface) by name instead of OID index. The name matching mode supports regular expressions. |
| 503 |
|
| 504 |
=item B<--speed> |
| 505 |
|
| 506 |
Set interface speed for incoming/outgoing traffic (in Mb). |
| 507 |
|
| 508 |
=item B<--speed-in> |
| 509 |
|
| 510 |
Set interface speed for incoming traffic (in Mb). |
| 511 |
|
| 512 |
=item B<--speed-out> |
| 513 |
|
| 514 |
Set interface speed for outgoing traffic (in Mb). |
| 515 |
|
| 516 |
=item B<--reload-cache-time> |
| 517 |
|
| 518 |
Time in minutes before reloading cache file (default: 180). |
| 519 |
|
| 520 |
=item B<--oid-filter> |
| 521 |
|
| 522 |
Define the OID to be used to filter interfaces (default: ifName) (values: ifDesc, ifAlias, ifName). |
| 523 |
|
| 524 |
=item B<--oid-display> |
| 525 |
|
| 526 |
Define the OID that will be used to name the interfaces (default: ifName) (values: ifDesc, ifAlias, ifName). |
| 527 |
|
| 528 |
=item B<--oid-extra-display> |
| 529 |
|
| 530 |
Add an OID to display. |
| 531 |
|
| 532 |
=item B<--display-transform-src> B<--display-transform-dst> |
| 533 |
|
| 534 |
Modify the interface name displayed by using a regular expression. |
| 535 |
|
| 536 |
Example: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens' |
| 537 |
|
| 538 |
=item B<--show-cache> |
| 539 |
|
| 540 |
Display cache interface data. |
| 541 |
|
| 542 |
=back |
| 543 |
|
| 544 |
=cut |