update juniper ggsn mode with class counter
This commit is contained in:
parent
af8afec1b9
commit
e527cda33d
|
@ -20,168 +20,12 @@
|
||||||
|
|
||||||
package network::juniper::ggsn::mode::apnstats;
|
package network::juniper::ggsn::mode::apnstats;
|
||||||
|
|
||||||
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 Digest::MD5 qw(md5_hex);
|
use Digest::MD5 qw(md5_hex);
|
||||||
|
|
||||||
my $maps_counters = {
|
|
||||||
'000_traffic-in' => { class => 'centreon::plugins::values', obj => undef,
|
|
||||||
set => {
|
|
||||||
key_values => [
|
|
||||||
{ name => 'ggsnApnUplinkBytes', diff => 1 }, { name => 'ggsnApnName' },
|
|
||||||
],
|
|
||||||
per_second => 1, output_change_bytes => 2,
|
|
||||||
output_template => 'Traffic In : %s %s/s',
|
|
||||||
perfdatas => [
|
|
||||||
{ label => 'traffic_in', value => 'ggsnApnUplinkBytes_per_second', template => '%s',
|
|
||||||
unit => 'b/s', min => 0, label_extra_instance => 1, cast_int => 1, instance_use => 'ggsnApnName_absolute' },
|
|
||||||
],
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'001_traffic-out' => { class => 'centreon::plugins::values', obj => undef,
|
|
||||||
set => {
|
|
||||||
key_values => [
|
|
||||||
{ name => 'ggsnApnDownlinkBytes', diff => 1 }, { name => 'ggsnApnName' },
|
|
||||||
],
|
|
||||||
per_second => 1, output_change_bytes => 2,
|
|
||||||
output_template => 'Traffic Out : %s %s/s',
|
|
||||||
perfdatas => [
|
|
||||||
{ label => 'traffic_out', value => 'ggsnApnDownlinkBytes_per_second', template => '%s',
|
|
||||||
unit => 'b/s', min => 0, label_extra_instance => 1, cast_int => 1, instance_use => 'ggsnApnName_absolute' },
|
|
||||||
],
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'004_drop-in' => { class => 'centreon::plugins::values', obj => undef,
|
|
||||||
set => {
|
|
||||||
key_values => [
|
|
||||||
{ name => 'ggsnApnUplinkDrops', diff => 1 }, { name => 'ggsnApnUplinkPackets', diff => 1 }, { name => 'ggsnApnName' },
|
|
||||||
],
|
|
||||||
output_template => 'Drop In Packets : %.2f %%', threshold_use => 'drop_prct', output_use => 'drop_prct',
|
|
||||||
closure_custom_calc => \&custom_drop_in_calc,
|
|
||||||
perfdatas => [
|
|
||||||
{ label => 'drop_in', value => 'ggsnApnUplinkDrops_absolute', template => '%s',
|
|
||||||
min => 0, max => 'ggsnApnUplinkPackets_absolute', label_extra_instance => 1, instance_use => 'ggsnApnName' },
|
|
||||||
],
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'005_drop-out' => { class => 'centreon::plugins::values', obj => undef,
|
|
||||||
set => {
|
|
||||||
key_values => [
|
|
||||||
{ name => 'ggsnApnDownlinkDrops', diff => 1 }, { name => 'ggsnApnDownlinkPackets', diff => 1 }, { name => 'ggsnApnName' },
|
|
||||||
],
|
|
||||||
output_template => 'Drop Out Packets : %.2f %%', threshold_use => 'drop_prct', output_use => 'drop_prct',
|
|
||||||
closure_custom_calc => \&custom_drop_out_calc,
|
|
||||||
perfdatas => [
|
|
||||||
{ label => 'drop_out', value => 'ggsnApnDownlinkDrops_absolute', template => '%s',
|
|
||||||
min => 0, max => 'ggsnApnDownlinkPackets_absolute', label_extra_instance => 1, instance_use => 'ggsnApnName' },
|
|
||||||
],
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'006_active-pdp' => { class => 'centreon::plugins::values', obj => undef,
|
|
||||||
set => {
|
|
||||||
key_values => [
|
|
||||||
{ name => 'ggsnApnActivePdpContextCount' }, { name => 'ggsnApnName' },
|
|
||||||
],
|
|
||||||
output_template => 'Active Pdp : %s',
|
|
||||||
perfdatas => [
|
|
||||||
{ label => 'active_pdp', value => 'ggsnApnActivePdpContextCount_absolute', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'ggsnApnName_absolute' },
|
|
||||||
],
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'007_attempted-activation-pdp' => { class => 'centreon::plugins::values', obj => undef,
|
|
||||||
set => {
|
|
||||||
key_values => [
|
|
||||||
{ name => 'ggsnApnAttemptedActivation', diff => 1 }, { name => 'ggsnApnName' },
|
|
||||||
],
|
|
||||||
output_template => 'Attempted Activation Pdp : %s',
|
|
||||||
perfdatas => [
|
|
||||||
{ label => 'attempted_activation_pdp', value => 'ggsnApnAttemptedActivation_absolute', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'ggsnApnName_absolute' },
|
|
||||||
],
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'008_attempted-dyn-activation-pdp' => { class => 'centreon::plugins::values', obj => undef,
|
|
||||||
set => {
|
|
||||||
key_values => [
|
|
||||||
{ name => 'ggsnApnAttemptedDynActivation', diff => 1 }, { name => 'ggsnApnName' },
|
|
||||||
],
|
|
||||||
output_template => 'Attempted Dyn Activation Pdp : %s',
|
|
||||||
perfdatas => [
|
|
||||||
{ label => 'attempted_dyn_activation_pdp', value => 'ggsnApnAttemptedDynActivation_absolute', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'ggsnApnName_absolute' },
|
|
||||||
],
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'009_attempted-deactivation-pdp' => { class => 'centreon::plugins::values', obj => undef,
|
|
||||||
set => {
|
|
||||||
key_values => [
|
|
||||||
{ name => 'ggsnApnAttemptedDeactivation', diff => 1 }, { name => 'ggsnApnName' },
|
|
||||||
],
|
|
||||||
output_template => 'Attempted Deactivation Pdp : %s',
|
|
||||||
perfdatas => [
|
|
||||||
{ label => 'attempted_deactivation_pdp', value => 'ggsnApnAttemptedDeactivation_absolute', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'ggsnApnName_absolute' },
|
|
||||||
],
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'010_attempted-self-deactivation-pdp' => { class => 'centreon::plugins::values', obj => undef,
|
|
||||||
set => {
|
|
||||||
key_values => [
|
|
||||||
{ name => 'ggsnApnAttemptedSelfDeactivation', diff => 1 }, { name => 'ggsnApnName' },
|
|
||||||
],
|
|
||||||
output_template => 'Attempted Self Deactivation Pdp : %s',
|
|
||||||
perfdatas => [
|
|
||||||
{ label => 'attempted_self_deactivation_pdp', value => 'ggsnApnAttemptedSelfDeactivation_absolute', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'ggsnApnName_absolute' },
|
|
||||||
],
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'011_completed-activation-pdp' => { class => 'centreon::plugins::values', obj => undef,
|
|
||||||
set => {
|
|
||||||
key_values => [
|
|
||||||
{ name => 'ggsnApnCompletedActivation', diff => 1 }, { name => 'ggsnApnName' },
|
|
||||||
],
|
|
||||||
output_template => 'Completed Activation Pdp : %s',
|
|
||||||
perfdatas => [
|
|
||||||
{ label => 'completed_activation_pdp', value => 'ggsnApnCompletedActivation_absolute', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'ggsnApnName_absolute' },
|
|
||||||
],
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'012_completed-dyn-activation-pdp' => { class => 'centreon::plugins::values', obj => undef,
|
|
||||||
set => {
|
|
||||||
key_values => [
|
|
||||||
{ name => 'ggsnApnCompletedDynActivation', diff => 1 }, { name => 'ggsnApnName' },
|
|
||||||
],
|
|
||||||
output_template => 'Completed Dyn Activation Pdp : %s',
|
|
||||||
perfdatas => [
|
|
||||||
{ label => 'completed_dyn_activation_pdp', value => 'ggsnApnCompletedDynActivation_absolute', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'ggsnApnName_absolute' },
|
|
||||||
],
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'013_completed-deactivation-pdp' => { class => 'centreon::plugins::values', obj => undef,
|
|
||||||
set => {
|
|
||||||
key_values => [
|
|
||||||
{ name => 'ggsnApnCompletedDeactivation', diff => 1 }, { name => 'ggsnApnName' },
|
|
||||||
],
|
|
||||||
output_template => 'Completed Deactivation Pdp : %s',
|
|
||||||
perfdatas => [
|
|
||||||
{ label => 'completed_deactivation_pdp', value => 'ggsnApnCompletedDeactivation_absolute', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'ggsnApnName_absolute' },
|
|
||||||
],
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'014_completed-self-deactivation-pdp' => { class => 'centreon::plugins::values', obj => undef,
|
|
||||||
set => {
|
|
||||||
key_values => [
|
|
||||||
{ name => 'ggsnApnCompletedSelfDeactivation', diff => 1 }, { name => 'ggsnApnName' },
|
|
||||||
],
|
|
||||||
output_template => 'Completed Self Deactivation Pdp : %s',
|
|
||||||
perfdatas => [
|
|
||||||
{ label => 'completed_self_deactivation_pdp', value => 'ggsnApnCompletedSelfDeactivation_absolute', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'ggsnApnName_absolute' },
|
|
||||||
],
|
|
||||||
}
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
sub custom_drop_in_calc {
|
sub custom_drop_in_calc {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
@ -210,120 +54,146 @@ sub custom_drop_out_calc {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub set_counters {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->{maps_counters_type} = [
|
||||||
|
{ name => 'apn', type => 1, cb_prefix_output => 'prefix_apn_output', message_multiple => 'All apn statistics are ok' }
|
||||||
|
];
|
||||||
|
|
||||||
|
$self->{maps_counters}->{apn} = [
|
||||||
|
{ label => 'traffic-in', set => {
|
||||||
|
key_values => [ { name => 'ggsnApnUplinkBytes', diff => 1 }, { name => 'ggsnApnName' } ],
|
||||||
|
per_second => 1, output_change_bytes => 2,
|
||||||
|
output_template => 'Traffic In : %s %s/s',
|
||||||
|
perfdatas => [
|
||||||
|
{ label => 'traffic_in', value => 'ggsnApnUplinkBytes_per_second', template => '%s',
|
||||||
|
unit => 'b/s', min => 0, label_extra_instance => 1, cast_int => 1, instance_use => 'ggsnApnName_absolute' },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'traffic-out', set => {
|
||||||
|
key_values => [ { name => 'ggsnApnDownlinkBytes', diff => 1 }, { name => 'ggsnApnName' } ],
|
||||||
|
per_second => 1, output_change_bytes => 2,
|
||||||
|
output_template => 'Traffic Out : %s %s/s',
|
||||||
|
perfdatas => [
|
||||||
|
{ label => 'traffic_out', value => 'ggsnApnDownlinkBytes_per_second', template => '%s',
|
||||||
|
unit => 'b/s', min => 0, label_extra_instance => 1, cast_int => 1, instance_use => 'ggsnApnName_absolute' },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'drop-in', set => {
|
||||||
|
key_values => [ { name => 'ggsnApnUplinkDrops', diff => 1 }, { name => 'ggsnApnUplinkPackets', diff => 1 }, { name => 'ggsnApnName' } ],
|
||||||
|
output_template => 'Drop In Packets : %.2f %%', threshold_use => 'drop_prct', output_use => 'drop_prct',
|
||||||
|
closure_custom_calc => $self->can('custom_drop_in_calc'),
|
||||||
|
perfdatas => [
|
||||||
|
{ label => 'drop_in', value => 'ggsnApnUplinkDrops_absolute', template => '%s',
|
||||||
|
min => 0, max => 'ggsnApnUplinkPackets_absolute', label_extra_instance => 1, instance_use => 'ggsnApnName' },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'drop-out', set => {
|
||||||
|
key_values => [ { name => 'ggsnApnDownlinkDrops', diff => 1 }, { name => 'ggsnApnDownlinkPackets', diff => 1 }, { name => 'ggsnApnName' } ],
|
||||||
|
output_template => 'Drop Out Packets : %.2f %%', threshold_use => 'drop_prct', output_use => 'drop_prct',
|
||||||
|
closure_custom_calc => $self->can('custom_drop_out_calc'),
|
||||||
|
perfdatas => [
|
||||||
|
{ label => 'drop_out', value => 'ggsnApnDownlinkDrops_absolute', template => '%s',
|
||||||
|
min => 0, max => 'ggsnApnDownlinkPackets_absolute', label_extra_instance => 1, instance_use => 'ggsnApnName' },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'active-pdp', set => {
|
||||||
|
key_values => [ { name => 'ggsnApnActivePdpContextCount' }, { name => 'ggsnApnName' } ],
|
||||||
|
output_template => 'Active Pdp : %s',
|
||||||
|
perfdatas => [
|
||||||
|
{ label => 'active_pdp', value => 'ggsnApnActivePdpContextCount_absolute', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'ggsnApnName_absolute' },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'attempted-activation-pdp', set => {
|
||||||
|
key_values => [ { name => 'ggsnApnAttemptedActivation', diff => 1 }, { name => 'ggsnApnName' } ],
|
||||||
|
output_template => 'Attempted Activation Pdp : %s',
|
||||||
|
perfdatas => [
|
||||||
|
{ label => 'attempted_activation_pdp', value => 'ggsnApnAttemptedActivation_absolute', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'ggsnApnName_absolute' },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'attempted-dyn-activation-pdp', set => {
|
||||||
|
key_values => [ { name => 'ggsnApnAttemptedDynActivation', diff => 1 }, { name => 'ggsnApnName' } ],
|
||||||
|
output_template => 'Attempted Dyn Activation Pdp : %s',
|
||||||
|
perfdatas => [
|
||||||
|
{ label => 'attempted_dyn_activation_pdp', value => 'ggsnApnAttemptedDynActivation_absolute', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'ggsnApnName_absolute' },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'attempted-deactivation-pdp', set => {
|
||||||
|
key_values => [ { name => 'ggsnApnAttemptedDeactivation', diff => 1 }, { name => 'ggsnApnName' } ],
|
||||||
|
output_template => 'Attempted Deactivation Pdp : %s',
|
||||||
|
perfdatas => [
|
||||||
|
{ label => 'attempted_deactivation_pdp', value => 'ggsnApnAttemptedDeactivation_absolute', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'ggsnApnName_absolute' },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'attempted-self-deactivation-pdp', set => {
|
||||||
|
key_values => [ { name => 'ggsnApnAttemptedSelfDeactivation', diff => 1 }, { name => 'ggsnApnName' } ],
|
||||||
|
output_template => 'Attempted Self Deactivation Pdp : %s',
|
||||||
|
perfdatas => [
|
||||||
|
{ label => 'attempted_self_deactivation_pdp', value => 'ggsnApnAttemptedSelfDeactivation_absolute', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'ggsnApnName_absolute' },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'completed-activation-pdp', set => {
|
||||||
|
key_values => [ { name => 'ggsnApnCompletedActivation', diff => 1 }, { name => 'ggsnApnName' } ],
|
||||||
|
output_template => 'Completed Activation Pdp : %s',
|
||||||
|
perfdatas => [
|
||||||
|
{ label => 'completed_activation_pdp', value => 'ggsnApnCompletedActivation_absolute', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'ggsnApnName_absolute' },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'completed-dyn-activation-pdp', set => {
|
||||||
|
key_values => [ { name => 'ggsnApnCompletedDynActivation', diff => 1 }, { name => 'ggsnApnName' } ],
|
||||||
|
output_template => 'Completed Dyn Activation Pdp : %s',
|
||||||
|
perfdatas => [
|
||||||
|
{ label => 'completed_dyn_activation_pdp', value => 'ggsnApnCompletedDynActivation_absolute', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'ggsnApnName_absolute' },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'completed-deactivation-pdp', set => {
|
||||||
|
key_values => [ { name => 'ggsnApnCompletedDeactivation', diff => 1 }, { name => 'ggsnApnName' } ],
|
||||||
|
output_template => 'Completed Deactivation Pdp : %s',
|
||||||
|
perfdatas => [
|
||||||
|
{ label => 'completed_deactivation_pdp', value => 'ggsnApnCompletedDeactivation_absolute', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'ggsnApnName_absolute' },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'completed-self-deactivation-pdp', set => {
|
||||||
|
key_values => [ { name => 'ggsnApnCompletedSelfDeactivation', diff => 1 }, { name => 'ggsnApnName' } ],
|
||||||
|
output_template => 'Completed Self Deactivation Pdp : %s',
|
||||||
|
perfdatas => [
|
||||||
|
{ label => 'completed_self_deactivation_pdp', value => 'ggsnApnCompletedSelfDeactivation_absolute', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'ggsnApnName_absolute' },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my ($class, %options) = @_;
|
my ($class, %options) = @_;
|
||||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$self->{version} = '1.0';
|
$self->{version} = '1.0';
|
||||||
$options{options}->add_options(arguments =>
|
$options{options}->add_options(arguments => {
|
||||||
{
|
"filter-name:s" => { name => 'filter_name' },
|
||||||
"filter-name:s" => { name => 'filter_name' },
|
});
|
||||||
});
|
|
||||||
$self->{statefile_value} = centreon::plugins::statefile->new(%options);
|
|
||||||
|
|
||||||
foreach (keys %{$maps_counters}) {
|
|
||||||
my ($id, $name) = split /_/;
|
|
||||||
if (!defined($maps_counters->{$_}->{threshold}) || $maps_counters->{$_}->{threshold} != 0) {
|
|
||||||
$options{options}->add_options(arguments => {
|
|
||||||
'warning-' . $name . ':s' => { name => 'warning-' . $name },
|
|
||||||
'critical-' . $name . ':s' => { name => 'critical-' . $name },
|
|
||||||
});
|
|
||||||
}
|
|
||||||
my $class = $maps_counters->{$_}->{class};
|
|
||||||
$maps_counters->{$_}->{obj} = $class->new(statefile => $self->{statefile_value},
|
|
||||||
output => $self->{output}, perfdata => $self->{perfdata},
|
|
||||||
label => $name);
|
|
||||||
$maps_counters->{$_}->{obj}->set(%{$maps_counters->{$_}->{set}});
|
|
||||||
}
|
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub check_options {
|
sub prefix_apn_output {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
$self->SUPER::init(%options);
|
|
||||||
|
|
||||||
foreach (keys %{$maps_counters}) {
|
return "APN '" . $options{instance_value}->{ggsnApnName} . "' ";
|
||||||
$maps_counters->{$_}->{obj}->init(option_results => $self->{option_results});
|
|
||||||
}
|
|
||||||
|
|
||||||
$self->{statefile_value}->check_options(%options);
|
|
||||||
}
|
|
||||||
|
|
||||||
sub run {
|
|
||||||
my ($self, %options) = @_;
|
|
||||||
$self->{snmp} = $options{snmp};
|
|
||||||
$self->{hostname} = $self->{snmp}->get_hostname();
|
|
||||||
$self->{snmp_port} = $self->{snmp}->get_port();
|
|
||||||
|
|
||||||
if ($self->{snmp}->is_snmpv1()) {
|
|
||||||
$self->{output}->add_option_msg(short_msg => "Need to use SNMP v2c or v3.");
|
|
||||||
$self->{output}->option_exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
$self->manage_selection();
|
|
||||||
|
|
||||||
my $multiple = 1;
|
|
||||||
if (scalar(keys %{$self->{apn_selected}}) == 1) {
|
|
||||||
$multiple = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($multiple == 1) {
|
|
||||||
$self->{output}->output_add(severity => 'OK',
|
|
||||||
short_msg => 'All apn statistics are ok');
|
|
||||||
}
|
|
||||||
|
|
||||||
$self->{new_datas} = {};
|
|
||||||
$self->{statefile_value}->read(statefile => "juniper_ggsn_" . $self->{hostname} . '_' . $self->{snmp_port} . '_' . $self->{mode} . '_' . (defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('.*')));
|
|
||||||
$self->{new_datas}->{last_timestamp} = time();
|
|
||||||
|
|
||||||
foreach my $id (sort keys %{$self->{apn_selected}}) {
|
|
||||||
my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', '');
|
|
||||||
my @exits;
|
|
||||||
foreach (sort keys %{$maps_counters}) {
|
|
||||||
$maps_counters->{$_}->{obj}->set(instance => $id);
|
|
||||||
|
|
||||||
my ($value_check) = $maps_counters->{$_}->{obj}->execute(values => $self->{apn_selected}->{$id},
|
|
||||||
new_datas => $self->{new_datas});
|
|
||||||
|
|
||||||
if ($value_check != 0) {
|
|
||||||
$long_msg .= $long_msg_append . $maps_counters->{$_}->{obj}->output_error();
|
|
||||||
$long_msg_append = ', ';
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
my $exit2 = $maps_counters->{$_}->{obj}->threshold_check();
|
|
||||||
push @exits, $exit2;
|
|
||||||
|
|
||||||
my $output = $maps_counters->{$_}->{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 = ', ';
|
|
||||||
}
|
|
||||||
|
|
||||||
$maps_counters->{$_}->{obj}->perfdata(level => 1, extra_instance => $multiple);
|
|
||||||
}
|
|
||||||
|
|
||||||
$self->{output}->output_add(long_msg => "APN '" . $self->{apn_selected}->{$id}->{ggsnApnName} . "' $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 => "APN '" . $self->{apn_selected}->{$id}->{ggsnApnName} . "' $short_msg"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($multiple == 0) {
|
|
||||||
$self->{output}->output_add(short_msg => "APN '" . $self->{apn_selected}->{$id}->{ggsnApnName} . "' $long_msg");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$self->{statefile_value}->write(data => $self->{new_datas});
|
|
||||||
$self->{output}->display();
|
|
||||||
$self->{output}->exit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
my $mapping = {
|
my $mapping = {
|
||||||
|
@ -348,29 +218,40 @@ my $mapping = {
|
||||||
sub manage_selection {
|
sub manage_selection {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{apn_selected} = {};
|
if ($options{snmp}->is_snmpv1()) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Need to use SNMP v2c or v3.");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
$self->{apn} = {};
|
||||||
my $oid_ggsnApnStatsEntry = '.1.3.6.1.4.1.10923.1.1.1.1.1.5.1';
|
my $oid_ggsnApnStatsEntry = '.1.3.6.1.4.1.10923.1.1.1.1.1.5.1';
|
||||||
$self->{results} = $self->{snmp}->get_table(oid => $oid_ggsnApnStatsEntry,
|
my $snmp_result = $options{snmp}->get_table(
|
||||||
nothing_quit => 1);
|
oid => $oid_ggsnApnStatsEntry,
|
||||||
foreach my $oid (keys %{$self->{results}}) {
|
nothing_quit => 1
|
||||||
|
);
|
||||||
|
foreach my $oid (keys %$snmp_result) {
|
||||||
next if ($oid !~ /^$mapping->{ggsnApnName}->{oid}\.(\d+)/);
|
next if ($oid !~ /^$mapping->{ggsnApnName}->{oid}\.(\d+)/);
|
||||||
my $instance = $1;
|
my $instance = $1;
|
||||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => $instance);
|
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
|
||||||
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||||
$result->{ggsnApnName} !~ /$self->{option_results}->{filter_name}/) {
|
$result->{ggsnApnName} !~ /$self->{option_results}->{filter_name}/) {
|
||||||
$self->{output}->output_add(long_msg => "Skipping '" . $result->{ggsnApnName} . "': no matching filter.");
|
$self->{output}->output_add(long_msg => "skipping '" . $result->{ggsnApnName} . "': no matching filter.");
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result->{ggsnApnDownlinkBytes} *= 8 if (defined($result->{ggsnApnDownlinkBytes}));
|
$result->{ggsnApnDownlinkBytes} *= 8 if (defined($result->{ggsnApnDownlinkBytes}));
|
||||||
$result->{ggsnApnUplinkBytes} *= 8 if (defined($result->{ggsnApnUplinkBytes}));
|
$result->{ggsnApnUplinkBytes} *= 8 if (defined($result->{ggsnApnUplinkBytes}));
|
||||||
$self->{apn_selected}->{$instance} = $result;
|
$self->{apn}->{$instance} = $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scalar(keys %{$self->{apn_selected}}) <= 0) {
|
if (scalar(keys %{$self->{apn}}) <= 0) {
|
||||||
$self->{output}->add_option_msg(short_msg => "No entry found.");
|
$self->{output}->add_option_msg(short_msg => "No entry found.");
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$self->{cache_name} = "juniper_ggsn_" . $self->{mode} . '_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' .
|
||||||
|
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' .
|
||||||
|
(defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all'));
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
|
@ -20,166 +20,11 @@
|
||||||
|
|
||||||
package network::juniper::ggsn::mode::globalstats;
|
package network::juniper::ggsn::mode::globalstats;
|
||||||
|
|
||||||
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 Digest::MD5 qw(md5_hex);
|
||||||
use centreon::plugins::statefile;
|
|
||||||
|
|
||||||
my $maps_counters = {
|
|
||||||
'000_traffic-in' => { class => 'centreon::plugins::values', obj => undef,
|
|
||||||
set => {
|
|
||||||
key_values => [
|
|
||||||
{ name => 'ggsnUplinkBytes', diff => 1 },
|
|
||||||
],
|
|
||||||
per_second => 1, output_change_bytes => 2,
|
|
||||||
output_template => 'Traffic In : %s %s/s',
|
|
||||||
perfdatas => [
|
|
||||||
{ label => 'traffic_in', value => 'ggsnUplinkBytes_per_second', template => '%s',
|
|
||||||
unit => 'b/s', min => 0, cast_int => 1 },
|
|
||||||
],
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'001_traffic-out' => { class => 'centreon::plugins::values', obj => undef,
|
|
||||||
set => {
|
|
||||||
key_values => [
|
|
||||||
{ name => 'ggsnDownlinkBytes', diff => 1 },
|
|
||||||
],
|
|
||||||
per_second => 1, output_change_bytes => 2,
|
|
||||||
output_template => 'Traffic Out : %s %s/s',
|
|
||||||
perfdatas => [
|
|
||||||
{ label => 'traffic_out', value => 'ggsnDownlinkBytes_per_second', template => '%s',
|
|
||||||
unit => 'b/s', min => 0, cast_int => 1 },
|
|
||||||
],
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'004_drop-in' => { class => 'centreon::plugins::values', obj => undef,
|
|
||||||
set => {
|
|
||||||
key_values => [
|
|
||||||
{ name => 'ggsnUplinkDrops', diff => 1 }, { name => 'ggsnUplinkPackets', diff => 1 },
|
|
||||||
],
|
|
||||||
output_template => 'Drop In Packets : %.2f %%', threshold_use => 'drop_prct', output_use => 'drop_prct',
|
|
||||||
closure_custom_calc => \&custom_drop_in_calc,
|
|
||||||
perfdatas => [
|
|
||||||
{ label => 'drop_in', value => 'ggsnUplinkDrops_absolute', template => '%s',
|
|
||||||
min => 0, max => 'ggsnUplinkPackets_absolute' },
|
|
||||||
],
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'005_drop-out' => { class => 'centreon::plugins::values', obj => undef,
|
|
||||||
set => {
|
|
||||||
key_values => [
|
|
||||||
{ name => 'ggsnDownlinkDrops', diff => 1 }, { name => 'ggsnDownlinkPackets', diff => 1 },
|
|
||||||
],
|
|
||||||
output_template => 'Drop Out Packets : %.2f %%', threshold_use => 'drop_prct', output_use => 'drop_prct',
|
|
||||||
closure_custom_calc => \&custom_drop_out_calc,
|
|
||||||
perfdatas => [
|
|
||||||
{ label => 'drop_out', value => 'ggsnDownlinkDrops_absolute', template => '%s',
|
|
||||||
min => 0, max => 'ggsnDownlinkPackets_absolute' },
|
|
||||||
],
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'006_active-pdp' => { class => 'centreon::plugins::values', obj => undef,
|
|
||||||
set => {
|
|
||||||
key_values => [
|
|
||||||
{ name => 'ggsnNbrOfActivePdpContexts' },
|
|
||||||
],
|
|
||||||
output_template => 'Active Pdp : %s',
|
|
||||||
perfdatas => [
|
|
||||||
{ label => 'active_pdp', value => 'ggsnNbrOfActivePdpContexts_absolute', template => '%s', min => 0 },
|
|
||||||
],
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'007_attempted-activation-pdp' => { class => 'centreon::plugins::values', obj => undef,
|
|
||||||
set => {
|
|
||||||
key_values => [
|
|
||||||
{ name => 'ggsnAttemptedActivation', diff => 1 },
|
|
||||||
],
|
|
||||||
output_template => 'Attempted Activation Pdp : %s',
|
|
||||||
perfdatas => [
|
|
||||||
{ label => 'attempted_activation_pdp', value => 'ggsnAttemptedActivation_absolute', template => '%s', min => 0 },
|
|
||||||
],
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'008_attempted-deactivation-pdp' => { class => 'centreon::plugins::values', obj => undef,
|
|
||||||
set => {
|
|
||||||
key_values => [
|
|
||||||
{ name => 'ggsnAttemptedDeactivation', diff => 1 },
|
|
||||||
],
|
|
||||||
output_template => 'Attempted Deactivation Pdp : %s',
|
|
||||||
perfdatas => [
|
|
||||||
{ label => 'attempted_deactivation_pdp', value => 'ggsnAttemptedDeactivation_absolute', template => '%s', min => 0 },
|
|
||||||
],
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'009_attempted-self-deactivation-pdp' => { class => 'centreon::plugins::values', obj => undef,
|
|
||||||
set => {
|
|
||||||
key_values => [
|
|
||||||
{ name => 'ggsnAttemptedSelfDeactivation', diff => 1 },
|
|
||||||
],
|
|
||||||
output_template => 'Attempted Self Deactivation Pdp : %s',
|
|
||||||
perfdatas => [
|
|
||||||
{ label => 'attempted_self_deactivation_pdp', value => 'ggsnAttemptedSelfDeactivation_absolute', template => '%s', min => 0 },
|
|
||||||
],
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'010_attempted-update-pdp' => { class => 'centreon::plugins::values', obj => undef,
|
|
||||||
set => {
|
|
||||||
key_values => [
|
|
||||||
{ name => 'ggsnAttemptedUpdate', diff => 1 },
|
|
||||||
],
|
|
||||||
output_template => 'Attempted Update Pdp : %s',
|
|
||||||
perfdatas => [
|
|
||||||
{ label => 'attempted_update_pdp', value => 'ggsnAttemptedUpdate_absolute', template => '%s', min => 0 },
|
|
||||||
],
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'011_completed-activation-pdp' => { class => 'centreon::plugins::values', obj => undef,
|
|
||||||
set => {
|
|
||||||
key_values => [
|
|
||||||
{ name => 'ggsnCompletedActivation', diff => 1 },
|
|
||||||
],
|
|
||||||
output_template => 'Completed Activation Pdp : %s',
|
|
||||||
perfdatas => [
|
|
||||||
{ label => 'completed_activation_pdp', value => 'ggsnCompletedActivation_absolute', template => '%s', min => 0 },
|
|
||||||
],
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'012_completed-deactivation-pdp' => { class => 'centreon::plugins::values', obj => undef,
|
|
||||||
set => {
|
|
||||||
key_values => [
|
|
||||||
{ name => 'ggsnCompletedDeactivation', diff => 1 },
|
|
||||||
],
|
|
||||||
output_template => 'Completed Deactivation Pdp : %s',
|
|
||||||
perfdatas => [
|
|
||||||
{ label => 'completed_deactivation_pdp', value => 'ggsnCompletedDeactivation_absolute', template => '%s', min => 0 },
|
|
||||||
],
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'013_completed-self-deactivation-pdp' => { class => 'centreon::plugins::values', obj => undef,
|
|
||||||
set => {
|
|
||||||
key_values => [
|
|
||||||
{ name => 'ggsnCompletedSelfDeactivation', diff => 1 },
|
|
||||||
],
|
|
||||||
output_template => 'Completed Self Deactivation Pdp : %s',
|
|
||||||
perfdatas => [
|
|
||||||
{ label => 'completed_self_deactivation_pdp', value => 'ggsnCompletedSelfDeactivation_absolute', template => '%s', min => 0 },
|
|
||||||
],
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'014_completed-update-pdp' => { class => 'centreon::plugins::values', obj => undef,
|
|
||||||
set => {
|
|
||||||
key_values => [
|
|
||||||
{ name => 'ggsnCompletedUpdate', diff => 1 },
|
|
||||||
],
|
|
||||||
output_template => 'Completed Update Pdp : %s',
|
|
||||||
perfdatas => [
|
|
||||||
{ label => 'completed_update_pdp', value => 'ggsnCompletedUpdate_absolute', template => '%s', min => 0 },
|
|
||||||
],
|
|
||||||
}
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
sub custom_drop_in_calc {
|
sub custom_drop_in_calc {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
@ -207,106 +52,155 @@ sub custom_drop_out_calc {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub set_counters {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->{maps_counters_type} = [
|
||||||
|
{ name => 'global', type => 0, cb_prefix_output => 'prefix_global_output', skipped_code => { -10 => 1 } }
|
||||||
|
];
|
||||||
|
|
||||||
|
$self->{maps_counters}->{global} = [
|
||||||
|
{ label => 'traffic-in', set => {
|
||||||
|
key_values => [ { name => 'ggsnUplinkBytes', diff => 1 } ],
|
||||||
|
per_second => 1, output_change_bytes => 2,
|
||||||
|
output_template => 'Traffic In : %s %s/s',
|
||||||
|
perfdatas => [
|
||||||
|
{ label => 'traffic_in', value => 'ggsnUplinkBytes_per_second', template => '%s',
|
||||||
|
unit => 'b/s', min => 0, cast_int => 1 },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'traffic-out', set => {
|
||||||
|
key_values => [ { name => 'ggsnDownlinkBytes', diff => 1 } ],
|
||||||
|
per_second => 1, output_change_bytes => 2,
|
||||||
|
output_template => 'Traffic Out : %s %s/s',
|
||||||
|
perfdatas => [
|
||||||
|
{ label => 'traffic_out', value => 'ggsnDownlinkBytes_per_second', template => '%s',
|
||||||
|
unit => 'b/s', min => 0, cast_int => 1 },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'drop-in', set => {
|
||||||
|
key_values => [ { name => 'ggsnUplinkDrops', diff => 1 }, { name => 'ggsnUplinkPackets', diff => 1 } ],
|
||||||
|
output_template => 'Drop In Packets : %.2f %%', threshold_use => 'drop_prct', output_use => 'drop_prct',
|
||||||
|
closure_custom_calc => \&custom_drop_in_calc,
|
||||||
|
perfdatas => [
|
||||||
|
{ label => 'drop_in', value => 'ggsnUplinkDrops_absolute', template => '%s',
|
||||||
|
min => 0, max => 'ggsnUplinkPackets_absolute' },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'drop-out', set => {
|
||||||
|
key_values => [ { name => 'ggsnDownlinkDrops', diff => 1 }, { name => 'ggsnDownlinkPackets', diff => 1 } ],
|
||||||
|
output_template => 'Drop Out Packets : %.2f %%', threshold_use => 'drop_prct', output_use => 'drop_prct',
|
||||||
|
closure_custom_calc => \&custom_drop_out_calc,
|
||||||
|
perfdatas => [
|
||||||
|
{ label => 'drop_out', value => 'ggsnDownlinkDrops_absolute', template => '%s',
|
||||||
|
min => 0, max => 'ggsnDownlinkPackets_absolute' },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'active-pdp', set => {
|
||||||
|
key_values => [ { name => 'ggsnNbrOfActivePdpContexts' } ],
|
||||||
|
output_template => 'Active Pdp : %s',
|
||||||
|
perfdatas => [
|
||||||
|
{ label => 'active_pdp', value => 'ggsnNbrOfActivePdpContexts_absolute', template => '%s', min => 0 },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'attempted-activation-pdp', set => {
|
||||||
|
key_values => [ { name => 'ggsnAttemptedActivation', diff => 1 } ],
|
||||||
|
output_template => 'Attempted Activation Pdp : %s',
|
||||||
|
perfdatas => [
|
||||||
|
{ label => 'attempted_activation_pdp', value => 'ggsnAttemptedActivation_absolute', template => '%s', min => 0 },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'attempted-deactivation-pdp', set => {
|
||||||
|
key_values => [ { name => 'ggsnAttemptedDeactivation', diff => 1 } ],
|
||||||
|
output_template => 'Attempted Deactivation Pdp : %s',
|
||||||
|
perfdatas => [
|
||||||
|
{ label => 'attempted_deactivation_pdp', value => 'ggsnAttemptedDeactivation_absolute', template => '%s', min => 0 },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'attempted-deactivation-pdp', set => {
|
||||||
|
key_values => [ { name => 'ggsnAttemptedDeactivation', diff => 1 } ],
|
||||||
|
output_template => 'Attempted Deactivation Pdp : %s',
|
||||||
|
perfdatas => [
|
||||||
|
{ label => 'attempted_deactivation_pdp', value => 'ggsnAttemptedDeactivation_absolute', template => '%s', min => 0 },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'attempted-self-deactivation-pdp', set => {
|
||||||
|
key_values => [ { name => 'ggsnAttemptedSelfDeactivation', diff => 1 } ],
|
||||||
|
output_template => 'Attempted Self Deactivation Pdp : %s',
|
||||||
|
perfdatas => [
|
||||||
|
{ label => 'attempted_self_deactivation_pdp', value => 'ggsnAttemptedSelfDeactivation_absolute', template => '%s', min => 0 },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'attempted-update-pdp', set => {
|
||||||
|
key_values => [ { name => 'ggsnAttemptedUpdate', diff => 1 } ],
|
||||||
|
output_template => 'Attempted Update Pdp : %s',
|
||||||
|
perfdatas => [
|
||||||
|
{ label => 'attempted_update_pdp', value => 'ggsnAttemptedUpdate_absolute', template => '%s', min => 0 },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'completed-activation-pdp', set => {
|
||||||
|
key_values => [ { name => 'ggsnCompletedActivation', diff => 1 } ],
|
||||||
|
output_template => 'Completed Activation Pdp : %s',
|
||||||
|
perfdatas => [
|
||||||
|
{ label => 'completed_activation_pdp', value => 'ggsnCompletedActivation_absolute', template => '%s', min => 0 },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'completed-deactivation-pdp', set => {
|
||||||
|
key_values => [ { name => 'ggsnCompletedDeactivation', diff => 1 } ],
|
||||||
|
output_template => 'Completed Deactivation Pdp : %s',
|
||||||
|
perfdatas => [
|
||||||
|
{ label => 'completed_deactivation_pdp', value => 'ggsnCompletedDeactivation_absolute', template => '%s', min => 0 },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'completed-self-deactivation-pdp', set => {
|
||||||
|
key_values => [ { name => 'ggsnCompletedSelfDeactivation', diff => 1 } ],
|
||||||
|
output_template => 'Completed Self Deactivation Pdp : %s',
|
||||||
|
perfdatas => [
|
||||||
|
{ label => 'completed_self_deactivation_pdp', value => 'ggsnCompletedSelfDeactivation_absolute', template => '%s', min => 0 },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'completed-update-pdp', set => {
|
||||||
|
key_values => [ { name => 'ggsnCompletedUpdate', diff => 1 } ],
|
||||||
|
output_template => 'Completed Update Pdp : %s',
|
||||||
|
perfdatas => [
|
||||||
|
{ label => 'completed_update_pdp', value => 'ggsnCompletedUpdate_absolute', template => '%s', min => 0 },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
sub prefix_global_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return 'Global Stats ';
|
||||||
|
}
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my ($class, %options) = @_;
|
my ($class, %options) = @_;
|
||||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$self->{version} = '1.0';
|
$self->{version} = '1.0';
|
||||||
$options{options}->add_options(arguments =>
|
$options{options}->add_options(arguments => {
|
||||||
{
|
});
|
||||||
});
|
|
||||||
$self->{statefile_value} = centreon::plugins::statefile->new(%options);
|
|
||||||
|
|
||||||
foreach (keys %{$maps_counters}) {
|
|
||||||
my ($id, $name) = split /_/;
|
|
||||||
if (!defined($maps_counters->{$_}->{threshold}) || $maps_counters->{$_}->{threshold} != 0) {
|
|
||||||
$options{options}->add_options(arguments => {
|
|
||||||
'warning-' . $name . ':s' => { name => 'warning-' . $name },
|
|
||||||
'critical-' . $name . ':s' => { name => 'critical-' . $name },
|
|
||||||
});
|
|
||||||
}
|
|
||||||
my $class = $maps_counters->{$_}->{class};
|
|
||||||
$maps_counters->{$_}->{obj} = $class->new(statefile => $self->{statefile_value},
|
|
||||||
output => $self->{output}, perfdata => $self->{perfdata},
|
|
||||||
label => $name);
|
|
||||||
$maps_counters->{$_}->{obj}->set(%{$maps_counters->{$_}->{set}});
|
|
||||||
}
|
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub check_options {
|
|
||||||
my ($self, %options) = @_;
|
|
||||||
$self->SUPER::init(%options);
|
|
||||||
|
|
||||||
foreach (keys %{$maps_counters}) {
|
|
||||||
$maps_counters->{$_}->{obj}->init(option_results => $self->{option_results});
|
|
||||||
}
|
|
||||||
|
|
||||||
$self->{statefile_value}->check_options(%options);
|
|
||||||
}
|
|
||||||
|
|
||||||
sub run {
|
|
||||||
my ($self, %options) = @_;
|
|
||||||
$self->{snmp} = $options{snmp};
|
|
||||||
$self->{hostname} = $self->{snmp}->get_hostname();
|
|
||||||
$self->{snmp_port} = $self->{snmp}->get_port();
|
|
||||||
|
|
||||||
if ($self->{snmp}->is_snmpv1()) {
|
|
||||||
$self->{output}->add_option_msg(short_msg => "Need to use SNMP v2c or v3.");
|
|
||||||
$self->{output}->option_exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
$self->manage_selection();
|
|
||||||
|
|
||||||
$self->{new_datas} = {};
|
|
||||||
$self->{statefile_value}->read(statefile => "juniper_ggsn_" . $self->{hostname} . '_' . $self->{snmp_port} . '_' . $self->{mode});
|
|
||||||
$self->{new_datas}->{last_timestamp} = time();
|
|
||||||
|
|
||||||
my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', '');
|
|
||||||
my @exits;
|
|
||||||
foreach (sort keys %{$maps_counters}) {
|
|
||||||
$maps_counters->{$_}->{obj}->set(instance => 'global');
|
|
||||||
|
|
||||||
my ($value_check) = $maps_counters->{$_}->{obj}->execute(values => $self->{global},
|
|
||||||
new_datas => $self->{new_datas});
|
|
||||||
|
|
||||||
if ($value_check != 0) {
|
|
||||||
$long_msg .= $long_msg_append . $maps_counters->{$_}->{obj}->output_error();
|
|
||||||
$long_msg_append = ', ';
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
my $exit2 = $maps_counters->{$_}->{obj}->threshold_check();
|
|
||||||
push @exits, $exit2;
|
|
||||||
|
|
||||||
my $output = $maps_counters->{$_}->{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 = ', ';
|
|
||||||
}
|
|
||||||
|
|
||||||
$maps_counters->{$_}->{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 => "Global Stats $short_msg"
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
$self->{output}->output_add(short_msg => "Global Stats $long_msg");
|
|
||||||
}
|
|
||||||
|
|
||||||
$self->{statefile_value}->write(data => $self->{new_datas});
|
|
||||||
$self->{output}->display();
|
|
||||||
$self->{output}->exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
my $mapping = {
|
my $mapping = {
|
||||||
ggsnNbrOfActivePdpContexts => { oid => '.1.3.6.1.4.1.10923.1.1.1.1.1.3.2' },
|
ggsnNbrOfActivePdpContexts => { oid => '.1.3.6.1.4.1.10923.1.1.1.1.1.3.2' },
|
||||||
ggsnAttemptedActivation => { oid => '.1.3.6.1.4.1.10923.1.1.1.1.1.3.3.1' },
|
ggsnAttemptedActivation => { oid => '.1.3.6.1.4.1.10923.1.1.1.1.1.3.3.1' },
|
||||||
|
@ -328,12 +222,22 @@ my $mapping = {
|
||||||
sub manage_selection {
|
sub manage_selection {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
if ($options{snmp}->is_snmpv1()) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "Need to use SNMP v2c or v3.");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
|
||||||
my $oid_ggsnGlobalStats = '.1.3.6.1.4.1.10923.1.1.1.1.1.3';
|
my $oid_ggsnGlobalStats = '.1.3.6.1.4.1.10923.1.1.1.1.1.3';
|
||||||
$self->{results} = $self->{snmp}->get_table(oid => $oid_ggsnGlobalStats,
|
my $snmp_result = $options{snmp}->get_table(
|
||||||
nothing_quit => 1);
|
oid => $oid_ggsnGlobalStats,
|
||||||
$self->{global} = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => '0');
|
nothing_quit => 1
|
||||||
|
);
|
||||||
|
$self->{global} = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => '0');
|
||||||
$self->{global}->{ggsnDownlinkBytes} *= 8 if (defined($self->{global}->{ggsnDownlinkBytes}));
|
$self->{global}->{ggsnDownlinkBytes} *= 8 if (defined($self->{global}->{ggsnDownlinkBytes}));
|
||||||
$self->{global}->{ggsnUplinkBytes} *= 8 if (defined($self->{global}->{ggsnUplinkBytes}));
|
$self->{global}->{ggsnUplinkBytes} *= 8 if (defined($self->{global}->{ggsnUplinkBytes}));
|
||||||
|
|
||||||
|
$self->{cache_name} = "juniper_ggsn_" . $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'));
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
Loading…
Reference in New Issue