migrate interfaces mode to counter class
This commit is contained in:
parent
577eaab82d
commit
deddea9211
|
@ -35,22 +35,21 @@ sub set_oids_errors {
|
||||||
$self->{oid_ifInCrc} = '.1.3.6.1.4.1.9.2.2.1.1.12';
|
$self->{oid_ifInCrc} = '.1.3.6.1.4.1.9.2.2.1.1.12';
|
||||||
}
|
}
|
||||||
|
|
||||||
sub set_counters {
|
sub set_counters_errors {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{maps_counters} = { int => {}, global => {} };
|
$self->SUPER::set_counters_errors(%options);
|
||||||
|
|
||||||
$self->{maps_counters}->{int}->{'045_in-crc'} = { filter => 'add_errors',
|
push @{$self->{maps_counters}->{int}},
|
||||||
set => {
|
{ label => 'in-crc', filter => 'add_errors', set => {
|
||||||
key_values => [ { name => 'incrc', diff => 1 }, { name => 'total_in_packets', diff => 1 }, { name => 'display' }, { name => 'mode_cast' } ],
|
key_values => [ { name => 'incrc', diff => 1 }, { name => 'total_in_packets', diff => 1 }, { name => 'display' }, { name => 'mode_cast' } ],
|
||||||
closure_custom_calc => $self->can('custom_errors_calc'), closure_custom_calc_extra_options => { label_ref1 => 'in', label_ref2 => 'crc' },
|
closure_custom_calc => $self->can('custom_errors_calc'), closure_custom_calc_extra_options => { label_ref1 => 'in', label_ref2 => 'crc' },
|
||||||
closure_custom_output => $self->can('custom_errors_output'), output_error_template => 'Packets In Crc : %s',
|
closure_custom_output => $self->can('custom_errors_output'), output_error_template => 'Packets In Crc : %s',
|
||||||
closure_custom_perfdata => $self->can('custom_errors_perfdata'),
|
closure_custom_perfdata => $self->can('custom_errors_perfdata'),
|
||||||
closure_custom_threshold_check => $self->can('custom_errors_threshold'),
|
closure_custom_threshold_check => $self->can('custom_errors_threshold'),
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
|
;
|
||||||
$self->SUPER::set_counters(%options);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
|
@ -78,11 +77,11 @@ sub load_errors {
|
||||||
sub add_result_errors {
|
sub add_result_errors {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{interface_selected}->{$options{instance}}->{indiscard} = $self->{results}->{$self->{oid_ifInDiscards} . '.' . $options{instance}};
|
$self->{int}->{$options{instance}}->{indiscard} = $self->{results}->{$self->{oid_ifInDiscards} . '.' . $options{instance}};
|
||||||
$self->{interface_selected}->{$options{instance}}->{inerror} = $self->{results}->{$self->{oid_ifInErrors} . '.' . $options{instance}};
|
$self->{int}->{$options{instance}}->{inerror} = $self->{results}->{$self->{oid_ifInErrors} . '.' . $options{instance}};
|
||||||
$self->{interface_selected}->{$options{instance}}->{outdiscard} = $self->{results}->{$self->{oid_ifOutDiscards} . '.' . $options{instance}};
|
$self->{int}->{$options{instance}}->{outdiscard} = $self->{results}->{$self->{oid_ifOutDiscards} . '.' . $options{instance}};
|
||||||
$self->{interface_selected}->{$options{instance}}->{outerror} = $self->{results}->{$self->{oid_ifOutErrors} . '.' . $options{instance}};
|
$self->{int}->{$options{instance}}->{outerror} = $self->{results}->{$self->{oid_ifOutErrors} . '.' . $options{instance}};
|
||||||
$self->{interface_selected}->{$options{instance}}->{incrc} = $self->{results}->{$self->{oid_ifInCrc} . '.' . $options{instance}};
|
$self->{int}->{$options{instance}}->{incrc} = $self->{results}->{$self->{oid_ifInCrc} . '.' . $options{instance}};
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
|
@ -66,6 +66,16 @@ sub set_counters {
|
||||||
#};
|
#};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub get_callback {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
if (defined($options{method_name})) {
|
||||||
|
return $self->can($options{method_name});
|
||||||
|
}
|
||||||
|
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
|
||||||
sub call_object_callback {
|
sub call_object_callback {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
@ -121,7 +131,7 @@ sub new {
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{maps_counters} = {} if (!defined($self->{maps_counters}));
|
$self->{maps_counters} = {} if (!defined($self->{maps_counters}));
|
||||||
$self->set_counters();
|
$self->set_counters(%options);
|
||||||
|
|
||||||
foreach my $key (keys %{$self->{maps_counters}}) {
|
foreach my $key (keys %{$self->{maps_counters}}) {
|
||||||
foreach (@{$self->{maps_counters}->{$key}}) {
|
foreach (@{$self->{maps_counters}->{$key}}) {
|
||||||
|
@ -270,6 +280,7 @@ sub run_instances {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
return undef if (defined($options{config}->{cb_init}) && $self->call_object_callback(method_name => $options{config}->{cb_init}) == 1);
|
return undef if (defined($options{config}->{cb_init}) && $self->call_object_callback(method_name => $options{config}->{cb_init}) == 1);
|
||||||
|
my $cb_init_counters = $self->get_callback(method_name => $options{config}->{cb_init_counters});
|
||||||
my $display_status_lo = defined($options{display_status_long_output}) && $options{display_status_long_output} == 1 ? 1 : 0;
|
my $display_status_lo = defined($options{display_status_long_output}) && $options{display_status_long_output} == 1 ? 1 : 0;
|
||||||
my $resume = defined($options{resume}) && $options{resume} == 1 ? 1 : 0;
|
my $resume = defined($options{resume}) && $options{resume} == 1 ? 1 : 0;
|
||||||
my $no_message_multiple = 1;
|
my $no_message_multiple = 1;
|
||||||
|
@ -294,6 +305,7 @@ sub run_instances {
|
||||||
|
|
||||||
next if (defined($self->{option_results}->{filter_counters}) && $self->{option_results}->{filter_counters} ne '' &&
|
next if (defined($self->{option_results}->{filter_counters}) && $self->{option_results}->{filter_counters} ne '' &&
|
||||||
$_->{label} !~ /$self->{option_results}->{filter_counters}/);
|
$_->{label} !~ /$self->{option_results}->{filter_counters}/);
|
||||||
|
next if ($cb_init_counters && $self->$cb_init_counters(%$_) == 1);
|
||||||
|
|
||||||
$no_message_multiple = 0;
|
$no_message_multiple = 0;
|
||||||
$obj->set(instance => $id);
|
$obj->set(instance => $id);
|
||||||
|
|
|
@ -36,12 +36,11 @@ sub set_oids_traffic {
|
||||||
$self->{currentEthRxHighSpeed1dayBytes} = '.1.3.6.1.4.1.2544.1.11.2.6.2.89.1.4'; # in B
|
$self->{currentEthRxHighSpeed1dayBytes} = '.1.3.6.1.4.1.2544.1.11.2.6.2.89.1.4'; # in B
|
||||||
}
|
}
|
||||||
|
|
||||||
sub set_counters {
|
sub set_counters_traffic {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{maps_counters} = { int => {}, global => {} };
|
push @{$self->{maps_counters}->{int}},
|
||||||
$self->{maps_counters}->{int}->{'030_traffic-in'} = { filter => 'add_traffic',
|
{ label => 'traffic-in', filter => 'add_traffic', set => {
|
||||||
set => {
|
|
||||||
key_values => [ { name => 'traffic_in_15min', diff => 1 }, { name => 'traffic_in_1day', diff => 1 }, { name => 'speed_in'}, { name => 'display' } ],
|
key_values => [ { name => 'traffic_in_15min', diff => 1 }, { name => 'traffic_in_1day', diff => 1 }, { name => 'speed_in'}, { name => 'display' } ],
|
||||||
per_second => 1,
|
per_second => 1,
|
||||||
closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'in' },
|
closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'in' },
|
||||||
|
@ -49,9 +48,8 @@ sub set_counters {
|
||||||
closure_custom_perfdata => $self->can('custom_traffic_perfdata'),
|
closure_custom_perfdata => $self->can('custom_traffic_perfdata'),
|
||||||
closure_custom_threshold_check => $self->can('custom_traffic_threshold'),
|
closure_custom_threshold_check => $self->can('custom_traffic_threshold'),
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
$self->{maps_counters}->{int}->{'031_traffic-out'} = { filter => 'add_traffic',
|
{ label => 'traffic-out', filter => 'add_traffic', set => {
|
||||||
set => {
|
|
||||||
key_values => [ { name => 'traffic_out_15min', diff => 1 }, { name => 'traffic_out_1day', diff => 1 }, { name => 'speed_out'}, { name => 'display' } ],
|
key_values => [ { name => 'traffic_out_15min', diff => 1 }, { name => 'traffic_out_1day', diff => 1 }, { name => 'speed_out'}, { name => 'display' } ],
|
||||||
per_second => 1,
|
per_second => 1,
|
||||||
closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'out' },
|
closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'out' },
|
||||||
|
@ -59,9 +57,17 @@ sub set_counters {
|
||||||
closure_custom_perfdata => $self->can('custom_traffic_perfdata'),
|
closure_custom_perfdata => $self->can('custom_traffic_perfdata'),
|
||||||
closure_custom_threshold_check => $self->can('custom_traffic_threshold'),
|
closure_custom_threshold_check => $self->can('custom_traffic_threshold'),
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
$self->{maps_counters}->{int}->{'090_laser-temp'} = { filter => 'add_optical',
|
;
|
||||||
set => {
|
}
|
||||||
|
|
||||||
|
sub set_counters {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->SUPER::set_counters(%options);
|
||||||
|
|
||||||
|
push @{$self->{maps_counters}->{int}},
|
||||||
|
{ label => 'laser-temp', filter => 'add_optical', set => {
|
||||||
key_values => [ { name => 'laser_temp' }, { name => 'display' } ],
|
key_values => [ { name => 'laser_temp' }, { name => 'display' } ],
|
||||||
output_template => 'Laser Temperature : %.2f C', output_error_template => 'Laser Temperature : %.2f',
|
output_template => 'Laser Temperature : %.2f C', output_error_template => 'Laser Temperature : %.2f',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
|
@ -69,9 +75,8 @@ sub set_counters {
|
||||||
unit => 'C', label_extra_instance => 1, instance_use => 'display_absolute' },
|
unit => 'C', label_extra_instance => 1, instance_use => 'display_absolute' },
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
$self->{maps_counters}->{int}->{'091_input-power'} = { filter => 'add_optical',
|
{ label => 'input-power', filter => 'add_optical', set => {
|
||||||
set => {
|
|
||||||
key_values => [ { name => 'input_power' }, { name => 'display' } ],
|
key_values => [ { name => 'input_power' }, { name => 'display' } ],
|
||||||
output_template => 'Input Power : %s dBm', output_error_template => 'Input Power : %s',
|
output_template => 'Input Power : %s dBm', output_error_template => 'Input Power : %s',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
|
@ -79,9 +84,8 @@ sub set_counters {
|
||||||
unit => 'dBm', label_extra_instance => 1, instance_use => 'display_absolute' },
|
unit => 'dBm', label_extra_instance => 1, instance_use => 'display_absolute' },
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
$self->{maps_counters}->{int}->{'091_output-power'} = { filter => 'add_optical',
|
{ label => 'output-power', filter => 'add_optical', set => {
|
||||||
set => {
|
|
||||||
key_values => [ { name => 'output_power' }, { name => 'display' } ],
|
key_values => [ { name => 'output_power' }, { name => 'display' } ],
|
||||||
output_template => 'Output Power : %s dBm', output_error_template => 'Output Power : %s',
|
output_template => 'Output Power : %s dBm', output_error_template => 'Output Power : %s',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
|
@ -89,9 +93,8 @@ sub set_counters {
|
||||||
unit => 'dBm', label_extra_instance => 1, instance_use => 'display_absolute' },
|
unit => 'dBm', label_extra_instance => 1, instance_use => 'display_absolute' },
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
|
;
|
||||||
$self->SUPER::set_counters(%options);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub custom_traffic_perfdata {
|
sub custom_traffic_perfdata {
|
||||||
|
@ -173,15 +176,26 @@ sub new {
|
||||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_set_traffic => 1, no_errors => 1, no_cast => 1);
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_set_traffic => 1, no_errors => 1, no_cast => 1);
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments =>
|
$options{options}->add_options(arguments => {
|
||||||
{
|
'add-optical' => { name => 'add_optical' },
|
||||||
"add-optical" => { name => 'add_optical' },
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub check_options {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
$self->SUPER::check_options(%options);
|
||||||
|
|
||||||
|
$self->{checking} = '';
|
||||||
|
foreach (('add_global', 'add_status', 'add_traffic', 'add_speed', 'add_volume', 'add_optical')) {
|
||||||
|
if (defined($self->{option_results}->{$_})) {
|
||||||
|
$self->{checking} .= $_;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
my $oid_opticalIfDiagLaserTemp = '.1.3.6.1.4.1.2544.1.11.2.4.3.5.1.2';
|
my $oid_opticalIfDiagLaserTemp = '.1.3.6.1.4.1.2544.1.11.2.4.3.5.1.2';
|
||||||
my $oid_opticalIfDiagInputPower = '.1.3.6.1.4.1.2544.1.11.2.4.3.5.1.3';
|
my $oid_opticalIfDiagInputPower = '.1.3.6.1.4.1.2544.1.11.2.4.3.5.1.3';
|
||||||
my $oid_opticalIfDiagOutputPower = '.1.3.6.1.4.1.2544.1.11.2.4.3.5.1.4';
|
my $oid_opticalIfDiagOutputPower = '.1.3.6.1.4.1.2544.1.11.2.4.3.5.1.4';
|
||||||
|
@ -199,22 +213,22 @@ sub custom_add_result {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
return if (!defined($self->{option_results}->{add_optical}));
|
return if (!defined($self->{option_results}->{add_optical}));
|
||||||
$self->{interface_selected}->{$options{instance}}->{laser_temp} = undef;
|
$self->{int}->{$options{instance}}->{laser_temp} = undef;
|
||||||
if (defined($self->{results}->{$oid_opticalIfDiagLaserTemp . '.' . $options{instance}}) &&
|
if (defined($self->{results}->{$oid_opticalIfDiagLaserTemp . '.' . $options{instance}}) &&
|
||||||
$self->{results}->{$oid_opticalIfDiagLaserTemp . '.' . $options{instance}} != -2147483648) {
|
$self->{results}->{$oid_opticalIfDiagLaserTemp . '.' . $options{instance}} != -2147483648) {
|
||||||
$self->{interface_selected}->{$options{instance}}->{laser_temp} = $self->{results}->{$oid_opticalIfDiagLaserTemp . '.' . $options{instance}} * 0.1;
|
$self->{int}->{$options{instance}}->{laser_temp} = $self->{results}->{$oid_opticalIfDiagLaserTemp . '.' . $options{instance}} * 0.1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{interface_selected}->{$options{instance}}->{input_power} = undef;
|
$self->{int}->{$options{instance}}->{input_power} = undef;
|
||||||
if (defined($self->{results}->{$oid_opticalIfDiagInputPower . '.' . $options{instance}}) &&
|
if (defined($self->{results}->{$oid_opticalIfDiagInputPower . '.' . $options{instance}}) &&
|
||||||
$self->{results}->{$oid_opticalIfDiagInputPower . '.' . $options{instance}} != -65535) {
|
$self->{results}->{$oid_opticalIfDiagInputPower . '.' . $options{instance}} != -65535) {
|
||||||
$self->{interface_selected}->{$options{instance}}->{input_power} = $self->{results}->{$oid_opticalIfDiagInputPower . '.' . $options{instance}} / 10;
|
$self->{int}->{$options{instance}}->{input_power} = $self->{results}->{$oid_opticalIfDiagInputPower . '.' . $options{instance}} / 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{interface_selected}->{$options{instance}}->{output_power} = undef;
|
$self->{int}->{$options{instance}}->{output_power} = undef;
|
||||||
if (defined($self->{results}->{$oid_opticalIfDiagOutputPower . '.' . $options{instance}}) &&
|
if (defined($self->{results}->{$oid_opticalIfDiagOutputPower . '.' . $options{instance}}) &&
|
||||||
$self->{results}->{$oid_opticalIfDiagOutputPower . '.' . $options{instance}} != -65535) {
|
$self->{results}->{$oid_opticalIfDiagOutputPower . '.' . $options{instance}} != -65535) {
|
||||||
$self->{interface_selected}->{$options{instance}}->{output_power} = $self->{results}->{$oid_opticalIfDiagOutputPower . '.' . $options{instance}} / 10;
|
$self->{int}->{$options{instance}}->{output_power} = $self->{results}->{$oid_opticalIfDiagOutputPower . '.' . $options{instance}} / 10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,26 +249,26 @@ sub load_traffic {
|
||||||
sub add_result_traffic {
|
sub add_result_traffic {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{interface_selected}->{$options{instance}}->{traffic_in_15min} =
|
$self->{int}->{$options{instance}}->{traffic_in_15min} =
|
||||||
defined($self->{results}->{$self->{currentEthRxHighSpeed15minBytes} . '.' . $options{instance}}) ? $self->{results}->{$self->{currentEthRxHighSpeed15minBytes} . '.' . $options{instance}} * 8 :
|
defined($self->{results}->{$self->{currentEthRxHighSpeed15minBytes} . '.' . $options{instance}}) ? $self->{results}->{$self->{currentEthRxHighSpeed15minBytes} . '.' . $options{instance}} * 8 :
|
||||||
(defined($self->{results}->{$self->{currentEthRx15minBytes} . '.' . $options{instance}}) ? $self->{results}->{$self->{currentEthRx15minBytes} . '.' . $options{instance}} * 8 : undef);
|
(defined($self->{results}->{$self->{currentEthRx15minBytes} . '.' . $options{instance}}) ? $self->{results}->{$self->{currentEthRx15minBytes} . '.' . $options{instance}} * 8 : undef);
|
||||||
$self->{interface_selected}->{$options{instance}}->{traffic_in_1day} =
|
$self->{int}->{$options{instance}}->{traffic_in_1day} =
|
||||||
defined($self->{results}->{$self->{currentEthRxHighSpeed1dayBytes} . '.' . $options{instance}}) ? $self->{results}->{$self->{currentEthRxHighSpeed1dayBytes} . '.' . $options{instance}} * 8 :
|
defined($self->{results}->{$self->{currentEthRxHighSpeed1dayBytes} . '.' . $options{instance}}) ? $self->{results}->{$self->{currentEthRxHighSpeed1dayBytes} . '.' . $options{instance}} * 8 :
|
||||||
(defined($self->{results}->{$self->{currentEthRx1dayBytes} . '.' . $options{instance}}) ? $self->{results}->{$self->{currentEthRx1dayBytes} . '.' . $options{instance}} * 8 : undef);
|
(defined($self->{results}->{$self->{currentEthRx1dayBytes} . '.' . $options{instance}}) ? $self->{results}->{$self->{currentEthRx1dayBytes} . '.' . $options{instance}} * 8 : undef);
|
||||||
$self->{interface_selected}->{$options{instance}}->{traffic_out_15min} =
|
$self->{int}->{$options{instance}}->{traffic_out_15min} =
|
||||||
defined($self->{results}->{$self->{currentEthTx15minBytes} . '.' . $options{instance}}) ? $self->{results}->{$self->{currentEthTx15minBytes} . '.' . $options{instance}} * 8 : undef;
|
defined($self->{results}->{$self->{currentEthTx15minBytes} . '.' . $options{instance}}) ? $self->{results}->{$self->{currentEthTx15minBytes} . '.' . $options{instance}} * 8 : undef;
|
||||||
$self->{interface_selected}->{$options{instance}}->{traffic_out_1day} =
|
$self->{int}->{$options{instance}}->{traffic_out_1day} =
|
||||||
defined($self->{results}->{$self->{currentEthTx1dayBytes} . '.' . $options{instance}}) ? $self->{results}->{$self->{currentEthTx1dayBytes} . '.' . $options{instance}} * 8 : undef;
|
defined($self->{results}->{$self->{currentEthTx1dayBytes} . '.' . $options{instance}}) ? $self->{results}->{$self->{currentEthTx1dayBytes} . '.' . $options{instance}} * 8 : undef;
|
||||||
|
|
||||||
$self->{interface_selected}->{$options{instance}}->{speed_in} = 0;
|
$self->{int}->{$options{instance}}->{speed_in} = 0;
|
||||||
$self->{interface_selected}->{$options{instance}}->{speed_out} = 0;
|
$self->{int}->{$options{instance}}->{speed_out} = 0;
|
||||||
if ($self->{get_speed} == 0) {
|
if ($self->{get_speed} == 0) {
|
||||||
if (defined($self->{option_results}->{speed}) && $self->{option_results}->{speed} ne '') {
|
if (defined($self->{option_results}->{speed}) && $self->{option_results}->{speed} ne '') {
|
||||||
$self->{interface_selected}->{$options{instance}}->{speed_in} = $self->{option_results}->{speed} * 1000000;
|
$self->{int}->{$options{instance}}->{speed_in} = $self->{option_results}->{speed} * 1000000;
|
||||||
$self->{interface_selected}->{$options{instance}}->{speed_out} = $self->{option_results}->{speed} * 1000000;
|
$self->{int}->{$options{instance}}->{speed_out} = $self->{option_results}->{speed} * 1000000;
|
||||||
}
|
}
|
||||||
$self->{interface_selected}->{$options{instance}}->{speed_in} = $self->{option_results}->{speed_in} * 1000000 if (defined($self->{option_results}->{speed_in}) && $self->{option_results}->{speed_in} ne '');
|
$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 '');
|
||||||
$self->{interface_selected}->{$options{instance}}->{speed_out} = $self->{option_results}->{speed_out} * 1000000 if (defined($self->{option_results}->{speed_out}) && $self->{option_results}->{speed_out} ne '');
|
$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 '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -142,12 +142,11 @@ sub default_oid_display_name {
|
||||||
return 'atrConnCepGenDescr';
|
return 'atrConnCepGenDescr';
|
||||||
}
|
}
|
||||||
|
|
||||||
sub set_counters {
|
sub set_counters_traffic {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{maps_counters} = { int => {}, global => {} };
|
push @{$self->{maps_counters}->{int}},
|
||||||
$self->{maps_counters}->{int}->{'030_in-cir'} = { filter => 'add_traffic',
|
{ label => 'in-cir', filter => 'add_traffic', set => {
|
||||||
set => {
|
|
||||||
key_values => [ { name => 'in_cir', diff => 1 }, { name => 'speed_in'}, { name => 'display' } ],
|
key_values => [ { name => 'in_cir', diff => 1 }, { name => 'speed_in'}, { name => 'display' } ],
|
||||||
per_second => 1,
|
per_second => 1,
|
||||||
closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'in_cir' },
|
closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'in_cir' },
|
||||||
|
@ -155,9 +154,8 @@ sub set_counters {
|
||||||
closure_custom_perfdata => $self->can('custom_traffic_perfdata'),
|
closure_custom_perfdata => $self->can('custom_traffic_perfdata'),
|
||||||
closure_custom_threshold_check => $self->can('custom_traffic_threshold'),
|
closure_custom_threshold_check => $self->can('custom_traffic_threshold'),
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
$self->{maps_counters}->{int}->{'031_in-eir'} = { filter => 'add_traffic',
|
{ label => 'in-eir', filter => 'add_traffic', set => {
|
||||||
set => {
|
|
||||||
key_values => [ { name => 'in_eir', diff => 1 }, { name => 'speed_in'}, { name => 'display' } ],
|
key_values => [ { name => 'in_eir', diff => 1 }, { name => 'speed_in'}, { name => 'display' } ],
|
||||||
per_second => 1,
|
per_second => 1,
|
||||||
closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'in_eir' },
|
closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'in_eir' },
|
||||||
|
@ -165,9 +163,8 @@ sub set_counters {
|
||||||
closure_custom_perfdata => $self->can('custom_traffic_perfdata'),
|
closure_custom_perfdata => $self->can('custom_traffic_perfdata'),
|
||||||
closure_custom_threshold_check => $self->can('custom_traffic_threshold'),
|
closure_custom_threshold_check => $self->can('custom_traffic_threshold'),
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
$self->{maps_counters}->{int}->{'032_out-cir'} = { filter => 'add_traffic',
|
{ label => 'out-cir', filter => 'add_traffic', set => {
|
||||||
set => {
|
|
||||||
key_values => [ { name => 'out_cir', diff => 1 }, { name => 'speed_out'}, { name => 'display' } ],
|
key_values => [ { name => 'out_cir', diff => 1 }, { name => 'speed_out'}, { name => 'display' } ],
|
||||||
per_second => 1,
|
per_second => 1,
|
||||||
closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'out_cir' },
|
closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'out_cir' },
|
||||||
|
@ -175,9 +172,8 @@ sub set_counters {
|
||||||
closure_custom_perfdata => $self->can('custom_traffic_perfdata'),
|
closure_custom_perfdata => $self->can('custom_traffic_perfdata'),
|
||||||
closure_custom_threshold_check => $self->can('custom_traffic_threshold'),
|
closure_custom_threshold_check => $self->can('custom_traffic_threshold'),
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
$self->{maps_counters}->{int}->{'033_out-eir'} = { filter => 'add_traffic',
|
{ label => 'out-eir', filter => 'add_traffic', set => {
|
||||||
set => {
|
|
||||||
key_values => [ { name => 'out_eir', diff => 1 }, { name => 'speed_out'}, { name => 'display' } ],
|
key_values => [ { name => 'out_eir', diff => 1 }, { name => 'speed_out'}, { name => 'display' } ],
|
||||||
per_second => 1,
|
per_second => 1,
|
||||||
closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'out_eir' },
|
closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'out_eir' },
|
||||||
|
@ -185,9 +181,15 @@ sub set_counters {
|
||||||
closure_custom_perfdata => $self->can('custom_traffic_perfdata'),
|
closure_custom_perfdata => $self->can('custom_traffic_perfdata'),
|
||||||
closure_custom_threshold_check => $self->can('custom_traffic_threshold'),
|
closure_custom_threshold_check => $self->can('custom_traffic_threshold'),
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
$self->{maps_counters}->{int}->{'050_in-eir-discard'} = { filter => 'add_errors',
|
;
|
||||||
set => {
|
}
|
||||||
|
|
||||||
|
sub set_counters_errors {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
push @{$self->{maps_counters}->{int}},
|
||||||
|
{ label => 'in-eir-discard', filter => 'add_errors', set => {
|
||||||
key_values => [ { name => 'in_eir_discard', diff => 1 }, { name => 'speed_in'}, { name => 'display' } ],
|
key_values => [ { name => 'in_eir_discard', diff => 1 }, { name => 'speed_in'}, { name => 'display' } ],
|
||||||
per_second => 1,
|
per_second => 1,
|
||||||
closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'in_eir_discard' },
|
closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'in_eir_discard' },
|
||||||
|
@ -195,9 +197,8 @@ sub set_counters {
|
||||||
closure_custom_perfdata => $self->can('custom_traffic_perfdata'),
|
closure_custom_perfdata => $self->can('custom_traffic_perfdata'),
|
||||||
closure_custom_threshold_check => $self->can('custom_traffic_threshold'),
|
closure_custom_threshold_check => $self->can('custom_traffic_threshold'),
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
$self->{maps_counters}->{int}->{'051_out-eir-discard'} = { filter => 'add_errors',
|
{ label => 'out-eir-discard', filter => 'add_errors', set => {
|
||||||
set => {
|
|
||||||
key_values => [ { name => 'out_eir_discard', diff => 1 }, { name => 'speed_out'}, { name => 'display' } ],
|
key_values => [ { name => 'out_eir_discard', diff => 1 }, { name => 'speed_out'}, { name => 'display' } ],
|
||||||
per_second => 1,
|
per_second => 1,
|
||||||
closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'out_eir_discard' },
|
closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'out_eir_discard' },
|
||||||
|
@ -205,9 +206,8 @@ sub set_counters {
|
||||||
closure_custom_perfdata => $self->can('custom_traffic_perfdata'),
|
closure_custom_perfdata => $self->can('custom_traffic_perfdata'),
|
||||||
closure_custom_threshold_check => $self->can('custom_traffic_threshold'),
|
closure_custom_threshold_check => $self->can('custom_traffic_threshold'),
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
|
;
|
||||||
$self->SUPER::set_counters(%options);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub custom_traffic_perfdata {
|
sub custom_traffic_perfdata {
|
||||||
|
@ -239,9 +239,9 @@ sub custom_traffic_threshold {
|
||||||
|
|
||||||
my $exit = 'ok';
|
my $exit = 'ok';
|
||||||
if ($self->{instance_mode}->{option_results}->{units_traffic} eq '%' && defined($self->{result_values}->{speed})) {
|
if ($self->{instance_mode}->{option_results}->{units_traffic} eq '%' && defined($self->{result_values}->{speed})) {
|
||||||
$exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{traffic_prct}, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]);
|
$exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{traffic_prct}, threshold => [ { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' } ]);
|
||||||
} elsif ($self->{instance_mode}->{option_results}->{units_traffic} eq 'b/s') {
|
} elsif ($self->{instance_mode}->{option_results}->{units_traffic} eq 'b/s') {
|
||||||
$exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{traffic_per_seconds}, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]);
|
$exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{traffic_per_seconds}, threshold => [ { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' } ]);
|
||||||
}
|
}
|
||||||
return $exit;
|
return $exit;
|
||||||
}
|
}
|
||||||
|
@ -333,41 +333,41 @@ sub load_errors {
|
||||||
sub add_result_speed {
|
sub add_result_speed {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
return if (defined($self->{interface_selected}->{$options{instance}}->{speed_in}));
|
return if (defined($self->{int}->{$options{instance}}->{speed_in}));
|
||||||
$self->{interface_selected}->{$options{instance}}->{speed_in} = 0;
|
$self->{int}->{$options{instance}}->{speed_in} = 0;
|
||||||
$self->{interface_selected}->{$options{instance}}->{speed_out} = 0;
|
$self->{int}->{$options{instance}}->{speed_out} = 0;
|
||||||
if ($self->{get_speed} == 0) {
|
if ($self->{get_speed} == 0) {
|
||||||
if (defined($self->{option_results}->{speed}) && $self->{option_results}->{speed} ne '') {
|
if (defined($self->{option_results}->{speed}) && $self->{option_results}->{speed} ne '') {
|
||||||
$self->{interface_selected}->{$options{instance}}->{speed_in} = $self->{option_results}->{speed} * 1000000;
|
$self->{int}->{$options{instance}}->{speed_in} = $self->{option_results}->{speed} * 1000000;
|
||||||
$self->{interface_selected}->{$options{instance}}->{speed_out} = $self->{option_results}->{speed} * 1000000;
|
$self->{int}->{$options{instance}}->{speed_out} = $self->{option_results}->{speed} * 1000000;
|
||||||
}
|
}
|
||||||
$self->{interface_selected}->{$options{instance}}->{speed_in} = $self->{option_results}->{speed_in} * 1000000 if (defined($self->{option_results}->{speed_in}) && $self->{option_results}->{speed_in} ne '');
|
$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 '');
|
||||||
$self->{interface_selected}->{$options{instance}}->{speed_out} = $self->{option_results}->{speed_out} * 1000000 if (defined($self->{option_results}->{speed_out}) && $self->{option_results}->{speed_out} ne '');
|
$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 '');
|
||||||
} else {
|
} else {
|
||||||
my $interface_speed = defined($self->{results}->{$self->{oid_speed} . "." . $options{instance}}) ? $self->{results}->{$self->{oid_speed} . "." . $options{instance}} : 0;
|
my $interface_speed = defined($self->{results}->{$self->{oid_speed} . "." . $options{instance}}) ? $self->{results}->{$self->{oid_speed} . "." . $options{instance}} : 0;
|
||||||
$interface_speed *= 1000;
|
$interface_speed *= 1000;
|
||||||
$self->{interface_selected}->{$options{instance}}->{speed_in} = $interface_speed;
|
$self->{int}->{$options{instance}}->{speed_in} = $interface_speed;
|
||||||
$self->{interface_selected}->{$options{instance}}->{speed_out} = $interface_speed;
|
$self->{int}->{$options{instance}}->{speed_out} = $interface_speed;
|
||||||
$self->{interface_selected}->{$options{instance}}->{speed_in} = $self->{option_results}->{speed_in} * 1000000 if (defined($self->{option_results}->{speed_in}) && $self->{option_results}->{speed_in} ne '');
|
$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 '');
|
||||||
$self->{interface_selected}->{$options{instance}}->{speed_out} = $self->{option_results}->{speed_out} * 1000000 if (defined($self->{option_results}->{speed_out}) && $self->{option_results}->{speed_out} ne '');
|
$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 '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub add_result_errors {
|
sub add_result_errors {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{interface_selected}->{$options{instance}}->{in_eir_discard} = $self->{results}->{$self->{oid_ing_eir_discard} . '.' . $options{instance}} * 8;
|
$self->{int}->{$options{instance}}->{in_eir_discard} = $self->{results}->{$self->{oid_ing_eir_discard} . '.' . $options{instance}} * 8;
|
||||||
$self->{interface_selected}->{$options{instance}}->{out_eir_discard} = $self->{results}->{$self->{oid_eg_eir_discard} . '.' . $options{instance}} * 8;
|
$self->{int}->{$options{instance}}->{out_eir_discard} = $self->{results}->{$self->{oid_eg_eir_discard} . '.' . $options{instance}} * 8;
|
||||||
$self->add_result_speed(%options);
|
$self->add_result_speed(%options);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub add_result_traffic {
|
sub add_result_traffic {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{interface_selected}->{$options{instance}}->{in_cir} = $self->{results}->{$self->{oid_ing_cir} . '.' . $options{instance}} * 8;
|
$self->{int}->{$options{instance}}->{in_cir} = $self->{results}->{$self->{oid_ing_cir} . '.' . $options{instance}} * 8;
|
||||||
$self->{interface_selected}->{$options{instance}}->{in_eir} = $self->{results}->{$self->{oid_ing_eir} . '.' . $options{instance}} * 8;
|
$self->{int}->{$options{instance}}->{in_eir} = $self->{results}->{$self->{oid_ing_eir} . '.' . $options{instance}} * 8;
|
||||||
$self->{interface_selected}->{$options{instance}}->{out_cir} = $self->{results}->{$self->{oid_eg_cir} . '.' . $options{instance}} * 8;
|
$self->{int}->{$options{instance}}->{out_cir} = $self->{results}->{$self->{oid_eg_cir} . '.' . $options{instance}} * 8;
|
||||||
$self->{interface_selected}->{$options{instance}}->{out_eir} = $self->{results}->{$self->{oid_eg_eir} . '.' . $options{instance}} * 8;
|
$self->{int}->{$options{instance}}->{out_eir} = $self->{results}->{$self->{oid_eg_eir} . '.' . $options{instance}} * 8;
|
||||||
$self->add_result_speed(%options);
|
$self->add_result_speed(%options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,13 +46,13 @@ sub custom_status_calc {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub set_counters {
|
sub set_counters_global {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{maps_counters} = { int => {}, global => {} } if (!defined($self->{maps_counters}));
|
$self->SUPER::set_counters_global(%options);
|
||||||
|
|
||||||
$self->{maps_counters}->{global}->{'005_total-link-up'} = { filter => 'add_global',
|
push @{$self->{maps_counters}->{global}},
|
||||||
set => {
|
{ label => 'total-link-up', filter => 'add_global', set => {
|
||||||
key_values => [ { name => 'global_link_up' }, { name => 'total_port' } ],
|
key_values => [ { name => 'global_link_up' }, { name => 'total_port' } ],
|
||||||
output_template => 'LinkStatus Up : %s', output_error_template => 'LinkStatus Up : %s',
|
output_template => 'LinkStatus Up : %s', output_error_template => 'LinkStatus Up : %s',
|
||||||
output_use => 'global_link_up_absolute', threshold_use => 'global_link_up_absolute',
|
output_use => 'global_link_up_absolute', threshold_use => 'global_link_up_absolute',
|
||||||
|
@ -61,9 +61,8 @@ sub set_counters {
|
||||||
min => 0, max => 'total_port_absolute' },
|
min => 0, max => 'total_port_absolute' },
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
$self->{maps_counters}->{global}->{'006_total-link-down'} = { filter => 'add_global',
|
{ label => 'total-link-down', filter => 'add_global', set => {
|
||||||
set => {
|
|
||||||
key_values => [ { name => 'global_link_down' }, { name => 'total_port' } ],
|
key_values => [ { name => 'global_link_down' }, { name => 'total_port' } ],
|
||||||
output_template => 'LinkStatus Down : %s', output_error_template => 'LinkStatus Down : %s',
|
output_template => 'LinkStatus Down : %s', output_error_template => 'LinkStatus Down : %s',
|
||||||
output_use => 'global_link_down_absolute', threshold_use => 'global_link_down_absolute',
|
output_use => 'global_link_down_absolute', threshold_use => 'global_link_down_absolute',
|
||||||
|
@ -72,19 +71,23 @@ sub set_counters {
|
||||||
min => 0, max => 'total_port_absolute' },
|
min => 0, max => 'total_port_absolute' },
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
$self->{maps_counters}->{int}->{'045_in-crc'} = { filter => 'add_errors',
|
sub set_counters_errors {
|
||||||
set => {
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
push @{$self->{maps_counters}->{int}},
|
||||||
|
{ label => 'in-crc', filter => 'add_errors', set => {
|
||||||
key_values => [ { name => 'incrc', diff => 1 }, { name => 'total_in_packets', diff => 1 }, { name => 'display' }, { name => 'mode_cast' } ],
|
key_values => [ { name => 'incrc', diff => 1 }, { name => 'total_in_packets', diff => 1 }, { name => 'display' }, { name => 'mode_cast' } ],
|
||||||
closure_custom_calc => $self->can('custom_errors_calc'), closure_custom_calc_extra_options => { label_ref1 => 'in', label_ref2 => 'crc' },
|
closure_custom_calc => $self->can('custom_errors_calc'), closure_custom_calc_extra_options => { label_ref1 => 'in', label_ref2 => 'crc' },
|
||||||
closure_custom_output => $self->can('custom_errors_output'), output_error_template => 'Packets In Crc : %s',
|
closure_custom_output => $self->can('custom_errors_output'), output_error_template => 'Packets In Crc : %s',
|
||||||
closure_custom_perfdata => $self->can('custom_errors_perfdata'),
|
closure_custom_perfdata => $self->can('custom_errors_perfdata'),
|
||||||
closure_custom_threshold_check => $self->can('custom_errors_threshold'),
|
closure_custom_threshold_check => $self->can('custom_errors_threshold'),
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
|
;
|
||||||
$self->SUPER::set_counters(%options);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub set_key_values_status {
|
sub set_key_values_status {
|
||||||
|
@ -343,36 +346,36 @@ sub add_result_global {
|
||||||
sub add_result_status {
|
sub add_result_status {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{interface_selected}->{$options{instance}}->{linkstatus} = defined($self->{results}->{$self->{oid_linkstatus} . '.' . $options{instance}}) ? $self->{oid_linkstatus_mapping}->{$self->{results}->{$self->{oid_linkstatus} . '.' . $options{instance}}} : undef;
|
$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;
|
||||||
$self->{interface_selected}->{$options{instance}}->{opstatus} = defined($self->{results}->{$self->{oid_opstatus} . '.' . $options{instance}}) ? $self->{oid_opstatus_mapping}->{$self->{results}->{$self->{oid_opstatus} . '.' . $options{instance}}} : undef;
|
$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;
|
||||||
$self->{interface_selected}->{$options{instance}}->{admstatus} = defined($self->{results}->{$self->{oid_adminstatus} . '.' . $options{instance}}) ? $self->{oid_adminstatus_mapping}->{$self->{results}->{$self->{oid_adminstatus} . '.' . $options{instance}}} : undef;
|
$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;
|
||||||
$self->{interface_selected}->{$options{instance}}->{duplexstatus} = defined($self->{results}->{$self->{oid_duplexstatus} . '.' . $options{instance}}) ? $self->{oid_duplexstatus_mapping}->{$self->{results}->{$self->{oid_duplexstatus} . '.' . $options{instance}}} : 'n/a';
|
$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';
|
||||||
}
|
}
|
||||||
|
|
||||||
sub add_result_traffic {
|
sub add_result_traffic {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{interface_selected}->{$options{instance}}->{mode_traffic} = 64;
|
$self->{int}->{$options{instance}}->{mode_traffic} = 64;
|
||||||
$self->{interface_selected}->{$options{instance}}->{in} = $self->{results}->{$self->{oid_in64} . '.' . $options{instance}};
|
$self->{int}->{$options{instance}}->{in} = $self->{results}->{$self->{oid_in64} . '.' . $options{instance}};
|
||||||
$self->{interface_selected}->{$options{instance}}->{out} = $self->{results}->{$self->{oid_out64} . '.' . $options{instance}};
|
$self->{int}->{$options{instance}}->{out} = $self->{results}->{$self->{oid_out64} . '.' . $options{instance}};
|
||||||
$self->{interface_selected}->{$options{instance}}->{in} *= 8 if (defined($self->{interface_selected}->{$options{instance}}->{in}));
|
$self->{int}->{$options{instance}}->{in} *= 8 if (defined($self->{int}->{$options{instance}}->{in}));
|
||||||
$self->{interface_selected}->{$options{instance}}->{out} *= 8 if (defined($self->{interface_selected}->{$options{instance}}->{out}));
|
$self->{int}->{$options{instance}}->{out} *= 8 if (defined($self->{int}->{$options{instance}}->{out}));
|
||||||
$self->{interface_selected}->{$options{instance}}->{speed_in} = 0;
|
$self->{int}->{$options{instance}}->{speed_in} = 0;
|
||||||
$self->{interface_selected}->{$options{instance}}->{speed_out} = 0;
|
$self->{int}->{$options{instance}}->{speed_out} = 0;
|
||||||
if ($self->{get_speed} == 0) {
|
if ($self->{get_speed} == 0) {
|
||||||
if (defined($self->{option_results}->{speed}) && $self->{option_results}->{speed} ne '') {
|
if (defined($self->{option_results}->{speed}) && $self->{option_results}->{speed} ne '') {
|
||||||
$self->{interface_selected}->{$options{instance}}->{speed_in} = $self->{option_results}->{speed} * 1000000;
|
$self->{int}->{$options{instance}}->{speed_in} = $self->{option_results}->{speed} * 1000000;
|
||||||
$self->{interface_selected}->{$options{instance}}->{speed_out} = $self->{option_results}->{speed} * 1000000;
|
$self->{int}->{$options{instance}}->{speed_out} = $self->{option_results}->{speed} * 1000000;
|
||||||
}
|
}
|
||||||
$self->{interface_selected}->{$options{instance}}->{speed_in} = $self->{option_results}->{speed_in} * 1000000 if (defined($self->{option_results}->{speed_in}) && $self->{option_results}->{speed_in} ne '');
|
$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 '');
|
||||||
$self->{interface_selected}->{$options{instance}}->{speed_out} = $self->{option_results}->{speed_out} * 1000000 if (defined($self->{option_results}->{speed_out}) && $self->{option_results}->{speed_out} ne '');
|
$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 '');
|
||||||
} else {
|
} else {
|
||||||
my $interface_speed = 0;
|
my $interface_speed = 0;
|
||||||
$interface_speed = $self->{results}->{$self->{oid_speed64} . "." . $options{instance}} * 1000000;
|
$interface_speed = $self->{results}->{$self->{oid_speed64} . "." . $options{instance}} * 1000000;
|
||||||
$self->{interface_selected}->{$options{instance}}->{speed_in} = $interface_speed;
|
$self->{int}->{$options{instance}}->{speed_in} = $interface_speed;
|
||||||
$self->{interface_selected}->{$options{instance}}->{speed_out} = $interface_speed;
|
$self->{int}->{$options{instance}}->{speed_out} = $interface_speed;
|
||||||
$self->{interface_selected}->{$options{instance}}->{speed_in} = $self->{option_results}->{speed_in} * 1000000 if (defined($self->{option_results}->{speed_in}) && $self->{option_results}->{speed_in} ne '');
|
$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 '');
|
||||||
$self->{interface_selected}->{$options{instance}}->{speed_out} = $self->{option_results}->{speed_out} * 1000000 if (defined($self->{option_results}->{speed_out}) && $self->{option_results}->{speed_out} ne '');
|
$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 '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -381,27 +384,27 @@ sub add_result_cast {
|
||||||
|
|
||||||
my $iucast = $self->{results}->{$self->{oid_ifHCInUcastPkts} . '.' . $options{instance}};
|
my $iucast = $self->{results}->{$self->{oid_ifHCInUcastPkts} . '.' . $options{instance}};
|
||||||
if (defined($iucast) && $iucast =~ /[1-9]/) {
|
if (defined($iucast) && $iucast =~ /[1-9]/) {
|
||||||
$self->{interface_selected}->{$options{instance}}->{iucast} = $iucast;
|
$self->{int}->{$options{instance}}->{iucast} = $iucast;
|
||||||
$self->{interface_selected}->{$options{instance}}->{imcast} = defined($self->{results}->{$self->{oid_ifHCInMulticastPkts} . '.' . $options{instance}}) ? $self->{results}->{$self->{oid_ifHCInMulticastPkts} . '.' . $options{instance}} : 0;
|
$self->{int}->{$options{instance}}->{imcast} = defined($self->{results}->{$self->{oid_ifHCInMulticastPkts} . '.' . $options{instance}}) ? $self->{results}->{$self->{oid_ifHCInMulticastPkts} . '.' . $options{instance}} : 0;
|
||||||
$self->{interface_selected}->{$options{instance}}->{ibcast} = defined($self->{results}->{$self->{oid_ifHCInBroadcastPkts} . '.' . $options{instance}}) ? $self->{results}->{$self->{oid_ifHCInBroadcastPkts} . '.' . $options{instance}} : 0;
|
$self->{int}->{$options{instance}}->{ibcast} = defined($self->{results}->{$self->{oid_ifHCInBroadcastPkts} . '.' . $options{instance}}) ? $self->{results}->{$self->{oid_ifHCInBroadcastPkts} . '.' . $options{instance}} : 0;
|
||||||
$self->{interface_selected}->{$options{instance}}->{oucast} = $self->{results}->{$self->{oid_ifHCOutUcastPkts} . '.' . $options{instance}};
|
$self->{int}->{$options{instance}}->{oucast} = $self->{results}->{$self->{oid_ifHCOutUcastPkts} . '.' . $options{instance}};
|
||||||
$self->{interface_selected}->{$options{instance}}->{omcast} = defined($self->{results}->{$self->{oid_ifHCOutMulticastPkts} . '.' . $options{instance}}) ? $self->{results}->{$self->{oid_ifHCOutMulticastPkts} . '.' . $options{instance}} : 0;
|
$self->{int}->{$options{instance}}->{omcast} = defined($self->{results}->{$self->{oid_ifHCOutMulticastPkts} . '.' . $options{instance}}) ? $self->{results}->{$self->{oid_ifHCOutMulticastPkts} . '.' . $options{instance}} : 0;
|
||||||
$self->{interface_selected}->{$options{instance}}->{obcast} = defined($self->{results}->{$self->{oid_ifHCOutBroadcastPkts} . '.' . $options{instance}}) ? $self->{results}->{$self->{oid_ifHCOutBroadcastPkts} . '.' . $options{instance}} : 0;
|
$self->{int}->{$options{instance}}->{obcast} = defined($self->{results}->{$self->{oid_ifHCOutBroadcastPkts} . '.' . $options{instance}}) ? $self->{results}->{$self->{oid_ifHCOutBroadcastPkts} . '.' . $options{instance}} : 0;
|
||||||
$self->{interface_selected}->{$options{instance}}->{mode_cast} = 64;
|
$self->{int}->{$options{instance}}->{mode_cast} = 64;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (('iucast', 'imcast', 'ibcast', 'oucast', 'omcast', 'obcast')) {
|
foreach (('iucast', 'imcast', 'ibcast', 'oucast', 'omcast', 'obcast')) {
|
||||||
$self->{interface_selected}->{$options{instance}}->{$_} = 0 if (!defined($self->{interface_selected}->{$options{instance}}->{$_}));
|
$self->{int}->{$options{instance}}->{$_} = 0 if (!defined($self->{int}->{$options{instance}}->{$_}));
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{interface_selected}->{$options{instance}}->{total_in_packets} = $self->{interface_selected}->{$options{instance}}->{iucast} + $self->{interface_selected}->{$options{instance}}->{imcast} + $self->{interface_selected}->{$options{instance}}->{ibcast};
|
$self->{int}->{$options{instance}}->{total_in_packets} = $self->{int}->{$options{instance}}->{iucast} + $self->{int}->{$options{instance}}->{imcast} + $self->{int}->{$options{instance}}->{ibcast};
|
||||||
$self->{interface_selected}->{$options{instance}}->{total_out_packets} = $self->{interface_selected}->{$options{instance}}->{oucast} + $self->{interface_selected}->{$options{instance}}->{omcast} + $self->{interface_selected}->{$options{instance}}->{obcast};
|
$self->{int}->{$options{instance}}->{total_out_packets} = $self->{int}->{$options{instance}}->{oucast} + $self->{int}->{$options{instance}}->{omcast} + $self->{int}->{$options{instance}}->{obcast};
|
||||||
}
|
}
|
||||||
|
|
||||||
sub add_result_errors {
|
sub add_result_errors {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{interface_selected}->{$options{instance}}->{incrc} = $self->{results}->{$self->{oid_ifInCrc} . '.' . $options{instance}};
|
$self->{int}->{$options{instance}}->{incrc} = $self->{results}->{$self->{oid_ifInCrc} . '.' . $options{instance}};
|
||||||
}
|
}
|
||||||
|
|
||||||
sub add_result_speed {
|
sub add_result_speed {
|
||||||
|
@ -410,14 +413,14 @@ sub add_result_speed {
|
||||||
my $interface_speed = 0;
|
my $interface_speed = 0;
|
||||||
$interface_speed = $self->{results}->{$self->{oid_speed64} . "." . $options{instance}} * 1000000;
|
$interface_speed = $self->{results}->{$self->{oid_speed64} . "." . $options{instance}} * 1000000;
|
||||||
|
|
||||||
$self->{interface_selected}->{$options{instance}}->{speed} = $interface_speed;
|
$self->{int}->{$options{instance}}->{speed} = $interface_speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub add_result_volume {
|
sub add_result_volume {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{interface_selected}->{$options{instance}}->{in_volume} = $self->{results}->{$self->{oid_in64} . '.' . $options{instance}};
|
$self->{int}->{$options{instance}}->{in_volume} = $self->{results}->{$self->{oid_in64} . '.' . $options{instance}};
|
||||||
$self->{interface_selected}->{$options{instance}}->{out_volume} = $self->{results}->{$self->{oid_out64} . '.' . $options{instance}};
|
$self->{int}->{$options{instance}}->{out_volume} = $self->{results}->{$self->{oid_out64} . '.' . $options{instance}};
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
|
@ -20,11 +20,10 @@
|
||||||
|
|
||||||
package snmp_standard::mode::interfaces;
|
package snmp_standard::mode::interfaces;
|
||||||
|
|
||||||
use base qw(centreon::plugins::mode);
|
use base qw(centreon::plugins::templates::counter);
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use centreon::plugins::values;
|
|
||||||
use centreon::plugins::statefile;
|
use centreon::plugins::statefile;
|
||||||
use Digest::MD5 qw(md5_hex);
|
use Digest::MD5 qw(md5_hex);
|
||||||
|
|
||||||
|
@ -128,17 +127,21 @@ sub custom_traffic_perfdata {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defined($self->{instance_mode}->{option_results}->{nagvis_perfdata})) {
|
if (defined($self->{instance_mode}->{option_results}->{nagvis_perfdata})) {
|
||||||
$self->{output}->perfdata_add(label => $self->{result_values}->{label} . $extra_label,
|
$self->{output}->perfdata_add(
|
||||||
|
label => $self->{result_values}->{label} . $extra_label,
|
||||||
value => sprintf("%.2f", $self->{result_values}->{traffic_per_seconds}),
|
value => sprintf("%.2f", $self->{result_values}->{traffic_per_seconds}),
|
||||||
warning => $warning,
|
warning => $warning,
|
||||||
critical => $critical,
|
critical => $critical,
|
||||||
min => 0, max => $self->{result_values}->{speed});
|
min => 0, max => $self->{result_values}->{speed}
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
$self->{output}->perfdata_add(label => 'traffic_' . $self->{result_values}->{label} . $extra_label, unit => 'b/s',
|
$self->{output}->perfdata_add(
|
||||||
|
label => 'traffic_' . $self->{result_values}->{label} . $extra_label, unit => 'b/s',
|
||||||
value => sprintf("%.2f", $self->{result_values}->{traffic_per_seconds}),
|
value => sprintf("%.2f", $self->{result_values}->{traffic_per_seconds}),
|
||||||
warning => $warning,
|
warning => $warning,
|
||||||
critical => $critical,
|
critical => $critical,
|
||||||
min => 0, max => $self->{result_values}->{speed});
|
min => 0, max => $self->{result_values}->{speed}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,9 +150,9 @@ sub custom_traffic_threshold {
|
||||||
|
|
||||||
my $exit = 'ok';
|
my $exit = 'ok';
|
||||||
if ($self->{instance_mode}->{option_results}->{units_traffic} eq '%' && defined($self->{result_values}->{speed})) {
|
if ($self->{instance_mode}->{option_results}->{units_traffic} eq '%' && defined($self->{result_values}->{speed})) {
|
||||||
$exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{traffic_prct}, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]);
|
$exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{traffic_prct}, threshold => [ { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' } ]);
|
||||||
} elsif ($self->{instance_mode}->{option_results}->{units_traffic} eq 'b/s') {
|
} elsif ($self->{instance_mode}->{option_results}->{units_traffic} eq 'b/s') {
|
||||||
$exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{traffic_per_seconds}, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]);
|
$exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{traffic_per_seconds}, threshold => [ { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' } ]);
|
||||||
}
|
}
|
||||||
return $exit;
|
return $exit;
|
||||||
}
|
}
|
||||||
|
@ -201,17 +204,21 @@ sub custom_errors_perfdata {
|
||||||
$extra_label .= '_' . $self->{result_values}->{display};
|
$extra_label .= '_' . $self->{result_values}->{display};
|
||||||
}
|
}
|
||||||
if ($self->{instance_mode}->{option_results}->{units_errors} eq '%') {
|
if ($self->{instance_mode}->{option_results}->{units_errors} eq '%') {
|
||||||
$self->{output}->perfdata_add(label => 'packets_' . $self->{result_values}->{label2} . '_' . $self->{result_values}->{label1} . $extra_label, unit => '%',
|
$self->{output}->perfdata_add(
|
||||||
|
label => 'packets_' . $self->{result_values}->{label2} . '_' . $self->{result_values}->{label1} . $extra_label, unit => '%',
|
||||||
value => sprintf("%.2f", $self->{result_values}->{prct}),
|
value => sprintf("%.2f", $self->{result_values}->{prct}),
|
||||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}),
|
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}),
|
||||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}),
|
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}),
|
||||||
min => 0, max => 100);
|
min => 0, max => 100
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
$self->{output}->perfdata_add(label => 'packets_' . $self->{result_values}->{label2} . '_' . $self->{result_values}->{label1} . $extra_label,
|
$self->{output}->perfdata_add(
|
||||||
|
label => 'packets_' . $self->{result_values}->{label2} . '_' . $self->{result_values}->{label1} . $extra_label,
|
||||||
value => $self->{result_values}->{used},
|
value => $self->{result_values}->{used},
|
||||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}),
|
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}),
|
||||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}),
|
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}),
|
||||||
min => 0, max => $self->{result_values}->{total});
|
min => 0, max => $self->{result_values}->{total}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,9 +227,9 @@ sub custom_errors_threshold {
|
||||||
|
|
||||||
my $exit = 'ok';
|
my $exit = 'ok';
|
||||||
if ($self->{instance_mode}->{option_results}->{units_errors} eq '%') {
|
if ($self->{instance_mode}->{option_results}->{units_errors} eq '%') {
|
||||||
$exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{prct}, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]);
|
$exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{prct}, threshold => [ { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' } ]);
|
||||||
} else {
|
} else {
|
||||||
$exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{used}, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]);
|
$exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{used}, threshold => [ { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' } ]);
|
||||||
}
|
}
|
||||||
return $exit;
|
return $exit;
|
||||||
}
|
}
|
||||||
|
@ -274,13 +281,12 @@ sub custom_speed_calc {
|
||||||
#########################
|
#########################
|
||||||
# OIDs mapping functions
|
# OIDs mapping functions
|
||||||
#########################
|
#########################
|
||||||
sub set_counters {
|
|
||||||
|
sub set_counters_global {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{maps_counters} = { int => {}, global => {} } if (!defined($self->{maps_counters}));
|
push @{$self->{maps_counters}->{global}},
|
||||||
|
{ label => 'total-port', filter => 'add_global', set => {
|
||||||
$self->{maps_counters}->{global}->{'000_total-port'} = { filter => 'add_global',
|
|
||||||
set => {
|
|
||||||
key_values => [ { name => 'total_port' } ],
|
key_values => [ { name => 'total_port' } ],
|
||||||
output_template => 'Total port : %s', output_error_template => 'Total port : %s',
|
output_template => 'Total port : %s', output_error_template => 'Total port : %s',
|
||||||
output_use => 'total_port_absolute', threshold_use => 'total_port_absolute',
|
output_use => 'total_port_absolute', threshold_use => 'total_port_absolute',
|
||||||
|
@ -289,9 +295,8 @@ sub set_counters {
|
||||||
min => 0, max => 'total_port_absolute' },
|
min => 0, max => 'total_port_absolute' },
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
$self->{maps_counters}->{global}->{'001_global-admin-up'} = { filter => 'add_global',
|
{ label => 'global-admin-up', filter => 'add_global', set => {
|
||||||
set => {
|
|
||||||
key_values => [ { name => 'global_admin_up' }, { name => 'total_port' } ],
|
key_values => [ { name => 'global_admin_up' }, { name => 'total_port' } ],
|
||||||
output_template => 'AdminStatus Up : %s', output_error_template => 'AdminStatus Up : %s',
|
output_template => 'AdminStatus Up : %s', output_error_template => 'AdminStatus Up : %s',
|
||||||
output_use => 'global_admin_up_absolute', threshold_use => 'global_admin_up_absolute',
|
output_use => 'global_admin_up_absolute', threshold_use => 'global_admin_up_absolute',
|
||||||
|
@ -300,9 +305,8 @@ sub set_counters {
|
||||||
min => 0, max => 'total_port_absolute' },
|
min => 0, max => 'total_port_absolute' },
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
$self->{maps_counters}->{global}->{'002_total-admin-down'} = { filter => 'add_global',
|
{ label => 'total-admin-down', filter => 'add_global', set => {
|
||||||
set => {
|
|
||||||
key_values => [ { name => 'global_admin_down' }, { name => 'total_port' } ],
|
key_values => [ { name => 'global_admin_down' }, { name => 'total_port' } ],
|
||||||
output_template => 'AdminStatus Down : %s', output_error_template => 'AdminStatus Down : %s',
|
output_template => 'AdminStatus Down : %s', output_error_template => 'AdminStatus Down : %s',
|
||||||
output_use => 'global_admin_down_absolute', threshold_use => 'global_admin_down_absolute',
|
output_use => 'global_admin_down_absolute', threshold_use => 'global_admin_down_absolute',
|
||||||
|
@ -311,9 +315,8 @@ sub set_counters {
|
||||||
min => 0, max => 'total_port_absolute' },
|
min => 0, max => 'total_port_absolute' },
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
$self->{maps_counters}->{global}->{'003_total-oper-up'} = { filter => 'add_global',
|
{ label => 'total-oper-up', filter => 'add_global', set => {
|
||||||
set => {
|
|
||||||
key_values => [ { name => 'global_oper_up' }, { name => 'total_port' } ],
|
key_values => [ { name => 'global_oper_up' }, { name => 'total_port' } ],
|
||||||
output_template => 'OperStatus Up : %s', output_error_template => 'OperStatus Up : %s',
|
output_template => 'OperStatus Up : %s', output_error_template => 'OperStatus Up : %s',
|
||||||
output_use => 'global_oper_up_absolute', threshold_use => 'global_oper_up_absolute',
|
output_use => 'global_oper_up_absolute', threshold_use => 'global_oper_up_absolute',
|
||||||
|
@ -322,9 +325,8 @@ sub set_counters {
|
||||||
min => 0, max => 'total_port_absolute' },
|
min => 0, max => 'total_port_absolute' },
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
$self->{maps_counters}->{global}->{'004_total-oper-down'} = { filter => 'add_global',
|
{ label => 'total-oper-down', filter => 'add_global', set => {
|
||||||
set => {
|
|
||||||
key_values => [ { name => 'global_oper_down' }, { name => 'total_port' } ],
|
key_values => [ { name => 'global_oper_down' }, { name => 'total_port' } ],
|
||||||
output_template => 'OperStatus Down : %s', output_error_template => 'OperStatus Down : %s',
|
output_template => 'OperStatus Down : %s', output_error_template => 'OperStatus Down : %s',
|
||||||
output_use => 'global_oper_down_absolute', threshold_use => 'global_oper_down_absolute',
|
output_use => 'global_oper_down_absolute', threshold_use => 'global_oper_down_absolute',
|
||||||
|
@ -333,20 +335,32 @@ sub set_counters {
|
||||||
min => 0, max => 'total_port_absolute' },
|
min => 0, max => 'total_port_absolute' },
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
$self->{maps_counters}->{int}->{'000_status'} = { filter => 'add_status', threshold => 0,
|
sub set_counters_status {
|
||||||
set => {
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
push @{$self->{maps_counters}->{int}},
|
||||||
|
{ label => 'status', filter => 'add_status', threshold => 0, set => {
|
||||||
key_values => $self->set_key_values_status(),
|
key_values => $self->set_key_values_status(),
|
||||||
closure_custom_calc => $self->can('custom_status_calc'),
|
closure_custom_calc => $self->can('custom_status_calc'),
|
||||||
closure_custom_output => $self->can('custom_status_output'),
|
closure_custom_output => $self->can('custom_status_output'),
|
||||||
closure_custom_perfdata => sub { return 0; },
|
closure_custom_perfdata => sub { return 0; },
|
||||||
closure_custom_threshold_check => $self->can('custom_threshold_output'),
|
closure_custom_threshold_check => $self->can('custom_threshold_output'),
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
if ($self->{no_traffic} == 0 && $self->{no_set_traffic} == 0) {
|
;
|
||||||
$self->{maps_counters}->{int}->{'020_in-traffic'} = { filter => 'add_traffic',
|
}
|
||||||
set => {
|
|
||||||
|
sub set_counters_traffic {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return if ($self->{no_traffic} != 0 && $self->{no_set_traffic} != 0);
|
||||||
|
|
||||||
|
push @{$self->{maps_counters}->{int}},
|
||||||
|
{ label => 'in-traffic', filter => 'add_traffic', set => {
|
||||||
key_values => $self->set_key_values_in_traffic(),
|
key_values => $self->set_key_values_in_traffic(),
|
||||||
per_second => 1,
|
per_second => 1,
|
||||||
closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'in' },
|
closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'in' },
|
||||||
|
@ -354,9 +368,8 @@ sub set_counters {
|
||||||
closure_custom_perfdata => $self->can('custom_traffic_perfdata'),
|
closure_custom_perfdata => $self->can('custom_traffic_perfdata'),
|
||||||
closure_custom_threshold_check => $self->can('custom_traffic_threshold'),
|
closure_custom_threshold_check => $self->can('custom_traffic_threshold'),
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
$self->{maps_counters}->{int}->{'021_out-traffic'} = { filter => 'add_traffic',
|
{ label => 'out-traffic', filter => 'add_traffic', set => {
|
||||||
set => {
|
|
||||||
key_values => $self->set_key_values_out_traffic(),
|
key_values => $self->set_key_values_out_traffic(),
|
||||||
per_second => 1,
|
per_second => 1,
|
||||||
closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'out' },
|
closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'out' },
|
||||||
|
@ -364,49 +377,58 @@ sub set_counters {
|
||||||
closure_custom_perfdata => $self->can('custom_traffic_perfdata'),
|
closure_custom_perfdata => $self->can('custom_traffic_perfdata'),
|
||||||
closure_custom_threshold_check => $self->can('custom_traffic_threshold'),
|
closure_custom_threshold_check => $self->can('custom_traffic_threshold'),
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
|
;
|
||||||
}
|
}
|
||||||
if ($self->{no_errors} == 0 && $self->{no_set_errors} == 0) {
|
|
||||||
$self->{maps_counters}->{int}->{'040_in-discard'} = { filter => 'add_errors',
|
sub set_counters_errors {
|
||||||
set => {
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return if ($self->{no_errors} != 0 && $self->{no_set_errors} != 0);
|
||||||
|
|
||||||
|
push @{$self->{maps_counters}->{int}},
|
||||||
|
{ label => 'in-discard', filter => 'add_errors', set => {
|
||||||
key_values => [ { name => 'indiscard', diff => 1 }, { name => 'total_in_packets', diff => 1 }, { name => 'display' }, { name => 'mode_cast' } ],
|
key_values => [ { name => 'indiscard', diff => 1 }, { name => 'total_in_packets', diff => 1 }, { name => 'display' }, { name => 'mode_cast' } ],
|
||||||
closure_custom_calc => $self->can('custom_errors_calc'), closure_custom_calc_extra_options => { label_ref1 => 'in', label_ref2 => 'discard' },
|
closure_custom_calc => $self->can('custom_errors_calc'), closure_custom_calc_extra_options => { label_ref1 => 'in', label_ref2 => 'discard' },
|
||||||
closure_custom_output => $self->can('custom_errors_output'), output_error_template => 'Packets In Discard : %s',
|
closure_custom_output => $self->can('custom_errors_output'), output_error_template => 'Packets In Discard : %s',
|
||||||
closure_custom_perfdata => $self->can('custom_errors_perfdata'),
|
closure_custom_perfdata => $self->can('custom_errors_perfdata'),
|
||||||
closure_custom_threshold_check => $self->can('custom_errors_threshold'),
|
closure_custom_threshold_check => $self->can('custom_errors_threshold'),
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
$self->{maps_counters}->{int}->{'041_in-error'} = { filter => 'add_errors',
|
{ label => 'in-error', filter => 'add_errors', set => {
|
||||||
set => {
|
|
||||||
key_values => [ { name => 'inerror', diff => 1 }, { name => 'total_in_packets', diff => 1 }, { name => 'display' }, { name => 'mode_cast' } ],
|
key_values => [ { name => 'inerror', diff => 1 }, { name => 'total_in_packets', diff => 1 }, { name => 'display' }, { name => 'mode_cast' } ],
|
||||||
closure_custom_calc => $self->can('custom_errors_calc'), closure_custom_calc_extra_options => { label_ref1 => 'in', label_ref2 => 'error' },
|
closure_custom_calc => $self->can('custom_errors_calc'), closure_custom_calc_extra_options => { label_ref1 => 'in', label_ref2 => 'error' },
|
||||||
closure_custom_output => $self->can('custom_errors_output'), output_error_template => 'Packets In Error : %s',
|
closure_custom_output => $self->can('custom_errors_output'), output_error_template => 'Packets In Error : %s',
|
||||||
closure_custom_perfdata => $self->can('custom_errors_perfdata'),
|
closure_custom_perfdata => $self->can('custom_errors_perfdata'),
|
||||||
closure_custom_threshold_check => $self->can('custom_errors_threshold'),
|
closure_custom_threshold_check => $self->can('custom_errors_threshold'),
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
$self->{maps_counters}->{int}->{'042_out-discard'} = { filter => 'add_errors',
|
{ label => 'out-discard', filter => 'add_errors', set => {
|
||||||
set => {
|
|
||||||
key_values => [ { name => 'outdiscard', diff => 1 }, { name => 'total_out_packets', diff => 1 }, { name => 'display' }, { name => 'mode_cast' } ],
|
key_values => [ { name => 'outdiscard', diff => 1 }, { name => 'total_out_packets', diff => 1 }, { name => 'display' }, { name => 'mode_cast' } ],
|
||||||
closure_custom_calc => $self->can('custom_errors_calc'), closure_custom_calc_extra_options => { label_ref1 => 'out', label_ref2 => 'discard' },
|
closure_custom_calc => $self->can('custom_errors_calc'), closure_custom_calc_extra_options => { label_ref1 => 'out', label_ref2 => 'discard' },
|
||||||
closure_custom_output => $self->can('custom_errors_output'), output_error_template => 'Packets Out Discard : %s',
|
closure_custom_output => $self->can('custom_errors_output'), output_error_template => 'Packets Out Discard : %s',
|
||||||
closure_custom_perfdata => $self->can('custom_errors_perfdata'),
|
closure_custom_perfdata => $self->can('custom_errors_perfdata'),
|
||||||
closure_custom_threshold_check => $self->can('custom_errors_threshold'),
|
closure_custom_threshold_check => $self->can('custom_errors_threshold'),
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
$self->{maps_counters}->{int}->{'043_out-error'} = { filter => 'add_errors',
|
{ label => 'out-error', filter => 'add_errors', set => {
|
||||||
set => {
|
|
||||||
key_values => [ { name => 'outerror', diff => 1 }, { name => 'total_out_packets', diff => 1 }, { name => 'display' }, { name => 'mode_cast' } ],
|
key_values => [ { name => 'outerror', diff => 1 }, { name => 'total_out_packets', diff => 1 }, { name => 'display' }, { name => 'mode_cast' } ],
|
||||||
closure_custom_calc => $self->can('custom_errors_calc'), closure_custom_calc_extra_options => { label_ref1 => 'out', label_ref2 => 'error' },
|
closure_custom_calc => $self->can('custom_errors_calc'), closure_custom_calc_extra_options => { label_ref1 => 'out', label_ref2 => 'error' },
|
||||||
closure_custom_output => $self->can('custom_errors_output'), output_error_template => 'Packets Out Error : %s',
|
closure_custom_output => $self->can('custom_errors_output'), output_error_template => 'Packets Out Error : %s',
|
||||||
closure_custom_perfdata => $self->can('custom_errors_perfdata'),
|
closure_custom_perfdata => $self->can('custom_errors_perfdata'),
|
||||||
closure_custom_threshold_check => $self->can('custom_errors_threshold'),
|
closure_custom_threshold_check => $self->can('custom_errors_threshold'),
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
|
;
|
||||||
}
|
}
|
||||||
if ($self->{no_cast} == 0 && $self->{no_set_cast} == 0) {
|
|
||||||
$self->{maps_counters}->{int}->{'060_in-ucast'} = { filter => 'add_cast',
|
sub set_counters_cast {
|
||||||
set => {
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return if ($self->{no_cast} != 0 && $self->{no_set_cast} != 0);
|
||||||
|
|
||||||
|
push @{$self->{maps_counters}->{int}},
|
||||||
|
{ label => 'in-ucast', filter => 'add_cast', set => {
|
||||||
key_values => [ { name => 'iucast', diff => 1 }, { name => 'imcast', diff => 1 }, { name => 'ibcast', diff => 1 }, { name => 'display' }, { name => 'mode_cast' } ],
|
key_values => [ { name => 'iucast', diff => 1 }, { name => 'imcast', diff => 1 }, { name => 'ibcast', diff => 1 }, { name => 'display' }, { name => 'mode_cast' } ],
|
||||||
closure_custom_calc => \&custom_cast_calc, closure_custom_calc_extra_options => { label_ref => 'iucast', total_ref1 => 'ibcast', total_ref2 => 'imcast' },
|
closure_custom_calc => \&custom_cast_calc, closure_custom_calc_extra_options => { label_ref => 'iucast', total_ref1 => 'ibcast', total_ref2 => 'imcast' },
|
||||||
output_template => 'In Ucast : %.2f %%', output_error_template => 'In Ucast : %s',
|
output_template => 'In Ucast : %.2f %%', output_error_template => 'In Ucast : %s',
|
||||||
|
@ -416,9 +438,8 @@ sub set_counters {
|
||||||
unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' },
|
unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' },
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
$self->{maps_counters}->{int}->{'061_in-bcast'} = { filter => 'add_cast',
|
{ label => 'in-bcast', filter => 'add_cast', set => {
|
||||||
set => {
|
|
||||||
key_values => [ { name => 'iucast', diff => 1 }, { name => 'imcast', diff => 1 }, { name => 'ibcast', diff => 1 }, { name => 'display' }, { name => 'mode_cast' } ],
|
key_values => [ { name => 'iucast', diff => 1 }, { name => 'imcast', diff => 1 }, { name => 'ibcast', diff => 1 }, { name => 'display' }, { name => 'mode_cast' } ],
|
||||||
closure_custom_calc => \&custom_cast_calc, closure_custom_calc_extra_options => { label_ref => 'ibcast', total_ref1 => 'iucast', total_ref2 => 'imcast' },
|
closure_custom_calc => \&custom_cast_calc, closure_custom_calc_extra_options => { label_ref => 'ibcast', total_ref1 => 'iucast', total_ref2 => 'imcast' },
|
||||||
output_template => 'In Bcast : %.2f %%', output_error_template => 'In Bcast : %s',
|
output_template => 'In Bcast : %.2f %%', output_error_template => 'In Bcast : %s',
|
||||||
|
@ -428,9 +449,8 @@ sub set_counters {
|
||||||
unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' },
|
unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' },
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
$self->{maps_counters}->{int}->{'062_in-mcast'} = { filter => 'add_cast',
|
{ label => 'in-mcast', filter => 'add_cast', set => {
|
||||||
set => {
|
|
||||||
key_values => [ { name => 'iucast', diff => 1 }, { name => 'imcast', diff => 1 }, { name => 'ibcast', diff => 1 }, { name => 'display' }, { name => 'mode_cast' } ],
|
key_values => [ { name => 'iucast', diff => 1 }, { name => 'imcast', diff => 1 }, { name => 'ibcast', diff => 1 }, { name => 'display' }, { name => 'mode_cast' } ],
|
||||||
closure_custom_calc => \&custom_cast_calc, closure_custom_calc_extra_options => { label_ref => 'imcast', total_ref1 => 'iucast', total_ref2 => 'ibcast' },
|
closure_custom_calc => \&custom_cast_calc, closure_custom_calc_extra_options => { label_ref => 'imcast', total_ref1 => 'iucast', total_ref2 => 'ibcast' },
|
||||||
output_template => 'In Mcast : %.2f %%', output_error_template => 'In Mcast : %s',
|
output_template => 'In Mcast : %.2f %%', output_error_template => 'In Mcast : %s',
|
||||||
|
@ -440,9 +460,8 @@ sub set_counters {
|
||||||
unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' },
|
unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' },
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
$self->{maps_counters}->{int}->{'063_out-ucast'} = { filter => 'add_cast',
|
{ label => 'out-ucast', filter => 'add_cast', set => {
|
||||||
set => {
|
|
||||||
key_values => [ { name => 'oucast', diff => 1 }, { name => 'omcast', diff => 1 }, { name => 'obcast', diff => 1 }, { name => 'display' }, { name => 'mode_cast' } ],
|
key_values => [ { name => 'oucast', diff => 1 }, { name => 'omcast', diff => 1 }, { name => 'obcast', diff => 1 }, { name => 'display' }, { name => 'mode_cast' } ],
|
||||||
closure_custom_calc => \&custom_cast_calc, closure_custom_calc_extra_options => { label_ref => 'oucast', total_ref1 => 'omcast', total_ref2 => 'obcast' },
|
closure_custom_calc => \&custom_cast_calc, closure_custom_calc_extra_options => { label_ref => 'oucast', total_ref1 => 'omcast', total_ref2 => 'obcast' },
|
||||||
output_template => 'Out Ucast : %.2f %%', output_error_template => 'Out Ucast : %s',
|
output_template => 'Out Ucast : %.2f %%', output_error_template => 'Out Ucast : %s',
|
||||||
|
@ -452,9 +471,8 @@ sub set_counters {
|
||||||
unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' },
|
unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' },
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
$self->{maps_counters}->{int}->{'064_out-bcast'} = { filter => 'add_cast',
|
{ label => 'out-bcast', filter => 'add_cast', set => {
|
||||||
set => {
|
|
||||||
key_values => [ { name => 'oucast', diff => 1 }, { name => 'omcast', diff => 1 }, { name => 'obcast', diff => 1 }, { name => 'display' }, { name => 'mode_cast' } ],
|
key_values => [ { name => 'oucast', diff => 1 }, { name => 'omcast', diff => 1 }, { name => 'obcast', diff => 1 }, { name => 'display' }, { name => 'mode_cast' } ],
|
||||||
closure_custom_calc => \&custom_cast_calc, closure_custom_calc_extra_options => { label_ref => 'obcast', total_ref1 => 'omcast', total_ref2 => 'oucast' },
|
closure_custom_calc => \&custom_cast_calc, closure_custom_calc_extra_options => { label_ref => 'obcast', total_ref1 => 'omcast', total_ref2 => 'oucast' },
|
||||||
output_template => 'Out Bcast : %.2f %%', output_error_template => 'Out Bcast : %s',
|
output_template => 'Out Bcast : %.2f %%', output_error_template => 'Out Bcast : %s',
|
||||||
|
@ -464,9 +482,8 @@ sub set_counters {
|
||||||
unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' },
|
unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' },
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
$self->{maps_counters}->{int}->{'065_out-mcast'} = { filter => 'add_cast',
|
{ label => 'out-mcast', filter => 'add_cast', set => {
|
||||||
set => {
|
|
||||||
key_values => [ { name => 'oucast', diff => 1 }, { name => 'omcast', diff => 1 }, { name => 'obcast', diff => 1 }, { name => 'display' }, { name => 'mode_cast' } ],
|
key_values => [ { name => 'oucast', diff => 1 }, { name => 'omcast', diff => 1 }, { name => 'obcast', diff => 1 }, { name => 'display' }, { name => 'mode_cast' } ],
|
||||||
closure_custom_calc => \&custom_cast_calc, closure_custom_calc_extra_options => { label_ref => 'omcast', total_ref1 => 'oucast', total_ref2 => 'obcast' },
|
closure_custom_calc => \&custom_cast_calc, closure_custom_calc_extra_options => { label_ref => 'omcast', total_ref1 => 'oucast', total_ref2 => 'obcast' },
|
||||||
output_template => 'Out Mcast : %.2f %%', output_error_template => 'Out Mcast : %s',
|
output_template => 'Out Mcast : %.2f %%', output_error_template => 'Out Mcast : %s',
|
||||||
|
@ -476,11 +493,17 @@ sub set_counters {
|
||||||
unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' },
|
unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' },
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
|
;
|
||||||
}
|
}
|
||||||
if ($self->{no_speed} == 0 && $self->{no_set_speed} == 0) {
|
|
||||||
$self->{maps_counters}->{int}->{'080_speed'} = { filter => 'add_speed',
|
sub set_counters_speed {
|
||||||
set => {
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return if ($self->{no_speed} != 0 && $self->{no_set_speed} != 0);
|
||||||
|
|
||||||
|
push @{$self->{maps_counters}->{int}},
|
||||||
|
{ label => 'speed', filter => 'add_speed', set => {
|
||||||
key_values => [ { name => 'speed' }, { name => 'display' } ],
|
key_values => [ { name => 'speed' }, { name => 'display' } ],
|
||||||
closure_custom_calc => $self->can('custom_speed_calc'),
|
closure_custom_calc => $self->can('custom_speed_calc'),
|
||||||
output_template => 'Speed : %s%s/s', output_error_template => 'Speed : %s%s/s',
|
output_template => 'Speed : %s%s/s', output_error_template => 'Speed : %s%s/s',
|
||||||
|
@ -491,11 +514,17 @@ sub set_counters {
|
||||||
unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display' },
|
unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display' },
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
|
;
|
||||||
}
|
}
|
||||||
if ($self->{no_volume} == 0 && $self->{no_set_volume} == 0) {
|
|
||||||
$self->{maps_counters}->{int}->{'090_in-volume'} = { filter => 'add_volume', threshold => 0,
|
sub set_counters_volume {
|
||||||
set => {
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return if ($self->{no_volume} != 0 && $self->{no_set_volume} != 0);
|
||||||
|
|
||||||
|
push @{$self->{maps_counters}->{int}},
|
||||||
|
{ label => 'in-volume', filter => 'add_volume', set => {
|
||||||
key_values => [ { name => 'in_volume', diff => 1 }, { name => 'display' } ],
|
key_values => [ { name => 'in_volume', diff => 1 }, { name => 'display' } ],
|
||||||
output_template => 'Volume In : %.2f %s',
|
output_template => 'Volume In : %.2f %s',
|
||||||
output_change_bytes => 1,
|
output_change_bytes => 1,
|
||||||
|
@ -504,9 +533,8 @@ sub set_counters {
|
||||||
unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
|
unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
$self->{maps_counters}->{int}->{'091_out-volume'} = { filter => 'add_volume', threshold => 0,
|
{ label => 'out-volume', filter => 'add_volume', set => {
|
||||||
set => {
|
|
||||||
key_values => [ { name => 'out_volume', diff => 1 }, { name => 'display' } ],
|
key_values => [ { name => 'out_volume', diff => 1 }, { name => 'display' } ],
|
||||||
output_template => 'Volume Out : %.2f %s',
|
output_template => 'Volume Out : %.2f %s',
|
||||||
output_change_bytes => 1,
|
output_change_bytes => 1,
|
||||||
|
@ -515,8 +543,55 @@ sub set_counters {
|
||||||
unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
|
unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub set_counters {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->{maps_counters_type} = [
|
||||||
|
{ name => 'global', type => 0, cb_init => 'skip_global' },
|
||||||
|
{ name => 'int', type => 1, cb_init => 'skip_interface', cb_init_counters => 'skip_counters', cb_prefix_output => 'prefix_interface_output', message_multiple => 'All interfaces are ok', skipped_code => { -10 => 1 } },
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach (('traffic', 'errors', 'cast', 'speed', 'volume')) {
|
||||||
|
$self->{'no_' . $_} = defined($options{'no_' . $_}) && $options{'no_' . $_} =~ /^[01]$/ ? $options{'no_' . $_} : 0;
|
||||||
|
$self->{'no_set_' . $_} = defined($options{'no_set_' . $_}) && $options{'no_set_' . $_} =~ /^[01]$/ ? $options{'no_set_' . $_} : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$self->{maps_counters} = { int => [], global => [] } if (!defined($self->{maps_counters}));
|
||||||
|
$self->set_counters_global();
|
||||||
|
$self->set_counters_status();
|
||||||
|
$self->set_counters_traffic();
|
||||||
|
$self->set_counters_errors();
|
||||||
|
$self->set_counters_cast();
|
||||||
|
$self->set_counters_speed();
|
||||||
|
$self->set_counters_volume();
|
||||||
|
}
|
||||||
|
|
||||||
|
sub prefix_interface_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return "Interface '" . $options{instance_value}->{display} . "'$options{instance_value}->{extra_display} "
|
||||||
|
}
|
||||||
|
|
||||||
|
sub skip_global {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return (defined($self->{option_results}->{add_global}) ? 0 : 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub skip_interface {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return ($self->{checking} =~ /cast|errors|traffic|status|volume/ ? 0 : 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub skip_counters {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return (defined($self->{option_results}->{$options{filter}})) ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub set_key_values_status {
|
sub set_key_values_status {
|
||||||
|
@ -690,118 +765,88 @@ sub default_oid_display_name {
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my ($class, %options) = @_;
|
my ($class, %options) = @_;
|
||||||
my $self = $class->SUPER::new(package => defined($options{package}) ? $options{package} : __PACKAGE__, %options);
|
my $self = $class->SUPER::new(package => defined($options{package}) ? $options{package} : __PACKAGE__, %options, statefile => 1);
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$self->{no_oid_options} = defined($options{no_oid_options}) && $options{no_oid_options} =~ /^[01]$/ ? $options{no_oid_options} : 0;
|
$self->{no_oid_options} = defined($options{no_oid_options}) && $options{no_oid_options} =~ /^[01]$/ ? $options{no_oid_options} : 0;
|
||||||
$self->{no_interfaceid_options} = defined($options{no_interfaceid_options}) && $options{no_interfaceid_options} =~ /^[01]$/ ?
|
$self->{no_interfaceid_options} = defined($options{no_interfaceid_options}) && $options{no_interfaceid_options} =~ /^[01]$/ ?
|
||||||
$options{no_interfaceid_options} : 0;
|
$options{no_interfaceid_options} : 0;
|
||||||
foreach (('traffic', 'errors', 'cast', 'speed', 'volume')) {
|
|
||||||
$self->{'no_' . $_} = defined($options{'no_' . $_}) && $options{'no_' . $_} =~ /^[01]$/ ? $options{'no_' . $_} : 0;
|
|
||||||
$self->{'no_set_' . $_} = defined($options{'no_set_' . $_}) && $options{'no_set_' . $_} =~ /^[01]$/ ? $options{'no_set_' . $_} : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
$self->{version} = '1.0';
|
$self->{version} = '1.0';
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
"add-global" => { name => 'add_global' },
|
'add-global' => { name => 'add_global' },
|
||||||
"add-status" => { name => 'add_status' },
|
'add-status' => { name => 'add_status' },
|
||||||
"add-duplex-status" => { name => 'add_duplex_status' },
|
'add-duplex-status' => { name => 'add_duplex_status' },
|
||||||
"warning-status:s" => { name => 'warning_status', default => $self->default_warning_status() },
|
'warning-status:s' => { name => 'warning_status', default => $self->default_warning_status() },
|
||||||
"critical-status:s" => { name => 'critical_status', default => $self->default_critical_status() },
|
'critical-status:s' => { name => 'critical_status', default => $self->default_critical_status() },
|
||||||
"global-admin-up-rule:s" => { name => 'global_admin_up_rule', default => $self->default_global_admin_up_rule() },
|
'global-admin-up-rule:s' => { name => 'global_admin_up_rule', default => $self->default_global_admin_up_rule() },
|
||||||
"global-oper-up-rule:s" => { name => 'global_oper_up_rule', default => $self->default_global_oper_up_rule() },
|
'global-oper-up-rule:s' => { name => 'global_oper_up_rule', default => $self->default_global_oper_up_rule() },
|
||||||
"global-admin-down-rule:s" => { name => 'global_admin_down_rule', default => $self->default_global_admin_down_rule() },
|
'global-admin-down-rule:s' => { name => 'global_admin_down_rule', default => $self->default_global_admin_down_rule() },
|
||||||
"global-oper-down-rule:s" => { name => 'global_oper_down_rule', default => $self->default_global_oper_down_rule() },
|
'global-oper-down-rule:s' => { name => 'global_oper_down_rule', default => $self->default_global_oper_down_rule() },
|
||||||
"interface:s" => { name => 'interface' },
|
'interface:s' => { name => 'interface' },
|
||||||
"units-traffic:s" => { name => 'units_traffic', default => '%' },
|
'units-traffic:s' => { name => 'units_traffic', default => '%' },
|
||||||
"units-errors:s" => { name => 'units_errors', default => '%' },
|
'units-errors:s' => { name => 'units_errors', default => '%' },
|
||||||
"speed:s" => { name => 'speed' },
|
'speed:s' => { name => 'speed' },
|
||||||
"speed-in:s" => { name => 'speed_in' },
|
'speed-in:s' => { name => 'speed_in' },
|
||||||
"speed-out:s" => { name => 'speed_out' },
|
'speed-out:s' => { name => 'speed_out' },
|
||||||
"no-skipped-counters" => { name => 'no_skipped_counters' },
|
'no-skipped-counters' => { name => 'no_skipped_counters' },
|
||||||
"display-transform-src:s" => { name => 'display_transform_src' },
|
'display-transform-src:s' => { name => 'display_transform_src' },
|
||||||
"display-transform-dst:s" => { name => 'display_transform_dst' },
|
'display-transform-dst:s' => { name => 'display_transform_dst' },
|
||||||
"show-cache" => { name => 'show_cache' },
|
'show-cache' => { name => 'show_cache' },
|
||||||
"reload-cache-time:s" => { name => 'reload_cache_time', default => 180 },
|
'reload-cache-time:s' => { name => 'reload_cache_time', default => 180 },
|
||||||
"nagvis-perfdata" => { name => 'nagvis_perfdata' },
|
'nagvis-perfdata' => { name => 'nagvis_perfdata' },
|
||||||
"force-counters32" => { name => 'force_counters32' },
|
'force-counters32' => { name => 'force_counters32' },
|
||||||
});
|
});
|
||||||
if ($self->{no_traffic} == 0) {
|
if ($self->{no_traffic} == 0) {
|
||||||
$options{options}->add_options(arguments => { "add-traffic" => { name => 'add_traffic' } });
|
$options{options}->add_options(arguments => { 'add-traffic' => { name => 'add_traffic' } });
|
||||||
}
|
}
|
||||||
if ($self->{no_errors} == 0) {
|
if ($self->{no_errors} == 0) {
|
||||||
$options{options}->add_options(arguments => { "add-errors" => { name => 'add_errors' } });
|
$options{options}->add_options(arguments => { 'add-errors' => { name => 'add_errors' } });
|
||||||
}
|
}
|
||||||
if ($self->{no_cast} == 0) {
|
if ($self->{no_cast} == 0) {
|
||||||
$options{options}->add_options(arguments => { "add-cast" => { name => 'add_cast' }, });
|
$options{options}->add_options(arguments => { 'add-cast' => { name => 'add_cast' }, });
|
||||||
}
|
}
|
||||||
if ($self->{no_speed} == 0) {
|
if ($self->{no_speed} == 0) {
|
||||||
$options{options}->add_options(arguments => { "add-speed" => { name => 'add_speed' }, });
|
$options{options}->add_options(arguments => { 'add-speed' => { name => 'add_speed' }, });
|
||||||
}
|
}
|
||||||
if ($self->{no_volume} == 0) {
|
if ($self->{no_volume} == 0) {
|
||||||
$options{options}->add_options(arguments => { "add-volume" => { name => 'add_volume' }, });
|
$options{options}->add_options(arguments => { 'add-volume' => { name => 'add_volume' }, });
|
||||||
}
|
}
|
||||||
if ($self->{no_oid_options} == 0) {
|
if ($self->{no_oid_options} == 0) {
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
"oid-filter:s" => { name => 'oid_filter', default => $self->default_oid_filter_name() },
|
'oid-filter:s' => { name => 'oid_filter', default => $self->default_oid_filter_name() },
|
||||||
"oid-display:s" => { name => 'oid_display', default => $self->default_oid_display_name() },
|
'oid-display:s' => { name => 'oid_display', default => $self->default_oid_display_name() },
|
||||||
"oid-extra-display:s" => { name => 'oid_extra_display' },
|
'oid-extra-display:s' => { name => 'oid_extra_display' },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if ($self->{no_interfaceid_options} == 0) {
|
if ($self->{no_interfaceid_options} == 0) {
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
"name" => { name => 'use_name' },
|
'name' => { name => 'use_name' },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{statefile_value} = centreon::plugins::statefile->new(%options);
|
|
||||||
$self->{statefile_cache} = centreon::plugins::statefile->new(%options);
|
$self->{statefile_cache} = centreon::plugins::statefile->new(%options);
|
||||||
$self->set_counters();
|
|
||||||
|
|
||||||
foreach my $key (('int', 'global')) {
|
|
||||||
foreach (keys %{$self->{maps_counters}->{$key}}) {
|
|
||||||
my ($id, $name) = split /_/;
|
|
||||||
if (!defined($self->{maps_counters}->{$key}->{$_}->{threshold}) || $self->{maps_counters}->{$key}->{$_}->{threshold} != 0) {
|
|
||||||
$options{options}->add_options(arguments => {
|
|
||||||
'warning-' . $name . ':s' => { name => 'warning-' . $name },
|
|
||||||
'critical-' . $name . ':s' => { name => 'critical-' . $name },
|
|
||||||
});
|
|
||||||
}
|
|
||||||
$self->{maps_counters}->{$key}->{$_}->{obj} = centreon::plugins::values->new(statefile => $self->{statefile_value},
|
|
||||||
output => $self->{output}, perfdata => $self->{perfdata},
|
|
||||||
label => $name);
|
|
||||||
$self->{maps_counters}->{$key}->{$_}->{obj}->set(%{$self->{maps_counters}->{$key}->{$_}->{set}});
|
|
||||||
$self->{maps_counters}->{$key}->{$_}->{obj}->{instance_mode} = $self;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub check_options {
|
sub check_options {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
$self->SUPER::init(%options);
|
$self->SUPER::check_options(%options);
|
||||||
|
|
||||||
foreach my $key (('int', 'global')) {
|
|
||||||
foreach (keys %{$self->{maps_counters}->{$key}}) {
|
|
||||||
$self->{maps_counters}->{$key}->{$_}->{obj}->init(option_results => $self->{option_results});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$self->set_oids_label();
|
$self->set_oids_label();
|
||||||
$self->check_oids_label();
|
$self->check_oids_label();
|
||||||
|
|
||||||
$self->{statefile_cache}->check_options(%options);
|
$self->{statefile_cache}->check_options(%options);
|
||||||
$self->{statefile_value}->check_options(%options);
|
|
||||||
|
|
||||||
if (defined($self->{option_results}->{add_traffic}) &&
|
if (defined($self->{option_results}->{add_traffic}) &&
|
||||||
(!defined($self->{option_results}->{units_traffic}) || $self->{option_results}->{units_traffic} !~ /^(%|b\/s)$/)) {
|
(!defined($self->{option_results}->{units_traffic}) || $self->{option_results}->{units_traffic} !~ /^(%|b\/s)$/)) {
|
||||||
$self->{output}->add_option_msg(short_msg => "Wrong option --units-traffic.");
|
$self->{output}->add_option_msg(short_msg => 'Wrong option --units-traffic.');
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
if (defined($self->{option_results}->{add_errors}) &&
|
if (defined($self->{option_results}->{add_errors}) &&
|
||||||
(!defined($self->{option_results}->{units_errors}) || $self->{option_results}->{units_errors} !~ /^(%|absolute|b\/s)$/)) {
|
(!defined($self->{option_results}->{units_errors}) || $self->{option_results}->{units_errors} !~ /^(%|absolute|b\/s)$/)) {
|
||||||
$self->{output}->add_option_msg(short_msg => "Wrong option --units-errors.");
|
$self->{output}->add_option_msg(short_msg => 'Wrong option --units-errors.');
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -811,7 +856,7 @@ sub check_options {
|
||||||
(!defined($self->{option_results}->{speed_out}) || $self->{option_results}->{speed_out} eq ''))) {
|
(!defined($self->{option_results}->{speed_out}) || $self->{option_results}->{speed_out} eq ''))) {
|
||||||
$self->{get_speed} = 1;
|
$self->{get_speed} = 1;
|
||||||
} elsif (defined($self->{option_results}->{add_speed})) {
|
} elsif (defined($self->{option_results}->{add_speed})) {
|
||||||
$self->{output}->add_option_msg(short_msg => "Cannot use option --add-speed with --speed, --speed-in or --speed-out options.");
|
$self->{output}->add_option_msg(short_msg => 'Cannot use option --add-speed with --speed, --speed-in or --speed-out options.');
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -828,139 +873,7 @@ sub check_options {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->change_macros();
|
$self->change_macros(macros => ['warning_status', 'critical_status']);
|
||||||
}
|
|
||||||
|
|
||||||
sub run_global {
|
|
||||||
my ($self, %options) = @_;
|
|
||||||
|
|
||||||
my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', '');
|
|
||||||
my @exits;
|
|
||||||
foreach (sort keys %{$self->{maps_counters}->{global}}) {
|
|
||||||
my $obj = $self->{maps_counters}->{global}->{$_}->{obj};
|
|
||||||
|
|
||||||
$obj->set(instance => 'global');
|
|
||||||
|
|
||||||
my ($value_check) = $obj->execute(values => $self->{global});
|
|
||||||
|
|
||||||
if ($value_check != 0) {
|
|
||||||
$long_msg .= $long_msg_append . $obj->output_error();
|
|
||||||
$long_msg_append = ', ';
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
my $exit2 = $obj->threshold_check();
|
|
||||||
push @exits, $exit2;
|
|
||||||
|
|
||||||
my $output = $obj->output();
|
|
||||||
$long_msg .= $long_msg_append . $output;
|
|
||||||
$long_msg_append = ', ';
|
|
||||||
|
|
||||||
if (!$self->{output}->is_status(litteral => 1, value => $exit2, compare => 'ok')) {
|
|
||||||
$short_msg .= $short_msg_append . $output;
|
|
||||||
$short_msg_append = ', ';
|
|
||||||
}
|
|
||||||
|
|
||||||
$obj->perfdata();
|
|
||||||
}
|
|
||||||
|
|
||||||
my $exit = $self->{output}->get_most_critical(status => [ @exits ]);
|
|
||||||
if (!$self->{output}->is_status(litteral => 1, value => $exit, compare => 'ok')) {
|
|
||||||
$self->{output}->output_add(severity => $exit,
|
|
||||||
short_msg => "$short_msg"
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
$self->{output}->output_add(short_msg => "$long_msg");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sub run {
|
|
||||||
my ($self, %options) = @_;
|
|
||||||
$self->{snmp} = $options{snmp};
|
|
||||||
$self->{hostname} = $self->{snmp}->get_hostname();
|
|
||||||
$self->{snmp_port} = $self->{snmp}->get_port();
|
|
||||||
|
|
||||||
$self->get_informations();
|
|
||||||
|
|
||||||
my $multiple = 1;
|
|
||||||
if (scalar(keys %{$self->{interface_selected}}) == 1) {
|
|
||||||
$multiple = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($multiple == 1 && defined($self->{option_results}->{add_global})) {
|
|
||||||
$self->run_global();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($multiple == 1 && $self->{checking} =~ /cast|errors|traffic|status|volume/) {
|
|
||||||
$self->{output}->output_add(severity => 'OK',
|
|
||||||
short_msg => 'All interfaces are ok');
|
|
||||||
}
|
|
||||||
|
|
||||||
$self->{new_datas} = {};
|
|
||||||
$self->{statefile_value}->read(statefile => "snmpstandard_" . $self->{hostname} . '_' . $self->{snmp_port} . '_' . $self->{mode} . '_' .
|
|
||||||
(defined($self->{option_results}->{interface}) ? md5_hex($self->{option_results}->{interface}) : md5_hex('all')) . '_' .
|
|
||||||
md5_hex($self->{checking}));
|
|
||||||
$self->{new_datas}->{last_timestamp} = time();
|
|
||||||
|
|
||||||
foreach my $id (sort keys %{$self->{interface_selected}}) {
|
|
||||||
next if ($self->{checking} !~ /cast|errors|traffic|status|volume/);
|
|
||||||
|
|
||||||
my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', '');
|
|
||||||
my @exits = ();
|
|
||||||
foreach (sort keys %{$self->{maps_counters}->{int}}) {
|
|
||||||
my $obj = $self->{maps_counters}->{int}->{$_}->{obj};
|
|
||||||
next if (!defined($self->{option_results}->{$self->{maps_counters}->{int}->{$_}->{filter}}));
|
|
||||||
$obj->set(instance => $id);
|
|
||||||
|
|
||||||
my ($value_check) = $obj->execute(values => $self->{interface_selected}->{$id},
|
|
||||||
new_datas => $self->{new_datas});
|
|
||||||
next if ($value_check == -10); # not running
|
|
||||||
if ($value_check != 0) {
|
|
||||||
$long_msg .= $long_msg_append . $obj->output_error();
|
|
||||||
$long_msg_append = ', ';
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
my $exit2 = $obj->threshold_check();
|
|
||||||
push @exits, $exit2;
|
|
||||||
|
|
||||||
my $output = $obj->output();
|
|
||||||
$long_msg .= $long_msg_append . $output;
|
|
||||||
$long_msg_append = ', ';
|
|
||||||
|
|
||||||
if (!$self->{output}->is_status(litteral => 1, value => $exit2, compare => 'ok')) {
|
|
||||||
$short_msg .= $short_msg_append . $output;
|
|
||||||
$short_msg_append = ', ';
|
|
||||||
}
|
|
||||||
|
|
||||||
$obj->perfdata(level => 1, extra_instance => $multiple);
|
|
||||||
}
|
|
||||||
|
|
||||||
$self->{output}->output_add(long_msg => "Interface '" . $self->{interface_selected}->{$id}->{display} . "'$self->{interface_selected}->{$id}->{extra_display} $long_msg");
|
|
||||||
my $exit = $self->{output}->get_most_critical(status => [ @exits ]);
|
|
||||||
if (!$self->{output}->is_status(litteral => 1, value => $exit, compare => 'ok')) {
|
|
||||||
$self->{output}->output_add(severity => $exit,
|
|
||||||
short_msg => "Interface '" . $self->{interface_selected}->{$id}->{display} . "'$self->{interface_selected}->{$id}->{extra_display} $short_msg"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($multiple == 0) {
|
|
||||||
$self->{output}->output_add(short_msg => "Interface '" . $self->{interface_selected}->{$id}->{display} . "'$self->{interface_selected}->{$id}->{extra_display} $long_msg");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$self->{statefile_value}->write(data => $self->{new_datas});
|
|
||||||
$self->{output}->display();
|
|
||||||
$self->{output}->exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
sub change_macros {
|
|
||||||
my ($self, %options) = @_;
|
|
||||||
|
|
||||||
foreach (('warning_status', 'critical_status')) {
|
|
||||||
if (defined($self->{option_results}->{$_})) {
|
|
||||||
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$self->{check_status} = $self->default_check_status();
|
$self->{check_status} = $self->default_check_status();
|
||||||
$self->{check_status} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
|
$self->{check_status} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
|
||||||
}
|
}
|
||||||
|
@ -1067,9 +980,9 @@ sub reload_cache {
|
||||||
sub add_selected_interface {
|
sub add_selected_interface {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{interface_selected}->{$options{id}} = { display => $self->get_display_value(id => $options{id}), extra_display => '' };
|
$self->{int}->{$options{id}} = { display => $self->get_display_value(id => $options{id}), extra_display => '' };
|
||||||
if (defined($self->{option_results}->{oid_extra_display})) {
|
if (defined($self->{option_results}->{oid_extra_display})) {
|
||||||
$self->{interface_selected}->{$options{id}}->{extra_display} = ' [ ' . $self->{statefile_cache}->get(name => $self->{option_results}->{oid_extra_display} . "_" . $options{id}) . ' ]';
|
$self->{int}->{$options{id}}->{extra_display} = ' [ ' . $self->{statefile_cache}->get(name => $self->{option_results}->{oid_extra_display} . "_" . $options{id}) . ' ]';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1077,13 +990,13 @@ sub get_selection {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
# init cache file
|
# init cache file
|
||||||
my $has_cache_file = $self->{statefile_cache}->read(statefile => 'cache_snmpstandard_' . $self->{hostname} . '_' . $self->{snmp_port} . '_' . $self->{mode});
|
my $has_cache_file = $self->{statefile_cache}->read(statefile => 'cache_snmpstandard_' . $self->{snmp}->get_hostname() . '_' . $self->{snmp}->get_port() . '_' . $self->{mode});
|
||||||
if (defined($self->{option_results}->{show_cache})) {
|
if (defined($self->{option_results}->{show_cache})) {
|
||||||
$self->{output}->add_option_msg(long_msg => $self->{statefile_cache}->get_string_content());
|
$self->{output}->add_option_msg(long_msg => $self->{statefile_cache}->get_string_content());
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{interface_selected} = {};
|
$self->{int} = {};
|
||||||
my $timestamp_cache = $self->{statefile_cache}->get(name => 'last_timestamp');
|
my $timestamp_cache = $self->{statefile_cache}->get(name => 'last_timestamp');
|
||||||
|
|
||||||
if ($has_cache_file == 0 || $self->check_oids_options_change() ||
|
if ($has_cache_file == 0 || $self->check_oids_options_change() ||
|
||||||
|
@ -1114,7 +1027,7 @@ sub get_selection {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scalar(keys %{$self->{interface_selected}}) <= 0) {
|
if (scalar(keys %{$self->{int}}) <= 0) {
|
||||||
$self->{output}->add_option_msg(short_msg => "No entry found (maybe you should reload cache file)");
|
$self->{output}->add_option_msg(short_msg => "No entry found (maybe you should reload cache file)");
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
|
@ -1190,14 +1103,15 @@ sub load_volume {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub get_informations {
|
sub manage_selection {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
$self->{snmp} = $options{snmp};
|
||||||
|
|
||||||
my $custom_load_method = $self->can('custom_load');
|
my $custom_load_method = $self->can('custom_load');
|
||||||
my $custom_add_result_method = $self->can('custom_add_result');
|
my $custom_add_result_method = $self->can('custom_add_result');
|
||||||
|
|
||||||
$self->get_selection();
|
$self->get_selection();
|
||||||
$self->{array_interface_selected} = [keys %{$self->{interface_selected}}];
|
$self->{array_interface_selected} = [keys %{$self->{int}}];
|
||||||
$self->load_status() if (defined($self->{option_results}->{add_status}) || defined($self->{option_results}->{add_global}));
|
$self->load_status() if (defined($self->{option_results}->{add_status}) || defined($self->{option_results}->{add_global}));
|
||||||
$self->load_errors() if (defined($self->{option_results}->{add_errors}));
|
$self->load_errors() if (defined($self->{option_results}->{add_errors}));
|
||||||
$self->load_traffic() if (defined($self->{option_results}->{add_traffic}));
|
$self->load_traffic() if (defined($self->{option_results}->{add_traffic}));
|
||||||
|
@ -1218,6 +1132,11 @@ sub get_informations {
|
||||||
$self->add_result_volume(instance => $_) if (defined($self->{option_results}->{add_volume}));
|
$self->add_result_volume(instance => $_) if (defined($self->{option_results}->{add_volume}));
|
||||||
$self->$custom_add_result_method(instance => $_) if ($custom_add_result_method);
|
$self->$custom_add_result_method(instance => $_) if ($custom_add_result_method);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$self->{cache_name} = 'snmpstandard_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' .
|
||||||
|
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' .
|
||||||
|
(defined($self->{option_results}->{interface}) ? md5_hex($self->{option_results}->{interface}) : md5_hex('all')) . '_' .
|
||||||
|
md5_hex($self->{checking});
|
||||||
}
|
}
|
||||||
|
|
||||||
sub add_result_global {
|
sub add_result_global {
|
||||||
|
@ -1252,46 +1171,46 @@ sub add_result_global {
|
||||||
sub add_result_status {
|
sub add_result_status {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{interface_selected}->{$options{instance}}->{opstatus} = defined($self->{results}->{$self->{oid_opstatus} . '.' . $options{instance}}) ? $self->{oid_opstatus_mapping}->{$self->{results}->{$self->{oid_opstatus} . '.' . $options{instance}}} : undef;
|
$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;
|
||||||
$self->{interface_selected}->{$options{instance}}->{admstatus} = defined($self->{results}->{$self->{oid_adminstatus} . '.' . $options{instance}}) ? $self->{oid_adminstatus_mapping}->{$self->{results}->{$self->{oid_adminstatus} . '.' . $options{instance}}} : undef;
|
$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;
|
||||||
$self->{interface_selected}->{$options{instance}}->{duplexstatus} = defined($self->{results}->{$self->{oid_duplexstatus} . '.' . $options{instance}}) ? $self->{oid_duplexstatus_mapping}->{$self->{results}->{$self->{oid_duplexstatus} . '.' . $options{instance}}} : 'n/a';
|
$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';
|
||||||
}
|
}
|
||||||
|
|
||||||
sub add_result_errors {
|
sub add_result_errors {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{interface_selected}->{$options{instance}}->{indiscard} = $self->{results}->{$self->{oid_ifInDiscards} . '.' . $options{instance}};
|
$self->{int}->{$options{instance}}->{indiscard} = $self->{results}->{$self->{oid_ifInDiscards} . '.' . $options{instance}};
|
||||||
$self->{interface_selected}->{$options{instance}}->{inerror} = $self->{results}->{$self->{oid_ifInErrors} . '.' . $options{instance}};
|
$self->{int}->{$options{instance}}->{inerror} = $self->{results}->{$self->{oid_ifInErrors} . '.' . $options{instance}};
|
||||||
$self->{interface_selected}->{$options{instance}}->{outdiscard} = $self->{results}->{$self->{oid_ifOutDiscards} . '.' . $options{instance}};
|
$self->{int}->{$options{instance}}->{outdiscard} = $self->{results}->{$self->{oid_ifOutDiscards} . '.' . $options{instance}};
|
||||||
$self->{interface_selected}->{$options{instance}}->{outerror} = $self->{results}->{$self->{oid_ifOutErrors} . '.' . $options{instance}};
|
$self->{int}->{$options{instance}}->{outerror} = $self->{results}->{$self->{oid_ifOutErrors} . '.' . $options{instance}};
|
||||||
}
|
}
|
||||||
|
|
||||||
sub add_result_traffic {
|
sub add_result_traffic {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{interface_selected}->{$options{instance}}->{mode_traffic} = 32;
|
$self->{int}->{$options{instance}}->{mode_traffic} = 32;
|
||||||
$self->{interface_selected}->{$options{instance}}->{in} = $self->{results}->{$self->{oid_in32} . '.' . $options{instance}};
|
$self->{int}->{$options{instance}}->{in} = $self->{results}->{$self->{oid_in32} . '.' . $options{instance}};
|
||||||
$self->{interface_selected}->{$options{instance}}->{out} = $self->{results}->{$self->{oid_out32} . '.' . $options{instance}};
|
$self->{int}->{$options{instance}}->{out} = $self->{results}->{$self->{oid_out32} . '.' . $options{instance}};
|
||||||
if (!$self->{snmp}->is_snmpv1() && !defined($self->{option_results}->{force_counters32})) {
|
if (!$self->{snmp}->is_snmpv1() && !defined($self->{option_results}->{force_counters32})) {
|
||||||
if (defined($self->{results}->{$self->{oid_in64} . '.' . $options{instance}}) && $self->{results}->{$self->{oid_in64} . '.' . $options{instance}} ne '' &&
|
if (defined($self->{results}->{$self->{oid_in64} . '.' . $options{instance}}) && $self->{results}->{$self->{oid_in64} . '.' . $options{instance}} ne '' &&
|
||||||
$self->{results}->{$self->{oid_in64} . '.' . $options{instance}} != 0) {
|
$self->{results}->{$self->{oid_in64} . '.' . $options{instance}} != 0) {
|
||||||
$self->{interface_selected}->{$options{instance}}->{mode_traffic} = 64;
|
$self->{int}->{$options{instance}}->{mode_traffic} = 64;
|
||||||
$self->{interface_selected}->{$options{instance}}->{in} = $self->{results}->{$self->{oid_in64} . '.' . $options{instance}};
|
$self->{int}->{$options{instance}}->{in} = $self->{results}->{$self->{oid_in64} . '.' . $options{instance}};
|
||||||
$self->{interface_selected}->{$options{instance}}->{out} = $self->{results}->{$self->{oid_out64} . '.' . $options{instance}};
|
$self->{int}->{$options{instance}}->{out} = $self->{results}->{$self->{oid_out64} . '.' . $options{instance}};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$self->{interface_selected}->{$options{instance}}->{in} *= 8 if (defined($self->{interface_selected}->{$options{instance}}->{in}));
|
$self->{int}->{$options{instance}}->{in} *= 8 if (defined($self->{int}->{$options{instance}}->{in}));
|
||||||
$self->{interface_selected}->{$options{instance}}->{out} *= 8 if (defined($self->{interface_selected}->{$options{instance}}->{out}));
|
$self->{int}->{$options{instance}}->{out} *= 8 if (defined($self->{int}->{$options{instance}}->{out}));
|
||||||
|
|
||||||
$self->{interface_selected}->{$options{instance}}->{speed_in} = 0;
|
$self->{int}->{$options{instance}}->{speed_in} = 0;
|
||||||
$self->{interface_selected}->{$options{instance}}->{speed_out} = 0;
|
$self->{int}->{$options{instance}}->{speed_out} = 0;
|
||||||
if ($self->{get_speed} == 0) {
|
if ($self->{get_speed} == 0) {
|
||||||
if (defined($self->{option_results}->{speed}) && $self->{option_results}->{speed} ne '') {
|
if (defined($self->{option_results}->{speed}) && $self->{option_results}->{speed} ne '') {
|
||||||
$self->{interface_selected}->{$options{instance}}->{speed_in} = $self->{option_results}->{speed} * 1000000;
|
$self->{int}->{$options{instance}}->{speed_in} = $self->{option_results}->{speed} * 1000000;
|
||||||
$self->{interface_selected}->{$options{instance}}->{speed_out} = $self->{option_results}->{speed} * 1000000;
|
$self->{int}->{$options{instance}}->{speed_out} = $self->{option_results}->{speed} * 1000000;
|
||||||
}
|
}
|
||||||
$self->{interface_selected}->{$options{instance}}->{speed_in} = $self->{option_results}->{speed_in} * 1000000 if (defined($self->{option_results}->{speed_in}) && $self->{option_results}->{speed_in} ne '');
|
$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 '');
|
||||||
$self->{interface_selected}->{$options{instance}}->{speed_out} = $self->{option_results}->{speed_out} * 1000000 if (defined($self->{option_results}->{speed_out}) && $self->{option_results}->{speed_out} ne '');
|
$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 '');
|
||||||
} else {
|
} else {
|
||||||
my $interface_speed = 0;
|
my $interface_speed = 0;
|
||||||
if (defined($self->{results}->{$self->{oid_speed64} . "." . $options{instance}}) && $self->{results}->{$self->{oid_speed64} . "." . $options{instance}} ne '') {
|
if (defined($self->{results}->{$self->{oid_speed64} . "." . $options{instance}}) && $self->{results}->{$self->{oid_speed64} . "." . $options{instance}} ne '') {
|
||||||
|
@ -1304,42 +1223,42 @@ sub add_result_traffic {
|
||||||
$interface_speed = $self->{results}->{$self->{oid_speed32} . "." . $options{instance}};
|
$interface_speed = $self->{results}->{$self->{oid_speed32} . "." . $options{instance}};
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{interface_selected}->{$options{instance}}->{speed_in} = $interface_speed;
|
$self->{int}->{$options{instance}}->{speed_in} = $interface_speed;
|
||||||
$self->{interface_selected}->{$options{instance}}->{speed_out} = $interface_speed;
|
$self->{int}->{$options{instance}}->{speed_out} = $interface_speed;
|
||||||
$self->{interface_selected}->{$options{instance}}->{speed_in} = $self->{option_results}->{speed_in} * 1000000 if (defined($self->{option_results}->{speed_in}) && $self->{option_results}->{speed_in} ne '');
|
$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 '');
|
||||||
$self->{interface_selected}->{$options{instance}}->{speed_out} = $self->{option_results}->{speed_out} * 1000000 if (defined($self->{option_results}->{speed_out}) && $self->{option_results}->{speed_out} ne '');
|
$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 '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub add_result_cast {
|
sub add_result_cast {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{interface_selected}->{$options{instance}}->{mode_cast} = 32;
|
$self->{int}->{$options{instance}}->{mode_cast} = 32;
|
||||||
$self->{interface_selected}->{$options{instance}}->{iucast} = $self->{results}->{$self->{oid_ifInUcastPkts} . '.' . $options{instance}};
|
$self->{int}->{$options{instance}}->{iucast} = $self->{results}->{$self->{oid_ifInUcastPkts} . '.' . $options{instance}};
|
||||||
$self->{interface_selected}->{$options{instance}}->{ibcast} = defined($self->{results}->{$self->{oid_ifInBroadcastPkts} . '.' . $options{instance}}) ? $self->{results}->{$self->{oid_ifInBroadcastPkts} . '.' . $options{instance}} : 0;
|
$self->{int}->{$options{instance}}->{ibcast} = defined($self->{results}->{$self->{oid_ifInBroadcastPkts} . '.' . $options{instance}}) ? $self->{results}->{$self->{oid_ifInBroadcastPkts} . '.' . $options{instance}} : 0;
|
||||||
$self->{interface_selected}->{$options{instance}}->{imcast} = defined($self->{results}->{$self->{oid_ifInMulticastPkts} . '.' . $options{instance}}) ? $self->{results}->{$self->{oid_ifInMulticastPkts} . '.' . $options{instance}} : 0;
|
$self->{int}->{$options{instance}}->{imcast} = defined($self->{results}->{$self->{oid_ifInMulticastPkts} . '.' . $options{instance}}) ? $self->{results}->{$self->{oid_ifInMulticastPkts} . '.' . $options{instance}} : 0;
|
||||||
$self->{interface_selected}->{$options{instance}}->{oucast} = $self->{results}->{$self->{oid_ifOutUcastPkts} . '.' . $options{instance}};
|
$self->{int}->{$options{instance}}->{oucast} = $self->{results}->{$self->{oid_ifOutUcastPkts} . '.' . $options{instance}};
|
||||||
$self->{interface_selected}->{$options{instance}}->{omcast} = defined($self->{results}->{$self->{oid_ifOutMulticastPkts} . '.' . $options{instance}}) ? $self->{results}->{$self->{oid_ifOutMulticastPkts} . '.' . $options{instance}} : 0;
|
$self->{int}->{$options{instance}}->{omcast} = defined($self->{results}->{$self->{oid_ifOutMulticastPkts} . '.' . $options{instance}}) ? $self->{results}->{$self->{oid_ifOutMulticastPkts} . '.' . $options{instance}} : 0;
|
||||||
$self->{interface_selected}->{$options{instance}}->{obcast} = defined($self->{results}->{$self->{oid_ifOutBroadcastPkts} . '.' . $options{instance}}) ? $self->{results}->{$self->{oid_ifOutBroadcastPkts} . '.' . $options{instance}} : 0;
|
$self->{int}->{$options{instance}}->{obcast} = defined($self->{results}->{$self->{oid_ifOutBroadcastPkts} . '.' . $options{instance}}) ? $self->{results}->{$self->{oid_ifOutBroadcastPkts} . '.' . $options{instance}} : 0;
|
||||||
if (!$self->{snmp}->is_snmpv1() && !defined($self->{option_results}->{force_counters32})) {
|
if (!$self->{snmp}->is_snmpv1() && !defined($self->{option_results}->{force_counters32})) {
|
||||||
my $iucast = $self->{results}->{$self->{oid_ifHCInUcastPkts} . '.' . $options{instance}};
|
my $iucast = $self->{results}->{$self->{oid_ifHCInUcastPkts} . '.' . $options{instance}};
|
||||||
if (defined($iucast) && $iucast =~ /[1-9]/) {
|
if (defined($iucast) && $iucast =~ /[1-9]/) {
|
||||||
$self->{interface_selected}->{$options{instance}}->{iucast} = $iucast;
|
$self->{int}->{$options{instance}}->{iucast} = $iucast;
|
||||||
$self->{interface_selected}->{$options{instance}}->{imcast} = defined($self->{results}->{$self->{oid_ifHCInMulticastPkts} . '.' . $options{instance}}) ? $self->{results}->{$self->{oid_ifHCInMulticastPkts} . '.' . $options{instance}} : 0;
|
$self->{int}->{$options{instance}}->{imcast} = defined($self->{results}->{$self->{oid_ifHCInMulticastPkts} . '.' . $options{instance}}) ? $self->{results}->{$self->{oid_ifHCInMulticastPkts} . '.' . $options{instance}} : 0;
|
||||||
$self->{interface_selected}->{$options{instance}}->{ibcast} = defined($self->{results}->{$self->{oid_ifHCInBroadcastPkts} . '.' . $options{instance}}) ? $self->{results}->{$self->{oid_ifHCInBroadcastPkts} . '.' . $options{instance}} : 0;
|
$self->{int}->{$options{instance}}->{ibcast} = defined($self->{results}->{$self->{oid_ifHCInBroadcastPkts} . '.' . $options{instance}}) ? $self->{results}->{$self->{oid_ifHCInBroadcastPkts} . '.' . $options{instance}} : 0;
|
||||||
$self->{interface_selected}->{$options{instance}}->{oucast} = $self->{results}->{$self->{oid_ifHCOutUcastPkts} . '.' . $options{instance}};
|
$self->{int}->{$options{instance}}->{oucast} = $self->{results}->{$self->{oid_ifHCOutUcastPkts} . '.' . $options{instance}};
|
||||||
$self->{interface_selected}->{$options{instance}}->{omcast} = defined($self->{results}->{$self->{oid_ifHCOutMulticastPkts} . '.' . $options{instance}}) ? $self->{results}->{$self->{oid_ifHCOutMulticastPkts} . '.' . $options{instance}} : 0;
|
$self->{int}->{$options{instance}}->{omcast} = defined($self->{results}->{$self->{oid_ifHCOutMulticastPkts} . '.' . $options{instance}}) ? $self->{results}->{$self->{oid_ifHCOutMulticastPkts} . '.' . $options{instance}} : 0;
|
||||||
$self->{interface_selected}->{$options{instance}}->{obcast} = defined($self->{results}->{$self->{oid_ifHCOutBroadcastPkts} . '.' . $options{instance}}) ? $self->{results}->{$self->{oid_ifHCOutBroadcastPkts} . '.' . $options{instance}} : 0;
|
$self->{int}->{$options{instance}}->{obcast} = defined($self->{results}->{$self->{oid_ifHCOutBroadcastPkts} . '.' . $options{instance}}) ? $self->{results}->{$self->{oid_ifHCOutBroadcastPkts} . '.' . $options{instance}} : 0;
|
||||||
$self->{interface_selected}->{$options{instance}}->{mode_cast} = 64;
|
$self->{int}->{$options{instance}}->{mode_cast} = 64;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (('iucast', 'imcast', 'ibcast', 'oucast', 'omcast', 'obcast')) {
|
foreach (('iucast', 'imcast', 'ibcast', 'oucast', 'omcast', 'obcast')) {
|
||||||
$self->{interface_selected}->{$options{instance}}->{$_} = 0 if (!defined($self->{interface_selected}->{$options{instance}}->{$_}));
|
$self->{int}->{$options{instance}}->{$_} = 0 if (!defined($self->{int}->{$options{instance}}->{$_}));
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{interface_selected}->{$options{instance}}->{total_in_packets} = $self->{interface_selected}->{$options{instance}}->{iucast} + $self->{interface_selected}->{$options{instance}}->{imcast} + $self->{interface_selected}->{$options{instance}}->{ibcast};
|
$self->{int}->{$options{instance}}->{total_in_packets} = $self->{int}->{$options{instance}}->{iucast} + $self->{int}->{$options{instance}}->{imcast} + $self->{int}->{$options{instance}}->{ibcast};
|
||||||
$self->{interface_selected}->{$options{instance}}->{total_out_packets} = $self->{interface_selected}->{$options{instance}}->{oucast} + $self->{interface_selected}->{$options{instance}}->{omcast} + $self->{interface_selected}->{$options{instance}}->{obcast};
|
$self->{int}->{$options{instance}}->{total_out_packets} = $self->{int}->{$options{instance}}->{oucast} + $self->{int}->{$options{instance}}->{omcast} + $self->{int}->{$options{instance}}->{obcast};
|
||||||
}
|
}
|
||||||
|
|
||||||
sub add_result_speed {
|
sub add_result_speed {
|
||||||
|
@ -1356,21 +1275,21 @@ sub add_result_speed {
|
||||||
$interface_speed = $self->{results}->{$self->{oid_speed32} . "." . $options{instance}};
|
$interface_speed = $self->{results}->{$self->{oid_speed32} . "." . $options{instance}};
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{interface_selected}->{$options{instance}}->{speed} = $interface_speed;
|
$self->{int}->{$options{instance}}->{speed} = $interface_speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub add_result_volume {
|
sub add_result_volume {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{interface_selected}->{$options{instance}}->{mode_traffic} = 32;
|
$self->{int}->{$options{instance}}->{mode_traffic} = 32;
|
||||||
$self->{interface_selected}->{$options{instance}}->{in_volume} = $self->{results}->{$self->{oid_in32} . '.' . $options{instance}};
|
$self->{int}->{$options{instance}}->{in_volume} = $self->{results}->{$self->{oid_in32} . '.' . $options{instance}};
|
||||||
$self->{interface_selected}->{$options{instance}}->{out_volume} = $self->{results}->{$self->{oid_out32} . '.' . $options{instance}};
|
$self->{int}->{$options{instance}}->{out_volume} = $self->{results}->{$self->{oid_out32} . '.' . $options{instance}};
|
||||||
if (!$self->{snmp}->is_snmpv1() && !defined($self->{option_results}->{force_counters32})) {
|
if (!$self->{snmp}->is_snmpv1() && !defined($self->{option_results}->{force_counters32})) {
|
||||||
if (defined($self->{results}->{$self->{oid_in64} . '.' . $options{instance}}) && $self->{results}->{$self->{oid_in64} . '.' . $options{instance}} ne '' &&
|
if (defined($self->{results}->{$self->{oid_in64} . '.' . $options{instance}}) && $self->{results}->{$self->{oid_in64} . '.' . $options{instance}} ne '' &&
|
||||||
$self->{results}->{$self->{oid_in64} . '.' . $options{instance}} != 0) {
|
$self->{results}->{$self->{oid_in64} . '.' . $options{instance}} != 0) {
|
||||||
$self->{interface_selected}->{$options{instance}}->{mode_traffic} = 64;
|
$self->{int}->{$options{instance}}->{mode_traffic} = 64;
|
||||||
$self->{interface_selected}->{$options{instance}}->{in_volume} = $self->{results}->{$self->{oid_in64} . '.' . $options{instance}};
|
$self->{int}->{$options{instance}}->{in_volume} = $self->{results}->{$self->{oid_in64} . '.' . $options{instance}};
|
||||||
$self->{interface_selected}->{$options{instance}}->{out_volume} = $self->{results}->{$self->{oid_out64} . '.' . $options{instance}};
|
$self->{int}->{$options{instance}}->{out_volume} = $self->{results}->{$self->{oid_out64} . '.' . $options{instance}};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue