diff --git a/apps/redis/cli/custom/rediscli.pm b/apps/redis/cli/custom/rediscli.pm new file mode 100644 index 000000000..f17c2d96e --- /dev/null +++ b/apps/redis/cli/custom/rediscli.pm @@ -0,0 +1,148 @@ +# +# Copyright 2017 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::redis::cli::custom::rediscli; + +use strict; +use warnings; +use Redis; + +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 => + { + "hostname:s" => { name => 'hostname' }, + "port:s" => { name => 'port' }, + }); + } + $options{options}->add_help(package => __PACKAGE__, sections => 'REDIS CLI OPTIONS', once => 1); + + $self->{output} = $options{output}; + $self->{mode} = $options{mode}; + + return $self; +} + +# Method to manage multiples +sub set_options { + my ($self, %options) = @_; + # options{options_result} + + $self->{option_results} = $options{option_results}; +} + +# Method to manage multiples +sub set_defaults { + my ($self, %options) = @_; + # options{default} + + # Manage default value + foreach (keys %{$options{default}}) { + if ($_ eq $self->{mode}) { + for (my $i = 0; $i < scalar(@{$options{default}->{$_}}); $i++) { + foreach my $opt (keys %{$options{default}->{$_}[$i]}) { + if (!defined($self->{option_results}->{$opt}[$i])) { + $self->{option_results}->{$opt}[$i] = $options{default}->{$_}[$i]->{$opt}; + } + } + } + } + } +} + +sub check_options { + my ($self, %options) = @_; + + $self->{hostname} = $self->{option_results}->{hostname}; + $self->{port} = $self->{option_results}->{port}; + + if (!defined($self->{hostname})) { + $self->{output}->add_option_msg(short_msg => "Need to specify hostname argument."); + $self->{output}->option_exit(); + } + if (!defined($self->{port})) { + $self->{output}->add_option_msg(short_msg => "Need to specify port argument."); + $self->{output}->option_exit(); + } + + return 0; +} + +sub get_info { + my ($self, %options) = @_; + + $self->{redis} = Redis->new(server => $self->{hostname}.":".$self->{port}); + + my $response = $self->{redis}->info; + + my $items; + + foreach my $attributes (keys %{$response}) { + $items->{$attributes} = $response->{$attributes}; + } + + return $items; +} + +1; + +__END__ + +=head1 NAME + +REDIS CLI + +=head1 SYNOPSIS + +Redis Cli custom mode + +=head1 REDIS CLI OPTIONS + +=over 8 + +=item B<--hostname> + +Redis hostname. + +=item B<--port> + +Redis port. + +=back + +=head1 DESCRIPTION + +B. + +=cut diff --git a/apps/redis/cli/mode/clients.pm b/apps/redis/cli/mode/clients.pm new file mode 100644 index 000000000..547e0e409 --- /dev/null +++ b/apps/redis/cli/mode/clients.pm @@ -0,0 +1,141 @@ +# +# Copyright 2017 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::redis::cli::mode::clients; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0 }, + ]; + + $self->{maps_counters}->{global} = [ + { label => 'connected-clients', set => { + key_values => [ { name => 'connected_clients' } ], + output_template => 'Connected clients: %s', + perfdatas => [ + { label => 'connected_clients', value => 'connected_clients_absolute', template => '%s', min => 0 }, + ], + }, + }, + { label => 'blocked-clients', set => { + key_values => [ { name => 'blocked_clients' } ], + output_template => 'Blocked clients: %s', + perfdatas => [ + { label => 'blocked_clients', value => 'blocked_clients_absolute', template => '%s', min => 0 }, + ], + }, + }, + { label => 'client-longest-output-list', set => { + key_values => [ { name => 'client_longest_output_list' } ], + output_template => 'Client longest output list: %s', + perfdatas => [ + { label => 'client_longest_output_list', value => 'client_longest_output_list_absolute', template => '%s', min => 0 }, + ], + }, + }, + { label => 'client-biggest-input-buf', set => { + key_values => [ { name => 'client_biggest_input_buf' } ], + output_template => 'Client biggest input buffer: %s', + perfdatas => [ + { label => 'client_biggest_input_buf', value => 'client_biggest_input_buf_absolute', template => '%s', min => 0 }, + ], + }, + } + ]; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.0'; + + $options{options}->add_options(arguments => + { + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + $self->{redis} = $options{custom}; + $self->{results} = $self->{redis}->get_info(); + + $self->{global} = { 'connected_clients' => $self->{results}->{connected_clients}, + 'blocked_clients' => $self->{results}->{blocked_clients}, + 'client_longest_output_list' => $self->{results}->{client_longest_output_list}, + 'client_biggest_input_buf' => $self->{results}->{client_biggest_input_buf}}; +} + +1; + +__END__ + +=head1 MODE + +Check number of connected and blocked clients + +=over 8 + +=item B<--warning-connected-clients> + +Warning threshold for number of connected clients + +=item B<--critical-connected-clients> + +Critical threshold for number of connected clients + +=item B<--warning-blocked-clients> + +Warning threshold for number of blocked clients + +=item B<--critical-blocked-clients> + +Critical threshold for number of blocked clients + +=item B<--warning-client-longest-output-list> + +Warning threshold for longest output list among current client connections + +=item B<--critical-client-longest-output-list> + +Critical threshold for longest output list among current client connections + +=item B<--warning-client-biggest-input-buf> + +Warning threshold for biggest input buffer among current client connections + +=item B<--critical-client-biggest-input-buf> + +Critical threshold for biggest input buffer among current client connections + +=back + +=cut diff --git a/apps/redis/cli/mode/cluster.pm b/apps/redis/cli/mode/cluster.pm new file mode 100644 index 000000000..0c0f613dc --- /dev/null +++ b/apps/redis/cli/mode/cluster.pm @@ -0,0 +1,128 @@ +# +# Copyright 2017 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::redis::cli::mode::cluster; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +my $thresholds = { + global => [ + ['disabled', 'CRITICAL'], + ['enabled', 'OK'], + ], +}; + +my %map_status = ( + 0 => 'disabled', + 1 => 'enabled', +); + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.0'; + + $options{options}->add_options(arguments => + { + "threshold-overload:s@" => { name => 'threshold_overload' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + + $self->{overload_th} = {}; + foreach my $val (@{$self->{option_results}->{threshold_overload}}) { + if ($val !~ /^(.*?),(.*)$/) { + $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); + $self->{output}->option_exit(); + } + my ($section, $status, $filter) = ('global', $1, $2); + if ($self->{output}->is_litteral_status(status => $status) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload status '" . $val . "'."); + $self->{output}->option_exit(); + } + $self->{overload_th}->{$section} = [] if (!defined($self->{overload_th}->{$section})); + push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status}; + } +} + + +sub get_severity { + my ($self, %options) = @_; + my $status = 'UNKNOWN'; # default + + if (defined($self->{overload_th}->{$options{section}})) { + foreach (@{$self->{overload_th}->{$options{section}}}) { + if ($options{value} =~ /$_->{filter}/i) { + $status = $_->{status}; + return $status; + } + } + } + foreach (@{$thresholds->{$options{section}}}) { + if ($options{value} =~ /$$_[0]/i) { + $status = $$_[1]; + return $status; + } + } + + return $status; +} + +sub run { + my ($self, %options) = @_; + + $self->{redis} = $options{custom}; + $self->{results} = $self->{redis}->get_info(); + + my $exit = $self->get_severity(section => 'global', value => $map_status{$items->{cluster_enabled}}); + + $self->{output}->output_add(severity => $exit, short_msg => sprintf("Cluster is '%s'", $map_status{$items->{cluster_enabled}})); + $self->{output}->display(); + $self->{output}->exit(); +} + +1; + +__END__ + +=head1 MODE + +Check cluster status + +=over 8 + +=item B<--threshold-overload> + +Set to overload default threshold values (syntax: status,regexp) +Example: --threshold-overload='CRITICAL,disabled' + +=back + +=cut diff --git a/apps/redis/cli/mode/commands.pm b/apps/redis/cli/mode/commands.pm new file mode 100644 index 000000000..f648019cc --- /dev/null +++ b/apps/redis/cli/mode/commands.pm @@ -0,0 +1,116 @@ +# +# Copyright 2017 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::redis::cli::mode::commands; + +use base qw(centreon::plugins::templates::counter); +use Digest::MD5 qw(md5_hex); + +use strict; +use warnings; + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0, cb_prefix_output => 'prefix_output' } + ]; + + $self->{maps_counters}->{global} = [ + { label => 'processed-commands', set => { + key_values => [ { name => 'total_commands_processed', diff => 1 } ], + output_template => 'Processed: %s', + perfdatas => [ + { label => 'processed_commands', value => 'total_commands_processed_absolute', template => '%s', min => 0 }, + ], + }, + }, + { label => 'ops-per-sec', set => { + key_values => [ { name => 'instantaneous_ops_per_sec' } ], + output_template => 'Processed per sec: %s', + perfdatas => [ + { label => 'ops_per_sec', value => 'instantaneous_ops_per_sec_absolute', template => '%s', min => 0, unit => 'ops/s' }, + ], + }, + }, + ]; +} + +sub prefix_output { + my ($self, %options) = @_; + + return "Number of commands: "; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); + bless $self, $class; + + $self->{version} = '1.0'; + + $options{options}->add_options(arguments => + { + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + $self->{cache_name} = "redis_" . $self->{mode} . '_' . $self->{option_results}->{hostname} . '_' . md5_hex('all'); + + $self->{redis} = $options{custom}; + $self->{results} = $self->{redis}->get_info(); + + $self->{global} = { 'total_commands_processed' => $self->{results}->{total_commands_processed}, + 'instantaneous_ops_per_sec' => $self->{results}->{instantaneous_ops_per_sec}}; +} + +1; + +__END__ + +=head1 MODE + +Check commands number + +=over 8 + +=item B<--warning-processed-commands> + +Warning threshold for number of commands processed by the server + +=item B<--critical-processed-commands> + +Critical threshold for number of commands processed by the server + +=item B<--warning-ops-per-sec> + +Warning threshold for number of commands processed per second + +=item B<--critical-ops-per-sec> + +Critical threshold for number of commands processed per second + +=back + +=cut diff --git a/apps/redis/cli/mode/connections.pm b/apps/redis/cli/mode/connections.pm new file mode 100644 index 000000000..e834f0a05 --- /dev/null +++ b/apps/redis/cli/mode/connections.pm @@ -0,0 +1,163 @@ +# +# Copyright 2017 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::redis::cli::mode::connections; + +use base qw(centreon::plugins::templates::counter); +use Digest::MD5 qw(md5_hex); + +use strict; +use warnings; + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'connections', type => 0, cb_prefix_output => 'prefix_connections_output' }, + { name => 'traffic', type => 0, cb_prefix_output => 'prefix_traffic_output' } + ]; + + $self->{maps_counters}->{connections} = [ + { label => 'received-connections', set => { + key_values => [ { name => 'total_connections_received', diff => 1 } ], + output_template => 'Received: %s', + perfdatas => [ + { label => 'received_connections', value => 'total_connections_received_absolute', template => '%s', min => 0 }, + ], + }, + }, + { label => 'rejected-connections', set => { + key_values => [ { name => 'rejected_connections', diff => 1 } ], + output_template => 'Rejected: %s', + perfdatas => [ + { label => 'rejected_connections', value => 'rejected_connections_absolute', template => '%s', min => 0 }, + ], + }, + }, + ]; + + $self->{maps_counters}->{traffic} = [ + { label => 'traffic-in', set => { + key_values => [ { name => 'total_net_input_bytes', diff => 1 } ], + output_template => 'Traffic In: %s %s/s', + per_second => 1, output_change_bytes => 2, + perfdatas => [ + { label => 'traffic_in', value => 'total_net_input_bytes_per_second', template => '%s', min => 0, unit => 'b/s' }, + ], + }, + }, + { label => 'traffic-out', set => { + key_values => [ { name => 'total_net_output_bytes', diff => 1 } ], + output_template => 'Traffic Out: %s %s/s', + per_second => 1, output_change_bytes => 2, + perfdatas => [ + { label => 'traffic_out', value => 'total_net_output_bytes_per_second', template => '%s', min => 0, unit => 'b/s' }, + ], + }, + }, + ]; +} + +sub prefix_connections_output { + my ($self, %options) = @_; + + return "Number of connections: "; +} + +sub prefix_traffic_output { + my ($self, %options) = @_; + + return "Network usage: "; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); + bless $self, $class; + + $self->{version} = '1.0'; + + $options{options}->add_options(arguments => + { + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + $self->{cache_name} = "redis_" . $self->{mode} . '_' . $self->{option_results}->{hostname} . '_' . md5_hex('all'); + + $self->{redis} = $options{custom}; + $self->{results} = $self->{redis}->get_info(); + + $self->{connections} = { 'total_connections_received' => $self->{results}->{total_connections_received}, + 'rejected_connections' => $self->{results}->{rejected_connections}}; + + $self->{traffic} = { 'total_net_input_bytes' => $self->{results}->{total_net_input_bytes}, + 'total_net_output_bytes' => $self->{results}->{total_net_output_bytes}}; +} + +1; + +__END__ + +=head1 MODE + +Check connections number and network usage + +=over 8 + +=item B<--warning-received-connections> + +Warning threshold for received connections + +=item B<--critical-received-connections> + +Critical threshold for received connections + +=item B<--warning-rejected-connections> + +Warning threshold for rejected connections + +=item B<--critical-rejected-connections> + +Critical threshold for rejected connections + +=item B<--warning-traffic-in> + +Warning threshold for inbound traffic (b/s) + +=item B<--critical-traffic-in> + +Critical threshold for inbound traffic (b/s) + +=item B<--warning-traffic-out> + +Warning threshold for outbound traffic (b/s) + +=item B<--critical-traffic-out> + +Critical thresholdfor outbound traffic (b/s) + +=back + +=cut diff --git a/apps/redis/cli/mode/cpu.pm b/apps/redis/cli/mode/cpu.pm new file mode 100644 index 000000000..7a483185a --- /dev/null +++ b/apps/redis/cli/mode/cpu.pm @@ -0,0 +1,147 @@ +# +# Copyright 2017 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::redis::cli::mode::cpu; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0, cb_prefix_output => 'prefix_output' } + ]; + + $self->{maps_counters}->{global} = [ + { label => 'sys', set => { + key_values => [ { name => 'used_cpu_sys' } ], + output_template => 'System: %.2f %%', + perfdatas => [ + { label => 'sys', value => 'used_cpu_sys_absolute', template => '%.2f', min => 0, max => 100, unit => '%' }, + ], + }, + }, + { label => 'user', set => { + key_values => [ { name => 'used_cpu_user' } ], + output_template => 'User: %.2f %%', + perfdatas => [ + { label => 'user', value => 'used_cpu_user_absolute', template => '%.2f', min => 0, max => 100, unit => '%' }, + ], + }, + }, + { label => 'sys-children', set => { + key_values => [ { name => 'used_cpu_sys_children' } ], + output_template => 'System children: %.2f %%', + perfdatas => [ + { label => 'sys_children', value => 'used_cpu_sys_children_absolute', template => '%.2f', min => 0, max => 100, unit => '%' }, + ], + }, + }, + { label => 'user-children', set => { + key_values => [ { name => 'used_cpu_user_children' } ], + output_template => 'User children: %.2f %%', + perfdatas => [ + { label => 'user_children', value => 'used_cpu_user_children_absolute', template => '%.2f', min => 0, max => 100, unit => '%' }, + ], + }, + }, + ]; +} + +sub prefix_output { + my ($self, %options) = @_; + + return "CPU usage: "; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.0'; + + $options{options}->add_options(arguments => + { + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + $self->{redis} = $options{custom}; + $self->{results} = $self->{redis}->get_info(); + + $self->{global} = { 'used_cpu_sys' => $self->{results}->{used_cpu_sys}, + 'used_cpu_user' => $self->{results}->{used_cpu_user}, + 'used_cpu_sys_children' => $self->{results}->{used_cpu_sys_children}, + 'used_cpu_user_children' => $self->{results}->{used_cpu_user_children}}; +} + +1; + +__END__ + +=head1 MODE + +Check CPU utilization + +=over 8 + +=item B<--warning-sys> + +Warning threshold for Sys CPU utilization + +=item B<--critical-sys> + +Critical threshold for Sys CPU utilization + +=item B<--warning-user> + +Warning threshold for User CPU utilization + +=item B<--critical-user> + +Critical threshold for User CPU utilization + +=item B<--warning-sys-children> + +Warning threshold for Sys Children CPU utilization + +=item B<--critical-sys-children> + +Critical threshold for Sys Children CPU utilization + +=item B<--warning-user-children> + +Warning threshold for User Children CPU utilization + +=item B<--critical-user-children> + +Critical threshold for User Children CPU utilization + +=back + +=cut diff --git a/apps/redis/cli/mode/memory.pm b/apps/redis/cli/mode/memory.pm new file mode 100644 index 000000000..5f2c69fa1 --- /dev/null +++ b/apps/redis/cli/mode/memory.pm @@ -0,0 +1,355 @@ +# +# Copyright 2017 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::redis::cli::mode::memory; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub custom_usage_perfdata { + my ($self, %options) = @_; + + $self->{output}->perfdata_add(label => $self->{result_values}->{label}, unit => 'B', + value => $self->{result_values}->{used}, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{result_values}->{label}, total => $self->{result_values}->{total}, cast_int => 1), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{result_values}->{label}, total => $self->{result_values}->{total}, cast_int => 1), + min => 0, max => $self->{result_values}->{total}); +} + +my $instance_mode; + +sub custom_usage_threshold { + my ($self, %options) = @_; + + my ($exit, $threshold_value); + $threshold_value = $self->{result_values}->{used}; + $threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free})); + if ($instance_mode->{option_results}->{units} eq '%') { + $threshold_value = $self->{result_values}->{prct_used}; + $threshold_value = $self->{result_values}->{prct_free} if (defined($instance_mode->{option_results}->{free})); + } + $exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{result_values}->{label}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{result_values}->{label}, exit_litteral => 'warning' } ]); + return $exit; +} + +sub custom_usage_output { + my ($self, %options) = @_; + + my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}); + + my $msg = sprintf($self->{result_values}->{display}.": %s (%.2f%%)", + $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used}); + return $msg; +} + +sub custom_usage_calc { + my ($self, %options) = @_; + + $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; + $self->{result_values}->{label} = $options{new_datas}->{$self->{instance} . '_label'}; + $self->{result_values}->{used} = $options{new_datas}->{$self->{instance} . '_used'}; + $self->{result_values}->{total} = $options{new_datas}->{$self->{instance} . '_total'}; + $self->{result_values}->{free} = $self->{result_values}->{total} - $self->{result_values}->{used}; + $self->{result_values}->{prct_used} = $self->{result_values}->{used} * 100 / $self->{result_values}->{total}; + $self->{result_values}->{prct_free} = 100 - $self->{result_values}->{prct_used}; + + return 0; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'used', type => 0 }, + { name => 'rss', type => 0 }, + { name => 'peak', type => 0 }, + { name => 'overhead', type => 0 }, + { name => 'startup', type => 0 }, + { name => 'dataset', type => 0 }, + { name => 'lua', type => 0 }, + { name => 'stats', type => 0, cb_prefix_output => 'prefix_stats_output' } + ]; + + $self->{maps_counters}->{used} = [ + { label => 'used', set => { + key_values => [ { name => 'display' }, { name => 'label' }, { name => 'used' }, { name => 'total' } ], + closure_custom_calc => $self->can('custom_usage_calc'), + closure_custom_output => $self->can('custom_usage_output'), + closure_custom_perfdata => $self->can('custom_usage_perfdata'), + closure_custom_threshold_check => $self->can('custom_usage_threshold'), + } + }, + ]; + + $self->{maps_counters}->{rss} = [ + { label => 'rss', set => { + key_values => [ { name => 'display' }, { name => 'label' }, { name => 'used' }, { name => 'total' } ], + closure_custom_calc => $self->can('custom_usage_calc'), + closure_custom_output => $self->can('custom_usage_output'), + closure_custom_perfdata => $self->can('custom_usage_perfdata'), + closure_custom_threshold_check => $self->can('custom_usage_threshold'), + } + }, + ]; + + $self->{maps_counters}->{peak} = [ + { label => 'peak', set => { + key_values => [ { name => 'display' }, { name => 'label' }, { name => 'used' }, { name => 'total' } ], + closure_custom_calc => $self->can('custom_usage_calc'), + closure_custom_output => $self->can('custom_usage_output'), + closure_custom_perfdata => $self->can('custom_usage_perfdata'), + closure_custom_threshold_check => $self->can('custom_usage_threshold'), + } + }, + ]; + + $self->{maps_counters}->{overhead} = [ + { label => 'overhead', set => { + key_values => [ { name => 'display' }, { name => 'label' }, { name => 'used' }, { name => 'total' } ], + closure_custom_calc => $self->can('custom_usage_calc'), + closure_custom_output => $self->can('custom_usage_output'), + closure_custom_perfdata => $self->can('custom_usage_perfdata'), + closure_custom_threshold_check => $self->can('custom_usage_threshold'), + } + }, + ]; + + $self->{maps_counters}->{startup} = [ + { label => 'startup', set => { + key_values => [ { name => 'display' }, { name => 'label' }, { name => 'used' }, { name => 'total' } ], + closure_custom_calc => $self->can('custom_usage_calc'), + closure_custom_output => $self->can('custom_usage_output'), + closure_custom_perfdata => $self->can('custom_usage_perfdata'), + closure_custom_threshold_check => $self->can('custom_usage_threshold'), + } + }, + ]; + + $self->{maps_counters}->{dataset} = [ + { label => 'dataset', set => { + key_values => [ { name => 'display' }, { name => 'label' }, { name => 'used' }, { name => 'total' } ], + closure_custom_calc => $self->can('custom_usage_calc'), + closure_custom_output => $self->can('custom_usage_output'), + closure_custom_perfdata => $self->can('custom_usage_perfdata'), + closure_custom_threshold_check => $self->can('custom_usage_threshold'), + } + }, + ]; + + $self->{maps_counters}->{lua} = [ + { label => 'lua', set => { + key_values => [ { name => 'display' }, { name => 'label' }, { name => 'used' }, { name => 'total' } ], + closure_custom_calc => $self->can('custom_usage_calc'), + closure_custom_output => $self->can('custom_usage_output'), + closure_custom_perfdata => $self->can('custom_usage_perfdata'), + closure_custom_threshold_check => $self->can('custom_usage_threshold'), + } + }, + ]; + + $self->{maps_counters}->{stats} = [ + { label => 'fragmentation-ratio', set => { + key_values => [ { name => 'mem_fragmentation_ratio' } ], + output_template => 'Fragmentation ratio: %s', + perfdatas => [ + { label => 'fragmentation_ratio', value => 'mem_fragmentation_ratio_absolute', template => '%s', min => 0 }, + ], + }, + }, + { label => 'defrag-running', set => { + key_values => [ { name => 'active_defrag_running' } ], + output_template => 'Defragmentation running: %s', + perfdatas => [ + { label => 'defrag_running', value => 'active_defrag_running_absolute', template => '%s', min => 0 }, + ], + }, + }, + { label => 'lazyfree-pending-objects', set => { + key_values => [ { name => 'lazyfree_pending_objects' } ], + output_template => 'Lazyfree pending objects: %s', + perfdatas => [ + { label => 'lazyfree_pending_objects', value => 'lazyfree_pending_objects_absolute', template => '%s', min => 0 }, + ], + }, + }, + ]; +} + +sub prefix_stats_output { + my ($self, %options) = @_; + + return "Statistics: "; +} + + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.0'; + + $options{options}->add_options(arguments => + { + "units:s" => { name => 'units', default => '%' }, + "free" => { name => 'free' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $instance_mode = $self; +} + +my $metrics = { + 'used_memory' => { label => 'used', display => 'Used' }, + 'used_memory_rss' => { label => 'rss', display => 'Rss' }, + 'used_memory_peak' => { label => 'peak', display => 'Peak' }, + 'used_memory_overhead' => { label => 'overhead', display => 'Overhead' }, + 'used_memory_startup' => { label => 'startup', display => 'Startup' }, + 'used_memory_dataset' => { label => 'dataset', display => 'Dataset' }, + 'used_memory_lua' => { label => 'lua', display => 'Lua' }, +}; + +sub manage_selection { + my ($self, %options) = @_; + + $self->{redis} = $options{custom}; + $self->{results} = $self->{redis}->get_info(); + + foreach my $type (keys $metrics) { + $self->{$metrics->{$type}->{label}} = { 'display' => $metrics->{$type}->{display}, + 'label' => $metrics->{$type}->{label}, + 'used' => $self->{results}->{$type}, + 'total' => $self->{results}->{total_system_memory} }; + } + + $self->{stats} = { 'mem_fragmentation_ratio' => $self->{results}->{mem_fragmentation_ratio}, + 'active_defrag_running' => $self->{results}->{active_defrag_running}, + 'lazyfree_pending_objects' => $self->{results}->{lazyfree_pending_objects} }; +} + +1; + +__END__ + +=head1 MODE + +Check memory utilization + +=over 8 + +=item B<--units> + +Units of thresholds (Default: '%') ('%', 'B'). + +=item B<--free> + +Thresholds are on free space left. + +=item B<--warning-used> + +Warning threshold for Used memory utilization + +=item B<--critical-used> + +Critical threshold for Used memory utilization + +=item B<--warning-rss> + +Warning threshold for Rss memory utilization + +=item B<--critical-rss> + +Critical threshold for Rss memory utilization + +=item B<--warning-peak> + +Warning threshold for Peak memory utilization + +=item B<--critical-peak> + +Critical threshold for Peak memory utilization + +=item B<--warning-overhead> + +Warning threshold for Overhead memory utilization + +=item B<--critical-overhead> + +Critical threshold for Overhead memory utilization + +=item B<--warning-startup> + +Warning threshold for Startup memory utilization + +=item B<--critical-startup> + +Critical threshold for Startup memory utilization + +=item B<--warning-dataset> + +Warning threshold for Dataset memory utilization + +=item B<--critical-dataset> + +Critical threshold for Dataset memory utilization + +=item B<--warning-lua> + +Warning threshold for Lua memory utilization + +=item B<--critical-lua> + +Critical threshold for Lua memory utilization + +=item B<--warning-fragmentation-ratio> + +Warning threshold for Fragmentation Ratio + +=item B<--critical-fragmentation-ratio> + +Critical threshold for Fragmentation Ratio + +=item B<--warning-defrag-running> + +Warning threshold for Running Defragmentation + +=item B<--critical-defrag-running> + +Critical threshold for Running Defragmentation + +=item B<--warning-lazyfree-pending-objects> + +Warning threshold for Lazyfree Pending Objects + +=item B<--critical-lazyfree-pending-objects> + +Critical threshold for Lazyfree Pending Objects + +=back + +=cut diff --git a/apps/redis/cli/mode/persistence.pm b/apps/redis/cli/mode/persistence.pm new file mode 100644 index 000000000..07bc62988 --- /dev/null +++ b/apps/redis/cli/mode/persistence.pm @@ -0,0 +1,237 @@ +# +# Copyright 2017 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::redis::cli::mode::persistence; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +my $thresholds = { + status => [ + ['fail', 'CRITICAL'], + ['ok', 'OK'], + ], + progress => [ + ['stopped', 'WARNING'], + ['in progress', 'OK'], + ], +}; + +my %map_status = ( + 0 => 'stopped', + 1 => 'in progress', +); + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0 } + ]; + + $self->{maps_counters}->{global} = [ + { label => 'changes', set => { + key_values => [ { name => 'rdb_changes_since_last_save' } ], + output_template => 'Number of changes since the last dump: %s', + perfdatas => [ + { label => 'changes', value => 'rdb_changes_since_last_save_absolute', template => '%s', min => 0 }, + ], + }, + }, + { label => 'last-save', set => { + key_values => [ { name => 'rdb_last_save_time' }, { name => 'rdb_last_save_time_sec' } ], + output_template => 'Time since last successful save: %s', + perfdatas => [ + { label => 'last_save', value => 'rdb_last_save_time_sec_absolute', template => '%s', min => 0, unit => 's' }, + ], + }, + }, + { label => 'save-size', set => { + key_values => [ { name => 'rdb_last_cow_size' } ], + output_template => 'Size of last save: %s %s', + output_change_bytes => 1, + perfdatas => [ + { label => 'save_size', value => 'rdb_last_cow_size_absolute', template => '%s', min => 0, unit => 'B' }, + ], + }, + }, + { label => 'last-save-duration', set => { + key_values => [ { name => 'rdb_last_bgsave_time' } ], + output_template => 'Duration of last save: %s s', + perfdatas => [ + { label => 'last_save_duration', value => 'rdb_last_bgsave_time_absolute', template => '%s', min => 0, unit => 's' }, + ], + }, + }, + { label => 'current-save-duration', set => { + key_values => [ { name => 'rdb_current_bgsave_time' } ], + output_template => 'Duration of current save: %s s', + perfdatas => [ + { label => 'current_save_duration', value => 'rdb_current_bgsave_time_absolute', template => '%s', min => 0, unit => 's' }, + ], + }, + }, + ]; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.0'; + + $options{options}->add_options(arguments => + { + "threshold-overload:s@" => { name => 'threshold_overload' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + + $self->{overload_th} = {}; + foreach my $val (@{$self->{option_results}->{threshold_overload}}) { + if ($val !~ /^(.*?),(.*?),(.*)$/) { + $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); + $self->{output}->option_exit(); + } + my ($section, $status, $filter) = ($1, $2, $3); + if ($self->{output}->is_litteral_status(status => $status) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload status '" . $val . "'."); + $self->{output}->option_exit(); + } + $self->{overload_th}->{$section} = [] if (!defined($self->{overload_th}->{$section})); + push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status}; + } +} + + +sub get_severity { + my ($self, %options) = @_; + my $status = 'UNKNOWN'; # default + + if (defined($self->{overload_th}->{$options{section}})) { + foreach (@{$self->{overload_th}->{$options{section}}}) { + if ($options{value} =~ /$_->{filter}/i) { + $status = $_->{status}; + return $status; + } + } + } + foreach (@{$thresholds->{$options{section}}}) { + if ($options{value} =~ /$$_[0]/i) { + $status = $$_[1]; + return $status; + } + } + + return $status; +} + +sub manage_selection { + my ($self, %options) = @_; + + $self->{redis} = $options{custom}; + $self->{results} = $self->{redis}->get_info(); + + my @exits; + + push @exits, $self->get_severity(section => 'status', value => $self->{results}->{rdb_last_bgsave_status}); + push @exits, $self->get_severity(section => 'progess', value => $map_status{$self->{results}->{rdb_bgsave_in_progress}}); + + $self->{output}->output_add(short_msg => sprintf("RDB save is in '%s' status", $self->{results}->{rdb_last_bgsave_status})); + $self->{output}->output_add(short_msg => sprintf("RDB save is '%s'", $map_status{$self->{results}->{rdb_bgsave_in_progress}})); + + $self->{global} = { 'rdb_changes_since_last_save' => $self->{results}->{rdb_changes_since_last_save}, + 'rdb_last_save_time' => centreon::plugins::misc::change_seconds(value => time() - $self->{results}->{rdb_last_save_time}), + 'rdb_last_save_time_sec' => time() - $self->{results}->{rdb_last_save_time}, + 'rdb_last_cow_size' => $self->{results}->{rdb_last_cow_size}, + 'rdb_last_bgsave_time' => $self->{results}->{rdb_last_bgsave_time_sec}, + 'rdb_current_bgsave_time' => $self->{results}->{rdb_current_bgsave_time_sec}}; + + my $exit = $self->{output}->get_most_critical(status => \@exits); + $self->{output}->output_add(severity => $exit); +} + +1; + +__END__ + +=head1 MODE + +Check RDB persistence status + +=over 8 + +=item B<--threshold-overload> + +Set to overload default threshold values (syntax: section,status,regexp) +Example: --threshold-overload='status,CRITICAL,ok' +Section can be: 'status', 'progress' + +=item B<--warning-changes> + +Warning threshold for number of changes since the last dump + +=item B<--critical-changes> + +Critical threshold for number of changes since the last dump + +=item B<--warning-last-save> + +Warning threshold for time since last successful save (in second) + +=item B<--critical-last-save> + +Critical threshold for time since last successful save (in second) + +=item B<--warning-save-size> + +Warning threshold for size of last save (in bytes) + +=item B<--critical-save-size> + +Critical threshold for size of last save (in bytes) + +=item B<--warning-last-save-duration> + +Warning threshold for duration of last save (in second) + +=item B<--critical-last-save-duration> + +Critical threshold for duration of last save (in second) + +=item B<--warning-current-save-duration> + +Warning threshold for current of last save (in second) + +=item B<--critical-current-save-duration> + +Critical threshold for current of last save (in second) + +=back + +=cut diff --git a/apps/redis/cli/mode/replication.pm b/apps/redis/cli/mode/replication.pm new file mode 100644 index 000000000..1004d545f --- /dev/null +++ b/apps/redis/cli/mode/replication.pm @@ -0,0 +1,261 @@ +# +# Copyright 2017 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::redis::cli::mode::replication; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +my $thresholds = { + link => [ + ['down', 'CRITICAL'], + ['up', 'OK'], + ], + sync => [ + ['stopped', 'OK'], + ['in progress', 'WARNING'], + ], +}; + +my %map_sync = ( + 0 => 'stopped', + 1 => 'in progress', +); + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0 }, + { name => 'master', type => 0 }, + { name => 'slave', type => 0 } + ]; + + $self->{maps_counters}->{global} = [ + { label => 'connected-slaves', set => { + key_values => [ { name => 'connected_slaves' } ], + output_template => 'Number of connected slaves: %s', + perfdatas => [ + { label => 'connected_slaves', value => 'connected_slaves_absolute', template => '%s', min => 0 }, + ], + }, + }, + ]; + + $self->{maps_counters}->{master} = [ + { label => 'master-repl-offset', set => { + key_values => [ { name => 'master_repl_offset' } ], + output_template => 'Master replication offset: %s s', + perfdatas => [ + { label => 'master_repl_offset', value => 'master_repl_offset_absolute', template => '%s', min => 0, unit => 's' }, + ], + }, + }, + ]; + + $self->{maps_counters}->{slave} = [ + { label => 'master-last-io', set => { + key_values => [ { name => 'master_last_io_seconds_ago' } ], + output_template => 'Last interaction with master: %s s', + perfdatas => [ + { label => 'master_last_io', value => 'master_last_io_seconds_ago_absolute', template => '%s', min => 0, unit => 's' }, + ], + }, + }, + { label => 'slave-repl-offset', set => { + key_values => [ { name => 'slave_repl_offset' } ], + output_template => 'Slave replication offset: %s s', + perfdatas => [ + { label => 'slave_repl_offset', value => 'slave_repl_offset_absolute', template => '%s', min => 0, unit => 's' }, + ], + }, + }, + { label => 'slave-priority', set => { + key_values => [ { name => 'slave_priority' } ], + output_template => 'Slave replication offset: %s s', + perfdatas => [ + { label => 'slave_priority', value => 'slave_priority_absolute', template => '%s' }, + ], + }, + }, + { label => 'slave-read-only', set => { + key_values => [ { name => 'slave_read_only' } ], + output_template => 'Slave replication offset: %s s', + perfdatas => [ + { label => 'slave_read_only', value => 'slave_read_only_absolute', template => '%s' }, + ], + }, + }, + ]; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.0'; + + $options{options}->add_options(arguments => + { + "threshold-overload:s@" => { name => 'threshold_overload' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + + $self->{overload_th} = {}; + foreach my $val (@{$self->{option_results}->{threshold_overload}}) { + if ($val !~ /^(.*?),(.*?),(.*)$/) { + $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload option '" . $val . "'."); + $self->{output}->option_exit(); + } + my ($section, $status, $filter) = ($1, $2, $3); + if ($self->{output}->is_litteral_status(status => $status) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong threshold-overload status '" . $val . "'."); + $self->{output}->option_exit(); + } + $self->{overload_th}->{$section} = [] if (!defined($self->{overload_th}->{$section})); + push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status}; + } +} + + +sub get_severity { + my ($self, %options) = @_; + my $status = 'UNKNOWN'; # default + + if (defined($self->{overload_th}->{$options{section}})) { + foreach (@{$self->{overload_th}->{$options{section}}}) { + if ($options{value} =~ /$_->{filter}/i) { + $status = $_->{status}; + return $status; + } + } + } + foreach (@{$thresholds->{$options{section}}}) { + if ($options{value} =~ /$$_[0]/i) { + $status = $$_[1]; + return $status; + } + } + + return $status; +} + +sub manage_selection { + my ($self, %options) = @_; + + $self->{redis} = $options{custom}; + $self->{results} = $self->{redis}->get_info(); + + my @exits; + + $self->{output}->output_add(short_msg => sprintf("Node is '%s'", $self->{results}->{role})); + + $self->{global} = { 'connected_slaves' => $self->{results}->{connected_slaves} }; + + if ($self->{results}->{role} =~ /master/) { + $self->{master} = { 'master_repl_offset' => $self->{results}->{master_repl_offset} }; + } elsif ($self->{results}->{role} =~ /slave/) { + $self->{output}->output_add(short_msg => sprintf("Link with master '%s:%s' is '%s', Sync is '%s'", + $self->{results}->{master_host}, + $self->{results}->{master_port}, + $self->{results}->{master_link_status}, + $map_sync{$self->{results}->{master_sync_in_progress}})); + + push @exits, $self->get_severity(section => 'link', value => $self->{results}->{master_link_status}); + push @exits, $self->get_severity(section => 'sync', value => $map_sync{$self->{results}->{master_sync_in_progress}}); + + $self->{slave} = { 'master_last_io_seconds_ago' => $self->{results}->{master_last_io_seconds_ago}, + 'slave_repl_offset' => $self->{results}->{slave_repl_offset}, + 'slave_priority' => $self->{results}->{slave_priority}, + 'slave_read_only' => $self->{results}->{slave_read_only} }; + } + + my $exit = $self->{output}->get_most_critical(status => \@exits); + $self->{output}->output_add(severity => $exit); +} + +1; + +__END__ + +=head1 MODE + +Check replication status + +=over 8 + +=item B<--threshold-overload> + +Set to overload default threshold values (syntax: section,status,regexp) +Example: --threshold-overload='link,OK,down' +Section can be: 'link', 'sync' + +=item B<--warning-connected-slaves> + +Warning threshold for number of connected slave + +=item B<--critical-connected-slaves> + +Critical threshold for number of connected slave + +=item B<--warning-master-repl-offset> + +Warning threshold for master replication offset (in second) + +=item B<--critical-master-repl-offset> + +Critical threshold for master replication offset (in second) + +=item B<--warning-master-last-io> + +Warning threshold for last interaction with master (in second) + +=item B<--critical-master-last-io> + +Critical threshold for last interaction with master (in second) + +=item B<--warning-slave-priority> + +Warning threshold for slave priority + +=item B<--critical-slave-priority> + +Critical threshold for slave priority + +=item B<--warning-slave-read-only> + +Warning threshold for slave being in read-only + +=item B<--critical-slave-read-only> + +Critical threshold for slave being in read-only + +=back + +=cut diff --git a/apps/redis/cli/plugin.pm b/apps/redis/cli/plugin.pm new file mode 100644 index 000000000..2496285c5 --- /dev/null +++ b/apps/redis/cli/plugin.pm @@ -0,0 +1,60 @@ +# +# Copyright 2017 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::redis::cli::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}} = ( + 'clients' => 'apps::redis::cli::mode::clients', + 'cluster' => 'apps::redis::cli::mode::cluster', + 'commands' => 'apps::redis::cli::mode::commands', + 'connections' => 'apps::redis::cli::mode::connections', + 'cpu' => 'apps::redis::cli::mode::cpu', + 'memory' => 'apps::redis::cli::mode::memory', + 'persistence' => 'apps::redis::cli::mode::persistence', + 'replication' => 'apps::redis::cli::mode::replication', + ); + + $self->{custom_modes}{rediscli} = 'apps::redis::cli::custom::rediscli'; + return $self; +} + +sub init { + my ($self, %options) = @_; + + $self->SUPER::init(%options); +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Redis server through Perl Cli binding library.