parent
9cd2fbcf78
commit
245f59a33b
|
@ -27,6 +27,130 @@ use warnings;
|
|||
use Digest::MD5 qw(md5_hex);
|
||||
use Socket;
|
||||
|
||||
sub custom_traffic_perfdata {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
label => 'traffic_' . lc($self->{result_values}->{label}), unit => 'b/s',
|
||||
instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef,
|
||||
value => sprintf("%.2f", $self->{result_values}->{traffic_per_seconds}),
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}),
|
||||
min => 0
|
||||
);
|
||||
}
|
||||
|
||||
sub custom_traffic_threshold {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return $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' } ]);
|
||||
}
|
||||
|
||||
sub custom_traffic_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my ($traffic_value, $traffic_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{traffic_per_seconds}, network => 1);
|
||||
return sprintf(
|
||||
'traffic %s: %s/s',
|
||||
lc($self->{result_values}->{label}),
|
||||
$traffic_value . $traffic_unit
|
||||
);
|
||||
}
|
||||
|
||||
sub custom_traffic_calc {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
if (!defined($options{old_datas}->{$self->{instance} . '_display'})) {
|
||||
$self->{error_msg} = "Buffer creation";
|
||||
return -1;
|
||||
}
|
||||
|
||||
my $total_bytes = 0;
|
||||
foreach (keys %{$options{new_datas}}) {
|
||||
if (/$self->{instance}_cipSecTunHc$options{extra_options}->{label_ref}Octets_(\d+)/) {
|
||||
my $new_bytes = $options{new_datas}->{$_};
|
||||
next if (!defined($options{old_datas}->{$_}));
|
||||
my $old_bytes = $options{old_datas}->{$_};
|
||||
|
||||
my $diff_bytes = $new_bytes - $old_bytes;
|
||||
$total_bytes += (($diff_bytes < 0) ? $new_bytes : $diff_bytes);
|
||||
} elsif (/$self->{instance}_cipSecTun$options{extra_options}->{label_ref}Octets_(\d+)/) {
|
||||
my $new_bytes = $options{new_datas}->{$_};
|
||||
my $new_wraps = $options{new_datas}->{$self->{instance} . '_cipSecTun' . $options{extra_options}->{label_ref} . 'OctWraps_' . $1};
|
||||
next if (!defined($options{old_datas}->{$_}));
|
||||
my ($old_bytes, $old_wraps) = ($options{old_datas}->{$_}, $options{old_datas}->{$self->{instance} . '_cipSecTun' . $options{extra_options}->{label_ref} . 'OctWraps_' . $1});
|
||||
|
||||
my $diff_bytes = $new_bytes - $old_bytes + (($new_wraps - $old_wraps) * (2**32));
|
||||
$total_bytes += (($diff_bytes < 0) ? $new_bytes : $diff_bytes);
|
||||
}
|
||||
}
|
||||
|
||||
$self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'};
|
||||
$self->{result_values}->{traffic_per_seconds} = ($total_bytes * 8) / $options{delta_time};
|
||||
$self->{result_values}->{label} = $options{extra_options}->{label_ref};
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub custom_drop_perfdata {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
label => 'drop_' . lc($self->{result_values}->{label}), unit => 'pkts/s',
|
||||
instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef,
|
||||
value => sprintf("%.2f", $self->{result_values}->{pkts_per_seconds}),
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}),
|
||||
min => 0
|
||||
);
|
||||
}
|
||||
|
||||
sub custom_drop_threshold {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return $self->{perfdata}->threshold_check(value => $self->{result_values}->{pkts_per_seconds}, threshold => [ { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' } ]);
|
||||
}
|
||||
|
||||
sub custom_drop_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return sprintf(
|
||||
'drop %s: %s pkts/s',
|
||||
lc($self->{result_values}->{label}), $self->{result_values}->{pkts_per_seconds}
|
||||
);
|
||||
}
|
||||
|
||||
sub custom_drop_calc {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
if (!defined($options{old_datas}->{$self->{instance} . '_display'})) {
|
||||
$self->{error_msg} = "Buffer creation";
|
||||
return -1;
|
||||
}
|
||||
|
||||
my $total_pkts = 0;
|
||||
foreach (keys %{$options{new_datas}}) {
|
||||
if (/$self->{instance}_cipSecTun$options{extra_options}->{label_ref}DropPkts_(\d+)/) {
|
||||
next if (!defined($options{old_datas}->{$_}));
|
||||
|
||||
my $diff_pkts = $options{new_datas}->{$_} - $options{old_datas}->{$_};
|
||||
$total_pkts += (($diff_pkts < 0) ? $options{new_datas}->{$_} : $diff_pkts);
|
||||
}
|
||||
}
|
||||
|
||||
$self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'};
|
||||
$self->{result_values}->{pkts_per_seconds} = $total_pkts / $options{delta_time};
|
||||
$self->{result_values}->{label} = $options{extra_options}->{label_ref};
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub prefix_tunnel_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Tunnel '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
@ -38,7 +162,7 @@ sub set_counters {
|
|||
$self->{maps_counters}->{global} = [
|
||||
{ label => 'tunnels-total', set => {
|
||||
key_values => [ { name => 'total' } ],
|
||||
output_template => 'Total Tunnels : %s',
|
||||
output_template => 'Total tunnels: %s',
|
||||
perfdatas => [
|
||||
{ label => 'total_tunnels', template => '%s', min => 0 }
|
||||
]
|
||||
|
@ -85,7 +209,7 @@ sub set_counters {
|
|||
},
|
||||
{ label => 'sa-total', set => {
|
||||
key_values => [ { name => 'sa' }, { name => 'display' } ],
|
||||
output_template => 'Total SA : %s',
|
||||
output_template => 'total sa: %s',
|
||||
perfdatas => [
|
||||
{ label => 'total_sa', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' }
|
||||
]
|
||||
|
@ -94,138 +218,6 @@ sub set_counters {
|
|||
];
|
||||
}
|
||||
|
||||
sub custom_traffic_perfdata {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $warning = $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel});
|
||||
my $critical = $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel});
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
label => 'traffic_' . lc($self->{result_values}->{label}), unit => 'b/s',
|
||||
instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef,
|
||||
value => sprintf("%.2f", $self->{result_values}->{traffic_per_seconds}),
|
||||
warning => $warning,
|
||||
critical => $critical,
|
||||
min => 0
|
||||
);
|
||||
}
|
||||
|
||||
sub custom_traffic_threshold {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return $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' } ]);
|
||||
}
|
||||
|
||||
sub custom_traffic_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my ($traffic_value, $traffic_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{traffic_per_seconds}, network => 1);
|
||||
return sprintf(
|
||||
'Traffic %s : %s/s',
|
||||
$self->{result_values}->{label},
|
||||
$traffic_value . $traffic_unit
|
||||
);
|
||||
}
|
||||
|
||||
sub custom_traffic_calc {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
if (!defined($options{old_datas}->{$self->{instance} . '_' . $options{extra_options}->{label_ref}})) {
|
||||
$self->{error_msg} = "Buffer creation";
|
||||
return -1;
|
||||
}
|
||||
|
||||
my $total_bytes = 0;
|
||||
foreach (keys %{$options{new_datas}}) {
|
||||
if (/$self->{instance}_cipSecTunHc$options{extra_options}->{label_ref}Octets_(\d+)/) {
|
||||
my $new_bytes = $options{new_datas}->{$_};
|
||||
next if (!defined($options{old_datas}->{$_}));
|
||||
my $old_bytes = $options{old_datas}->{$_};
|
||||
|
||||
$total_bytes += $new_bytes - $old_bytes;
|
||||
$total_bytes += $new_bytes if ($total_bytes <= 0);
|
||||
} elsif (/$self->{instance}_cipSecTun$options{extra_options}->{label_ref}Octets_(\d+)/) {
|
||||
my $new_bytes = $options{new_datas}->{$_};
|
||||
my $new_wraps = $options{new_datas}->{$self->{instance} . '_cipSecTun' . $options{extra_options}->{label_ref} . 'OctWraps_' . $1};
|
||||
next if (!defined($options{old_datas}->{$_}));
|
||||
my ($old_bytes, $old_wraps) = ($options{old_datas}->{$_}, $options{old_datas}->{$self->{instance} . '_cipSecTun' . $options{extra_options}->{label_ref} . 'OctWraps_' . $1});
|
||||
|
||||
$total_bytes += $new_bytes - $old_bytes + (($new_wraps - $old_wraps) * (2**32));
|
||||
$total_bytes += $new_bytes if ($total_bytes <= 0);
|
||||
}
|
||||
}
|
||||
|
||||
$self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'};
|
||||
$self->{result_values}->{traffic_per_seconds} = ($total_bytes * 8) / $options{delta_time};
|
||||
$self->{result_values}->{label} = $options{extra_options}->{label_ref};
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub custom_drop_perfdata {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $warning = $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel});
|
||||
my $critical = $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel});
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
label => 'drop_' . lc($self->{result_values}->{label}), unit => 'pkts/s',
|
||||
instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef,
|
||||
value => sprintf("%.2f", $self->{result_values}->{pkts_per_seconds}),
|
||||
warning => $warning,
|
||||
critical => $critical,
|
||||
min => 0
|
||||
);
|
||||
}
|
||||
|
||||
sub custom_drop_threshold {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return $self->{perfdata}->threshold_check(value => $self->{result_values}->{pkts_per_seconds}, threshold => [ { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' } ]);
|
||||
}
|
||||
|
||||
sub custom_drop_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return sprintf(
|
||||
'Drop %s : %s pkts/s',
|
||||
$self->{result_values}->{label}, $self->{result_values}->{pkts_per_seconds}
|
||||
);
|
||||
}
|
||||
|
||||
sub custom_drop_calc {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
if (!defined($options{old_datas}->{$self->{instance} . '_' . $options{extra_options}->{label_ref}})) {
|
||||
$self->{error_msg} = "Buffer creation";
|
||||
return -1;
|
||||
}
|
||||
|
||||
my $total_pkts = 0;
|
||||
foreach (keys %{$options{new_datas}}) {
|
||||
if (/$self->{instance}_cipSecTun$options{extra_options}->{label_ref}DropPkts_(\d+)/) {
|
||||
my $new_pkts = $options{new_datas}->{$_};
|
||||
next if (!defined($options{old_datas}->{$_}));
|
||||
my $old_pkts = $options{old_datas}->{$_};
|
||||
|
||||
$old_pkts = 0 if ($old_pkts > $new_pkts);
|
||||
$total_pkts += $new_pkts - $old_pkts;
|
||||
}
|
||||
}
|
||||
|
||||
$self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'};
|
||||
$self->{result_values}->{pkts_per_seconds} = $total_pkts / $options{delta_time};
|
||||
$self->{result_values}->{label} = $options{extra_options}->{label_ref};
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub prefix_tunnel_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Tunnel '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
|
||||
|
@ -252,13 +244,13 @@ my $mapping2 = {
|
|||
cipSecTunOutOctets => { oid => '.1.3.6.1.4.1.9.9.171.1.3.2.1.39' },
|
||||
cipSecTunHcOutOctets => { oid => '.1.3.6.1.4.1.9.9.171.1.3.2.1.40' }, # seems buggy
|
||||
cipSecTunOutOctWraps => { oid => '.1.3.6.1.4.1.9.9.171.1.3.2.1.41' },
|
||||
cipSecTunOutDropPkts => { oid => '.1.3.6.1.4.1.9.9.171.1.3.2.1.46' },
|
||||
cipSecTunOutDropPkts => { oid => '.1.3.6.1.4.1.9.9.171.1.3.2.1.46' }
|
||||
};
|
||||
my $mapping3 = {
|
||||
cipSecEndPtLocalAddr1 => { oid => '.1.3.6.1.4.1.9.9.171.1.3.3.1.4' },
|
||||
cipSecEndPtLocalAddr2 => { oid => '.1.3.6.1.4.1.9.9.171.1.3.3.1.5' },
|
||||
cipSecEndPtRemoteAddr1 => { oid => '.1.3.6.1.4.1.9.9.171.1.3.3.1.10' },
|
||||
cipSecEndPtRemoteAddr2 => { oid => '.1.3.6.1.4.1.9.9.171.1.3.3.1.11' },
|
||||
cipSecEndPtRemoteAddr2 => { oid => '.1.3.6.1.4.1.9.9.171.1.3.3.1.11' }
|
||||
};
|
||||
|
||||
my $oid_cikeTunnelEntry = '.1.3.6.1.4.1.9.9.171.1.2.3.1';
|
||||
|
|
Loading…
Reference in New Issue