+ use template counter for f5 bigip
This commit is contained in:
parent
12bfb5d97e
commit
840c6efd9a
|
@ -20,16 +20,29 @@
|
|||
|
||||
package network::f5::bigip::mode::connections;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::values;
|
||||
use centreon::plugins::statefile;
|
||||
use Digest::MD5 qw(md5_hex);
|
||||
|
||||
my $maps_counters = {
|
||||
global => [
|
||||
sub custom_client_tps_calc {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $diff_native = $options{new_datas}->{$self->{instance} . '_client_ssl_tot_native'} - $options{old_datas}->{$self->{instance} . '_client_ssl_tot_native'};
|
||||
my $diff_compat = $options{new_datas}->{$self->{instance} . '_client_ssl_tot_compat'} - $options{old_datas}->{$self->{instance} . '_client_ssl_tot_compat'};
|
||||
$self->{result_values}->{client_ssl_tps} = ($diff_native + $diff_compat) / $options{delta_time};
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'global', type => 0 },
|
||||
];
|
||||
$self->{maps_counters}->{global} = [
|
||||
{ label => 'client', set => {
|
||||
key_values => [ { name => 'client' } ],
|
||||
output_template => 'Current client connections : %s',
|
||||
|
@ -48,10 +61,10 @@ my $maps_counters = {
|
|||
],
|
||||
}
|
||||
},
|
||||
{ label => 'client-ssl-tps', set => {
|
||||
{ label => 'client-ssl-tps', set => {
|
||||
key_values => [ { name => 'client_ssl_tot_native', diff => 1 }, { name => 'client_ssl_tot_compat', diff => 1 } ],
|
||||
output_template => 'TPS client SSL connections : %.2f', threshold_use => 'client_ssl_tps', output_use => 'client_ssl_tps',
|
||||
closure_custom_calc => \&custom_client_tps_calc,
|
||||
closure_custom_calc => $self->can('custom_client_tps_calc'),
|
||||
per_second => 1,
|
||||
perfdatas => [
|
||||
{ label => 'ClientSSL_Tps', value => 'client_ssl_tps', template => '%.2f',
|
||||
|
@ -59,7 +72,7 @@ my $maps_counters = {
|
|||
],
|
||||
}
|
||||
},
|
||||
{ label => 'server', set => {
|
||||
{ label => 'server', set => {
|
||||
key_values => [ { name => 'server' } ],
|
||||
output_template => 'Current server connections: %s',
|
||||
perfdatas => [
|
||||
|
@ -77,22 +90,12 @@ my $maps_counters = {
|
|||
],
|
||||
}
|
||||
},
|
||||
]
|
||||
};
|
||||
|
||||
sub custom_client_tps_calc {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $diff_native = $options{new_datas}->{$self->{instance} . '_client_ssl_tot_native'} - $options{old_datas}->{$self->{instance} . '_client_ssl_tot_native'};
|
||||
my $diff_compat = $options{new_datas}->{$self->{instance} . '_client_ssl_tot_compat'} - $options{old_datas}->{$self->{instance} . '_client_ssl_tot_compat'};
|
||||
$self->{result_values}->{client_ssl_tps} = ($diff_native + $diff_compat) / $options{delta_time};
|
||||
|
||||
return 0;
|
||||
];
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
|
@ -100,100 +103,10 @@ sub new {
|
|||
{
|
||||
"filter-counters:s" => { name => 'filter_counters' },
|
||||
});
|
||||
$self->{statefile_value} = centreon::plugins::statefile->new(%options);
|
||||
|
||||
foreach my $key (('global')) {
|
||||
foreach (@{$maps_counters->{$key}}) {
|
||||
if (!defined($_->{threshold}) || $_->{threshold} != 0) {
|
||||
$options{options}->add_options(arguments => {
|
||||
'warning-' . $_->{label} . ':s' => { name => 'warning-' . $_->{label} },
|
||||
'critical-' . $_->{label} . ':s' => { name => 'critical-' . $_->{label} },
|
||||
});
|
||||
}
|
||||
$_->{obj} = centreon::plugins::values->new(statefile => $self->{statefile_value},
|
||||
output => $self->{output}, perfdata => $self->{perfdata},
|
||||
label => $_->{label});
|
||||
$_->{obj}->set(%{$_->{set}});
|
||||
}
|
||||
}
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
foreach my $key (('global')) {
|
||||
foreach (@{$maps_counters->{$key}}) {
|
||||
$_->{obj}->init(option_results => $self->{option_results});
|
||||
}
|
||||
}
|
||||
|
||||
$self->{statefile_value}->check_options(%options);
|
||||
}
|
||||
|
||||
sub run_global {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', '');
|
||||
my @exits;
|
||||
foreach (@{$maps_counters->{global}}) {
|
||||
my $obj = $_->{obj};
|
||||
|
||||
next if (defined($self->{option_results}->{filter_counters}) && $self->{option_results}->{filter_counters} ne '' &&
|
||||
$_->{name} !~ /$self->{option_results}->{filter_counters}/);
|
||||
|
||||
$obj->set(instance => 'global');
|
||||
|
||||
my ($value_check) = $obj->execute(new_datas => $self->{new_datas}, 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->manage_selection(%options);
|
||||
|
||||
$self->{new_datas} = {};
|
||||
$self->{statefile_value}->read(statefile => $self->{cache_name});
|
||||
$self->{new_datas}->{last_timestamp} = time();
|
||||
|
||||
$self->run_global();
|
||||
|
||||
$self->{statefile_value}->write(data => $self->{new_datas});
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
|
|
@ -20,11 +20,10 @@
|
|||
|
||||
package network::f5::bigip::mode::nodestatus;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::values;
|
||||
|
||||
my $thresholds = {
|
||||
node => [
|
||||
|
@ -38,21 +37,6 @@ my $thresholds = {
|
|||
};
|
||||
my $instance_mode;
|
||||
|
||||
my $maps_counters = {
|
||||
node => {
|
||||
'000_status' => { set => {
|
||||
key_values => [ { name => 'AvailState' } ],
|
||||
closure_custom_calc => \&custom_status_calc,
|
||||
output_template => 'Status : %s', output_error_template => 'Status : %s',
|
||||
output_use => 'AvailState',
|
||||
closure_custom_perfdata => sub { return 0; },
|
||||
closure_custom_threshold_check => \&custom_threshold_output,
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
sub custom_threshold_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
@ -66,6 +50,31 @@ sub custom_status_calc {
|
|||
return 0;
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'node', type => 1, cb_prefix_output => 'prefix_node_output', message_multiple => 'All Nodes are ok' },
|
||||
];
|
||||
$self->{maps_counters}->{node} = [
|
||||
{ label => 'status', set => {
|
||||
key_values => [ { name => 'AvailState' } ],
|
||||
closure_custom_calc => $self->can('custom_status_calc'),
|
||||
output_template => 'Status : %s', output_error_template => 'Status : %s',
|
||||
output_use => 'AvailState',
|
||||
closure_custom_perfdata => sub { return 0; },
|
||||
closure_custom_threshold_check => $self->can('custom_threshold_output'),
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
sub prefix_node_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Node '" . $options{instance_value}->{Name} . "' ";
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
|
@ -77,21 +86,6 @@ sub new {
|
|||
"filter-name:s" => { name => 'filter_name' },
|
||||
"threshold-overload:s@" => { name => 'threshold_overload' },
|
||||
});
|
||||
|
||||
foreach my $key (('node')) {
|
||||
foreach (keys %{$maps_counters->{$key}}) {
|
||||
my ($id, $name) = split /_/;
|
||||
if (!defined($maps_counters->{$key}->{$_}->{threshold}) || $maps_counters->{$key}->{$_}->{threshold} != 0) {
|
||||
$options{options}->add_options(arguments => {
|
||||
'warning-' . $name . ':s' => { name => 'warning-' . $name },
|
||||
'critical-' . $name . ':s' => { name => 'critical-' . $name },
|
||||
});
|
||||
}
|
||||
$maps_counters->{$key}->{$_}->{obj} = centreon::plugins::values->new(output => $self->{output}, perfdata => $self->{perfdata},
|
||||
label => $name);
|
||||
$maps_counters->{$key}->{$_}->{obj}->set(%{$maps_counters->{$key}->{$_}->{set}});
|
||||
}
|
||||
}
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
@ -100,12 +94,6 @@ sub check_options {
|
|||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
foreach my $key (('node')) {
|
||||
foreach (keys %{$maps_counters->{$key}}) {
|
||||
$maps_counters->{$key}->{$_}->{obj}->init(option_results => $self->{option_results});
|
||||
}
|
||||
}
|
||||
|
||||
$instance_mode = $self;
|
||||
|
||||
$self->{overload_th} = {};
|
||||
|
@ -124,69 +112,6 @@ sub check_options {
|
|||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
# $options{snmp} = snmp object
|
||||
$self->{snmp} = $options{snmp};
|
||||
|
||||
$self->manage_selection();
|
||||
|
||||
my $multiple = 1;
|
||||
if (scalar(keys %{$self->{node}}) == 1) {
|
||||
$multiple = 0;
|
||||
}
|
||||
|
||||
if ($multiple == 1) {
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => 'All Nodes are ok');
|
||||
}
|
||||
|
||||
foreach my $id (sort keys %{$self->{node}}) {
|
||||
my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', '');
|
||||
my @exits = ();
|
||||
foreach (sort keys %{$maps_counters->{node}}) {
|
||||
my $obj = $maps_counters->{node}->{$_}->{obj};
|
||||
$obj->set(instance => $id);
|
||||
|
||||
my ($value_check) = $obj->execute(values => $self->{node}->{$id});
|
||||
|
||||
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 = ', ';
|
||||
}
|
||||
|
||||
$maps_counters->{node}->{$_}->{obj}->perfdata(extra_instance => $multiple);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(long_msg => "Node '$self->{node}->{$id}->{Name}' $long_msg [Status Reason: $self->{node}->{$id}->{StatusReason}]");
|
||||
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 => "Node '$self->{node}->{$id}->{Name}' $short_msg"
|
||||
);
|
||||
}
|
||||
|
||||
if ($multiple == 0) {
|
||||
$self->{output}->output_add(short_msg => "Node '$self->{node}->{$id}->{Name}' $long_msg");
|
||||
}
|
||||
}
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
sub get_severity {
|
||||
my ($self, %options) = @_;
|
||||
my $status = 'UNKNOWN'; # default
|
||||
|
@ -243,7 +168,7 @@ my $oid_ltmNodeAddrEntry = '.1.3.6.1.4.1.3375.2.2.4.1.2.1'; # old
|
|||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{results} = $self->{snmp}->get_multiple_table(oids => [
|
||||
$self->{results} = $options{snmp}->get_multiple_table(oids => [
|
||||
{ oid => $oid_ltmNodeAddrEntry, start => $mapping->{old}->{AvailState}->{oid} },
|
||||
{ oid => $oid_ltmNodeAddrStatusEntry, start => $mapping->{new}->{AvailState}->{oid} },
|
||||
],
|
||||
|
@ -258,7 +183,7 @@ sub manage_selection {
|
|||
foreach my $oid (keys %{$self->{results}->{$branch}}) {
|
||||
next if ($oid !~ /^$mapping->{$map}->{AvailState}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping->{$map}, results => $self->{results}->{$branch}, instance => $instance);
|
||||
my $result = $options{snmp}->map_instance(mapping => $mapping->{$map}, results => $self->{results}->{$branch}, instance => $instance);
|
||||
|
||||
$result->{Name} = $instance;
|
||||
# prefix by '1.4'
|
||||
|
|
|
@ -20,11 +20,10 @@
|
|||
|
||||
package network::f5::bigip::mode::poolstatus;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::values;
|
||||
|
||||
my $thresholds = {
|
||||
pool => [
|
||||
|
@ -38,21 +37,6 @@ my $thresholds = {
|
|||
};
|
||||
my $instance_mode;
|
||||
|
||||
my $maps_counters = {
|
||||
pool => {
|
||||
'000_status' => { set => {
|
||||
key_values => [ { name => 'AvailState' } ],
|
||||
closure_custom_calc => \&custom_status_calc,
|
||||
output_template => 'Status : %s', output_error_template => 'Status : %s',
|
||||
output_use => 'AvailState',
|
||||
closure_custom_perfdata => sub { return 0; },
|
||||
closure_custom_threshold_check => \&custom_threshold_output,
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
sub custom_threshold_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
@ -66,6 +50,31 @@ sub custom_status_calc {
|
|||
return 0;
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'pool', type => 1, cb_prefix_output => 'prefix_pool_output', message_multiple => 'All Pools are ok' },
|
||||
];
|
||||
$self->{maps_counters}->{pool} = [
|
||||
{ label => 'status', set => {
|
||||
key_values => [ { name => 'AvailState' } ],
|
||||
closure_custom_calc => $self->can('custom_status_calc'),
|
||||
output_template => 'Status : %s', output_error_template => 'Status : %s',
|
||||
output_use => 'AvailState',
|
||||
closure_custom_perfdata => sub { return 0; },
|
||||
closure_custom_threshold_check => $self->can('custom_threshold_output'),
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
sub prefix_pool_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Pool '" . $options{instance_value}->{Name} . "' ";
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
|
@ -77,21 +86,6 @@ sub new {
|
|||
"filter-name:s" => { name => 'filter_name' },
|
||||
"threshold-overload:s@" => { name => 'threshold_overload' },
|
||||
});
|
||||
|
||||
foreach my $key (('pool')) {
|
||||
foreach (keys %{$maps_counters->{$key}}) {
|
||||
my ($id, $name) = split /_/;
|
||||
if (!defined($maps_counters->{$key}->{$_}->{threshold}) || $maps_counters->{$key}->{$_}->{threshold} != 0) {
|
||||
$options{options}->add_options(arguments => {
|
||||
'warning-' . $name . ':s' => { name => 'warning-' . $name },
|
||||
'critical-' . $name . ':s' => { name => 'critical-' . $name },
|
||||
});
|
||||
}
|
||||
$maps_counters->{$key}->{$_}->{obj} = centreon::plugins::values->new(output => $self->{output}, perfdata => $self->{perfdata},
|
||||
label => $name);
|
||||
$maps_counters->{$key}->{$_}->{obj}->set(%{$maps_counters->{$key}->{$_}->{set}});
|
||||
}
|
||||
}
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
@ -100,12 +94,6 @@ sub check_options {
|
|||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
foreach my $key (('pool')) {
|
||||
foreach (keys %{$maps_counters->{$key}}) {
|
||||
$maps_counters->{$key}->{$_}->{obj}->init(option_results => $self->{option_results});
|
||||
}
|
||||
}
|
||||
|
||||
$instance_mode = $self;
|
||||
|
||||
$self->{overload_th} = {};
|
||||
|
@ -124,69 +112,6 @@ sub check_options {
|
|||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
# $options{snmp} = snmp object
|
||||
$self->{snmp} = $options{snmp};
|
||||
|
||||
$self->manage_selection();
|
||||
|
||||
my $multiple = 1;
|
||||
if (scalar(keys %{$self->{pool}}) == 1) {
|
||||
$multiple = 0;
|
||||
}
|
||||
|
||||
if ($multiple == 1) {
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => 'All Pools are ok');
|
||||
}
|
||||
|
||||
foreach my $id (sort keys %{$self->{pool}}) {
|
||||
my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', '');
|
||||
my @exits = ();
|
||||
foreach (sort keys %{$maps_counters->{pool}}) {
|
||||
my $obj = $maps_counters->{pool}->{$_}->{obj};
|
||||
$obj->set(instance => $id);
|
||||
|
||||
my ($value_check) = $obj->execute(values => $self->{pool}->{$id});
|
||||
|
||||
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 = ', ';
|
||||
}
|
||||
|
||||
$maps_counters->{pool}->{$_}->{obj}->perfdata(extra_instance => $multiple);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(long_msg => "Pool '$self->{pool}->{$id}->{Name}' $long_msg [Status Reason: $self->{pool}->{$id}->{StatusReason}]");
|
||||
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 => "Pool '$self->{pool}->{$id}->{Name}' $short_msg"
|
||||
);
|
||||
}
|
||||
|
||||
if ($multiple == 0) {
|
||||
$self->{output}->output_add(short_msg => "Pool '$self->{pool}->{$id}->{Name}' $long_msg");
|
||||
}
|
||||
}
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
sub get_severity {
|
||||
my ($self, %options) = @_;
|
||||
my $status = 'UNKNOWN'; # default
|
||||
|
@ -243,7 +168,7 @@ my $oid_ltmPoolEntry = '.1.3.6.1.4.1.3375.2.2.5.1.2.1'; # old
|
|||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{results} = $self->{snmp}->get_multiple_table(oids => [
|
||||
$self->{results} = $options{snmp}->get_multiple_table(oids => [
|
||||
{ oid => $oid_ltmPoolEntry, start => $mapping->{old}->{AvailState}->{oid} },
|
||||
{ oid => $oid_ltmPoolStatusEntry, start => $mapping->{new}->{AvailState}->{oid} },
|
||||
],
|
||||
|
@ -258,7 +183,7 @@ sub manage_selection {
|
|||
foreach my $oid (keys %{$self->{results}->{$branch}}) {
|
||||
next if ($oid !~ /^$mapping->{$map}->{AvailState}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping->{$map}, results => $self->{results}->{$branch}, instance => $instance);
|
||||
my $result = $options{snmp}->map_instance(mapping => $mapping->{$map}, results => $self->{results}->{$branch}, instance => $instance);
|
||||
|
||||
$result->{Name} = '';
|
||||
foreach (split /\./, $instance) {
|
||||
|
|
|
@ -20,11 +20,10 @@
|
|||
|
||||
package network::f5::bigip::mode::virtualserverstatus;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::values;
|
||||
|
||||
my $thresholds = {
|
||||
vs => [
|
||||
|
@ -38,20 +37,6 @@ my $thresholds = {
|
|||
};
|
||||
my $instance_mode;
|
||||
|
||||
my $maps_counters = {
|
||||
vs => {
|
||||
'000_status' => { set => {
|
||||
key_values => [ { name => 'AvailState' } ],
|
||||
closure_custom_calc => \&custom_status_calc,
|
||||
output_template => 'Status : %s', output_error_template => 'Status : %s',
|
||||
output_use => 'AvailState',
|
||||
closure_custom_perfdata => sub { return 0; },
|
||||
closure_custom_threshold_check => \&custom_threshold_output,
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
sub custom_threshold_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
@ -65,6 +50,31 @@ sub custom_status_calc {
|
|||
return 0;
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'vs', type => 1, cb_prefix_output => 'prefix_vs_output', message_multiple => 'All Virtual Servers are ok' },
|
||||
];
|
||||
$self->{maps_counters}->{vs} = [
|
||||
{ label => 'status', set => {
|
||||
key_values => [ { name => 'AvailState' } ],
|
||||
closure_custom_calc => $self->can('custom_status_calc'),
|
||||
output_template => 'Status : %s', output_error_template => 'Status : %s',
|
||||
output_use => 'AvailState',
|
||||
closure_custom_perfdata => sub { return 0; },
|
||||
closure_custom_threshold_check => $self->can('custom_threshold_output'),
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
sub prefix_node_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Virtual Server '" . $options{instance_value}->{Name} . "' ";
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
|
@ -76,21 +86,6 @@ sub new {
|
|||
"filter-name:s" => { name => 'filter_name' },
|
||||
"threshold-overload:s@" => { name => 'threshold_overload' },
|
||||
});
|
||||
|
||||
foreach my $key (('vs')) {
|
||||
foreach (keys %{$maps_counters->{$key}}) {
|
||||
my ($id, $name) = split /_/;
|
||||
if (!defined($maps_counters->{$key}->{$_}->{threshold}) || $maps_counters->{$key}->{$_}->{threshold} != 0) {
|
||||
$options{options}->add_options(arguments => {
|
||||
'warning-' . $name . ':s' => { name => 'warning-' . $name },
|
||||
'critical-' . $name . ':s' => { name => 'critical-' . $name },
|
||||
});
|
||||
}
|
||||
$maps_counters->{$key}->{$_}->{obj} = centreon::plugins::values->new(output => $self->{output}, perfdata => $self->{perfdata},
|
||||
label => $name);
|
||||
$maps_counters->{$key}->{$_}->{obj}->set(%{$maps_counters->{$key}->{$_}->{set}});
|
||||
}
|
||||
}
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
@ -99,12 +94,6 @@ sub check_options {
|
|||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
foreach my $key (('vs')) {
|
||||
foreach (keys %{$maps_counters->{$key}}) {
|
||||
$maps_counters->{$key}->{$_}->{obj}->init(option_results => $self->{option_results});
|
||||
}
|
||||
}
|
||||
|
||||
$instance_mode = $self;
|
||||
|
||||
$self->{overload_th} = {};
|
||||
|
@ -123,69 +112,6 @@ sub check_options {
|
|||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
# $options{snmp} = snmp object
|
||||
$self->{snmp} = $options{snmp};
|
||||
|
||||
$self->manage_selection();
|
||||
|
||||
my $multiple = 1;
|
||||
if (scalar(keys %{$self->{vs}}) == 1) {
|
||||
$multiple = 0;
|
||||
}
|
||||
|
||||
if ($multiple == 1) {
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => 'All Virtual Servers are ok');
|
||||
}
|
||||
|
||||
foreach my $id (sort keys %{$self->{vs}}) {
|
||||
my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', '');
|
||||
my @exits = ();
|
||||
foreach (sort keys %{$maps_counters->{vs}}) {
|
||||
my $obj = $maps_counters->{vs}->{$_}->{obj};
|
||||
$obj->set(instance => $id);
|
||||
|
||||
my ($value_check) = $obj->execute(values => $self->{vs}->{$id});
|
||||
|
||||
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 = ', ';
|
||||
}
|
||||
|
||||
$maps_counters->{vs}->{$_}->{obj}->perfdata(extra_instance => $multiple);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(long_msg => "Virtual Server '$self->{vs}->{$id}->{Name}' $long_msg [Status Reason: $self->{vs}->{$id}->{StatusReason}]");
|
||||
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 => "Virtual Server '$self->{vs}->{$id}->{Name}' $short_msg"
|
||||
);
|
||||
}
|
||||
|
||||
if ($multiple == 0) {
|
||||
$self->{output}->output_add(short_msg => "Virtual Server '$self->{vs}->{$id}->{Name}' $long_msg");
|
||||
}
|
||||
}
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
sub get_severity {
|
||||
my ($self, %options) = @_;
|
||||
my $status = 'UNKNOWN'; # default
|
||||
|
@ -242,7 +168,7 @@ my $oid_ltmVirtualServEntry = '.1.3.6.1.4.1.3375.2.2.10.1.2.1'; # old
|
|||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{results} = $self->{snmp}->get_multiple_table(oids => [
|
||||
$self->{results} = $options{snmp}->get_multiple_table(oids => [
|
||||
{ oid => $oid_ltmVirtualServEntry, start => $mapping->{old}->{AvailState}->{oid} },
|
||||
{ oid => $oid_ltmVsStatusEntry, start => $mapping->{new}->{AvailState}->{oid} },
|
||||
],
|
||||
|
@ -257,7 +183,7 @@ sub manage_selection {
|
|||
foreach my $oid (keys %{$self->{results}->{$branch}}) {
|
||||
next if ($oid !~ /^$mapping->{$map}->{AvailState}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping->{$map}, results => $self->{results}->{$branch}, instance => $instance);
|
||||
my $result = $options{snmp}->map_instance(mapping => $mapping->{$map}, results => $self->{results}->{$branch}, instance => $instance);
|
||||
|
||||
$result->{Name} = '';
|
||||
foreach (split /\./, $instance) {
|
||||
|
|
Loading…
Reference in New Issue