diff --git a/network/mikrotik/snmp/mode/interfaces.pm b/network/mikrotik/snmp/mode/interfaces.pm index 92ee4ed31..d81f5a2f6 100644 --- a/network/mikrotik/snmp/mode/interfaces.pm +++ b/network/mikrotik/snmp/mode/interfaces.pm @@ -85,10 +85,34 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - + + $options{options}->add_options(arguments => { + 'warning-errors:s' => { name => 'warning_errors' }, + 'critical-errors:s' => { name => 'critical_errors' }, + }); + return $self; } +sub check_options { + my ($self, %options) = @_; + + foreach ('warning', 'critical') { + next if (!defined($options{option_results}->{$_ . '_errors'}) || $options{option_results}->{$_ . '_errors'} eq ''); + foreach my $oid (keys %{$self->{oids_errors}}) { + $oid =~ /^oid_if(In|Out)(.*)$/; + if (!defined($options{option_results}->{$_ . '-instance-interface-packets-' . lc($1) . '-' . lc($2) . '-count'})) { + $options{option_results}->{$_ . '-instance-interface-packets-' . lc($1) . '-' . lc($2) . '-count'} = $options{option_results}->{$_ . '_errors'}; + } + if (!defined($options{option_results}->{$_ . '-' . lc($1) . '-' . lc($2)})) { + $options{option_results}->{$_ . '-' . lc($1) . '-' . lc($2)} = $options{option_results}->{$_ . '_errors'}; + } + } + } + + $self->SUPER::check_options(%options); +} + sub load_errors { my ($self, %options) = @_; @@ -159,9 +183,17 @@ Can used special variables like: %{admstatus}, %{opstatus}, %{duplexstatus}, %{d Set critical threshold for status (Default: '%{admstatus} eq "up" and %{opstatus} ne "up"'). Can used special variables like: %{admstatus}, %{opstatus}, %{duplexstatus}, %{display} +=item B<--warning-errors> + +Set warning threshold for all error counters. + +=item B<--critical-errors> + +Set critical threshold for all error counters. + =item B<--warning-*> -Threshold warning. +Threshold warning (will superseed --warning-errors). Can be: 'total-port', 'total-admin-up', 'total-admin-down', 'total-oper-up', 'total-oper-down', 'in-traffic', 'out-traffic', 'in-error', 'in-discard', 'out-error', 'out-discard', 'in-ucast' (%), 'in-bcast' (%), 'in-mcast' (%), 'out-ucast' (%), 'out-bcast' (%), 'out-mcast' (%), @@ -176,7 +208,7 @@ And also: 'in-tooshort' (%), 'in-toolong' (%), 'in-fcserror' (%), 'in-alignerror =item B<--critical-*> -Threshold critical. +Threshold critical (will superseed --warning-errors). Can be: 'total-port', 'total-admin-up', 'total-admin-down', 'total-oper-up', 'total-oper-down', 'in-traffic', 'out-traffic', 'in-error', 'in-discard', 'out-error', 'out-discard', 'in-ucast' (%), 'in-bcast' (%), 'in-mcast' (%), 'out-ucast' (%), 'out-bcast' (%), 'out-mcast' (%),