feat(haproxy-web): new plugin for HAProxy Web Stats (#5385)

Co-authored-by: omercier <32134301+omercier@users.noreply.github.com>

Refs: CTOR-680
This commit is contained in:
Thibault S 2025-02-04 10:02:03 +01:00 committed by GitHub
parent bae0b56ea9
commit 9115be2fb1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 1632 additions and 1 deletions

View File

@ -0,0 +1,5 @@
{
"dependencies": [
"libjson-perl"
]
}

View File

@ -0,0 +1,9 @@
{
"pkg_name": "centreon-plugin-Applications-Haproxy-Web",
"pkg_summary": "Centreon Plugin to monitor HAProxy through JSON web stats page",
"plugin_name": "centreon_haproxy_web.pl",
"files": [
"centreon/plugins/script_custom.pm",
"apps/haproxy/web/"
]
}

View File

@ -0,0 +1,5 @@
{
"dependencies": [
"perl(JSON::XS)"
]
}

View File

@ -0,0 +1,212 @@
#
# Copyright 2025 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package apps::haproxy::web::custom::api;
use strict;
use warnings;
use centreon::plugins::http;
use JSON::XS;
sub new {
my ($class, %options) = @_;
my $self = {};
bless $self, $class;
if (!defined($options{output})) {
print "Class Custom: Need to specify 'output' argument.\n";
exit 3;
}
if (!defined($options{options})) {
$options{output}->add_option_msg(short_msg => "Class Custom: Need to specify 'options' argument.");
$options{output}->option_exit();
}
if (!defined($options{noptions})) {
$options{options}->add_options(arguments => {
'basic' => { name => 'basic' },
'credentials' => { name => 'credentials' },
'hostname:s' => { name => 'hostname' },
'ntlmv2' => { name => 'ntlmv2' },
'password:s' => { name => 'password' },
'port:s' => { name => 'port' },
'proto:s' => { name => 'proto' },
'timeout:s' => { name => 'timeout' },
'urlpath:s' => { name => 'url_path' },
'username:s' => { name => 'username' },
'critical-http-status:s' => { name => 'critical_http_status' },
'unknown-http-status:s' => { name => 'unknown_http_status' },
'warning-http-status:s' => { name => 'warning_http_status' }
});
}
$options{options}->add_help(package => __PACKAGE__, sections => 'API OPTIONS', once => 1);
$self->{output} = $options{output};
$self->{http} = centreon::plugins::http->new(%options, default_backend => 'curl');
return $self;
}
sub set_options {
my ($self, %options) = @_;
$self->{option_results} = $options{option_results};
}
sub set_defaults {}
sub check_options {
my ($self, %options) = @_;
$self->{hostname} = (defined($self->{option_results}->{hostname})) ? $self->{option_results}->{hostname} : undef;
$self->{port} = (defined($self->{option_results}->{port})) ? $self->{option_results}->{port} : 8404;
$self->{proto} = (defined($self->{option_results}->{proto})) ? $self->{option_results}->{proto} : 'http';
$self->{timeout} = (defined($self->{option_results}->{timeout})) ? $self->{option_results}->{timeout} : 10;
$self->{url_path} = (defined($self->{option_results}->{url_path})) ? $self->{option_results}->{url_path} : '/stats;json;';
$self->{unknown_http_status} = (defined($self->{option_results}->{unknown_http_status})) ? $self->{option_results}->{unknown_http_status} : '(%{http_code} < 200 or %{http_code} >= 300) and %{http_code} != 424';
$self->{warning_http_status} = (defined($self->{option_results}->{warning_http_status})) ? $self->{option_results}->{warning_http_status} : '';
$self->{critical_http_status} = (defined($self->{option_results}->{critical_http_status})) ? $self->{option_results}->{critical_http_status} : '';
if (!defined($self->{hostname}) || $self->{hostname} eq '') {
$self->{output}->add_option_msg(short_msg => "Need to specify --hostname option.");
$self->{output}->option_exit();
}
return 0;
}
sub build_options_for_httplib {
my ($self, %options) = @_;
$self->{option_results}->{hostname} = $self->{hostname};
$self->{option_results}->{timeout} = $self->{timeout};
$self->{option_results}->{port} = $self->{port};
$self->{option_results}->{proto} = $self->{proto};
$self->{option_results}->{timeout} = $self->{timeout};
}
sub settings {
my ($self, %options) = @_;
return if (defined($self->{settings_done}));
$self->build_options_for_httplib();
$self->{http}->add_header(key => 'Accept', value => 'application/json');
$self->{http}->add_header(key => 'Content-Type', value => 'application/json');
$self->{http}->set_options(%{$self->{option_results}});
$self->{settings_done} = 1;
}
sub get_hostname {
my ($self, %options) = @_;
return $self->{hostname};
}
sub get_stats {
my ($self, %options) = @_;
$self->settings();
my $response = $self->{http}->request(method => 'GET', url_path => $self->{url_path});
if (!defined($response) || $response eq '') {
$self->{output}->add_option_msg(short_msg => "API returns empty content [code: '" . $self->{http}->get_code() . "'] [message: '" . $self->{http}->get_message() . "']");
$self->{output}->option_exit();
}
my $decoded;
eval {
$decoded = JSON::XS->new->decode($response);
};
if ($@) {
$self->{output}->add_option_msg(short_msg => "Cannot decode response (add --debug option to display returned content)");
$self->{output}->option_exit();
}
if ($self->{http}->get_code() < 200 || $self->{http}->get_code() >= 300) {
$self->{output}->add_option_msg(short_msg => 'API request error (add --debug option to display returned content)');
$self->{output}->option_exit();
}
return $decoded;
}
1;
__END__
=head1 NAME
HAProxy HTTP custom mode for web json stats
=head1 API OPTIONS
HAProxy web stats
=over 8
=item B<--hostname>
IP address or FQDN of the HAProxy server.
=item B<--port>
Port used by the web server
=item B<--proto>
Specify https if needed (default: 'http')
=item B<--urlpath>
Define the path of the web page to get (default: '/stats;json;').
=item B<--credentials>
Specify this option if you are accessing a web page using authentication.
=item B<--username>
Specify the username for authentication (mandatory if --credentials is specified).
=item B<--password>
Specify the password for authentication (mandatory if --credentials is specified).
=item B<--basic>
Specify this option if you are accessing a web page using basic authentication and don't want a '401 UNAUTHORIZED' error to be logged on your web server.
Specify this option if you are accessing a web page using hidden basic authentication or you'll get a '404 NOT FOUND' error.
(use with --credentials)
=item B<--ntlmv2>
Specify this option if you are accessing a web page using NTLMv2 authentication (use with C<--credentials> and C<--port> options).
=item B<--timeout>
Define the timeout in seconds (default: 5).
=back
=cut

View File

@ -0,0 +1,505 @@
#
# Copyright 2025 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package apps::haproxy::web::mode::backendusage;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use Digest::MD5 qw(md5_hex);
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
sub prefix_backend_output {
my ($self, %options) = @_;
return "Backend '" . $options{instance_value}->{display} . "' ";
}
sub prefix_server_output {
my ($self, %options) = @_;
return "Server '" . $options{instance_value}->{svname} . "' ";
}
sub prefix_global_backend_output {
my ($self, %options) = @_;
return 'backend ';
}
sub backend_long_output {
my ($self, %options) = @_;
return "Backend '" . $options{instance_value}->{display} . "':";
}
sub custom_status_output {
my ($self, %options) = @_;
return sprintf("status: %s", $self->{result_values}->{status});
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{
name => 'backends',
type => 3,
cb_prefix_output => 'prefix_backend_output',
cb_long_output => 'backend_long_output',
message_multiple => 'All Backends are ok',
indent_long_output => ' ',
skipped_code => { -10 => 1 },
group => [
{
name => 'backend',
type => 0,
cb_prefix_output => 'prefix_global_backend_output'
},
{
name => 'servers',
type => 1,
display_long => 1,
cb_prefix_output => 'prefix_server_output',
message_multiple => 'Servers are ok',
skipped_code => { -10 => 1 }
}
]
}
];
$self->{maps_counters}->{backend} = [
{
label => 'backend-status',
type => 2,
critical_default => '%{status} !~ /UP/i',
set => {
key_values => [ { name => 'status' }, { name => 'pxname' } ],
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => \&catalog_status_threshold_ng
}
},
{ label => 'backend-current-queue', nlabel => 'backend.queue.current.count', set => {
key_values => [ { name => 'qcur' }, { name => 'pxname' } ],
output_template => 'current queue: %s',
perfdatas => [
{ template => '%s', min => 0, label_extra_instance => 1, instance_use => 'pxname' }
]
}
},
{ label => 'backend-current-session-rate', nlabel => 'backend.session.current.rate.countpersecond', set => {
key_values => [ { name => 'rate' }, { name => 'pxname' } ],
output_template => 'current session rate: %s/s',
perfdatas => [
{ template => '%s', min => 0, label_extra_instance => 1, instance_use => 'pxname' }
]
}
},
{ label => 'backend-max-session-rate', nlabel => 'backend.session.max.rate.countpersecond', set => {
key_values => [ { name => 'rate_max' }, { name => 'pxname' } ],
output_template => 'max session rate: %s/s',
perfdatas => [
{ template => '%s', min => 0, label_extra_instance => 1, instance_use => 'pxname' }
]
}
},
{ label => 'backend-current-sessions', nlabel => 'backend.sessions.current.count', set => {
key_values => [ { name => 'scur' }, { name => 'pxname' } ],
output_template => 'current sessions: %s',
perfdatas => [
{ template => '%s', min => 0, label_extra_instance => 1, instance_use => 'pxname' }
]
}
},
{ label => 'backend-total-sessions', nlabel => 'backend.sessions.total.count', set => {
key_values => [ { name => 'stot', diff => 1 }, { name => 'pxname' } ],
output_template => 'total sessions: %s',
perfdatas => [
{ template => '%s', min => 0, label_extra_instance => 1, instance_use => 'pxname' }
]
}
},
{ label => 'backend-traffic-in', nlabel => 'backend.traffic.in.bitpersecond', set => {
key_values => [ { name => 'bin', per_second => 1 }, { name => 'pxname' } ],
output_template => 'traffic in: %s %s/s',
output_change_bytes => 2,
perfdatas => [
{ template => '%.2f', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'pxname' }
]
}
},
{ label => 'backend-traffic-out', nlabel => 'backend.traffic.out.bitpersecond', set => {
key_values => [ { name => 'bout', per_second => 1 }, { name => 'pxname' } ],
output_template => 'traffic out: %s %s/s',
output_change_bytes => 2,
perfdatas => [
{ template => '%.2f', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'pxname' }
]
}
},
{ label => 'backend-denied-requests', nlabel => 'backend.requests.denied.count', set => {
key_values => [ { name => 'dreq' }, { name => 'pxname' } ],
output_template => 'denied requests: %s',
perfdatas => [
{ template => '%s', min => 0, label_extra_instance => 1, instance_use => 'pxname' }
]
}
},
{ label => 'backend-denied-responses', nlabel => 'backend.responses.denied.count', set => {
key_values => [ { name => 'dresp' }, { name => 'pxname' } ],
output_template => 'denied responses: %s',
perfdatas => [
{ template => '%s', min => 0, label_extra_instance => 1, instance_use => 'pxname' }
]
}
},
{ label => 'backend-connections-errors', nlabel => 'backend.connections.error.count', set => {
key_values => [ { name => 'econ' }, { name => 'pxname' } ],
output_template => 'connection errors: %s',
perfdatas => [
{ template => '%s', min => 0, label_extra_instance => 1, instance_use => 'pxname' }
]
}
},
{ label => 'backend-responses-errors', nlabel => 'backend.responses.error.count', set => {
key_values => [ { name => 'eresp' }, { name => 'pxname' } ],
output_template => 'responses errors: %s',
perfdatas => [
{ template => '%s', min => 0, label_extra_instance => 1, instance_use => 'pxname' }
]
}
}
];
$self->{maps_counters}->{servers} = [
{
label => 'server-status',
type => 2,
critical_default => '%{status} !~ /UP/i',
set => {
key_values => [ { name => 'status' }, { name => 'svname' } ],
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => \&catalog_status_threshold_ng
}
},
{ label => 'server-current-sessions', nlabel => 'server.sessions.current.count', set => {
key_values => [ { name => 'scur' }, { name => 'svname' } ],
output_template => 'current sessions: %s',
perfdatas => [
{ template => '%s', min => 0, label_extra_instance => 1, instance_use => 'svname'}
]
}
},
{ label => 'server-current-session-rate', nlabel => 'server.session.current.rate.countpersecond', set => {
key_values => [ { name => 'rate' }, { name => 'svname' } ],
output_template => 'current session rate: %s/s',
perfdatas => [
{ template => '%s', min => 0, label_extra_instance => 1, instance_use => 'svname' }
]
}
},
{ label => 'server-max-session-rate', nlabel => 'server.session.max.rate.countpersecond', set => {
key_values => [ { name => 'rate_max' }, { name => 'svname' } ],
output_template => 'max session rate: %s/s',
perfdatas => [
{ template => '%s', min => 0, label_extra_instance => 1, instance_use => 'svname' }
]
}
},
{ label => 'server-denied-responses', nlabel => 'server.responses.denied.count', set => {
key_values => [ { name => 'dresp' }, { name => 'svname' } ],
output_template => 'denied responses: %s',
perfdatas => [
{ template => '%s', min => 0, label_extra_instance => 1, instance_use => 'svname' }
]
}
},
{ label => 'server-connections-errors', nlabel => 'server.connections.error.count', set => {
key_values => [ { name => 'econ' }, { name => 'svname' } ],
output_template => 'connection errors: %s',
perfdatas => [
{ template => '%s', min => 0, label_extra_instance => 1, instance_use => 'svname' }
]
}
},
{ label => 'server-responses-errors', nlabel => 'server.responses.error.count', set => {
key_values => [ { name => 'eresp' }, { name => 'svname' } ],
output_template => 'responses errors: %s',
perfdatas => [
{ template => '%s', min => 0, label_extra_instance => 1, instance_use => 'svname' }
]
}
}
];
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1, force_new_perfdata => 1);
bless $self, $class;
$options{options}->add_options(arguments => {
'add-servers' => { name => 'add_servers' },
'filter-name:s' => { name => 'filter_name' }
});
return $self;
}
sub manage_selection {
my ($self, %options) = @_;
my $result = $options{custom}->get_stats();
my $stats;
foreach (@$result) {
foreach my $entry (@$_) {
if ($entry->{objType} eq 'Backend') {
$stats->{$entry->{proxyId}}->{$entry->{field}->{name}} = $entry->{value}->{value};
}
if ($entry->{objType} eq 'Server') {
$stats->{$entry->{proxyId}}->{servers}->{$entry->{id}}->{$entry->{field}->{name}} = $entry->{value}->{value};
}
}
}
foreach (keys %$stats) {
my $name;
$name = $stats->{$_}->{pxname};
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
$name !~ /$self->{option_results}->{filter_name}/) {
$self->{output}->output_add(long_msg => "skipping Backend '" . $name . "'.", debug => 1);
next;
}
if (defined($self->{option_results}->{add_servers})) {
$self->{backends}->{$_}->{servers} = $stats->{$_}->{servers};
}
$self->{backends}->{$_}->{backend} = $stats->{$_};
$self->{backends}->{$_}->{display} = $name;
}
if (scalar(keys %{$self->{backends}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "No Backend found.");
$self->{output}->option_exit();
}
$self->{cache_name} = 'haproxy_' . $self->{mode} . '_' . $options{custom}->get_hostname() . '_' .
(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;
__END__
=head1 MODE
Check HAProxy backend usage.
=over 8
=item B<--add-servers>
Also display and monitor Servers related to a given backend.
=item B<--filter-counters>
Define which counters should appear in the performance data (metrics).
This option will be treated as a regular expression.
Example: C<--filter-counters='^total-connections$'>.
=item B<--filter-name>
Define which backends should be monitored based on their names.
This option will be treated as a regular expression.
=item B<--warning-backend-status>
Define the conditions to match for the backend status to be WARNING.
You can use the following variables: %{status}.
Example: C<--warning-backend-status='%{status} !~ /UP/i'>
=item B<--critical-backend-status>
Define the conditions to match for the backend status to be CRITICAL.
Default: C<'%{status} !~ /UP/i'>.
You can use the following variables: C<%{status}>.
Example: C<--critical-backend-status='%{status} !~ /UP/i'>
=item B<--warning-server-status>
Define the conditions to match for the server status to be WARNING.
You can use the following variables: C<%{status}>.
Example: C<--warning-backend-status='%{status} !~ /UP/i'>
=item B<--critical-server-status>
Define the conditions to match for the status to be CRITICAL. Default: C<'%{status} !~ /UP/i'>.
You can use the following variables: C<%{status}>.
Example: C<--critical-backend-status='%{status} !~ /UP/i'>
=item B<--warning-backend-current-queue>
Thresholds.
=item B<--critical-backend-current-queue>
Thresholds.
=item B<--warning-backend-current-session-rate>
Thresholds.
=item B<--critical-backend-current-session-rate>
Thresholds.
=item B<--warning-backend-max-session-rate>
Thresholds.
=item B<--critical-backend-max-session-rate>
Thresholds.
=item B<--warning-backend-current-sessions>
Thresholds.
=item B<--critical-backend-current-sessions>
Thresholds.
=item B<--warning-backend-total-sessions>
Thresholds.
=item B<--critical-backend-total-sessions>
Thresholds.
=item B<--warning-backend-traffic-in>
Thresholds in b/s.
=item B<--critical-backend-traffic-in>
Thresholds in b/s.
=item B<--warning-backend-traffic-out>
Thresholds in b/s.
=item B<--critical-backend-traffic-out>
Thresholds in b/s.
=item B<--warning-backend-denied-requests>
Thresholds.
=item B<--critical-backend-denied-requests>
Thresholds.
=item B<--warning-backend-denied-responses>
Thresholds.
=item B<--critical-backend-denied-responses>
Thresholds.
=item B<--warning-backend-connections-errors>
Thresholds.
=item B<--critical-backend-connections-errors>
Thresholds.
=item B<--warning-backend-responses-errors>
Thresholds.
=item B<--critical-backend-responses-errors>
Thresholds.
=item B<--warning-server-current-sessions>
Thresholds.
=item B<--critical-server-current-sessions>
Thresholds.
=item B<--warning-server-current-session-rate>
Thresholds.
=item B<--critical-server-current-session-rate>
Thresholds.
=item B<--warning-server-max-session-rate>
Thresholds.
=item B<--critical-server-max-session-rate>
Thresholds.
=item B<--warning-server-denied-responses>
Thresholds.
=item B<--critical-server-denied-responses>
Thresholds.
=item B<--warning-server-connections-errors>
Thresholds.
=item B<--critical-server-connections-errors>
Thresholds.
=item B<--warning-server-responses-errors>
Thresholds.
=item B<--critical-server-responses-errors>
Thresholds.
=back
=cut

View File

@ -0,0 +1,476 @@
#
# Copyright 2025 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package apps::haproxy::web::mode::frontendusage;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use Digest::MD5 qw(md5_hex);
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
sub prefix_frontend_output {
my ($self, %options) = @_;
return "Frontend '" . $options{instance_value}->{display} . "' ";
}
sub prefix_listener_output {
my ($self, %options) = @_;
return "Listener '" . $options{instance_value}->{svname} . "' ";
}
sub prefix_global_frontend_output {
my ($self, %options) = @_;
return 'frontend ';
}
sub frontend_long_output {
my ($self, %options) = @_;
return "Frontend '" . $options{instance_value}->{display} . "':";
}
sub custom_status_output {
my ($self, %options) = @_;
return sprintf("status: %s", $self->{result_values}->{status});
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'frontends', type => 3, cb_prefix_output => 'prefix_frontend_output', cb_long_output => 'frontend_long_output', message_multiple => 'All frontends are ok', indent_long_output => ' ', skipped_code => { -10 => 1 },
group => [
{ name => 'frontend', type => 0, cb_prefix_output => 'prefix_global_frontend_output' },
{ name => 'listeners', type => 1, display_long => 1, cb_prefix_output => 'prefix_listener_output', message_multiple => 'listeners are ok', skipped_code => { -10 => 1 } }
]
}
];
$self->{maps_counters}->{frontend} = [
{
label => 'frontend-status',
type => 2,
critical_default => '%{status} !~ /OPEN/i',
set => {
key_values => [ { name => 'status' }, { name => 'pxname' } ],
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => \&catalog_status_threshold_ng
}
},
{ label => 'frontend-current-session-rate', nlabel => 'frontend.session.current.rate.countpersecond', set => {
key_values => [ { name => 'rate' }, { name => 'pxname' } ],
output_template => 'current session rate: %s/s',
perfdatas => [
{ template => '%s', min => 0, label_extra_instance => 1, instance_use => 'pxname' }
]
}
},
{ label => 'frontend-max-session-rate', nlabel => 'frontend.session.max.rate.countpersecond', set => {
key_values => [ { name => 'rate_max' }, { name => 'pxname' } ],
output_template => 'max session rate: %s/s',
perfdatas => [
{ template => '%s', min => 0, label_extra_instance => 1, instance_use => 'pxname' }
]
}
},
{ label => 'frontend-current-sessions', nlabel => 'frontend.sessions.current.count', set => {
key_values => [ { name => 'scur' }, { name => 'pxname' } ],
output_template => 'current sessions: %s',
perfdatas => [
{ template => '%s', min => 0, label_extra_instance => 1, instance_use => 'pxname' }
]
}
},
{ label => 'frontend-total-sessions', nlabel => 'frontend.sessions.total.count', set => {
key_values => [ { name => 'stot' }, { name => 'pxname' } ],
output_template => 'total sessions: %s',
perfdatas => [
{ template => '%s', min => 0, label_extra_instance => 1, instance_use => 'pxname' }
]
}
},
{ label => 'frontend-max-sessions', nlabel => 'frontend.sessions.maximum.count', set => {
key_values => [ { name => 'smax' }, { name => 'pxname' } ],
output_template => 'max sessions: %s',
perfdatas => [
{ template => '%s', min => 0, label_extra_instance => 1, instance_use => 'pxname' }
]
}
},
{ label => 'frontend-traffic-in', nlabel => 'frontend.traffic.in.bitpersecond', set => {
key_values => [ { name => 'bin', per_second => 1 }, { name => 'pxname' } ],
output_template => 'traffic in: %s %s/s',
output_change_bytes => 2,
perfdatas => [
{ template => '%.2f', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'pxname' }
]
}
},
{ label => 'frontend-traffic-out', nlabel => 'frontend.traffic.out.bitpersecond', set => {
key_values => [ { name => 'bout', per_second => 1 }, { name => 'pxname' } ],
output_template => 'traffic out: %s %s/s',
output_change_bytes => 2,
perfdatas => [
{ template => '%.2f', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'pxname' }
]
}
},
{ label => 'frontend-denied-requests', nlabel => 'frontend.requests.denied.count', set => {
key_values => [ { name => 'dreq' }, { name => 'pxname' } ],
output_template => 'denied requests: %s',
perfdatas => [
{ template => '%s', min => 0, label_extra_instance => 1, instance_use => 'pxname' }
]
}
},
{ label => 'frontend-denied-responses', nlabel => 'frontend.responses.denied.count', set => {
key_values => [ { name => 'dresp' }, { name => 'pxname' } ],
output_template => 'denied responses: %s',
perfdatas => [
{ template => '%s', min => 0, label_extra_instance => 1, instance_use => 'pxname' }
]
}
},
{ label => 'frontend-errors-requests', nlabel => 'frontend.requests.error.count', set => {
key_values => [ { name => 'ereq' }, { name => 'pxname' } ],
output_template => 'error requests: %s',
perfdatas => [
{ template => '%s', min => 0, label_extra_instance => 1, instance_use => 'pxname' }
]
}
}
];
$self->{maps_counters}->{listeners} = [
{
label => 'listener-status',
type => 2,
critical_default => '%{status} !~ /OPEN/i',
set => {
key_values => [ { name => 'status' }, { name => 'pxname' } ],
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => \&catalog_status_threshold_ng
}
},
{ label => 'listener-current-sessions', nlabel => 'listener.sessions.current.count', set => {
key_values => [ { name => 'scur' }, { name => 'svname' } ],
output_template => 'current sessions: %s',
perfdatas => [
{ template => '%s', min => 0, label_extra_instance => 1, instance_use => 'svname' }
]
}
},
{ label => 'listener-denied-requests', nlabel => 'listener.requests.denied.count', set => {
key_values => [ { name => 'dreq' }, { name => 'svname' } ],
output_template => 'denied requests: %s',
perfdatas => [
{ template => '%s', min => 0, label_extra_instance => 1, instance_use => 'svname' }
]
}
},
{ label => 'listener-denied-responses', nlabel => 'listener.responses.denied.count', set => {
key_values => [ { name => 'dresp' }, { name => 'svname' } ],
output_template => 'denied responses: %s',
perfdatas => [
{ template => '%s', min => 0, label_extra_instance => 1, instance_use => 'svname' }
]
}
},
{ label => 'listener-errors-requests', nlabel => 'listener.requests.error.count', set => {
key_values => [ { name => 'ereq' }, { name => 'svname' } ],
output_template => 'error requests: %s',
perfdatas => [
{ template => '%s', min => 0, label_extra_instance => 1, instance_use => 'svname' }
]
}
},
{ label => 'listener-traffic-in', nlabel => 'listener.traffic.in.bitpersecond', set => {
key_values => [ { name => 'bin', per_second => 1 }, { name => 'pxname' } ],
output_template => 'traffic in: %s %s/s',
output_change_bytes => 2,
perfdatas => [
{ template => '%.2f', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'svname' }
]
}
},
{ label => 'listener-traffic-out', nlabel => 'listener.traffic.out.bitpersecond', set => {
key_values => [ { name => 'bout', per_second => 1 }, { name => 'svname' } ],
output_template => 'traffic out: %s %s/s',
output_change_bytes => 2,
perfdatas => [
{ template => '%.2f', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'svname' }
]
}
}
];
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1, force_new_perfdata => 1);
bless $self, $class;
$options{options}->add_options(arguments => {
'add-listeners' => { name => 'add_listeners' },
'filter-name:s' => { name => 'filter_name' }
});
return $self;
}
sub manage_selection {
my ($self, %options) = @_;
my $result = $options{custom}->get_stats();
my $stats;
foreach (@$result) {
foreach my $entry (@$_) {
if ($entry->{objType} eq 'Frontend') {
$stats->{$entry->{proxyId}}->{$entry->{field}->{name}} = $entry->{value}->{value};
}
if ($entry->{objType} eq 'Listener') {
$stats->{$entry->{proxyId}}->{listeners}->{$entry->{id}}->{$entry->{field}->{name}} = $entry->{value}->{value};
}
}
}
foreach (keys %$stats) {
my $name;
$name = $stats->{$_}->{pxname};
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
$name !~ /$self->{option_results}->{filter_name}/) {
$self->{output}->output_add(long_msg => "skipping frontend '" . $name . "'.", debug => 1);
next;
}
if (defined($self->{option_results}->{add_listeners})) {
$self->{frontends}->{$_}->{listeners} = $stats->{$_}->{listeners};
}
$self->{frontends}->{$_}->{frontend} = $stats->{$_};
$self->{frontends}->{$_}->{display} = $name;
}
if (scalar(keys %{$self->{frontends}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "No Frontend found.");
$self->{output}->option_exit();
}
$self->{cache_name} = 'haproxy_' . $self->{mode} . '_' . $options{custom}->get_hostname() . '_' .
(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;
__END__
=head1 MODE
Check HAProxy frontend usage.
=over 8
=item B<--add-listeners>
Also display and monitor listeners related to a given frontend.
=item B<--filter-counters>
Define which counters should appear in the performance data (metrics).
This option will be treated as a regular expression.
Example: --filter-counters='^total-connections$'.
=item B<--filter-name>
Define which frontends should be monitored based on their names.
This option will be treated as a regular expression.
=item B<--warning-frontend-status>
Define the conditions to match for the status to be B<WARNING>.
You can use the following variables: C<%{status}>.
Example: C<--warning-frontend-status='%{status} !~ /UP/i'>
=item B<--critical-frontend-status>
Define the conditions to match for the status to be B<CRITICAL>. Default: C<%{status} !~ /OPEN/i>.
You can use the following variables: C<%{status}>.
Example: C<--critical-frontend-status='%{status} !~ /UP/i'>
=item B<--warning-listener-status>
Define the conditions to match for the status to be B<WARNING>
You can use the following variables: C<%{status}>.
Example: C<--warning-listener-status='%{status} !~ /UP/i'>
=item B<--critical-listener-status>
Define the conditions to match for the status to be B<CRITICAL>. Default: C<%{status} !~ /OPEN/i>.
You can use the following variables: C<%{status}>.
Example: C<--critical-listener-status='%{status} !~ /UP/i'>
=item B<--warning-frontend-current-session-rate>
Thresholds.
=item B<--critical-frontend-current-session-rate>
Thresholds.
=item B<--warning-frontend-max-session-rate>
Thresholds.
=item B<--critical-frontend-max-session-rate>
Thresholds.
=item B<--warning-frontend-current-sessions>
Thresholds.
=item B<--critical-frontend-current-sessions>
Thresholds.
=item B<--warning-frontend-total-sessions>
Thresholds.
=item B<--critical-frontend-total-sessions>
Thresholds.
=item B<--warning-frontend-max-sessions>
Thresholds.
=item B<--critical-frontend-max-sessions>
Thresholds.
=item B<--warning-frontend-traffic-in>
Thresholds in b/s.
=item B<--critical-frontend-traffic-in>
Thresholds in b/s.
=item B<--warning-frontend-traffic-out>
Thresholds in b/s.
=item B<--critical-frontend-traffic-out>
Thresholds in b/s.
=item B<--warning-frontend-denied-requests>
Thresholds.
=item B<--critical-frontend-denied-requests>
Thresholds.
=item B<--warning-frontend-denied-responses>
Thresholds.
=item B<--critical-frontend-denied-responses>
Thresholds.
=item B<--warning-frontend-errors-requests>
Thresholds.
=item B<--critical-frontend-errors-requests>
Thresholds.
=item B<--warning-listener-current-sessions>
Thresholds.
=item B<--critical-listener-current-sessions>
Thresholds.
=item B<--warning-listener-denied-requests>
Thresholds.
=item B<--critical-listener-denied-requests>
Thresholds.
=item B<--warning-listener-denied-responses>
Thresholds.
=item B<--critical-listener-denied-responses>
Thresholds.
=item B<--warning-listener-errors-requests>
Thresholds.
=item B<--critical-listener-errors-requests>
Thresholds.
=item B<--warning-listener-traffic-in>
Thresholds in b/s.
=item B<--critical-listener-traffic-in>
Thresholds in b/s.
=item B<--warning-listener-traffic-out>
Thresholds in b/s.
=item B<--critical-listener-traffic-out>
Thresholds in b/s.
=back
=cut

View File

@ -0,0 +1,117 @@
#
# Copyright 2025 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package apps::haproxy::web::mode::listobjects;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
bless $self, $class;
$options{options}->add_options(arguments => {
'filter-name:s' => { name => 'filter_name' },
'filter-object-type:s' => { name => 'filter_objtype', default => 'frontend|backend' }
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
}
sub manage_selection {
my ($self, %options) = @_;
my $results = $options{custom}->get_stats();
my $backends;
foreach (@$results) {
foreach my $entry (@$_) {
next if (defined($self->{option_results}->{filter_objtype}) && $self->{option_results}->{filter_objtype} ne ''
&& lc($entry->{objType}) !~ /$self->{option_results}->{filter_objtype}/);
$backends->{$entry->{proxyId}}->{type} = lc($entry->{objType});
next if ($entry->{field}->{name} !~ /^(pxname|status)$/);
$backends->{$entry->{proxyId}}->{$entry->{field}->{name}} = $entry->{value}->{value};
}
}
return $backends;
}
sub run {
my ($self, %options) = @_;
my $backends = $self->manage_selection(%options);
foreach (sort keys %$backends) {
$self->{output}->output_add(
long_msg => sprintf("[name = %s][status = %s][type = %s]", $backends->{$_}->{pxname}, $backends->{$_}->{status}, $backends->{$_}->{type})
);
}
$self->{output}->output_add(severity => 'OK', short_msg => 'HAProxy objects:');
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
sub disco_format {
my ($self, %options) = @_;
$self->{output}->add_disco_format(elements => ['name','status','type']);
}
sub disco_show {
my ($self, %options) = @_;
my $backends = $self->manage_selection(%options);
foreach (sort keys %$backends) {
$self->{output}->add_disco_entry(
name => $backends->{$_}->{pxname},
status => $backends->{$_}->{status},
type => $backends->{$_}->{type},
);
}
}
1;
__END__
=head1 MODE
List HAProxy objects (Backends & Frontends).
=over 8
=item B<--filter-object-type>
Filter object type (can be a regexp).
=item B<--filter-name>
Filter object name (can be a regexp).
=back
=cut

View File

@ -0,0 +1,51 @@
#
# Copyright 2025 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package apps::haproxy::web::plugin;
use strict;
use warnings;
use base qw(centreon::plugins::script_custom);
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$self->{modes} = {
'backend-usage' => 'apps::haproxy::web::mode::backendusage',
'frontend-usage' => 'apps::haproxy::web::mode::frontendusage',
'list-objects' => 'apps::haproxy::web::mode::listobjects'
};
$self->{custom_modes}->{api} = 'apps::haproxy::web::custom::api';
return $self;
}
1;
__END__
=head1 PLUGIN DESCRIPTION
Check HAProxy stats using HTTP stats page.
=cut

View File

@ -0,0 +1,45 @@
*** Settings ***
Documentation HAProxy Backend Usage Monitoring
Resource ${CURDIR}${/}..${/}..${/}..${/}resources/import.resource
Suite Setup Start Mockoon ${MOCKOON_JSON}
Suite Teardown Stop Mockoon
Test Timeout 120s
*** Variables ***
${MOCKOON_JSON} ${CURDIR}${/}mockoon.json
${cmd} ${CENTREON_PLUGINS}
... --plugin=apps::haproxy::web::plugin
... --mode=backend-usage
... --hostname=${HOSTNAME}
... --username='username'
... --password='password'
... --proto='http'
... --port=${APIPORT}
*** Test Cases ***
backend-usage ${tc}
[Tags] mockoon restapi
${command} Catenate
... ${CMD}
... --filter-name='${filter_name}'
... ${extra_options}
Ctn Run Command And Check Result As Strings ${command} ${expected_result}
Examples: tc filter_name extra_options expected_result --
... 1 STATIC_BG_IMAGE ${EMPTY} OK: Backend 'STATIC_BG_IMAGE' backend status: UP, current queue: 0, current session rate: 0/s, max session rate: 1/s, current sessions: 0, backend-total-sessions : Buffer creation, backend-traffic-in : Buffer creation, backend-traffic-out : Buffer creation, denied requests: 0, denied responses: 0, connection errors: 0, responses errors: 0 | 'STATIC_BG_IMAGE#backend.queue.current.count'=0;;;0; 'STATIC_BG_IMAGE#backend.session.current.rate.countpersecond'=0;;;0; 'STATIC_BG_IMAGE#backend.session.max.rate.countpersecond'=1;;;0; 'STATIC_BG_IMAGE#backend.sessions.current.count'=0;;;0; 'STATIC_BG_IMAGE#backend.requests.denied.count'=0;;;0; 'STATIC_BG_IMAGE#backend.responses.denied.count'=0;;;0; 'STATIC_BG_IMAGE#backend.connections.error.count'=0;;;0; 'STATIC_BG_IMAGE#backend.responses.error.count'=0;;;0;
... 2 STATIC_BG_IMAGE --warning-backend-max-session-rate=0:0 WARNING: Backend 'STATIC_BG_IMAGE' backend max session rate: 1/s | 'STATIC_BG_IMAGE#backend.queue.current.count'=0;;;0; 'STATIC_BG_IMAGE#backend.session.current.rate.countpersecond'=0;;;0; 'STATIC_BG_IMAGE#backend.session.max.rate.countpersecond'=1;0:0;;0; 'STATIC_BG_IMAGE#backend.sessions.current.count'=0;;;0; 'STATIC_BG_IMAGE#backend.sessions.total.count'=0;;;0; 'STATIC_BG_IMAGE#backend.traffic.in.bitpersecond'=0.00b/s;;;0; 'STATIC_BG_IMAGE#backend.traffic.out.bitpersecond'=0.00b/s;;;0; 'STATIC_BG_IMAGE#backend.requests.denied.count'=0;;;0; 'STATIC_BG_IMAGE#backend.responses.denied.count'=0;;;0; 'STATIC_BG_IMAGE#backend.connections.error.count'=0;;;0; 'STATIC_BG_IMAGE#backend.responses.error.count'=0;;;0;
... 3 STATIC_BG_IMAGE --critical-backend-max-session-rate=0:0 CRITICAL: Backend 'STATIC_BG_IMAGE' backend max session rate: 1/s | 'STATIC_BG_IMAGE#backend.queue.current.count'=0;;;0; 'STATIC_BG_IMAGE#backend.session.current.rate.countpersecond'=0;;;0; 'STATIC_BG_IMAGE#backend.session.max.rate.countpersecond'=1;;0:0;0; 'STATIC_BG_IMAGE#backend.sessions.current.count'=0;;;0; 'STATIC_BG_IMAGE#backend.sessions.total.count'=0;;;0; 'STATIC_BG_IMAGE#backend.traffic.in.bitpersecond'=0.00b/s;;;0; 'STATIC_BG_IMAGE#backend.traffic.out.bitpersecond'=0.00b/s;;;0; 'STATIC_BG_IMAGE#backend.requests.denied.count'=0;;;0; 'STATIC_BG_IMAGE#backend.responses.denied.count'=0;;;0; 'STATIC_BG_IMAGE#backend.connections.error.count'=0;;;0; 'STATIC_BG_IMAGE#backend.responses.error.count'=0;;;0;
... 4 APP-IHM ${EMPTY} OK: Backend 'APP-IHM' backend status: UP, current queue: 0, current session rate: 1/s, max session rate: 25/s, current sessions: 0, backend-total-sessions : Buffer creation, backend-traffic-in : Buffer creation, backend-traffic-out : Buffer creation, denied requests: 0, denied responses: 0, connection errors: 1, responses errors: 0 | 'APP-IHM#backend.queue.current.count'=0;;;0; 'APP-IHM#backend.session.current.rate.countpersecond'=1;;;0; 'APP-IHM#backend.session.max.rate.countpersecond'=25;;;0; 'APP-IHM#backend.sessions.current.count'=0;;;0; 'APP-IHM#backend.requests.denied.count'=0;;;0; 'APP-IHM#backend.responses.denied.count'=0;;;0; 'APP-IHM#backend.connections.error.count'=1;;;0; 'APP-IHM#backend.responses.error.count'=0;;;0;
... 5 APP-IHM --warning-backend-current-session-rate=0:0 WARNING: Backend 'APP-IHM' backend current session rate: 1/s | 'APP-IHM#backend.queue.current.count'=0;;;0; 'APP-IHM#backend.session.current.rate.countpersecond'=1;0:0;;0; 'APP-IHM#backend.session.max.rate.countpersecond'=25;;;0; 'APP-IHM#backend.sessions.current.count'=0;;;0; 'APP-IHM#backend.sessions.total.count'=0;;;0; 'APP-IHM#backend.traffic.in.bitpersecond'=0.00b/s;;;0; 'APP-IHM#backend.traffic.out.bitpersecond'=0.00b/s;;;0; 'APP-IHM#backend.requests.denied.count'=0;;;0; 'APP-IHM#backend.responses.denied.count'=0;;;0; 'APP-IHM#backend.connections.error.count'=1;;;0; 'APP-IHM#backend.responses.error.count'=0;;;0;
... 6 APP-IHM --critical-backend-current-session-rate=0:0 CRITICAL: Backend 'APP-IHM' backend current session rate: 1/s | 'APP-IHM#backend.queue.current.count'=0;;;0; 'APP-IHM#backend.session.current.rate.countpersecond'=1;;0:0;0; 'APP-IHM#backend.session.max.rate.countpersecond'=25;;;0; 'APP-IHM#backend.sessions.current.count'=0;;;0; 'APP-IHM#backend.sessions.total.count'=0;;;0; 'APP-IHM#backend.traffic.in.bitpersecond'=0.00b/s;;;0; 'APP-IHM#backend.traffic.out.bitpersecond'=0.00b/s;;;0; 'APP-IHM#backend.requests.denied.count'=0;;;0; 'APP-IHM#backend.responses.denied.count'=0;;;0; 'APP-IHM#backend.connections.error.count'=1;;;0; 'APP-IHM#backend.responses.error.count'=0;;;0;
... 7 APP-RIA ${EMPTY} OK: Backend 'APP-RIA' backend status: UP, current queue: 0, current session rate: 0/s, max session rate: 0/s, current sessions: 0, backend-total-sessions : Buffer creation, backend-traffic-in : Buffer creation, backend-traffic-out : Buffer creation, denied requests: 0, denied responses: 0, connection errors: 0, responses errors: 0 | 'APP-RIA#backend.queue.current.count'=0;;;0; 'APP-RIA#backend.session.current.rate.countpersecond'=0;;;0; 'APP-RIA#backend.session.max.rate.countpersecond'=0;;;0; 'APP-RIA#backend.sessions.current.count'=0;;;0; 'APP-RIA#backend.requests.denied.count'=0;;;0; 'APP-RIA#backend.responses.denied.count'=0;;;0; 'APP-RIA#backend.connections.error.count'=0;;;0; 'APP-RIA#backend.responses.error.count'=0;;;0;
... 8 APP-RIA --warning-backend-denied-requests=1:1 WARNING: Backend 'APP-RIA' backend denied requests: 0 | 'APP-RIA#backend.queue.current.count'=0;;;0; 'APP-RIA#backend.session.current.rate.countpersecond'=0;;;0; 'APP-RIA#backend.session.max.rate.countpersecond'=0;;;0; 'APP-RIA#backend.sessions.current.count'=0;;;0; 'APP-RIA#backend.sessions.total.count'=0;;;0; 'APP-RIA#backend.traffic.in.bitpersecond'=0.00b/s;;;0; 'APP-RIA#backend.traffic.out.bitpersecond'=0.00b/s;;;0; 'APP-RIA#backend.requests.denied.count'=0;1:1;;0; 'APP-RIA#backend.responses.denied.count'=0;;;0; 'APP-RIA#backend.connections.error.count'=0;;;0; 'APP-RIA#backend.responses.error.count'=0;;;0;
... 9 APP-RIA --critical-backend-denied-requests=1:1 CRITICAL: Backend 'APP-RIA' backend denied requests: 0 | 'APP-RIA#backend.queue.current.count'=0;;;0; 'APP-RIA#backend.session.current.rate.countpersecond'=0;;;0; 'APP-RIA#backend.session.max.rate.countpersecond'=0;;;0; 'APP-RIA#backend.sessions.current.count'=0;;;0; 'APP-RIA#backend.sessions.total.count'=0;;;0; 'APP-RIA#backend.traffic.in.bitpersecond'=0.00b/s;;;0; 'APP-RIA#backend.traffic.out.bitpersecond'=0.00b/s;;;0; 'APP-RIA#backend.requests.denied.count'=0;;1:1;0; 'APP-RIA#backend.responses.denied.count'=0;;;0; 'APP-RIA#backend.connections.error.count'=0;;;0; 'APP-RIA#backend.responses.error.count'=0;;;0;

View File

@ -0,0 +1,50 @@
*** Settings ***
Documentation HAProxy Frontend Usage Monitoring
Resource ${CURDIR}${/}..${/}..${/}..${/}resources/import.resource
Suite Setup Start Mockoon ${MOCKOON_JSON}
Suite Teardown Stop Mockoon
Test Timeout 120s
*** Variables ***
${MOCKOON_JSON} ${CURDIR}${/}mockoon.json
${cmd} ${CENTREON_PLUGINS}
... --plugin=apps::haproxy::web::plugin
... --mode=frontend-usage
... --hostname=${HOSTNAME}
... --username='username'
... --password='password'
... --proto='http'
... --port=${APIPORT}
*** Test Cases ***
frontend-usage ${tc}
[Tags] mockoon restapi
${command} Catenate
... ${CMD}
... --filter-name='${filter_name}'
... ${extra_options}
Ctn Run Command And Check Result As Strings ${command} ${expected_result}
Examples: tc filter_name extra_options expected_result --
... 1 ${EMPTY} ${EMPTY} OK: Frontend 'hafrontend' frontend status: OPEN, current session rate: 1/s, max session rate: 6/s, current sessions: 10, total sessions: 3980, max sessions: 16, frontend-traffic-in : Buffer creation, frontend-traffic-out : Buffer creation, denied requests: 0, denied responses: 0, error requests: 42 | 'hafrontend#frontend.session.current.rate.countpersecond'=1;;;0; 'hafrontend#frontend.session.max.rate.countpersecond'=6;;;0; 'hafrontend#frontend.sessions.current.count'=10;;;0; 'hafrontend#frontend.sessions.total.count'=3980;;;0; 'hafrontend#frontend.sessions.maximum.count'=16;;;0; 'hafrontend#frontend.requests.denied.count'=0;;;0; 'hafrontend#frontend.responses.denied.count'=0;;;0; 'hafrontend#frontend.requests.error.count'=42;;;0;
... 2 hafrontend ${EMPTY} OK: Frontend 'hafrontend' frontend status: OPEN, current session rate: 1/s, max session rate: 6/s, current sessions: 10, total sessions: 3980, max sessions: 16, frontend-traffic-in : Buffer creation, frontend-traffic-out : Buffer creation, denied requests: 0, denied responses: 0, error requests: 42 | 'hafrontend#frontend.session.current.rate.countpersecond'=1;;;0; 'hafrontend#frontend.session.max.rate.countpersecond'=6;;;0; 'hafrontend#frontend.sessions.current.count'=10;;;0; 'hafrontend#frontend.sessions.total.count'=3980;;;0; 'hafrontend#frontend.sessions.maximum.count'=16;;;0; 'hafrontend#frontend.requests.denied.count'=0;;;0; 'hafrontend#frontend.responses.denied.count'=0;;;0; 'hafrontend#frontend.requests.error.count'=42;;;0;
... 3 none ${EMPTY} UNKNOWN: No Frontend found.
... 4 hafrontend --warning-frontend-current-session-rate=0:0 WARNING: Frontend 'hafrontend' frontend current session rate: 1/s | 'hafrontend#frontend.session.current.rate.countpersecond'=1;0:0;;0; 'hafrontend#frontend.session.max.rate.countpersecond'=6;;;0; 'hafrontend#frontend.sessions.current.count'=10;;;0; 'hafrontend#frontend.sessions.total.count'=3980;;;0; 'hafrontend#frontend.sessions.maximum.count'=16;;;0; 'hafrontend#frontend.traffic.in.bitpersecond'=0.00b/s;;;0; 'hafrontend#frontend.traffic.out.bitpersecond'=0.00b/s;;;0; 'hafrontend#frontend.requests.denied.count'=0;;;0; 'hafrontend#frontend.responses.denied.count'=0;;;0; 'hafrontend#frontend.requests.error.count'=42;;;0;
... 5 hafrontend --critical-frontend-current-session-rate=0:0 CRITICAL: Frontend 'hafrontend' frontend current session rate: 1/s | 'hafrontend#frontend.session.current.rate.countpersecond'=1;;0:0;0; 'hafrontend#frontend.session.max.rate.countpersecond'=6;;;0; 'hafrontend#frontend.sessions.current.count'=10;;;0; 'hafrontend#frontend.sessions.total.count'=3980;;;0; 'hafrontend#frontend.sessions.maximum.count'=16;;;0; 'hafrontend#frontend.traffic.in.bitpersecond'=0.00b/s;;;0; 'hafrontend#frontend.traffic.out.bitpersecond'=0.00b/s;;;0; 'hafrontend#frontend.requests.denied.count'=0;;;0; 'hafrontend#frontend.responses.denied.count'=0;;;0; 'hafrontend#frontend.requests.error.count'=42;;;0;
... 6 hafrontend --warning-frontend-max-session-rate=0:0 WARNING: Frontend 'hafrontend' frontend max session rate: 6/s | 'hafrontend#frontend.session.current.rate.countpersecond'=1;;;0; 'hafrontend#frontend.session.max.rate.countpersecond'=6;0:0;;0; 'hafrontend#frontend.sessions.current.count'=10;;;0; 'hafrontend#frontend.sessions.total.count'=3980;;;0; 'hafrontend#frontend.sessions.maximum.count'=16;;;0; 'hafrontend#frontend.traffic.in.bitpersecond'=0.00b/s;;;0; 'hafrontend#frontend.traffic.out.bitpersecond'=0.00b/s;;;0; 'hafrontend#frontend.requests.denied.count'=0;;;0; 'hafrontend#frontend.responses.denied.count'=0;;;0; 'hafrontend#frontend.requests.error.count'=42;;;0;
... 7 hafrontend --critical-frontend-max-session-rate=0:0 CRITICAL: Frontend 'hafrontend' frontend max session rate: 6/s | 'hafrontend#frontend.session.current.rate.countpersecond'=1;;;0; 'hafrontend#frontend.session.max.rate.countpersecond'=6;;0:0;0; 'hafrontend#frontend.sessions.current.count'=10;;;0; 'hafrontend#frontend.sessions.total.count'=3980;;;0; 'hafrontend#frontend.sessions.maximum.count'=16;;;0; 'hafrontend#frontend.traffic.in.bitpersecond'=0.00b/s;;;0; 'hafrontend#frontend.traffic.out.bitpersecond'=0.00b/s;;;0; 'hafrontend#frontend.requests.denied.count'=0;;;0; 'hafrontend#frontend.responses.denied.count'=0;;;0; 'hafrontend#frontend.requests.error.count'=42;;;0;
... 8 hafrontend --warning-frontend-current-sessions=0:0 WARNING: Frontend 'hafrontend' frontend current sessions: 10 | 'hafrontend#frontend.session.current.rate.countpersecond'=1;;;0; 'hafrontend#frontend.session.max.rate.countpersecond'=6;;;0; 'hafrontend#frontend.sessions.current.count'=10;0:0;;0; 'hafrontend#frontend.sessions.total.count'=3980;;;0; 'hafrontend#frontend.sessions.maximum.count'=16;;;0; 'hafrontend#frontend.traffic.in.bitpersecond'=0.00b/s;;;0; 'hafrontend#frontend.traffic.out.bitpersecond'=0.00b/s;;;0; 'hafrontend#frontend.requests.denied.count'=0;;;0; 'hafrontend#frontend.responses.denied.count'=0;;;0; 'hafrontend#frontend.requests.error.count'=42;;;0;
... 9 hafrontend --critical-frontend-current-sessions=0:0 CRITICAL: Frontend 'hafrontend' frontend current sessions: 10 | 'hafrontend#frontend.session.current.rate.countpersecond'=1;;;0; 'hafrontend#frontend.session.max.rate.countpersecond'=6;;;0; 'hafrontend#frontend.sessions.current.count'=10;;0:0;0; 'hafrontend#frontend.sessions.total.count'=3980;;;0; 'hafrontend#frontend.sessions.maximum.count'=16;;;0; 'hafrontend#frontend.traffic.in.bitpersecond'=0.00b/s;;;0; 'hafrontend#frontend.traffic.out.bitpersecond'=0.00b/s;;;0; 'hafrontend#frontend.requests.denied.count'=0;;;0; 'hafrontend#frontend.responses.denied.count'=0;;;0; 'hafrontend#frontend.requests.error.count'=42;;;0;
... 10 hafrontend --warning-frontend-total-sessions=0:0 WARNING: Frontend 'hafrontend' frontend total sessions: 3980 | 'hafrontend#frontend.session.current.rate.countpersecond'=1;;;0; 'hafrontend#frontend.session.max.rate.countpersecond'=6;;;0; 'hafrontend#frontend.sessions.current.count'=10;;;0; 'hafrontend#frontend.sessions.total.count'=3980;0:0;;0; 'hafrontend#frontend.sessions.maximum.count'=16;;;0; 'hafrontend#frontend.traffic.in.bitpersecond'=0.00b/s;;;0; 'hafrontend#frontend.traffic.out.bitpersecond'=0.00b/s;;;0; 'hafrontend#frontend.requests.denied.count'=0;;;0; 'hafrontend#frontend.responses.denied.count'=0;;;0; 'hafrontend#frontend.requests.error.count'=42;;;0;
... 11 hafrontend --critical-frontend-total-sessions=0:0 CRITICAL: Frontend 'hafrontend' frontend total sessions: 3980 | 'hafrontend#frontend.session.current.rate.countpersecond'=1;;;0; 'hafrontend#frontend.session.max.rate.countpersecond'=6;;;0; 'hafrontend#frontend.sessions.current.count'=10;;;0; 'hafrontend#frontend.sessions.total.count'=3980;;0:0;0; 'hafrontend#frontend.sessions.maximum.count'=16;;;0; 'hafrontend#frontend.traffic.in.bitpersecond'=0.00b/s;;;0; 'hafrontend#frontend.traffic.out.bitpersecond'=0.00b/s;;;0; 'hafrontend#frontend.requests.denied.count'=0;;;0; 'hafrontend#frontend.responses.denied.count'=0;;;0; 'hafrontend#frontend.requests.error.count'=42;;;0;

File diff suppressed because one or more lines are too long

View File

@ -84,9 +84,11 @@ FCCapacity
--force-oid
Fortigate
Fortinet
FQDN
FreeBSD
frsevent
--get-param
HAProxy
HashiCorp
hashicorpvault
HPE
@ -260,11 +262,11 @@ v2
VDSL2
Veeam
VeloCloud
Vserver
VM
VMware
VPN
vSAN
Vserver
vSphere
--warning-authserver-clients-timeout
--warning-authserver-packets-access-accepts