+ Enhance f5 bigip connection mode (WIP)
This commit is contained in:
parent
240f4fc8f6
commit
68df9b2e5c
|
@ -25,6 +25,51 @@ use base qw(centreon::plugins::mode);
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
|
my $maps_counters = {
|
||||||
|
global => [
|
||||||
|
{ set => {
|
||||||
|
label => 'client',
|
||||||
|
key_values => [ { name => 'client' } ],
|
||||||
|
output_template => 'Current client connections : %s',
|
||||||
|
perfdatas => [
|
||||||
|
{ label => 'Client', value => 'client_absolute', template => '%s',
|
||||||
|
min => 0, unit => 'con' },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ set => {
|
||||||
|
label => 'client-ssl',
|
||||||
|
key_values => [ { name => 'client_ssl' } ],
|
||||||
|
output_template => 'Current client SSL connections : %s',
|
||||||
|
perfdatas => [
|
||||||
|
{ label => 'ClientSSL', value => 'client_absolute', template => '%s',
|
||||||
|
min => 0, unit => 'con' },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ set => {
|
||||||
|
label => 'server',
|
||||||
|
key_values => [ { name => 'server' } ],
|
||||||
|
output_template => 'Current server connections: %s',
|
||||||
|
perfdatas => [
|
||||||
|
{ label => 'Server', value => 'server_absolute', template => '%s',
|
||||||
|
min => 0, unit => 'con' },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ set => {
|
||||||
|
label => 'server-ssl',
|
||||||
|
key_values => [ { name => 'server_ssl' } ],
|
||||||
|
output_template => 'Current server SSL connections : %s',
|
||||||
|
perfdatas => [
|
||||||
|
{ label => 'ServerSSL', value => 'server_ssl_absolute', template => '%s',
|
||||||
|
min => 0, unit => 'con' },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
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);
|
||||||
|
@ -33,12 +78,23 @@ sub new {
|
||||||
$self->{version} = '1.0';
|
$self->{version} = '1.0';
|
||||||
$options{options}->add_options(arguments =>
|
$options{options}->add_options(arguments =>
|
||||||
{
|
{
|
||||||
"warning-client:s" => { name => 'warning_client' },
|
"filter:s" => { name => 'filter' },
|
||||||
"critical-client:s" => { name => 'critical_client' },
|
|
||||||
"warning-server:s" => { name => 'warning_server' },
|
|
||||||
"critical-server:s" => { name => 'critical_server' },
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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(output => $self->{output}, perfdata => $self->{perfdata},
|
||||||
|
label => $_->{label});
|
||||||
|
$_->{obj}->set(%{$_->{set}});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,71 +102,93 @@ sub check_options {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
$self->SUPER::init(%options);
|
$self->SUPER::init(%options);
|
||||||
|
|
||||||
if (($self->{perfdata}->threshold_validate(label => 'warning-client', value => $self->{option_results}->{warning_client})) == 0) {
|
foreach my $key (('global')) {
|
||||||
$self->{output}->add_option_msg(short_msg => "Wrong warning-client threshold '" . $self->{option_results}->{option_results}->{warning_client} . "'.");
|
foreach (@{$maps_counters->{$key}}) {
|
||||||
$self->{output}->option_exit();
|
$_->{obj}->init(option_results => $self->{option_results});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (($self->{perfdata}->threshold_validate(label => 'critical-client', value => $self->{option_results}->{critical_client})) == 0) {
|
}
|
||||||
$self->{output}->add_option_msg(short_msg => "Wrong critical-client threshold '" . $self->{option_results}->{critical_client} . "'.");
|
|
||||||
$self->{output}->option_exit();
|
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}) && $self->{option_results}->{filter} ne '' &&
|
||||||
|
$_->{name} !~ /$self->{option_results}->{filter}/);
|
||||||
|
|
||||||
|
$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();
|
||||||
}
|
}
|
||||||
if (($self->{perfdata}->threshold_validate(label => 'warning-server', value => $self->{option_results}->{warning_server})) == 0) {
|
|
||||||
$self->{output}->add_option_msg(short_msg => "Wrong warning-server threshold '" . $self->{option_results}->{warning_client} . "'.");
|
my $exit = $self->{output}->get_most_critical(status => [ @exits ]);
|
||||||
$self->{output}->option_exit();
|
if (!$self->{output}->is_status(litteral => 1, value => $exit, compare => 'ok')) {
|
||||||
}
|
$self->{output}->output_add(severity => $exit,
|
||||||
if (($self->{perfdata}->threshold_validate(label => 'critical-server', value => $self->{option_results}->{critical_server})) == 0) {
|
short_msg => "$short_msg"
|
||||||
$self->{output}->add_option_msg(short_msg => "Wrong critical-server threshold '" . $self->{option_results}->{critical_client} . "'.");
|
);
|
||||||
$self->{output}->option_exit();
|
} else {
|
||||||
|
$self->{output}->output_add(short_msg => "$long_msg");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub run {
|
sub run {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
# $options{snmp} = snmp object
|
|
||||||
$self->{snmp} = $options{snmp};
|
$self->{snmp} = $options{snmp};
|
||||||
|
|
||||||
if ($self->{snmp}->is_snmpv1()) {
|
$self->manage_selection();
|
||||||
$self->{output}->add_option_msg(short_msg => "Need to use SNMP v2c or v3.");
|
|
||||||
$self->{output}->option_exit();
|
$self->run_global();
|
||||||
}
|
|
||||||
|
$self->{output}->display();
|
||||||
|
$self->{output}->exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
sub manage_selection {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $oid_sysStatClientCurConns = '.1.3.6.1.4.1.3375.2.1.1.2.1.8.0';
|
my $oid_sysStatClientCurConns = '.1.3.6.1.4.1.3375.2.1.1.2.1.8.0';
|
||||||
my $oid_sysStatServerCurConns = '.1.3.6.1.4.1.3375.2.1.1.2.1.15.0';
|
my $oid_sysStatServerCurConns = '.1.3.6.1.4.1.3375.2.1.1.2.1.15.0';
|
||||||
my $oid_sysClientsslStatCurConns = '.1.3.6.1.4.1.3375.2.1.1.2.9.2.0';
|
my $oid_sysClientsslStatCurConns = '.1.3.6.1.4.1.3375.2.1.1.2.9.2.0';
|
||||||
my $oid_sysServersslStatCurConns = '.1.3.6.1.4.1.3375.2.1.1.2.10.2.0';
|
my $oid_sysServersslStatCurConns = '.1.3.6.1.4.1.3375.2.1.1.2.10.2.0';
|
||||||
|
|
||||||
my $result = $self->{snmp}->get_leef(oids => [$oid_sysStatClientCurConns, $oid_sysStatServerCurConns, $oid_sysClientsslStatCurConns, $oid_sysServersslStatCurConns], nothing_quit => 1);
|
|
||||||
|
|
||||||
my $sysStatClientCurConns = $result->{$oid_sysStatClientCurConns};
|
if ($self->{snmp}->is_snmpv1()) {
|
||||||
my $sysStatServerCurConns = $result->{$oid_sysStatServerCurConns};
|
$self->{output}->add_option_msg(short_msg => "Need to use SNMP v2c or v3.");
|
||||||
my $sysClientsslStatCurConns = $result->{$oid_sysClientsslStatCurConns};
|
$self->{output}->option_exit();
|
||||||
my $sysServersslStatCurConns = $result->{$oid_sysServersslStatCurConns};
|
}
|
||||||
|
|
||||||
my $exit1 = $self->{perfdata}->threshold_check(value => $sysStatClientCurConns, threshold => [ { label => 'critical-client', 'exit_litteral' => 'critical' }, { label => 'warning-client', exit_litteral => 'warning' } ]);
|
$self->{global} = { };
|
||||||
my $exit2 = $self->{perfdata}->threshold_check(value => $sysStatServerCurConns, threshold => [ { label => 'critical-server', 'exit_litteral' => 'critical' }, { label => 'warning-server', exit_litteral => 'warning' } ]);
|
my $result = $self->{snmp}->get_leef(oids => [$oid_sysStatClientCurConns, $oid_sysStatServerCurConns,
|
||||||
my $exit = $self->{output}->get_most_critical(status => [ $exit1, $exit2 ]);
|
$oid_sysClientsslStatCurConns, $oid_sysServersslStatCurConns],
|
||||||
|
nothing_quit => 1);
|
||||||
$self->{output}->output_add(severity => $exit,
|
$self->{global} = {
|
||||||
short_msg => sprintf("Current connections : Client = %d (SSL: %d) , Server = %d (SSL: %d)",
|
client => $result->{$oid_sysStatClientCurConns},
|
||||||
$sysStatClientCurConns, $sysClientsslStatCurConns,
|
client_ssl => $result->{$oid_sysClientsslStatCurConns},
|
||||||
$sysStatServerCurConns, $sysServersslStatCurConns));
|
server => $result->{$oid_sysStatServerCurConns},
|
||||||
$self->{output}->perfdata_add(label => "Client", unit => 'con',
|
server_ssl => $result->{$oid_sysServersslStatCurConns},
|
||||||
value => $sysStatClientCurConns,
|
};
|
||||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-client'),
|
|
||||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-client'),
|
|
||||||
);
|
|
||||||
$self->{output}->perfdata_add(label => "Server", unit => 'con',
|
|
||||||
value => $sysStatServerCurConns,
|
|
||||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-server'),
|
|
||||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-server'),
|
|
||||||
);
|
|
||||||
$self->{output}->perfdata_add(label => "ClientSSL", unit => 'con',
|
|
||||||
value => $sysClientsslStatCurConns);
|
|
||||||
$self->{output}->perfdata_add(label => "ServerSSL", unit => 'con',
|
|
||||||
value => $sysServersslStatCurConns);
|
|
||||||
|
|
||||||
$self->{output}->display();
|
|
||||||
$self->{output}->exit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -123,21 +201,20 @@ Check current connections on F5 BIG IP device.
|
||||||
|
|
||||||
=over 8
|
=over 8
|
||||||
|
|
||||||
=item B<--warning-client>
|
=item B<--filter>
|
||||||
|
|
||||||
Threshold warning (current client connection number)
|
Filter (can be a regexp) to filter output.
|
||||||
|
Example to check SSL connections only : --filter='^client-ssl|server-ssl$'
|
||||||
|
|
||||||
=item B<--critical-client>
|
=item B<--warning-*>
|
||||||
|
|
||||||
Threshold critical (current client connection number)
|
Threshold warning.
|
||||||
|
Can be: 'client', 'server', 'client-ssl', 'server-ssl'.
|
||||||
|
|
||||||
=item B<--warning-server>
|
=item B<--critical-*>
|
||||||
|
|
||||||
Threshold warning (current server connection number)
|
Threshold critical.
|
||||||
|
Can be: 'client', 'server', 'client-ssl', 'server-ssl'.
|
||||||
=item B<--critical-server>
|
|
||||||
|
|
||||||
Threshold critical (current server connection number)
|
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue