From bfedaeec9d9342c96d64aad9834bb91c775aea3c Mon Sep 17 00:00:00 2001 From: Sims24 Date: Mon, 23 Mar 2020 13:38:28 +0100 Subject: [PATCH 001/283] (wip)sample net mode for parity --- blockchain/parity/restapi/custom/api.pm | 187 ++++++++++++++++++++++++ blockchain/parity/restapi/mode/net.pm | 133 +++++++++++++++++ blockchain/parity/restapi/plugin.pm | 48 ++++++ 3 files changed, 368 insertions(+) create mode 100644 blockchain/parity/restapi/custom/api.pm create mode 100644 blockchain/parity/restapi/mode/net.pm create mode 100644 blockchain/parity/restapi/plugin.pm diff --git a/blockchain/parity/restapi/custom/api.pm b/blockchain/parity/restapi/custom/api.pm new file mode 100644 index 000000000..d792c57d8 --- /dev/null +++ b/blockchain/parity/restapi/custom/api.pm @@ -0,0 +1,187 @@ +# +# Copyright 2020 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 blockchain::parity::restapi::custom::api; + +use strict; +use warnings; +use centreon::plugins::http; +use JSON; + +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' }, + "timeout:s" => { name => 'timeout' }, + "api-path:s" => { name => 'api_path' }, + }); + } + $options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1); + + $self->{output} = $options{output}; + $self->{mode} = $options{mode}; + $self->{http} = centreon::plugins::http->new(%options); + + return $self; +} + +sub set_options { + my ($self, %options) = @_; + + $self->{option_results} = $options{option_results}; +} + +sub set_defaults { + my ($self, %options) = @_; + + 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} = (defined($self->{option_results}->{hostname})) ? $self->{option_results}->{hostname} : undef; + $self->{timeout} = (defined($self->{option_results}->{timeout})) ? $self->{option_results}->{timeout} : 10; + $self->{api_path} = (defined($self->{option_results}->{api_path})) ? $self->{option_results}->{api_path} : '/'; + + if (!defined($self->{hostname})) { + $self->{output}->add_option_msg(short_msg => "Need to specify hostname option."); + $self->{output}->option_exit(); + } + return 0; +} + +sub get_connection_infos { + my ($self, %options) = @_; + + return $self->{hostname} . '_' . $self->{http}->get_port(); +} + +sub build_options_for_httplib { + my ($self, %options) = @_; + + $self->{option_results}->{hostname} = $self->{hostname}; + $self->{option_results}->{timeout} = $self->{timeout}; + $self->{option_results}->{port} = 8545; + $self->{option_results}->{proto} = 'http'; +} + +sub settings { + my ($self, %options) = @_; + + $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}}); +} + +sub request_api { + my ($self, %options) = @_; + + + $self->settings(); + + my $encoded; + eval { + $encoded = encode_json($options{query_form_post}); + }; + if ($@) { + $self->{output}->add_option_msg(short_msg => "Cannot encode json request"); + $self->{output}->option_exit(); + } + + my $content = $self->{http}->request(method => $options{method}, url_path => '/', query_form_post => $encoded, + critical_status => '', warning_status => '', unknown_status => ''); + + my $decoded; + eval { + $decoded = decode_json($content); + }; + if ($@) { + $self->{output}->output_add(long_msg => $content, debug => 1); + $self->{output}->add_option_msg(short_msg => "Cannot decode json response"); + $self->{output}->option_exit(); + } + if ($self->{http}->get_code() != 200) { + $self->{output}->add_option_msg(short_msg => "Connection issue: " . $decoded->{msg}); + $self->{output}->option_exit(); + } + + return $decoded; +} + +1; + +__END__ + +=head1 NAME + +Parity node JSON WEBRPC + +=head1 SYNOPSIS + +Parity node JSON RPC API custom mode + +=head1 REST API OPTIONS + +=over 8 + +=item B<--hostname> + +Parity node hostname or IP + +=item B<--timeout> + +Set HTTP timeout in seconds (Default: '10'). + +=item B<--api-path> + +API base url path (Default: '/'). + +=back + +=head1 DESCRIPTION + +B. + +=cut diff --git a/blockchain/parity/restapi/mode/net.pm b/blockchain/parity/restapi/mode/net.pm new file mode 100644 index 000000000..a1f94ffc3 --- /dev/null +++ b/blockchain/parity/restapi/mode/net.pm @@ -0,0 +1,133 @@ +# +# Copyright 2020 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 blockchain::parity::restapi::mode::net; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); + +sub custom_status_output { + my ($self, %options) = @_; + + return sprintf( + 'Listening status: %s ', + $self->{result_values}->{listening}, + ); +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'network', cb_prefix_output => 'prefix_module_output', type => 0 }, + ]; + + $self->{maps_counters}->{network} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'listening' } ], + closure_custom_calc => \&catalog_status_calc, + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold + } + }, + { label => 'peers', nlabel => 'parity.network.peers.count', set => { + key_values => [ { name => 'peers' } ], + output_template => "connected peers: %s ", + perfdatas => [ + { label => 'peer_count', value => 'peers_absolute', template => '%d', min => 0 } + ], + } + }, + ]; +} + +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 => { + 'unknown-status:s' => { name => 'unknown_status', default => '' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '%{listening} !~ /true/' }, + }); + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->change_macros(macros => ['unknown_status', 'warning_status', 'critical_status']); +} + +sub prefix_module_output { + my ($self, %options) = @_; + + return "Parity network module: "; +} + +sub manage_selection { + my ($self, %options) = @_; + + my $query_form_post_listening = { method => 'net_listening', params => [], id => "1", jsonrpc => "2.0" }; + my $result_listening = $options{custom}->request_api(method => 'POST', query_form_post => $query_form_post_listening); + + my $query_form_post_peer = { method => 'net_peerCount', params => [], id => "1", jsonrpc => "2.0" }; + my $result_peer = $options{custom}->request_api(method => 'POST', query_form_post => $query_form_post_peer); + + $self->{network} = { listening => $result_listening->{result}, + peers => hex($result_peer->{result}) } + +} + +1; + +__END__ + +=head1 MODE + +Check network module metrics parity (net_isListening, net_peerCount) + +=over 8 + +=item B<--unknown-status> + +Set unknown threshold for listening status (Default: ''). + +=item B<--warning-status> + +Set warning threshold for listening status (Default: ''). + +=item B<--critical-status> + +Set critical threshold for listening status (Default: '%{listening} !~ /true/'). + +=item B<--warning-peers> B<--critical-peers> + +Warning and Critical threhsold on the number of peer + +=back + +=cut diff --git a/blockchain/parity/restapi/plugin.pm b/blockchain/parity/restapi/plugin.pm new file mode 100644 index 000000000..cda22b0ac --- /dev/null +++ b/blockchain/parity/restapi/plugin.pm @@ -0,0 +1,48 @@ +# +# Copyright 2020 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 blockchain::parity::restapi::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} = '0.1'; + %{$self->{modes}} = ( + 'net' => 'blockchain::parity::restapi::mode::net', + ); + $self->{custom_modes}{api} = 'blockchain::parity::restapi::custom::api'; + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Parity blockchain with JSON RPC + +=cut From b3ea402abca9e1a89bb6dd9f7f6db749a9a308b4 Mon Sep 17 00:00:00 2001 From: Sims24 Date: Mon, 23 Mar 2020 15:21:56 +0100 Subject: [PATCH 002/283] (wip) sample multiple method post on RPC --- blockchain/parity/restapi/mode/net.pm | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/blockchain/parity/restapi/mode/net.pm b/blockchain/parity/restapi/mode/net.pm index a1f94ffc3..d5e8f88cf 100644 --- a/blockchain/parity/restapi/mode/net.pm +++ b/blockchain/parity/restapi/mode/net.pm @@ -91,15 +91,14 @@ sub prefix_module_output { sub manage_selection { my ($self, %options) = @_; - my $query_form_post_listening = { method => 'net_listening', params => [], id => "1", jsonrpc => "2.0" }; - my $result_listening = $options{custom}->request_api(method => 'POST', query_form_post => $query_form_post_listening); - - my $query_form_post_peer = { method => 'net_peerCount', params => [], id => "1", jsonrpc => "2.0" }; - my $result_peer = $options{custom}->request_api(method => 'POST', query_form_post => $query_form_post_peer); + my $query_form_post = [ { method => 'net_listening', params => [], id => "1", jsonrpc => "2.0" }, + { method => 'net_peerCount', params => [], id => "2", jsonrpc => "2.0" } ]; + + my $result = $options{custom}->request_api(method => 'POST', query_form_post => $query_form_post); + + $self->{network} = { listening => @{$result}[0]->{result}, + peers => hex(@{$result}[1]->{result}) }; - $self->{network} = { listening => $result_listening->{result}, - peers => hex($result_peer->{result}) } - } 1; From af9b57dd0412d233bdd9967e8d6fd9cae224a36b Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Wed, 25 Mar 2020 16:38:57 +0000 Subject: [PATCH 003/283] adding eth module --- blockchain/parity/restapi/mode/eth.pm | 223 ++++++++++++++++++++++++++ blockchain/parity/restapi/plugin.pm | 1 + 2 files changed, 224 insertions(+) create mode 100644 blockchain/parity/restapi/mode/eth.pm diff --git a/blockchain/parity/restapi/mode/eth.pm b/blockchain/parity/restapi/mode/eth.pm new file mode 100644 index 000000000..6beec926d --- /dev/null +++ b/blockchain/parity/restapi/mode/eth.pm @@ -0,0 +1,223 @@ +# +# Copyright 2020 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 blockchain::parity::restapi::mode::eth; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); + +sub custom_status_output { + my ($self, %options) = @_; + + return sprintf( + 'Listening status: %s ', + $self->{result_values}->{listening}, + ); +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'eth', cb_prefix_output => 'prefix_module_output', type => 0 }, + ]; + + $self->{maps_counters}->{eth} = [ + { label => 'is_minning', nlabel => 'parity.eth.peers.minning.status', set => { + key_values => [ { name => 'is_minning' } ], + output_template => "Client is minning: %s ", + perfdatas => [ + { label => 'is_minning', value => 'is_minning_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'coinbase', nlabel => 'parity.eth.client.coinbase', set => { + key_values => [ { name => 'coinbase' } ], + output_template => "Client coinbase is: %s ", + perfdatas => [ + { label => 'client_coinbase', value => 'coinbase_absolute', template => '%s', min => 0 } + ], + } + }, + { label => 'gas_price', nlabel => 'parity.eth.gas.price', set => { + key_values => [ { name => 'gas_price' } ], + output_template => "The gas price is: %d wei ", + perfdatas => [ + { label => 'gas_price', value => 'gas_price_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'hashrate', nlabel => 'parity.eth.node.hashrate', set => { + key_values => [ { name => 'hashrate' } ], + output_template => "Node hashrate is: %d/s ", + perfdatas => [ + { label => 'node_hashrate', value => 'hashrate_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'block_number', nlabel => 'parity.eth.block.number', set => { + key_values => [ { name => 'block_number' } ], + output_template => "Most recent block number is: %d ", + perfdatas => [ + { label => 'block_number', value => 'block_number_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'block_time', nlabel => 'parity.eth.block.time', set => { + key_values => [ { name => 'block_time' } ], + output_template => "Block time is: %s ", + perfdatas => [ + { label => 'block_time', value => 'block_time_absolute', template => '%s', min => 0 } + ], + } + }, + { label => 'sync_start', nlabel => 'parity.eth.sync.start.block', set => { + key_values => [ { name => 'sync_start' } ], + output_template => "Sync start block number is: %d ", + perfdatas => [ + { label => 'sync_start', value => 'sync_start_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'sync_current', nlabel => 'parity.eth.sync.current.block', set => { + key_values => [ { name => 'sync_current' } ], + output_template => "Sync current block number is: %d ", + perfdatas => [ + { label => 'sync_current', value => 'sync_current_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'sync_highest', nlabel => 'parity.eth.sync.highest.block', set => { + key_values => [ { name => 'sync_highest' } ], + output_template => "Sync highest block number is: %d ", + perfdatas => [ + { label => 'sync_highest', value => 'sync_highest_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'sync', nlabel => 'parity.eth.sync.ratio', set => { + key_values => [ { name => 'sync' } ], + output_template => "Sync ratio is: %d% ", + perfdatas => [ + { label => 'sync', value => 'sync_absolute', template => '%d', min => 0 } + ], + } + } + ]; +} + +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 => { + 'unknown-status:s' => { name => 'unknown_status', default => '' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '%{listening} !~ /true/' }, + }); + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->change_macros(macros => ['unknown_status', 'warning_status', 'critical_status']); +} + +sub prefix_module_output { + my ($self, %options) = @_; + + return "Parity Eth module: "; +} + +sub manage_selection { + my ($self, %options) = @_; + + my $query_form_post = [ { method => 'eth_mining', params => [], id => "1", jsonrpc => "2.0" }, + { method => 'eth_coinbase', params => [], id => "1", jsonrpc => "2.0" }, + { method => 'eth_gasPrice', params => [], id => "1", jsonrpc => "2.0" } , + { method => 'eth_hashrate', params => [], id => "1", jsonrpc => "2.0" } , + { method => 'eth_blockNumber', params => [], id => "1", jsonrpc => "2.0" }, + { method => 'eth_getBlockByNumber', params => ["latest","false"], id => "1", jsonrpc => "2.0" }, + { method => 'eth_syncing', params => [], id => "1", jsonrpc => "2.0" }, + { method => 'eth_coinbase', params => [], id => "1", jsonrpc => "2.0" }, + { method => 'eth_coinbase', params => [], id => "1", jsonrpc => "2.0" }, + { method => 'eth_coinbase', params => [], id => "1", jsonrpc => "2.0" }, + { method => 'eth_coinbase', params => [], id => "1", jsonrpc => "2.0" }, + { method => 'eth_coinbase', params => [], id => "1", jsonrpc => "2.0" } ]; + + my $result = $options{custom}->request_api(method => 'POST', query_form_post => $query_form_post); + + # conditional formating: + my $res_sync = @{$result}[6]->{result} ? (@{$result}[6]->{result}->{currentBlock} / @{$result}[6]->{result}->{highestBlock}) * 100 : 100; + my $res_startingBlock = $res_sync != 100 ? @{$result}[6]->{result}->{startingBlock} : undef; + my $res_currentBlock = $res_sync != 100 ? @{$result}[6]->{result}->{currentBlock} : undef; + my $res_highestBlock = $res_sync != 100 ? @{$result}[6]->{result}->{highestBlock} : undef; + + # Unix time conversion + my $res_timestamp = localtime((@{$result}[5]->{result}->{timestamp})); + + $self->{eth} = { is_minning => @{$result}[0]->{result}, + coinbase => @{$result}[1]->{result}, + gas_price => @{$result}[2]->{result}, + hashrate => hex(@{$result}[3]->{result}), + block_number => @{$result}[4]->{result}, + block_time => $res_timestamp, + sync_start => $res_startingBlock, + sync_current => $res_currentBlock, + sync_highest => $res_highestBlock, + sync => $res_sync }; + +} + +1; + +__END__ + +=head1 MODE + +Check eth module metrics parity (eth_mining, eth_coinbase, eth_gasPrice, eth_hashrate, eth_blockNumber, eth_getBlockByNumber::timestamp) + +=over 8 + +=item B<--unknown-status> + +Set unknown threshold for listening status (Default: ''). + +=item B<--warning-status> + +Set warning threshold for listening status (Default: ''). + +=item B<--critical-status> + +Set critical threshold for listening status (Default: '%{listening} !~ /true/'). + +=item B<--warning-peers> B<--critical-peers> + +Warning and Critical threhsold on the number of peer + +=back + +=cut diff --git a/blockchain/parity/restapi/plugin.pm b/blockchain/parity/restapi/plugin.pm index cda22b0ac..64e9f0a9b 100644 --- a/blockchain/parity/restapi/plugin.pm +++ b/blockchain/parity/restapi/plugin.pm @@ -32,6 +32,7 @@ sub new { $self->{version} = '0.1'; %{$self->{modes}} = ( 'net' => 'blockchain::parity::restapi::mode::net', + 'eth' => 'blockchain::parity::restapi::mode::eth', ); $self->{custom_modes}{api} = 'blockchain::parity::restapi::custom::api'; return $self; From f5aba66983906ef476a6f918468d61aae16dcb81 Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Thu, 26 Mar 2020 08:40:14 +0000 Subject: [PATCH 004/283] adding parity mode --- blockchain/parity/restapi/mode/parity.pm | 204 +++++++++++++++++++++++ 1 file changed, 204 insertions(+) create mode 100644 blockchain/parity/restapi/mode/parity.pm diff --git a/blockchain/parity/restapi/mode/parity.pm b/blockchain/parity/restapi/mode/parity.pm new file mode 100644 index 000000000..122fd090b --- /dev/null +++ b/blockchain/parity/restapi/mode/parity.pm @@ -0,0 +1,204 @@ +# +# Copyright 2020 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 blockchain::parity::restapi::mode::parity; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'parity', cb_prefix_output => 'prefix_module_output', type => 0 }, + ]; + + $self->{maps_counters}->{parity} = [ + { label => 'parity_version', nlabel => 'parity.version', set => { + key_values => [ { name => 'parity_version' } ], + output_template => "Parity version is: %s ", + perfdatas => [ + { label => 'parity_version', value => 'parity_version_absolute', template => '%s', min => 0 } + ], + } + }, + { label => 'parity_version_hash', nlabel => 'parity.version.hash', set => { + key_values => [ { name => 'parity_version_hash' } ], + output_template => "Parity version hash is: %s ", + perfdatas => [ + { label => 'parity_version_hash', value => 'parity_version_hash_absolute', template => '%s', min => 0 } + ], + } + }, + { label => 'chain_name', nlabel => 'parity.chain.name', set => { + key_values => [ { name => 'chain_name' } ], + output_template => "Chain name is: %s ", + perfdatas => [ + { label => 'chain_name', value => 'chain_name_absolute', template => '%s', min => 0 } + ], + } + }, + { label => 'pending_transactions', nlabel => 'parity.pending.transactions', set => { + key_values => [ { name => 'pending_transactions' } ], + output_template => "Pending transactions: %d ", + perfdatas => [ + { label => 'pending_transactions', value => 'pending_transactions_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'mempool', nlabel => 'parity.mempol.capacity', set => { + key_values => [ { name => 'mempool' } ], + output_template => "Mempool: %d % ", + perfdatas => [ + { label => 'mempool', value => 'mempool_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'peers_connected', nlabel => 'parity.peers.connected', set => { + key_values => [ { name => 'peers_connected' } ], + output_template => "Number of connected peers: %d ", + perfdatas => [ + { label => 'peers_connected', value => 'peers_connected_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'peers_max', nlabel => 'parity.peers.max.connected', set => { + key_values => [ { name => 'peers_max' } ], + output_template => "Maximum number of connected peers: %d ", + perfdatas => [ + { label => 'peers_max', value => 'peers_max_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'peers', nlabel => 'parity.peers', set => { + key_values => [ { name => 'peers' } ], + output_template => "Peers: %d ", + perfdatas => [ + { label => 'peers', value => 'peers_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'enode', nlabel => 'parity.node.enode.uri', set => { + key_values => [ { name => 'enode' } ], + output_template => "Node enode URI: %s ", + perfdatas => [ + { label => 'enode', value => 'enode_absolute', template => '%s', min => 0 } + ], + } + }, + { label => 'node_name', nlabel => 'parity.node.name', set => { + key_values => [ { name => 'node_name' } ], + output_template => "Node name: %s ", + perfdatas => [ + { label => 'node_name', value => 'node_name_absolute', template => '%s', min => 0 } + ], + } + } + ]; +} + +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 => { + 'unknown-status:s' => { name => 'unknown_status', default => '' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '%{listening} !~ /true/' }, + }); + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->change_macros(macros => ['unknown_status', 'warning_status', 'critical_status']); +} + +sub prefix_module_output { + my ($self, %options) = @_; + + return "Parity module: "; +} + +sub manage_selection { + my ($self, %options) = @_; + + my $query_form_post = [ { method => 'parity_versionInfo', params => [], id => "1", jsonrpc => "2.0" }, + { method => 'parity_chain', params => [], id => "2", jsonrpc => "2.0" }, + { method => 'parity_pendingTransactions', params => [], id => "3", jsonrpc => "2.0" } , + { method => 'parity_netPeers', params => [], id => "4", jsonrpc => "2.0" }, + { method => 'parity_enode', params => [], id => "5", jsonrpc => "2.0" }, + { method => 'parity_nodeName', params => [], id => "6", jsonrpc => "2.0" }, + { method => 'parity_transactionsLimit', params => [], id => "7", jsonrpc => "2.0" } # could be done once, at the beginning of the process + ]; + + my $result = $options{custom}->request_api(method => 'POST', query_form_post => $query_form_post); + + # Parity version construction + my $res_parity_version = @{$result}[0]->{result}->{version}->{major} . @{$result}[0]->{result}->{version}->{minor} . @{$result}[0]->{result}->{version}->{patch}; + + $self->{eth} = { parity_version => $res_parity_version, + parity_version_hash => @{$result}[0]->{result}->{hash}, + chain_name => @{$result}[1]->{result}, + pending_transactions => scalar @{$result}[2]->{result}, + mempool => @{$result}[2]->{result} / @{$result}[6]->{result} * 100, + peers_connected => @{$result}[3]->{result}->{connected}, + peers_max => @{$result}[3]->{result}->{max}, + peers => scalar @{$result}[3]->{result}->{peers}, + enode => @{$result}[4]->{result}, + node_name => @{$result}[5]->{result} }; + +} + +1; + +__END__ + +=head1 MODE + +Check parity module metrics parity (parity_versionInfo, ) + +=over 8 + +=item B<--unknown-status> + +Set unknown threshold for listening status (Default: ''). + +=item B<--warning-status> + +Set warning threshold for listening status (Default: ''). + +=item B<--critical-status> + +Set critical threshold for listening status (Default: '%{listening} !~ /true/'). + +=item B<--warning-peers> B<--critical-peers> + +Warning and Critical threhsold on the number of peer + +=back + +=cut From 930b1fc22636b7f2ea4143d6d10562932ebf6f68 Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Thu, 26 Mar 2020 08:45:23 +0000 Subject: [PATCH 005/283] adding parity mode --- blockchain/parity/restapi/plugin.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/blockchain/parity/restapi/plugin.pm b/blockchain/parity/restapi/plugin.pm index 64e9f0a9b..7cffb8686 100644 --- a/blockchain/parity/restapi/plugin.pm +++ b/blockchain/parity/restapi/plugin.pm @@ -31,8 +31,9 @@ sub new { $self->{version} = '0.1'; %{$self->{modes}} = ( - 'net' => 'blockchain::parity::restapi::mode::net', - 'eth' => 'blockchain::parity::restapi::mode::eth', + 'net' => 'blockchain::parity::restapi::mode::net', + 'eth' => 'blockchain::parity::restapi::mode::eth', + 'parity' => 'blockchain::parity::restapi::mode::parity' ); $self->{custom_modes}{api} = 'blockchain::parity::restapi::custom::api'; return $self; From b8b1efc9cf13351cec1c858f7cc3bb2761d95b56 Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Thu, 26 Mar 2020 09:21:33 +0000 Subject: [PATCH 006/283] code cleanning --- blockchain/parity/restapi/mode/eth.pm | 64 ++++++++++++++------------- 1 file changed, 34 insertions(+), 30 deletions(-) diff --git a/blockchain/parity/restapi/mode/eth.pm b/blockchain/parity/restapi/mode/eth.pm index 6beec926d..5dcd4d71e 100644 --- a/blockchain/parity/restapi/mode/eth.pm +++ b/blockchain/parity/restapi/mode/eth.pm @@ -26,12 +26,12 @@ use strict; use warnings; use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); -sub custom_status_output { +sub custom_mining_status_output { my ($self, %options) = @_; return sprintf( - 'Listening status: %s ', - $self->{result_values}->{listening}, + 'Client mininig status: %s ', + $self->{result_values}->{is_mining}, ); } @@ -43,14 +43,23 @@ sub set_counters { ]; $self->{maps_counters}->{eth} = [ - { label => 'is_minning', nlabel => 'parity.eth.peers.minning.status', set => { - key_values => [ { name => 'is_minning' } ], - output_template => "Client is minning: %s ", + { label => 'is_mining', nlabel => 'parity.eth.peers.mining.status', set => { + key_values => [ { name => 'is_mining' } ], + output_template => "Client is mining: " . $self->can('custom_mining_status_output'), perfdatas => [ - { label => 'is_minning', value => 'is_minning_absolute', template => '%d', min => 0 } + { label => 'is_mining', value => 'is_mining_absolute', template => '%s', min => 0 } ], } }, + # { label => 'is_mining', nlabel => 'parity.eth.peers.mining.status', threshold => 0, set => { + # key_values => [ { name => 'is_mining' } ], + # output_template => "Client is mining: %s ", + # closure_custom_calc => \&catalog_status_calc, + # closure_custom_output => $self->can('custom_mining_status_output'), + # closure_custom_perfdata => sub { return 0; }, + # closure_custom_threshold_check => \&catalog_status_threshold + # } + # }, { label => 'coinbase', nlabel => 'parity.eth.client.coinbase', set => { key_values => [ { name => 'coinbase' } ], output_template => "Client coinbase is: %s ", @@ -156,39 +165,34 @@ sub manage_selection { my ($self, %options) = @_; my $query_form_post = [ { method => 'eth_mining', params => [], id => "1", jsonrpc => "2.0" }, - { method => 'eth_coinbase', params => [], id => "1", jsonrpc => "2.0" }, - { method => 'eth_gasPrice', params => [], id => "1", jsonrpc => "2.0" } , - { method => 'eth_hashrate', params => [], id => "1", jsonrpc => "2.0" } , - { method => 'eth_blockNumber', params => [], id => "1", jsonrpc => "2.0" }, - { method => 'eth_getBlockByNumber', params => ["latest","false"], id => "1", jsonrpc => "2.0" }, - { method => 'eth_syncing', params => [], id => "1", jsonrpc => "2.0" }, - { method => 'eth_coinbase', params => [], id => "1", jsonrpc => "2.0" }, - { method => 'eth_coinbase', params => [], id => "1", jsonrpc => "2.0" }, - { method => 'eth_coinbase', params => [], id => "1", jsonrpc => "2.0" }, - { method => 'eth_coinbase', params => [], id => "1", jsonrpc => "2.0" }, - { method => 'eth_coinbase', params => [], id => "1", jsonrpc => "2.0" } ]; + { method => 'eth_coinbase', params => [], id => "2", jsonrpc => "2.0" }, + { method => 'eth_gasPrice', params => [], id => "3", jsonrpc => "2.0" } , + { method => 'eth_hashrate', params => [], id => "4", jsonrpc => "2.0" } , + { method => 'eth_blockNumber', params => [], id => "5", jsonrpc => "2.0" }, + { method => 'eth_getBlockByNumber', params => ["latest","false"], id => "6", jsonrpc => "2.0" }, + { method => 'eth_syncing', params => [], id => "7", jsonrpc => "2.0" } ]; my $result = $options{custom}->request_api(method => 'POST', query_form_post => $query_form_post); # conditional formating: - my $res_sync = @{$result}[6]->{result} ? (@{$result}[6]->{result}->{currentBlock} / @{$result}[6]->{result}->{highestBlock}) * 100 : 100; + my $res_sync = @{$result}[6]->{result} ? hex((@{$result}[6]->{result}->{currentBlock} / @{$result}[6]->{result}->{highestBlock})) * 100 : 100; my $res_startingBlock = $res_sync != 100 ? @{$result}[6]->{result}->{startingBlock} : undef; my $res_currentBlock = $res_sync != 100 ? @{$result}[6]->{result}->{currentBlock} : undef; my $res_highestBlock = $res_sync != 100 ? @{$result}[6]->{result}->{highestBlock} : undef; # Unix time conversion - my $res_timestamp = localtime((@{$result}[5]->{result}->{timestamp})); + my $res_timestamp = localtime(hex(@{$result}[5]->{result}->{timestamp})); - $self->{eth} = { is_minning => @{$result}[0]->{result}, - coinbase => @{$result}[1]->{result}, - gas_price => @{$result}[2]->{result}, - hashrate => hex(@{$result}[3]->{result}), - block_number => @{$result}[4]->{result}, - block_time => $res_timestamp, - sync_start => $res_startingBlock, - sync_current => $res_currentBlock, - sync_highest => $res_highestBlock, - sync => $res_sync }; + $self->{eth} = { is_mining => @{$result}[0]->{result}, + coinbase => @{$result}[1]->{result}, + gas_price => hex(@{$result}[2]->{result}), + hashrate => hex(@{$result}[3]->{result}), + block_number => hex(@{$result}[4]->{result}), + block_time => $res_timestamp, + sync_start => hex($res_startingBlock), + sync_current => hex($res_currentBlock), + sync_highest => hex($res_highestBlock), + sync => $res_sync }; } From 13f578bd7792df63690ae53de28be1881eb04ef1 Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Thu, 26 Mar 2020 17:10:09 +0000 Subject: [PATCH 007/283] counters split --- blockchain/parity/restapi/mode/eth.pm | 118 ++++++++++++-------- blockchain/parity/restapi/mode/parity.pm | 134 ++++++++++++++--------- 2 files changed, 150 insertions(+), 102 deletions(-) diff --git a/blockchain/parity/restapi/mode/eth.pm b/blockchain/parity/restapi/mode/eth.pm index 5dcd4d71e..21aa5498b 100644 --- a/blockchain/parity/restapi/mode/eth.pm +++ b/blockchain/parity/restapi/mode/eth.pm @@ -26,7 +26,7 @@ use strict; use warnings; use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); -sub custom_mining_status_output { +sub custom_status_output { my ($self, %options) = @_; return sprintf( @@ -39,30 +39,17 @@ sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ - { name => 'eth', cb_prefix_output => 'prefix_module_output', type => 0 }, + { name => 'global', cb_prefix_output => 'prefix_module_output', type => 0 }, + { name => 'peer', cb_prefix_output => 'prefix_module_output', type => 0 }, + { name => 'block', cb_prefix_output => 'prefix_module_output', type => 0 }, + { name => 'sync', cb_prefix_output => 'prefix_module_output', type => 0 } ]; - $self->{maps_counters}->{eth} = [ - { label => 'is_mining', nlabel => 'parity.eth.peers.mining.status', set => { - key_values => [ { name => 'is_mining' } ], - output_template => "Client is mining: " . $self->can('custom_mining_status_output'), - perfdatas => [ - { label => 'is_mining', value => 'is_mining_absolute', template => '%s', min => 0 } - ], - } - }, - # { label => 'is_mining', nlabel => 'parity.eth.peers.mining.status', threshold => 0, set => { - # key_values => [ { name => 'is_mining' } ], - # output_template => "Client is mining: %s ", - # closure_custom_calc => \&catalog_status_calc, - # closure_custom_output => $self->can('custom_mining_status_output'), - # closure_custom_perfdata => sub { return 0; }, - # closure_custom_threshold_check => \&catalog_status_threshold - # } - # }, + $self->{maps_counters}->{global} = [ { label => 'coinbase', nlabel => 'parity.eth.client.coinbase', set => { key_values => [ { name => 'coinbase' } ], output_template => "Client coinbase is: %s ", + # closure_custom_perfdata => sub { return 0; } perfdatas => [ { label => 'client_coinbase', value => 'coinbase_absolute', template => '%s', min => 0 } ], @@ -75,6 +62,25 @@ sub set_counters { { label => 'gas_price', value => 'gas_price_absolute', template => '%d', min => 0 } ], } + } + ]; + + $self->{maps_counters}->{peer} = [ + # { label => 'status', nlabel => 'parity.eth.peers.mining.status', set => { + # key_values => [ { name => 'is_mining' } ], + # output_template => "Client is mining: " . $self->can('custom_mining_status_output'), + # perfdatas => [ + # { label => 'is_mining', value => 'is_mining_absolute', template => '%s', min => 0 } + # ], + # } + # }, + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'is_mining' } ], + closure_custom_calc => \&catalog_status_calc, + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold + } }, { label => 'hashrate', nlabel => 'parity.eth.node.hashrate', set => { key_values => [ { name => 'hashrate' } ], @@ -84,41 +90,52 @@ sub set_counters { ], } }, + ]; + + $self->{maps_counters}->{block} = [ { label => 'block_number', nlabel => 'parity.eth.block.number', set => { key_values => [ { name => 'block_number' } ], output_template => "Most recent block number is: %d ", - perfdatas => [ - { label => 'block_number', value => 'block_number_absolute', template => '%d', min => 0 } - ], + closure_custom_perfdata => sub { return 0; } + # perfdatas => [ + # { label => 'block_number', value => 'block_number_absolute', template => '%d', min => 0 } + # ], } }, { label => 'block_time', nlabel => 'parity.eth.block.time', set => { key_values => [ { name => 'block_time' } ], output_template => "Block time is: %s ", - perfdatas => [ - { label => 'block_time', value => 'block_time_absolute', template => '%s', min => 0 } - ], + closure_custom_perfdata => sub { return 0; } + # perfdatas => [ + # { label => 'block_time', value => 'block_time_absolute', template => '%s', min => 0 } + # ], } }, + ]; + + $self->{maps_counters}->{sync} = [ { label => 'sync_start', nlabel => 'parity.eth.sync.start.block', set => { key_values => [ { name => 'sync_start' } ], output_template => "Sync start block number is: %d ", - perfdatas => [ - { label => 'sync_start', value => 'sync_start_absolute', template => '%d', min => 0 } - ], + closure_custom_perfdata => sub { return 0; } + # perfdatas => [ + # { label => 'sync_start', value => 'sync_start_absolute', template => '%d', min => 0 } + # ], } }, { label => 'sync_current', nlabel => 'parity.eth.sync.current.block', set => { key_values => [ { name => 'sync_current' } ], output_template => "Sync current block number is: %d ", - perfdatas => [ - { label => 'sync_current', value => 'sync_current_absolute', template => '%d', min => 0 } - ], + closure_custom_perfdata => sub { return 0; } + # perfdatas => [ + # { label => 'sync_current', value => 'sync_current_absolute', template => '%d', min => 0 } + # ], } }, { label => 'sync_highest', nlabel => 'parity.eth.sync.highest.block', set => { key_values => [ { name => 'sync_highest' } ], output_template => "Sync highest block number is: %d ", + # closure_custom_perfdata => sub { return 0; } perfdatas => [ { label => 'sync_highest', value => 'sync_highest_absolute', template => '%d', min => 0 } ], @@ -131,7 +148,7 @@ sub set_counters { { label => 'sync', value => 'sync_absolute', template => '%d', min => 0 } ], } - } + } ]; } @@ -169,31 +186,36 @@ sub manage_selection { { method => 'eth_gasPrice', params => [], id => "3", jsonrpc => "2.0" } , { method => 'eth_hashrate', params => [], id => "4", jsonrpc => "2.0" } , { method => 'eth_blockNumber', params => [], id => "5", jsonrpc => "2.0" }, - { method => 'eth_getBlockByNumber', params => ["latest","false"], id => "6", jsonrpc => "2.0" }, + { method => 'eth_getBlockByNumber', params => ["latest",\0], id => "6", jsonrpc => "2.0" }, { method => 'eth_syncing', params => [], id => "7", jsonrpc => "2.0" } ]; my $result = $options{custom}->request_api(method => 'POST', query_form_post => $query_form_post); - + + # use Data::Dumper; + # print Dumper($result); + # conditional formating: my $res_sync = @{$result}[6]->{result} ? hex((@{$result}[6]->{result}->{currentBlock} / @{$result}[6]->{result}->{highestBlock})) * 100 : 100; - my $res_startingBlock = $res_sync != 100 ? @{$result}[6]->{result}->{startingBlock} : undef; - my $res_currentBlock = $res_sync != 100 ? @{$result}[6]->{result}->{currentBlock} : undef; - my $res_highestBlock = $res_sync != 100 ? @{$result}[6]->{result}->{highestBlock} : undef; + my $res_startingBlock = $res_sync != 100 ? hex(@{$result}[6]->{result}->{startingBlock}) : undef; + my $res_currentBlock = $res_sync != 100 ? hex(@{$result}[6]->{result}->{currentBlock}) : undef; + my $res_highestBlock = $res_sync != 100 ? hex(@{$result}[6]->{result}->{highestBlock}) : undef; # Unix time conversion my $res_timestamp = localtime(hex(@{$result}[5]->{result}->{timestamp})); - $self->{eth} = { is_mining => @{$result}[0]->{result}, - coinbase => @{$result}[1]->{result}, - gas_price => hex(@{$result}[2]->{result}), - hashrate => hex(@{$result}[3]->{result}), - block_number => hex(@{$result}[4]->{result}), - block_time => $res_timestamp, - sync_start => hex($res_startingBlock), - sync_current => hex($res_currentBlock), - sync_highest => hex($res_highestBlock), + $self->{global} = { coinbase => @{$result}[1]->{result}, + gas_price => hex(@{$result}[2]->{result}) }; + + $self->{block} = { block_number => defined @{$result}[4]->{result} ? hex(@{$result}[4]->{result}) : 0, + block_time => $res_timestamp }; + + $self->{sync} = { sync_start => $res_startingBlock, + sync_current => $res_currentBlock, + sync_highest => $res_highestBlock, sync => $res_sync }; + $self->{peer} = { is_mining => @{$result}[0]->{result}, + hashrate => hex(@{$result}[3]->{result}) }; } 1; @@ -216,7 +238,7 @@ Set warning threshold for listening status (Default: ''). =item B<--critical-status> -Set critical threshold for listening status (Default: '%{listening} !~ /true/'). +Set critical threshold for listening status (Default: '%{is_mining} !~ /true/'). =item B<--warning-peers> B<--critical-peers> diff --git a/blockchain/parity/restapi/mode/parity.pm b/blockchain/parity/restapi/mode/parity.pm index 122fd090b..099216314 100644 --- a/blockchain/parity/restapi/mode/parity.pm +++ b/blockchain/parity/restapi/mode/parity.pm @@ -30,50 +30,64 @@ sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ - { name => 'parity', cb_prefix_output => 'prefix_module_output', type => 0 }, + { name => 'global', cb_prefix_output => 'prefix_module_output', type => 0 }, + { name => 'node', cb_prefix_output => 'prefix_module_output', type => 0 }, + { name => 'mempool', cb_prefix_output => 'prefix_module_output', type => 0 }, + { name => 'network', cb_prefix_output => 'prefix_module_output', type => 0 } ]; - $self->{maps_counters}->{parity} = [ + $self->{maps_counters}->{global} = [ { label => 'parity_version', nlabel => 'parity.version', set => { key_values => [ { name => 'parity_version' } ], output_template => "Parity version is: %s ", - perfdatas => [ - { label => 'parity_version', value => 'parity_version_absolute', template => '%s', min => 0 } - ], + closure_custom_perfdata => sub { return 0; } + # perfdatas => [ + # { label => 'parity_version', value => 'parity_version_absolute', template => '%s', min => 0 } + # ], } }, { label => 'parity_version_hash', nlabel => 'parity.version.hash', set => { key_values => [ { name => 'parity_version_hash' } ], output_template => "Parity version hash is: %s ", - perfdatas => [ - { label => 'parity_version_hash', value => 'parity_version_hash_absolute', template => '%s', min => 0 } - ], + closure_custom_perfdata => sub { return 0; } + # perfdatas => [ + # { label => 'parity_version_hash', value => 'parity_version_hash_absolute', template => '%s', min => 0 } + # ], } }, { label => 'chain_name', nlabel => 'parity.chain.name', set => { key_values => [ { name => 'chain_name' } ], output_template => "Chain name is: %s ", - perfdatas => [ - { label => 'chain_name', value => 'chain_name_absolute', template => '%s', min => 0 } - ], + closure_custom_perfdata => sub { return 0; } + # perfdatas => [ + # { label => 'chain_name', value => 'chain_name_absolute', template => '%s', min => 0 } + # ], } }, - { label => 'pending_transactions', nlabel => 'parity.pending.transactions', set => { - key_values => [ { name => 'pending_transactions' } ], - output_template => "Pending transactions: %d ", - perfdatas => [ - { label => 'pending_transactions', value => 'pending_transactions_absolute', template => '%d', min => 0 } - ], + ]; + + $self->{maps_counters}->{node} = [ + { label => 'enode', nlabel => 'parity.node.enode.uri', set => { + key_values => [ { name => 'enode' } ], + output_template => "Node enode URI: %s ", + closure_custom_perfdata => sub { return 0; } + # perfdatas => [ + # { label => 'enode', value => 'enode_absolute', template => '%s', min => 0 } + # ], } }, - { label => 'mempool', nlabel => 'parity.mempol.capacity', set => { - key_values => [ { name => 'mempool' } ], - output_template => "Mempool: %d % ", - perfdatas => [ - { label => 'mempool', value => 'mempool_absolute', template => '%d', min => 0 } - ], + { label => 'node_name', nlabel => 'parity.node.name', set => { + key_values => [ { name => 'node_name' } ], + output_template => "Node name: %s ", + closure_custom_perfdata => sub { return 0; } + # perfdatas => [ + # { label => 'node_name', value => 'node_name_absolute', template => '%s', min => 0 } + # ], } - }, + } + ]; + + $self->{maps_counters}->{network} = [ { label => 'peers_connected', nlabel => 'parity.peers.connected', set => { key_values => [ { name => 'peers_connected' } ], output_template => "Number of connected peers: %d ", @@ -97,24 +111,28 @@ sub set_counters { { label => 'peers', value => 'peers_absolute', template => '%d', min => 0 } ], } - }, - { label => 'enode', nlabel => 'parity.node.enode.uri', set => { - key_values => [ { name => 'enode' } ], - output_template => "Node enode URI: %s ", - perfdatas => [ - { label => 'enode', value => 'enode_absolute', template => '%s', min => 0 } - ], - } - }, - { label => 'node_name', nlabel => 'parity.node.name', set => { - key_values => [ { name => 'node_name' } ], - output_template => "Node name: %s ", - perfdatas => [ - { label => 'node_name', value => 'node_name_absolute', template => '%s', min => 0 } - ], - } } ]; + + $self->{maps_counters}->{mempool} = [ + { label => 'pending_transactions', nlabel => 'parity.pending.transactions', set => { + key_values => [ { name => 'pending_transactions' } ], + output_template => "Pending transactions: %d ", + perfdatas => [ + { label => 'pending_transactions', value => 'pending_transactions_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'mempool', nlabel => 'parity.mempol.capacity', set => { + key_values => [ { name => 'mempool' } ], + output_template => "Mempool: %d % ", + perfdatas => [ + { label => 'mempool', value => 'mempool_absolute', template => '%d', min => 0 } + ], + } + }, + ]; + } sub new { @@ -152,24 +170,32 @@ sub manage_selection { { method => 'parity_netPeers', params => [], id => "4", jsonrpc => "2.0" }, { method => 'parity_enode', params => [], id => "5", jsonrpc => "2.0" }, { method => 'parity_nodeName', params => [], id => "6", jsonrpc => "2.0" }, - { method => 'parity_transactionsLimit', params => [], id => "7", jsonrpc => "2.0" } # could be done once, at the beginning of the process - ]; + { method => 'parity_transactionsLimit', params => [], id => "7", jsonrpc => "2.0" } ]; # parity_transactionsLimit could be done once, at the beginning of the process + my $result = $options{custom}->request_api(method => 'POST', query_form_post => $query_form_post); # Parity version construction - my $res_parity_version = @{$result}[0]->{result}->{version}->{major} . @{$result}[0]->{result}->{version}->{minor} . @{$result}[0]->{result}->{version}->{patch}; + my $res_parity_version = @{$result}[0]->{result}->{version}->{major} . '.' . @{$result}[0]->{result}->{version}->{minor} . '.' . @{$result}[0]->{result}->{version}->{patch}; - $self->{eth} = { parity_version => $res_parity_version, - parity_version_hash => @{$result}[0]->{result}->{hash}, - chain_name => @{$result}[1]->{result}, - pending_transactions => scalar @{$result}[2]->{result}, - mempool => @{$result}[2]->{result} / @{$result}[6]->{result} * 100, - peers_connected => @{$result}[3]->{result}->{connected}, - peers_max => @{$result}[3]->{result}->{max}, - peers => scalar @{$result}[3]->{result}->{peers}, - enode => @{$result}[4]->{result}, - node_name => @{$result}[5]->{result} }; + + # use Data::Dumper; + # print Dumper($res_parity_version); + + + $self->{global} = { parity_version => $res_parity_version, + parity_version_hash => @{$result}[0]->{result}->{hash}, + chain_name => @{$result}[1]->{result} }; + + $self->{node} = { enode => @{$result}[4]->{result}, + node_name => @{$result}[5]->{result} }; + + $self->{network} = { peers_connected => @{$result}[3]->{result}->{connected}, + peers_max => @{$result}[3]->{result}->{max}, + peers => length(@{$result}[3]->{result}->{peers}) }; + + $self->{mempool} = { pending_transactions => length(@{$result}[2]->{result}), + mempool => @{$result}[2]->{result} / @{$result}[6]->{result} * 100 }; } @@ -179,7 +205,7 @@ __END__ =head1 MODE -Check parity module metrics parity (parity_versionInfo, ) +Check parity module metrics parity (parity_versionInfo, parity_chain, parity_pendingTransactions, parity_netPeers, parity_enode, parity_nodeName, parity_transactionsLimit) =over 8 From 1b2955a619b944a0005fcf7dd476107af12b57b8 Mon Sep 17 00:00:00 2001 From: Sims24 Date: Fri, 27 Mar 2020 16:12:08 +0100 Subject: [PATCH 008/283] dirty code update as an example --- blockchain/parity/restapi/mode/parity.pm | 26 ++++++++++++++---------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/blockchain/parity/restapi/mode/parity.pm b/blockchain/parity/restapi/mode/parity.pm index 099216314..0050e1ce9 100644 --- a/blockchain/parity/restapi/mode/parity.pm +++ b/blockchain/parity/restapi/mode/parity.pm @@ -30,17 +30,18 @@ sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ - { name => 'global', cb_prefix_output => 'prefix_module_output', type => 0 }, +# { name => 'global', cb_prefix_output => 'prefix_module_output', type => 0 }, { name => 'node', cb_prefix_output => 'prefix_module_output', type => 0 }, { name => 'mempool', cb_prefix_output => 'prefix_module_output', type => 0 }, { name => 'network', cb_prefix_output => 'prefix_module_output', type => 0 } ]; $self->{maps_counters}->{global} = [ - { label => 'parity_version', nlabel => 'parity.version', set => { + { label => 'parity_version', nlabel => 'parity.version', threshold => 0, set => { key_values => [ { name => 'parity_version' } ], output_template => "Parity version is: %s ", - closure_custom_perfdata => sub { return 0; } + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => sub { return 0; } # perfdatas => [ # { label => 'parity_version', value => 'parity_version_absolute', template => '%s', min => 0 } # ], @@ -67,10 +68,11 @@ sub set_counters { ]; $self->{maps_counters}->{node} = [ - { label => 'enode', nlabel => 'parity.node.enode.uri', set => { + { label => 'enode', nlabel => 'parity.node.enode.uri', threshold => 0, set => { key_values => [ { name => 'enode' } ], output_template => "Node enode URI: %s ", - closure_custom_perfdata => sub { return 0; } + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => sub { return 0; } # perfdatas => [ # { label => 'enode', value => 'enode_absolute', template => '%s', min => 0 } # ], @@ -125,7 +127,7 @@ sub set_counters { }, { label => 'mempool', nlabel => 'parity.mempol.capacity', set => { key_values => [ { name => 'mempool' } ], - output_template => "Mempool: %d % ", + output_template => "Mempool: %d %% ", perfdatas => [ { label => 'mempool', value => 'mempool_absolute', template => '%d', min => 0 } ], @@ -182,13 +184,15 @@ sub manage_selection { # use Data::Dumper; # print Dumper($res_parity_version); + $self->{output}->output_add(long_msg => "[config] chain name: " . @{$result}[1]->{result} . " parity version: " . $res_parity_version . " version_hash: " . @{$result}[0]->{result}->{hash}, + severity => 'OK'); - $self->{global} = { parity_version => $res_parity_version, - parity_version_hash => @{$result}[0]->{result}->{hash}, - chain_name => @{$result}[1]->{result} }; +# $self->{global} = { parity_version => $res_parity_version, +# parity_version_hash => @{$result}[0]->{result}->{hash}, +# chain_name => @{$result}[1]->{result} }; - $self->{node} = { enode => @{$result}[4]->{result}, - node_name => @{$result}[5]->{result} }; +# $self->{node} = { enode => @{$result}[4]->{result}, +# node_name => @{$result}[5]->{result} }; $self->{network} = { peers_connected => @{$result}[3]->{result}->{connected}, peers_max => @{$result}[3]->{result}->{max}, From b119ecf68d54a1f98f6f86ef6167086fd2306b59 Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Fri, 27 Mar 2020 15:51:49 +0000 Subject: [PATCH 009/283] formating fix --- blockchain/parity/restapi/mode/eth.pm | 2 +- blockchain/parity/restapi/mode/parity.pm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/blockchain/parity/restapi/mode/eth.pm b/blockchain/parity/restapi/mode/eth.pm index 21aa5498b..de8eb872f 100644 --- a/blockchain/parity/restapi/mode/eth.pm +++ b/blockchain/parity/restapi/mode/eth.pm @@ -143,7 +143,7 @@ sub set_counters { }, { label => 'sync', nlabel => 'parity.eth.sync.ratio', set => { key_values => [ { name => 'sync' } ], - output_template => "Sync ratio is: %d% ", + output_template => "Sync ratio is: %d%% ", perfdatas => [ { label => 'sync', value => 'sync_absolute', template => '%d', min => 0 } ], diff --git a/blockchain/parity/restapi/mode/parity.pm b/blockchain/parity/restapi/mode/parity.pm index 099216314..cbc70e312 100644 --- a/blockchain/parity/restapi/mode/parity.pm +++ b/blockchain/parity/restapi/mode/parity.pm @@ -125,7 +125,7 @@ sub set_counters { }, { label => 'mempool', nlabel => 'parity.mempol.capacity', set => { key_values => [ { name => 'mempool' } ], - output_template => "Mempool: %d % ", + output_template => "Mempool: %d %% ", perfdatas => [ { label => 'mempool', value => 'mempool_absolute', template => '%d', min => 0 } ], From 56852ef82e37633ce69e55fa4c7fd0f1c7b3ba25 Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Wed, 8 Apr 2020 16:34:15 +0000 Subject: [PATCH 010/283] eth-poller plugin and restapi plugin update --- blockchain/parity/ethpoller/custom/api.pm | 204 ++++++++++++++++++ blockchain/parity/ethpoller/mode/fork.pm | 98 +++++++++ blockchain/parity/ethpoller/mode/stats.pm | 114 ++++++++++ blockchain/parity/ethpoller/mode/watchlist.pm | 130 +++++++++++ blockchain/parity/ethpoller/plugin.pm | 50 +++++ blockchain/parity/restapi/mode/eth.pm | 175 +++++++-------- blockchain/parity/restapi/mode/net.pm | 29 ++- blockchain/parity/restapi/mode/parity.pm | 147 +++---------- 8 files changed, 720 insertions(+), 227 deletions(-) create mode 100644 blockchain/parity/ethpoller/custom/api.pm create mode 100644 blockchain/parity/ethpoller/mode/fork.pm create mode 100644 blockchain/parity/ethpoller/mode/stats.pm create mode 100644 blockchain/parity/ethpoller/mode/watchlist.pm create mode 100644 blockchain/parity/ethpoller/plugin.pm diff --git a/blockchain/parity/ethpoller/custom/api.pm b/blockchain/parity/ethpoller/custom/api.pm new file mode 100644 index 000000000..b6462c32f --- /dev/null +++ b/blockchain/parity/ethpoller/custom/api.pm @@ -0,0 +1,204 @@ +# +# Copyright 2020 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 blockchain::parity::ethpoller::custom::api; + +use strict; +use warnings; +use centreon::plugins::http; +use DateTime; +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 => { + "hostname:s" => { name => 'hostname' }, + "port:s" => { name => 'port' }, + "proto:s" => { name => 'proto' }, + "url-path:s" => { name => 'url_path' }, + "timeout:s" => { name => 'timeout' }, + }); + } + $options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1); + + $self->{output} = $options{output}; + $self->{mode} = $options{mode}; + $self->{http} = centreon::plugins::http->new(%options); + + return $self; +} + +sub set_options { + my ($self, %options) = @_; + + $self->{option_results} = $options{option_results}; +} + +sub set_defaults { + my ($self, %options) = @_; + + 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} = (defined($self->{option_results}->{hostname})) ? $self->{option_results}->{hostname} : undef; + $self->{port} = (defined($self->{option_results}->{port})) ? $self->{option_results}->{port} : 8000; + $self->{proto} = (defined($self->{option_results}->{proto})) ? $self->{option_results}->{proto} : 'http'; + $self->{url_path} = (defined($self->{option_results}->{url_path})) ? $self->{option_results}->{url_path} : ''; + $self->{timeout} = (defined($self->{option_results}->{timeout})) ? $self->{option_results}->{timeout} : 10; + + 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}->{url_path} = $self->{url_path}; + $self->{option_results}->{warning_status} = ''; + $self->{option_results}->{critical_status} = ''; +} + +sub settings { + my ($self, %options) = @_; + + $self->build_options_for_httplib(); + $self->{http}->add_header(key => 'Accept', value => 'application/json'); + $self->{http}->set_options(%{$self->{option_results}}); +} + +sub get_connection_info { + my ($self, %options) = @_; + + return $self->{hostname} . ":" . $self->{port}; +} + +sub get_hostname { + my ($self, %options) = @_; + + return $self->{hostname}; +} + +sub get_port { + my ($self, %options) = @_; + + return $self->{port}; +} + +sub request_api { + my ($self, %options) = @_; + + $self->settings; + + $self->{output}->output_add(long_msg => "Query URL: '" . $self->{proto} . "://" . $self->{hostname} . + $self->{url_path} . $options{url_path} . "'", debug => 1); + + my $content = $self->{http}->request(url_path => $self->{url_path} . $options{url_path}); + + my $decoded; + eval { + $decoded = JSON::XS->new->utf8->decode($content); + }; + if ($@) { + $self->{output}->add_option_msg(short_msg => "Cannot decode json response: $@"); + $self->{output}->option_exit(); + } + + return $decoded; +} + +1; + +__END__ + +=head1 NAME + +Parity eth-poller Rest API + +=head1 SYNOPSIS + +Parity eth-poller Rest API custom mode + +=head1 REST API OPTIONS + +Parity eth-poller Rest API + +=over 8 + +=item B<--hostname> + +Parity eth-poller API hostname. + +=item B<--port> + +API port (Default: 8000) + +=item B<--proto> + +Specify https if needed (Default: 'http') + +=item B<--url-path> + +API URL path (Default: '') + +=item B<--timeout> + +Set HTTP timeout + +=back + +=head1 DESCRIPTION + +B. + +=cut \ No newline at end of file diff --git a/blockchain/parity/ethpoller/mode/fork.pm b/blockchain/parity/ethpoller/mode/fork.pm new file mode 100644 index 000000000..226fdbc4a --- /dev/null +++ b/blockchain/parity/ethpoller/mode/fork.pm @@ -0,0 +1,98 @@ +# +# Copyright 2020 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 blockchain::parity::ethpoller::mode::fork; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); + +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 => { + 'unknown-status:s' => { name => 'unknown_status', default => '' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '%{listening} !~ /true/' }, + }); + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + my $result = $options{custom}->request_api(url_path => '/fork'); + + # use Data::Dumper; + # print Dumper($result); + + # Unix time conversion + my $res_timestamp = localtime(hex($result->{last_update}->{timestamp})); + + # Alerts management + my $cache = Cache::File->new( cache_root => './parity-eth-poller-cache' ); + + if (my $cached_timestamp = $cache->get('fork_timestamp')) { + if ($cached_timestamp ne $res_timestamp) { + #alert + } + } else { + $cache->set('fork_timestamp', $res_timestamp); + } + + $self->{output}->output_add(severity => 'OK', long_msg => '[Fork]: fork_timestamp: ' . $res_timestamp . + ' | fork_occurence: ' . $result->{occurence} . ' | fork_blockNumber: ' . $result->{last_update}->{blockNumber} . + ' | fork_in: ' . $result->{last_update}->{in} . ' | fork_out: ' . $result->{last_update}->{out} ); + +} + +1; + +__END__ + +=head1 MODE + +Check Parity eth-poller for forks details + +=over 8 + +=item B<--unknown-status> + +Set unknown threshold for listening status (Default: ''). + +=item B<--warning-status> + +Set warning threshold for listening status (Default: ''). + +=item B<--critical-status> + +Set critical threshold for listening status (Default: '%{is_mining} !~ /true/'). + +=item B<--warning-peers> B<--critical-peers> + +Warning and Critical threhsold on the number of peer + +=back + +=cut diff --git a/blockchain/parity/ethpoller/mode/stats.pm b/blockchain/parity/ethpoller/mode/stats.pm new file mode 100644 index 000000000..4844e9d6f --- /dev/null +++ b/blockchain/parity/ethpoller/mode/stats.pm @@ -0,0 +1,114 @@ +# +# Copyright 2020 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 blockchain::parity::ethpoller::mode::stats; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use Digest::MD5 qw(md5_hex); + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', cb_prefix_output => 'prefix_module_output', type => 0 }, + ]; + + $self->{maps_counters}->{global} = [ + { label => 'stats_blockInterval', nlabel => 'parity.network.peers.count', set => { + key_values => [ { name => 'stats_blockInterval' } ], + output_template => "Block interval: %d ", + perfdatas => [ + { label => 'stats_blockInterval', value => 'stats_blockInterval_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'stats_contracts', nlabel => 'eth.poller.stats.contracts.number', set => { + key_values => [ { name => 'stats_contracts' } ], + output_template => "Cumulative contracts: %d ", + perfdatas => [ + { label => 'stats_contracts', value => 'stats_contracts_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'stats_blocks', nlabel => 'eth.poller.stats.blocks.number', set => { + key_values => [ { name => 'stats_blocks' } ], + output_template => "Cumulative blocks: %d ", + perfdatas => [ + { label => 'stats_blocks', value => 'stats_blocks_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'stats_transactions', nlabel => 'eth.poller.stats.transactions.number', set => { + key_values => [ { name => 'stats_transactions' } ], + output_template => "Cumulative transactions: %d ", + perfdatas => [ + { label => 'stats_transactions', value => 'stats_transactions_absolute', template => '%d', min => 0 } + ], + } + }, + ]; + +} + +sub prefix_output { + my ($self, %options) = @_; + + return "Stats '"; +} + +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' }, + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + my $result = $options{custom}->request_api(url_path => '/stats'); + + # use Data::Dumper; + # print Dumper($result); + + $self->{global} = { stats_blockInterval => $result->{blockInterval}, + stats_contracts => $result->{cumulative}->{contracts}, + stats_blocks => $result->{cumulative}->{blocks}, + stats_transactions => $result->{cumulative}->{transactions} + }; +} + +1; + +__END__ + +=head1 MODE + +Check Parity eth-poller for accounts tracking + +=cut diff --git a/blockchain/parity/ethpoller/mode/watchlist.pm b/blockchain/parity/ethpoller/mode/watchlist.pm new file mode 100644 index 000000000..8a6e734f2 --- /dev/null +++ b/blockchain/parity/ethpoller/mode/watchlist.pm @@ -0,0 +1,130 @@ +# +# Copyright 2020 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 blockchain::parity::ethpoller::mode::watchlist; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use Digest::MD5 qw(md5_hex); + +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' }, + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + my $results = $options{custom}->request_api(url_path => '/watchlist'); + + # use Data::Dumper; + # print Dumper($results); + + # Alerts management + my $cache = Cache::File->new( cache_root => './parity-eth-poller-cache' ); + + if (my $cached_balance = $cache->get('contract_balance')) { + if ($cached_balance != $contract->{balance}) { + #alert + } + } else { + $cache->set('contract_balance', $contract->{balance}); + } + + foreach my $account (@{$results->{Accounts}}) { + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $account->{id} !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping '" . $account->{id} . "': no matching filter name.", debug => 1); + next; + } + + $self->{output}->output_add(severity => 'OK', long_msg => '[Account ' . $account->{id} . ']: label: ' . $account->{label} . ' | nonce: ' . $account->{nonce} . + ' | timestamp: ' . localtime(hex($account->{last_update}->{timestamp})) . ' | blockNumber: ' . $account->{last_update}->{blockNumber} . + ' | receiver: ' . $account->{last_update}->{receiver} . ' | value: ' . $account->{last_update}->{value} ); + } + + foreach my $minner (@{$results->{Miners}}) { + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $minner->{id} !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping '" . $minner->{id} . "': no matching filter name.", debug => 1); + next; + } + + $self->{output}->output_add(severity => 'OK', long_msg => '[Minner ' . $minner->{id} . ']: label: ' . $minner->{label} . ' | blocks: ' . $minner->{blocks} . + ' | timestamp: ' . localtime(hex($minner->{last_update}->{timestamp})) . ' | blockNumber: ' . $minner->{last_update}->{blockNumber} ); + } + + foreach my $contract (@{$results->{Constracts}}) { + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $contract->{id} !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping '" . $contract->{id} . "': no matching filter name.", debug => 1); + next; + } + + $self->{output}->output_add(severity => 'OK', long_msg => '[Contract ' . $contract->{id} . ']: label: ' . $contract->{label} . ' | balance: ' . $contract->{balance} . + ' | timestamp: ' . localtime(hex($contract->{last_update}->{timestamp})) . ' | blockNumber: ' . $contract->{last_update}->{blockNumber} . + ' | sender: ' . $contract->{last_update}->{sender} . ' | value: ' . $contract->{last_update}->{value} ); + } + + foreach my $function (@{$results->{Functions}}) { + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $function->{id} !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping '" . $function->{id} . "': no matching filter name.", debug => 1); + next; + } + + $self->{output}->output_add(severity => 'OK', long_msg => '[Function ' . $function->{id} . ']: label: ' . $function->{label} . ' | calls: ' . $function->{calls} . + ' | timestamp: ' . localtime(hex($function->{last_update}->{timestamp})) . ' | blockNumber: ' . $function->{last_update}->{blockNumber} . + ' | sender: ' . $function->{last_update}->{sender} . ' | receiver: ' . $function->{last_update}->{receiver} . + ' | value: ' . $function->{last_update}->{value} ); + } + + foreach my $event (@{$results->{Events}}) { + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $event->{id} !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping '" . $event->{id} . "': no matching filter name.", debug => 1); + next; + } + + $self->{output}->output_add(severity => 'OK', long_msg => '[Event ' . $event->{id} . ']: label: ' . $event->{label} . ' | calls: ' . $event->{calls} . + ' | timestamp: ' . localtime(hex($event->{last_update}->{timestamp})) . ' | blockNumber: ' . $event->{last_update}->{blockNumber} . + ' | sender: ' . $event->{last_update}->{sender} . ' | receiver: ' . $event->{last_update}->{receiver}); + } + +} + +1; + +__END__ + +=head1 MODE + +Check Parity eth-poller for accounts tracking + +=cut diff --git a/blockchain/parity/ethpoller/plugin.pm b/blockchain/parity/ethpoller/plugin.pm new file mode 100644 index 000000000..77989acd3 --- /dev/null +++ b/blockchain/parity/ethpoller/plugin.pm @@ -0,0 +1,50 @@ +# +# Copyright 2020 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 blockchain::parity::ethpoller::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} = '0.1'; + %{$self->{modes}} = ( + 'watchlist' => 'blockchain::parity::ethpoller::mode::watchlist', + 'fork' => 'blockchain::parity::ethpoller::mode::fork', + 'stats' => 'blockchain::parity::ethpoller::mode::stats' + ); + $self->{custom_modes}{api} = 'blockchain::parity::ethpoller::custom::api'; + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Parity blockchain accounts, contracts and forks from eth-poller with HTTP GET + +=cut diff --git a/blockchain/parity/restapi/mode/eth.pm b/blockchain/parity/restapi/mode/eth.pm index de8eb872f..ca604f753 100644 --- a/blockchain/parity/restapi/mode/eth.pm +++ b/blockchain/parity/restapi/mode/eth.pm @@ -40,21 +40,10 @@ sub set_counters { $self->{maps_counters_type} = [ { name => 'global', cb_prefix_output => 'prefix_module_output', type => 0 }, - { name => 'peer', cb_prefix_output => 'prefix_module_output', type => 0 }, { name => 'block', cb_prefix_output => 'prefix_module_output', type => 0 }, - { name => 'sync', cb_prefix_output => 'prefix_module_output', type => 0 } ]; $self->{maps_counters}->{global} = [ - { label => 'coinbase', nlabel => 'parity.eth.client.coinbase', set => { - key_values => [ { name => 'coinbase' } ], - output_template => "Client coinbase is: %s ", - # closure_custom_perfdata => sub { return 0; } - perfdatas => [ - { label => 'client_coinbase', value => 'coinbase_absolute', template => '%s', min => 0 } - ], - } - }, { label => 'gas_price', nlabel => 'parity.eth.gas.price', set => { key_values => [ { name => 'gas_price' } ], output_template => "The gas price is: %d wei ", @@ -65,90 +54,47 @@ sub set_counters { } ]; - $self->{maps_counters}->{peer} = [ - # { label => 'status', nlabel => 'parity.eth.peers.mining.status', set => { - # key_values => [ { name => 'is_mining' } ], - # output_template => "Client is mining: " . $self->can('custom_mining_status_output'), - # perfdatas => [ - # { label => 'is_mining', value => 'is_mining_absolute', template => '%s', min => 0 } - # ], - # } - # }, - { label => 'status', threshold => 0, set => { - key_values => [ { name => 'is_mining' } ], - closure_custom_calc => \&catalog_status_calc, - closure_custom_output => $self->can('custom_status_output'), - closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => \&catalog_status_threshold - } - }, - { label => 'hashrate', nlabel => 'parity.eth.node.hashrate', set => { - key_values => [ { name => 'hashrate' } ], - output_template => "Node hashrate is: %d/s ", - perfdatas => [ - { label => 'node_hashrate', value => 'hashrate_absolute', template => '%d', min => 0 } - ], - } - }, - ]; - $self->{maps_counters}->{block} = [ - { label => 'block_number', nlabel => 'parity.eth.block.number', set => { - key_values => [ { name => 'block_number' } ], - output_template => "Most recent block number is: %d ", - closure_custom_perfdata => sub { return 0; } - # perfdatas => [ - # { label => 'block_number', value => 'block_number_absolute', template => '%d', min => 0 } - # ], - } - }, - { label => 'block_time', nlabel => 'parity.eth.block.time', set => { - key_values => [ { name => 'block_time' } ], - output_template => "Block time is: %s ", - closure_custom_perfdata => sub { return 0; } - # perfdatas => [ - # { label => 'block_time', value => 'block_time_absolute', template => '%s', min => 0 } - # ], - } - }, - ]; - - $self->{maps_counters}->{sync} = [ - { label => 'sync_start', nlabel => 'parity.eth.sync.start.block', set => { - key_values => [ { name => 'sync_start' } ], - output_template => "Sync start block number is: %d ", - closure_custom_perfdata => sub { return 0; } - # perfdatas => [ - # { label => 'sync_start', value => 'sync_start_absolute', template => '%d', min => 0 } - # ], - } - }, - { label => 'sync_current', nlabel => 'parity.eth.sync.current.block', set => { - key_values => [ { name => 'sync_current' } ], - output_template => "Sync current block number is: %d ", - closure_custom_perfdata => sub { return 0; } - # perfdatas => [ - # { label => 'sync_current', value => 'sync_current_absolute', template => '%d', min => 0 } - # ], - } - }, - { label => 'sync_highest', nlabel => 'parity.eth.sync.highest.block', set => { - key_values => [ { name => 'sync_highest' } ], - output_template => "Sync highest block number is: %d ", - # closure_custom_perfdata => sub { return 0; } + { label => 'block_size', nlabel => 'parity.eth.block.size', set => { + key_values => [ { name => 'block_size' } ], + output_template => "Most recent block size: %d ", perfdatas => [ - { label => 'sync_highest', value => 'sync_highest_absolute', template => '%d', min => 0 } + { label => 'block_size', value => 'block_size_absolute', template => '%d', min => 0 } ], } }, - { label => 'sync', nlabel => 'parity.eth.sync.ratio', set => { - key_values => [ { name => 'sync' } ], - output_template => "Sync ratio is: %d%% ", + { label => 'block_transactions', nlabel => 'parity.eth.block.transactions.number', set => { + key_values => [ { name => 'block_transactions' } ], + output_template => "Block transactions number: %d ", perfdatas => [ - { label => 'sync', value => 'sync_absolute', template => '%d', min => 0 } + { label => 'block_transactions', value => 'block_transactions_absolute', template => '%d', min => 0 } ], } - } + }, + { label => 'block_gas', nlabel => 'parity.eth.block.gas', set => { + key_values => [ { name => 'block_gas' } ], + output_template => "Block gas: %d ", + perfdatas => [ + { label => 'block_gas', value => 'block_gas_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'block_difficulty', nlabel => 'parity.eth.block.difficulty', set => { + key_values => [ { name => 'block_difficulty' } ], + output_template => "Block difficulty: %f ", + perfdatas => [ + { label => 'block_difficulty', value => 'block_difficulty_absolute', template => '%f', min => 0 } + ], + } + }, + { label => 'block_uncles', nlabel => 'parity.eth.block.difficulty', set => { + key_values => [ { name => 'block_uncles' } ], + output_template => "Block uncles: %d ", + perfdatas => [ + { label => 'block_uncles', value => 'block_uncles_absolute', template => '%d', min => 0 } + ], + } + }, ]; } @@ -190,32 +136,55 @@ sub manage_selection { { method => 'eth_syncing', params => [], id => "7", jsonrpc => "2.0" } ]; my $result = $options{custom}->request_api(method => 'POST', query_form_post => $query_form_post); + + my $gas_price = hex(@{$result}[2]->{result}); # use Data::Dumper; - # print Dumper($result); + # my $length = scalar(@{$$result[5]->{result}->{transactions}}); + # print Dumper($result) ; # conditional formating: my $res_sync = @{$result}[6]->{result} ? hex((@{$result}[6]->{result}->{currentBlock} / @{$result}[6]->{result}->{highestBlock})) * 100 : 100; - my $res_startingBlock = $res_sync != 100 ? hex(@{$result}[6]->{result}->{startingBlock}) : undef; - my $res_currentBlock = $res_sync != 100 ? hex(@{$result}[6]->{result}->{currentBlock}) : undef; - my $res_highestBlock = $res_sync != 100 ? hex(@{$result}[6]->{result}->{highestBlock}) : undef; + my $res_startingBlock = $res_sync != 100 ? hex(@{$result}[6]->{result}->{startingBlock}) : 'none'; + my $res_currentBlock = $res_sync != 100 ? hex(@{$result}[6]->{result}->{currentBlock}) : 'none'; + my $res_highestBlock = $res_sync != 100 ? hex(@{$result}[6]->{result}->{highestBlock}) : 'none'; - # Unix time conversion - my $res_timestamp = localtime(hex(@{$result}[5]->{result}->{timestamp})); + # Alerts management + my $cache = Cache::File->new( cache_root => './parity-restapi-cache' ); - $self->{global} = { coinbase => @{$result}[1]->{result}, - gas_price => hex(@{$result}[2]->{result}) }; + if (my $cached_sync = $cache->get('node_sync')) { + if ($cached_sync == 100 && $res_sync < 100) { + #alert + } + } else { + $cache->set('node_sync', $res_sync); + } - $self->{block} = { block_number => defined @{$result}[4]->{result} ? hex(@{$result}[4]->{result}) : 0, - block_time => $res_timestamp }; + if (my $cached_price = $cache->get('gas_price')) { + if ($cached_price != $gas_price) { + #alert + } + } else { + $cache->set('gas_price', $gas_price); + } - $self->{sync} = { sync_start => $res_startingBlock, - sync_current => $res_currentBlock, - sync_highest => $res_highestBlock, - sync => $res_sync }; + $self->{global} = { gas_price => $gas_price }; - $self->{peer} = { is_mining => @{$result}[0]->{result}, - hashrate => hex(@{$result}[3]->{result}) }; + $self->{block} = { block_size => hex(@{$result}[5]->{result}->{size}), + block_gas => hex(@{$result}[5]->{result}->{gasUsed}), + block_difficulty => hex(@{$result}[5]->{result}->{totalDifficulty}), + block_uncles => scalar(@{$$result[5]->{result}->{uncles}}), + block_transactions => scalar(@{$$result[5]->{result}->{transactions}})}; + + $self->{output}->output_add(severity => 'OK', long_msg => '[Node status] is_mining: ' . @{$result}[0]->{result} . ' | sync_start: ' . $res_startingBlock . + ' | sync_current: ' . $res_currentBlock . ' | sync_highest: ' . $res_highestBlock . ' | sync: ' . $res_sync . '%%'); + $self->{output}->output_add(severity => 'OK', long_msg => '[Client] coinbase: ' . @{$result}[1]->{result}); + $self->{output}->output_add(severity => 'OK', long_msg => '[Global] hashrate: ' . hex(@{$result}[3]->{result}) . + ' | block_number: ' . (defined @{$result}[4]->{result} ? hex(@{$result}[4]->{result}) : 0)); + $self->{output}->output_add(severity => 'OK', long_msg => '[Last block] block_time: ' . localtime(hex(@{$result}[5]->{result}->{timestamp})) . ' | block_gas_limit: ' . hex(@{$result}[5]->{result}->{gasLimit}) . + ' | block_miner: ' . @{$result}[5]->{result}->{miner} . ' | block_hash: ' . @{$result}[5]->{result}->{hash} . + ' | last_block_number: ' . hex(@{$result}[5]->{result}->{number})); + } 1; diff --git a/blockchain/parity/restapi/mode/net.pm b/blockchain/parity/restapi/mode/net.pm index d5e8f88cf..02ba31028 100644 --- a/blockchain/parity/restapi/mode/net.pm +++ b/blockchain/parity/restapi/mode/net.pm @@ -43,15 +43,7 @@ sub set_counters { ]; $self->{maps_counters}->{network} = [ - { label => 'status', threshold => 0, set => { - key_values => [ { name => 'listening' } ], - closure_custom_calc => \&catalog_status_calc, - closure_custom_output => $self->can('custom_status_output'), - closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => \&catalog_status_threshold - } - }, - { label => 'peers', nlabel => 'parity.network.peers.count', set => { + { label => 'peers', nlabel => 'parity.network.peers.count', set => { key_values => [ { name => 'peers' } ], output_template => "connected peers: %s ", perfdatas => [ @@ -96,9 +88,24 @@ sub manage_selection { my $result = $options{custom}->request_api(method => 'POST', query_form_post => $query_form_post); - $self->{network} = { listening => @{$result}[0]->{result}, - peers => hex(@{$result}[1]->{result}) }; + my $peer_count = hex(@{$result}[1]->{result}); + # Alerts management + my $cache = Cache::File->new( cache_root => './parity-restapi-cache' ); + + if (my $cached_count = $cache->get('peers_count')) { + if ($peer_count < $cached_count) { + #alert + } elsif ($peer_count > $cached_count) { + #alert + } + } else { + $cache->set('peers_count', $peer_count); + } + + $self->{network} = { peers => hex(@{$result}[1]->{result}) }; + + $self->{output}->output_add(long_msg => "[Node] is_listening: " . $peer_count, severity => 'OK'); } 1; diff --git a/blockchain/parity/restapi/mode/parity.pm b/blockchain/parity/restapi/mode/parity.pm index 0050e1ce9..8823d1673 100644 --- a/blockchain/parity/restapi/mode/parity.pm +++ b/blockchain/parity/restapi/mode/parity.pm @@ -24,108 +24,18 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; +use Cache::File; use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ -# { name => 'global', cb_prefix_output => 'prefix_module_output', type => 0 }, - { name => 'node', cb_prefix_output => 'prefix_module_output', type => 0 }, - { name => 'mempool', cb_prefix_output => 'prefix_module_output', type => 0 }, - { name => 'network', cb_prefix_output => 'prefix_module_output', type => 0 } - ]; - - $self->{maps_counters}->{global} = [ - { label => 'parity_version', nlabel => 'parity.version', threshold => 0, set => { - key_values => [ { name => 'parity_version' } ], - output_template => "Parity version is: %s ", - closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => sub { return 0; } - # perfdatas => [ - # { label => 'parity_version', value => 'parity_version_absolute', template => '%s', min => 0 } - # ], - } - }, - { label => 'parity_version_hash', nlabel => 'parity.version.hash', set => { - key_values => [ { name => 'parity_version_hash' } ], - output_template => "Parity version hash is: %s ", - closure_custom_perfdata => sub { return 0; } - # perfdatas => [ - # { label => 'parity_version_hash', value => 'parity_version_hash_absolute', template => '%s', min => 0 } - # ], - } - }, - { label => 'chain_name', nlabel => 'parity.chain.name', set => { - key_values => [ { name => 'chain_name' } ], - output_template => "Chain name is: %s ", - closure_custom_perfdata => sub { return 0; } - # perfdatas => [ - # { label => 'chain_name', value => 'chain_name_absolute', template => '%s', min => 0 } - # ], - } - }, - ]; - - $self->{maps_counters}->{node} = [ - { label => 'enode', nlabel => 'parity.node.enode.uri', threshold => 0, set => { - key_values => [ { name => 'enode' } ], - output_template => "Node enode URI: %s ", - closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => sub { return 0; } - # perfdatas => [ - # { label => 'enode', value => 'enode_absolute', template => '%s', min => 0 } - # ], - } - }, - { label => 'node_name', nlabel => 'parity.node.name', set => { - key_values => [ { name => 'node_name' } ], - output_template => "Node name: %s ", - closure_custom_perfdata => sub { return 0; } - # perfdatas => [ - # { label => 'node_name', value => 'node_name_absolute', template => '%s', min => 0 } - # ], - } - } - ]; - - $self->{maps_counters}->{network} = [ - { label => 'peers_connected', nlabel => 'parity.peers.connected', set => { - key_values => [ { name => 'peers_connected' } ], - output_template => "Number of connected peers: %d ", - perfdatas => [ - { label => 'peers_connected', value => 'peers_connected_absolute', template => '%d', min => 0 } - ], - } - }, - { label => 'peers_max', nlabel => 'parity.peers.max.connected', set => { - key_values => [ { name => 'peers_max' } ], - output_template => "Maximum number of connected peers: %d ", - perfdatas => [ - { label => 'peers_max', value => 'peers_max_absolute', template => '%d', min => 0 } - ], - } - }, - { label => 'peers', nlabel => 'parity.peers', set => { - key_values => [ { name => 'peers' } ], - output_template => "Peers: %d ", - perfdatas => [ - { label => 'peers', value => 'peers_absolute', template => '%d', min => 0 } - ], - } - } - ]; + { name => 'mempool', cb_prefix_output => 'prefix_module_output', type => 0 } + ]; $self->{maps_counters}->{mempool} = [ - { label => 'pending_transactions', nlabel => 'parity.pending.transactions', set => { - key_values => [ { name => 'pending_transactions' } ], - output_template => "Pending transactions: %d ", - perfdatas => [ - { label => 'pending_transactions', value => 'pending_transactions_absolute', template => '%d', min => 0 } - ], - } - }, - { label => 'mempool', nlabel => 'parity.mempol.capacity', set => { + { label => 'mempool', nlabel => 'parity.mempol.usage', set => { key_values => [ { name => 'mempool' } ], output_template => "Mempool: %d %% ", perfdatas => [ @@ -172,35 +82,46 @@ sub manage_selection { { method => 'parity_netPeers', params => [], id => "4", jsonrpc => "2.0" }, { method => 'parity_enode', params => [], id => "5", jsonrpc => "2.0" }, { method => 'parity_nodeName', params => [], id => "6", jsonrpc => "2.0" }, - { method => 'parity_transactionsLimit', params => [], id => "7", jsonrpc => "2.0" } ]; # parity_transactionsLimit could be done once, at the beginning of the process + { method => 'parity_transactionsLimit', params => [], id => "7", jsonrpc => "2.0" } ]; #TO CHECK parity_transactionsLimit could be done once, at the beginning of the process - my $result = $options{custom}->request_api(method => 'POST', query_form_post => $query_form_post); + use Data::Dumper; + # print Dumper($result); + # Parity version construction my $res_parity_version = @{$result}[0]->{result}->{version}->{major} . '.' . @{$result}[0]->{result}->{version}->{minor} . '.' . @{$result}[0]->{result}->{version}->{patch}; + # Alerts management + my $cache = Cache::File->new( cache_root => './parity-restapi-cache' ); + + if (my $cached_version = $cache->get('parity_version')) { + if ($res_parity_version ne $cached_version) { + #alert + } + } else { + $cache->set('parity_version', $res_parity_version); + } + + if (my $cached_name = $cache->get('chain_name')) { + if ($cached_name ne @{$result}[1]->{result}) { + #alert + } + } else { + $cache->set('chain_name', @{$result}[1]->{result}); + } # use Data::Dumper; - # print Dumper($res_parity_version); + # print Dumper($result); - $self->{output}->output_add(long_msg => "[config] chain name: " . @{$result}[1]->{result} . " parity version: " . $res_parity_version . " version_hash: " . @{$result}[0]->{result}->{hash}, - severity => 'OK'); - -# $self->{global} = { parity_version => $res_parity_version, -# parity_version_hash => @{$result}[0]->{result}->{hash}, -# chain_name => @{$result}[1]->{result} }; - -# $self->{node} = { enode => @{$result}[4]->{result}, -# node_name => @{$result}[5]->{result} }; - - $self->{network} = { peers_connected => @{$result}[3]->{result}->{connected}, - peers_max => @{$result}[3]->{result}->{max}, - peers => length(@{$result}[3]->{result}->{peers}) }; - - $self->{mempool} = { pending_transactions => length(@{$result}[2]->{result}), - mempool => @{$result}[2]->{result} / @{$result}[6]->{result} * 100 }; + $self->{output}->output_add(long_msg => "[config] chain name: " . @{$result}[1]->{result} . " | parity version: " . $res_parity_version . " | version_hash: " + . @{$result}[0]->{result}->{hash}, severity => 'OK'); + $self->{output}->output_add(long_msg => "[Network] peers_connected: " . @{$result}[3]->{result}->{connected} . " | peers_max: " . @{$result}[3]->{result}->{max} . " | peers: " + . scalar(@{$$result[3]->{result}->{peers}}), severity => 'OK'); + $self->{output}->output_add(long_msg => "[Node] node_name: " . @{$result}[5]->{result} . " | enode: " . @{$result}[4]->{result} , severity => 'OK'); + $self->{output}->output_add(long_msg => "[Node] pending_transactions: " . scalar(@{$$result[2]->{result}}), severity => 'OK'); + $self->{mempool} = { mempool => scalar(@{$$result[2]->{result}}) / @{$result}[6]->{result} * 100 }; #TO CHECK division entière } 1; From 59f4b619de5fd54fdeec5a4f5374f523dd8f5f8b Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Thu, 9 Apr 2020 08:00:11 +0000 Subject: [PATCH 011/283] add missing package --- blockchain/parity/ethpoller/mode/fork.pm | 1 + blockchain/parity/ethpoller/mode/watchlist.pm | 18 ++++++++++-------- blockchain/parity/restapi/mode/eth.pm | 1 + blockchain/parity/restapi/mode/net.pm | 1 + 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/blockchain/parity/ethpoller/mode/fork.pm b/blockchain/parity/ethpoller/mode/fork.pm index 226fdbc4a..7fc4f5c0c 100644 --- a/blockchain/parity/ethpoller/mode/fork.pm +++ b/blockchain/parity/ethpoller/mode/fork.pm @@ -24,6 +24,7 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; +use Cache::File; use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); sub new { diff --git a/blockchain/parity/ethpoller/mode/watchlist.pm b/blockchain/parity/ethpoller/mode/watchlist.pm index 8a6e734f2..a6a7b28f8 100644 --- a/blockchain/parity/ethpoller/mode/watchlist.pm +++ b/blockchain/parity/ethpoller/mode/watchlist.pm @@ -24,6 +24,7 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; +use Cache::File; use Digest::MD5 qw(md5_hex); sub new { @@ -49,14 +50,6 @@ sub manage_selection { # Alerts management my $cache = Cache::File->new( cache_root => './parity-eth-poller-cache' ); - if (my $cached_balance = $cache->get('contract_balance')) { - if ($cached_balance != $contract->{balance}) { - #alert - } - } else { - $cache->set('contract_balance', $contract->{balance}); - } - foreach my $account (@{$results->{Accounts}}) { if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && $account->{id} !~ /$self->{option_results}->{filter_name}/) { @@ -90,6 +83,15 @@ sub manage_selection { $self->{output}->output_add(severity => 'OK', long_msg => '[Contract ' . $contract->{id} . ']: label: ' . $contract->{label} . ' | balance: ' . $contract->{balance} . ' | timestamp: ' . localtime(hex($contract->{last_update}->{timestamp})) . ' | blockNumber: ' . $contract->{last_update}->{blockNumber} . ' | sender: ' . $contract->{last_update}->{sender} . ' | value: ' . $contract->{last_update}->{value} ); + + if (my $cached_balance = $cache->get('contract_balance_' . $contract->{id})) { + if ($cached_balance != $contract->{balance}) { + #alert + } + } else { + $cache->set('contract_balance_' . $contract->{id}, $contract->{balance}); + } + } foreach my $function (@{$results->{Functions}}) { diff --git a/blockchain/parity/restapi/mode/eth.pm b/blockchain/parity/restapi/mode/eth.pm index ca604f753..00c479110 100644 --- a/blockchain/parity/restapi/mode/eth.pm +++ b/blockchain/parity/restapi/mode/eth.pm @@ -24,6 +24,7 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; +use Cache::File; use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); sub custom_status_output { diff --git a/blockchain/parity/restapi/mode/net.pm b/blockchain/parity/restapi/mode/net.pm index 02ba31028..17ceaed4b 100644 --- a/blockchain/parity/restapi/mode/net.pm +++ b/blockchain/parity/restapi/mode/net.pm @@ -24,6 +24,7 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; +use Cache::File; use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); sub custom_status_output { From db9a76d67509ebd655775d3b577c8bdce4e91281 Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Thu, 9 Apr 2020 08:28:21 +0000 Subject: [PATCH 012/283] remove Cache::File package --- blockchain/parity/ethpoller/mode/fork.pm | 23 +++++++----- blockchain/parity/ethpoller/mode/watchlist.pm | 22 ++++++----- blockchain/parity/restapi/mode/eth.pm | 37 ++++++++++--------- blockchain/parity/restapi/mode/net.pm | 27 ++++++++------ blockchain/parity/restapi/mode/parity.pm | 37 ++++++++++--------- 5 files changed, 80 insertions(+), 66 deletions(-) diff --git a/blockchain/parity/ethpoller/mode/fork.pm b/blockchain/parity/ethpoller/mode/fork.pm index 7fc4f5c0c..597dbd4a0 100644 --- a/blockchain/parity/ethpoller/mode/fork.pm +++ b/blockchain/parity/ethpoller/mode/fork.pm @@ -24,12 +24,12 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; -use Cache::File; +use Digest::MD5 qw(md5_hex); use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1, statefile => 1); bless $self, $class; $options{options}->add_options(arguments => { @@ -43,6 +43,9 @@ sub new { sub manage_selection { my ($self, %options) = @_; + $self->{cache_name} = "parity_ethpoller_" . $self->{mode} . '_' . (defined($self->{option_results}->{hostname}) ? $self->{option_results}->{hostname} : 'me') . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); + my $result = $options{custom}->request_api(url_path => '/fork'); # use Data::Dumper; @@ -52,15 +55,15 @@ sub manage_selection { my $res_timestamp = localtime(hex($result->{last_update}->{timestamp})); # Alerts management - my $cache = Cache::File->new( cache_root => './parity-eth-poller-cache' ); + # my $cache = Cache::File->new( cache_root => './parity-eth-poller-cache' ); - if (my $cached_timestamp = $cache->get('fork_timestamp')) { - if ($cached_timestamp ne $res_timestamp) { - #alert - } - } else { - $cache->set('fork_timestamp', $res_timestamp); - } + # if (my $cached_timestamp = $cache->get('fork_timestamp')) { + # if ($cached_timestamp ne $res_timestamp) { + # #alert + # } + # } else { + # $cache->set('fork_timestamp', $res_timestamp); + # } $self->{output}->output_add(severity => 'OK', long_msg => '[Fork]: fork_timestamp: ' . $res_timestamp . ' | fork_occurence: ' . $result->{occurence} . ' | fork_blockNumber: ' . $result->{last_update}->{blockNumber} . diff --git a/blockchain/parity/ethpoller/mode/watchlist.pm b/blockchain/parity/ethpoller/mode/watchlist.pm index a6a7b28f8..69e2baef2 100644 --- a/blockchain/parity/ethpoller/mode/watchlist.pm +++ b/blockchain/parity/ethpoller/mode/watchlist.pm @@ -24,12 +24,11 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; -use Cache::File; use Digest::MD5 qw(md5_hex); sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1, statefile => 1); bless $self, $class; $options{options}->add_options(arguments => { @@ -42,13 +41,16 @@ sub new { sub manage_selection { my ($self, %options) = @_; + $self->{cache_name} = "parity_ethpoller_" . $self->{mode} . '_' . (defined($self->{option_results}->{hostname}) ? $self->{option_results}->{hostname} : 'me') . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); + my $results = $options{custom}->request_api(url_path => '/watchlist'); # use Data::Dumper; # print Dumper($results); # Alerts management - my $cache = Cache::File->new( cache_root => './parity-eth-poller-cache' ); + # my $cache = Cache::File->new( cache_root => './parity-eth-poller-cache' ); foreach my $account (@{$results->{Accounts}}) { if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && @@ -84,13 +86,13 @@ sub manage_selection { ' | timestamp: ' . localtime(hex($contract->{last_update}->{timestamp})) . ' | blockNumber: ' . $contract->{last_update}->{blockNumber} . ' | sender: ' . $contract->{last_update}->{sender} . ' | value: ' . $contract->{last_update}->{value} ); - if (my $cached_balance = $cache->get('contract_balance_' . $contract->{id})) { - if ($cached_balance != $contract->{balance}) { - #alert - } - } else { - $cache->set('contract_balance_' . $contract->{id}, $contract->{balance}); - } + # if (my $cached_balance = $cache->get('contract_balance_' . $contract->{id})) { + # if ($cached_balance != $contract->{balance}) { + # #alert + # } + # } else { + # $cache->set('contract_balance_' . $contract->{id}, $contract->{balance}); + # } } diff --git a/blockchain/parity/restapi/mode/eth.pm b/blockchain/parity/restapi/mode/eth.pm index 00c479110..fd819842a 100644 --- a/blockchain/parity/restapi/mode/eth.pm +++ b/blockchain/parity/restapi/mode/eth.pm @@ -24,7 +24,7 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; -use Cache::File; +use Digest::MD5 qw(md5_hex); use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); sub custom_status_output { @@ -101,7 +101,7 @@ sub set_counters { sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1, statefile => 1); bless $self, $class; $options{options}->add_options(arguments => { @@ -128,6 +128,9 @@ sub prefix_module_output { sub manage_selection { my ($self, %options) = @_; + $self->{cache_name} = "parity_restapi_" . $self->{mode} . '_' . (defined($self->{option_results}->{hostname}) ? $self->{option_results}->{hostname} : 'me') . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); + my $query_form_post = [ { method => 'eth_mining', params => [], id => "1", jsonrpc => "2.0" }, { method => 'eth_coinbase', params => [], id => "2", jsonrpc => "2.0" }, { method => 'eth_gasPrice', params => [], id => "3", jsonrpc => "2.0" } , @@ -151,23 +154,23 @@ sub manage_selection { my $res_highestBlock = $res_sync != 100 ? hex(@{$result}[6]->{result}->{highestBlock}) : 'none'; # Alerts management - my $cache = Cache::File->new( cache_root => './parity-restapi-cache' ); + # my $cache = Cache::File->new( cache_root => './parity-restapi-cache' ); - if (my $cached_sync = $cache->get('node_sync')) { - if ($cached_sync == 100 && $res_sync < 100) { - #alert - } - } else { - $cache->set('node_sync', $res_sync); - } + # if (my $cached_sync = $cache->get('node_sync')) { + # if ($cached_sync == 100 && $res_sync < 100) { + # #alert + # } + # } else { + # $cache->set('node_sync', $res_sync); + # } - if (my $cached_price = $cache->get('gas_price')) { - if ($cached_price != $gas_price) { - #alert - } - } else { - $cache->set('gas_price', $gas_price); - } + # if (my $cached_price = $cache->get('gas_price')) { + # if ($cached_price != $gas_price) { + # #alert + # } + # } else { + # $cache->set('gas_price', $gas_price); + # } $self->{global} = { gas_price => $gas_price }; diff --git a/blockchain/parity/restapi/mode/net.pm b/blockchain/parity/restapi/mode/net.pm index 17ceaed4b..b3d9fdd5a 100644 --- a/blockchain/parity/restapi/mode/net.pm +++ b/blockchain/parity/restapi/mode/net.pm @@ -24,7 +24,7 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; -use Cache::File; +use Digest::MD5 qw(md5_hex); use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); sub custom_status_output { @@ -57,7 +57,7 @@ sub set_counters { sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1, statefile => 1); bless $self, $class; $options{options}->add_options(arguments => { @@ -84,6 +84,9 @@ sub prefix_module_output { sub manage_selection { my ($self, %options) = @_; + $self->{cache_name} = "parity_restapi_" . $self->{mode} . '_' . (defined($self->{option_results}->{hostname}) ? $self->{option_results}->{hostname} : 'me') . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); + my $query_form_post = [ { method => 'net_listening', params => [], id => "1", jsonrpc => "2.0" }, { method => 'net_peerCount', params => [], id => "2", jsonrpc => "2.0" } ]; @@ -92,17 +95,17 @@ sub manage_selection { my $peer_count = hex(@{$result}[1]->{result}); # Alerts management - my $cache = Cache::File->new( cache_root => './parity-restapi-cache' ); + # my $cache = Cache::File->new( cache_root => './parity-restapi-cache' ); - if (my $cached_count = $cache->get('peers_count')) { - if ($peer_count < $cached_count) { - #alert - } elsif ($peer_count > $cached_count) { - #alert - } - } else { - $cache->set('peers_count', $peer_count); - } + # if (my $cached_count = $cache->get('peers_count')) { + # if ($peer_count < $cached_count) { + # #alert + # } elsif ($peer_count > $cached_count) { + # #alert + # } + # } else { + # $cache->set('peers_count', $peer_count); + # } $self->{network} = { peers => hex(@{$result}[1]->{result}) }; diff --git a/blockchain/parity/restapi/mode/parity.pm b/blockchain/parity/restapi/mode/parity.pm index 8823d1673..f58e3234e 100644 --- a/blockchain/parity/restapi/mode/parity.pm +++ b/blockchain/parity/restapi/mode/parity.pm @@ -24,7 +24,7 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; -use Cache::File; +use Digest::MD5 qw(md5_hex); use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); sub set_counters { @@ -49,7 +49,7 @@ sub set_counters { sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1, statefile => 1); bless $self, $class; $options{options}->add_options(arguments => { @@ -76,6 +76,9 @@ sub prefix_module_output { sub manage_selection { my ($self, %options) = @_; + $self->{cache_name} = "parity_restapi_" . $self->{mode} . '_' . (defined($self->{option_results}->{hostname}) ? $self->{option_results}->{hostname} : 'me') . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); + my $query_form_post = [ { method => 'parity_versionInfo', params => [], id => "1", jsonrpc => "2.0" }, { method => 'parity_chain', params => [], id => "2", jsonrpc => "2.0" }, { method => 'parity_pendingTransactions', params => [], id => "3", jsonrpc => "2.0" } , @@ -93,23 +96,23 @@ sub manage_selection { my $res_parity_version = @{$result}[0]->{result}->{version}->{major} . '.' . @{$result}[0]->{result}->{version}->{minor} . '.' . @{$result}[0]->{result}->{version}->{patch}; # Alerts management - my $cache = Cache::File->new( cache_root => './parity-restapi-cache' ); + # my $cache = Cache::File->new( cache_root => './parity-restapi-cache' ); - if (my $cached_version = $cache->get('parity_version')) { - if ($res_parity_version ne $cached_version) { - #alert - } - } else { - $cache->set('parity_version', $res_parity_version); - } + # if (my $cached_version = $cache->get('parity_version')) { + # if ($res_parity_version ne $cached_version) { + # #alert + # } + # } else { + # $cache->set('parity_version', $res_parity_version); + # } - if (my $cached_name = $cache->get('chain_name')) { - if ($cached_name ne @{$result}[1]->{result}) { - #alert - } - } else { - $cache->set('chain_name', @{$result}[1]->{result}); - } + # if (my $cached_name = $cache->get('chain_name')) { + # if ($cached_name ne @{$result}[1]->{result}) { + # #alert + # } + # } else { + # $cache->set('chain_name', @{$result}[1]->{result}); + # } # use Data::Dumper; # print Dumper($result); From 975d8d85397757ed552a0eff74caa7604c8241f5 Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Thu, 9 Apr 2020 09:50:29 +0000 Subject: [PATCH 013/283] change long_msg output format --- blockchain/parity/ethpoller/mode/fork.pm | 6 ++-- blockchain/parity/ethpoller/mode/watchlist.pm | 30 +++++++++---------- blockchain/parity/restapi/mode/eth.pm | 16 +++++----- blockchain/parity/restapi/mode/net.pm | 2 +- blockchain/parity/restapi/mode/parity.pm | 12 ++++---- 5 files changed, 33 insertions(+), 33 deletions(-) diff --git a/blockchain/parity/ethpoller/mode/fork.pm b/blockchain/parity/ethpoller/mode/fork.pm index 597dbd4a0..84b1d194f 100644 --- a/blockchain/parity/ethpoller/mode/fork.pm +++ b/blockchain/parity/ethpoller/mode/fork.pm @@ -65,9 +65,9 @@ sub manage_selection { # $cache->set('fork_timestamp', $res_timestamp); # } - $self->{output}->output_add(severity => 'OK', long_msg => '[Fork]: fork_timestamp: ' . $res_timestamp . - ' | fork_occurence: ' . $result->{occurence} . ' | fork_blockNumber: ' . $result->{last_update}->{blockNumber} . - ' | fork_in: ' . $result->{last_update}->{in} . ' | fork_out: ' . $result->{last_update}->{out} ); + $self->{output}->output_add(severity => 'OK', long_msg => 'Fork: [fork_timestamp: ' . $res_timestamp . + '] [fork_occurence: ' . $result->{occurence} . '] [fork_blockNumber: ' . $result->{last_update}->{blockNumber} . + '] [fork_in: ' . $result->{last_update}->{in} . '] [fork_out: ' . $result->{last_update}->{out} . ']'); } diff --git a/blockchain/parity/ethpoller/mode/watchlist.pm b/blockchain/parity/ethpoller/mode/watchlist.pm index 69e2baef2..9ffb7fd85 100644 --- a/blockchain/parity/ethpoller/mode/watchlist.pm +++ b/blockchain/parity/ethpoller/mode/watchlist.pm @@ -59,9 +59,9 @@ sub manage_selection { next; } - $self->{output}->output_add(severity => 'OK', long_msg => '[Account ' . $account->{id} . ']: label: ' . $account->{label} . ' | nonce: ' . $account->{nonce} . - ' | timestamp: ' . localtime(hex($account->{last_update}->{timestamp})) . ' | blockNumber: ' . $account->{last_update}->{blockNumber} . - ' | receiver: ' . $account->{last_update}->{receiver} . ' | value: ' . $account->{last_update}->{value} ); + $self->{output}->output_add(severity => 'OK', long_msg => 'Account ' . $account->{id} . ': [label: ' . $account->{label} . '] [nonce: ' . $account->{nonce} . + '] [timestamp: ' . localtime(hex($account->{last_update}->{timestamp})) . '] [blockNumber: ' . $account->{last_update}->{blockNumber} . + '] [receiver: ' . $account->{last_update}->{receiver} . '] [value: ' . $account->{last_update}->{value} . ']' ); } foreach my $minner (@{$results->{Miners}}) { @@ -71,8 +71,8 @@ sub manage_selection { next; } - $self->{output}->output_add(severity => 'OK', long_msg => '[Minner ' . $minner->{id} . ']: label: ' . $minner->{label} . ' | blocks: ' . $minner->{blocks} . - ' | timestamp: ' . localtime(hex($minner->{last_update}->{timestamp})) . ' | blockNumber: ' . $minner->{last_update}->{blockNumber} ); + $self->{output}->output_add(severity => 'OK', long_msg => 'Minner ' . $minner->{id} . ': [label: ' . $minner->{label} . '] [blocks: ' . $minner->{blocks} . + '] [timestamp: ' . localtime(hex($minner->{last_update}->{timestamp})) . '] [blockNumber: ' . $minner->{last_update}->{blockNumber} . ']'); } foreach my $contract (@{$results->{Constracts}}) { @@ -82,9 +82,9 @@ sub manage_selection { next; } - $self->{output}->output_add(severity => 'OK', long_msg => '[Contract ' . $contract->{id} . ']: label: ' . $contract->{label} . ' | balance: ' . $contract->{balance} . - ' | timestamp: ' . localtime(hex($contract->{last_update}->{timestamp})) . ' | blockNumber: ' . $contract->{last_update}->{blockNumber} . - ' | sender: ' . $contract->{last_update}->{sender} . ' | value: ' . $contract->{last_update}->{value} ); + $self->{output}->output_add(severity => 'OK', long_msg => 'Contract ' . $contract->{id} . ': [label: ' . $contract->{label} . '] [balance: ' . $contract->{balance} . + '] [timestamp: ' . localtime(hex($contract->{last_update}->{timestamp})) . '] [blockNumber: ' . $contract->{last_update}->{blockNumber} . + '] [sender: ' . $contract->{last_update}->{sender} . '] [value: ' . $contract->{last_update}->{value} . ']'); # if (my $cached_balance = $cache->get('contract_balance_' . $contract->{id})) { # if ($cached_balance != $contract->{balance}) { @@ -103,10 +103,10 @@ sub manage_selection { next; } - $self->{output}->output_add(severity => 'OK', long_msg => '[Function ' . $function->{id} . ']: label: ' . $function->{label} . ' | calls: ' . $function->{calls} . - ' | timestamp: ' . localtime(hex($function->{last_update}->{timestamp})) . ' | blockNumber: ' . $function->{last_update}->{blockNumber} . - ' | sender: ' . $function->{last_update}->{sender} . ' | receiver: ' . $function->{last_update}->{receiver} . - ' | value: ' . $function->{last_update}->{value} ); + $self->{output}->output_add(severity => 'OK', long_msg => '[Function ' . $function->{id} . ']: label: ' . $function->{label} . '] [calls: ' . $function->{calls} . + '] [timestamp: ' . localtime(hex($function->{last_update}->{timestamp})) . '] [blockNumber: ' . $function->{last_update}->{blockNumber} . + '] [sender: ' . $function->{last_update}->{sender} . '] [receiver: ' . $function->{last_update}->{receiver} . + '] [value: ' . $function->{last_update}->{value} . ']'); } foreach my $event (@{$results->{Events}}) { @@ -116,9 +116,9 @@ sub manage_selection { next; } - $self->{output}->output_add(severity => 'OK', long_msg => '[Event ' . $event->{id} . ']: label: ' . $event->{label} . ' | calls: ' . $event->{calls} . - ' | timestamp: ' . localtime(hex($event->{last_update}->{timestamp})) . ' | blockNumber: ' . $event->{last_update}->{blockNumber} . - ' | sender: ' . $event->{last_update}->{sender} . ' | receiver: ' . $event->{last_update}->{receiver}); + $self->{output}->output_add(severity => 'OK', long_msg => '[Event ' . $event->{id} . ']: label: ' . $event->{label} . '] [calls: ' . $event->{calls} . + '] [timestamp: ' . localtime(hex($event->{last_update}->{timestamp})) . '] [blockNumber: ' . $event->{last_update}->{blockNumber} . + '] [sender: ' . $event->{last_update}->{sender} . '] [receiver: ' . $event->{last_update}->{receiver} . ']'); } } diff --git a/blockchain/parity/restapi/mode/eth.pm b/blockchain/parity/restapi/mode/eth.pm index fd819842a..63f7f435b 100644 --- a/blockchain/parity/restapi/mode/eth.pm +++ b/blockchain/parity/restapi/mode/eth.pm @@ -180,14 +180,14 @@ sub manage_selection { block_uncles => scalar(@{$$result[5]->{result}->{uncles}}), block_transactions => scalar(@{$$result[5]->{result}->{transactions}})}; - $self->{output}->output_add(severity => 'OK', long_msg => '[Node status] is_mining: ' . @{$result}[0]->{result} . ' | sync_start: ' . $res_startingBlock . - ' | sync_current: ' . $res_currentBlock . ' | sync_highest: ' . $res_highestBlock . ' | sync: ' . $res_sync . '%%'); - $self->{output}->output_add(severity => 'OK', long_msg => '[Client] coinbase: ' . @{$result}[1]->{result}); - $self->{output}->output_add(severity => 'OK', long_msg => '[Global] hashrate: ' . hex(@{$result}[3]->{result}) . - ' | block_number: ' . (defined @{$result}[4]->{result} ? hex(@{$result}[4]->{result}) : 0)); - $self->{output}->output_add(severity => 'OK', long_msg => '[Last block] block_time: ' . localtime(hex(@{$result}[5]->{result}->{timestamp})) . ' | block_gas_limit: ' . hex(@{$result}[5]->{result}->{gasLimit}) . - ' | block_miner: ' . @{$result}[5]->{result}->{miner} . ' | block_hash: ' . @{$result}[5]->{result}->{hash} . - ' | last_block_number: ' . hex(@{$result}[5]->{result}->{number})); + $self->{output}->output_add(severity => 'OK', long_msg => 'Node status: [is_mining: ' . @{$result}[0]->{result} . '] [sync_start: ' . $res_startingBlock . + '] [sync_current: ' . $res_currentBlock . '] [sync_highest: ' . $res_highestBlock . '] [sync: ' . $res_sync . '%%]'); + $self->{output}->output_add(severity => 'OK', long_msg => 'Client: [coinbase: ' . @{$result}[1]->{result} . ']'); + $self->{output}->output_add(severity => 'OK', long_msg => 'Global: [hashrate: ' . hex(@{$result}[3]->{result}) . + '] [block_number: ' . (defined @{$result}[4]->{result} ? hex(@{$result}[4]->{result}) : 0) . ']'); + $self->{output}->output_add(severity => 'OK', long_msg => 'Last block: [block_time: ' . localtime(hex(@{$result}[5]->{result}->{timestamp})) . '] [block_gas_limit: ' . hex(@{$result}[5]->{result}->{gasLimit}) . + '] [block_miner: ' . @{$result}[5]->{result}->{miner} . '] [block_hash: ' . @{$result}[5]->{result}->{hash} . + '] [last_block_number: ' . hex(@{$result}[5]->{result}->{number}) . ']'); } diff --git a/blockchain/parity/restapi/mode/net.pm b/blockchain/parity/restapi/mode/net.pm index b3d9fdd5a..2ad2ca153 100644 --- a/blockchain/parity/restapi/mode/net.pm +++ b/blockchain/parity/restapi/mode/net.pm @@ -109,7 +109,7 @@ sub manage_selection { $self->{network} = { peers => hex(@{$result}[1]->{result}) }; - $self->{output}->output_add(long_msg => "[Node] is_listening: " . $peer_count, severity => 'OK'); + $self->{output}->output_add(long_msg => "Node status: [is_listening: " . $peer_count . ']', severity => 'OK'); } 1; diff --git a/blockchain/parity/restapi/mode/parity.pm b/blockchain/parity/restapi/mode/parity.pm index f58e3234e..d3aad2c31 100644 --- a/blockchain/parity/restapi/mode/parity.pm +++ b/blockchain/parity/restapi/mode/parity.pm @@ -117,12 +117,12 @@ sub manage_selection { # use Data::Dumper; # print Dumper($result); - $self->{output}->output_add(long_msg => "[config] chain name: " . @{$result}[1]->{result} . " | parity version: " . $res_parity_version . " | version_hash: " - . @{$result}[0]->{result}->{hash}, severity => 'OK'); - $self->{output}->output_add(long_msg => "[Network] peers_connected: " . @{$result}[3]->{result}->{connected} . " | peers_max: " . @{$result}[3]->{result}->{max} . " | peers: " - . scalar(@{$$result[3]->{result}->{peers}}), severity => 'OK'); - $self->{output}->output_add(long_msg => "[Node] node_name: " . @{$result}[5]->{result} . " | enode: " . @{$result}[4]->{result} , severity => 'OK'); - $self->{output}->output_add(long_msg => "[Node] pending_transactions: " . scalar(@{$$result[2]->{result}}), severity => 'OK'); + $self->{output}->output_add(long_msg => "Config: [chain name: " . @{$result}[1]->{result} . "] [parity version: " . $res_parity_version . "] [version_hash: " + . @{$result}[0]->{result}->{hash} . "]", severity => 'OK'); + $self->{output}->output_add(long_msg => "Network: [peers_connected: " . @{$result}[3]->{result}->{connected} . "] [peers_max: " . @{$result}[3]->{result}->{max} . "] [peers: " + . scalar(@{$$result[3]->{result}->{peers}}) . "]", severity => 'OK'); + $self->{output}->output_add(long_msg => "Node: [node_name: " . @{$result}[5]->{result} . "] [enode: " . @{$result}[4]->{result} . "]", severity => 'OK'); + $self->{output}->output_add(long_msg => "Mempool: [pending_transactions: " . scalar(@{$$result[2]->{result}}) . "]", severity => 'OK'); $self->{mempool} = { mempool => scalar(@{$$result[2]->{result}}) / @{$result}[6]->{result} * 100 }; #TO CHECK division entière } From 9cbfcd8b8b156be3e3dc51c28d706e26a3cd8e3f Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Thu, 9 Apr 2020 10:14:28 +0000 Subject: [PATCH 014/283] add package bigint --- blockchain/parity/ethpoller/mode/watchlist.pm | 1 + blockchain/parity/restapi/mode/eth.pm | 1 + 2 files changed, 2 insertions(+) diff --git a/blockchain/parity/ethpoller/mode/watchlist.pm b/blockchain/parity/ethpoller/mode/watchlist.pm index 9ffb7fd85..78b577fee 100644 --- a/blockchain/parity/ethpoller/mode/watchlist.pm +++ b/blockchain/parity/ethpoller/mode/watchlist.pm @@ -24,6 +24,7 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; +use bigint; use Digest::MD5 qw(md5_hex); sub new { diff --git a/blockchain/parity/restapi/mode/eth.pm b/blockchain/parity/restapi/mode/eth.pm index 63f7f435b..6d7fbe78c 100644 --- a/blockchain/parity/restapi/mode/eth.pm +++ b/blockchain/parity/restapi/mode/eth.pm @@ -25,6 +25,7 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; use Digest::MD5 qw(md5_hex); +use bigint; use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); sub custom_status_output { From fee54e7472b824f108be9abc589d493dd3d49ae3 Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Mon, 13 Apr 2020 12:32:07 +0000 Subject: [PATCH 015/283] timestamp formating --- blockchain/parity/ethpoller/mode/fork.pm | 3 +- blockchain/parity/ethpoller/mode/stats.pm | 2 +- blockchain/parity/ethpoller/mode/watchlist.pm | 22 ++++++++++--- blockchain/parity/restapi/mode/eth.pm | 33 ++++++++++--------- blockchain/parity/restapi/mode/parity.pm | 2 +- 5 files changed, 38 insertions(+), 24 deletions(-) diff --git a/blockchain/parity/ethpoller/mode/fork.pm b/blockchain/parity/ethpoller/mode/fork.pm index 84b1d194f..5d53b223f 100644 --- a/blockchain/parity/ethpoller/mode/fork.pm +++ b/blockchain/parity/ethpoller/mode/fork.pm @@ -52,7 +52,8 @@ sub manage_selection { # print Dumper($result); # Unix time conversion - my $res_timestamp = localtime(hex($result->{last_update}->{timestamp})); + my $res_timestamp = $result->{last_update}->{timestamp} == 0 ? '': localtime($result->{last_update}->{timestamp}); + # Alerts management # my $cache = Cache::File->new( cache_root => './parity-eth-poller-cache' ); diff --git a/blockchain/parity/ethpoller/mode/stats.pm b/blockchain/parity/ethpoller/mode/stats.pm index 4844e9d6f..e6cbe1451 100644 --- a/blockchain/parity/ethpoller/mode/stats.pm +++ b/blockchain/parity/ethpoller/mode/stats.pm @@ -34,7 +34,7 @@ sub set_counters { ]; $self->{maps_counters}->{global} = [ - { label => 'stats_blockInterval', nlabel => 'parity.network.peers.count', set => { + { label => 'stats_blockInterval', nlabel => 'parity.stats.block.interval', set => { key_values => [ { name => 'stats_blockInterval' } ], output_template => "Block interval: %d ", perfdatas => [ diff --git a/blockchain/parity/ethpoller/mode/watchlist.pm b/blockchain/parity/ethpoller/mode/watchlist.pm index 78b577fee..2c4ed8304 100644 --- a/blockchain/parity/ethpoller/mode/watchlist.pm +++ b/blockchain/parity/ethpoller/mode/watchlist.pm @@ -53,6 +53,8 @@ sub manage_selection { # Alerts management # my $cache = Cache::File->new( cache_root => './parity-eth-poller-cache' ); + my $res_timestamp = 0; + foreach my $account (@{$results->{Accounts}}) { if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && $account->{id} !~ /$self->{option_results}->{filter_name}/) { @@ -60,8 +62,10 @@ sub manage_selection { next; } + $res_timestamp = $account->{last_update}->{timestamp} == 0 ? '': localtime($account->{last_update}->{timestamp}); + $self->{output}->output_add(severity => 'OK', long_msg => 'Account ' . $account->{id} . ': [label: ' . $account->{label} . '] [nonce: ' . $account->{nonce} . - '] [timestamp: ' . localtime(hex($account->{last_update}->{timestamp})) . '] [blockNumber: ' . $account->{last_update}->{blockNumber} . + '] [timestamp: ' . $res_timestamp . '] [blockNumber: ' . $account->{last_update}->{blockNumber} . '] [receiver: ' . $account->{last_update}->{receiver} . '] [value: ' . $account->{last_update}->{value} . ']' ); } @@ -72,8 +76,10 @@ sub manage_selection { next; } + $res_timestamp = $minner->{last_update}->{timestamp} == 0 ? '': localtime($minner->{last_update}->{timestamp}); + $self->{output}->output_add(severity => 'OK', long_msg => 'Minner ' . $minner->{id} . ': [label: ' . $minner->{label} . '] [blocks: ' . $minner->{blocks} . - '] [timestamp: ' . localtime(hex($minner->{last_update}->{timestamp})) . '] [blockNumber: ' . $minner->{last_update}->{blockNumber} . ']'); + '] [timestamp: ' . $res_timestamp . '] [blockNumber: ' . $minner->{last_update}->{blockNumber} . ']'); } foreach my $contract (@{$results->{Constracts}}) { @@ -83,8 +89,10 @@ sub manage_selection { next; } + $res_timestamp = $contract->{last_update}->{timestamp} == 0 ? '': localtime($contract->{last_update}->{timestamp}); + $self->{output}->output_add(severity => 'OK', long_msg => 'Contract ' . $contract->{id} . ': [label: ' . $contract->{label} . '] [balance: ' . $contract->{balance} . - '] [timestamp: ' . localtime(hex($contract->{last_update}->{timestamp})) . '] [blockNumber: ' . $contract->{last_update}->{blockNumber} . + '] [timestamp: ' . $res_timestamp . '] [blockNumber: ' . $contract->{last_update}->{blockNumber} . '] [sender: ' . $contract->{last_update}->{sender} . '] [value: ' . $contract->{last_update}->{value} . ']'); # if (my $cached_balance = $cache->get('contract_balance_' . $contract->{id})) { @@ -104,8 +112,10 @@ sub manage_selection { next; } + $res_timestamp = $function->{last_update}->{timestamp} == 0 ? '': localtime($function->{last_update}->{timestamp}); + $self->{output}->output_add(severity => 'OK', long_msg => '[Function ' . $function->{id} . ']: label: ' . $function->{label} . '] [calls: ' . $function->{calls} . - '] [timestamp: ' . localtime(hex($function->{last_update}->{timestamp})) . '] [blockNumber: ' . $function->{last_update}->{blockNumber} . + '] [timestamp: ' . $res_timestamp . '] [blockNumber: ' . $function->{last_update}->{blockNumber} . '] [sender: ' . $function->{last_update}->{sender} . '] [receiver: ' . $function->{last_update}->{receiver} . '] [value: ' . $function->{last_update}->{value} . ']'); } @@ -117,8 +127,10 @@ sub manage_selection { next; } + $res_timestamp = $event->{last_update}->{timestamp} == 0 ? '': localtime($event->{last_update}->{timestamp}); + $self->{output}->output_add(severity => 'OK', long_msg => '[Event ' . $event->{id} . ']: label: ' . $event->{label} . '] [calls: ' . $event->{calls} . - '] [timestamp: ' . localtime(hex($event->{last_update}->{timestamp})) . '] [blockNumber: ' . $event->{last_update}->{blockNumber} . + '] [timestamp: ' . $res_timestamp . '] [blockNumber: ' . $event->{last_update}->{blockNumber} . '] [sender: ' . $event->{last_update}->{sender} . '] [receiver: ' . $event->{last_update}->{receiver} . ']'); } diff --git a/blockchain/parity/restapi/mode/eth.pm b/blockchain/parity/restapi/mode/eth.pm index 6d7fbe78c..90f5a0ae8 100644 --- a/blockchain/parity/restapi/mode/eth.pm +++ b/blockchain/parity/restapi/mode/eth.pm @@ -81,15 +81,15 @@ sub set_counters { ], } }, - { label => 'block_difficulty', nlabel => 'parity.eth.block.difficulty', set => { - key_values => [ { name => 'block_difficulty' } ], - output_template => "Block difficulty: %f ", - perfdatas => [ - { label => 'block_difficulty', value => 'block_difficulty_absolute', template => '%f', min => 0 } - ], - } - }, - { label => 'block_uncles', nlabel => 'parity.eth.block.difficulty', set => { + # { label => 'block_difficulty', nlabel => 'parity.eth.block.difficulty', set => { + # key_values => [ { name => 'block_difficulty' } ], + # output_template => "Block difficulty: %f ", + # perfdatas => [ + # { label => 'block_difficulty', value => 'block_difficulty_absolute', template => '%f', min => 0 } + # ], + # } + # }, + { label => 'block_uncles', nlabel => 'parity.eth.block.uncles', set => { key_values => [ { name => 'block_uncles' } ], output_template => "Block uncles: %d ", perfdatas => [ @@ -143,10 +143,11 @@ sub manage_selection { my $result = $options{custom}->request_api(method => 'POST', query_form_post => $query_form_post); my $gas_price = hex(@{$result}[2]->{result}); - - # use Data::Dumper; - # my $length = scalar(@{$$result[5]->{result}->{transactions}}); - # print Dumper($result) ; + my $res_block_time = @{$result}[5]->{result}->{timestamp} == 0 ? '': localtime(hex(@{$result}[5]->{result}->{timestamp})); + + use Data::Dumper; + print Dumper($res_block_time) ; + print Dumper(@{$result}[5]->{result}->{timestamp}); # conditional formating: my $res_sync = @{$result}[6]->{result} ? hex((@{$result}[6]->{result}->{currentBlock} / @{$result}[6]->{result}->{highestBlock})) * 100 : 100; @@ -177,16 +178,16 @@ sub manage_selection { $self->{block} = { block_size => hex(@{$result}[5]->{result}->{size}), block_gas => hex(@{$result}[5]->{result}->{gasUsed}), - block_difficulty => hex(@{$result}[5]->{result}->{totalDifficulty}), + # block_difficulty => hex(@{$result}[5]->{result}->{totalDifficulty}), block_uncles => scalar(@{$$result[5]->{result}->{uncles}}), block_transactions => scalar(@{$$result[5]->{result}->{transactions}})}; $self->{output}->output_add(severity => 'OK', long_msg => 'Node status: [is_mining: ' . @{$result}[0]->{result} . '] [sync_start: ' . $res_startingBlock . - '] [sync_current: ' . $res_currentBlock . '] [sync_highest: ' . $res_highestBlock . '] [sync: ' . $res_sync . '%%]'); + '] [sync_current: ' . $res_currentBlock . '] [sync_highest: ' . $res_highestBlock . '] [sync: ' . $res_sync . '%]'); $self->{output}->output_add(severity => 'OK', long_msg => 'Client: [coinbase: ' . @{$result}[1]->{result} . ']'); $self->{output}->output_add(severity => 'OK', long_msg => 'Global: [hashrate: ' . hex(@{$result}[3]->{result}) . '] [block_number: ' . (defined @{$result}[4]->{result} ? hex(@{$result}[4]->{result}) : 0) . ']'); - $self->{output}->output_add(severity => 'OK', long_msg => 'Last block: [block_time: ' . localtime(hex(@{$result}[5]->{result}->{timestamp})) . '] [block_gas_limit: ' . hex(@{$result}[5]->{result}->{gasLimit}) . + $self->{output}->output_add(severity => 'OK', long_msg => 'Last block: [block_time: ' . $res_block_time . '] [block_gas_limit: ' . hex(@{$result}[5]->{result}->{gasLimit}) . '] [block_miner: ' . @{$result}[5]->{result}->{miner} . '] [block_hash: ' . @{$result}[5]->{result}->{hash} . '] [last_block_number: ' . hex(@{$result}[5]->{result}->{number}) . ']'); diff --git a/blockchain/parity/restapi/mode/parity.pm b/blockchain/parity/restapi/mode/parity.pm index d3aad2c31..aad3fb67c 100644 --- a/blockchain/parity/restapi/mode/parity.pm +++ b/blockchain/parity/restapi/mode/parity.pm @@ -122,7 +122,7 @@ sub manage_selection { $self->{output}->output_add(long_msg => "Network: [peers_connected: " . @{$result}[3]->{result}->{connected} . "] [peers_max: " . @{$result}[3]->{result}->{max} . "] [peers: " . scalar(@{$$result[3]->{result}->{peers}}) . "]", severity => 'OK'); $self->{output}->output_add(long_msg => "Node: [node_name: " . @{$result}[5]->{result} . "] [enode: " . @{$result}[4]->{result} . "]", severity => 'OK'); - $self->{output}->output_add(long_msg => "Mempool: [pending_transactions: " . scalar(@{$$result[2]->{result}}) . "]", severity => 'OK'); + $self->{output}->output_add(long_msg => "Mempool: [pending_transactions: " . scalar(@{$$result[2]->{result}}) . "] [transactions_limit: " . @{$result}[6]->{result} . "]", severity => 'OK'); $self->{mempool} = { mempool => scalar(@{$$result[2]->{result}}) / @{$result}[6]->{result} * 100 }; #TO CHECK division entière } From 69fec615263c6954a4a360955e84c1470421ad72 Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Mon, 13 Apr 2020 15:41:39 +0000 Subject: [PATCH 016/283] default and configurable port support --- blockchain/parity/restapi/custom/api.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/blockchain/parity/restapi/custom/api.pm b/blockchain/parity/restapi/custom/api.pm index d792c57d8..a9e1866a5 100644 --- a/blockchain/parity/restapi/custom/api.pm +++ b/blockchain/parity/restapi/custom/api.pm @@ -41,7 +41,8 @@ sub new { if (!defined($options{noptions})) { $options{options}->add_options(arguments => { - "hostname:s" => { name => 'hostname' }, + "hostname:s" => { name => 'hostname' }, + "port:s" => { name => 'port' }, "timeout:s" => { name => 'timeout' }, "api-path:s" => { name => 'api_path' }, }); @@ -81,6 +82,7 @@ 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} : 8545; $self->{timeout} = (defined($self->{option_results}->{timeout})) ? $self->{option_results}->{timeout} : 10; $self->{api_path} = (defined($self->{option_results}->{api_path})) ? $self->{option_results}->{api_path} : '/'; @@ -102,7 +104,7 @@ sub build_options_for_httplib { $self->{option_results}->{hostname} = $self->{hostname}; $self->{option_results}->{timeout} = $self->{timeout}; - $self->{option_results}->{port} = 8545; + $self->{option_results}->{port} = $self->{port}; $self->{option_results}->{proto} = 'http'; } From c31964cbdd3d72212000b7cd2ea83abe0c7550f9 Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Tue, 14 Apr 2020 10:41:34 +0000 Subject: [PATCH 017/283] delete unnecessary print --- blockchain/parity/restapi/mode/eth.pm | 6 +++--- blockchain/parity/restapi/mode/parity.pm | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/blockchain/parity/restapi/mode/eth.pm b/blockchain/parity/restapi/mode/eth.pm index 90f5a0ae8..ac872603e 100644 --- a/blockchain/parity/restapi/mode/eth.pm +++ b/blockchain/parity/restapi/mode/eth.pm @@ -145,9 +145,9 @@ sub manage_selection { my $gas_price = hex(@{$result}[2]->{result}); my $res_block_time = @{$result}[5]->{result}->{timestamp} == 0 ? '': localtime(hex(@{$result}[5]->{result}->{timestamp})); - use Data::Dumper; - print Dumper($res_block_time) ; - print Dumper(@{$result}[5]->{result}->{timestamp}); + # use Data::Dumper; + # print Dumper($res_block_time) ; + # print Dumper(@{$result}[5]->{result}->{timestamp}); # conditional formating: my $res_sync = @{$result}[6]->{result} ? hex((@{$result}[6]->{result}->{currentBlock} / @{$result}[6]->{result}->{highestBlock})) * 100 : 100; diff --git a/blockchain/parity/restapi/mode/parity.pm b/blockchain/parity/restapi/mode/parity.pm index aad3fb67c..9da861cb1 100644 --- a/blockchain/parity/restapi/mode/parity.pm +++ b/blockchain/parity/restapi/mode/parity.pm @@ -89,7 +89,7 @@ sub manage_selection { my $result = $options{custom}->request_api(method => 'POST', query_form_post => $query_form_post); - use Data::Dumper; + # use Data::Dumper; # print Dumper($result); # Parity version construction From bd6995baf0151b954216136d3c09f5f09396d563 Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Mon, 11 May 2020 15:50:37 +0000 Subject: [PATCH 018/283] Code to be completed --- blockchain/parity/ethpoller/mode/disk.pm | 135 +++++++++++ blockchain/parity/ethpoller/mode/stats.pm | 120 ++++++---- blockchain/parity/ethpoller/mode/tracking.pm | 221 +++++++++++++++++++ blockchain/parity/ethpoller/plugin.pm | 8 +- blockchain/parity/restapi/mode/eth.pm | 48 +++- blockchain/parity/restapi/mode/infos.pm | 121 ++++++++++ blockchain/parity/restapi/mode/net.pm | 2 +- blockchain/parity/restapi/mode/parity.pm | 65 +++++- blockchain/parity/restapi/plugin.pm | 3 +- 9 files changed, 666 insertions(+), 57 deletions(-) create mode 100644 blockchain/parity/ethpoller/mode/disk.pm create mode 100644 blockchain/parity/ethpoller/mode/tracking.pm create mode 100644 blockchain/parity/restapi/mode/infos.pm diff --git a/blockchain/parity/ethpoller/mode/disk.pm b/blockchain/parity/ethpoller/mode/disk.pm new file mode 100644 index 000000000..bd5158c28 --- /dev/null +++ b/blockchain/parity/ethpoller/mode/disk.pm @@ -0,0 +1,135 @@ +# +# Copyright 2020 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 blockchain::parity::ethpoller::mode::disk; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use bigint; +use Digest::MD5 qw(md5_hex); + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', cb_prefix_output => 'prefix_module_output', type => 0 }, + ]; + + $self->{maps_counters}->{global} = [ + { label => 'disk_free', nlabel => 'eth.poller.disk.free', set => { + key_values => [ { name => 'disk_free' } ], + output_template => "Disk free: %d ", + perfdatas => [ + { label => 'disk_free', value => 'disk_free_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'disk_available', nlabel => 'eth.poller.disk.free', set => { + key_values => [ { name => 'disk_available' } ], + output_template => "Disk available: %d ", + perfdatas => [ + { label => 'disk_available', value => 'disk_available_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'disk_size', nlabel => 'eth.poller.disk.size', set => { + key_values => [ { name => 'disk_size' } ], + output_template => "Disk size: %d ", + perfdatas => [ + { label => 'disk_size', value => 'disk_size_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'disk_used', nlabel => 'eth.poller.disk.used', set => { + key_values => [ { name => 'disk_used' } ], + output_template => "Disk used: %d ", + perfdatas => [ + { label => 'disk_used', value => 'disk_used_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'disk_usage', nlabel => 'eth.poller.disk.usage', set => { + key_values => [ { name => 'disk_usage' } ], + output_template => "Disk usage: %d %", + perfdatas => [ + { label => 'disk_usage', value => 'disk_usage_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'blockchain_dir', nlabel => 'eth.poller.blockchain.directory', set => { + key_values => [ { name => 'blockchain_dir' } ], + output_template => "Blockchain directory: %d", + perfdatas => [ + { label => 'blockchain_dir', value => 'blockchain_dir_absolute', template => '%d', min => 0 } + ], + } + } + ]; + +} + +sub prefix_output { + my ($self, %options) = @_; + + return "Disk '"; +} + +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' }, + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + my $result = $options{custom}->request_api(url_path => '/disk'); + + # use Data::Dumper; + # print Dumper($result); + + $self->{global} = { disk_free => $result->{free}, + disk_available => $result->{available}, + disk_size => $result->{size}, + disk_used => $result->{used}, + disk_usage => $result->{usage}, + blockchain_dir => $result->{dir} + }; + + $self->{output}->output_add(severity => 'OK', long_msg => 'Ledger: ' . $result->{dir} . ' (' . $result->{usage} . '%)'); +} + +1; + +__END__ + +=head1 MODE + +Check Parity eth-poller for disk monitoring + +=cut diff --git a/blockchain/parity/ethpoller/mode/stats.pm b/blockchain/parity/ethpoller/mode/stats.pm index e6cbe1451..10acb6bef 100644 --- a/blockchain/parity/ethpoller/mode/stats.pm +++ b/blockchain/parity/ethpoller/mode/stats.pm @@ -24,61 +24,61 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; +use bigint; use Digest::MD5 qw(md5_hex); sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ - { name => 'global', cb_prefix_output => 'prefix_module_output', type => 0 }, + { name => 'block', cb_prefix_output => 'prefix_output_block', type => 0 }, + { name => 'transaction', cb_prefix_output => 'prefix_output_transaction', type => 0 } ]; - $self->{maps_counters}->{global} = [ - { label => 'stats_blockInterval', nlabel => 'parity.stats.block.interval', set => { - key_values => [ { name => 'stats_blockInterval' } ], - output_template => "Block interval: %d ", + $self->{maps_counters}->{block} = [ + { label => 'block_freq', nlabel => 'parity.stats.block.frequency', set => { + key_values => [ { name => 'block_freq' } ], + output_template => "Block frequency: %d (block/min)", perfdatas => [ - { label => 'stats_blockInterval', value => 'stats_blockInterval_absolute', template => '%d', min => 0 } + { label => 'block_freq', value => 'block_freq_absolute', template => '%d', min => 0 } ], } - }, - { label => 'stats_contracts', nlabel => 'eth.poller.stats.contracts.number', set => { - key_values => [ { name => 'stats_contracts' } ], - output_template => "Cumulative contracts: %d ", - perfdatas => [ - { label => 'stats_contracts', value => 'stats_contracts_absolute', template => '%d', min => 0 } - ], - } - }, - { label => 'stats_blocks', nlabel => 'eth.poller.stats.blocks.number', set => { - key_values => [ { name => 'stats_blocks' } ], - output_template => "Cumulative blocks: %d ", - perfdatas => [ - { label => 'stats_blocks', value => 'stats_blocks_absolute', template => '%d', min => 0 } - ], - } - }, - { label => 'stats_transactions', nlabel => 'eth.poller.stats.transactions.number', set => { - key_values => [ { name => 'stats_transactions' } ], - output_template => "Cumulative transactions: %d ", - perfdatas => [ - { label => 'stats_transactions', value => 'stats_transactions_absolute', template => '%d', min => 0 } - ], - } - }, + } ]; + $self->{maps_counters}->{transaction} = [ + { label => 'transaction_freq', nlabel => 'parity.stats.transaction.frequency', set => { + key_values => [ { name => 'transaction_freq' } ], + output_template => "Transaction frequency: %d (tx/min)", + perfdatas => [ + { label => 'transaction_freq', value => 'transaction_freq_absolute', template => '%d', min => 0 } + ], + } + } + ]; } -sub prefix_output { +sub prefix_output_block { my ($self, %options) = @_; - return "Stats '"; + return "Block stats '"; +} + +sub prefix_output_fork { + my ($self, %options) = @_; + + return "Fork stats '"; +} + +sub prefix_output_transaction { + my ($self, %options) = @_; + + return "Transaction stats '"; } sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1, statefile => 1); bless $self, $class; $options{options}->add_options(arguments => { @@ -91,16 +91,52 @@ sub new { sub manage_selection { my ($self, %options) = @_; + $self->{cache_name} = "parity_ethpoller_" . $self->{mode} . '_' . (defined($self->{option_results}->{hostname}) ? $self->{option_results}->{hostname} : 'me') . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); + my $result = $options{custom}->request_api(url_path => '/stats'); - # use Data::Dumper; - # print Dumper($result); + my $old_block_timestamp = $self->{statefile_cache}->get(name => 'last_block_timestamp'); + my $old_block_count = $self->{statefile_cache}->get(name => 'last_block_count'); - $self->{global} = { stats_blockInterval => $result->{blockInterval}, - stats_contracts => $result->{cumulative}->{contracts}, - stats_blocks => $result->{cumulative}->{blocks}, - stats_transactions => $result->{cumulative}->{transactions} - }; + my $old_tx_timestamp = $self->{statefile_cache}->get(name => 'last_tx_timestamp'); + my $old_tx_count = $self->{statefile_cache}->get(name => 'last_tx_count'); + + my $datas = {}; + $datas->{last_block_timestamp} = time(); + $datas->{last_block_count} = $result->{block}->{count}; + + $datas->{last_tx_timestamp} = time(); + $datas->{last_tx_count} = $result->{block}->{count}; + + use Data::Dumper; + print Dumper($old_timestamp); + + my $res_timestamp = 0; + + if ($old_block_count && $old_block_timestamp) { + $res_timestamp = $result->{block}->{timestamp}) == 0 ? '' : $result->{block}->{timestamp})); + my $calculated_block_freq = ($result->{block}->{count} - $old_block_count) / (time() - $old_block_timestamp); + $self->{block} = { block_freq => $calculated_block_freq }; + $self->{output}->output_add(severity => 'OK', long_msg => 'Last block (#' . $result->{block}->{count} . ') was at ' . $res_timestamp); + } else { + $self->{output}->output_add(severity => 'OK', long_msg => 'Last block (#' . $result->{block}->{block} . ') was at ' . $res_timestamp . '. Block frequency is being calculated...'); + } + + if ($old_tx_count && $old_tx_timestamp) { + $res_timestamp = $result->{transaction}->{timestamp}) == 0 ? '' : $result->{transaction}->{timestamp})); + my $calculated_tx_freq = ($result->{transaction}->{count} - $old_tx_count) / (time() - $old_tx_timestamp); + $self->{transaction} = { transaction_freq => $calculated_tx_freq }; + $self->{output}->output_add(severity => 'OK', long_msg => 'Last transaction (#' . $result->{transaction}->{count} . ') was at ' . $res_timestamp); + } else { + $self->{output}->output_add(severity => 'OK', long_msg => 'Last transaction (#' . $result->{transaction}->{count} . ') was at ' . $res_timestamp . '. Transaction frequency is being calculated...'); + } + + if ($result->{fork}->{count} > 0) { + $self->{output}->output_add(severity => 'OK', long_msg => 'Last fork (#' . $result->{fork}->{count} . ') was at ' . $res_timestamp); + } else { + $self->{output}->output_add(severity => 'OK', long_msg => 'No fork occurence'); + } } 1; @@ -109,6 +145,6 @@ __END__ =head1 MODE -Check Parity eth-poller for accounts tracking +Check Parity eth-poller for stats =cut diff --git a/blockchain/parity/ethpoller/mode/tracking.pm b/blockchain/parity/ethpoller/mode/tracking.pm new file mode 100644 index 000000000..3fbb113dc --- /dev/null +++ b/blockchain/parity/ethpoller/mode/tracking.pm @@ -0,0 +1,221 @@ +# +# Copyright 2020 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 blockchain::parity::ethpoller::mode::tracking; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use bigint; +use Digest::MD5 qw(md5_hex); + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'events', cb_prefix_output => 'prefix_module_events', type => 1, message_multiple => 'All event metrics are ok' }, + { name => 'miners', cb_prefix_output => 'prefix_module_miners', type => 1, message_multiple => 'All miner metrics are ok' }, + { name => 'balances', cb_prefix_output => 'prefix_module_balances', type => 1, message_multiple => 'All balance metrics are ok' }, + ]; + + $self->{maps_counters}->{events} = [ + { label => 'event_frequency', nlabel => 'parity.tracking.event.frequency', set => { + key_values => [ { name => 'event_frequency' } ], + output_template => "Event's frequency: %d (evt/min)", + perfdatas => [ + { label => 'event_frequency', value => 'event_frequency_absolute', template => '%d', min => 0 } + ], + } + } + ]; + + $self->{maps_counters}->{miners} = [ + { label => 'mining_frequency', nlabel => 'parity.tracking.mining.frequency', set => { + key_values => [ { name => 'mining_frequency' } ], + output_template => "Mining frequency: %d (block/min)", + perfdatas => [ + { label => 'mining_frequency', value => 'mining_frequency_absolute', template => '%d', min => 0 } + ], + } + } + ]; + + $self->{maps_counters}->{balances} = [ + { label => 'balance_fluctuation', nlabel => 'parity.tracking.balances.fluctuation', set => { + key_values => [ { name => 'balance_fluctuation' } ], + output_template => "Balance fluctuation: %d (diff/min)", + perfdatas => [ + { label => 'balance_fluctuation', value => 'balance_fluctuation_absolute', template => '%d', min => 0 } + ], + } + } + ]; + +} + +sub prefix_output_events { + my ($self, %options) = @_; + + return "Event stats '"; +} + +sub prefix_output_miners { + my ($self, %options) = @_; + + return "Miner stats '"; +} + +sub prefix_output_balances { + my ($self, %options) = @_; + + return "Balance stats '"; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1, statefile => 1); + bless $self, $class; + + $options{options}->add_options(arguments => { + "filter-name:s" => { name => 'filter_name' }, + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + $self->{cache_name} = "parity_ethpoller_" . $self->{mode} . '_' . (defined($self->{option_results}->{hostname}) ? $self->{option_results}->{hostname} : 'me') . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); + + my $results = $options{custom}->request_api(url_path => '/tracking'); + + # use Data::Dumper; + # print Dumper($results); + + my $res_timestamp = 0; + my $calculated_frequency = 0; + + $self->{events} = {}; + $self->{miners} = {}; + $self->{balances} = {}; + + my $datas = {}; + + foreach my $event (@{$results->{events}}) { + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $event->{id} !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping '" . $event->{id} . "': no matching filter name.", debug => 1); + next; + } + + my $old_event_timestamp = $self->{statefile_cache}->get(name => 'last_event_timestamp'); #get the id last_event_timestamp + my $old_event_count = $self->{statefile_cache}->get(name => 'last_event_count'); #get the id last_event_count + + $datas->{$event->{id}}->{last_event_timestamp} = time(); + $datas->{$event->{id}}->{last_event_count} = $result->{block}->{count}; + + if ($old_event_count && $old_event_timestamp) { + $calculated_frequency = ($event->{count} - $old_event_count) / (time() - $old_event_timestamp); + + $self->{events}->{$event->{id}}->{display} = $event->{label}; + $self->{events}->{$event->{id}}->{event_frequency} = $calculated_frequency; + + $res_timestamp = $event->{timestamp} == 0 ? '': localtime($event->{timestamp}); + + if ($event->{count} > 0) { + $self->{output}->output_add(severity => 'OK', long_msg => 'Event ' . $event->{id} . ': Last Tx from "' . $event->{label} . '" (#' . $event->{count} . + ') was at ' . $res_timestamp . ' (block #' . $event->{block} . ')' ); + } else { + $self->{output}->output_add(severity => 'OK', long_msg => 'Event ' . $event->{id} . ': No Tx from "' . $event->{label} . '"'); + } + } else { + $self->{output}->output_add(severity => 'OK', long_msg => 'Event ' . $event->{id} . ': Building perfdata for "' . $event->{label} . '"...'); + } + } + + foreach my $miner (@{$results->{miners}}) { + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $miner->{id} !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping '" . $miner->{id} . "': no matching filter name.", debug => 1); + next; + } + + my $old_miner_timestamp = $self->{statefile_cache}->get(name => 'last_miner_timestamp'); #get the id last_miner_timestamp + my $old_miner_count = $self->{statefile_cache}->get(name => 'last_miner_count'); #get the id last_miner_count + + $datas->{$miner->{id}}->{last_miner_timestamp} = time(); + $datas->{$miner->{id}}->{last_miner_count} = $result->{block}->{count}; + + if ($old_miner_timestamp && $old_miner_timestamp) { + $calculated_frequency = ($miner->{count} - $old_miner_count) / (time() - $old_miner_timestamp); + + $self->{miners}->{$miner->{id}}->{display} = $miner->{label}; + $self->{miners}->{$miner->{id}}->{mining_frequency} = $calculated_frequency; + + $res_timestamp = $miner->{timestamp} == 0 ? '': localtime($miner->{timestamp}); + if ($miner->{count} > 0) { + $self->{output}->output_add(severity => 'OK', long_msg => 'Miner ' . $miner->{id} . ': Last block from label "' . $miner->{label} . '" (#' . $miner->{count} . + ') was at ' . $res_timestamp . ' (block #' . $miner->{block} . ')' ); + } else { + $self->{output}->output_add(severity => 'OK', long_msg => 'Miner ' . $miner->{id} . ': No validation from "' . $miner->{label} . '"'); + } + } else { + $self->{output}->output_add(severity => 'OK', long_msg => 'Miner ' . $miner->{id} . ': Building perfdata for "' . $miner->{label} . '"...'); + } + } + + foreach my $balance (@{$results->{balances}}) { + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $balance->{id} !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping '" . $balance->{id} . "': no matching filter name.", debug => 1); + next; + } + + my $old_balance = $self->{statefile_cache}->get(name => 'last_balance'); #get the id last_balance + + $datas->{$balance->{id}}->{last_balance} = $balance->{balance}; + + if ($old_balance) { + $calculated_diff = ($balance->{balance} - $old_balance) / ($old_balance); + + $self->{balances}->{$balance->{id}}->{display} = $balance->{label}; + $self->{balances}->{$balance->{id}}->{balance} = $calculated_diff; + + $self->{output}->output_add(severity => 'OK', long_msg => 'Balance ' . $balance->{id} . ': Balance of "' . $balance->{label} . '" is ' . $balance->{balance} . ' ether' ); + } else { + $self->{output}->output_add(severity => 'OK', long_msg => 'Balance ' . $balance->{id} . ': Balance fluctuation of "' . $balance->{label} . '" is being calculated...'); + } + } + + +} + +1; + +__END__ + +=head1 MODE + +Check Parity eth-poller for events, miners and balances tracking + +=cut diff --git a/blockchain/parity/ethpoller/plugin.pm b/blockchain/parity/ethpoller/plugin.pm index 77989acd3..48e08df5c 100644 --- a/blockchain/parity/ethpoller/plugin.pm +++ b/blockchain/parity/ethpoller/plugin.pm @@ -31,9 +31,11 @@ sub new { $self->{version} = '0.1'; %{$self->{modes}} = ( - 'watchlist' => 'blockchain::parity::ethpoller::mode::watchlist', - 'fork' => 'blockchain::parity::ethpoller::mode::fork', - 'stats' => 'blockchain::parity::ethpoller::mode::stats' + # 'watchlist' => 'blockchain::parity::ethpoller::mode::watchlist', + # 'fork' => 'blockchain::parity::ethpoller::mode::fork', + 'stats' => 'blockchain::parity::ethpoller::mode::stats', + 'disk' => 'blockchain::parity::ethpoller::mode::disk', + 'tracking' => 'blockchain::parity::ethpoller::mode::tracking' ); $self->{custom_modes}{api} = 'blockchain::parity::ethpoller::custom::api'; return $self; diff --git a/blockchain/parity/restapi/mode/eth.pm b/blockchain/parity/restapi/mode/eth.pm index ac872603e..08c7a8461 100644 --- a/blockchain/parity/restapi/mode/eth.pm +++ b/blockchain/parity/restapi/mode/eth.pm @@ -41,11 +41,23 @@ sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ - { name => 'global', cb_prefix_output => 'prefix_module_output', type => 0 }, + { name => 'gas', cb_prefix_output => 'prefix_module_output', type => 0 }, { name => 'block', cb_prefix_output => 'prefix_module_output', type => 0 }, + { name => 'sync', cb_prefix_output => 'prefix_module_output', type => 0 }, ]; - $self->{maps_counters}->{global} = [ + $self->{maps_counters}->{gas} = [ + { label => 'sync_status', nlabel => 'parity.eth.sync.status', set => { + key_values => [ { name => 'sync_status' } ], + output_template => "The gas price is: %d %% ", + perfdatas => [ + { label => 'sync_status', value => 'sync_status_absolute', template => '%d', min => 0 } + ], + } + } + ]; + + $self->{maps_counters}->{gas} = [ { label => 'gas_price', nlabel => 'parity.eth.gas.price', set => { key_values => [ { name => 'gas_price' } ], output_template => "The gas price is: %d wei ", @@ -53,6 +65,22 @@ sub set_counters { { label => 'gas_price', value => 'gas_price_absolute', template => '%d', min => 0 } ], } + }, + { label => 'gas_used', nlabel => 'parity.eth.gas.used', set => { + key_values => [ { name => 'gas_used' } ], + output_template => "The gas used is: %d", + perfdatas => [ + { label => 'gas_used', value => 'gas_used_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'gas_limit', nlabel => 'parity.eth.gas.limit', set => { + key_values => [ { name => 'gas_limit' } ], + output_template => "The gas limit is: %d", + perfdatas => [ + { label => 'gas_limit', value => 'gas_limit_absolute', template => '%d', min => 0 } + ], + } } ]; @@ -65,6 +93,14 @@ sub set_counters { ], } }, + { label => 'block_usage', nlabel => 'parity.eth.block.usage', set => { + key_values => [ { name => 'block_usage' } ], + output_template => "Block usage: %d %%", + perfdatas => [ + { label => 'block_usage', value => 'block_usage_absolute', template => '%d', min => 0 } + ], + } + }, { label => 'block_transactions', nlabel => 'parity.eth.block.transactions.number', set => { key_values => [ { name => 'block_transactions' } ], output_template => "Block transactions number: %d ", @@ -174,10 +210,16 @@ sub manage_selection { # $cache->set('gas_price', $gas_price); # } - $self->{global} = { gas_price => $gas_price }; + $self->{sync} = { sync_status => $res_sync }; + $self->{gas} = { gas_price => $gas_price, + gas_used => hex(@{$result}[5]->{result}->{gasLimit}), + gas_limit => hex(@{$result}[5]->{result}->{gasUsed}) }; + + my $calculated_block_usage = hex(@{$result}[5]->{result}->{gasUsed}) / hex(@{$result}[5]->{result}->{gasLimit}); $self->{block} = { block_size => hex(@{$result}[5]->{result}->{size}), block_gas => hex(@{$result}[5]->{result}->{gasUsed}), + block_usage => $calculated_block_usage, # block_difficulty => hex(@{$result}[5]->{result}->{totalDifficulty}), block_uncles => scalar(@{$$result[5]->{result}->{uncles}}), block_transactions => scalar(@{$$result[5]->{result}->{transactions}})}; diff --git a/blockchain/parity/restapi/mode/infos.pm b/blockchain/parity/restapi/mode/infos.pm new file mode 100644 index 000000000..c93eee5ab --- /dev/null +++ b/blockchain/parity/restapi/mode/infos.pm @@ -0,0 +1,121 @@ +# +# Copyright 2020 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 blockchain::parity::restapi::mode::infos; + +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 catalog_status_calc); + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1, statefile => 1); + bless $self, $class; + + $options{options}->add_options(arguments => { + 'unknown-status:s' => { name => 'unknown_status', default => '' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '%{listening} !~ /true/' }, + }); + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->change_macros(macros => ['unknown_status', 'warning_status', 'critical_status']); +} + +sub prefix_module_output { + my ($self, %options) = @_; + + return "Parity network module: "; +} + +sub manage_selection { + my ($self, %options) = @_; + + $self->{cache_name} = "parity_restapi_" . $self->{mode} . '_' . (defined($self->{option_results}->{hostname}) ? $self->{option_results}->{hostname} : 'me') . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); + + my $query_form_post = [ { method => 'parity_versionInfo', params => [], id => "1", jsonrpc => "2.0" }, + { method => 'parity_chain', params => [], id => "2", jsonrpc => "2.0" }, + { method => 'eth_mining', params => [], id => "3", jsonrpc => "2.0" }, + { method => 'parity_nodeName', params => [], id => "4", jsonrpc => "2.0" }, ]; + + my $result = $options{custom}->request_api(method => 'POST', query_form_post => $query_form_post); + + # use Data::Dumper; + # print Dumper($result); + + # Parity version construction + my $res_parity_version = @{$result}[0]->{result}->{version}->{major} . '.' . @{$result}[0]->{result}->{version}->{minor} . '.' . @{$result}[0]->{result}->{version}->{patch}; + + + # Alerts management + # my $cache = Cache::File->new( cache_root => './parity-restapi-cache' ); + + # if (my $cached_count = $cache->get('peers_count')) { + # if ($peer_count < $cached_count) { + # #alert + # } elsif ($peer_count > $cached_count) { + # #alert + # } + # } else { + # $cache->set('peers_count', $peer_count); + # } + + $self->{output}->output_add(long_msg => "Parity version: '" . $res_parity_version . "'. Chain name: '" . @{$result}[1]->{result} . + "'. Node name: '" . @{$result}[3]->{result} . "'. is_validator: '" . @{$result}[2]->{result} . "'.", severity => 'OK'); +} + +1; + +__END__ + +=head1 MODE + +Check parity network cross module metrics (parity_versionInfo, parity_chain, eth_mining, parity_nodeName) + +=over 8 + +=item B<--unknown-status> + +Set unknown threshold for listening status (Default: ''). + +=item B<--warning-status> + +Set warning threshold for listening status (Default: ''). + +=item B<--critical-status> + +Set critical threshold for listening status (Default: '%{listening} !~ /true/'). + +=item B<--warning-peers> B<--critical-peers> + +Warning and Critical threhsold on the number of peer + +=back + +=cut diff --git a/blockchain/parity/restapi/mode/net.pm b/blockchain/parity/restapi/mode/net.pm index 2ad2ca153..7bc65d3a8 100644 --- a/blockchain/parity/restapi/mode/net.pm +++ b/blockchain/parity/restapi/mode/net.pm @@ -109,7 +109,7 @@ sub manage_selection { $self->{network} = { peers => hex(@{$result}[1]->{result}) }; - $self->{output}->output_add(long_msg => "Node status: [is_listening: " . $peer_count . ']', severity => 'OK'); + $self->{output}->output_add(long_msg => "Node status: [is_listening: " . @{$result}[0]->{result} . ']', severity => 'OK'); } 1; diff --git a/blockchain/parity/restapi/mode/parity.pm b/blockchain/parity/restapi/mode/parity.pm index 9da861cb1..7e62fda50 100644 --- a/blockchain/parity/restapi/mode/parity.pm +++ b/blockchain/parity/restapi/mode/parity.pm @@ -31,15 +31,59 @@ sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ - { name => 'mempool', cb_prefix_output => 'prefix_module_output', type => 0 } + { name => 'mempool', cb_prefix_output => 'prefix_module_output', type => 0 }, + { name => 'peers', cb_prefix_output => 'prefix_module_output', type => 0 } ]; $self->{maps_counters}->{mempool} = [ - { label => 'mempool', nlabel => 'parity.mempol.usage', set => { - key_values => [ { name => 'mempool' } ], - output_template => "Mempool: %d %% ", + { label => 'tx_pending', nlabel => 'parity.pending.transactions', set => { + key_values => [ { name => 'tx_pending' } ], + output_template => "Pending transactions: %d", perfdatas => [ - { label => 'mempool', value => 'mempool_absolute', template => '%d', min => 0 } + { label => 'tx_pending', value => 'tx_pending_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'mempool_size', nlabel => 'parity.mempol.size', set => { + key_values => [ { name => 'mempool_size' } ], + output_template => "Mempool size: %d", + perfdatas => [ + { label => 'mempool_size', value => 'mempool_size_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'mempool_usage', nlabel => 'parity.mempol.usage', set => { + key_values => [ { name => 'mempool_usage' } ], + output_template => "Mempool usage: %d %% ", + perfdatas => [ + { label => 'mempool_usage', value => 'mempool_usage_absolute', template => '%d', min => 0 } + ], + } + }, + ]; + + $self->{maps_counters}->{peers} = [ + { label => 'peers_connected', nlabel => 'parity.peers.connected', set => { + key_values => [ { name => 'peers_connected' } ], + output_template => "Peers connected: %d", + perfdatas => [ + { label => 'peers_connected', value => 'peers_connected_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'peers_max', nlabel => 'parity.peers.max', set => { + key_values => [ { name => 'peers_max' } ], + output_template => "Peers max: %d", + perfdatas => [ + { label => 'peers_max', value => 'peers_max_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'peers_usage', nlabel => 'parity.peers.usage', set => { + key_values => [ { name => 'peers_usage' } ], + output_template => "Mempool usage: %d %% ", + perfdatas => [ + { label => 'peers_usage', value => 'peers_usage_absolute', template => '%d', min => 0 } ], } }, @@ -85,7 +129,8 @@ sub manage_selection { { method => 'parity_netPeers', params => [], id => "4", jsonrpc => "2.0" }, { method => 'parity_enode', params => [], id => "5", jsonrpc => "2.0" }, { method => 'parity_nodeName', params => [], id => "6", jsonrpc => "2.0" }, - { method => 'parity_transactionsLimit', params => [], id => "7", jsonrpc => "2.0" } ]; #TO CHECK parity_transactionsLimit could be done once, at the beginning of the process + { method => 'parity_transactionsLimit', params => [], id => "7", jsonrpc => "2.0" }, #TO CHECK parity_transactionsLimit could be done once, at the beginning of the process + { method => 'net_peerCount', params => [], id => "8", jsonrpc => "2.0" } ]; my $result = $options{custom}->request_api(method => 'POST', query_form_post => $query_form_post); @@ -124,7 +169,13 @@ sub manage_selection { $self->{output}->output_add(long_msg => "Node: [node_name: " . @{$result}[5]->{result} . "] [enode: " . @{$result}[4]->{result} . "]", severity => 'OK'); $self->{output}->output_add(long_msg => "Mempool: [pending_transactions: " . scalar(@{$$result[2]->{result}}) . "] [transactions_limit: " . @{$result}[6]->{result} . "]", severity => 'OK'); - $self->{mempool} = { mempool => scalar(@{$$result[2]->{result}}) / @{$result}[6]->{result} * 100 }; #TO CHECK division entière + $self->{mempool} = { mempool_usage => scalar(@{$$result[2]->{result}}) / @{$result}[6]->{result} * 100, #TO CHECK division entière + mempool_size => @{$result}[6]->{result}, + tx_pending => scalar(@{$$result[2]->{result}}) }; + + $self->{peers} = { peers_usage => @{$result}[3]->{result}->{connected} / @{$result}[3]->{result}->{max} * 100, #TO CHECK division entière + peers_max => @{$result}[3]->{result}->{max}, + peers_connected => @{$result}[3]->{result}->{connected} }; } 1; diff --git a/blockchain/parity/restapi/plugin.pm b/blockchain/parity/restapi/plugin.pm index 7cffb8686..b470c1666 100644 --- a/blockchain/parity/restapi/plugin.pm +++ b/blockchain/parity/restapi/plugin.pm @@ -33,7 +33,8 @@ sub new { %{$self->{modes}} = ( 'net' => 'blockchain::parity::restapi::mode::net', 'eth' => 'blockchain::parity::restapi::mode::eth', - 'parity' => 'blockchain::parity::restapi::mode::parity' + 'parity' => 'blockchain::parity::restapi::mode::parity', + 'infos' => 'blockchain::parity::restapi::mode::infos' ); $self->{custom_modes}{api} = 'blockchain::parity::restapi::custom::api'; return $self; From 8ed7f631a4251b638ea93bd8ba831a041036e18e Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Mon, 11 May 2020 18:32:33 +0000 Subject: [PATCH 019/283] code to be completed 2/2 --- blockchain/parity/ethpoller/mode/disk.pm | 2 +- blockchain/parity/ethpoller/mode/stats.pm | 6 +++--- blockchain/parity/ethpoller/mode/tracking.pm | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/blockchain/parity/ethpoller/mode/disk.pm b/blockchain/parity/ethpoller/mode/disk.pm index bd5158c28..586d41da9 100644 --- a/blockchain/parity/ethpoller/mode/disk.pm +++ b/blockchain/parity/ethpoller/mode/disk.pm @@ -69,7 +69,7 @@ sub set_counters { }, { label => 'disk_usage', nlabel => 'eth.poller.disk.usage', set => { key_values => [ { name => 'disk_usage' } ], - output_template => "Disk usage: %d %", + output_template => "Disk usage: %d %%", perfdatas => [ { label => 'disk_usage', value => 'disk_usage_absolute', template => '%d', min => 0 } ], diff --git a/blockchain/parity/ethpoller/mode/stats.pm b/blockchain/parity/ethpoller/mode/stats.pm index 10acb6bef..e0cf28b7b 100644 --- a/blockchain/parity/ethpoller/mode/stats.pm +++ b/blockchain/parity/ethpoller/mode/stats.pm @@ -110,12 +110,12 @@ sub manage_selection { $datas->{last_tx_count} = $result->{block}->{count}; use Data::Dumper; - print Dumper($old_timestamp); + print Dumper($old_tx_timestamp); my $res_timestamp = 0; if ($old_block_count && $old_block_timestamp) { - $res_timestamp = $result->{block}->{timestamp}) == 0 ? '' : $result->{block}->{timestamp})); + $res_timestamp = $result->{block}->{timestamp} == 0 ? '' : $result->{block}->{timestamp}; my $calculated_block_freq = ($result->{block}->{count} - $old_block_count) / (time() - $old_block_timestamp); $self->{block} = { block_freq => $calculated_block_freq }; $self->{output}->output_add(severity => 'OK', long_msg => 'Last block (#' . $result->{block}->{count} . ') was at ' . $res_timestamp); @@ -124,7 +124,7 @@ sub manage_selection { } if ($old_tx_count && $old_tx_timestamp) { - $res_timestamp = $result->{transaction}->{timestamp}) == 0 ? '' : $result->{transaction}->{timestamp})); + $res_timestamp = $result->{transaction}->{timestamp} == 0 ? '' : $result->{transaction}->{timestamp}; my $calculated_tx_freq = ($result->{transaction}->{count} - $old_tx_count) / (time() - $old_tx_timestamp); $self->{transaction} = { transaction_freq => $calculated_tx_freq }; $self->{output}->output_add(severity => 'OK', long_msg => 'Last transaction (#' . $result->{transaction}->{count} . ') was at ' . $res_timestamp); diff --git a/blockchain/parity/ethpoller/mode/tracking.pm b/blockchain/parity/ethpoller/mode/tracking.pm index 3fbb113dc..49a927894 100644 --- a/blockchain/parity/ethpoller/mode/tracking.pm +++ b/blockchain/parity/ethpoller/mode/tracking.pm @@ -132,7 +132,7 @@ sub manage_selection { my $old_event_count = $self->{statefile_cache}->get(name => 'last_event_count'); #get the id last_event_count $datas->{$event->{id}}->{last_event_timestamp} = time(); - $datas->{$event->{id}}->{last_event_count} = $result->{block}->{count}; + $datas->{$event->{id}}->{last_event_count} = $event->{count}; if ($old_event_count && $old_event_timestamp) { $calculated_frequency = ($event->{count} - $old_event_count) / (time() - $old_event_timestamp); @@ -164,7 +164,7 @@ sub manage_selection { my $old_miner_count = $self->{statefile_cache}->get(name => 'last_miner_count'); #get the id last_miner_count $datas->{$miner->{id}}->{last_miner_timestamp} = time(); - $datas->{$miner->{id}}->{last_miner_count} = $result->{block}->{count}; + $datas->{$miner->{id}}->{last_miner_count} = $miner->{count}; if ($old_miner_timestamp && $old_miner_timestamp) { $calculated_frequency = ($miner->{count} - $old_miner_count) / (time() - $old_miner_timestamp); @@ -196,7 +196,7 @@ sub manage_selection { $datas->{$balance->{id}}->{last_balance} = $balance->{balance}; if ($old_balance) { - $calculated_diff = ($balance->{balance} - $old_balance) / ($old_balance); + my $calculated_diff = ($balance->{balance} - $old_balance) / ($old_balance); $self->{balances}->{$balance->{id}}->{display} = $balance->{label}; $self->{balances}->{$balance->{id}}->{balance} = $calculated_diff; From 98456bc906ca7f9b292f96f66530910fa1a00bd8 Mon Sep 17 00:00:00 2001 From: Sims24 Date: Mon, 11 May 2020 22:32:12 +0200 Subject: [PATCH 020/283] enh(plugin)correct-cache-file-mgmt --- blockchain/parity/ethpoller/mode/tracking.pm | 122 +++++-------------- 1 file changed, 31 insertions(+), 91 deletions(-) diff --git a/blockchain/parity/ethpoller/mode/tracking.pm b/blockchain/parity/ethpoller/mode/tracking.pm index 49a927894..250383c55 100644 --- a/blockchain/parity/ethpoller/mode/tracking.pm +++ b/blockchain/parity/ethpoller/mode/tracking.pm @@ -31,40 +31,42 @@ sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ - { name => 'events', cb_prefix_output => 'prefix_module_events', type => 1, message_multiple => 'All event metrics are ok' }, - { name => 'miners', cb_prefix_output => 'prefix_module_miners', type => 1, message_multiple => 'All miner metrics are ok' }, - { name => 'balances', cb_prefix_output => 'prefix_module_balances', type => 1, message_multiple => 'All balance metrics are ok' }, + { name => 'events', cb_prefix_output => 'prefix_output_events', type => 1, message_multiple => 'Events metrics are ok' }, + { name => 'miners', cb_prefix_output => 'prefix_output_miners', type => 1, message_multiple => 'Miners metrics are ok' }, + { name => 'balances', cb_prefix_output => 'prefix_output_balances', type => 1, message_multiple => 'Balances metrics are ok' } ]; $self->{maps_counters}->{events} = [ - { label => 'event_frequency', nlabel => 'parity.tracking.event.frequency', set => { - key_values => [ { name => 'event_frequency' } ], - output_template => "Event's frequency: %d (evt/min)", - perfdatas => [ - { label => 'event_frequency', value => 'event_frequency_absolute', template => '%d', min => 0 } - ], + { label => 'event_frequency', nlabel => 'parity.tracking.event.persecond', set => { + key_values => [ { name => 'event_count', diff => 1 }, { name => 'display' } ], + per_second => 1, + output_template => " %.2f (events/s)", + perfdatas => [ + { label => 'events', template => '%.2f', value => 'event_count_per_second', + label_extra_instance => 1, instance_use => 'display_absolute' } + ], } } ]; $self->{maps_counters}->{miners} = [ - { label => 'mining_frequency', nlabel => 'parity.tracking.mining.frequency', set => { + { label => 'mining_frequency', nlabel => 'parity.tracking.mined.block.persecond', set => { key_values => [ { name => 'mining_frequency' } ], - output_template => "Mining frequency: %d (block/min)", - perfdatas => [ - { label => 'mining_frequency', value => 'mining_frequency_absolute', template => '%d', min => 0 } - ], + output_template => " %.2f (blocks/s)", + perfdatas => [ instance_use => 'display_absolute', label_extra_instance => 1 ], } } ]; $self->{maps_counters}->{balances} = [ - { label => 'balance_fluctuation', nlabel => 'parity.tracking.balances.fluctuation', set => { - key_values => [ { name => 'balance_fluctuation' } ], - output_template => "Balance fluctuation: %d (diff/min)", + { label => 'balance_fluctuation', nlabel => 'parity.tracking.balances.variation.persecond', set => { + key_values => [ { name => 'balance', diff => 1 } ], + per_second => 1, + output_template => " variation: %.2f (diff/sec)", perfdatas => [ - { label => 'balance_fluctuation', value => 'balance_fluctuation_absolute', template => '%d', min => 0 } - ], + { label => 'balances', template => '%.2f', value => 'balance_per_second', + label_extra_instance => 1, instance_use => 'display_absolute' } + ], } } ]; @@ -74,24 +76,24 @@ sub set_counters { sub prefix_output_events { my ($self, %options) = @_; - return "Event stats '"; + return "Event '" . $options{instance_value}->{display} . "' "; } sub prefix_output_miners { my ($self, %options) = @_; - return "Miner stats '"; + return "Miner '" . $options{instance_value}->{display} . "' ";; } sub prefix_output_balances { my ($self, %options) = @_; - return "Balance stats '"; + return "Balance '" . $options{instance_value}->{display} . "' "; } sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1, statefile => 1); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1, force_new_perfdata => 1); bless $self, $class; $options{options}->add_options(arguments => { @@ -109,48 +111,20 @@ sub manage_selection { my $results = $options{custom}->request_api(url_path => '/tracking'); - # use Data::Dumper; - # print Dumper($results); - - my $res_timestamp = 0; - my $calculated_frequency = 0; - $self->{events} = {}; $self->{miners} = {}; $self->{balances} = {}; - - my $datas = {}; foreach my $event (@{$results->{events}}) { if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && $event->{id} !~ /$self->{option_results}->{filter_name}/) { - $self->{output}->output_add(long_msg => "skipping '" . $event->{id} . "': no matching filter name.", debug => 1); + $self->{output}->output_add(long_msg => "skipping '" . $event->{label} . "': no matching filter name.", debug => 1); next; } - my $old_event_timestamp = $self->{statefile_cache}->get(name => 'last_event_timestamp'); #get the id last_event_timestamp - my $old_event_count = $self->{statefile_cache}->get(name => 'last_event_count'); #get the id last_event_count + $self->{events}->{lc($event->{label})} = { display => lc($event->{label}), + event_count => $event->{count} }; - $datas->{$event->{id}}->{last_event_timestamp} = time(); - $datas->{$event->{id}}->{last_event_count} = $event->{count}; - - if ($old_event_count && $old_event_timestamp) { - $calculated_frequency = ($event->{count} - $old_event_count) / (time() - $old_event_timestamp); - - $self->{events}->{$event->{id}}->{display} = $event->{label}; - $self->{events}->{$event->{id}}->{event_frequency} = $calculated_frequency; - - $res_timestamp = $event->{timestamp} == 0 ? '': localtime($event->{timestamp}); - - if ($event->{count} > 0) { - $self->{output}->output_add(severity => 'OK', long_msg => 'Event ' . $event->{id} . ': Last Tx from "' . $event->{label} . '" (#' . $event->{count} . - ') was at ' . $res_timestamp . ' (block #' . $event->{block} . ')' ); - } else { - $self->{output}->output_add(severity => 'OK', long_msg => 'Event ' . $event->{id} . ': No Tx from "' . $event->{label} . '"'); - } - } else { - $self->{output}->output_add(severity => 'OK', long_msg => 'Event ' . $event->{id} . ': Building perfdata for "' . $event->{label} . '"...'); - } } foreach my $miner (@{$results->{miners}}) { @@ -160,51 +134,17 @@ sub manage_selection { next; } - my $old_miner_timestamp = $self->{statefile_cache}->get(name => 'last_miner_timestamp'); #get the id last_miner_timestamp - my $old_miner_count = $self->{statefile_cache}->get(name => 'last_miner_count'); #get the id last_miner_count - - $datas->{$miner->{id}}->{last_miner_timestamp} = time(); - $datas->{$miner->{id}}->{last_miner_count} = $miner->{count}; - - if ($old_miner_timestamp && $old_miner_timestamp) { - $calculated_frequency = ($miner->{count} - $old_miner_count) / (time() - $old_miner_timestamp); - - $self->{miners}->{$miner->{id}}->{display} = $miner->{label}; - $self->{miners}->{$miner->{id}}->{mining_frequency} = $calculated_frequency; - - $res_timestamp = $miner->{timestamp} == 0 ? '': localtime($miner->{timestamp}); - if ($miner->{count} > 0) { - $self->{output}->output_add(severity => 'OK', long_msg => 'Miner ' . $miner->{id} . ': Last block from label "' . $miner->{label} . '" (#' . $miner->{count} . - ') was at ' . $res_timestamp . ' (block #' . $miner->{block} . ')' ); - } else { - $self->{output}->output_add(severity => 'OK', long_msg => 'Miner ' . $miner->{id} . ': No validation from "' . $miner->{label} . '"'); - } - } else { - $self->{output}->output_add(severity => 'OK', long_msg => 'Miner ' . $miner->{id} . ': Building perfdata for "' . $miner->{label} . '"...'); - } } foreach my $balance (@{$results->{balances}}) { if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && $balance->{id} !~ /$self->{option_results}->{filter_name}/) { - $self->{output}->output_add(long_msg => "skipping '" . $balance->{id} . "': no matching filter name.", debug => 1); + $self->{output}->output_add(long_msg => "skipping '" . $balance->{label} . "': no matching filter name.", debug => 1); next; } - my $old_balance = $self->{statefile_cache}->get(name => 'last_balance'); #get the id last_balance - - $datas->{$balance->{id}}->{last_balance} = $balance->{balance}; - - if ($old_balance) { - my $calculated_diff = ($balance->{balance} - $old_balance) / ($old_balance); - - $self->{balances}->{$balance->{id}}->{display} = $balance->{label}; - $self->{balances}->{$balance->{id}}->{balance} = $calculated_diff; - - $self->{output}->output_add(severity => 'OK', long_msg => 'Balance ' . $balance->{id} . ': Balance of "' . $balance->{label} . '" is ' . $balance->{balance} . ' ether' ); - } else { - $self->{output}->output_add(severity => 'OK', long_msg => 'Balance ' . $balance->{id} . ': Balance fluctuation of "' . $balance->{label} . '" is being calculated...'); - } + $self->{balances}->{lc($balance->{label})} = { display => lc($balance->{label}), + balance => $balance->{balance} }; } From 14b3b5561c32bb15fd12682709d1de3d2db6b3e3 Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Tue, 12 May 2020 20:26:06 +0000 Subject: [PATCH 021/283] update frequency counters --- blockchain/parity/ethpoller/mode/stats.pm | 67 ++++++++------------ blockchain/parity/ethpoller/mode/tracking.pm | 11 +++- 2 files changed, 33 insertions(+), 45 deletions(-) diff --git a/blockchain/parity/ethpoller/mode/stats.pm b/blockchain/parity/ethpoller/mode/stats.pm index e0cf28b7b..a0c7f9687 100644 --- a/blockchain/parity/ethpoller/mode/stats.pm +++ b/blockchain/parity/ethpoller/mode/stats.pm @@ -36,22 +36,26 @@ sub set_counters { ]; $self->{maps_counters}->{block} = [ - { label => 'block_freq', nlabel => 'parity.stats.block.frequency', set => { - key_values => [ { name => 'block_freq' } ], - output_template => "Block frequency: %d (block/min)", + { label => 'block_frequency', nlabel => 'parity.stats.block.persecond', set => { + key_values => [ { name => 'block_count', diff => 1 }, { name => 'display' } ], + per_second => 1, + output_template => "Block frequency: %.2f (block/s)", perfdatas => [ - { label => 'block_freq', value => 'block_freq_absolute', template => '%d', min => 0 } + { label => 'block', value => 'block_count_per_second', template => ' %.2f', + label_extra_instance => 1, instance_use => 'display_absolute' } ], } } ]; $self->{maps_counters}->{transaction} = [ - { label => 'transaction_freq', nlabel => 'parity.stats.transaction.frequency', set => { - key_values => [ { name => 'transaction_freq' } ], - output_template => "Transaction frequency: %d (tx/min)", + { label => 'transaction_frequency', nlabel => 'parity.stats.transaction.persecond', set => { + key_values => [ { name => 'transaction_count', diff => 1 } ], + per_second => 1, + output_template => "Transaction frequency: %.2f (tx/s)", perfdatas => [ - { label => 'transaction_freq', value => 'transaction_freq_absolute', template => '%d', min => 0 } + { label => 'transaction', value => 'transaction_count_per_second', template => '%.2f', + label_extra_instance => 1, instance_use => 'display_absolute' } ], } } @@ -96,46 +100,25 @@ sub manage_selection { my $result = $options{custom}->request_api(url_path => '/stats'); - my $old_block_timestamp = $self->{statefile_cache}->get(name => 'last_block_timestamp'); - my $old_block_count = $self->{statefile_cache}->get(name => 'last_block_count'); + $self->{block} = { block_count => $result->{block}->{count} }; - my $old_tx_timestamp = $self->{statefile_cache}->get(name => 'last_tx_timestamp'); - my $old_tx_count = $self->{statefile_cache}->get(name => 'last_tx_count'); + $self->{transaction} = { transaction_count => $result->{transaction}->{count} }; - my $datas = {}; - $datas->{last_block_timestamp} = time(); - $datas->{last_block_count} = $result->{block}->{count}; + my $block_timestamp = $result->{block}->{timestamp} == 0 ? '' : localtime($result->{block}->{timestamp}); + $self->{output}->output_add(severity => 'OK', long_msg => 'Last block (#' . $result->{block}->{count} . ') was at ' . $block_timestamp); - $datas->{last_tx_timestamp} = time(); - $datas->{last_tx_count} = $result->{block}->{count}; - - use Data::Dumper; - print Dumper($old_tx_timestamp); - - my $res_timestamp = 0; - - if ($old_block_count && $old_block_timestamp) { - $res_timestamp = $result->{block}->{timestamp} == 0 ? '' : $result->{block}->{timestamp}; - my $calculated_block_freq = ($result->{block}->{count} - $old_block_count) / (time() - $old_block_timestamp); - $self->{block} = { block_freq => $calculated_block_freq }; - $self->{output}->output_add(severity => 'OK', long_msg => 'Last block (#' . $result->{block}->{count} . ') was at ' . $res_timestamp); + if ($result->{transaction}->{count} > 0) { + my $tx_timestamp = $result->{transaction}->{timestamp} == 0 ? '' : localtime($result->{transaction}->{timestamp}); + $self->{output}->output_add(severity => 'OK', long_msg => 'Last transaction (#' . $result->{transaction}->{count} . ') was at ' . $tx_timestamp); } else { - $self->{output}->output_add(severity => 'OK', long_msg => 'Last block (#' . $result->{block}->{block} . ') was at ' . $res_timestamp . '. Block frequency is being calculated...'); + $self->{output}->output_add(severity => 'OK', long_msg => 'No transaction...'); } - - if ($old_tx_count && $old_tx_timestamp) { - $res_timestamp = $result->{transaction}->{timestamp} == 0 ? '' : $result->{transaction}->{timestamp}; - my $calculated_tx_freq = ($result->{transaction}->{count} - $old_tx_count) / (time() - $old_tx_timestamp); - $self->{transaction} = { transaction_freq => $calculated_tx_freq }; - $self->{output}->output_add(severity => 'OK', long_msg => 'Last transaction (#' . $result->{transaction}->{count} . ') was at ' . $res_timestamp); + + if ($result->{transaction}->{count} > 0) { + my $fork_timestamp = $result->{fork}->{timestamp} == 0 ? '' : localtime($result->{fork}->{timestamp}); + $self->{output}->output_add(severity => 'OK', long_msg => 'Last fork (#' . $result->{fork}->{count} . ') was at ' . $fork_timestamp); } else { - $self->{output}->output_add(severity => 'OK', long_msg => 'Last transaction (#' . $result->{transaction}->{count} . ') was at ' . $res_timestamp . '. Transaction frequency is being calculated...'); - } - - if ($result->{fork}->{count} > 0) { - $self->{output}->output_add(severity => 'OK', long_msg => 'Last fork (#' . $result->{fork}->{count} . ') was at ' . $res_timestamp); - } else { - $self->{output}->output_add(severity => 'OK', long_msg => 'No fork occurence'); + $self->{output}->output_add(severity => 'OK', long_msg => 'No fork occurence...'); } } diff --git a/blockchain/parity/ethpoller/mode/tracking.pm b/blockchain/parity/ethpoller/mode/tracking.pm index 250383c55..e41d6d726 100644 --- a/blockchain/parity/ethpoller/mode/tracking.pm +++ b/blockchain/parity/ethpoller/mode/tracking.pm @@ -51,9 +51,11 @@ sub set_counters { $self->{maps_counters}->{miners} = [ { label => 'mining_frequency', nlabel => 'parity.tracking.mined.block.persecond', set => { - key_values => [ { name => 'mining_frequency' } ], + key_values => [ { name => 'mining_count', diff => 1 }, { name => 'display' } ], + per_second => 1, output_template => " %.2f (blocks/s)", - perfdatas => [ instance_use => 'display_absolute', label_extra_instance => 1 ], + perfdatas => [ { label => 'miners', template => '%.2f', value => 'mining_count_per_second', + label_extra_instance => 1, instance_use => 'display_absolute' } ], } } ]; @@ -130,10 +132,13 @@ sub manage_selection { foreach my $miner (@{$results->{miners}}) { if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && $miner->{id} !~ /$self->{option_results}->{filter_name}/) { - $self->{output}->output_add(long_msg => "skipping '" . $miner->{id} . "': no matching filter name.", debug => 1); + $self->{output}->output_add(long_msg => "skipping '" . $miner->{label} . "': no matching filter name.", debug => 1); next; } + $self->{miners}->{lc($miner->{label})} = { display => lc($miner->{label}), + mining_count => $miner->{count} }; + } foreach my $balance (@{$results->{balances}}) { From 5b2a8271b7e4ba5735aa7c5931a55fd3296f879a Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Wed, 13 May 2020 11:13:46 +0000 Subject: [PATCH 022/283] POC prct --- blockchain/parity/ethpoller/mode/prct.pm | 129 +++++++++++++++++++++++ blockchain/parity/ethpoller/plugin.pm | 3 +- 2 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 blockchain/parity/ethpoller/mode/prct.pm diff --git a/blockchain/parity/ethpoller/mode/prct.pm b/blockchain/parity/ethpoller/mode/prct.pm new file mode 100644 index 000000000..633c13b35 --- /dev/null +++ b/blockchain/parity/ethpoller/mode/prct.pm @@ -0,0 +1,129 @@ +# +# Copyright 2020 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 blockchain::parity::ethpoller::mode::prct; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use bigint; +use Digest::MD5 qw(md5_hex); + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'balances', cb_prefix_output => 'prefix_output_balances', type => 1, message_multiple => 'Balances metrics are ok' } + ]; + + $self->{maps_counters}->{balances} = [ + { label => 'balance-fluctuation-prct', nlabel => 'parity.tracking.balances.variation.persecond', display_ok => 0, set => { + key_values => [], + manual_keys => 1, + closure_custom_calc => $self->can('custom_loss_calc'), + closure_custom_output => $self->can('custom_loss_output'), + threshold_use => 'balance_fluctuation', + perfdatas => [ + { value => 'balance_fluctuation', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'display' }, + ], + } + } + ]; + +} + +sub custom_loss_output { + my ($self, %options) = @_; + + # use Data::Dumper; + # print Dumper('$total_balance'); + return sprintf( + "balance variation: %.2f%% ", + $self->{result_values}->{balance_fluctuation} + ); +} + +sub custom_loss_calc { + my ($self, %options) = @_; + + my $new_balance = $options{new_datas}->{$_}; + my $old_balance = $options{old_datas}->{$_}; + + # use Data::Dumper; + # print Dumper($total_balance); + + $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; + $self->{result_values}->{balance_fluctuation} = 0; + if ($old_balance > 0) { + $self->{result_values}->{balance_fluctuation} = ($new_balance - $old_balance) / $old_balance; + } + + +} + +sub prefix_output_balances { + my ($self, %options) = @_; + + return "Balance '" . $options{instance_value}->{display} . "' "; +} + +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 => { + "filter-name:s" => { name => 'filter_name' }, + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + $self->{cache_name} = "parity_ethpoller_" . $self->{mode} . '_' . (defined($self->{option_results}->{hostname}) ? $self->{option_results}->{hostname} : 'me') . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); + + my $result = $options{custom}->request_api(url_path => '/tracking'); + use Data::Dumper; + # print Dumper($result); + + foreach my $balance (@{$result->{balances}}) { + # print Dumper($balance); + $self->{balances}->{$balance->{label}} = { display => $balance->{label} }; + $self->{balances}->{$balance->{label}}->{'balance_fluctuation'} = $balance->{balance}; + } + +} + + + +1; + +__END__ + +=head1 MODE + +Check Parity eth-poller for events, miners and balances tracking + +=cut diff --git a/blockchain/parity/ethpoller/plugin.pm b/blockchain/parity/ethpoller/plugin.pm index 48e08df5c..d28ab211d 100644 --- a/blockchain/parity/ethpoller/plugin.pm +++ b/blockchain/parity/ethpoller/plugin.pm @@ -35,7 +35,8 @@ sub new { # 'fork' => 'blockchain::parity::ethpoller::mode::fork', 'stats' => 'blockchain::parity::ethpoller::mode::stats', 'disk' => 'blockchain::parity::ethpoller::mode::disk', - 'tracking' => 'blockchain::parity::ethpoller::mode::tracking' + 'tracking' => 'blockchain::parity::ethpoller::mode::tracking', + 'prct' => 'blockchain::parity::ethpoller::mode::prct' ); $self->{custom_modes}{api} = 'blockchain::parity::ethpoller::custom::api'; return $self; From aa49fa70fa2cf9d6bc07aaabb4f91ce238c42934 Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Thu, 14 May 2020 05:40:48 +0000 Subject: [PATCH 023/283] prct improvments --- blockchain/parity/ethpoller/mode/prct.pm | 48 +++++++++++++++++------- 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/blockchain/parity/ethpoller/mode/prct.pm b/blockchain/parity/ethpoller/mode/prct.pm index 633c13b35..205feff6a 100644 --- a/blockchain/parity/ethpoller/mode/prct.pm +++ b/blockchain/parity/ethpoller/mode/prct.pm @@ -35,42 +35,62 @@ sub set_counters { ]; $self->{maps_counters}->{balances} = [ - { label => 'balance-fluctuation-prct', nlabel => 'parity.tracking.balances.variation.persecond', display_ok => 0, set => { + { label => 'balance-fluctuation-prct', nlabel => 'parity.tracking.balances.fluctuation', display_ok => 0, set => { key_values => [], manual_keys => 1, - closure_custom_calc => $self->can('custom_loss_calc'), - closure_custom_output => $self->can('custom_loss_output'), + closure_custom_calc => $self->can('custom_prct_calc'), + closure_custom_output => $self->can('custom_prct_output'), threshold_use => 'balance_fluctuation', perfdatas => [ - { value => 'balance_fluctuation', template => '%d', + { value => 'balance_fluctuation', template => '%.2f', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } + }, + { label => 'balance', nlabel => 'parity.tracking.balance', set => { + key_values => [ { name => 'balance' } ], + output_template => "%d (wei)", + perfdatas => [ + { label => 'balance', template => '%d', value => 'balance_absolute' } + ], + } } ]; } -sub custom_loss_output { +sub custom_prct_output { my ($self, %options) = @_; # use Data::Dumper; # print Dumper('$total_balance'); return sprintf( - "balance variation: %.2f%% ", + "balance variation: %.2f ", $self->{result_values}->{balance_fluctuation} ); } -sub custom_loss_calc { +sub custom_prct_calc { + use Data::Dumper; + my ($self, %options) = @_; - my $new_balance = $options{new_datas}->{$_}; - my $old_balance = $options{old_datas}->{$_}; + my ($old_balance, $new_balance) = (0, 0); + foreach (keys %{$options{new_datas}}) { + # print Dumper($self->{instance}); + # print Dumper($options{new_datas}); + # print Dumper($options{new_datas}->{$_}); + if (/\Q$self->{instance}\E_.*_balance/) { + # print Dumper($self->{instance}); + $new_balance = $options{new_datas}->{$_}; + $old_balance = $options{old_datas}->{$_}; + # print Dumper($old_balance); + # print Dumper($new_balance); + } + } + + - # use Data::Dumper; - # print Dumper($total_balance); - $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; $self->{result_values}->{balance_fluctuation} = 0; if ($old_balance > 0) { @@ -83,7 +103,7 @@ sub custom_loss_calc { sub prefix_output_balances { my ($self, %options) = @_; - return "Balance '" . $options{instance_value}->{display} . "' "; + return "Balance '" . $options{instance_value}->{display} . "': "; } sub new { @@ -111,7 +131,7 @@ sub manage_selection { foreach my $balance (@{$result->{balances}}) { # print Dumper($balance); $self->{balances}->{$balance->{label}} = { display => $balance->{label} }; - $self->{balances}->{$balance->{label}}->{'balance_fluctuation'} = $balance->{balance}; + $self->{balances}->{$balance->{label}}->{'balance'} = $balance->{balance}; } } From 45e6c515d3655a278a437043eab609b4f26612b9 Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Thu, 14 May 2020 14:06:40 +0000 Subject: [PATCH 024/283] typos in eth correction --- blockchain/parity/restapi/mode/eth.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/blockchain/parity/restapi/mode/eth.pm b/blockchain/parity/restapi/mode/eth.pm index 08c7a8461..edb5e571b 100644 --- a/blockchain/parity/restapi/mode/eth.pm +++ b/blockchain/parity/restapi/mode/eth.pm @@ -46,10 +46,10 @@ sub set_counters { { name => 'sync', cb_prefix_output => 'prefix_module_output', type => 0 }, ]; - $self->{maps_counters}->{gas} = [ + $self->{maps_counters}->{sync} = [ { label => 'sync_status', nlabel => 'parity.eth.sync.status', set => { key_values => [ { name => 'sync_status' } ], - output_template => "The gas price is: %d %% ", + output_template => "Syncing: %d %% ", perfdatas => [ { label => 'sync_status', value => 'sync_status_absolute', template => '%d', min => 0 } ], @@ -213,8 +213,8 @@ sub manage_selection { $self->{sync} = { sync_status => $res_sync }; $self->{gas} = { gas_price => $gas_price, - gas_used => hex(@{$result}[5]->{result}->{gasLimit}), - gas_limit => hex(@{$result}[5]->{result}->{gasUsed}) }; + gas_used => hex(@{$result}[5]->{result}->{gasUsed}), + gas_limit => hex(@{$result}[5]->{result}->{gasLimit}) }; my $calculated_block_usage = hex(@{$result}[5]->{result}->{gasUsed}) / hex(@{$result}[5]->{result}->{gasLimit}); $self->{block} = { block_size => hex(@{$result}[5]->{result}->{size}), From 8562f117d1347aa9a520b4834616ba09b2357aa9 Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Thu, 14 May 2020 16:06:15 +0000 Subject: [PATCH 025/283] stats typos correction --- blockchain/parity/ethpoller/mode/stats.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blockchain/parity/ethpoller/mode/stats.pm b/blockchain/parity/ethpoller/mode/stats.pm index a0c7f9687..3431c9839 100644 --- a/blockchain/parity/ethpoller/mode/stats.pm +++ b/blockchain/parity/ethpoller/mode/stats.pm @@ -37,7 +37,7 @@ sub set_counters { $self->{maps_counters}->{block} = [ { label => 'block_frequency', nlabel => 'parity.stats.block.persecond', set => { - key_values => [ { name => 'block_count', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'block_count', diff => 1 } ], per_second => 1, output_template => "Block frequency: %.2f (block/s)", perfdatas => [ From 2494262a718249ef2ab4bd5668af44dca91cdb18 Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Mon, 18 May 2020 21:25:03 +0000 Subject: [PATCH 026/283] typos correction --- blockchain/parity/ethpoller/mode/disk.pm | 2 +- blockchain/parity/ethpoller/mode/stats.pm | 6 ++-- blockchain/parity/ethpoller/mode/tracking.pm | 32 ++++++++++---------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/blockchain/parity/ethpoller/mode/disk.pm b/blockchain/parity/ethpoller/mode/disk.pm index 586d41da9..cd06b13ba 100644 --- a/blockchain/parity/ethpoller/mode/disk.pm +++ b/blockchain/parity/ethpoller/mode/disk.pm @@ -43,7 +43,7 @@ sub set_counters { ], } }, - { label => 'disk_available', nlabel => 'eth.poller.disk.free', set => { + { label => 'disk_available', nlabel => 'eth.poller.disk.available', set => { key_values => [ { name => 'disk_available' } ], output_template => "Disk available: %d ", perfdatas => [ diff --git a/blockchain/parity/ethpoller/mode/stats.pm b/blockchain/parity/ethpoller/mode/stats.pm index 3431c9839..72fe40df8 100644 --- a/blockchain/parity/ethpoller/mode/stats.pm +++ b/blockchain/parity/ethpoller/mode/stats.pm @@ -105,18 +105,18 @@ sub manage_selection { $self->{transaction} = { transaction_count => $result->{transaction}->{count} }; my $block_timestamp = $result->{block}->{timestamp} == 0 ? '' : localtime($result->{block}->{timestamp}); - $self->{output}->output_add(severity => 'OK', long_msg => 'Last block (#' . $result->{block}->{count} . ') was at ' . $block_timestamp); + $self->{output}->output_add(severity => 'OK', long_msg => 'Last block (#' . $result->{block}->{count} . ') was on ' . $block_timestamp); if ($result->{transaction}->{count} > 0) { my $tx_timestamp = $result->{transaction}->{timestamp} == 0 ? '' : localtime($result->{transaction}->{timestamp}); - $self->{output}->output_add(severity => 'OK', long_msg => 'Last transaction (#' . $result->{transaction}->{count} . ') was at ' . $tx_timestamp); + $self->{output}->output_add(severity => 'OK', long_msg => 'Last transaction (#' . $result->{transaction}->{count} . ') was on ' . $tx_timestamp); } else { $self->{output}->output_add(severity => 'OK', long_msg => 'No transaction...'); } if ($result->{transaction}->{count} > 0) { my $fork_timestamp = $result->{fork}->{timestamp} == 0 ? '' : localtime($result->{fork}->{timestamp}); - $self->{output}->output_add(severity => 'OK', long_msg => 'Last fork (#' . $result->{fork}->{count} . ') was at ' . $fork_timestamp); + $self->{output}->output_add(severity => 'OK', long_msg => 'Last fork (#' . $result->{fork}->{count} . ') was on ' . $fork_timestamp); } else { $self->{output}->output_add(severity => 'OK', long_msg => 'No fork occurence...'); } diff --git a/blockchain/parity/ethpoller/mode/tracking.pm b/blockchain/parity/ethpoller/mode/tracking.pm index e41d6d726..4badb37de 100644 --- a/blockchain/parity/ethpoller/mode/tracking.pm +++ b/blockchain/parity/ethpoller/mode/tracking.pm @@ -32,36 +32,36 @@ sub set_counters { $self->{maps_counters_type} = [ { name => 'events', cb_prefix_output => 'prefix_output_events', type => 1, message_multiple => 'Events metrics are ok' }, - { name => 'miners', cb_prefix_output => 'prefix_output_miners', type => 1, message_multiple => 'Miners metrics are ok' }, - { name => 'balances', cb_prefix_output => 'prefix_output_balances', type => 1, message_multiple => 'Balances metrics are ok' } + { name => 'mining', cb_prefix_output => 'prefix_output_mining', type => 1, message_multiple => 'Mining metrics are ok' }, + { name => 'balance', cb_prefix_output => 'prefix_output_balance', type => 1, message_multiple => 'Balances metrics are ok' } ]; $self->{maps_counters}->{events} = [ - { label => 'event_frequency', nlabel => 'parity.tracking.event.persecond', set => { - key_values => [ { name => 'event_count', diff => 1 }, { name => 'display' } ], + { label => 'events_frequency', nlabel => 'parity.tracking.events.persecond', set => { + key_values => [ { name => 'events_count', diff => 1 }, { name => 'display' } ], per_second => 1, output_template => " %.2f (events/s)", perfdatas => [ - { label => 'events', template => '%.2f', value => 'event_count_per_second', + { label => 'events', template => '%.2f', value => 'events_count_per_second', label_extra_instance => 1, instance_use => 'display_absolute' } ], } } ]; - $self->{maps_counters}->{miners} = [ + $self->{maps_counters}->{mining} = [ { label => 'mining_frequency', nlabel => 'parity.tracking.mined.block.persecond', set => { key_values => [ { name => 'mining_count', diff => 1 }, { name => 'display' } ], per_second => 1, output_template => " %.2f (blocks/s)", - perfdatas => [ { label => 'miners', template => '%.2f', value => 'mining_count_per_second', + perfdatas => [ { label => 'mining', template => '%.2f', value => 'mining_count_per_second', label_extra_instance => 1, instance_use => 'display_absolute' } ], } } ]; - $self->{maps_counters}->{balances} = [ - { label => 'balance_fluctuation', nlabel => 'parity.tracking.balances.variation.persecond', set => { + $self->{maps_counters}->{balance} = [ + { label => 'balance_fluctuation', nlabel => 'parity.tracking.balance.variation.persecond', set => { key_values => [ { name => 'balance', diff => 1 } ], per_second => 1, output_template => " variation: %.2f (diff/sec)", @@ -81,13 +81,13 @@ sub prefix_output_events { return "Event '" . $options{instance_value}->{display} . "' "; } -sub prefix_output_miners { +sub prefix_output_mining { my ($self, %options) = @_; return "Miner '" . $options{instance_value}->{display} . "' ";; } -sub prefix_output_balances { +sub prefix_output_balance { my ($self, %options) = @_; return "Balance '" . $options{instance_value}->{display} . "' "; @@ -114,8 +114,8 @@ sub manage_selection { my $results = $options{custom}->request_api(url_path => '/tracking'); $self->{events} = {}; - $self->{miners} = {}; - $self->{balances} = {}; + $self->{mining} = {}; + $self->{balance} = {}; foreach my $event (@{$results->{events}}) { if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && @@ -125,7 +125,7 @@ sub manage_selection { } $self->{events}->{lc($event->{label})} = { display => lc($event->{label}), - event_count => $event->{count} }; + events_count => $event->{count} }; } @@ -136,7 +136,7 @@ sub manage_selection { next; } - $self->{miners}->{lc($miner->{label})} = { display => lc($miner->{label}), + $self->{mining}->{lc($miner->{label})} = { display => lc($miner->{label}), mining_count => $miner->{count} }; } @@ -148,7 +148,7 @@ sub manage_selection { next; } - $self->{balances}->{lc($balance->{label})} = { display => lc($balance->{label}), + $self->{balance}->{lc($balance->{label})} = { display => lc($balance->{label}), balance => $balance->{balance} }; } From 9c2e9c90194730810a987fa1e6c9478429a6e925 Mon Sep 17 00:00:00 2001 From: Sims24 Date: Tue, 24 Mar 2020 14:22:30 +0100 Subject: [PATCH 027/283] enh(plugin)Palo-Alto vsys close #1849 --- network/paloalto/snmp/mode/vsyssessions.pm | 203 +++++++++++++++++++++ network/paloalto/snmp/plugin.pm | 1 + 2 files changed, 204 insertions(+) create mode 100644 network/paloalto/snmp/mode/vsyssessions.pm diff --git a/network/paloalto/snmp/mode/vsyssessions.pm b/network/paloalto/snmp/mode/vsyssessions.pm new file mode 100644 index 000000000..0a9040321 --- /dev/null +++ b/network/paloalto/snmp/mode/vsyssessions.pm @@ -0,0 +1,203 @@ +# +# Copyright 2020 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 network::paloalto::snmp::mode::vsyssessions; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'vsys', type => 1, cb_prefix_output => 'prefix_vsys_output', message_multiple => 'Vsys Sessions metrics are OK' }, + ]; + $self->{maps_counters}->{vsys} = [ + { label => 'active', set => { + key_values => [ { name => 'panVsysActiveSessions' }, { name => 'panVsysMaxSessions' }, { name => 'display' } ], + closure_custom_calc => $self->can('custom_active_calc'), + closure_custom_output => $self->can('custom_active_output'), + closure_custom_perfdata => $self->can('custom_active_perfdata'), + closure_custom_threshold_check => $self->can('custom_active_threshold'), + + } + }, + { label => 'active-tcp', nlabel => 'vsys.sessions.active.tcp.count', set => { + key_values => [ { name => 'panVsysActiveTcpCps' }, { name => 'display' } ], + output_template => 'Active TCP : %s', + perfdatas => [ + { label => 'active_tcp', value => 'panVsysActiveTcpCps_absolute', template => '%s', + label_extra_instance => 1, instance_use => 'display_absolute', min => 0 }, + ], + } + }, + { label => 'active-udp', nlabel => 'vsys.sessions.active.udp.count', set => { + key_values => [ { name => 'panVsysActiveUdpCps' }, { name => 'display' } ], + output_template => 'Active UDP : %s', + perfdatas => [ + { label => 'active_udp', value => 'panVsysActiveUdpCps_absolute', template => '%s', + label_extra_instance => 1, instance_use => 'display_absolute', min => 0 }, + ], + } + }, + { label => 'active-other', nlabel => 'vsys.sessions.active.other.count', set => { + key_values => [ { name => 'panVsysActiveOtherIpCps' }, { name => 'display' } ], + output_template => 'Other : %s', + perfdatas => [ + { label => 'active_other', value => 'panVsysActiveOtherIpCps_absolute', template => '%s', + label_extra_instance => 1, instance_use => 'display_absolute', min => 0 }, + ], + } + }, + ]; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, force_new_perfdata => 1, %options); + bless $self, $class; + + $options{options}->add_options(arguments => { + }); + + return $self; +} + +sub prefix_vsys_output { + my ($self, %options) = @_; + + return "Vsys '" . $options{instance_value}->{display} . "' "; + +} + +sub custom_active_perfdata { + my ($self, %options) = @_; + + my $label = 'active'; + my %total_options = (); + if ($self->{result_values}->{panVsysMaxSessions} != 0) { + $total_options{total} = $self->{result_values}->{panVsysMaxSessions}; + $total_options{cast_int} = 1; + } + + $self->{output}->perfdata_add(label => $self->{result_values}->{display} . "#active.sessions.count", + value => $self->{result_values}->{panVsysActiveSessions}, + warning => defined($total_options{total}) ? + $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options) : undef, + critical => defined($total_options{total}) ? + $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options) : undef, + min => 0, + max => $self->{result_values}->{panVsysMaxSessions}); +} + +sub custom_active_threshold { + my ($self, %options) = @_; + + my ($exit, $threshold_value) = ('ok'); + if ($self->{result_values}->{panVsysMaxSessions} != 0) { + $threshold_value = $self->{result_values}->{active_prct}; + } + $exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => + [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-'. $self->{label}, exit_litteral => 'warning' } ]) if (defined($threshold_value)); + return $exit; +} + +sub custom_active_output { + my ($self, %options) = @_; + + my $msg = sprintf("Active : %s (%s)", + $self->{result_values}->{panVsysActiveSessions}, + $self->{result_values}->{panVsysMaxSessions} != 0 ? $self->{result_values}->{active_prct} . " %" : + '-'); + return $msg; +} + +sub custom_active_calc { + my ($self, %options) = @_; + + $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; + $self->{result_values}->{panVsysActiveSessions} = $options{new_datas}->{$self->{instance} . '_panVsysActiveSessions'}; + $self->{result_values}->{panVsysMaxSessions} = $options{new_datas}->{$self->{instance} . '_panVsysMaxSessions'}; + $self->{result_values}->{active_prct} = 0; + if ($self->{result_values}->{panVsysMaxSessions} != 0) { + $self->{result_values}->{active_prct} = $self->{result_values}->{panVsysActiveSessions} * 100 / $self->{result_values}->{panVsysMaxSessions}; + } + return 0; +} + +my $mapping = { + panVsysName => { oid => '.1.3.6.1.4.1.25461.2.1.2.3.9.1.2' }, + panVsysActiveSessions => { oid => '.1.3.6.1.4.1.25461.2.1.2.3.9.1.4' }, + panVsysMaxSessions => { oid => '.1.3.6.1.4.1.25461.2.1.2.3.9.1.5' }, + panVsysActiveTcpCps => { oid => '.1.3.6.1.4.1.25461.2.1.2.3.9.1.6' }, + panVsysActiveUdpCps => { oid => '.1.3.6.1.4.1.25461.2.1.2.3.9.1.7' }, + panVsysActiveOtherIpCps => { oid => '.1.3.6.1.4.1.25461.2.1.2.3.9.1.8' }, +}; + +sub manage_selection { + my ($self, %options) = @_; + + my $oid_panVsysEntry = '.1.3.6.1.4.1.25461.2.1.2.3.9.1'; + $self->{results} = $options{snmp}->get_table(oid => $oid_panVsysEntry, + nothing_quit => 1); + + foreach my $oid (keys %{$self->{results}}) { + next if $oid !~ /^$mapping->{panVsysName}->{oid}\.(.*)$/; + my $instance = $1; + + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => $instance); + + $self->{vsys}->{$result->{panVsysName}} = { + display => $result->{panVsysName}, + panVsysMaxSessions => defined($result->{panVsysMaxSessions}) ? $result->{panVsysMaxSessions} : 0, + panVsysActiveSessions => $result->{panVsysActiveSessions}, + panVsysActiveTcpCps => $result->{panVsysActiveTcpCps}, + panVsysActiveUdpCps => $result->{panVsysActiveUdpCps}, + panVsysActiveOtherIpCps => $result->{panVsysActiveOtherIpCps} + }; + + } +} + +1; + +__END__ + +=head1 MODE + +Check sessions per Vsys + +=over 8 + +=item B<--warning-*> + +Threshold warning. +Can be: 'active' (%), 'active-tcp', 'active-udp', 'active-other' + +=item B<--critical-*> + +Threshold critical. +Can be: 'active' (%), 'active-tcp', 'active-udp', 'active-other' + +=back + +=cut diff --git a/network/paloalto/snmp/plugin.pm b/network/paloalto/snmp/plugin.pm index 41509f404..4b4e476a0 100644 --- a/network/paloalto/snmp/plugin.pm +++ b/network/paloalto/snmp/plugin.pm @@ -40,6 +40,7 @@ sub new { 'memory' => 'network::paloalto::snmp::mode::memory', 'panorama' => 'network::paloalto::snmp::mode::panorama', 'sessions' => 'network::paloalto::snmp::mode::sessions', + 'vsys-sessions' => 'network::paloalto::snmp::mode::vsyssessions', ); return $self; From 3fb175fa91fec546cf07b38c461776f7f287c42e Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 25 Mar 2020 09:17:57 +0100 Subject: [PATCH 028/283] add cache for fortigate policy --- .../fortinet/fortigate/snmp/mode/vdomusage.pm | 47 ++++++++++++------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/centreon/common/fortinet/fortigate/snmp/mode/vdomusage.pm b/centreon/common/fortinet/fortigate/snmp/mode/vdomusage.pm index e4d596b99..c2842db05 100644 --- a/centreon/common/fortinet/fortigate/snmp/mode/vdomusage.pm +++ b/centreon/common/fortinet/fortigate/snmp/mode/vdomusage.pm @@ -115,7 +115,7 @@ sub set_counters { closure_custom_output => $self->can('custom_license_output'), perfdatas => [ { value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute' } - ], + ] } }, { label => 'license-free', nlabel => 'virtualdomains.license.free.count', display_ok => 0, set => { @@ -123,7 +123,7 @@ sub set_counters { closure_custom_output => $self->can('custom_license_output'), perfdatas => [ { value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute' } - ], + ] } }, { label => 'license-usage-prct', nlabel => 'virtualdomains.license.usage.percentage', display_ok => 0, set => { @@ -131,7 +131,7 @@ sub set_counters { closure_custom_output => $self->can('custom_license_output'), perfdatas => [ { value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, unit => '%' } - ], + ] } } ]; @@ -143,7 +143,7 @@ sub set_counters { perfdatas => [ { value => 'cpu_absolute', template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' } - ], + ] } } ]; @@ -167,7 +167,7 @@ sub set_counters { perfdatas => [ { value => 'active_policies_absolute', template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, - ], + ] } } ]; @@ -179,7 +179,7 @@ sub set_counters { perfdatas => [ { value => 'active_sessions_absolute', template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, - ], + ] } }, { label => 'session-rate', nlabel => 'virtualdomain.sessions.rate.persecond', set => { @@ -188,7 +188,7 @@ sub set_counters { perfdatas => [ { value => 'session_rate_absolute', template => '%d', min => 0, unit => '/s', label_extra_instance => 1, instance_use => 'display_absolute' } - ], + ] } } ]; @@ -215,7 +215,7 @@ sub set_counters { perfdatas => [ { value => 'traffic_per_second', template => '%s', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, - ], + ] } }, { label => 'traffic-out', nlabel => 'virtualdomain.traffic.out.bitspersecond', set => { @@ -228,7 +228,7 @@ sub set_counters { perfdatas => [ { value => 'traffic_per_second', template => '%s', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, - ], + ] } } ]; @@ -240,13 +240,15 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - 'filter-vdomain:s' => { name => 'filter_vdomain' }, - 'add-traffic' => { name => 'add_traffic' }, - 'add-policy' => { name => 'add_policy' }, - 'warning-status:s' => { name => 'warning_status', default => '' }, - 'critical-status:s' => { name => 'critical_status', default => '' } + 'filter-vdomain:s' => { name => 'filter_vdomain' }, + 'add-traffic' => { name => 'add_traffic' }, + 'add-policy' => { name => 'add_policy' }, + 'policy-cache-time:s' => { name => 'policy_cache_time', default => 60 }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '' } }); + $self->{cache_policy} = centreon::plugins::statefile->new(%options); return $self; } @@ -255,6 +257,7 @@ sub check_options { $self->SUPER::check_options(%options); $self->change_macros(macros => ['warning_status', 'critical_status']); + $self->{cache_policy}->check_options(%options) if (defined($self->{option_results}->{add_policy})); } my $map_opmode = { 1 => 'nat', 2 => 'transparent' }; @@ -262,7 +265,7 @@ my $map_ha = { 1 => 'master', 2 => 'backup', 3 => 'standalone' }; my $mapping = { fgVdNumber => { oid => '.1.3.6.1.4.1.12356.101.3.1.1' }, - fgVdMaxVdoms => { oid => '.1.3.6.1.4.1.12356.101.3.1.2' }, + fgVdMaxVdoms => { oid => '.1.3.6.1.4.1.12356.101.3.1.2' } }; my $mapping_vdom = { fgVdEntOpMode => { oid => '.1.3.6.1.4.1.12356.101.3.2.1.1.3', map => $map_opmode }, @@ -320,7 +323,15 @@ sub add_policy { my $oid_fgFwPolID = '.1.3.6.1.4.1.12356.101.5.1.2.1.1.1'; - my $snmp_result = $options{snmp}->get_table(oid => $oid_fgFwPolID); + my $has_cache_file = $self->{cache_policy}->read(statefile => 'fortinet_fortigate_policy_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port()); + my $timestamp_cache = $self->{cache_policy}->get(name => 'last_timestamp'); + my $snmp_result = $self->{cache_policy}->get(name => 'snmp_result'); + if ($has_cache_file == 0 || !defined($timestamp_cache) || !defined($snmp_result) || + ((time() - $timestamp_cache) > (($self->{option_results}->{policy_cache_time}) * 60))) { + $snmp_result = $options{snmp}->get_table(oid => $oid_fgFwPolID); + $self->{cache_policy}->write(data => { last_timestamp => time(), snmp_result => $snmp_result }); + } + foreach (keys %$snmp_result) { /^$oid_fgFwPolID\.(\d+)/; $self->{vdom}->{$1}->{vdom_policy}->{active_policies}++ @@ -421,6 +432,10 @@ Add traffic usage by virtual domain. Add number of policies by virtual domain. +=item B<--policy-cache-time> + +Time in minutes before reloading cache file (default: 60). + =item B<--warning-status> Set warning threshold for status (Default: ''). From 3d2fcca008aab0c0c87b7cdcf2fb9e8c96dd3d18 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 25 Mar 2020 16:04:23 +0100 Subject: [PATCH 029/283] wip: eltek enexus snmp --- .../devices/eltek/enexus/snmp/mode/alarms.pm | 175 ++++++++++ .../devices/eltek/enexus/snmp/mode/battery.pm | 317 ++++++++++++++++++ .../devices/eltek/enexus/snmp/mode/outputs.pm | 198 +++++++++++ hardware/devices/eltek/enexus/snmp/plugin.pm | 50 +++ 4 files changed, 740 insertions(+) create mode 100644 hardware/devices/eltek/enexus/snmp/mode/alarms.pm create mode 100644 hardware/devices/eltek/enexus/snmp/mode/battery.pm create mode 100644 hardware/devices/eltek/enexus/snmp/mode/outputs.pm create mode 100644 hardware/devices/eltek/enexus/snmp/plugin.pm diff --git a/hardware/devices/eltek/enexus/snmp/mode/alarms.pm b/hardware/devices/eltek/enexus/snmp/mode/alarms.pm new file mode 100644 index 000000000..dcb1c84a2 --- /dev/null +++ b/hardware/devices/eltek/enexus/snmp/mode/alarms.pm @@ -0,0 +1,175 @@ +# +# Copyright 2020 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 hardware::devices::eltek::enexus::snmp::mode::alarms; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); +use centreon::plugins::misc; + +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 => 'global', type => 0 }, + { name => 'alarm', type => 1, cb_prefix_output => 'prefix_alarm_output', message_multiple => 'All alarms are ok', skipped_code => { -10 => 1 } } + ]; + + $self->{maps_counters}->{global} = [ + { label => 'alarms-active', nlabel => 'alarms.active.count', display_ok => 0, set => { + key_values => [ { name => 'active' }, { name => 'total' } ], + output_template => 'current active alarms: %d', + perfdatas => [ + { value => 'active_absolute', template => '%d', min => 0, max => 'total_absolute' } + ] + } + } + ]; + + $self->{maps_counters}->{alarm} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'status' }, { name => 'name' } ], + closure_custom_calc => \&catalog_status_calc, + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold + } + } + ]; +} + +sub prefix_alarm_output { + my ($self, %options) = @_; + + return "Alarm '" . $options{instance_value}->{name} . "' "; +} + +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' }, + 'unknown-status:s' => { name => 'unknown_status', default => '' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '%{status} eq "alarm"' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->change_macros(macros => ['unknown_status', 'warning_status', 'critical_status']); +} + +my $map_status = { 0 => 'normal', 1 => 'alarm' }; + +my $mapping = { + alarmGroupStatus => { oid => '.1.3.6.1.4.1.12148.10.14.1.1.2', map => $map_status }, + alarmGroupDescription => { oid => '.1.3.6.1.4.1.12148.10.14.1.1.3' } +}; + +sub manage_selection { + my ($self, %options) = @_; + + my $oid_alarmGroupEntry = '.1.3.6.1.4.1.12148.10.14.1.1'; + my $snmp_result = $options{snmp}->get_table( + oid => $oid_alarmGroupEntry, + start => $mapping->{alarmGroupStatus}->{oid}, + nothing_quit => 1 + ); + + $self->{global} = { total => 0, active => 0 }; + $self->{alarm} = {}; + foreach my $oid (keys %$snmp_result) { + next if ($oid !~ /^$mapping->{alarmGroupStatus}->{oid}\.(.*)$/); + my $instance = $1; + + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance); + $result->{alarmGroupDescription} = centreon::plugins::misc::trim($result->{alarmGroupDescription}); + $result->{alarmGroupDescription} = $instance if ($result->{alarmGroupDescription} eq ''); + + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $result->{alarmGroupDescription} !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping alarm '" . $result->{alarmGroupDescription} . "'.", debug => 1); + next; + } + + $self->{alarm}->{$instance} = { + name => $result->{alarmGroupDescription}, + status => $result->{alarmGroupStatus} + }; + $self->{global}->{total}++; + $self->{global}->{active}++ if ($result->{alarmGroupStatus} eq 'alarm'); + } +} + +1; + +__END__ + +=head1 MODE + +Check alarms. + +=over 8 + +=item B<--filter-name> + +Filter name (can be a regexp). + +=item B<--unknown-status> + +Set unknown threshold for status (Default: ''). +Can used special variables like: %{state}, %{status}, %{lastOpError}, %{display} + +=item B<--warning-status> + +Set warning threshold for status (Default: ''). +Can used special variables like: %{name}, %{status} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{status} eq "alarm"). +Can used special variables like: %{name}, %{status} + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'alarms-active'. + +=back + +=cut diff --git a/hardware/devices/eltek/enexus/snmp/mode/battery.pm b/hardware/devices/eltek/enexus/snmp/mode/battery.pm new file mode 100644 index 000000000..29857b605 --- /dev/null +++ b/hardware/devices/eltek/enexus/snmp/mode/battery.pm @@ -0,0 +1,317 @@ +# +# Copyright 2020 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 hardware::devices::eltek::enexus::snmp::mode::battery; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); +use centreon::plugins::misc; + +sub custom_status_output { + my ($self, %options) = @_; + + return sprintf('status: %s', + $self->{result_values}->{status} + ); +} + +sub custom_temperature_output { + my ($self, %options) = @_; + + return sprintf('temperature: %s %s', + $self->{result_values}->{temperature_absolute}, + $self->{result_values}->{temperature_unit_absolute} + ); +} + +sub custom_temperature_perfdata { + my ($self, %options) = @_; + + $self->{output}->perfdata_add( + nlabel => 'battery.temperature.' . ($self->{result_values}->{temperature_unit_absolute} eq 'C' ? 'celsius' : 'fahrenheit'), + unit => $self->{result_values}->{temperature_unit_absolute}, + value => $self->{result_values}->{temperature_absolute}, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}), + ); +} + +sub custom_charge_remaining_output { + my ($self, %options) = @_; + + return sprintf('remaining capacity: %s %s', + $self->{result_values}->{charge_remaining_absolute}, + $self->{result_values}->{charge_remaining_unit_absolute} + ); +} + +sub custom_charge_remaining_perfdata { + my ($self, %options) = @_; + + $self->{output}->perfdata_add( + nlabel => 'battery.charge.remaining.' . ($self->{result_values}->{charge_remaining_unit_absolute} eq '%' ? '%' : 'amperehour'), + unit => $self->{result_values}->{charge_remaining_unit_absolute}, + value => $self->{result_values}->{charge_remaining_absolute}, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}), + min => 0, + max => $self->{result_values}->{charge_remaining_unit_absolute} eq '%' ? 100 : undef + ); +} + +sub custom_charge_time_output { + my ($self, %options) = @_; + + return sprintf( + 'remaining time: %s', + centreon::plugins::misc::change_seconds(value => $self->{result_values}->{charge_remaining_time_absolute}) + ); +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'battery', type => 0, cb_prefix_output => 'prefix_battery_output', skipped_code => { -10 => 1 } } + ]; + + $self->{maps_counters}->{battery} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'status' } ], + closure_custom_calc => \&catalog_status_calc, + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold + } + }, + { label => 'temperature', display_ok => 0, set => { + key_values => [ { name => 'temperature' }, { name => 'temperature_unit' } ], + closure_custom_output => $self->can('custom_temperature_output'), + closure_custom_perfdata => $self->can('custom_temperature_perfdata') + } + }, + { label => 'charge-remaining', set => { + key_values => [ { name => 'charge_remaining' }, { name => 'charge_remaining_unit' } ], + closure_custom_output => $self->can('custom_charge_remaining_output'), + closure_custom_perfdata => $self->can('custom_charge_remaining_perfdata') + } + }, + { label => 'charge-remaining-time', nlabel => 'battery.charge.remaining.time.seconds', set => { + key_values => [ { name => 'charge_remaining_time' } ], + closure_custom_output => $self->can('custom_charge_time_output'), + perfdatas => [ + { value => 'charge_remaining_time_absolute', template => '%s', min => 0, unit => 's' }, + ], + } + }, + { label => 'voltage', nlabel => 'battery.voltage.volt', display_ok => 0, set => { + key_values => [ { name => 'voltage' } ], + output_template => 'voltage: %.2f V', + perfdatas => [ + { value => 'voltage_absolute', template => '%.2f', unit => 'V' } + ] + } + }, + { label => 'current', nlabel => 'battery.current.ampere', display_ok => 0, set => { + key_values => [ { name => 'current' } ], + output_template => 'current: %.2f A', + perfdatas => [ + { value => 'current_absolute', template => '%.2f', min => 0, unit => 'A' } + ] + } + }, + ]; +} + +sub prefix_battery_output { + my ($self, %options) = @_; + + return "Battery "; +} + +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 => { + 'unknown-status:s' => { name => 'unknown_status', default => '' }, + 'warning-status:s' => { name => 'warning_status', default => '%{status} =~ /minor|warning/i' }, + 'critical-status:s' => { name => 'critical_status', default => '%{status} =~ /error|major|critical/i' } + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->change_macros(macros => [ + 'warning_status', 'critical_status', 'unknown_status', + ]); +} + +my $map_status = { + 0 => 'error', 1 => 'normal', 2 => 'minorAlarm', 3 => 'majorAlarm', + 4 => 'disabled', 5 => 'disconnected', 6 => 'notPresent', + 7 => 'minorAndMajor', 8 => 'majorLow', 9 => 'minorLow', + 10 => 'majorHigh', 11 => 'minorHigh', 12 => 'event', + 13 => 'valueVolt', 14 => 'valueAmp', 15 => 'valueTemp', + 16 => 'valueUnit', 17 => 'valuePerCent', 18 => 'critical', + 19 => 'warning' +}; +my $map_decimal_setting = { 0 => 'ampere', 1 => 'deciAmpere' }; +my $map_temp_setting = { 0 => 'celsius', 1 => 'fahrenheit' }; +my $map_capacity = { 0 => 'ah', 1 => 'percent' }; + +my $mapping = { + powerSystemCurrentDecimalSetting => { oid => '.1.3.6.1.4.1.12148.10.2.15', map => $map_decimal_setting }, + powerSystemTemperatureScale => { oid => '.1.3.6.1.4.1.12148.10.2.16', map => $map_temp_setting }, + powerSystemCapacityScale => { oid => '.1.3.6.1.4.1.12148.10.2.17', map => $map_capacity }, + batteryStatus => { oid => '.1.3.6.1.4.1.12148.10.10.1', map => $map_status }, + batteryVoltageValue => { oid => '.1.3.6.1.4.1.12148.10.10.5.5' }, + batteryVoltageMajorHighLevel => { oid => '.1.3.6.1.4.1.12148.10.10.5.6' }, + batteryVoltageMinorHighLevel => { oid => '.1.3.6.1.4.1.12148.10.10.5.7' }, # 0.01 for vdc + batteryVoltageMinorLowLevel => { oid => '.1.3.6.1.4.1.12148.10.10.5.8' }, + batteryVoltageMajorLowLevel => { oid => '.1.3.6.1.4.1.12148.10.10.5.9' }, + batteryCurrentsValue => { oid => '.1.3.6.1.4.1.12148.10.10.6.5' }, # A or dA + batteryCurrentsMajorHighLevel => { oid => '.1.3.6.1.4.1.12148.10.10.6.6' }, + batteryCurrentsMinorHighLevel => { oid => '.1.3.6.1.4.1.12148.10.10.6.7' }, + batteryCurrentsMinorLowLevel => { oid => '.1.3.6.1.4.1.12148.10.10.6.8' }, + batteryCurrentsMajorLowLevel => { oid => '.1.3.6.1.4.1.12148.10.10.6.9' }, + batteryTemperaturesValue => { oid => '.1.3.6.1.4.1.12148.10.10.7.5' }, # C or F + batteryTemperaturesMajorHighLevel => { oid => '.1.3.6.1.4.1.12148.10.10.7.6' }, + batteryTemperaturesMinorHighLevel => { oid => '.1.3.6.1.4.1.12148.10.10.7.7' }, + batteryTemperaturesMinorLowLevel => { oid => '.1.3.6.1.4.1.12148.10.10.7.8' }, + batteryTemperaturesMajorLowLevel => { oid => '.1.3.6.1.4.1.12148.10.10.7.9' }, + batteryRemainingCapacityValue => { oid => '.1.3.6.1.4.1.12148.10.10.9.5' }, # ah or % + batteryRemainingCapacityMinorLowLevel => { oid => '.1.3.6.1.4.1.12148.10.10.9.6' }, + batteryRemainingCapacityMajorLowLevel => { oid => '.1.3.6.1.4.1.12148.10.10.9.7' }, +}; + +sub threshold_eltek_configured { + my ($self, %options) = @_; + + if ((!defined($self->{option_results}->{'critical-' . $options{label}}) || $self->{option_results}->{'critical-' . $options{label}} eq '') && + (!defined($self->{option_results}->{'warning-' . $options{label}}) || $self->{option_results}->{'warning-' . $options{label}} eq '')) { + my ($crit, $warn) = ('', ''); + $crit = $options{low_crit} . ':' if (defined($options{low_crit}) && $options{low_crit} ne ''); + $crit .= $options{high_crit} if (defined($options{high_crit}) && $options{high_crit} ne ''); + $warn = $options{low_warn} . ':' if (defined($options{low_warn}) && $options{low_warn} ne ''); + $warn .= $options{high_warn} if (defined($options{high_warn}) && $options{high_warn} ne ''); + $self->{perfdata}->threshold_validate(label => 'critical-' . $options{label}, value => $crit); + $self->{perfdata}->threshold_validate(label => 'warning-' . $options{label}, value => $warn); + } +} + +sub manage_selection { + my ($self, %options) = @_; + + # we can calculate the time remaining if unit is ah (amperehour). + + my $oid_outputControlUnitOutputEntry = '.1.3.6.1.4.1.12148.10.12.2.1'; + my $snmp_result = $options{snmp}->get_leef( + oids => [ map($_->{oid} . '.0', values(%$mapping)) ], + nothing_quit => 1 + ); + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => '0'); + + my $scale_current = 1; + $scale_current = 0.1 if ($result->{powerSystemCurrentDecimalSetting} eq 'deciAmpere'); + $self->{battery} = { + status => $result->{batteryStatus}, + temperature => $result->{batteryTemperaturesValue}, + temperature_unit => $result->{powerSystemTemperatureScale} eq 'celsius' ? 'C' : 'F', + voltage => $result->{batteryVoltageValue} * 0.01, + current => $result->{batteryCurrentsValue} * $scale_current, + charge_remaining => $result->{batteryRemainingCapacityValue}, + charge_remaining_unit => $result->{powerSystemCapacityScale} + }; + if ($result->{powerSystemCapacityScale} eq 'ah' && $result->{batteryCurrentsValue} < 0) { + $self->{battery}->{charge_remaining_time} = + int($result->{batteryRemainingCapacityValue} * 3600 / $result->{batteryCurrentsValue} * $scale_current * -1); + } + + $self->threshold_eltek_configured( + label => 'temperature', + high_crit => $result->{batteryTemperaturesMajorHighLevel}, + low_crit => $result->{batteryTemperaturesMajorLowLevel}, + high_warn => $result->{batteryTemperaturesMinorHighLevel}, + low_warn => $result->{batteryTemperaturesMinorLowLevel} + ); + $self->threshold_eltek_configured( + label => 'battery-voltage-volt', + high_crit => $result->{batteryVoltageMajorHighLevel} * 0.01, + low_crit => $result->{batteryVoltageMajorLowLevel} * 0.01, + high_warn => $result->{batteryVoltageMinorHighLevel} * 0.01, + low_warn => $result->{batteryVoltageMinorLowLevel} * 0.01 + ); + $self->threshold_eltek_configured( + label => 'battery-current-ampere', + high_crit => $result->{batteryCurrentsMajorHighLevel} * $scale_current, + low_crit => $result->{batteryCurrentsMajorLowLevel} * $scale_current, + high_warn => $result->{batteryCurrentsMinorHighLevel} * $scale_current, + low_warn => $result->{batteryCurrentsMinorLowLevel} * $scale_current + ); + $self->threshold_eltek_configured( + label => 'charge-remaining', + low_crit => $result->{batteryRemainingCapacityMajorLowLevel}, + low_warn => $result->{batteryRemainingCapacityMinorLowLevel} + ); +} + +1; + +__END__ + +=head1 MODE + +Check battery. + +=over 8 + +=item B<--unknown-status> + +Set unknown threshold for status. +Can used special variables like: %{status} + +=item B<--warning-status> + +Set warning threshold for status (Default: '%{status} =~ /minor|warning/i'). +Can used special variables like: %{status} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{status} =~ /error|major|critical/i'). +Can used special variables like: %{status} + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'temperature', 'voltage', 'current', +'charge-remaining', 'charge-remaining-time'. + +=back + +=cut diff --git a/hardware/devices/eltek/enexus/snmp/mode/outputs.pm b/hardware/devices/eltek/enexus/snmp/mode/outputs.pm new file mode 100644 index 000000000..2630eb63b --- /dev/null +++ b/hardware/devices/eltek/enexus/snmp/mode/outputs.pm @@ -0,0 +1,198 @@ +# +# Copyright 2020 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 hardware::devices::eltek::enexus::snmp::mode::outputs; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); +use centreon::plugins::misc; + +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 => 'global', type => 0 }, + { name => 'cuo', type => 1, cb_prefix_output => 'prefix_cuo_output', message_multiple => 'All outputs for control units are ok', skipped_code => { -10 => 1 } } + ]; + + $self->{maps_counters}->{global} = [ + { label => 'outputs-disconnected', nlabel => 'outputs.disconnected.count', display_ok => 0, set => { + key_values => [ { name => 'disconnected' }, { name => 'total_contactors' } ], + output_template => 'current disconnected outputs: %d', + perfdatas => [ + { value => 'disconnected_absolute', template => '%d', min => 0, max => 'total_contactors_absolute' } + ] + } + }, + { label => 'outputs-notenergized', nlabel => 'outputs.notenergized.count', display_ok => 0, set => { + key_values => [ { name => 'notenergized' }, { name => 'total_relay' } ], + output_template => 'current not energized outputs: %d', + perfdatas => [ + { value => 'notenergized_absolute', template => '%d', min => 0, max => 'total_relay_absolute' } + ] + } + } + ]; + + $self->{maps_counters}->{cuo} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'status' }, { name => 'name' } ], + closure_custom_calc => \&catalog_status_calc, + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold + } + } + ]; +} + +sub prefix_cuo_output { + my ($self, %options) = @_; + + return "Control unit output '" . $options{instance_value}->{name} . "' "; +} + +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' }, + 'unknown-status:s' => { name => 'unknown_status', default => '' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '%{status} =~ /notenergized|disconnected/i' } + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->change_macros(macros => [ + 'warning_status', 'critical_status', 'unknown_status', + ]); +} + +my $map_status = { 0 => 'notenergized', 1 => 'energized', 2 => 'disconnected', 3 => 'connected' }; + +my $mapping = { + outputControlUnitOutputStatus => { oid => '.1.3.6.1.4.1.12148.10.12.2.1.2', map => $map_status }, + outputControlUnitOutputDescription => { oid => '.1.3.6.1.4.1.12148.10.12.2.1.3' } +}; + +sub manage_selection { + my ($self, %options) = @_; + + my $oid_outputControlUnitOutputEntry = '.1.3.6.1.4.1.12148.10.12.2.1'; + my $snmp_result = $options{snmp}->get_table( + oid => $oid_outputControlUnitOutputEntry, + start => $mapping->{outputControlUnitOutputStatus}->{oid}, + nothing_quit => 1 + ); + + $self->{global} = { total_relay => 0, total_contactors => 0, energized => 0, notenergized => 0, connected => 0, disconnected => 0 }; + $self->{cuo} = {}; + my $duplicated = {}; + foreach my $oid (keys %$snmp_result) { + next if ($oid !~ /^$mapping->{outputControlUnitOutputStatus}->{oid}\.(.*)$/); + my $instance = $1; + + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance); + my $name = centreon::plugins::misc::trim($result->{outputControlUnitOutputDescription}); + $name = $instance if ($name eq ''); + $name = $instance if (defined($duplicated->{$name})); + + 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 control unit output '" . $name . "'.", debug => 1); + next; + } + + if (defined($self->{cuo}->{$name})) { + $duplicated->{$name} = 1; + my $instance2 = $self->{cuo}->{$name}->{instance}; + $self->{cuo}->{$instance2} = $self->{cuo}->{$name}; + $self->{cuo}->{$instance2}->{name} = $instance2; + delete $self->{cuo}->{$name}; + $name = $instance; + } + + $self->{cuo}->{$name} = { + instance => $instance, + name => $name, + status => $result->{outputControlUnitOutputStatus} + }; + $self->{global}->{total_relay}++ if ($result->{outputControlUnitOutputStatus} =~ /energized/); + $self->{global}->{total_contactors}++ if ($result->{outputControlUnitOutputStatus} =~ /connected/); + $self->{global}->{$result->{outputControlUnitOutputStatus}}++; + } +} + +1; + +__END__ + +=head1 MODE + +Check outputs for control units. + +=over 8 + +=item B<--filter-name> + +Filter name (can be a regexp). + +=item B<--unknown-status> + +Set unknown threshold for status. +Can used special variables like: %{status}, %{name} + +=item B<--warning-status> + +Set warning threshold for status. +Can used special variables like: %{status}, %{name} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{status} =~ /notenergized|disconnected/i'). +Can used special variables like: %{status}, %{name} + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'current'. + +=back + +=cut diff --git a/hardware/devices/eltek/enexus/snmp/plugin.pm b/hardware/devices/eltek/enexus/snmp/plugin.pm new file mode 100644 index 000000000..297ae1605 --- /dev/null +++ b/hardware/devices/eltek/enexus/snmp/plugin.pm @@ -0,0 +1,50 @@ +# +# Copyright 2020 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 hardware::devices::eltek::enexus::snmp::plugin; + +use strict; +use warnings; +use base qw(centreon::plugins::script_snmp); + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '0.1'; + %{$self->{modes}} = ( + 'alarms' => 'hardware::devices::eltek::enexus::snmp::mode::alarms', + 'battery' => 'hardware::devices::eltek::enexus::snmp::mode::battery', + 'outputs' => 'hardware::devices::eltek::enexus::snmp::mode::outputs' + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Eltek eNexus in SNMP (SmartPack2 V2.x, SmartPack S V2.x and Compack V2.x). + +=cut From c5963d3dd4ca22c9774a8a5382db6d578d50999d Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 26 Mar 2020 10:18:59 +0100 Subject: [PATCH 030/283] mode load for eltek enexus --- .../devices/eltek/enexus/snmp/mode/battery.pm | 8 +- .../devices/eltek/enexus/snmp/mode/load.pm | 222 ++++++++++++++++++ hardware/devices/eltek/enexus/snmp/plugin.pm | 1 + 3 files changed, 226 insertions(+), 5 deletions(-) create mode 100644 hardware/devices/eltek/enexus/snmp/mode/load.pm diff --git a/hardware/devices/eltek/enexus/snmp/mode/battery.pm b/hardware/devices/eltek/enexus/snmp/mode/battery.pm index 29857b605..652603bde 100644 --- a/hardware/devices/eltek/enexus/snmp/mode/battery.pm +++ b/hardware/devices/eltek/enexus/snmp/mode/battery.pm @@ -139,14 +139,14 @@ sub set_counters { { value => 'current_absolute', template => '%.2f', min => 0, unit => 'A' } ] } - }, + } ]; } sub prefix_battery_output { my ($self, %options) = @_; - return "Battery "; + return 'Battery '; } sub new { @@ -228,9 +228,6 @@ sub threshold_eltek_configured { sub manage_selection { my ($self, %options) = @_; - # we can calculate the time remaining if unit is ah (amperehour). - - my $oid_outputControlUnitOutputEntry = '.1.3.6.1.4.1.12148.10.12.2.1'; my $snmp_result = $options{snmp}->get_leef( oids => [ map($_->{oid} . '.0', values(%$mapping)) ], nothing_quit => 1 @@ -248,6 +245,7 @@ sub manage_selection { charge_remaining => $result->{batteryRemainingCapacityValue}, charge_remaining_unit => $result->{powerSystemCapacityScale} }; + # we can calculate the time remaining if unit is ah (amperehour) and current battery is discharging (negative value) if ($result->{powerSystemCapacityScale} eq 'ah' && $result->{batteryCurrentsValue} < 0) { $self->{battery}->{charge_remaining_time} = int($result->{batteryRemainingCapacityValue} * 3600 / $result->{batteryCurrentsValue} * $scale_current * -1); diff --git a/hardware/devices/eltek/enexus/snmp/mode/load.pm b/hardware/devices/eltek/enexus/snmp/mode/load.pm new file mode 100644 index 000000000..5c80df04e --- /dev/null +++ b/hardware/devices/eltek/enexus/snmp/mode/load.pm @@ -0,0 +1,222 @@ +# +# Copyright 2020 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 hardware::devices::eltek::enexus::snmp::mode::load; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); +use Digest::MD5 qw(md5_hex); + +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 => 'load', type => 0, cb_prefix_output => 'prefix_load_output', skipped_code => { -10 => 1 } }, + { name => 'phase', type => 1, cb_prefix_output => 'prefix_phase_output', message_multiple => 'All phases are ok', skipped_code => { -10 => 1 } } + ]; + + $self->{maps_counters}->{load} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'status' } ], + closure_custom_calc => \&catalog_status_calc, + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold + } + }, + { label => 'current', nlabel => 'load.current.ampere', set => { + key_values => [ { name => 'current' } ], + output_template => 'current: %s A', + perfdatas => [ + { value => 'current_absolute', template => '%s', unit => 'A', min => 0 } + ] + } + }, + { label => 'energy-delivered', nlabel => 'load.energy.delivered.watt', display_ok => 0, set => { + key_values => [ { name => 'energy', diff => 1 } ], + output_template => 'accumulated energy delivered: %s W', + perfdatas => [ + { value => 'energy_absolute', template => '%s', unit => 'W', min => 0 } + ] + } + } + ]; + + $self->{maps_counters}->{phase} = [ + { label => 'voltage', nlabel => 'phase.voltage.volt', set => { + key_values => [ { name => 'voltage' } ], + output_template => 'voltage: %.2f V', + perfdatas => [ + { value => 'voltage_absolute', template => '%.2f', unit => 'V', label_extra_instance => 1 } + ] + } + } + ]; +} + +sub prefix_load_output { + my ($self, %options) = @_; + + return 'Load '; +} + +sub prefix_phase_output { + my ($self, %options) = @_; + + return "Phase '" . $options{instance_value}->{display} . "' "; +} + +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 => { + 'unknown-status:s' => { name => 'unknown_status', default => '' }, + 'warning-status:s' => { name => 'warning_status', default => '%{status} =~ /minor|warning/i' }, + 'critical-status:s' => { name => 'critical_status', default => '%{status} =~ /error|major|critical/i' } + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->change_macros(macros => [ + 'warning_status', 'critical_status', 'unknown_status', + ]); +} + +my $map_status = { + 0 => 'error', 1 => 'normal', 2 => 'minorAlarm', 3 => 'majorAlarm', + 4 => 'disabled', 5 => 'disconnected', 6 => 'notPresent', + 7 => 'minorAndMajor', 8 => 'majorLow', 9 => 'minorLow', + 10 => 'majorHigh', 11 => 'minorHigh', 12 => 'event', + 13 => 'valueVolt', 14 => 'valueAmp', 15 => 'valueTemp', + 16 => 'valueUnit', 17 => 'valuePerCent', 18 => 'critical', + 19 => 'warning' +}; +my $map_decimal_setting = { 0 => 'ampere', 1 => 'deciAmpere' }; + +my $mapping = { + powerSystemCurrentDecimalSetting => { oid => '.1.3.6.1.4.1.12148.10.2.15', map => $map_decimal_setting }, + loadStatus => { oid => '.1.3.6.1.4.1.12148.10.9.1', map => $map_status }, + loadCurrentValue => { oid => '.1.3.6.1.4.1.12148.10.9.2.5' }, # A or dA + loadCurrentMajorHighLevel => { oid => '.1.3.6.1.4.1.12148.10.9.2.6' }, + loadCurrentMinorHighLevel => { oid => '.1.3.6.1.4.1.12148.10.9.2.7' }, + loadEnergyLogAccumulated => { oid => '.1.3.6.1.4.1.12148.10.9.8.1' }, # Watt +}; + +sub threshold_eltek_configured { + my ($self, %options) = @_; + + if ((!defined($self->{option_results}->{'critical-' . $options{label}}) || $self->{option_results}->{'critical-' . $options{label}} eq '') && + (!defined($self->{option_results}->{'warning-' . $options{label}}) || $self->{option_results}->{'warning-' . $options{label}} eq '')) { + my ($crit, $warn) = ('', ''); + $crit = $options{low_crit} . ':' if (defined($options{low_crit}) && $options{low_crit} ne ''); + $crit .= $options{high_crit} if (defined($options{high_crit}) && $options{high_crit} ne ''); + $warn = $options{low_warn} . ':' if (defined($options{low_warn}) && $options{low_warn} ne ''); + $warn .= $options{high_warn} if (defined($options{high_warn}) && $options{high_warn} ne ''); + $self->{perfdata}->threshold_validate(label => 'critical-' . $options{label}, value => $crit); + $self->{perfdata}->threshold_validate(label => 'warning-' . $options{label}, value => $warn); + } +} + +sub manage_selection { + my ($self, %options) = @_; + + my $snmp_result = $options{snmp}->get_leef( + oids => [ map($_->{oid} . '.0', values(%$mapping)) ], + nothing_quit => 1 + ); + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => '0'); + + my $scale_current = 1; + $scale_current = 0.1 if ($result->{powerSystemCurrentDecimalSetting} eq 'deciAmpere'); + $self->{load} = { + status => $result->{loadStatus}, + energy => $result->{loadEnergyLogAccumulated}, + current => $result->{loadCurrentValue} * $scale_current + }; + + $self->threshold_eltek_configured( + label => 'load-current-ampere', + high_crit => $result->{loadCurrentMajorHighLevel} * $scale_current, + high_warn => $result->{loadCurrentMinorHighLevel} * $scale_current + ); + + my $oid_loadVoltageValue = '.1.3.6.1.4.1.12148.10.9.9.1.6'; + $snmp_result = $options{snmp}->get_table(oid => $oid_loadVoltageValue); + $self->{phase} = {}; + foreach (keys %$snmp_result) { + /\.(\d+)$/; + $self->{phase}->{$1} = { display => $1, voltage => $snmp_result->{$_} * 0.01 }; + } + + $self->{cache_name} = 'eltek_enexus_' . $self->{mode} . '_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); +} + +1; + +__END__ + +=head1 MODE + +Check load. + +=over 8 + +=item B<--unknown-status> + +Set unknown threshold for status. +Can used special variables like: %{status} + +=item B<--warning-status> + +Set warning threshold for status (Default: '%{status} =~ /minor|warning/i'). +Can used special variables like: %{status} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{status} =~ /error|major|critical/i'). +Can used special variables like: %{status} + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'current', 'energy-delivered'. + +=back + +=cut diff --git a/hardware/devices/eltek/enexus/snmp/plugin.pm b/hardware/devices/eltek/enexus/snmp/plugin.pm index 297ae1605..b6fd4245c 100644 --- a/hardware/devices/eltek/enexus/snmp/plugin.pm +++ b/hardware/devices/eltek/enexus/snmp/plugin.pm @@ -33,6 +33,7 @@ sub new { %{$self->{modes}} = ( 'alarms' => 'hardware::devices::eltek::enexus::snmp::mode::alarms', 'battery' => 'hardware::devices::eltek::enexus::snmp::mode::battery', + 'load' => 'hardware::devices::eltek::enexus::snmp::mode::load', 'outputs' => 'hardware::devices::eltek::enexus::snmp::mode::outputs' ); From 11795a3db1029367fad652f468c19df7792d316d Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 26 Mar 2020 14:06:32 +0100 Subject: [PATCH 031/283] add vsx mode for checkpoint --- network/checkpoint/snmp/mode/hastate.pm | 52 ++--- network/checkpoint/snmp/mode/memory.pm | 18 +- network/checkpoint/snmp/mode/vpnstatus.pm | 4 +- network/checkpoint/snmp/mode/vsx.pm | 242 ++++++++++++++++++++++ network/checkpoint/snmp/plugin.pm | 21 +- 5 files changed, 291 insertions(+), 46 deletions(-) create mode 100644 network/checkpoint/snmp/mode/vsx.pm diff --git a/network/checkpoint/snmp/mode/hastate.pm b/network/checkpoint/snmp/mode/hastate.pm index 1600f1307..8e2401ed4 100644 --- a/network/checkpoint/snmp/mode/hastate.pm +++ b/network/checkpoint/snmp/mode/hastate.pm @@ -24,22 +24,16 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; -use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold); +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); sub custom_status_output { my ($self, %options) = @_; + my $msg = "HA State: '" . $self->{result_values}->{hastate} . "' "; $msg .= "Role: '" . $self->{result_values}->{role} . "' "; return $msg; } -sub custom_status_calc { - my ($self, %options) = @_; - $self->{result_values}->{hastate} = $options{new_datas}->{$self->{instance} . '_hastate'}; - $self->{result_values}->{role} = $options{new_datas}->{$self->{instance} . '_role'}; - return 0; -} - sub set_counters { my ($self, %options) = @_; @@ -49,12 +43,12 @@ sub set_counters { $self->{maps_counters}->{high_availability} = [ { label => 'status', threshold => 0, set => { key_values => [ { name => 'hastate' }, { name => 'role' } ], - closure_custom_calc => $self->can('custom_status_calc'), + closure_custom_calc => \&catalog_status_calc, closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => \&catalog_status_threshold, + closure_custom_threshold_check => \&catalog_status_threshold } - }, + } ]; } @@ -63,12 +57,11 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - "warning-status:s" => { name => 'warning_status', default => '' }, - "critical-status:s" => { name => 'critical_status', default => '%{hastate} !~ /(UP|working)/' }, - "no-ha-status:s" => { name => 'no_ha_status', default => 'UNKNOWN' }, - }); + $options{options}->add_options(arguments => { + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '%{hastate} !~ /(UP|working)/' }, + 'no-ha-status:s' => { name => 'no_ha_status', default => 'UNKNOWN' } + }); return $self; } @@ -96,20 +89,27 @@ sub manage_selection { $self->{high_availability} = {}; - my $result = $options{snmp}->get_leef(oids => [$oid_haInstalled, $oid_haState, $oid_haStatCode, $oid_haStarted], - nothing_quit => 1); + my $result = $options{snmp}->get_leef( + oids => [$oid_haInstalled, $oid_haState, $oid_haStatCode, $oid_haStarted], + nothing_quit => 1 + ); if ($result->{$oid_haInstalled} < 1 or $result->{$oid_haStarted} eq "no") { - $self->{output}->output_add(severity => $self->{option_results}->{no_ha_status}, - short_msg => sprintf("Looks like HA is not started, or not installed .."), - long_msg => sprintf("HA Installed : '%u' HA Started : '%s'", - $result->{$oid_haInstalled}, $result->{$oid_haStarted}), - ); + $self->{output}->output_add( + severity => $self->{option_results}->{no_ha_status}, + short_msg => sprintf("Looks like HA is not started, or not installed .."), + long_msg => sprintf( + "HA Installed : '%u' HA Started : '%s'", + $result->{$oid_haInstalled}, $result->{$oid_haStarted} + ), + ); $self->{output}->display(); $self->{output}->exit(); } - $self->{high_availability} = { hastate => $map_status{$result->{$oid_haStatCode}}, - role => $result->{$oid_haState} }; + $self->{high_availability} = { + hastate => $map_status{$result->{$oid_haStatCode}}, + role => $result->{$oid_haState} + }; } 1; diff --git a/network/checkpoint/snmp/mode/memory.pm b/network/checkpoint/snmp/mode/memory.pm index d91eb1e73..67203270f 100644 --- a/network/checkpoint/snmp/mode/memory.pm +++ b/network/checkpoint/snmp/mode/memory.pm @@ -33,11 +33,12 @@ sub custom_usage_output { my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_absolute}); my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute}); - my $msg = sprintf("Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", - $total_size_value . " " . $total_size_unit, - $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used_absolute}, - $total_free_value . " " . $total_free_unit, 100 - $self->{result_values}->{prct_used_absolute}); - return $msg; + return sprintf( + 'Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)', + $total_size_value . " " . $total_size_unit, + $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used_absolute}, + $total_free_value . " " . $total_free_unit, 100 - $self->{result_values}->{prct_used_absolute} + ); } sub set_counters { @@ -61,6 +62,7 @@ sub set_counters { } }, ]; + $self->{maps_counters}->{swap} = [ { label => 'swap', set => { key_values => [ { name => 'prct_used' }, { name => 'used' }, { name => 'free' }, { name => 'total' } ], @@ -73,6 +75,7 @@ sub set_counters { } }, ]; + $self->{maps_counters}->{malloc} = [ { label => 'failed-malloc', set => { key_values => [ { name => 'failed_mallocs', diff => 1 } ], @@ -103,9 +106,8 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; - $options{options}->add_options(arguments => - { - }); + $options{options}->add_options(arguments => { + }); return $self; } diff --git a/network/checkpoint/snmp/mode/vpnstatus.pm b/network/checkpoint/snmp/mode/vpnstatus.pm index 73aa1b3e9..e9fae20d9 100644 --- a/network/checkpoint/snmp/mode/vpnstatus.pm +++ b/network/checkpoint/snmp/mode/vpnstatus.pm @@ -127,14 +127,14 @@ sub manage_selection { $self->{output}->output_add(long_msg => "skipping '" . $result->{tunnelPeerObjName} . "': no matching filter.", debug => 1); next; } - + $self->{vpn}->{$instance} = { display => $result->{tunnelPeerObjName}, status => $result->{tunnelState}, type => $result->{tunnelType} }; } - + if (scalar(keys %{$self->{vpn}}) <= 0) { $self->{output}->add_option_msg(short_msg => "No vpn found."); $self->{output}->option_exit(); diff --git a/network/checkpoint/snmp/mode/vsx.pm b/network/checkpoint/snmp/mode/vsx.pm new file mode 100644 index 000000000..9bab2217a --- /dev/null +++ b/network/checkpoint/snmp/mode/vsx.pm @@ -0,0 +1,242 @@ +# +# Copyright 2020 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 network::checkpoint::snmp::mode::vsx; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use Digest::MD5 qw(md5_hex); + +sub vsx_long_output { + my ($self, %options) = @_; + + return "checking virtual system '" . $options{instance_value}->{display} . "'"; +} + +sub prefix_vsx_output { + my ($self, %options) = @_; + + return "virtual system '" . $options{instance_value}->{display} . "' "; +} + +sub prefix_cpu_output { + my ($self, %options) = @_; + + return 'cpu usage: '; +} + + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'vsx', type => 3, cb_prefix_output => 'prefix_vsx_output', cb_long_output => 'vsx_long_output', + indent_long_output => ' ', message_multiple => 'All virtual systems are ok', + group => [ + { name => 'vsx_cpu', type => 0, cb_prefix_output => 'prefix_cpu_output', skipped_code => { -10 => 1 } }, + { name => 'vsx_memory', type => 0, skipped_code => { -10 => 1 } }, + { name => 'vsx_connection', type => 0, skipped_code => { -10 => 1 } }, + { name => 'vsx_traffic', type => 0, skipped_code => { -10 => 1 } } + ] + } + ]; + + $self->{maps_counters}->{vsx_cpu} = [ + { label => 'cpu-utilization-1hour', nlabel => 'virtualsystem.cpu.utilization.1hour.percentage', set => { + key_values => [ { name => 'cpu_1hour' }, { name => 'display' } ], + output_template => '%.2f%% (1hour)', + perfdatas => [ + { value => 'cpu_1hour_absolute', template => '%.2f', unit => '%', min => 0, max => 100, + label_extra_instance => 1, instance_use => 'display_absolute' } + ] + } + }, + { label => 'cpu-utilization-1min', nlabel => 'virtualsystem.cpu.utilization.1min.percentage', set => { + key_values => [ { name => 'cpu_1min' }, { name => 'display' } ], + output_template => '%.2f%% (1min)', + perfdatas => [ + { value => 'cpu_1min_absolute', template => '%.2f', unit => '%', min => 0, max => 100, + label_extra_instance => 1, instance_use => 'display_absolute' } + ] + } + } + ]; + + $self->{maps_counters}->{vsx_memory} = [ + { label => 'memory-usage', nlabel => 'virtualsystem.memory.usage.bytes', set => { + key_values => [ { name => 'memory_used' }, { name => 'display' } ], + output_template => 'memory used: %s%s', + output_change_bytes => 1, + perfdatas => [ + { value => 'memory_used_absolute', template => '%s', min => 0, + unit => 'B', label_extra_instance => 1, instance_use => 'display_absolute' } + ] + } + } + ]; + + $self->{maps_counters}->{vsx_connection} = [ + { label => 'connections-active', nlabel => 'virtualsystem.connections.active.count', set => { + key_values => [ { name => 'active_connections' }, { name => 'display' } ], + output_template => 'active connections: %d', + perfdatas => [ + { value => 'active_connections_absolute', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'display_absolute' } + ] + } + } + ]; + + $self->{maps_counters}->{vsx_traffic} = [ + { label => 'traffic-accepted', nlabel => 'virtualsystem.traffic.accepted.bitspersecond', set => { + key_values => [ { name => 'traffic_accepted', diff => 1 }, { name => 'display' } ], + output_template => 'traffic accepted: %s%s/s', + per_second => 1, output_change_bytes => 2, + perfdatas => [ + { value => 'traffic_accepted_per_second', template => '%s', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' } + ] + } + }, + { label => 'traffic-dropped', nlabel => 'virtualsystem.traffic.dropped.bitspersecond', set => { + key_values => [ { name => 'traffic_dropped', diff => 1 }, { name => 'display' } ], + output_template => 'traffic dropped: %s%s/s', + per_second => 1, output_change_bytes => 2, + perfdatas => [ + { value => 'traffic_dropped_per_second', template => '%s', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' } + ] + } + }, + { label => 'traffic-rejected', nlabel => 'virtualsystem.traffic.rejected.bitspersecond', set => { + key_values => [ { name => 'traffic_rejected', diff => 1 }, { name => 'display' } ], + output_template => 'traffic rejected: %s%s/s', + per_second => 1, output_change_bytes => 2, + perfdatas => [ + { value => 'traffic_rejected_per_second', template => '%s', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' } + ] + } + } + ]; +} + +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 => { + 'filter-vsx:s' => { name => 'filter_vsx' } + }); + + return $self; +} + +my $mapping = { + cpu_1min => { oid => '.1.3.6.1.4.1.2620.1.16.22.2.1.3' }, # vsxStatusCPUUsage1min + cpu_1hour => { oid => '.1.3.6.1.4.1.2620.1.16.22.2.1.4' }, # vsxStatusCPUUsage1hr + memory_used => { oid => '.1.3.6.1.4.1.2620.1.16.22.3.1.3' }, # vsxStatusMemoryUsage (KB) + active_connections => { oid => '.1.3.6.1.4.1.2620.1.16.23.1.1.2' }, # vsxCountersConnNum + traffic_accepted => { oid => '.1.3.6.1.4.1.2620.1.16.23.1.1.9' }, # vsxCountersBytesAcceptedTotal + traffic_dropped => { oid => '.1.3.6.1.4.1.2620.1.16.23.1.1.10' }, # vsxCountersBytesDroppedTotal + traffic_rejected => { oid => '.1.3.6.1.4.1.2620.1.16.23.1.1.11' } # vsxCountersBytesRejectedTotal +}; + +sub manage_selection { + my ($self, %options) = @_; + + my $oid_vsxStatusVsName = '.1.3.6.1.4.1.2620.1.16.22.1.1.3'; + my $snmp_result = $options{snmp}->get_table( + oid => $oid_vsxStatusVsName, + nothing_quit => 1 + ); + + $self->{vsx} = {}; + foreach (keys %$snmp_result) { + /^$oid_vsxStatusVsName\.(.*)/; + my $instance = $1; + my $name = $snmp_result->{$_}; + + if (defined($self->{option_results}->{filter_vsx}) && $self->{option_results}->{filter_vsx} ne '' && + $name !~ /$self->{option_results}->{filter_vsx}/) { + $self->{output}->output_add(long_msg => "skipping virtual system '" . $name . "'.", debug => 1); + next; + } + + $self->{vsx}->{$instance} = { + display => $name, + vsx_cpu => { display => $name }, + vsx_memory => { display => $name }, + vsx_connection => { display => $name }, + vsx_traffic => { display => $name } + }; + } + + return if (scalar(keys %{$self->{vsx}}) <= 0); + + $options{snmp}->load( + oids => [ map($_->{oid}, values(%$mapping)) ], + instances => [ keys %{$self->{vsx}} ], + instance_regexp => '^(.*)$' + ); + $snmp_result = $options{snmp}->get_leef(); + foreach (keys %{$self->{vsx}}) { + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $_); + $self->{vsx}->{$_}->{vsx_cpu}->{cpu_1min} = $result->{cpu_1min}; + $self->{vsx}->{$_}->{vsx_cpu}->{cpu_1hour} = $result->{cpu_1hour}; + $self->{vsx}->{$_}->{vsx_memory}->{memory_used} = $result->{memory_used} * 1024; + $self->{vsx}->{$_}->{vsx_connection}->{active_connections} = $result->{active_connections}; + $self->{vsx}->{$_}->{vsx_traffic}->{traffic_accepted} = $result->{traffic_accepted} * 8; + $self->{vsx}->{$_}->{vsx_traffic}->{traffic_dropped} = $result->{traffic_dropped} * 8; + $self->{vsx}->{$_}->{vsx_traffic}->{traffic_rejected} = $result->{traffic_rejected} * 8; + } + + $self->{cache_name} = 'checkpoint_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' . + (defined($self->{option_results}->{filter_vsx}) ? md5_hex($self->{option_results}->{filter_vsx}) : md5_hex('all')); +} + +1; + +__END__ + +=head1 MODE + +Check virtual systems. + +=over 8 + +=item B<--filter-vsx> + +Filter by virtual system name (can be a regexp). + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'cpu-utilization', 'sessions-active', 'session-rate', +'memory-usage-prct', 'license-usage', 'license-free', +'license-usage-prct', 'traffic-in', 'traffic-out', 'policies-active'. + +=back + +=cut diff --git a/network/checkpoint/snmp/plugin.pm b/network/checkpoint/snmp/plugin.pm index 963713424..42d7a5ba1 100644 --- a/network/checkpoint/snmp/plugin.pm +++ b/network/checkpoint/snmp/plugin.pm @@ -31,16 +31,17 @@ sub new { $self->{version} = '0.5'; %{$self->{modes}} = ( - 'connections' => 'network::checkpoint::snmp::mode::connections', - 'cpu' => 'network::checkpoint::snmp::mode::cpu', - 'hardware' => 'network::checkpoint::snmp::mode::hardware', - 'hastate' => 'network::checkpoint::snmp::mode::hastate', - 'interfaces' => 'snmp_standard::mode::interfaces', - 'list-interfaces' => 'snmp_standard::mode::listinterfaces', - 'memory' => 'network::checkpoint::snmp::mode::memory', - 'uptime' => 'snmp_standard::mode::uptime', - 'vpn-status' => 'network::checkpoint::snmp::mode::vpnstatus', - 'vrrp-status' => 'snmp_standard::mode::vrrp', + 'connections' => 'network::checkpoint::snmp::mode::connections', + 'cpu' => 'network::checkpoint::snmp::mode::cpu', + 'hardware' => 'network::checkpoint::snmp::mode::hardware', + 'hastate' => 'network::checkpoint::snmp::mode::hastate', + 'interfaces' => 'snmp_standard::mode::interfaces', + 'list-interfaces' => 'snmp_standard::mode::listinterfaces', + 'memory' => 'network::checkpoint::snmp::mode::memory', + 'uptime' => 'snmp_standard::mode::uptime', + 'vpn-status' => 'network::checkpoint::snmp::mode::vpnstatus', + 'vrrp-status' => 'snmp_standard::mode::vrrp', + 'vsx' => 'network::checkpoint::snmp::mode::vsx', ); return $self; From 76d46aa8038d964b475108003f67c18ec0fb1666 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 26 Mar 2020 14:07:23 +0100 Subject: [PATCH 032/283] enhance typo --- network/checkpoint/snmp/mode/vsx.pm | 6 +++--- .../cisco/meraki/cloudcontroller/snmp/mode/deviceusage.pm | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/network/checkpoint/snmp/mode/vsx.pm b/network/checkpoint/snmp/mode/vsx.pm index 9bab2217a..5418e8e5e 100644 --- a/network/checkpoint/snmp/mode/vsx.pm +++ b/network/checkpoint/snmp/mode/vsx.pm @@ -233,9 +233,9 @@ Filter by virtual system name (can be a regexp). =item B<--warning-*> B<--critical-*> Thresholds. -Can be: 'cpu-utilization', 'sessions-active', 'session-rate', -'memory-usage-prct', 'license-usage', 'license-free', -'license-usage-prct', 'traffic-in', 'traffic-out', 'policies-active'. +Can be: 'memory-usage', 'traffic-accepted', 'traffic-dropped', +'traffic-rejected', 'cpu-utilization-1hour', 'cpu-utilization-1min', +'connections-active'. =back diff --git a/network/cisco/meraki/cloudcontroller/snmp/mode/deviceusage.pm b/network/cisco/meraki/cloudcontroller/snmp/mode/deviceusage.pm index 4264f2a41..ecdfa8981 100644 --- a/network/cisco/meraki/cloudcontroller/snmp/mode/deviceusage.pm +++ b/network/cisco/meraki/cloudcontroller/snmp/mode/deviceusage.pm @@ -30,9 +30,8 @@ use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold) sub custom_status_output { my ($self, %options) = @_; - my $msg = 'status : ' . $self->{result_values}->{status}; - return $msg; + return 'status : ' . $self->{result_values}->{status}; } sub custom_status_calc { From 6d98241bc7e4ad7d947d3d80a1022f791a3e2e43 Mon Sep 17 00:00:00 2001 From: UrBnW <40244829+UrBnW@users.noreply.github.com> Date: Thu, 26 Mar 2020 19:28:49 +0100 Subject: [PATCH 033/283] Fix nsclient++ new API --- apps/protocols/nrpe/custom/nsclient.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/protocols/nrpe/custom/nsclient.pm b/apps/protocols/nrpe/custom/nsclient.pm index 6bbf04331..8e562b79f 100644 --- a/apps/protocols/nrpe/custom/nsclient.pm +++ b/apps/protocols/nrpe/custom/nsclient.pm @@ -142,7 +142,7 @@ sub output_perf { my $result = 'UNKNOWN'; $result = $errors_num{$options{result}} if ($options{result} =~ /[0-3]/); - $result = $options{result}if ($options{result} =~ /\w+/); + $result = $options{result} if ($options{result} =~ /[A-Z]+/); my %result = ( code => $result, From f23860ea6a20fee6d614bba13dc5305c93b19463 Mon Sep 17 00:00:00 2001 From: UrBnW <40244829+UrBnW@users.noreply.github.com> Date: Thu, 26 Mar 2020 22:49:57 +0100 Subject: [PATCH 034/283] Typo in interfaces perfdata new label --- snmp_standard/mode/interfaces.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snmp_standard/mode/interfaces.pm b/snmp_standard/mode/interfaces.pm index 013e6b125..e31c986b1 100644 --- a/snmp_standard/mode/interfaces.pm +++ b/snmp_standard/mode/interfaces.pm @@ -202,7 +202,7 @@ sub custom_errors_perfdata { if ($self->{instance_mode}->{option_results}->{units_errors} eq '%') { $self->{output}->perfdata_add( label => 'packets_' . $self->{result_values}->{label2} . '_' . $self->{result_values}->{label1}, unit => '%', - nlabel => 'interface.packets.' . $self->{result_values}->{label1} . '.' . $self->{result_values}->{label2} . 's.percentage', + nlabel => 'interface.packets.' . $self->{result_values}->{label1} . '.' . $self->{result_values}->{label2} . '.percentage', instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef, value => sprintf("%.2f", $self->{result_values}->{prct}), warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}), From 1fa504e7ffa8f3d7791bc286c755414935807806 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 27 Mar 2020 09:04:00 +0100 Subject: [PATCH 035/283] fix help --- hardware/devices/eltek/enexus/snmp/mode/outputs.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hardware/devices/eltek/enexus/snmp/mode/outputs.pm b/hardware/devices/eltek/enexus/snmp/mode/outputs.pm index 2630eb63b..37a86ffcb 100644 --- a/hardware/devices/eltek/enexus/snmp/mode/outputs.pm +++ b/hardware/devices/eltek/enexus/snmp/mode/outputs.pm @@ -191,7 +191,7 @@ Can used special variables like: %{status}, %{name} =item B<--warning-*> B<--critical-*> Thresholds. -Can be: 'current'. +Can be: 'outputs-disconnected', 'outputs-notenergized'. =back From 17812861a325a3089a20baf839742e0704c5cdf1 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 27 Mar 2020 09:17:08 +0100 Subject: [PATCH 036/283] update vpn-status checkpoint --- network/checkpoint/snmp/mode/connections.pm | 5 +- network/checkpoint/snmp/mode/cpu.pm | 10 +-- network/checkpoint/snmp/mode/vpnstatus.pm | 77 ++++++++++++--------- 3 files changed, 52 insertions(+), 40 deletions(-) diff --git a/network/checkpoint/snmp/mode/connections.pm b/network/checkpoint/snmp/mode/connections.pm index e0141c3cc..90adbcc9c 100644 --- a/network/checkpoint/snmp/mode/connections.pm +++ b/network/checkpoint/snmp/mode/connections.pm @@ -29,7 +29,7 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - + $options{options}->add_options(arguments => { 'warning:s' => { name => 'warning' }, 'critical:s' => { name => 'critical' }, @@ -65,7 +65,7 @@ sub run { my $oid_fwNumCom = '.1.3.6.1.4.1.2620.1.1.25.3.0'; my $oid_fwConnTableLimit = '.1.3.6.1.4.1.2620.1.1.25.10.0'; my $result = $self->{snmp}->get_leef(oids => [$oid_fwNumCom, $oid_fwConnTableLimit], nothing_quit => 1); - + my $value = $result->{$oid_fwNumCom}; my $extra = ''; my %total_options = (); @@ -78,7 +78,6 @@ sub run { } } - my $exit = $self->{perfdata}->threshold_check(value => $value, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); $self->{output}->output_add( diff --git a/network/checkpoint/snmp/mode/cpu.pm b/network/checkpoint/snmp/mode/cpu.pm index 5759d6587..d34127b0d 100644 --- a/network/checkpoint/snmp/mode/cpu.pm +++ b/network/checkpoint/snmp/mode/cpu.pm @@ -29,7 +29,7 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - + $options{options}->add_options(arguments => { 'warning:s' => { name => 'warning', }, 'critical:s' => { name => 'critical', }, @@ -41,7 +41,7 @@ sub new { sub check_options { my ($self, %options) = @_; $self->SUPER::init(%options); - + if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) { $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'."); $self->{output}->option_exit(); @@ -59,11 +59,11 @@ sub run { my $oid_procUsrTime = '.1.3.6.1.4.1.2620.1.6.7.2.1.0'; my $oid_procSysTime = '.1.3.6.1.4.1.2620.1.6.7.2.2.0'; my $oid_procIdleTime = '.1.3.6.1.4.1.2620.1.6.7.2.3.0'; - + my $result = $self->{snmp}->get_leef(oids => [$oid_procUsrTime, $oid_procSysTime, $oid_procIdleTime], nothing_quit => 1); - + my $totalCpuUsed = $result->{$oid_procUsrTime} + $result->{$oid_procSysTime}; - + my $exit = $self->{perfdata}->threshold_check(value => $totalCpuUsed, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); $self->{output}->output_add(severity => $exit, diff --git a/network/checkpoint/snmp/mode/vpnstatus.pm b/network/checkpoint/snmp/mode/vpnstatus.pm index e9fae20d9..08c42fa21 100644 --- a/network/checkpoint/snmp/mode/vpnstatus.pm +++ b/network/checkpoint/snmp/mode/vpnstatus.pm @@ -24,48 +24,50 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; -use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold); +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); sub custom_status_output { my ($self, %options) = @_; - - my $msg = 'status : ' . $self->{result_values}->{status}; - return $msg; -} -sub custom_status_calc { - my ($self, %options) = @_; - - $self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_status'}; - $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; - $self->{result_values}->{type} = $options{new_datas}->{$self->{instance} . '_type'}; - return 0; + return 'status : ' . $self->{result_values}->{status}; } sub set_counters { my ($self, %options) = @_; - + $self->{maps_counters_type} = [ + { name => 'global', type => 0 }, { name => 'vpn', type => 1, cb_prefix_output => 'prefix_vpn_output', message_multiple => 'All vpn are ok' } ]; - + + $self->{maps_counters}->{global} = [ + { label => 'tunnels-total', nlabel => 'vpn.tunnels.total.count', display_ok => 0, set => { + key_values => [ { name => 'total' } ], + output_template => 'current total number of tunnels: %d', + perfdatas => [ + { value => 'total_absolute', template => '%d', min => 0 } + ] + } + } + ]; + $self->{maps_counters}->{vpn} = [ { label => 'status', threshold => 0, set => { key_values => [ { name => 'type' }, { name => 'status' }, { name => 'display' } ], - closure_custom_calc => $self->can('custom_status_calc'), + closure_custom_calc => \&catalog_status_calc, closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => \&catalog_status_threshold, + closure_custom_threshold_check => \&catalog_status_threshold } - }, + } ]; } sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %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' }, 'warning-status:s' => { name => 'warning_status', default => '' }, @@ -73,7 +75,7 @@ sub new { 'filter-name:s' => { name => 'filter_name' }, 'buggy-snmp' => { name => 'buggy_snmp' }, }); - + return $self; } @@ -86,37 +88,42 @@ sub check_options { sub prefix_vpn_output { my ($self, %options) = @_; - + return "VPN '" . $options{instance_value}->{display} . "' "; } -my %map_type = (1 => 'regular', 2 => 'permanent'); -my %map_state = (3 => 'active', 4 => 'destroy', 129 => 'idle', 130 => 'phase1', +my $map_type = { 1 => 'regular', 2 => 'permanent' }; +my $map_state = { + 3 => 'active', 4 => 'destroy', 129 => 'idle', 130 => 'phase1', 131 => 'down', 132 => 'init' -); +}; my $mapping = { tunnelPeerObjName => { oid => '.1.3.6.1.4.1.2620.500.9002.1.2' }, - tunnelState => { oid => '.1.3.6.1.4.1.2620.500.9002.1.3', map => \%map_state }, - tunnelType => { oid => '.1.3.6.1.4.1.2620.500.9002.1.11', map => \%map_type }, + tunnelState => { oid => '.1.3.6.1.4.1.2620.500.9002.1.3', map => $map_state }, + tunnelType => { oid => '.1.3.6.1.4.1.2620.500.9002.1.11', map => $map_type } }; my $oid_tunnelEntry = '.1.3.6.1.4.1.2620.500.9002.1'; sub manage_selection { my ($self, %options) = @_; - $self->{vs} = {}; my $snmp_result; if (defined($self->{option_results}->{buggy_snmp})) { $snmp_result = $options{snmp}->get_table(oid => $oid_tunnelEntry, nothing_quit => 1); } else { - $snmp_result = $options{snmp}->get_multiple_table(oids => [ - { oid => $mapping->{tunnelPeerObjName}->{oid} }, - { oid => $mapping->{tunnelState}->{oid} }, - { oid => $mapping->{tunnelType}->{oid} }, - ], nothing_quit => 1, return_type => 1); + $snmp_result = $options{snmp}->get_multiple_table( + oids => [ + { oid => $oid_tunnelEntry, start => $mapping->{tunnelPeerObjName}->{oid}, end => $mapping->{tunnelState}->{oid} }, + { oid => $mapping->{tunnelType}->{oid} } + ], + nothing_quit => 1, + return_type => 1 + ); } + $self->{global} = { total => 0 }; + $self->{vs} = {}; foreach my $oid (keys %{$snmp_result}) { next if ($oid !~ /^$mapping->{tunnelState}->{oid}\.(.*)$/); my $instance = $1; @@ -133,6 +140,7 @@ sub manage_selection { status => $result->{tunnelState}, type => $result->{tunnelType} }; + $self->{global}->{total}++; } if (scalar(keys %{$self->{vpn}}) <= 0) { @@ -169,6 +177,11 @@ Can used special variables like: %{type}, %{status}, %{display} Checkpoint snmp can be buggy. Test that option if no response. +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'tunnels-total'. + =back =cut From 64ff6405cb2dd241cc8e67fac55a5af81c3b4f55 Mon Sep 17 00:00:00 2001 From: Sims24 Date: Fri, 27 Mar 2020 09:25:12 +0100 Subject: [PATCH 037/283] enh(plugin) include vsys within global session mode --- network/paloalto/snmp/mode/sessions.pm | 212 +++++++++++++++++---- network/paloalto/snmp/mode/vsyssessions.pm | 203 -------------------- 2 files changed, 178 insertions(+), 237 deletions(-) delete mode 100644 network/paloalto/snmp/mode/vsyssessions.pm diff --git a/network/paloalto/snmp/mode/sessions.pm b/network/paloalto/snmp/mode/sessions.pm index 9fdf069b4..404f9be4e 100644 --- a/network/paloalto/snmp/mode/sessions.pm +++ b/network/paloalto/snmp/mode/sessions.pm @@ -27,9 +27,10 @@ use warnings; sub set_counters { my ($self, %options) = @_; - + $self->{maps_counters_type} = [ { name => 'global', type => 0, cb_prefix_output => 'prefix_global_output', skipped_code => { -10 => 1 } }, + { name => 'vsys', type => 1, cb_prefix_output => 'prefix_vsys_output', message_multiple => 'Vsys sessions metrics are OK', skipped_code => { -10 => 1 } }, ]; $self->{maps_counters}->{global} = [ { label => 'active', set => { @@ -38,10 +39,10 @@ sub set_counters { closure_custom_output => $self->can('custom_active_output'), closure_custom_perfdata => $self->can('custom_active_perfdata'), closure_custom_threshold_check => $self->can('custom_active_threshold'), - + } }, - { label => 'active-ssl-proxy', set => { + { label => 'active-ssl-proxy', nlabel => 'sessions.active.vpnssl.count', set => { key_values => [ { name => 'panSessionSslProxyUtilization' } ], output_template => 'Active SSL Proxy : %.2f %%', perfdatas => [ @@ -50,7 +51,7 @@ sub set_counters { ], } }, - { label => 'active-tcp', set => { + { label => 'active-tcp', nlabel => 'sessions.active.tcp.count', set => { key_values => [ { name => 'panSessionActiveTcp' } ], output_template => 'Active TCP : %s', perfdatas => [ @@ -58,7 +59,7 @@ sub set_counters { ], } }, - { label => 'active-udp', set => { + { label => 'active-udp', nlabel => 'sessions.active.udp.count', set => { key_values => [ { name => 'panSessionActiveUdp' } ], output_template => 'Active UDP : %s', perfdatas => [ @@ -66,7 +67,7 @@ sub set_counters { ], } }, - { label => 'active-icmp', set => { + { label => 'active-icmp', nlabel => 'sessions.active.icmp.count', set => { key_values => [ { name => 'panSessionActiveICMP' } ], output_template => 'Active ICMP : %s', perfdatas => [ @@ -75,66 +76,171 @@ sub set_counters { } }, ]; + + $self->{maps_counters}->{vsys} = [ + { label => 'active-vsys', set => { + key_values => [ { name => 'panVsysActiveSessions' }, { name => 'panVsysMaxSessions' }, { name => 'display' } ], + closure_custom_calc => $self->can('custom_active_calc'), + closure_custom_output => $self->can('custom_active_output'), + closure_custom_perfdata => $self->can('custom_active_perfdata'), + closure_custom_threshold_check => $self->can('custom_active_threshold'), + + } + }, + { label => 'vsys-active-tcp', nlabel => 'vsys.sessions.active.tcp.count', set => { + key_values => [ { name => 'panVsysActiveTcpCps' }, { name => 'display' } ], + output_template => 'Active TCP : %s', + perfdatas => [ + { label => 'active_tcp', value => 'panVsysActiveTcpCps_absolute', template => '%s', + label_extra_instance => 1, instance_use => 'display_absolute', min => 0 }, + ], + } + }, + { label => 'vsys-active-udp', nlabel => 'vsys.sessions.active.udp.count', set => { + key_values => [ { name => 'panVsysActiveUdpCps' }, { name => 'display' } ], + output_template => 'Active UDP : %s', + perfdatas => [ + { label => 'active_udp', value => 'panVsysActiveUdpCps_absolute', template => '%s', + label_extra_instance => 1, instance_use => 'display_absolute', min => 0 }, + ], + } + }, + { label => 'vsys-active-other', nlabel => 'vsys.sessions.active.other.count', set => { + key_values => [ { name => 'panVsysActiveOtherIpCps' }, { name => 'display' } ], + output_template => 'Other : %s', + perfdatas => [ + { label => 'active_other', value => 'panVsysActiveOtherIpCps_absolute', template => '%s', + label_extra_instance => 1, instance_use => 'display_absolute', min => 0 }, + ], + } + }, + ]; + + + } sub prefix_global_output { my ($self, %options) = @_; - + return "Sessions "; } +sub prefix_vsys_output { + my ($self, %options) = @_; + + return "Vsys '" . $options{instance_value}->{display} . "' "; + +} + sub custom_active_perfdata { my ($self, %options) = @_; - - my $label = 'active'; - my %total_options = (); - if ($self->{result_values}->{panSessionMax} != 0) { - $total_options{total} = $self->{result_values}->{panSessionMax}; - $total_options{cast_int} = 1; - } - $self->{output}->perfdata_add(label => $label, - value => $self->{result_values}->{panSessionActive}, - warning => defined($total_options{total}) ? $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options) : undef, - critical => defined($total_options{total}) ? $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options) : undef, - min => 0, max => $self->{result_values}->{panSessionMax}); + my %total_options = (); + + if ($self->{label} eq 'active') { + if ($self->{result_values}->{panSessionMax} != 0) { + $total_options{total} = $self->{result_values}->{panSessionMax}; + $total_options{cast_int} = 1; + } + + $self->{output}->perfdata_add(label => $self->{label}, + nlabel => 'sessions.active.count', + value => $self->{result_values}->{panSessionActive}, + warning => defined($total_options{total}) ? $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options) : undef, + critical => defined($total_options{total}) ? $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options) : undef, + min => 0, max => $self->{result_values}->{panSessionMax}); + } else { + if ($self->{result_values}->{panVsysMaxSessions} != 0) { + $total_options{total} = $self->{result_values}->{panVsysMaxSessions}; + $total_options{cast_int} = 1; + } + + $self->{output}->perfdata_add(label => $self->{label}, + nlabel => $self->{result_values}->{display} . "#" . 'sessions.active.count', + value => $self->{result_values}->{panVsysActiveSessions}, + warning => defined($total_options{total}) ? $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options) : undef, + critical => defined($total_options{total}) ? $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options) : undef, + min => 0, max => $self->{result_values}->{panVsysMaxSessions}); + } } sub custom_active_threshold { my ($self, %options) = @_; - + my ($exit, $threshold_value) = ('ok'); - if ($self->{result_values}->{panSessionMax} != 0) { - $threshold_value = $self->{result_values}->{active_prct}; + + if ($self->{label} eq 'active') { + if ($self->{result_values}->{panSessionMax} != 0) { + $threshold_value = $self->{result_values}->{active_prct}; + } + $exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => + [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-'. $self->{label}, exit_litteral => 'warning' } ]) if (defined($threshold_value)); + return $exit; + } else { + if ($self->{result_values}->{panVsysMaxSessions} != 0) { + $threshold_value = $self->{result_values}->{active_prct}; + } + $exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => + [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-'. $self->{label}, exit_litteral => 'warning' } ]) if (defined($threshold_value)); + return $exit; } - $exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => - [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-'. $self->{label}, exit_litteral => 'warning' } ]) if (defined($threshold_value)); - return $exit; } sub custom_active_output { my ($self, %options) = @_; - - my $msg = sprintf("Active : %s (%s)", + + my $msg = ""; + if ($self->{label} eq 'active') { + $msg = sprintf("Active : %s (%s)", $self->{result_values}->{panSessionActive}, - $self->{result_values}->{panSessionMax} != 0 ? $self->{result_values}->{active_prct} . " %" : + $self->{result_values}->{panSessionMax} != 0 ? $self->{result_values}->{active_prct} . " %" : '-'); + } else { + $msg = sprintf("Active : %s (%s)", + $self->{result_values}->{panVsysActiveSessions}, + $self->{result_values}->{panVsysMaxSessions} != 0 ? $self->{result_values}->{active_prct} . " %" : + '-'); + } return $msg; } sub custom_active_calc { my ($self, %options) = @_; + $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; $self->{result_values}->{panSessionActive} = $options{new_datas}->{$self->{instance} . '_panSessionActive'}; $self->{result_values}->{panSessionMax} = $options{new_datas}->{$self->{instance} . '_panSessionMax'}; + $self->{result_values}->{panVsysActiveSessions} = $options{new_datas}->{$self->{instance} . '_panVsysActiveSessions'}; + $self->{result_values}->{panVsysMaxSessions} = $options{new_datas}->{$self->{instance} . '_panVsysMaxSessions'}; $self->{result_values}->{active_prct} = 0; - if ($self->{result_values}->{panSessionMax} != 0) { - $self->{result_values}->{active_prct} = $self->{result_values}->{panSessionActive} * 100 / $self->{result_values}->{panSessionMax}; + + if ($self->{label} eq 'active') { + if ($self->{result_values}->{panSessionMax} != 0) { + $self->{result_values}->{active_prct} = $self->{result_values}->{panSessionActive} * 100 / $self->{result_values}->{panSessionMax}; + } + } else { + if ($self->{result_values}->{panVsysMaxSessions} != 0) { + $self->{result_values}->{active_prct} = $self->{result_values}->{panVsysActiveSessions} * 100 / $self->{result_values}->{panVsysMaxSessions}; + } } return 0; } -my $mapping = { +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, force_new_perfdata => 1, %options); + bless $self, $class; + + $options{options}->add_options(arguments => { + 'add-vsys' => { name => 'add_vsys' }, + }); + + return $self; +} + + +my $mapping_sessions = { panSessionMax => { oid => '.1.3.6.1.4.1.25461.2.1.2.3.2' }, panSessionActive => { oid => '.1.3.6.1.4.1.25461.2.1.2.3.3' }, panSessionActiveTcp => { oid => '.1.3.6.1.4.1.25461.2.1.2.3.4' }, @@ -144,14 +250,50 @@ my $mapping = { panSessionSslProxyUtilization => { oid => '.1.3.6.1.4.1.25461.2.1.2.3.8' }, }; +my $mapping_vsys = { + panVsysName => { oid => '.1.3.6.1.4.1.25461.2.1.2.3.9.1.2' }, + panVsysActiveSessions => { oid => '.1.3.6.1.4.1.25461.2.1.2.3.9.1.4' }, + panVsysMaxSessions => { oid => '.1.3.6.1.4.1.25461.2.1.2.3.9.1.5' }, + panVsysActiveTcpCps => { oid => '.1.3.6.1.4.1.25461.2.1.2.3.9.1.6' }, + panVsysActiveUdpCps => { oid => '.1.3.6.1.4.1.25461.2.1.2.3.9.1.7' }, + panVsysActiveOtherIpCps => { oid => '.1.3.6.1.4.1.25461.2.1.2.3.9.1.8' }, +}; + +sub add_vsys { + my ($self, %options) = @_; + + my $oid_panVsysEntry = '.1.3.6.1.4.1.25461.2.1.2.3.9.1'; + $self->{results} = $options{snmp}->get_table(oid => $oid_panVsysEntry, + nothing_quit => 1); + + foreach my $oid (keys %{$self->{results}}) { + next if $oid !~ /^$mapping_vsys->{panVsysName}->{oid}\.(.*)$/; + my $instance = $1; + + my $result = $options{snmp}->map_instance(mapping => $mapping_vsys, results => $self->{results}, instance => $instance); + + $self->{vsys}->{$result->{panVsysName}} = { + display => $result->{panVsysName}, + panVsysMaxSessions => defined($result->{panVsysMaxSessions}) ? $result->{panVsysMaxSessions} : 0, + panVsysActiveSessions => $result->{panVsysActiveSessions}, + panVsysActiveTcpCps => $result->{panVsysActiveTcpCps}, + panVsysActiveUdpCps => $result->{panVsysActiveUdpCps}, + }; + + } +} + sub manage_selection { my ($self, %options) = @_; my $oid_panSession = '.1.3.6.1.4.1.25461.2.1.2.3'; $self->{results} = $options{snmp}->get_table(oid => $oid_panSession, nothing_quit => 1); - $self->{global} = $options{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => '0'); + $self->{global} = $options{snmp}->map_instance(mapping => $mapping_sessions, results => $self->{results}, instance => '0'); $self->{global}->{panSessionMax} = 0 if (!defined($self->{global}->{panSessionMax})); + + $self->add_vsys(snmp => $options{snmp}) + if (defined($self->{option_results}->{add_vsys})); } 1; @@ -167,12 +309,14 @@ Check sessions. =item B<--warning-*> Threshold warning. -Can be: 'active' (%), 'active-tcp', 'active-udp', 'active-icmp', 'active-ssl-proxy' (%). +Global: 'active' (%), 'active-tcp', 'active-udp', 'active-icmp', 'active-ssl-proxy' (%). +Per vsys: 'active-vsys' (%), 'vsys-active-tcp' 'vsys-active-udp' 'vsys-active-other' =item B<--critical-*> Threshold critical. -Can be: 'active' (%), 'active-tcp', 'active-udp', 'active-icmp', 'active-ssl-proxy' (%). +Global: 'active' (%), 'active-tcp', 'active-udp', 'active-icmp', 'active-ssl-proxy' (%). +Per vsys: 'active-vsys' (%), 'vsys-active-tcp' 'vsys-active-udp' 'vsys-active-other' =back diff --git a/network/paloalto/snmp/mode/vsyssessions.pm b/network/paloalto/snmp/mode/vsyssessions.pm deleted file mode 100644 index 0a9040321..000000000 --- a/network/paloalto/snmp/mode/vsyssessions.pm +++ /dev/null @@ -1,203 +0,0 @@ -# -# Copyright 2020 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 network::paloalto::snmp::mode::vsyssessions; - -use base qw(centreon::plugins::templates::counter); - -use strict; -use warnings; - -sub set_counters { - my ($self, %options) = @_; - - $self->{maps_counters_type} = [ - { name => 'vsys', type => 1, cb_prefix_output => 'prefix_vsys_output', message_multiple => 'Vsys Sessions metrics are OK' }, - ]; - $self->{maps_counters}->{vsys} = [ - { label => 'active', set => { - key_values => [ { name => 'panVsysActiveSessions' }, { name => 'panVsysMaxSessions' }, { name => 'display' } ], - closure_custom_calc => $self->can('custom_active_calc'), - closure_custom_output => $self->can('custom_active_output'), - closure_custom_perfdata => $self->can('custom_active_perfdata'), - closure_custom_threshold_check => $self->can('custom_active_threshold'), - - } - }, - { label => 'active-tcp', nlabel => 'vsys.sessions.active.tcp.count', set => { - key_values => [ { name => 'panVsysActiveTcpCps' }, { name => 'display' } ], - output_template => 'Active TCP : %s', - perfdatas => [ - { label => 'active_tcp', value => 'panVsysActiveTcpCps_absolute', template => '%s', - label_extra_instance => 1, instance_use => 'display_absolute', min => 0 }, - ], - } - }, - { label => 'active-udp', nlabel => 'vsys.sessions.active.udp.count', set => { - key_values => [ { name => 'panVsysActiveUdpCps' }, { name => 'display' } ], - output_template => 'Active UDP : %s', - perfdatas => [ - { label => 'active_udp', value => 'panVsysActiveUdpCps_absolute', template => '%s', - label_extra_instance => 1, instance_use => 'display_absolute', min => 0 }, - ], - } - }, - { label => 'active-other', nlabel => 'vsys.sessions.active.other.count', set => { - key_values => [ { name => 'panVsysActiveOtherIpCps' }, { name => 'display' } ], - output_template => 'Other : %s', - perfdatas => [ - { label => 'active_other', value => 'panVsysActiveOtherIpCps_absolute', template => '%s', - label_extra_instance => 1, instance_use => 'display_absolute', min => 0 }, - ], - } - }, - ]; -} - -sub new { - my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, force_new_perfdata => 1, %options); - bless $self, $class; - - $options{options}->add_options(arguments => { - }); - - return $self; -} - -sub prefix_vsys_output { - my ($self, %options) = @_; - - return "Vsys '" . $options{instance_value}->{display} . "' "; - -} - -sub custom_active_perfdata { - my ($self, %options) = @_; - - my $label = 'active'; - my %total_options = (); - if ($self->{result_values}->{panVsysMaxSessions} != 0) { - $total_options{total} = $self->{result_values}->{panVsysMaxSessions}; - $total_options{cast_int} = 1; - } - - $self->{output}->perfdata_add(label => $self->{result_values}->{display} . "#active.sessions.count", - value => $self->{result_values}->{panVsysActiveSessions}, - warning => defined($total_options{total}) ? - $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options) : undef, - critical => defined($total_options{total}) ? - $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options) : undef, - min => 0, - max => $self->{result_values}->{panVsysMaxSessions}); -} - -sub custom_active_threshold { - my ($self, %options) = @_; - - my ($exit, $threshold_value) = ('ok'); - if ($self->{result_values}->{panVsysMaxSessions} != 0) { - $threshold_value = $self->{result_values}->{active_prct}; - } - $exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => - [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-'. $self->{label}, exit_litteral => 'warning' } ]) if (defined($threshold_value)); - return $exit; -} - -sub custom_active_output { - my ($self, %options) = @_; - - my $msg = sprintf("Active : %s (%s)", - $self->{result_values}->{panVsysActiveSessions}, - $self->{result_values}->{panVsysMaxSessions} != 0 ? $self->{result_values}->{active_prct} . " %" : - '-'); - return $msg; -} - -sub custom_active_calc { - my ($self, %options) = @_; - - $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; - $self->{result_values}->{panVsysActiveSessions} = $options{new_datas}->{$self->{instance} . '_panVsysActiveSessions'}; - $self->{result_values}->{panVsysMaxSessions} = $options{new_datas}->{$self->{instance} . '_panVsysMaxSessions'}; - $self->{result_values}->{active_prct} = 0; - if ($self->{result_values}->{panVsysMaxSessions} != 0) { - $self->{result_values}->{active_prct} = $self->{result_values}->{panVsysActiveSessions} * 100 / $self->{result_values}->{panVsysMaxSessions}; - } - return 0; -} - -my $mapping = { - panVsysName => { oid => '.1.3.6.1.4.1.25461.2.1.2.3.9.1.2' }, - panVsysActiveSessions => { oid => '.1.3.6.1.4.1.25461.2.1.2.3.9.1.4' }, - panVsysMaxSessions => { oid => '.1.3.6.1.4.1.25461.2.1.2.3.9.1.5' }, - panVsysActiveTcpCps => { oid => '.1.3.6.1.4.1.25461.2.1.2.3.9.1.6' }, - panVsysActiveUdpCps => { oid => '.1.3.6.1.4.1.25461.2.1.2.3.9.1.7' }, - panVsysActiveOtherIpCps => { oid => '.1.3.6.1.4.1.25461.2.1.2.3.9.1.8' }, -}; - -sub manage_selection { - my ($self, %options) = @_; - - my $oid_panVsysEntry = '.1.3.6.1.4.1.25461.2.1.2.3.9.1'; - $self->{results} = $options{snmp}->get_table(oid => $oid_panVsysEntry, - nothing_quit => 1); - - foreach my $oid (keys %{$self->{results}}) { - next if $oid !~ /^$mapping->{panVsysName}->{oid}\.(.*)$/; - my $instance = $1; - - my $result = $options{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => $instance); - - $self->{vsys}->{$result->{panVsysName}} = { - display => $result->{panVsysName}, - panVsysMaxSessions => defined($result->{panVsysMaxSessions}) ? $result->{panVsysMaxSessions} : 0, - panVsysActiveSessions => $result->{panVsysActiveSessions}, - panVsysActiveTcpCps => $result->{panVsysActiveTcpCps}, - panVsysActiveUdpCps => $result->{panVsysActiveUdpCps}, - panVsysActiveOtherIpCps => $result->{panVsysActiveOtherIpCps} - }; - - } -} - -1; - -__END__ - -=head1 MODE - -Check sessions per Vsys - -=over 8 - -=item B<--warning-*> - -Threshold warning. -Can be: 'active' (%), 'active-tcp', 'active-udp', 'active-other' - -=item B<--critical-*> - -Threshold critical. -Can be: 'active' (%), 'active-tcp', 'active-udp', 'active-other' - -=back - -=cut From 36b527cc05ff48327f467b64b7b3a278d35f33b8 Mon Sep 17 00:00:00 2001 From: Sims24 Date: Fri, 27 Mar 2020 09:27:39 +0100 Subject: [PATCH 038/283] enh(plugin) delete vsyssession mode ref in plugin.pm --- network/paloalto/snmp/plugin.pm | 1 - 1 file changed, 1 deletion(-) diff --git a/network/paloalto/snmp/plugin.pm b/network/paloalto/snmp/plugin.pm index 4b4e476a0..41509f404 100644 --- a/network/paloalto/snmp/plugin.pm +++ b/network/paloalto/snmp/plugin.pm @@ -40,7 +40,6 @@ sub new { 'memory' => 'network::paloalto::snmp::mode::memory', 'panorama' => 'network::paloalto::snmp::mode::panorama', 'sessions' => 'network::paloalto::snmp::mode::sessions', - 'vsys-sessions' => 'network::paloalto::snmp::mode::vsyssessions', ); return $self; From 135e7f0ebd3d872d95de2b7d1c12487558a32a53 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 27 Mar 2020 11:22:59 +0100 Subject: [PATCH 039/283] Fix #1904 --- storage/synology/snmp/mode/ha.pm | 154 +++++++++++++++++++++++++++++++ storage/synology/snmp/plugin.pm | 3 +- 2 files changed, 156 insertions(+), 1 deletion(-) create mode 100644 storage/synology/snmp/mode/ha.pm diff --git a/storage/synology/snmp/mode/ha.pm b/storage/synology/snmp/mode/ha.pm new file mode 100644 index 000000000..799a0ae92 --- /dev/null +++ b/storage/synology/snmp/mode/ha.pm @@ -0,0 +1,154 @@ +# +# Copyright 2020 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 storage::synology::snmp::mode::ha; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); + +sub custom_status_output { + my ($self, %options) = @_; + + return sprintf( + "cluster status is '%s' [heartbeat status: %s] [active node: %s] [passive node: %s]", + $self->{result_values}->{cluster_status}, + $self->{result_values}->{heartbeat_status}, + $self->{result_values}->{active_node_name}, + $self->{result_values}->{passive_node_name} + ); +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0 }, + ]; + + $self->{maps_counters}->{global} = [ + { label => 'status', threshold => 0, set => { + key_values => [ + { name => 'cluster_status' }, { name => 'heartbeat_status' }, + { name => 'active_node_name' }, { name => 'passive_node_name' } + ], + closure_custom_calc => \&catalog_status_threshold, + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold + } + }, + { label => 'heartbeat-latency', nlabel => 'ha.heartbeat.latency.microseconds', display_ok => 0, set => { + key_values => [ { name => 'heartbeat_latency' } ], + output_template => 'heartbeat latency: %s us', + perfdatas => [ + { value => 'heartbeat_latency_absolute', template => '%s', min => 0, unit => 'us' } + ] + } + } + ]; +} + +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 => { + 'unknown-status:s' => { name => 'unknown_status', default => '' }, + 'warning-status:s' => { name => 'warning_status', default => '%{cluster_status} =~ /warning/i || %{heartbeat_status} =~ /abnormal/i' }, + 'critical-status:s' => { name => 'critical_status', default => '%{cluster_status} =~ /critical/i || %{heartbeat_status} =~ /disconnected/i' } + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->change_macros(macros => ['warning_status', 'critical_status', 'unknown_status']); +} + +my $map_cluster_status = { + 0 => 'normal', 1 => 'warning', 2 => 'critical', 3 => 'upgrading', 4 => 'processing' +}; +my $map_heartbeat_status = { + 0 => 'normal', 1 => 'abnormal', 2 => 'disconnected', 3 => 'empty' +}; + +my $mapping = { + active_node_name => { oid => '.1.3.6.1.4.1.6574.106.1' }, # activeNodeName + passive_node_name => { oid => '.1.3.6.1.4.1.6574.106.2' }, # passiveNodeName + cluster_status => { oid => '.1.3.6.1.4.1.6574.106.5', map => $map_cluster_status }, # clusterStatus + heartbeat_status => { oid => '.1.3.6.1.4.1.6574.106.6', map => $map_heartbeat_status }, # heartbeatStatus + heartbeat_latency => { oid => '.1.3.6.1.4.1.6574.106.8' } # microseconds +}; + +sub manage_selection { + my ($self, %options) = @_; + + my $snmp_result = $options{snmp}->get_leef( + oids => [ map($_->{oid} . '.0', values(%$mapping)) ], + nothing_quit => 1 + ); + $self->{global} = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => '0'); +} + +1; + +__END__ + +=head1 MODE + +Check high availability. + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='^status$' + +=item B<--unknown-status> + +Set unknown threshold for status. +Can used special variables like: %{cluster_status}, %{heartbeat_status}, %{active_node_name}, %{passive_node_name} + +=item B<--warning-status> + +Set warning threshold for status (Default: '%{cluster_status} =~ /warning/i || %{heartbeat_status} =~ /abnormal/i'). +Can used special variables like: %{cluster_status}, %{heartbeat_status}, %{active_node_name}, %{passive_node_name} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{cluster_status} =~ /critical/i || %{heartbeat_status} =~ /disconnected/i'). +Can used special variables like: %{cluster_status}, %{heartbeat_status}, %{active_node_name}, %{passive_node_name} + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'heartbeat-latency'. + +=back + +=cut diff --git a/storage/synology/snmp/plugin.pm b/storage/synology/snmp/plugin.pm index f3c8abd49..f1ce05244 100644 --- a/storage/synology/snmp/plugin.pm +++ b/storage/synology/snmp/plugin.pm @@ -33,12 +33,13 @@ sub new { %{$self->{modes}} = ( 'components' => 'storage::synology::snmp::mode::hardware', 'cpu' => 'snmp_standard::mode::cpu', + 'ha' => 'storage::synology::snmp::mode::ha', 'interfaces' => 'snmp_standard::mode::interfaces', 'memory' => 'snmp_standard::mode::memory', 'load' => 'snmp_standard::mode::loadaverage', 'storage' => 'snmp_standard::mode::storage', 'temperature' => 'storage::synology::snmp::mode::temperature', - 'ups' => 'storage::synology::snmp::mode::ups', + 'ups' => 'storage::synology::snmp::mode::ups' ); return $self; From d242fe12e086c95cf7f8704267b017da2f231a97 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 27 Mar 2020 12:04:48 +0100 Subject: [PATCH 040/283] enhance paloalto sessions --- network/paloalto/snmp/mode/sessions.pm | 293 ++++++++++--------------- 1 file changed, 114 insertions(+), 179 deletions(-) diff --git a/network/paloalto/snmp/mode/sessions.pm b/network/paloalto/snmp/mode/sessions.pm index 404f9be4e..9234c9e9b 100644 --- a/network/paloalto/snmp/mode/sessions.pm +++ b/network/paloalto/snmp/mode/sessions.pm @@ -25,6 +25,44 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; +sub custom_vsys_active_perfdata { + my ($self, %options) = @_; + + $self->{output}->perfdata_add( + label => $self->{label}, + nlabel => $self->{nlabel}, + instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display_absolute} : undef, + value => $self->{result_values}->{sessions_active_absolute}, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}), + min => 0, + max => $self->{result_values}->{sessions_max_absolute} != 0 ? $self->{result_values}->{sessions_max_absolute} : undef + ); +} + +sub custom_active_perfdata { + my ($self, %options) = @_; + + $self->{output}->perfdata_add( + label => $self->{label}, + nlabel => $self->{nlabel}, + value => $self->{result_values}->{sessions_active_absolute}, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}), + min => 0, + max => $self->{result_values}->{sessions_max_absolute} != 0 ? $self->{result_values}->{sessions_max_absolute} : undef + ); +} + +sub custom_active_output { + my ($self, %options) = @_; + + return sprintf('active: %s (%s)', + $self->{result_values}->{sessions_active_absolute}, + $self->{result_values}->{sessions_max_absolute} != 0 ? $self->{result_values}->{sessions_max_absolute} : '-' + ); +} + sub set_counters { my ($self, %options) = @_; @@ -33,76 +71,79 @@ sub set_counters { { name => 'vsys', type => 1, cb_prefix_output => 'prefix_vsys_output', message_multiple => 'Vsys sessions metrics are OK', skipped_code => { -10 => 1 } }, ]; $self->{maps_counters}->{global} = [ - { label => 'active', set => { - key_values => [ { name => 'panSessionActive' }, { name => 'panSessionMax' } ], - closure_custom_calc => $self->can('custom_active_calc'), + { label => 'active', nlabel => 'sessions.active.count', set => { + key_values => [ { name => 'sessions_active' }, { name => 'sessions_max' } ], closure_custom_output => $self->can('custom_active_output'), - closure_custom_perfdata => $self->can('custom_active_perfdata'), - closure_custom_threshold_check => $self->can('custom_active_threshold'), - + closure_custom_perfdata => $self->can('custom_active_perfdata') } }, - { label => 'active-ssl-proxy', nlabel => 'sessions.active.vpnssl.count', set => { - key_values => [ { name => 'panSessionSslProxyUtilization' } ], - output_template => 'Active SSL Proxy : %.2f %%', + { label => 'active-prct', nlabel => 'sessions.active.percentage', display_ok => 0, set => { + key_values => [ { name => 'sessions_active_prct' } ], + output_template => 'active: %.2f %%', perfdatas => [ - { label => 'active_ssl_proxy', value => 'panSessionSslProxyUtilization_absolute', template => '%.2f', unit => '%', - min => 0, max => 100 }, - ], + { label => 'active_prct', value => 'sessions_active_prct_absolute', template => '%.2f', unit => '%', + min => 0, max => 100 } + ] } }, { label => 'active-tcp', nlabel => 'sessions.active.tcp.count', set => { key_values => [ { name => 'panSessionActiveTcp' } ], - output_template => 'Active TCP : %s', + output_template => 'active TCP: %s', perfdatas => [ - { label => 'active_tcp', value => 'panSessionActiveTcp_absolute', template => '%s', min => 0 }, - ], + { label => 'active_tcp', value => 'panSessionActiveTcp_absolute', template => '%s', min => 0 } + ] } }, { label => 'active-udp', nlabel => 'sessions.active.udp.count', set => { key_values => [ { name => 'panSessionActiveUdp' } ], - output_template => 'Active UDP : %s', + output_template => 'active UDP: %s', perfdatas => [ - { label => 'active_udp', value => 'panSessionActiveUdp_absolute', template => '%s', min => 0 }, - ], + { label => 'active_udp', value => 'panSessionActiveUdp_absolute', template => '%s', min => 0 } + ] } }, { label => 'active-icmp', nlabel => 'sessions.active.icmp.count', set => { key_values => [ { name => 'panSessionActiveICMP' } ], - output_template => 'Active ICMP : %s', + output_template => 'active ICMP: %s', perfdatas => [ - { label => 'active_icmp', value => 'panSessionActiveICMP_absolute', template => '%s', min => 0 }, - ], + { label => 'active_icmp', value => 'panSessionActiveICMP_absolute', template => '%s', min => 0 } + ] } - }, + } ]; $self->{maps_counters}->{vsys} = [ - { label => 'active-vsys', set => { - key_values => [ { name => 'panVsysActiveSessions' }, { name => 'panVsysMaxSessions' }, { name => 'display' } ], - closure_custom_calc => $self->can('custom_active_calc'), + { label => 'vsys-active', nlabel => 'vsys.sessions.active.count', set => { + key_values => [ { name => 'sessions_active' }, { name => 'sessions_max' }, { name => 'display' } ], closure_custom_output => $self->can('custom_active_output'), - closure_custom_perfdata => $self->can('custom_active_perfdata'), - closure_custom_threshold_check => $self->can('custom_active_threshold'), - + closure_custom_perfdata => $self->can('custom_vsys_active_perfdata') + } + }, + { label => 'vsys-active-prct', nlabel => 'vsys.sessions.active.percentage', display_ok => 0, set => { + key_values => [ { name => 'sessions_active_prct' } ], + output_template => 'active: %.2f %%', + perfdatas => [ + { label => 'active_prct', value => 'sessions_active_prct_absolute', template => '%.2f', unit => '%', + min => 0, max => 100 } + ] } }, { label => 'vsys-active-tcp', nlabel => 'vsys.sessions.active.tcp.count', set => { key_values => [ { name => 'panVsysActiveTcpCps' }, { name => 'display' } ], - output_template => 'Active TCP : %s', + output_template => 'active TCP: %s', perfdatas => [ { label => 'active_tcp', value => 'panVsysActiveTcpCps_absolute', template => '%s', - label_extra_instance => 1, instance_use => 'display_absolute', min => 0 }, - ], + label_extra_instance => 1, min => 0 } + ] } }, { label => 'vsys-active-udp', nlabel => 'vsys.sessions.active.udp.count', set => { key_values => [ { name => 'panVsysActiveUdpCps' }, { name => 'display' } ], - output_template => 'Active UDP : %s', + output_template => 'active UDP: %s', perfdatas => [ { label => 'active_udp', value => 'panVsysActiveUdpCps_absolute', template => '%s', - label_extra_instance => 1, instance_use => 'display_absolute', min => 0 }, - ], + label_extra_instance => 1, min => 0 } + ] } }, { label => 'vsys-active-other', nlabel => 'vsys.sessions.active.other.count', set => { @@ -110,14 +151,11 @@ sub set_counters { output_template => 'Other : %s', perfdatas => [ { label => 'active_other', value => 'panVsysActiveOtherIpCps_absolute', template => '%s', - label_extra_instance => 1, instance_use => 'display_absolute', min => 0 }, - ], + label_extra_instance => 1, min => 0 } + ] } - }, + } ]; - - - } sub prefix_global_output { @@ -129,102 +167,7 @@ sub prefix_global_output { sub prefix_vsys_output { my ($self, %options) = @_; - return "Vsys '" . $options{instance_value}->{display} . "' "; - -} - -sub custom_active_perfdata { - my ($self, %options) = @_; - - my %total_options = (); - - if ($self->{label} eq 'active') { - if ($self->{result_values}->{panSessionMax} != 0) { - $total_options{total} = $self->{result_values}->{panSessionMax}; - $total_options{cast_int} = 1; - } - - $self->{output}->perfdata_add(label => $self->{label}, - nlabel => 'sessions.active.count', - value => $self->{result_values}->{panSessionActive}, - warning => defined($total_options{total}) ? $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options) : undef, - critical => defined($total_options{total}) ? $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options) : undef, - min => 0, max => $self->{result_values}->{panSessionMax}); - } else { - if ($self->{result_values}->{panVsysMaxSessions} != 0) { - $total_options{total} = $self->{result_values}->{panVsysMaxSessions}; - $total_options{cast_int} = 1; - } - - $self->{output}->perfdata_add(label => $self->{label}, - nlabel => $self->{result_values}->{display} . "#" . 'sessions.active.count', - value => $self->{result_values}->{panVsysActiveSessions}, - warning => defined($total_options{total}) ? $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options) : undef, - critical => defined($total_options{total}) ? $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options) : undef, - min => 0, max => $self->{result_values}->{panVsysMaxSessions}); - } -} - -sub custom_active_threshold { - my ($self, %options) = @_; - - my ($exit, $threshold_value) = ('ok'); - - if ($self->{label} eq 'active') { - if ($self->{result_values}->{panSessionMax} != 0) { - $threshold_value = $self->{result_values}->{active_prct}; - } - $exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => - [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-'. $self->{label}, exit_litteral => 'warning' } ]) if (defined($threshold_value)); - return $exit; - } else { - if ($self->{result_values}->{panVsysMaxSessions} != 0) { - $threshold_value = $self->{result_values}->{active_prct}; - } - $exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => - [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-'. $self->{label}, exit_litteral => 'warning' } ]) if (defined($threshold_value)); - return $exit; - } -} - -sub custom_active_output { - my ($self, %options) = @_; - - my $msg = ""; - if ($self->{label} eq 'active') { - $msg = sprintf("Active : %s (%s)", - $self->{result_values}->{panSessionActive}, - $self->{result_values}->{panSessionMax} != 0 ? $self->{result_values}->{active_prct} . " %" : - '-'); - } else { - $msg = sprintf("Active : %s (%s)", - $self->{result_values}->{panVsysActiveSessions}, - $self->{result_values}->{panVsysMaxSessions} != 0 ? $self->{result_values}->{active_prct} . " %" : - '-'); - } - return $msg; -} - -sub custom_active_calc { - my ($self, %options) = @_; - - $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; - $self->{result_values}->{panSessionActive} = $options{new_datas}->{$self->{instance} . '_panSessionActive'}; - $self->{result_values}->{panSessionMax} = $options{new_datas}->{$self->{instance} . '_panSessionMax'}; - $self->{result_values}->{panVsysActiveSessions} = $options{new_datas}->{$self->{instance} . '_panVsysActiveSessions'}; - $self->{result_values}->{panVsysMaxSessions} = $options{new_datas}->{$self->{instance} . '_panVsysMaxSessions'}; - $self->{result_values}->{active_prct} = 0; - - if ($self->{label} eq 'active') { - if ($self->{result_values}->{panSessionMax} != 0) { - $self->{result_values}->{active_prct} = $self->{result_values}->{panSessionActive} * 100 / $self->{result_values}->{panSessionMax}; - } - } else { - if ($self->{result_values}->{panVsysMaxSessions} != 0) { - $self->{result_values}->{active_prct} = $self->{result_values}->{panVsysActiveSessions} * 100 / $self->{result_values}->{panVsysMaxSessions}; - } - } - return 0; + return "Vsys '" . $options{instance_value}->{display} . "' sessions "; } sub new { @@ -233,7 +176,7 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - 'add-vsys' => { name => 'add_vsys' }, + 'add-vsys' => { name => 'add_vsys' }, }); return $self; @@ -241,56 +184,54 @@ sub new { my $mapping_sessions = { - panSessionMax => { oid => '.1.3.6.1.4.1.25461.2.1.2.3.2' }, - panSessionActive => { oid => '.1.3.6.1.4.1.25461.2.1.2.3.3' }, - panSessionActiveTcp => { oid => '.1.3.6.1.4.1.25461.2.1.2.3.4' }, - panSessionActiveUdp => { oid => '.1.3.6.1.4.1.25461.2.1.2.3.5' }, - panSessionActiveICMP => { oid => '.1.3.6.1.4.1.25461.2.1.2.3.6' }, - #panSessionActiveSslProxy => { oid => '.1.3.6.1.4.1.25461.2.1.2.3.7' }, Cannot get the max if 0... - panSessionSslProxyUtilization => { oid => '.1.3.6.1.4.1.25461.2.1.2.3.8' }, + sessions_max => { oid => '.1.3.6.1.4.1.25461.2.1.2.3.2' }, # panSessionMax + sessions_active => { oid => '.1.3.6.1.4.1.25461.2.1.2.3.3' }, # panSessionActive + panSessionActiveTcp => { oid => '.1.3.6.1.4.1.25461.2.1.2.3.4' }, + panSessionActiveUdp => { oid => '.1.3.6.1.4.1.25461.2.1.2.3.5' }, + panSessionActiveICMP => { oid => '.1.3.6.1.4.1.25461.2.1.2.3.6' }, + panSessionSslProxyUtilization => { oid => '.1.3.6.1.4.1.25461.2.1.2.3.8' } }; - my $mapping_vsys = { - panVsysName => { oid => '.1.3.6.1.4.1.25461.2.1.2.3.9.1.2' }, - panVsysActiveSessions => { oid => '.1.3.6.1.4.1.25461.2.1.2.3.9.1.4' }, - panVsysMaxSessions => { oid => '.1.3.6.1.4.1.25461.2.1.2.3.9.1.5' }, - panVsysActiveTcpCps => { oid => '.1.3.6.1.4.1.25461.2.1.2.3.9.1.6' }, - panVsysActiveUdpCps => { oid => '.1.3.6.1.4.1.25461.2.1.2.3.9.1.7' }, - panVsysActiveOtherIpCps => { oid => '.1.3.6.1.4.1.25461.2.1.2.3.9.1.8' }, + display => { oid => '.1.3.6.1.4.1.25461.2.1.2.3.9.1.2' }, # panVsysName + sessions_active => { oid => '.1.3.6.1.4.1.25461.2.1.2.3.9.1.4' }, # panVsysActiveSessions + sessions_max => { oid => '.1.3.6.1.4.1.25461.2.1.2.3.9.1.5' }, # panVsysMaxSessions + panVsysActiveTcpCps => { oid => '.1.3.6.1.4.1.25461.2.1.2.3.9.1.6' }, + panVsysActiveUdpCps => { oid => '.1.3.6.1.4.1.25461.2.1.2.3.9.1.7' }, + panVsysActiveOtherIpCps => { oid => '.1.3.6.1.4.1.25461.2.1.2.3.9.1.8' } }; sub add_vsys { my ($self, %options) = @_; my $oid_panVsysEntry = '.1.3.6.1.4.1.25461.2.1.2.3.9.1'; - $self->{results} = $options{snmp}->get_table(oid => $oid_panVsysEntry, - nothing_quit => 1); + my $snmp_result = $options{snmp}->get_table( + oid => $oid_panVsysEntry, + nothing_quit => 1 + ); - foreach my $oid (keys %{$self->{results}}) { + foreach my $oid (keys %$snmp_result) { next if $oid !~ /^$mapping_vsys->{panVsysName}->{oid}\.(.*)$/; my $instance = $1; - my $result = $options{snmp}->map_instance(mapping => $mapping_vsys, results => $self->{results}, instance => $instance); - - $self->{vsys}->{$result->{panVsysName}} = { - display => $result->{panVsysName}, - panVsysMaxSessions => defined($result->{panVsysMaxSessions}) ? $result->{panVsysMaxSessions} : 0, - panVsysActiveSessions => $result->{panVsysActiveSessions}, - panVsysActiveTcpCps => $result->{panVsysActiveTcpCps}, - panVsysActiveUdpCps => $result->{panVsysActiveUdpCps}, - }; - + my $result = $options{snmp}->map_instance(mapping => $mapping_vsys, results => $snmp_result, instance => $instance); + $self->{vsys}->{$result->{display}} = $result; + $self->{vsys}->{$result->{display}}->{sessions_max} = 0 if (!defined($result->{sessions_max})); + $self->{vsys}->{$result->{display}}->{sessions_active_prct} = $result->{sessions_active} * 100 / $self->{vsys}->{$result->{display}}->{sessions_max} + if ($self->{vsys}->{$result->{display}}->{sessions_max} != 0); } } sub manage_selection { my ($self, %options) = @_; - my $oid_panSession = '.1.3.6.1.4.1.25461.2.1.2.3'; - $self->{results} = $options{snmp}->get_table(oid => $oid_panSession, - nothing_quit => 1); - $self->{global} = $options{snmp}->map_instance(mapping => $mapping_sessions, results => $self->{results}, instance => '0'); - $self->{global}->{panSessionMax} = 0 if (!defined($self->{global}->{panSessionMax})); + my $snmp_result = $options{snmp}->get_leef( + oids => [ map($_->{oid} . '.0', values(%$mapping_sessions)) ], + nothing_quit => 1 + ); + $self->{global} = $options{snmp}->map_instance(mapping => $mapping_sessions, results => $snmp_result, instance => '0'); + $self->{global}->{sessions_max} = 0 if (!defined($self->{global}->{sessions_max})); + $self->{global}->{sessions_active_prct} = $self->{global}->{sessions_active} * 100 / $self->{global}->{sessions_max} + if ($self->{global}->{sessions_max} != 0); $self->add_vsys(snmp => $options{snmp}) if (defined($self->{option_results}->{add_vsys})); @@ -306,17 +247,11 @@ Check sessions. =over 8 -=item B<--warning-*> +=item B<--warning-*> B<--critical-*> -Threshold warning. -Global: 'active' (%), 'active-tcp', 'active-udp', 'active-icmp', 'active-ssl-proxy' (%). -Per vsys: 'active-vsys' (%), 'vsys-active-tcp' 'vsys-active-udp' 'vsys-active-other' - -=item B<--critical-*> - -Threshold critical. -Global: 'active' (%), 'active-tcp', 'active-udp', 'active-icmp', 'active-ssl-proxy' (%). -Per vsys: 'active-vsys' (%), 'vsys-active-tcp' 'vsys-active-udp' 'vsys-active-other' +Thresholds. +Global: 'active', 'active-prct', (%), 'active-tcp', 'active-udp', 'active-icmp', +Per vsys: 'vsys-active', 'vsys-active-prct' (%), 'vsys-active-tcp' 'vsys-active-udp' 'vsys-active-other'. =back From a3ff375f7c404fdf7543030a1e741ca741eaf650 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 27 Mar 2020 13:00:19 +0100 Subject: [PATCH 041/283] fix palo alto sessions --- network/paloalto/snmp/mode/sessions.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/network/paloalto/snmp/mode/sessions.pm b/network/paloalto/snmp/mode/sessions.pm index 9234c9e9b..157130103 100644 --- a/network/paloalto/snmp/mode/sessions.pm +++ b/network/paloalto/snmp/mode/sessions.pm @@ -210,7 +210,7 @@ sub add_vsys { ); foreach my $oid (keys %$snmp_result) { - next if $oid !~ /^$mapping_vsys->{panVsysName}->{oid}\.(.*)$/; + next if ($oid !~ /^$mapping_vsys->{display}->{oid}\.(.*)$/); my $instance = $1; my $result = $options{snmp}->map_instance(mapping => $mapping_vsys, results => $snmp_result, instance => $instance); From 1d55a188e026b69747642fa4d20d1ee650a6ea3d Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 27 Mar 2020 13:01:03 +0100 Subject: [PATCH 042/283] fix palo alto sessions --- network/paloalto/snmp/mode/sessions.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/network/paloalto/snmp/mode/sessions.pm b/network/paloalto/snmp/mode/sessions.pm index 157130103..78567fd68 100644 --- a/network/paloalto/snmp/mode/sessions.pm +++ b/network/paloalto/snmp/mode/sessions.pm @@ -148,7 +148,7 @@ sub set_counters { }, { label => 'vsys-active-other', nlabel => 'vsys.sessions.active.other.count', set => { key_values => [ { name => 'panVsysActiveOtherIpCps' }, { name => 'display' } ], - output_template => 'Other : %s', + output_template => 'other: %s', perfdatas => [ { label => 'active_other', value => 'panVsysActiveOtherIpCps_absolute', template => '%s', label_extra_instance => 1, min => 0 } From b5d699c0f2b5254c5f70b65e2f41aaae11976899 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 27 Mar 2020 15:10:40 +0100 Subject: [PATCH 043/283] typo + Fix #1894 --- database/mongodb/custom/driver.pm | 25 +++++------ database/mongodb/mode/collectionstatistics.pm | 13 +++--- database/mongodb/mode/connections.pm | 8 ++-- database/mongodb/mode/connectiontime.pm | 8 ++-- database/mongodb/mode/databasestatistics.pm | 15 +++---- database/mongodb/mode/queries.pm | 17 ++++---- database/mongodb/mode/replicationstatus.pm | 41 +++++++++---------- 7 files changed, 56 insertions(+), 71 deletions(-) diff --git a/database/mongodb/custom/driver.pm b/database/mongodb/custom/driver.pm index 1db7e0fe5..bb7306021 100644 --- a/database/mongodb/custom/driver.pm +++ b/database/mongodb/custom/driver.pm @@ -40,23 +40,24 @@ sub new { $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' }, - "protocol:s" => { name => 'protocol' }, - "username:s" => { name => 'username' }, - "password:s" => { name => 'password' }, - "timeout:s" => { name => 'timeout' }, - "ssl-opt:s@" => { name => 'ssl_opt' }, + 'hostname:s' => { name => 'hostname' }, + 'port:s' => { name => 'port' }, + 'protocol:s' => { name => 'protocol' }, + 'username:s' => { name => 'username' }, + 'password:s' => { name => 'password' }, + 'timeout:s' => { name => 'timeout' }, + 'ssl-opt:s@' => { name => 'ssl_opt' }, }); } + $options{options}->add_help(package => __PACKAGE__, sections => 'DRIVER OPTIONS', once => 1); $self->{output} = $options{output}; $self->{mode} = $options{mode}; - + return $self; } @@ -127,10 +128,10 @@ sub connect { $uri = $self->{protocol} . '://'; $uri .= $encoded_username . ':' . $encoded_password . '@' if ($encoded_username ne '' && $encoded_password ne ''); $uri .= $self->{hostname} if ($self->{hostname} ne ''); - $uri .= ':' . $self->{port} if ($self->{port} ne ''); + $uri .= ':' . $self->{port} if ($self->{port} ne '' && $self->{protocol} eq 'mongodb+srv'); $self->{output}->output_add(long_msg => 'Connection URI: ' . $uri, debug => 1); - + my $ssl = (defined($self->{ssl_opts})) ? $self->{ssl_opts} : 0; $self->{client} = MongoDB::MongoClient->new(host => $uri, ssl => $ssl); $self->{client}->connect(); @@ -163,7 +164,7 @@ sub run_command { if (!defined($self->{client})) { $self->connect(); } - + my $db = $self->{client}->get_database($options{database}); return $db->run_command($options{command}); } diff --git a/database/mongodb/mode/collectionstatistics.pm b/database/mongodb/mode/collectionstatistics.pm index 6001ba28a..7f6e54d7f 100644 --- a/database/mongodb/mode/collectionstatistics.pm +++ b/database/mongodb/mode/collectionstatistics.pm @@ -105,25 +105,22 @@ sub new { sub manage_selection { my ($self, %options) = @_; - - $self->{custom} = $options{custom}; + + my $databases = $options{custom}->list_databases(); $self->{databases} = {}; - - my $databases = $self->{custom}->list_databases(); - foreach my $database (sort @{$databases}) { next if (defined($self->{option_results}->{filter_database}) && $self->{option_results}->{filter_database} ne '' && $database !~ /$self->{option_results}->{filter_database}/); - my $collections = $self->{custom}->list_collections(database => $database); + my $collections = $options{custom}->list_collections(database => $database); $self->{databases}->{$database}->{display} = $database; foreach my $collection (sort @{$collections}) { - my $cl_stats = $self->{custom}->run_command( + my $cl_stats = $options{custom}->run_command( database => $database, - command => $self->{custom}->ordered_hash(collStats => $collection), + command => $options{custom}->ordered_hash(collStats => $collection), ); $self->{databases}->{$database}->{collections}->{$collection} = { diff --git a/database/mongodb/mode/connections.pm b/database/mongodb/mode/connections.pm index 82b07960c..54fd88821 100644 --- a/database/mongodb/mode/connections.pm +++ b/database/mongodb/mode/connections.pm @@ -88,14 +88,12 @@ sub new { sub manage_selection { my ($self, %options) = @_; - - $self->{custom} = $options{custom}; $self->{global} = {}; - my $server_stats = $self->{custom}->run_command( + my $server_stats = $options{custom}->run_command( database => 'admin', - command => $self->{custom}->ordered_hash(serverStatus => 1), + command => $options{custom}->ordered_hash(serverStatus => 1), ); $self->{global}->{active} = $server_stats->{connections}->{active}; @@ -103,7 +101,7 @@ sub manage_selection { $self->{global}->{usage} = $server_stats->{connections}->{current} / ($server_stats->{connections}->{current} + $server_stats->{connections}->{available}); $self->{global}->{totalCreated} = $server_stats->{connections}->{totalCreated}; - $self->{cache_name} = "mongodb_" . $self->{mode} . '_' . $self->{custom}->get_hostname() . '_' . $self->{custom}->get_port() . '_' . + $self->{cache_name} = "mongodb_" . $self->{mode} . '_' . $options{custom}->get_hostname() . '_' . $options{custom}->get_port() . '_' . (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); } diff --git a/database/mongodb/mode/connectiontime.pm b/database/mongodb/mode/connectiontime.pm index c291fffe6..fd3dee309 100644 --- a/database/mongodb/mode/connectiontime.pm +++ b/database/mongodb/mode/connectiontime.pm @@ -50,7 +50,7 @@ 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 => {}); return $self; @@ -58,13 +58,11 @@ sub new { sub manage_selection { my ($self, %options) = @_; - - $self->{custom} = $options{custom}; my $start = Time::HiRes::time(); - $self->{custom}->connect(); + $options{custom}->connect(); my $end = Time::HiRes::time(); - + $self->{global}->{connection_time} = ($end - $start) * 1000; } diff --git a/database/mongodb/mode/databasestatistics.pm b/database/mongodb/mode/databasestatistics.pm index 9a7a18e68..fd10ea8f7 100644 --- a/database/mongodb/mode/databasestatistics.pm +++ b/database/mongodb/mode/databasestatistics.pm @@ -115,29 +115,26 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - "filter-database:s" => { name => 'filter_database' }, + 'filter-database:s' => { name => 'filter_database' } }); return $self; } sub manage_selection { my ($self, %options) = @_; - - $self->{custom} = $options{custom}; + + my $databases = $options{custom}->list_databases(); $self->{databases} = {}; - - my $databases = $self->{custom}->list_databases(); - foreach my $database (sort @{$databases}) { next if (defined($self->{option_results}->{filter_database}) && $self->{option_results}->{filter_database} ne '' && $database !~ /$self->{option_results}->{filter_database}/); - my $db_stats = $self->{custom}->run_command( + my $db_stats = $options{custom}->run_command( database => $database, - command => $self->{custom}->ordered_hash('dbStats' => 1), + command => $options{custom}->ordered_hash(dbStats => 1), ); - + $self->{databases}->{$db_stats->{db}} = { display => $db_stats->{db}, collections => $db_stats->{collections}, diff --git a/database/mongodb/mode/queries.pm b/database/mongodb/mode/queries.pm index 125339420..fea4d56c0 100644 --- a/database/mongodb/mode/queries.pm +++ b/database/mongodb/mode/queries.pm @@ -28,11 +28,11 @@ use Digest::MD5 qw(md5_hex); sub set_counters { my ($self, %options) = @_; - + $self->{maps_counters_type} = [ { name => 'global', type => 0, cb_prefix_output => 'prefix_output' }, ]; - + $self->{maps_counters}->{global} = [ { label => 'total', nlabel => 'queries.total.persecond', set => { key_values => [ { name => 'total', diff => 1 } ], @@ -44,7 +44,7 @@ sub set_counters { } }, ]; - + foreach ('insert', 'query', 'update', 'delete', 'getmore', 'command') { push @{$self->{maps_counters}->{global}}, { label => $_, nlabel => 'queries.' . $_ . '.persecond', display_ok => 0, set => { @@ -71,7 +71,7 @@ sub set_counters { sub prefix_output { my ($self, %options) = @_; - return "Requests "; + return 'Requests '; } sub new { @@ -86,14 +86,11 @@ sub new { sub manage_selection { my ($self, %options) = @_; - - $self->{custom} = $options{custom}; $self->{global} = {}; - - my $server_stats = $self->{custom}->run_command( + my $server_stats = $options{custom}->run_command( database => 'admin', - command => $self->{custom}->ordered_hash(serverStatus => 1), + command => $options{custom}->ordered_hash(serverStatus => 1), ); foreach my $querie (keys %{$server_stats->{opcounters}}) { @@ -101,7 +98,7 @@ sub manage_selection { $self->{global}->{total} += $server_stats->{opcounters}->{$querie}; } - $self->{cache_name} = "mongodb_" . $self->{mode} . '_' . $self->{custom}->get_hostname() . '_' . $self->{custom}->get_port() . '_' . + $self->{cache_name} = 'mongodb_' . $self->{mode} . '_' . $options{custom}->get_hostname() . '_' . $options{custom}->get_port() . '_' . (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); } diff --git a/database/mongodb/mode/replicationstatus.pm b/database/mongodb/mode/replicationstatus.pm index 358bc7480..03ae69a14 100644 --- a/database/mongodb/mode/replicationstatus.pm +++ b/database/mongodb/mode/replicationstatus.pm @@ -41,7 +41,6 @@ sub custom_status_output { my $msg = sprintf("Current member state is '%s'", $self->{result_values}->{state}); $msg .= sprintf(", syncing to '%s'", $self->{result_values}->{sync_host}) if ($self->{result_values}->{state} ne 'PRIMARY'); - return $msg; } @@ -50,20 +49,18 @@ sub custom_status_calc { $self->{result_values}->{state} = $mapping_states{$options{new_datas}->{$self->{instance} . '_myState'}}; $self->{result_values}->{sync_host} = $options{new_datas}->{$self->{instance} . '_syncSourceHost'}; - return 0; } sub custom_member_status_output { my ($self, %options) = @_; - my $msg = sprintf("state is '%s' and health is '%s' [slave delay: %s] [priority: %s]", + return sprintf("state is '%s' and health is '%s' [slave delay: %s] [priority: %s]", $self->{result_values}->{state}, $self->{result_values}->{health}, $self->{result_values}->{slave_delay}, - $self->{result_values}->{priority}); - - return $msg; + $self->{result_values}->{priority} + ); } sub custom_member_status_calc { @@ -131,11 +128,12 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - "warning-status:s" => { name => 'warning_status', default => '' }, - "critical-status:s" => { name => 'critical_status', default => '' }, - "warning-member-status:s" => { name => 'warning_member_status', default => '%{state} !~ /PRIMARY|SECONDARY/' }, - "critical-member-status:s" => { name => 'critical_member_status', default => '%{health} !~ /up/' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '' }, + 'warning-member-status:s' => { name => 'warning_member_status', default => '%{state} !~ /PRIMARY|SECONDARY/' }, + 'critical-member-status:s' => { name => 'critical_member_status', default => '%{health} !~ /up/' }, }); + return $self; } @@ -143,18 +141,18 @@ sub check_options { my ($self, %options) = @_; $self->SUPER::check_options(%options); - $self->change_macros(macros => ['warning_status', 'critical_status', - 'warning_member_status', 'critical_member_status']); + $self->change_macros(macros => [ + 'warning_status', 'critical_status', + 'warning_member_status', 'critical_member_status' + ]); } sub manage_selection { my ($self, %options) = @_; - - $self->{custom} = $options{custom}; - my $ismaster = $self->{custom}->run_command( + my $ismaster = $options{custom}->run_command( database => 'admin', - command => $self->{custom}->ordered_hash('ismaster' => 1), + command => $options{custom}->ordered_hash(ismaster => 1), ); if (!defined($ismaster->{me})) { @@ -164,10 +162,9 @@ sub manage_selection { $self->{global} = {}; $self->{members} = {}; - - my $repl_conf = $self->{custom}->run_command( + my $repl_conf = $options{custom}->run_command( database => 'admin', - command => $self->{custom}->ordered_hash('replSetGetConfig' => 1), + command => $options{custom}->ordered_hash(replSetGetConfig => 1), ); my %config; @@ -175,9 +172,9 @@ sub manage_selection { $config{$member->{host}} = { priority => $member->{priority}, slaveDelay => $member->{slaveDelay} } } - my $repl_status = $self->{custom}->run_command( + my $repl_status = $options{custom}->run_command( database => 'admin', - command => $self->{custom}->ordered_hash('replSetGetStatus' => 1), + command => $options{custom}->ordered_hash(replSetGetStatus => 1), ); $self->{global}->{myState} = $repl_status->{myState}; @@ -191,7 +188,7 @@ sub manage_selection { health => $member->{health}, optimeDate => $member->{optime}->{ts}->{seconds}, slaveDelay => $config{$member->{name}}->{slaveDelay}, - priority => $config{$member->{name}}->{priority}, + priority => $config{$member->{name}}->{priority} } } From 94e59ab787824508584c0c4a3439fff126267912 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 27 Mar 2020 15:11:08 +0100 Subject: [PATCH 044/283] Fix #1894 --- database/mongodb/custom/driver.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/mongodb/custom/driver.pm b/database/mongodb/custom/driver.pm index bb7306021..cc9016c84 100644 --- a/database/mongodb/custom/driver.pm +++ b/database/mongodb/custom/driver.pm @@ -128,7 +128,7 @@ sub connect { $uri = $self->{protocol} . '://'; $uri .= $encoded_username . ':' . $encoded_password . '@' if ($encoded_username ne '' && $encoded_password ne ''); $uri .= $self->{hostname} if ($self->{hostname} ne ''); - $uri .= ':' . $self->{port} if ($self->{port} ne '' && $self->{protocol} eq 'mongodb+srv'); + $uri .= ':' . $self->{port} if ($self->{port} ne '' && $self->{protocol} ne 'mongodb+srv'); $self->{output}->output_add(long_msg => 'Connection URI: ' . $uri, debug => 1); From aaeb47266fae11637f86667a40dcd8c6b008ae4f Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 27 Mar 2020 15:42:15 +0100 Subject: [PATCH 045/283] Fix #1885 --- network/paloalto/ssh/mode/system.pm | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/network/paloalto/ssh/mode/system.pm b/network/paloalto/ssh/mode/system.pm index 0b72030b2..2cc828ac1 100644 --- a/network/paloalto/ssh/mode/system.pm +++ b/network/paloalto/ssh/mode/system.pm @@ -117,6 +117,7 @@ sub new { $options{options}->add_options(arguments => { 'warning-status:s' => { name => 'warning_status', default => '' }, 'critical-status:s' => { name => 'critical_status', default => '%{oper_mode} !~ /normal/i' }, + 'timezone:s' => { name => 'timezone' } }); return $self; @@ -127,6 +128,7 @@ sub check_options { $self->SUPER::check_options(%options); $self->change_macros(macros => ['warning_status', 'critical_status']); + $self->{option_results}->{timezone} = 'GMT' if (!defined($self->{option_results}->{timezone}) || $self->{option_results}->{timezone} eq ''); } sub get_diff_time { @@ -135,10 +137,7 @@ sub get_diff_time { # '2019/10/15 12:03:58 BST' return if ($options{time} !~ /^\s*(\d{4})\/(\d{2})\/(\d{2})\s+(\d+):(\d+):(\d+)\s+(\S+)/); - my $tz = $7; - $tz = 'GMT' if ($tz eq 'BST'); - $tz = 'Europe/Paris' if ($tz eq 'CEST'); - $tz = 'America/New_York' if ($tz eq 'EST'); + my $tz = centreon::plugins::misc::set_timezone(name => $self->{option_results}->{timezone}); my $dt = DateTime->new( year => $1, month => $2, @@ -146,7 +145,7 @@ sub get_diff_time { hour => $4, minute => $5, second => $6, - time_zone => $tz + %$tz ); return (time() - $dt->epoch); } @@ -198,6 +197,10 @@ Check system. Only display some counters (regexp can be used). Example: --filter-counters='^status$' +=item B<--timezone> + +Timezone options. Default is 'GMT'. + =item B<--warning-status> Set warning threshold for status (Default: ''). From ca32fb0859c0487a9e0ff01902a3389208c92ee0 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 27 Mar 2020 15:54:59 +0100 Subject: [PATCH 046/283] fix synology ha --- storage/synology/snmp/mode/ha.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/synology/snmp/mode/ha.pm b/storage/synology/snmp/mode/ha.pm index 799a0ae92..5987e5b6b 100644 --- a/storage/synology/snmp/mode/ha.pm +++ b/storage/synology/snmp/mode/ha.pm @@ -51,7 +51,7 @@ sub set_counters { { name => 'cluster_status' }, { name => 'heartbeat_status' }, { name => 'active_node_name' }, { name => 'passive_node_name' } ], - closure_custom_calc => \&catalog_status_threshold, + closure_custom_calc => \&catalog_status_calc, closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, closure_custom_threshold_check => \&catalog_status_threshold From 827bf6a26f288133ad26f43e2c133b53462b54c4 Mon Sep 17 00:00:00 2001 From: UrBnW <40244829+UrBnW@users.noreply.github.com> Date: Sat, 28 Mar 2020 14:43:00 +0100 Subject: [PATCH 047/283] MikroTik, add proper disk mode --- network/mikrotik/snmp/mode/disk.pm | 104 +++++++++++++++++++++++++++ network/mikrotik/snmp/mode/memory.pm | 4 +- network/mikrotik/snmp/plugin.pm | 1 + 3 files changed, 107 insertions(+), 2 deletions(-) create mode 100644 network/mikrotik/snmp/mode/disk.pm diff --git a/network/mikrotik/snmp/mode/disk.pm b/network/mikrotik/snmp/mode/disk.pm new file mode 100644 index 000000000..edbd7e6a0 --- /dev/null +++ b/network/mikrotik/snmp/mode/disk.pm @@ -0,0 +1,104 @@ +# +# Copyright 2020 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 network::mikrotik::snmp::mode::disk; + +use base qw(snmp_standard::mode::storage); + +use strict; +use warnings; + +sub default_storage_type { + my ($self, %options) = @_; + + return '^(?!(hrStorageRam)$)'; +} + +sub prefix_storage_output { + my ($self, %options) = @_; + + return "Disk '" . $options{instance_value}->{display} . "' "; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + return $self; +} + +1; + +__END__ + +=head1 MODE + +Check memory. + +=over 8 + +=item B<--warning-usage> + +Threshold warning. + +=item B<--critical-usage> + +Threshold critical. + +=item B<--units> + +Units of thresholds (Default: '%') ('%', 'B'). + +=item B<--free> + +Thresholds are on free space left. + +=item B<--storage> + +Set the storage (number expected) ex: 1, 2,... (empty means 'check all storage'). + +=item B<--name> + +Allows to use storage name with option --storage instead of storage oid index. + +=item B<--regexp> + +Allows to use regexp to filter storage (with option --name). + +=item B<--regexp-isensitive> + +Allows to use regexp non case-sensitive (with --regexp). + +=item B<--reload-cache-time> + +Time in minutes before reloading cache file (default: 180). + +=item B<--show-cache> + +Display cache storage datas. + +=item B<--filter-storage-type> + +Filter storage types with a regexp (Default: '^(?!(hrStorageRam)$)'). + +=back + +=cut diff --git a/network/mikrotik/snmp/mode/memory.pm b/network/mikrotik/snmp/mode/memory.pm index dc451ef33..fccdc8808 100644 --- a/network/mikrotik/snmp/mode/memory.pm +++ b/network/mikrotik/snmp/mode/memory.pm @@ -28,7 +28,7 @@ use warnings; sub default_storage_type { my ($self, %options) = @_; - return '^(hrStorageRam|hrStorageFlashMemory)'; + return '^hrStorageRam$'; } sub prefix_storage_output { @@ -97,7 +97,7 @@ Display cache storage datas. =item B<--filter-storage-type> -Filter storage types with a regexp (Default: '^(hrStorageRam|hrStorageFlashMemory)$'). +Filter storage types with a regexp (Default: '^hrStorageRam$'). =back diff --git a/network/mikrotik/snmp/plugin.pm b/network/mikrotik/snmp/plugin.pm index b45557fa1..d79b3eb55 100644 --- a/network/mikrotik/snmp/plugin.pm +++ b/network/mikrotik/snmp/plugin.pm @@ -32,6 +32,7 @@ sub new { $self->{version} = '1.0'; %{$self->{modes}} = ( 'cpu' => 'snmp_standard::mode::cpu', + 'disk' => 'network::mikrotik::snmp::mode::disk', 'environment' => 'network::mikrotik::snmp::mode::environment', 'interfaces' => 'network::mikrotik::snmp::mode::interfaces', 'list-interfaces' => 'snmp_standard::mode::listinterfaces', From 2bcd197c44b86ecb77207c0752f4b96709ff2605 Mon Sep 17 00:00:00 2001 From: UrBnW <40244829+UrBnW@users.noreply.github.com> Date: Sat, 28 Mar 2020 14:50:33 +0100 Subject: [PATCH 048/283] Typo --- network/mikrotik/snmp/mode/disk.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/network/mikrotik/snmp/mode/disk.pm b/network/mikrotik/snmp/mode/disk.pm index edbd7e6a0..da39790de 100644 --- a/network/mikrotik/snmp/mode/disk.pm +++ b/network/mikrotik/snmp/mode/disk.pm @@ -51,7 +51,7 @@ __END__ =head1 MODE -Check memory. +Check disk. =over 8 From 7f76750ba58df6f0fccd770c1695bbd1b13b9f75 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 30 Mar 2020 16:03:22 +0200 Subject: [PATCH 049/283] add wan3g cisco standard snmp mode --- .../common/cisco/standard/snmp/mode/wan3g.pm | 439 ++++++++++++++++++ network/cisco/standard/snmp/plugin.pm | 35 +- 2 files changed, 457 insertions(+), 17 deletions(-) create mode 100644 centreon/common/cisco/standard/snmp/mode/wan3g.pm diff --git a/centreon/common/cisco/standard/snmp/mode/wan3g.pm b/centreon/common/cisco/standard/snmp/mode/wan3g.pm new file mode 100644 index 000000000..15d8b8d34 --- /dev/null +++ b/centreon/common/cisco/standard/snmp/mode/wan3g.pm @@ -0,0 +1,439 @@ +# +# Copyright 2020 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 centreon::common::cisco::standard::snmp::mode::wan3g; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); +use Digest::MD5 qw(md5_hex); + +sub custom_connection_status_output { + my ($self, %options) = @_; + + return sprintf( + 'connection status: %s', + $self->{result_values}->{connection_status} + ); +} + +sub custom_sim_status_output { + my ($self, %options) = @_; + + return sprintf( + 'sim status: %s', + $self->{result_values}->{sim_status} + ); +} + +sub custom_modem_status_output { + my ($self, %options) = @_; + + return sprintf( + 'modem status: %s', + $self->{result_values}->{modem_status} + ); +} + +sub custom_radio_status_output { + my ($self, %options) = @_; + + return sprintf( + 'current band: %s [channel number: %s]', + $self->{result_values}->{current_band}, + $self->{result_values}->{channel_number} + ); +} + +sub custom_network_status_output { + my ($self, %options) = @_; + + return sprintf( + 'service status: %s', + $self->{result_values}->{service_status} + ); +} + + +sub modem_long_output { + my ($self, %options) = @_; + + return "checking module '" . $options{instance_value}->{display} . "'"; +} + +sub prefix_modem_output { + my ($self, %options) = @_; + + return "module '" . $options{instance_value}->{display} . "' "; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'modem', type => 3, cb_prefix_output => 'prefix_modem_output', cb_long_output => 'modem_long_output', + indent_long_output => ' ', message_multiple => 'All cellular modems are ok', + group => [ + { name => 'global', type => 0, skipped_code => { -10 => 1 } }, + { name => 'radio', type => 0, skipped_code => { -10 => 1 } }, + { name => 'network', type => 0, skipped_code => { -10 => 1 } } + ] + } + ]; + + $self->{maps_counters}->{global} = [ + { label => 'modem-status', threshold => 0, set => { + key_values => [ { name => 'modem_status' }, { name => 'display' } ], + closure_custom_calc => \&catalog_status_calc, + closure_custom_output => $self->can('custom_modem_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold + } + }, + { label => 'connection-status', threshold => 0, set => { + key_values => [ { name => 'connection_status' }, { name => 'display' } ], + closure_custom_calc => \&catalog_status_calc, + closure_custom_output => $self->can('custom_connection_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold + } + }, + { label => 'sim-status', threshold => 0, set => { + key_values => [ { name => 'sim_status' }, { name => 'display' } ], + closure_custom_calc => \&catalog_status_calc, + closure_custom_output => $self->can('custom_sim_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold + } + }, + { label => 'temperature', nlabel => 'modem.temperature.celsius', display_ok => 0, set => { + key_values => [ { name => 'temperature' }, { name => 'display' } ], + output_template => 'memory used: %s%s', + output_change_bytes => 1, + perfdatas => [ + { value => 'temperature_absolute', template => '%s', min => 0, + unit => 'C', label_extra_instance => 1, instance_use => 'display_absolute' } + ] + } + } + ]; + + $self->{maps_counters}->{radio} = [ + { label => 'radio-status', threshold => 0, set => { + key_values => [ { name => 'current_band' }, { name => 'channel_number' }, { name => 'display' } ], + closure_custom_calc => \&catalog_status_calc, + closure_custom_output => $self->can('custom_radio_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold + } + }, + { label => 'radio-rssi', nlabel => 'modem.radio.rssi.dbm', set => { + key_values => [ { name => 'rssi' }, { name => 'display' } ], + output_template => 'received signal strength: %s dBm', + output_change_bytes => 1, + perfdatas => [ + { value => 'rssi_absolute', template => '%s', min => 0, + unit => 'dBm', label_extra_instance => 1, instance_use => 'display_absolute' } + ] + } + } + ]; + + $self->{maps_counters}->{network} = [ + { label => 'network-status', threshold => 0, set => { + key_values => [ { name => 'service_status' }, { name => 'display' } ], + closure_custom_calc => \&catalog_status_calc, + closure_custom_output => $self->can('custom_network_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold + } + }, + { label => 'traffic-in', nlabel => 'modem.traffic.in.bitspersecond', set => { + key_values => [ { name => 'traffic_in', diff => 1 }, { name => 'display' } ], + output_template => 'traffic in: %s%s/s', + per_second => 1, output_change_bytes => 2, + perfdatas => [ + { value => 'traffic_in_per_second', template => '%s', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' } + ] + } + }, + { label => 'traffic-out', nlabel => 'modem.traffic.out.bitspersecond', set => { + key_values => [ { name => 'traffic_out', diff => 1 }, { name => 'display' } ], + output_template => 'traffic out: %s%s/s', + per_second => 1, output_change_bytes => 2, + perfdatas => [ + { value => 'traffic_out_per_second', template => '%s', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' } + ] + } + } + ]; +} + +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 => { + 'filter-name:s' => { name => 'filter_name' }, + 'unknown-modem-status:s' => { name => 'unknown_modem_status', default => '%{modem_status} =~ /unknown/i' }, + 'warning-modem-status:s' => { name => 'warning_modem_status', default => '%{modem_status} =~ /lowPowerMode/i' }, + 'critical-modem-status:s' => { name => 'critical_modem_status', default => '%{modem_status} =~ /offLine/i' }, + 'unknown-connection-status:s' => { name => 'unknown_connection_status', default => '%{connection_status} =~ /unknown/i' }, + 'warning-connection-status:s' => { name => 'warning_connection_status', default => '' }, + 'critical-connection-status:s' => { name => 'critical_connection_status', default => '%{connection_status} =~ /inactive|idle|disconnected|error/i' }, + 'unknown-sim-status:s' => { name => 'unknown_sim_status', default => '%{sim_status} =~ /unknown/i' }, + 'warning-sim-status:s' => { name => 'warning_sim_status', default => '' }, + 'critical-sim-status:s' => { name => 'critical_sim_status', default => '%{sim_status} !~ /ok|unknown/i' }, + 'unknown-radio-status:s' => { name => 'unknown_radio_status', default => '%{current_band} =~ /unknown/i' }, + 'warning-radio-status:s' => { name => 'warning_radio_status', default => '' }, + 'critical-radio-status:s' => { name => 'critical_radio_status', default => '%{current_band} =~ /invalid|none/i' }, + 'unknown-network-status:s' => { name => 'unknown_network_status', default => '%{service_status} =~ /unknown/i' }, + 'warning-network-status:s' => { name => 'warning_network_status', default => '' }, + 'critical-network-status:s' => { name => 'critical_network_status', default => '%{service_status} =~ /emergencyOnly|noService/i' } + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->change_macros( + macros => [ + 'unknown_modem_status', 'warning_modem_status', 'critical_modem_status', + 'unknown_connection_status', 'warning_connection_status', 'critical_connection_status', + 'unknown_sim_status', 'warning_sim_status', 'critical_sim_status', + 'unknown_radio_status', 'warning_radio_status', 'critical_radio_status', + 'unknown_network_status', 'warning_network_status', 'critical_network_status', + ] + ); +} + +my $map_current_band = { + 1 => 'unknown', 2 => 'invalid', 3 => 'none', + 4 => 'gsm850', 5 => 'gsm900', 6 => 'gsm1800', + 7 => 'gsm1900', 8 => 'wcdma800', 9 => 'wcdma850', + 10 => 'wcdma1900', 11 => 'wcdma2100', 12 => 'lteBand' +}; +my $map_modem_status = { + 1 => 'unknown', 2 => 'offLine', 3 => 'onLine', 4 => 'lowPowerMode' +}; +my $map_connection_status = { + 1 => 'unknown', 2 => 'error', 3 => 'connecting', + 4 => 'dormant', 5 => 'connected', 6 => 'disconnected', + 7 => 'idle', 8 => 'active', 9 => 'inactive' +}; +my $map_sim_status = { + 1 => 'unknown', 2 => 'ok', 3 => 'notInserted', + 4 => 'removed', 5 => 'initFailure', 6 => 'generalFailure', + 7 => 'locked', 8 => 'chv1Blocked', 9 => 'chv2Blocked', + 10 => 'chv1Rejected', 11 => 'chv2Rejected', + 12 => 'mepLocked', 13 => 'networkRejected' +}; +my $map_service_status = { + 1 => 'unknown', 2 => 'noService', + 3 => 'normal', 4 => 'emergencyOnly' +}; + +my $mapping = { + rssi => { oid => '.1.3.6.1.4.1.9.9.661.1.3.4.1.1.1' }, # c3gCurrentGsmRssi + current_band => { oid => '.1.3.6.1.4.1.9.9.661.1.3.4.1.1.3', map => $map_current_band }, # c3gGsmCurrentBand + channel_number => { oid => '.1.3.6.1.4.1.9.9.661.1.3.4.1.1.4' }, # c3gGsmChannelNumber + modem_status => { oid => '.1.3.6.1.4.1.9.9.661.1.3.1.1.6', map => $map_modem_status }, # c3gModemStatus + temperature => { oid => '.1.3.6.1.4.1.9.9.661.1.1.1.12' }, # c3gModemTemperature + connection_status => { oid => '.1.3.6.1.4.1.9.9.661.1.3.1.1.6', map => $map_connection_status }, # c3gConnectionStatus + sim_status => { oid => '.1.3.6.1.4.1.9.9.661.1.3.5.1.1.2', map => $map_sim_status }, # c3gGsmSimStatus + service_status => { oid => '.1.3.6.1.4.1.9.9.661.1.3.2.1.2', map => $map_service_status }, # c3gGsmCurrentServiceStatus + traffic_out => { oid => '.1.3.6.1.4.1.9.9.661.1.3.2.1.19' }, # c3gGsmTotalByteTransmitted + traffic_in => { oid => '.1.3.6.1.4.1.9.9.661.1.3.2.1.20' }, # c3gGsmTotalByteReceived +}; + +sub manage_selection { + my ($self, %options) = @_; + + my $oid_entPhysicalName = '.1.3.6.1.2.1.47.1.1.1.1.7'; + my $snmp_result = $options{snmp}->get_table( + oid => $mapping->{connection_status}->{oid}, + nothing_quit => 1 + ); + + my $instances = []; + foreach (keys %$snmp_result) { + /\.(\d+)$/; + push @$instances, $1; + } + + $options{snmp}->load( + oids => [ $oid_entPhysicalName ], + instances => $instances, + instance_regexp => '^(.*)$' + ); + $snmp_result = $options{snmp}->get_leef(); + + $self->{modem} = {}; + foreach (keys %$snmp_result) { + /\.(\d+)$/; + my $instance = $1; + my $name = $snmp_result->{$_}; + + 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 module '" . $name . "'.", debug => 1); + next; + } + + $self->{modem}->{$instance} = { + display => $name, + global => { display => $name }, + radio => { display => $name }, + network => { display => $name } + }; + } + + return if (scalar(keys %{$self->{modem}}) <= 0); + + $options{snmp}->load( + oids => [ map($_->{oid}, values(%$mapping)) ], + instances => [ keys %{$self->{modem}} ], + instance_regexp => '^(.*)$' + ); + $snmp_result = $options{snmp}->get_leef(); + foreach (keys %{$self->{modem}}) { + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $_); + $self->{modem}->{$_}->{global}->{modem_status} = $result->{modem_status}; + $self->{modem}->{$_}->{global}->{connection_status} = $result->{connection_status}; + $self->{modem}->{$_}->{global}->{sim_status} = $result->{sim_status}; + $self->{modem}->{$_}->{global}->{temperature} = $result->{temperature}; + $self->{modem}->{$_}->{radio}->{current_band} = $result->{current_band}; + $self->{modem}->{$_}->{radio}->{channel_number} = $result->{channel_number}; + $self->{modem}->{$_}->{radio}->{rssi} = $result->{rssi}; + $self->{modem}->{$_}->{network}->{traffic_in} = $result->{traffic_in}; + $self->{modem}->{$_}->{network}->{traffic_out} = $result->{traffic_out}; + $self->{modem}->{$_}->{network}->{service_status} = $result->{service_status}; + } + + $self->{cache_name} = 'cisco_standard_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' . + (defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')); +} + +1; + +__END__ + +=head1 MODE + +Check cellular 3G and 4G LTE WAN. + +=over 8 + +=item B<--filter-name> + +Filter by name (can be a regexp). + +=item B<--unknown-modem-status> + +Set unknown threshold for status (Default: '%{modem_status} =~ /unknown/i'). +Can used special variables like: %{modem_status}, %{display} + +=item B<--warning-modem-status> + +Set warning threshold for status (Default: '%{modem_status} =~ /lowPowerMode/i'). +Can used special variables like: %{modem_status}, %{display} + +=item B<--critical-modem-status> + +Set critical threshold for status (Default: '%{modem_status} =~ /offLine/i'). +Can used special variables like: %{modem_status}, %{display} + +=item B<--unknown-connection-status> + +Set unknown threshold for status (Default: '%{connection_status} =~ /unknown/i'). +Can used special variables like: %{connection_status}, %{display} + +=item B<--warning-connection-status> + +Set warning threshold for status. +Can used special variables like: %{connection_status}, %{display} + +=item B<--critical-connection-status> + +Set critical threshold for status (Default: '%{connection_status} =~ /inactive|idle|disconnected|error/i'). +Can used special variables like: %{connection_status}, %{display} + +=item B<--unknown-sim-status> + +Set unknown threshold for status (Default: '%{sim_status} =~ /unknown/i'). +Can used special variables like: %{sim_status}, %{display} + +=item B<--warning-sim-status> + +Set warning threshold for status. +Can used special variables like: %{sim_status}, %{display} + +=item B<--critical-sim-status> + +Set critical threshold for status (Default: '%{sim_status} !~ /ok|unknown/i'). +Can used special variables like: %{sim_status}, %{display} + +=item B<--unknown-radio-status> + +Set unknown threshold for status (Default: '%{current_band} =~ /unknown/i'). +Can used special variables like: %{current_band}, %{channel_number}, %{display} + +=item B<--warning-radio-status> + +Set warning threshold for status. +Can used special variables like: %{current_band}, %{channel_number}, %{display} + +=item B<--critical-radio-status> + +Set critical threshold for status (Default: '%{current_band} =~ /invalid|none/i'). +Can used special variables like: %{current_band}, %{channel_number}, %{display} + +=item B<--unknown-network-status> + +Set unknown threshold for status (Default: '%{service_status} =~ /unknown/i'). +Can used special variables like: %{service_status}, %{display} + +=item B<--warning-network-status> + +Set warning threshold for status. +Can used special variables like: %{service_status}, %{display} + +=item B<--critical-network-status> + +Set critical threshold for status (Default: '%{service_status} =~ /emergencyOnly|noService/i'). +Can used special variables like: %{service_status}, %{display} + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'temperature', 'traffic-in', 'traffic-out'. + +=back + +=cut diff --git a/network/cisco/standard/snmp/plugin.pm b/network/cisco/standard/snmp/plugin.pm index 61e9bf9c7..af5301c7e 100644 --- a/network/cisco/standard/snmp/plugin.pm +++ b/network/cisco/standard/snmp/plugin.pm @@ -31,23 +31,24 @@ sub new { $self->{version} = '1.0'; %{$self->{modes}} = ( - 'arp' => 'snmp_standard::mode::arp', - 'configuration' => 'centreon::common::cisco::standard::snmp::mode::configuration', - 'cpu' => 'centreon::common::cisco::standard::snmp::mode::cpu', - 'environment' => 'centreon::common::cisco::standard::snmp::mode::environment', - 'hsrp' => 'centreon::common::cisco::standard::snmp::mode::hsrp', - 'interfaces' => 'centreon::common::cisco::standard::snmp::mode::interfaces', - 'ipsla' => 'centreon::common::cisco::standard::snmp::mode::ipsla', - 'list-interfaces' => 'snmp_standard::mode::listinterfaces', - 'list-spanning-trees' => 'snmp_standard::mode::listspanningtrees', - 'load' => 'centreon::common::cisco::standard::snmp::mode::load', - 'memory' => 'centreon::common::cisco::standard::snmp::mode::memory', - 'memory-flash' => 'centreon::common::cisco::standard::snmp::mode::memoryflash', - 'qos-usage' => 'centreon::common::cisco::standard::snmp::mode::qosusage', - 'spanning-tree' => 'snmp_standard::mode::spanningtree', - 'stack' => 'centreon::common::cisco::standard::snmp::mode::stack', - 'uptime' => 'snmp_standard::mode::uptime', - 'voice-call' => 'centreon::common::cisco::standard::snmp::mode::voicecall', + 'arp' => 'snmp_standard::mode::arp', + 'configuration' => 'centreon::common::cisco::standard::snmp::mode::configuration', + 'cpu' => 'centreon::common::cisco::standard::snmp::mode::cpu', + 'environment' => 'centreon::common::cisco::standard::snmp::mode::environment', + 'hsrp' => 'centreon::common::cisco::standard::snmp::mode::hsrp', + 'interfaces' => 'centreon::common::cisco::standard::snmp::mode::interfaces', + 'ipsla' => 'centreon::common::cisco::standard::snmp::mode::ipsla', + 'list-interfaces' => 'snmp_standard::mode::listinterfaces', + 'list-spanning-trees' => 'snmp_standard::mode::listspanningtrees', + 'load' => 'centreon::common::cisco::standard::snmp::mode::load', + 'memory' => 'centreon::common::cisco::standard::snmp::mode::memory', + 'memory-flash' => 'centreon::common::cisco::standard::snmp::mode::memoryflash', + 'qos-usage' => 'centreon::common::cisco::standard::snmp::mode::qosusage', + 'spanning-tree' => 'snmp_standard::mode::spanningtree', + 'stack' => 'centreon::common::cisco::standard::snmp::mode::stack', + 'uptime' => 'snmp_standard::mode::uptime', + 'voice-call' => 'centreon::common::cisco::standard::snmp::mode::voicecall', + 'wan3g' => 'centreon::common::cisco::standard::snmp::mode::wan3g' ); return $self; From c30c28236440c3f49f2176da993d92a2c7a6029a Mon Sep 17 00:00:00 2001 From: Simon Bomm Date: Tue, 31 Mar 2020 10:19:45 +0200 Subject: [PATCH 050/283] fix(plugin) use the good c3gConnectionStatus OID --- centreon/common/cisco/standard/snmp/mode/wan3g.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/centreon/common/cisco/standard/snmp/mode/wan3g.pm b/centreon/common/cisco/standard/snmp/mode/wan3g.pm index 15d8b8d34..da72efd56 100644 --- a/centreon/common/cisco/standard/snmp/mode/wan3g.pm +++ b/centreon/common/cisco/standard/snmp/mode/wan3g.pm @@ -264,7 +264,7 @@ my $mapping = { channel_number => { oid => '.1.3.6.1.4.1.9.9.661.1.3.4.1.1.4' }, # c3gGsmChannelNumber modem_status => { oid => '.1.3.6.1.4.1.9.9.661.1.3.1.1.6', map => $map_modem_status }, # c3gModemStatus temperature => { oid => '.1.3.6.1.4.1.9.9.661.1.1.1.12' }, # c3gModemTemperature - connection_status => { oid => '.1.3.6.1.4.1.9.9.661.1.3.1.1.6', map => $map_connection_status }, # c3gConnectionStatus + connection_status => { oid => '.1.3.6.1.4.1.9.9.661.1.1.1.8', map => $map_connection_status }, # c3gConnectionStatus sim_status => { oid => '.1.3.6.1.4.1.9.9.661.1.3.5.1.1.2', map => $map_sim_status }, # c3gGsmSimStatus service_status => { oid => '.1.3.6.1.4.1.9.9.661.1.3.2.1.2', map => $map_service_status }, # c3gGsmCurrentServiceStatus traffic_out => { oid => '.1.3.6.1.4.1.9.9.661.1.3.2.1.19' }, # c3gGsmTotalByteTransmitted From 4e88d5eaac06428312dd136e6d389c256b6495f1 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 31 Mar 2020 10:38:37 +0200 Subject: [PATCH 051/283] use bigint for qos usage --- .../cisco/standard/snmp/mode/qosusage.pm | 133 +++++++++--------- 1 file changed, 70 insertions(+), 63 deletions(-) diff --git a/centreon/common/cisco/standard/snmp/mode/qosusage.pm b/centreon/common/cisco/standard/snmp/mode/qosusage.pm index b130f73dc..55f357544 100644 --- a/centreon/common/cisco/standard/snmp/mode/qosusage.pm +++ b/centreon/common/cisco/standard/snmp/mode/qosusage.pm @@ -25,6 +25,7 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; use Digest::MD5 qw(md5_hex); +use bigint; sub set_counters { my ($self, %options) = @_; @@ -32,7 +33,7 @@ sub set_counters { $self->{maps_counters_type} = [ { name => 'total', type => 0 }, { name => 'interface_classmap', type => 1, cb_prefix_output => 'prefix_intcmap_output', message_multiple => 'All interface classmaps are ok' }, - { name => 'classmap', type => 1, cb_prefix_output => 'prefix_cmap_output', message_multiple => 'All classmaps are ok' }, + { name => 'classmap', type => 1, cb_prefix_output => 'prefix_cmap_output', message_multiple => 'All classmaps are ok' } ]; $self->{maps_counters}->{interface_classmap} = [ @@ -42,7 +43,7 @@ sub set_counters { closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_output => $self->can('custom_traffic_output'), closure_custom_perfdata => $self->can('custom_traffic_perfdata'), - closure_custom_threshold_check => $self->can('custom_traffic_threshold'), + closure_custom_threshold_check => $self->can('custom_traffic_threshold') } }, { label => 'int-cmap-drop', set => { @@ -51,10 +52,10 @@ sub set_counters { output_template => 'Drop : %s %s/s', perfdatas => [ { label => 'icmap_drop', value => 'drop_usage_per_second', template => '%d', - unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, - ], + unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' } + ] } - }, + } ]; $self->{maps_counters}->{classmap} = [ { label => 'cmap-traffic', set => { @@ -63,8 +64,8 @@ sub set_counters { output_template => 'Traffic : %s %s/s', perfdatas => [ { label => 'cmap_traffic', value => 'traffic_usage_per_second', template => '%d', - unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, - ], + unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' } + ] } }, { label => 'cmap-drop', set => { @@ -73,11 +74,12 @@ sub set_counters { output_template => 'Drop : %s %s/s', perfdatas => [ { label => 'cmap_drop', value => 'drop_usage_per_second', template => '%d', - unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, - ], + unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' } + ] } - }, + } ]; + $self->{maps_counters}->{total} = [ { label => 'total-traffic', set => { key_values => [ { name => 'traffic_usage', diff => 1 } ], @@ -85,8 +87,8 @@ sub set_counters { output_template => 'Total Traffic : %s %s/s', perfdatas => [ { label => 'total_traffic', value => 'traffic_usage_per_second', template => '%d', - unit => 'b/s', min => 0 }, - ], + unit => 'b/s', min => 0 } + ] } }, { label => 'total-drop', set => { @@ -95,16 +97,16 @@ sub set_counters { output_template => 'Total Drop : %s %s/s', perfdatas => [ { label => 'total_drop', value => 'drop_usage_per_second', template => '%d', - unit => 'b/s', min => 0 }, - ], + unit => 'b/s', min => 0 } + ] } - }, + } ]; } sub custom_traffic_perfdata { my ($self, %options) = @_; - + my ($warning, $critical); if ($self->{instance_mode}->{option_results}->{units_traffic} eq '%' && (defined($self->{result_values}->{total}) && $self->{result_values}->{total} =~ /[0-9]/)) { @@ -114,7 +116,7 @@ sub custom_traffic_perfdata { $warning = $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}); $critical = $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}); } - + $self->{output}->perfdata_add( label => 'icmap_traffic', unit => 'b/s', instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef, @@ -127,7 +129,7 @@ sub custom_traffic_perfdata { sub custom_traffic_threshold { my ($self, %options) = @_; - + my $exit = 'ok'; if ($self->{instance_mode}->{option_results}->{units_traffic} eq '%' && (defined($self->{result_values}->{total}) && $self->{result_values}->{total} =~ /[0-9]/)) { @@ -142,10 +144,11 @@ sub custom_traffic_output { my ($self, %options) = @_; my ($traffic_value, $traffic_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{traffic_per_seconds}, network => 1); - my $msg = sprintf("Traffic : %s/s (%s)", - $traffic_value . $traffic_unit, - defined($self->{result_values}->{traffic_prct}) ? sprintf("%.2f%%", $self->{result_values}->{traffic_prct}) : '-'); - return $msg; + return sprintf( + 'Traffic : %s/s (%s)', + $traffic_value . $traffic_unit, + defined($self->{result_values}->{traffic_prct}) ? sprintf("%.2f%%", $self->{result_values}->{traffic_prct}) : '-' + ); } sub custom_traffic_calc { @@ -154,7 +157,7 @@ sub custom_traffic_calc { $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; $self->{result_values}->{total} = $options{new_datas}->{$self->{instance} . '_total'}; $self->{result_values}->{traffic_usage} = $options{new_datas}->{$self->{instance} . '_traffic_usage'}; - + my $diff_traffic = ($options{new_datas}->{$self->{instance} . '_traffic_usage'} - $options{old_datas}->{$self->{instance} . '_traffic_usage'}); $self->{result_values}->{traffic_per_seconds} = $diff_traffic / $options{delta_time}; if ($options{new_datas}->{$self->{instance} . '_total'} =~ /[1-9]/) { @@ -182,10 +185,10 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - "filter-source:s" => { name => 'filter_source' }, - "oid-filter:s" => { name => 'oid_filter', default => 'ifname' }, - "oid-display:s" => { name => 'oid_display', default => 'ifname' }, - "units-traffic:s" => { name => 'units_traffic', default => '%' }, + 'filter-source:s' => { name => 'filter_source' }, + 'oid-filter:s' => { name => 'oid_filter', default => 'ifname' }, + 'oid-display:s' => { name => 'oid_display', default => 'ifname' }, + 'units-traffic:s' => { name => 'units_traffic', default => '%' } }); return $self; @@ -205,7 +208,7 @@ sub check_options { sub check_oids_label { my ($self, %options) = @_; - + foreach (('oid_filter', 'oid_display')) { $self->{option_results}->{$_} = lc($self->{option_results}->{$_}) if (defined($self->{option_results}->{$_})); if (!defined($self->{oids_label}->{$self->{option_results}->{$_}})) { @@ -218,23 +221,20 @@ sub check_oids_label { } my $mapping = { - cbQosCMPrePolicyByteOverflow => { oid => '.1.3.6.1.4.1.9.9.166.1.15.1.1.4' }, - cbQosCMPrePolicyByte => { oid => '.1.3.6.1.4.1.9.9.166.1.15.1.1.5' }, - cbQosCMPrePolicyByte64 => { oid => '.1.3.6.1.4.1.9.9.166.1.15.1.1.6' }, cbQosCMPostPolicyByteOverflow => { oid => '.1.3.6.1.4.1.9.9.166.1.15.1.1.8' }, cbQosCMPostPolicyByte => { oid => '.1.3.6.1.4.1.9.9.166.1.15.1.1.9' }, cbQosCMPostPolicyByte64 => { oid => '.1.3.6.1.4.1.9.9.166.1.15.1.1.10' }, cbQosCMDropByteOverflow => { oid => '.1.3.6.1.4.1.9.9.166.1.15.1.1.15' }, cbQosCMDropByte => { oid => '.1.3.6.1.4.1.9.9.166.1.15.1.1.16' }, - cbQosCMDropByte64 => { oid => '.1.3.6.1.4.1.9.9.166.1.15.1.1.17' }, + cbQosCMDropByte64 => { oid => '.1.3.6.1.4.1.9.9.166.1.15.1.1.17' } }; my $mapping2 = { cbQosTSCfgRate => { oid => '.1.3.6.1.4.1.9.9.166.1.13.1.1.1' }, # bps - cbQosTSCfgRate64 => { oid => '.1.3.6.1.4.1.9.9.166.1.13.1.1.11' }, # bps + cbQosTSCfgRate64 => { oid => '.1.3.6.1.4.1.9.9.166.1.13.1.1.11' } # bps }; my $mapping3 = { cbQosQueueingCfgBandwidth => { oid => '.1.3.6.1.4.1.9.9.166.1.9.1.1.1' }, - cbQosQueueingCfgBandwidthUnits => { oid => '.1.3.6.1.4.1.9.9.166.1.9.1.1.2' }, + cbQosQueueingCfgBandwidthUnits => { oid => '.1.3.6.1.4.1.9.9.166.1.9.1.1.2' } }; my $oid_cbQosIfIndex = '.1.3.6.1.4.1.9.9.166.1.1.1.1.4'; @@ -252,17 +252,17 @@ my $oid_cbQosQueueingCfgEntry = '.1.3.6.1.4.1.9.9.166.1.9.1.1'; sub build_qos_information { my ($self, %options) = @_; - + my $qos_data = { complete_name => $options{class_name} }; # Need to try and find the queueing (it's a child) $qos_data->{queueing} = $options{link_queueing}->{$options{policy_index} . '.' . $options{object_index}} if (defined($options{link_queueing}->{$options{policy_index} . '.' . $options{object_index}})); $qos_data->{shaping} = $options{link_shaping}->{$options{policy_index} . '.' . $options{object_index}} if (!defined($qos_data->{shaping}) && defined($options{link_shaping}->{$options{policy_index} . '.' . $options{object_index}})); - + while (($options{object_index} = $self->{results}->{$oid_cbQosParentObjectsIndex}->{$oid_cbQosParentObjectsIndex . '.' . $options{policy_index} . '.' . $options{object_index}}) != 0) { my $config_index = $self->{results}->{$oid_cbQosConfigIndex}->{$oid_cbQosConfigIndex . '.' . $options{policy_index} . '.' . $options{object_index}}; - + my $tmp_name = ''; # try to find policy_map or class_map if (defined($self->{results}->{$oid_cbQosCMName}->{$oid_cbQosCMName . '.' . $config_index})) { @@ -270,23 +270,23 @@ sub build_qos_information { } elsif (defined($self->{results}->{$oid_cbQosPolicyMapName}->{$oid_cbQosPolicyMapName . '.' . $config_index})) { $tmp_name = $self->{results}->{$oid_cbQosPolicyMapName}->{$oid_cbQosPolicyMapName . '.' . $config_index}; } - + $qos_data->{shaping} = $options{link_shaping}->{$options{policy_index} . '.' . $options{object_index}} if (!defined($qos_data->{shaping}) && defined($options{link_shaping}->{$options{policy_index} . '.' . $options{object_index}})); - + $qos_data->{complete_name} = $tmp_name . ':' . $qos_data->{complete_name}; } - + return $qos_data; } sub manage_selection { my ($self, %options) = @_; - + $self->{interface_classmap} = {}; $self->{classmap} = {}; $self->{total} = { drop_usage => 0, total_usage => 0 }; - + my $request_oids = [ { oid => $self->{oids_label}->{$self->{option_results}->{oid_filter}} }, { oid => $oid_cbQosPolicyMapName }, @@ -294,9 +294,9 @@ sub manage_selection { { oid => $oid_cbQosConfigIndex }, { oid => $oid_cbQosCMName }, { oid => $oid_cbQosQueueingCfgEntry, end => $mapping3->{cbQosQueueingCfgBandwidthUnits}->{oid} }, - { oid => $oid_cbQosCMStatsEntry, start => $mapping->{cbQosCMPrePolicyByteOverflow}->{oid}, end => $mapping->{cbQosCMDropByte64}->{oid} }, + { oid => $oid_cbQosCMStatsEntry, start => $mapping->{cbQosCMPostPolicyByteOverflow}->{oid}, end => $mapping->{cbQosCMDropByte64}->{oid} }, { oid => $oid_cbQosParentObjectsIndex }, - { oid => $oid_cbQosTSCfgEntry, end => $mapping2->{cbQosTSCfgRate64}->{oid} }, + { oid => $oid_cbQosTSCfgEntry, end => $mapping2->{cbQosTSCfgRate64}->{oid} } ]; push @$request_oids, { oid => $self->{oids_label}->{$self->{option_results}->{oid_display}} } if ($self->{option_results}->{oid_filter} ne $self->{option_results}->{oid_display}); @@ -321,8 +321,8 @@ sub manage_selection { } foreach (keys %{$self->{results}->{$oid_cbQosCMStatsEntry}}) { - next if (!/$mapping->{cbQosCMPrePolicyByte}->{oid}\.(\d+)\.(\d+)/); - + next if (!/$mapping->{cbQosCMPostPolicyByteOverflow}->{oid}\.(\d+)\.(\d+)/); + my ($policy_index, $qos_object_index) = ($1, $2); my $class_name = $classmap_name{$policy_index . '.' . $qos_object_index}; @@ -338,24 +338,29 @@ sub manage_selection { next; } - my $qos_data = $self->build_qos_information(class_name => $class_name, policy_index => $policy_index, object_index => $qos_object_index, - link_queueing => $link_queueing, link_shaping => $link_shaping); - + my $qos_data = $self->build_qos_information( + class_name => $class_name, + policy_index => $policy_index, + object_index => $qos_object_index, + link_queueing => $link_queueing, + link_shaping => $link_shaping + ); + my $interface_filter = $self->{results}->{$self->{oids_label}->{$self->{option_results}->{oid_filter}}}->{$self->{oids_label}->{$self->{option_results}->{oid_filter}} . '.' . $if_index}; my $name = $interface_filter . ':' . $qos_data->{complete_name}; - + if (defined($self->{option_results}->{filter_source}) && $self->{option_results}->{filter_source} ne '' && $name !~ /$self->{option_results}->{filter_source}/) { $self->{output}->output_add(long_msg => "skipping '" . $name . "': no matching filter source.", debug => 1); next; } - + # Same hash key but only for disco context if (defined($options{disco})) { $self->{interface_classmap}->{$policy_index . '.' . $qos_object_index} = $name; next; } - + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_cbQosCMStatsEntry}, instance => $policy_index . '.' . $qos_object_index); my $traffic_usage = (defined($result->{cbQosCMPostPolicyByte64}) && $result->{cbQosCMPostPolicyByte64} =~ /[1-9]/) ? $result->{cbQosCMPostPolicyByte64} : (($result->{cbQosCMPostPolicyByteOverflow} << 32) + $result->{cbQosCMPostPolicyByte}); @@ -366,40 +371,42 @@ sub manage_selection { my $result_shaping = $options{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$oid_cbQosTSCfgEntry}, instance => $qos_data->{shaping}); $total = defined($result_shaping->{cbQosTSCfgRate64}) ? $result_shaping->{cbQosTSCfgRate64} : $result_shaping->{cbQosTSCfgRate}; } - + $self->{interface_classmap}->{$policy_index . '.' . $qos_object_index} = { display => $name, - traffic_usage => $traffic_usage * 8, drop_usage => $drop_usage * 8, total => $total + traffic_usage => $traffic_usage * 8, + drop_usage => $drop_usage * 8, + total => $total }; - + my @tabname = split /:/, $name; if (defined($tabname[3])){ - $class_name = $tabname[3].'-'.$class_name; + $class_name = $tabname[3] . '-' . $class_name; } - + $self->{classmap}->{$name} = { display => $class_name, drop_usage => 0, traffic_usage => 0} if (!defined($self->{classmap}->{$name})); $self->{classmap}->{$name}->{traffic_usage} += $traffic_usage * 8; $self->{classmap}->{$name}->{drop_usage} += $drop_usage * 8; - + if (!defined($tabname[3])){ $self->{total}->{traffic_usage} += $traffic_usage * 8; $self->{total}->{drop_usage} += $drop_usage * 8; } } - - $self->{cache_name} = "cisco_qos_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' . + + $self->{cache_name} = 'cisco_qos_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' . (defined($self->{option_results}->{filter_source}) ? md5_hex($self->{option_results}->{filter_source}) : md5_hex('all')) . '_' . (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); - + if (scalar(keys %{$self->{interface_classmap}}) <= 0 && !defined($options{disco})) { - $self->{output}->add_option_msg(short_msg => "Cannot found classmap."); + $self->{output}->add_option_msg(short_msg => 'Cannot found classmap.'); $self->{output}->option_exit(); } } sub disco_format { my ($self, %options) = @_; - + $self->{output}->add_disco_format(elements => ['name']); } From 18797072277a3f14a50fe99c7b12971241004c96 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 31 Mar 2020 11:34:20 +0200 Subject: [PATCH 052/283] fix fortinet core filter cpu --- centreon/common/fortinet/fortigate/snmp/mode/cpu.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/centreon/common/fortinet/fortigate/snmp/mode/cpu.pm b/centreon/common/fortinet/fortigate/snmp/mode/cpu.pm index 91185c599..245ce76e6 100644 --- a/centreon/common/fortinet/fortigate/snmp/mode/cpu.pm +++ b/centreon/common/fortinet/fortigate/snmp/mode/cpu.pm @@ -147,8 +147,9 @@ sub manage_selection { $cpu += $snmp_result->{$oid_fgProcessorUsage}->{$_}; } + my $num_core = scalar(keys %{$self->{cpu_core}}); $self->{cpu_avg} = { - average => ($i > 0) ? $cpu / $i : $snmp_result->{$oid_fgSysCpuUsage}->{$oid_fgSysCpuUsage . '.0'} + average => $num_core > 0 ? $cpu / $num_core : $snmp_result->{$oid_fgSysCpuUsage}->{$oid_fgSysCpuUsage . '.0'} }; if (defined($self->{option_results}->{cluster})) { From 28d3490a10e7c9321aa7848815ae65d56dffad33 Mon Sep 17 00:00:00 2001 From: Thibault S <48209914+thibaults-centreon@users.noreply.github.com> Date: Tue, 31 Mar 2020 14:10:53 +0200 Subject: [PATCH 053/283] add(plugin): Amazon EFS (#1913) * add(plugin): Amazon EFS --- efs/mode/connections.pm | 231 ++++++++++++++++++++++++++++++ efs/mode/datausage.pm | 310 ++++++++++++++++++++++++++++++++++++++++ efs/mode/discovery.pm | 112 +++++++++++++++ efs/plugin.pm | 52 +++++++ 4 files changed, 705 insertions(+) create mode 100644 efs/mode/connections.pm create mode 100644 efs/mode/datausage.pm create mode 100644 efs/mode/discovery.pm create mode 100644 efs/plugin.pm diff --git a/efs/mode/connections.pm b/efs/mode/connections.pm new file mode 100644 index 000000000..aa7e4a092 --- /dev/null +++ b/efs/mode/connections.pm @@ -0,0 +1,231 @@ +# +# Copyright 2020 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 cloud::aws::efs::mode::connections; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +my %metrics_mapping = ( + 'ClientConnections' => { + 'output' => 'Client Connections', + 'label' => 'client-connections', + 'nlabel' => 'efs.clients.connections.count', + 'unit' => '' + } +); + + +sub custom_metric_calc { + my ($self, %options) = @_; + + $self->{result_values}->{timeframe} = $options{new_datas}->{$self->{instance} . '_timeframe'}; + $self->{result_values}->{value} = $options{new_datas}->{$self->{instance} . '_' . $options{extra_options}->{metric}}; + $self->{result_values}->{metric} = $options{extra_options}->{metric}; + return 0; +} + +sub custom_metric_threshold { + my ($self, %options) = @_; + + my $exit = $self->{perfdata}->threshold_check( + value => $self->{result_values}->{value}, + threshold => [ { label => 'critical-' . $metrics_mapping{$self->{result_values}->{metric}}->{label}, exit_litteral => 'critical' }, + { label => 'warning-' . $metrics_mapping{$self->{result_values}->{metric}}->{label}, exit_litteral => 'warning' } ]); + return $exit; +} + +sub custom_metric_perfdata { + my ($self, %options) = @_; + + $self->{output}->perfdata_add( + instances => $self->{instance}, + label => $metrics_mapping{$self->{result_values}->{metric}}->{label}, + nlabel => $metrics_mapping{$self->{result_values}->{metric}}->{nlabel}, + unit => $metrics_mapping{$self->{result_values}->{metric}}->{unit}, + value => $self->{result_values}->{value}, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $metrics_mapping{$self->{result_values}->{metric}}->{label}), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $metrics_mapping{$self->{result_values}->{metric}}->{label}) + ); +} + +sub custom_metric_output { + my ($self, %options) = @_; + my $msg = ""; + + my ($value, $unit) = ($self->{result_values}->{value}, $metrics_mapping{$self->{result_values}->{metric}}->{unit}); + return $msg = sprintf("%s: %.2f %s", $metrics_mapping{$self->{result_values}->{metric}}->{output}, $value, $unit); +} + + +sub prefix_metric_output { + my ($self, %options) = @_; + + return "'" . $options{instance_value}->{display} . "' "; +} + +sub prefix_statistics_output { + my ($self, %options) = @_; + + return "Statistic '" . $options{instance_value}->{display} . "' Metrics "; +} + +sub long_output { + my ($self, %options) = @_; + + return "EFS FileSystemId'" . $options{instance_value}->{display} . "' "; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'metrics', type => 3, cb_prefix_output => 'prefix_metric_output', cb_long_output => 'long_output', + message_multiple => 'All FS metrics are ok', indent_long_output => ' ', + group => [ + { name => 'statistics', display_long => 1, cb_prefix_output => 'prefix_statistics_output', + message_multiple => 'All metrics are ok', type => 1, skipped_code => { -10 => 1 } }, + ] + } + ]; + + foreach my $metric (keys %metrics_mapping) { + my $entry = { + label => $metrics_mapping{$metric}->{label}, + set => { + key_values => [ { name => $metric }, { name => 'timeframe' }, { name => 'display' } ], + closure_custom_calc => $self->can('custom_metric_calc'), + closure_custom_calc_extra_options => { metric => $metric }, + closure_custom_output => $self->can('custom_metric_output'), + closure_custom_perfdata => $self->can('custom_metric_perfdata'), + closure_custom_threshold_check => $self->can('custom_metric_threshold'), + } + }; + push @{$self->{maps_counters}->{statistics}}, $entry; + } +} + +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 => { + "name:s@" => { name => 'name' }, + }); + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + if (!defined($self->{option_results}->{name}) || $self->{option_results}->{name} eq '') { + $self->{output}->add_option_msg(short_msg => "Need to specify --name option."); + $self->{output}->option_exit(); + } + + foreach my $instance (@{$self->{option_results}->{name}}) { + if ($instance ne '') { + push @{$self->{aws_instance}}, $instance; + } + } + + $self->{aws_timeframe} = defined($self->{option_results}->{timeframe}) ? $self->{option_results}->{timeframe} : 172800; + $self->{aws_period} = defined($self->{option_results}->{period}) ? $self->{option_results}->{period} : 86400; + $self->{aws_statistics} = ['Sum']; + + foreach my $metric (keys %metrics_mapping) { + next if (defined($self->{option_results}->{filter_metric}) && $self->{option_results}->{filter_metric} ne '' + && $metric !~ /$self->{option_results}->{filter_metric}/); + push @{$self->{aws_metrics}}, $metric; + } +} + +sub manage_selection { + my ($self, %options) = @_; + + my %metric_results; + foreach my $instance (@{$self->{aws_instance}}) { + $metric_results{$instance} = $options{custom}->cloudwatch_get_metrics( + region => $self->{option_results}->{region}, + namespace => 'AWS/EFS', + dimensions => [ { Name => 'FileSystemId', Value => $instance } ], + metrics => $self->{aws_metrics}, + statistics => $self->{aws_statistics}, + timeframe => $self->{aws_timeframe}, + period => $self->{aws_period}, + ); + + foreach my $metric (@{$self->{aws_metrics}}) { + foreach my $statistic (@{$self->{aws_statistics}}) { + next if (!defined($metric_results{$instance}->{$metric}->{lc($statistic)}) && + !defined($self->{option_results}->{zeroed})); + + $self->{metrics}->{$instance}->{display} = $instance; + $self->{metrics}->{$instance}->{statistics}->{lc($statistic)}->{display} = $statistic; + $self->{metrics}->{$instance}->{statistics}->{lc($statistic)}->{timeframe} = $self->{aws_timeframe}; + $self->{metrics}->{$instance}->{statistics}->{lc($statistic)}->{$metric} = + defined($metric_results{$instance}->{$metric}->{lc($statistic)}) ? + $metric_results{$instance}->{$metric}->{lc($statistic)} : 0; + } + } + } + + if (scalar(keys %{$self->{metrics}}) <= 0) { + $self->{output}->add_option_msg(short_msg => 'No metrics. Check your options or use --zeroed option to set 0 on undefined values'); + $self->{output}->option_exit(); + } +} + +1; + +__END__ + +=head1 MODE + +Check EFS FileSystem Connection Count. + +Example: +perl centreon_plugins.pl --plugin=cloud::aws::efs::plugin --custommode=paws --mode=connections --region='eu-west-1' +--name='fs-1234abcd' --warning-client-connections='50' --critical-client-connections='100' --verbose + +See 'https://docs.aws.amazon.com/efs/latest/ug/monitoring-cloudwatch.html' for more information. + + +=over 8 + +=item B<--name> + +Set the instance name (Required) (Can be multiple). + +=item B<--warning-client-connections> + +Warning threshold. + +=item B<--critical-client-connections> + +Critical threshold. + +=back + +=cut diff --git a/efs/mode/datausage.pm b/efs/mode/datausage.pm new file mode 100644 index 000000000..3711b2f39 --- /dev/null +++ b/efs/mode/datausage.pm @@ -0,0 +1,310 @@ +# +# Copyright 2020 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 cloud::aws::efs::mode::datausage; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +my %metrics_mapping = ( + 'DataReadIOBytes' => { + 'output' => 'Data Read IO Bytes', + 'label' => 'data-iobytes-read', + 'nlabel' => { + 'absolute' => 'efs.data.iobytes.read.bytes', + 'per_second' => 'efs.data.iobytes.read.bytespersecond', + }, + 'unit' => 'B' + }, + 'DataWriteIOBytes' => { + 'output' => 'Data Write IO Bytes', + 'label' => 'data-iobytes-write', + 'nlabel' => { + 'absolute' => 'efs.data.iobytes.write.bytes', + 'per_second' => 'efs.data.iobytes.write.bytespersecond', + }, + 'unit' => 'B' + }, + 'MetaDataIOBytes' => { + 'output' => 'MetaData IO Bytes', + 'label' => 'metadata-iobytes', + 'nlabel' => { + 'absolute' => 'efs.metadata.iobytes.bytes', + 'per_second' => 'efs.metadata.iobytes.bytespersecond', + }, + 'unit' => 'B' + }, + 'TotalIOBytes' => { + 'output' => 'Total IO Bytes', + 'label' => 'total-iobytes', + 'nlabel' => { + 'absolute' => 'efs.total.iobytes.bytes', + 'per_second' => 'efs.total.iobytes.bytespersecond', + }, + 'unit' => 'B' + }, + 'BurstCreditBalance' => { + 'output' => 'Burst Credit Balance Bytes', + 'label' => 'burst-bytes', + 'nlabel' => { + 'absolute' => 'efs.creditbalance.burst.bytes', + 'per_second' => 'efs.creditbalance.burst.bytespersecond', + }, + 'unit' => 'B' + } + +); + +sub custom_metric_calc { + my ($self, %options) = @_; + + $self->{result_values}->{timeframe} = $options{new_datas}->{$self->{instance} . '_timeframe'}; + $self->{result_values}->{value} = $options{new_datas}->{$self->{instance} . '_' . $options{extra_options}->{metric}}; + $self->{result_values}->{value_per_sec} = $self->{result_values}->{value} / $self->{result_values}->{timeframe}; + $self->{result_values}->{metric} = $options{extra_options}->{metric}; + return 0; +} + +sub custom_metric_threshold { + my ($self, %options) = @_; + + my $exit = $self->{perfdata}->threshold_check( + value => defined($self->{instance_mode}->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value}, + threshold => [ { label => 'critical-' . $metrics_mapping{$self->{result_values}->{metric}}->{label}, exit_litteral => 'critical' }, + { label => 'warning-' . $metrics_mapping{$self->{result_values}->{metric}}->{label}, exit_litteral => 'warning' } ]); + return $exit; +} + +sub custom_metric_perfdata { + my ($self, %options) = @_; + + $self->{output}->perfdata_add( + instances => $self->{instance}, + label => $metrics_mapping{$self->{result_values}->{metric}}->{label}, + nlabel => defined($self->{instance_mode}->{option_results}->{per_sec}) ? + $metrics_mapping{$self->{result_values}->{metric}}->{nlabel}->{per_second} : + $metrics_mapping{$self->{result_values}->{metric}}->{nlabel}->{absolute}, + unit => defined($self->{instance_mode}->{option_results}->{per_sec}) ? + $metrics_mapping{$self->{result_values}->{metric}}->{unit} . '/s' : + $metrics_mapping{$self->{result_values}->{metric}}->{unit}, + value => sprintf("%.2f", defined($self->{instance_mode}->{option_results}->{per_sec}) ? + $self->{result_values}->{value_per_sec} : + $self->{result_values}->{value}), + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $metrics_mapping{$self->{result_values}->{metric}}->{label}), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $metrics_mapping{$self->{result_values}->{metric}}->{label}), + ); +} + +sub custom_metric_output { + my ($self, %options) = @_; + my $msg = ""; + + if (defined($self->{instance_mode}->{option_results}->{per_sec})) { + my ($value, $unit) = ($metrics_mapping{$self->{result_values}->{metric}}->{unit} eq 'B') ? + $self->{perfdata}->change_bytes(value => $self->{result_values}->{value_per_sec}) : + ($self->{result_values}->{value_per_sec}, $metrics_mapping{$self->{result_values}->{metric}}->{unit}); + $msg = sprintf("%s: %.2f %s", $metrics_mapping{$self->{result_values}->{metric}}->{output}, $value, $unit . '/s'); + } else { + my ($value, $unit) = ($metrics_mapping{$self->{result_values}->{metric}}->{unit} eq 'B') ? + $self->{perfdata}->change_bytes(value => $self->{result_values}->{value}) : + ($self->{result_values}->{value}, $metrics_mapping{$self->{result_values}->{metric}}->{unit}); + $msg = sprintf("%s: %.2f %s", $metrics_mapping{$self->{result_values}->{metric}}->{output}, $value, $unit); + } + return $msg; +} + +sub prefix_metric_output { + my ($self, %options) = @_; + + return "'" . $options{instance_value}->{display} . "' "; +} + +sub prefix_statistics_output { + my ($self, %options) = @_; + + return "Statistic '" . $options{instance_value}->{display} . "' Metrics "; +} + +sub long_output { + my ($self, %options) = @_; + + return "EFS FileSystemId'" . $options{instance_value}->{display} . "' "; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'metrics', type => 3, cb_prefix_output => 'prefix_metric_output', cb_long_output => 'long_output', + message_multiple => 'All FS metrics are ok', indent_long_output => ' ', + group => [ + { name => 'statistics', display_long => 1, cb_prefix_output => 'prefix_statistics_output', + message_multiple => 'All metrics are ok', type => 1, skipped_code => { -10 => 1 } }, + ] + } + ]; + + foreach my $metric (keys %metrics_mapping) { + my $entry = { + label => $metrics_mapping{$metric}->{label}, + set => { + key_values => [ { name => $metric }, { name => 'timeframe' }, { name => 'display' } ], + closure_custom_calc => $self->can('custom_metric_calc'), + closure_custom_calc_extra_options => { metric => $metric }, + closure_custom_output => $self->can('custom_metric_output'), + closure_custom_perfdata => $self->can('custom_metric_perfdata'), + closure_custom_threshold_check => $self->can('custom_metric_threshold'), + } + }; + push @{$self->{maps_counters}->{statistics}}, $entry; + } +} + +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 => { + "type:s" => { name => 'type' }, + "name:s@" => { name => 'name' }, + "per-sec" => { name => 'per_sec' }, + "filter-metric:s" => { name => 'filter_metric' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + if (!defined($self->{option_results}->{name}) || $self->{option_results}->{name} eq '') { + $self->{output}->add_option_msg(short_msg => "Need to specify --name option."); + $self->{output}->option_exit(); + } + + foreach my $instance (@{$self->{option_results}->{name}}) { + if ($instance ne '') { + push @{$self->{aws_instance}}, $instance; + } + } + + $self->{aws_timeframe} = defined($self->{option_results}->{timeframe}) ? $self->{option_results}->{timeframe} : 600; + $self->{aws_period} = defined($self->{option_results}->{period}) ? $self->{option_results}->{period} : 60; + + $self->{aws_statistics} = ['Average']; + if (defined($self->{option_results}->{statistic})) { + $self->{aws_statistics} = []; + foreach my $stat (@{$self->{option_results}->{statistic}}) { + if ($stat ne '') { + push @{$self->{aws_statistics}}, ucfirst(lc($stat)); + } + } + } + + foreach my $metric (keys %metrics_mapping) { + next if (defined($self->{option_results}->{filter_metric}) && $self->{option_results}->{filter_metric} ne '' + && $metric !~ /$self->{option_results}->{filter_metric}/); + + push @{$self->{aws_metrics}}, $metric; + } +} + +sub manage_selection { + my ($self, %options) = @_; + + my %metric_results; + foreach my $instance (@{$self->{aws_instance}}) { + $metric_results{$instance} = $options{custom}->cloudwatch_get_metrics( + region => $self->{option_results}->{region}, + namespace => 'AWS/EFS', + dimensions => [ { Name => "FileSystemId", Value => $instance } ], + metrics => $self->{aws_metrics}, + statistics => $self->{aws_statistics}, + timeframe => $self->{aws_timeframe}, + period => $self->{aws_period}, + ); + + foreach my $metric (@{$self->{aws_metrics}}) { + foreach my $statistic (@{$self->{aws_statistics}}) { + next if (!defined($metric_results{$instance}->{$metric}->{lc($statistic)}) && + !defined($self->{option_results}->{zeroed})); + + $self->{metrics}->{$instance}->{display} = $instance; + $self->{metrics}->{$instance}->{statistics}->{lc($statistic)}->{display} = $statistic; + $self->{metrics}->{$instance}->{statistics}->{lc($statistic)}->{timeframe} = $self->{aws_timeframe}; + $self->{metrics}->{$instance}->{statistics}->{lc($statistic)}->{$metric} = + defined($metric_results{$instance}->{$metric}->{lc($statistic)}) ? + $metric_results{$instance}->{$metric}->{lc($statistic)} : 0; + } + } + } + + if (scalar(keys %{$self->{metrics}}) <= 0) { + $self->{output}->add_option_msg(short_msg => 'No metrics. Check your options or use --zeroed option to set 0 on undefined values'); + $self->{output}->option_exit(); + } +} + +1; + +__END__ + +=head1 MODE + +Check EFS FileSystem Data IO metrics. + +Example: +perl centreon_plugins.pl --plugin=cloud::aws::efs::plugin --custommode=paws --mode=datausage --region='eu-west-1' +--name='fs-1234abcd' --filter-metric='DataReadIOBytes' --warning-data-iobytes-read='5' --critical-data-iobytes-read='10' --verbose + +See 'https://docs.aws.amazon.com/efs/latest/ug/monitoring-cloudwatch.html' for more information. + + +=over 8 + +=item B<--name> + +Set the instance name (Required) (Can be multiple). + +=item B<--filter-metric> + +Filter on a specific metric +Can be: DataReadIOBytes, DataWriteIOBytes, MetaDataIOBytes, TotalIOBytes, BurstCreditBalance + +=item B<--statistic> + +Set the metric calculation method (Default: Average) +Can be 'minimum', 'maximum', 'average', 'sum' + +=item B<--warning-$metric$> + +Thresholds warning ($metric$ can be: 'data-iobytes-read', 'data-iobytes-write', 'metadata-iobytes', 'total-iobytes', 'burst-bytes'). + +=item B<--critical-$metric$> + +Thresholds critical ($metric$ can be: 'data-iobytes-read', 'data-iobytes-write', 'metadata-iobytes', 'total-iobytes', 'burst-bytes'). + +=back + +=cut diff --git a/efs/mode/discovery.pm b/efs/mode/discovery.pm new file mode 100644 index 000000000..f66982d8b --- /dev/null +++ b/efs/mode/discovery.pm @@ -0,0 +1,112 @@ +# +# Copyright 2020 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 cloud::aws::efs::mode::discovery; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use JSON::XS; + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $options{options}->add_options(arguments => { + "prettify" => { name => 'prettify' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); +} + +sub run { + my ($self, %options) = @_; + + my @disco_data; + my $disco_stats; + + $disco_stats->{start_time} = time(); + + my $fs_instances = $options{custom}->discovery( + region => $self->{option_results}->{region}, + service => 'efs', + command => 'describe-file-systems' + ); + + foreach my $fs_instance (@{$fs_instances->{FileSystems}}) { + next if (!defined($fs_instance->{FileSystemId})); + my %efs; + $efs{type} = "efs"; + $efs{id} = $fs_instance->{FileSystemId}; + $efs{name} = $fs_instance->{Name}; + $efs{creation_time} = $fs_instance->{CreationTime}; + $efs{size} = $fs_instance->{SizeInBytes}->{Value}; + $efs{perf_mode} = $fs_instance->{PerformanceMode }; + $efs{is_encrypted} = $fs_instance->{Encrypted}; + $efs{throughput_mode} = $fs_instance->{ThroughputMode}; + push @disco_data, \%efs; + } + + $disco_stats->{end_time} = time(); + $disco_stats->{duration} = $disco_stats->{end_time} - $disco_stats->{start_time}; + $disco_stats->{discovered_items} = @disco_data; + $disco_stats->{results} = \@disco_data; + + my $encoded_data; + eval { + if (defined($self->{option_results}->{prettify})) { + $encoded_data = JSON::XS->new->utf8->pretty->encode($disco_stats); + } else { + $encoded_data = JSON::XS->new->utf8->encode($disco_stats); + } + }; + if ($@) { + $encoded_data = '{"code":"encode_error","message":"Cannot encode discovered data into JSON format"}'; + } + + $self->{output}->output_add(short_msg => $encoded_data); + $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1); + $self->{output}->exit(); +} + +1; + +__END__ + +=head1 MODE + +EFS discovery. + +=over 8 + +=item B<--prettify> + +Prettify JSON output. + +=back + +=cut diff --git a/efs/plugin.pm b/efs/plugin.pm new file mode 100644 index 000000000..1921b281a --- /dev/null +++ b/efs/plugin.pm @@ -0,0 +1,52 @@ +# +# Copyright 2020 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 cloud::aws::efs::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} } = ( + 'connections' => 'cloud::aws::efs::mode::connections', + 'datausage' => 'cloud::aws::efs::mode::datausage', + 'discovery' => 'cloud::aws::efs::mode::discovery' + ); + + $self->{custom_modes}{paws} = 'cloud::aws::custom::paws'; + $self->{custom_modes}{awscli} = 'cloud::aws::custom::awscli'; + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Amazon Elastic File System (Amazon EFS). + +=cut From 6011eee1860133697d66c83af0889dad5156b0b9 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 31 Mar 2020 15:56:16 +0200 Subject: [PATCH 054/283] wip meraki rest api --- centreon/plugins/templates/counter.pm | 7 + .../cloudcontroller/restapi/custom/api.pm | 329 ++++++++++++++++++ .../cloudcontroller/restapi/mode/networks.pm | 162 +++++++++ .../meraki/cloudcontroller/restapi/plugin.pm | 50 +++ 4 files changed, 548 insertions(+) create mode 100644 network/cisco/meraki/cloudcontroller/restapi/custom/api.pm create mode 100644 network/cisco/meraki/cloudcontroller/restapi/mode/networks.pm create mode 100644 network/cisco/meraki/cloudcontroller/restapi/plugin.pm diff --git a/centreon/plugins/templates/counter.pm b/centreon/plugins/templates/counter.pm index e47e39f32..f17ad53bf 100644 --- a/centreon/plugins/templates/counter.pm +++ b/centreon/plugins/templates/counter.pm @@ -620,6 +620,13 @@ sub run_multiple { } } +sub read_statefile_key { + my ($self, %options) = @_; + + $self->{statefile_value}->read(statefile => $self->{cache_name}); + return $self->{statefile_value}->get(name => $options{key}); +} + sub run { my ($self, %options) = @_; diff --git a/network/cisco/meraki/cloudcontroller/restapi/custom/api.pm b/network/cisco/meraki/cloudcontroller/restapi/custom/api.pm new file mode 100644 index 000000000..78c860212 --- /dev/null +++ b/network/cisco/meraki/cloudcontroller/restapi/custom/api.pm @@ -0,0 +1,329 @@ +# +# Copyright 2020 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 network::cisco::meraki::cloudcontroller::restapi::custom::api; + +use strict; +use warnings; +use centreon::plugins::http; +use centreon::plugins::statefile; +use JSON::XS; +use Digest::MD5 qw(md5_hex); + +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' }, + 'proto:s' => { name => 'proto' }, + 'api-token:s' => { name => 'api_token' }, + 'timeout:s' => { name => 'timeout' }, + 'reload-cache-time:s' => { name => 'reload_cache_time' } + }); + } + $options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1); + + $self->{output} = $options{output}; + $self->{mode} = $options{mode}; + $self->{http} = centreon::plugins::http->new(%options); + $self->{cache} = centreon::plugins::statefile->new(%options); + $self->{cache_checked} = 0; + + return $self; +} + +sub set_options { + my ($self, %options) = @_; + + $self->{option_results} = $options{option_results}; +} + +sub set_defaults { + my ($self, %options) = @_; + + 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} = (defined($self->{option_results}->{hostname})) ? $self->{option_results}->{hostname} : 'api.meraki.com'; + $self->{port} = (defined($self->{option_results}->{port})) ? $self->{option_results}->{port} : 443; + $self->{proto} = (defined($self->{option_results}->{proto})) ? $self->{option_results}->{proto} : 'https'; + $self->{timeout} = (defined($self->{option_results}->{timeout})) ? $self->{option_results}->{timeout} : 10; + $self->{api_token} = (defined($self->{option_results}->{api_token})) ? $self->{option_results}->{api_token} : ''; + $self->{reload_cache_time} = (defined($self->{option_results}->{reload_cache_time})) ? $self->{option_results}->{reload_cache_time} : 180; + + if (!defined($self->{hostname}) || $self->{hostname} eq '') { + $self->{output}->add_option_msg(short_msg => "Need to specify --hostname option."); + $self->{output}->option_exit(); + } + if (!defined($self->{api_token}) || $self->{api_token} eq '') { + $self->{output}->add_option_msg(short_msg => "Need to specify --api-token option."); + $self->{output}->option_exit(); + } + + $self->{cache}->check_options(option_results => $self->{option_results}); + return 0; +} + +sub get_token { + my ($self, %options) = @_; + + return md5_hex($self->{api_token}); +} + +sub get_cache_networks { + my ($self, %options) = @_; + + $self->cache_networks_organizations(); + return $self->{cache_networks}; +} + +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->{http}->add_header(key => 'X-Cisco-Meraki-API-Key', value => $self->{api_token}); +} + +sub settings { + my ($self, %options) = @_; + + $self->build_options_for_httplib(); + $self->{http}->set_options(%{$self->{option_results}}); +} + +sub request_api { + my ($self, %options) = @_; + + $self->settings(); + + #400: Bad Request- You did something wrong, e.g. a malformed request or missing parameter. + #403: Forbidden- You don't have permission to do that. + #404: Not found- No such URL, or you don't have access to the API or organization at all. + #429: Too Many Requests- You submitted more than 5 calls in 1 second to an Organization, triggering rate limiting. This also applies for API calls made across multiple organizations that triggers rate limiting for one of the organizations. + do { + my $response = $self->{http}->request( + url_path => '/api/v0' . $options{endpoint}, + critical_status => '', + warning_status => '', + unknown_status => '(%{http_code} < 200 or %{http_code} >= 300) and %{http_code} != 429' + ); + + if ($self->{http}->get_code() == 429) { + sleep(1); + continue; + } + + my $content; + eval { + $content = JSON::XS->new->utf8->decode($response); + }; + if ($@) { + $self->{output}->add_option_msg(short_msg => "Cannot decode json response: $@"); + $self->{output}->option_exit(); + } + return ($content); + } while (1); +} + +sub cache_networks_organizations { + my ($self, %options) = @_; + + return if ($self->{cache_checked} == 1); + + $self->{cache_checked} = 1; + my $has_cache_file = $self->{cache}->read(statefile => 'cache_cisco_meraki_' . $self->get_token()); + my $timestamp_cache = $self->{cache}->get(name => 'last_timestamp'); + $self->{cache_organizations} = $self->{cache}->get(name => 'organizations'); + $self->{cache_networks} = $self->{cache}->get(name => 'networks'); + + if ($has_cache_file == 0 || !defined($timestamp_cache) || ((time() - $timestamp_cache) > (($self->{reload_cache_time}) * 60))) { + $self->{cache_organizations} = {}; + $self->{cache_organizations} = $self->get_organizations(disable_cache => 1); + $self->{cache_networks} = $self->get_networks(organizations => [keys %{$self->{cache_organizations}}], disable_cache => 1); + + $self->{cache}->write(data => { + last_timestamp => time(), + organizations => $self->{cache_organizations}, + networks => $self->{cache_networks} + }); + } +} + +sub get_organizations { + my ($self, %options) = @_; + + $self->cache_networks_organizations(); + return $self->{cache_organizations} if (!defined($options{disable_cache}) || $options{disable_cache} == 0); + my $datas = $self->request_api(endpoint => '/organizations'); + my $results = {}; + $results->{$_->{id}} = $_ foreach (@$datas); + + return $results; +} + +sub get_networks { + my ($self, %options) = @_; + + $self->cache_networks_organizations(); + return $self->{cache_networks} if (!defined($options{disable_cache}) || $options{disable_cache} == 0); + + my $results = {}; + foreach my $id (keys %{$self->{cache_organizations}}) { + my $datas = $self->request_api(endpoint => '/organizations/' . $id . '/networks'); + $results->{$_->{id}} = $_ foreach (@$datas); + } + + return $results; +} + +sub filter_networks { + my ($self, %options) = @_; + + my $network_ids = []; + foreach (values %{$self->{cache_networks}}) { + if (!defined($options{filter_name}) || $options{filter_name} eq '') { + push @$network_ids, $_->{id}; + } elsif ($_->{name} =~ /$options{filter_name}/) { + push @$network_ids, $_->{id}; + } + } + + if (scalar(@$network_ids) > 5) { + $self->{output}->add_option_msg(short_msg => 'cannot check than 5 networks at once'); + $self->{output}->option_exit(); + } + + return $network_ids; +} + +sub get_networks_connection_stats { + my ($self, %options) = @_; + + $self->cache_networks_organizations(); + my $network_ids = $self->filter_networks(filter_name => $options{filter_name}); + + my $timespan = defined($options{timespan}) ? $options{timespan} : 300; + $timespan = 1 if ($timespan <= 0); + my $results = {}; + foreach my $id (@$network_ids) { + my $datas = $self->request_api(endpoint => '/networks/' . $id . '/connectionStats?timespan=' . $options{timespan}); + $results->{$id} = $datas; + } + + return $results; +} + +sub get_networks_clients { + my ($self, %options) = @_; + + $self->cache_networks_organizations(); + my $network_ids = $self->filter_networks(filter_name => $options{filter_name}); + + my $timespan = defined($options{timespan}) ? $options{timespan} : 300; + $timespan = 1 if ($timespan <= 0); + my $results = {}; + foreach my $id (@$network_ids) { + my $datas = $self->request_api(endpoint => '/networks/' . $id . '/clients?timespan=' . $options{timespan}); + $results->{$id} = $datas; + } + + return $results; +} + +sub get_device_statuses { + my ($self, %options) = @_; +} + +1; + +__END__ + +=head1 NAME + +Meraki REST API + +=head1 SYNOPSIS + +api_token Rest API custom mode + +=head1 REST API OPTIONS + +=over 8 + +=item B<--hostname> + +Meraki api hostname (default: 'api.meraki.com') + +=item B<--port> + +Port used (Default: 443) + +=item B<--proto> + +Specify https if needed (Default: 'https') + +=item B<--api-token> + +Meraki api token. + +=item B<--timeout> + +Set HTTP timeout + +=item B<--reload-cache-time> + +Time in minutes before reloading cache file (default: 180). + +=back + +=head1 DESCRIPTION + +B. + +=cut diff --git a/network/cisco/meraki/cloudcontroller/restapi/mode/networks.pm b/network/cisco/meraki/cloudcontroller/restapi/mode/networks.pm new file mode 100644 index 000000000..c15bbc0a9 --- /dev/null +++ b/network/cisco/meraki/cloudcontroller/restapi/mode/networks.pm @@ -0,0 +1,162 @@ +# +# Copyright 2020 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 network::cisco::meraki::cloudcontroller::restapi::mode::networks; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use Digest::MD5 qw(md5_hex); + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'networks', type => 1, cb_prefix_output => 'prefix_network_output', message_multiple => 'All networks are ok' } + ]; + + $self->{maps_counters}->{networks} = [ + { label => 'connections-success', nlabel => 'network.connections.success.count', set => { + key_values => [ { name => 'assoc' }, { name => 'display' } ], + output_template => 'connections success: %s', + perfdatas => [ + { value => 'assoc_absolute', + template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' } + ] + } + }, + { label => 'connections-auth', nlabel => 'network.connections.auth.count', display_ok => 0, set => { + key_values => [ { name => 'auth' }, { name => 'display' } ], + output_template => 'connections auth: %s', + perfdatas => [ + { value => 'auth_absolute', + template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' } + ] + } + }, + { label => 'connections-assoc', nlabel => 'network.connections.assoc.count', display_ok => 0, set => { + key_values => [ { name => 'assoc' }, { name => 'display' } ], + output_template => 'connections assoc: %s', + perfdatas => [ + { value => 'assoc_absolute', + template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' } + ] + } + }, + { label => 'connections-dhcp', nlabel => 'network.connections.dhcp.count', display_ok => 0, set => { + key_values => [ { name => 'dhcp' }, { name => 'display' } ], + output_template => 'connections dhcp: %s', + perfdatas => [ + { value => 'dhcp_absolute', + template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' } + ] + } + }, + { label => 'connections-dns', nlabel => 'network.connections.dns.count', display_ok => 0, set => { + key_values => [ { name => 'dns' }, { name => 'display' } ], + output_template => 'connections dns: %s', + perfdatas => [ + { value => 'dns_absolute', + template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' } + ] + } + } + ]; +} + +sub prefix_network_output { + my ($self, %options) = @_; + + return "Network '" . $options{instance_value}->{display} . "' "; +} + +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 => { + 'filter-name:s' => { name => 'filter_name' } + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + $self->{cache_name} = 'meraki_' . $self->{mode} . '_' . $options{custom}->get_token() . '_' . + (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')); + my $last_timestamp = $self->read_statefile_key(key => 'last_timestamp'); + my $timespan = 300; + $timespan = time() - $last_timestamp if (defined($last_timestamp)); + + my $cache_networks = $options{custom}->get_cache_networks(); + my $connections = $options{custom}->get_networks_connection_stats(timespan => $timespan, filter_name => $self->{option_results}->{filter_name}); + my $clients = $options{custom}->get_networks_clients(timespan => $timespan, filter_name => $self->{option_results}->{filter_name}); + + $self->{networks} = {}; + foreach my $id (keys %$connections) { + $self->{networks}->{$id} = { + display => $cache_networks->{$id}->{name}, + assoc => defined($connections->{$id}->{assoc}) ? $connections->{$id}->{assoc} : 0, + auth => defined($connections->{$id}->{assoc}) ? $connections->{$id}->{auth} : 0, + dhcp => defined($connections->{$id}->{assoc}) ? $connections->{$id}->{assoc} : 0, + dns => defined($connections->{$id}->{assoc}) ? $connections->{$id}->{dhcp} : 0, + success => defined($connections->{$id}->{assoc}) ? $connections->{$id}->{success} : 0 + }; + + } + + if (scalar(keys %{$self->{networks}}) <= 0) { + $self->{output}->add_option_msg(short_msg => "No networks found."); + $self->{output}->option_exit(); + } +} + +1; + +__END__ + +=head1 MODE + +Check networks. + +=over 8 + +=item B<--filter-name> + +Filter network name (Can be a regexp). + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'volume-data-read-bytespersecond', 'volume-data-written-bytespersecond', +'volume-reads-count', 'volume-writes-count', +'volume-data-transfer-bytespersecond', 'volume-iops-ops', +'volume-cache-write-usage-percentage', 'volume-cache-write-hits-count', +'volume-cache-write-misses-count', 'volume-cache-read-hits-count', +'volume-cache-read-misses-count'. + +=back + +=cut diff --git a/network/cisco/meraki/cloudcontroller/restapi/plugin.pm b/network/cisco/meraki/cloudcontroller/restapi/plugin.pm new file mode 100644 index 000000000..ed31ce585 --- /dev/null +++ b/network/cisco/meraki/cloudcontroller/restapi/plugin.pm @@ -0,0 +1,50 @@ +# +# Copyright 2020 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 network::cisco::meraki::cloudcontroller::restapi::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}} = ( + 'devices' => 'network::cisco::meraki::cloudcontroller::restapi::mode::devices', + 'networks' => 'network::cisco::meraki::cloudcontroller::restapi::mode::networks' + ); + + $self->{custom_modes}{api} = 'network::cisco::meraki::cloudcontroller::restapi::custom::api'; + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Cisco Meraki cloud controller through HTTP/REST API. + +=cut From 076c320652eb60a49ca677ab8824b028c946f25c Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 31 Mar 2020 16:19:26 +0200 Subject: [PATCH 055/283] wip cisco meraki rest api --- .../cloudcontroller/restapi/mode/networks.pm | 39 +++++++++++++++---- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/network/cisco/meraki/cloudcontroller/restapi/mode/networks.pm b/network/cisco/meraki/cloudcontroller/restapi/mode/networks.pm index c15bbc0a9..ce53e1e7a 100644 --- a/network/cisco/meraki/cloudcontroller/restapi/mode/networks.pm +++ b/network/cisco/meraki/cloudcontroller/restapi/mode/networks.pm @@ -78,6 +78,26 @@ sub set_counters { template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' } ] } + }, + { label => 'traffic-in', nlabel => 'network.traffic.in.bitspersecond', set => { + key_values => [ { name => 'traffic_in', diff => 1 }, { name => 'display' } ], + output_template => 'traffic in: %s %s/s', + per_second => 1, output_change_bytes => 2, + perfdatas => [ + { value => 'traffic_in_per_second', template => '%s', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' } + ] + } + }, + { label => 'traffic-out', nlabel => 'network.traffic.out.bitspersecond', set => { + key_values => [ { name => 'traffic_out', diff => 1 }, { name => 'display' } ], + output_template => 'traffic out: %s %s/s', + per_second => 1, output_change_bytes => 2, + perfdatas => [ + { value => 'traffic_out_per_second', template => '%s', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' } + ] + } } ]; } @@ -122,9 +142,16 @@ sub manage_selection { auth => defined($connections->{$id}->{assoc}) ? $connections->{$id}->{auth} : 0, dhcp => defined($connections->{$id}->{assoc}) ? $connections->{$id}->{assoc} : 0, dns => defined($connections->{$id}->{assoc}) ? $connections->{$id}->{dhcp} : 0, - success => defined($connections->{$id}->{assoc}) ? $connections->{$id}->{success} : 0 + success => defined($connections->{$id}->{assoc}) ? $connections->{$id}->{success} : 0, + traffic_in => 0, traffic_out => 0 }; - + + if (defined($clients->{$id})) { + foreach (@{$clients->{$id}}) { + $self->{networks}->{$id}->{traffic_in} += $_->{usage}->{recv} * 8; + $self->{networks}->{$id}->{traffic_out} += $_->{usage}->{sent} * 8; + } + } } if (scalar(keys %{$self->{networks}}) <= 0) { @@ -150,12 +177,8 @@ Filter network name (Can be a regexp). =item B<--warning-*> B<--critical-*> Thresholds. -Can be: 'volume-data-read-bytespersecond', 'volume-data-written-bytespersecond', -'volume-reads-count', 'volume-writes-count', -'volume-data-transfer-bytespersecond', 'volume-iops-ops', -'volume-cache-write-usage-percentage', 'volume-cache-write-hits-count', -'volume-cache-write-misses-count', 'volume-cache-read-hits-count', -'volume-cache-read-misses-count'. +Can be: 'connections-success', 'connections-auth', 'connections-assoc', +'connections-dhcp', 'connections-dns', 'traffic-in', 'traffic-out'. =back From 4d16c55602cca199c6c240c55341f9473780cf8a Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 31 Mar 2020 18:36:35 +0200 Subject: [PATCH 056/283] fix efs path --- {efs => cloud/aws/efs}/mode/connections.pm | 11 +++++---- {efs => cloud/aws/efs}/mode/datausage.pm | 23 ++++++++++--------- {efs => cloud/aws/efs}/mode/discovery.pm | 8 +++---- {efs => cloud/aws/efs}/plugin.pm | 6 ++--- .../cloudcontroller/restapi/custom/api.pm | 2 +- 5 files changed, 26 insertions(+), 24 deletions(-) rename {efs => cloud/aws/efs}/mode/connections.pm (96%) rename {efs => cloud/aws/efs}/mode/datausage.pm (97%) rename {efs => cloud/aws/efs}/mode/discovery.pm (94%) rename {efs => cloud/aws/efs}/plugin.pm (83%) diff --git a/efs/mode/connections.pm b/cloud/aws/efs/mode/connections.pm similarity index 96% rename from efs/mode/connections.pm rename to cloud/aws/efs/mode/connections.pm index aa7e4a092..f812f247c 100644 --- a/efs/mode/connections.pm +++ b/cloud/aws/efs/mode/connections.pm @@ -97,7 +97,7 @@ sub long_output { sub set_counters { my ($self, %options) = @_; - + $self->{maps_counters_type} = [ { name => 'metrics', type => 3, cb_prefix_output => 'prefix_metric_output', cb_long_output => 'long_output', message_multiple => 'All FS metrics are ok', indent_long_output => ' ', @@ -128,10 +128,11 @@ 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 => { - "name:s@" => { name => 'name' }, + 'name:s@' => { name => 'name' }, }); + return $self; } @@ -153,7 +154,7 @@ sub check_options { $self->{aws_timeframe} = defined($self->{option_results}->{timeframe}) ? $self->{option_results}->{timeframe} : 172800; $self->{aws_period} = defined($self->{option_results}->{period}) ? $self->{option_results}->{period} : 86400; $self->{aws_statistics} = ['Sum']; - + foreach my $metric (keys %metrics_mapping) { next if (defined($self->{option_results}->{filter_metric}) && $self->{option_results}->{filter_metric} ne '' && $metric !~ /$self->{option_results}->{filter_metric}/); @@ -175,7 +176,7 @@ sub manage_selection { timeframe => $self->{aws_timeframe}, period => $self->{aws_period}, ); - + foreach my $metric (@{$self->{aws_metrics}}) { foreach my $statistic (@{$self->{aws_statistics}}) { next if (!defined($metric_results{$instance}->{$metric}->{lc($statistic)}) && diff --git a/efs/mode/datausage.pm b/cloud/aws/efs/mode/datausage.pm similarity index 97% rename from efs/mode/datausage.pm rename to cloud/aws/efs/mode/datausage.pm index 3711b2f39..dd5171618 100644 --- a/efs/mode/datausage.pm +++ b/cloud/aws/efs/mode/datausage.pm @@ -76,7 +76,7 @@ my %metrics_mapping = ( sub custom_metric_calc { my ($self, %options) = @_; - + $self->{result_values}->{timeframe} = $options{new_datas}->{$self->{instance} . '_timeframe'}; $self->{result_values}->{value} = $options{new_datas}->{$self->{instance} . '_' . $options{extra_options}->{metric}}; $self->{result_values}->{value_per_sec} = $self->{result_values}->{value} / $self->{result_values}->{timeframe}; @@ -90,7 +90,8 @@ sub custom_metric_threshold { my $exit = $self->{perfdata}->threshold_check( value => defined($self->{instance_mode}->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value}, threshold => [ { label => 'critical-' . $metrics_mapping{$self->{result_values}->{metric}}->{label}, exit_litteral => 'critical' }, - { label => 'warning-' . $metrics_mapping{$self->{result_values}->{metric}}->{label}, exit_litteral => 'warning' } ]); + { label => 'warning-' . $metrics_mapping{$self->{result_values}->{metric}}->{label}, exit_litteral => 'warning' } ] + ); return $exit; } @@ -134,13 +135,13 @@ sub custom_metric_output { sub prefix_metric_output { my ($self, %options) = @_; - + return "'" . $options{instance_value}->{display} . "' "; } sub prefix_statistics_output { my ($self, %options) = @_; - + return "Statistic '" . $options{instance_value}->{display} . "' Metrics "; } @@ -152,7 +153,7 @@ sub long_output { sub set_counters { my ($self, %options) = @_; - + $self->{maps_counters_type} = [ { name => 'metrics', type => 3, cb_prefix_output => 'prefix_metric_output', cb_long_output => 'long_output', message_multiple => 'All FS metrics are ok', indent_long_output => ' ', @@ -183,12 +184,12 @@ 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 => { - "type:s" => { name => 'type' }, - "name:s@" => { name => 'name' }, - "per-sec" => { name => 'per_sec' }, - "filter-metric:s" => { name => 'filter_metric' }, + 'type:s' => { name => 'type' }, + 'name:s@' => { name => 'name' }, + 'per-sec' => { name => 'per_sec' }, + 'filter-metric:s' => { name => 'filter_metric' }, }); return $self; @@ -211,7 +212,7 @@ sub check_options { $self->{aws_timeframe} = defined($self->{option_results}->{timeframe}) ? $self->{option_results}->{timeframe} : 600; $self->{aws_period} = defined($self->{option_results}->{period}) ? $self->{option_results}->{period} : 60; - + $self->{aws_statistics} = ['Average']; if (defined($self->{option_results}->{statistic})) { $self->{aws_statistics} = []; diff --git a/efs/mode/discovery.pm b/cloud/aws/efs/mode/discovery.pm similarity index 94% rename from efs/mode/discovery.pm rename to cloud/aws/efs/mode/discovery.pm index f66982d8b..fc575bcaf 100644 --- a/efs/mode/discovery.pm +++ b/cloud/aws/efs/mode/discovery.pm @@ -30,11 +30,11 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - + $options{options}->add_options(arguments => { - "prettify" => { name => 'prettify' }, + 'prettify' => { name => 'prettify' } }); - + return $self; } @@ -87,7 +87,7 @@ sub run { if ($@) { $encoded_data = '{"code":"encode_error","message":"Cannot encode discovered data into JSON format"}'; } - + $self->{output}->output_add(short_msg => $encoded_data); $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1); $self->{output}->exit(); diff --git a/efs/plugin.pm b/cloud/aws/efs/plugin.pm similarity index 83% rename from efs/plugin.pm rename to cloud/aws/efs/plugin.pm index 1921b281a..4b8f112bd 100644 --- a/efs/plugin.pm +++ b/cloud/aws/efs/plugin.pm @@ -31,9 +31,9 @@ sub new { $self->{version} = '1.0'; %{ $self->{modes} } = ( - 'connections' => 'cloud::aws::efs::mode::connections', - 'datausage' => 'cloud::aws::efs::mode::datausage', - 'discovery' => 'cloud::aws::efs::mode::discovery' + 'connections' => 'cloud::aws::efs::mode::connections', + 'datausage' => 'cloud::aws::efs::mode::datausage', + 'discovery' => 'cloud::aws::efs::mode::discovery' ); $self->{custom_modes}{paws} = 'cloud::aws::custom::paws'; diff --git a/network/cisco/meraki/cloudcontroller/restapi/custom/api.pm b/network/cisco/meraki/cloudcontroller/restapi/custom/api.pm index 78c860212..bfc2a979e 100644 --- a/network/cisco/meraki/cloudcontroller/restapi/custom/api.pm +++ b/network/cisco/meraki/cloudcontroller/restapi/custom/api.pm @@ -235,7 +235,7 @@ sub filter_networks { } if (scalar(@$network_ids) > 5) { - $self->{output}->add_option_msg(short_msg => 'cannot check than 5 networks at once'); + $self->{output}->add_option_msg(short_msg => 'cannot check than 5 networks at once (api rate limit)'); $self->{output}->option_exit(); } From 7edc6b9678516014f2b8c1358a3f00633d027cb0 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 1 Apr 2020 10:00:18 +0200 Subject: [PATCH 057/283] fix cisco qos usage --- .../cisco/standard/snmp/mode/qosusage.pm | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/centreon/common/cisco/standard/snmp/mode/qosusage.pm b/centreon/common/cisco/standard/snmp/mode/qosusage.pm index 55f357544..79708b47f 100644 --- a/centreon/common/cisco/standard/snmp/mode/qosusage.pm +++ b/centreon/common/cisco/standard/snmp/mode/qosusage.pm @@ -363,9 +363,21 @@ sub manage_selection { my $result = $options{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_cbQosCMStatsEntry}, instance => $policy_index . '.' . $qos_object_index); my $traffic_usage = (defined($result->{cbQosCMPostPolicyByte64}) && $result->{cbQosCMPostPolicyByte64} =~ /[1-9]/) ? - $result->{cbQosCMPostPolicyByte64} : (($result->{cbQosCMPostPolicyByteOverflow} << 32) + $result->{cbQosCMPostPolicyByte}); - my $drop_usage = (defined($result->{cbQosCMDropByte64}) && $result->{cbQosCMDropByte64} =~ /[1-9]/) ? - $result->{cbQosCMDropByte64} : (($result->{cbQosCMDropByteOverflow} << 32) + $result->{cbQosCMDropByte}); + $result->{cbQosCMPostPolicyByte64} : + ( + ($result->{cbQosCMPostPolicyByteOverflow} == 4294967295) ? + undef : + ($result->{cbQosCMPostPolicyByteOverflow} * 4294967295 + $result->{cbQosCMPostPolicyByte}) + ); + my $drop_usage = + (defined($result->{cbQosCMDropByte64}) && $result->{cbQosCMDropByte64} =~ /[1-9]/) ? + $result->{cbQosCMDropByte64} : + ( + ($result->{cbQosCMDropByteOverflow} == 4294967295) ? + undef : + ($result->{cbQosCMDropByteOverflow} * 4294967295 + $result->{cbQosCMDropByte}) + ); + my $total = 'unknown'; if (defined($qos_data->{shaping})) { my $result_shaping = $options{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$oid_cbQosTSCfgEntry}, instance => $qos_data->{shaping}); @@ -374,8 +386,8 @@ sub manage_selection { $self->{interface_classmap}->{$policy_index . '.' . $qos_object_index} = { display => $name, - traffic_usage => $traffic_usage * 8, - drop_usage => $drop_usage * 8, + traffic_usage => defined($traffic_usage) ? $traffic_usage * 8 : undef, + drop_usage => defined($drop_usage) ? $drop_usage * 8 : undef, total => $total }; @@ -385,12 +397,12 @@ sub manage_selection { } $self->{classmap}->{$name} = { display => $class_name, drop_usage => 0, traffic_usage => 0} if (!defined($self->{classmap}->{$name})); - $self->{classmap}->{$name}->{traffic_usage} += $traffic_usage * 8; - $self->{classmap}->{$name}->{drop_usage} += $drop_usage * 8; + $self->{classmap}->{$name}->{traffic_usage} += defined($traffic_usage) ? $traffic_usage * 8 : 0; + $self->{classmap}->{$name}->{drop_usage} += defined($drop_usage) ? $drop_usage * 8 : 0; if (!defined($tabname[3])){ - $self->{total}->{traffic_usage} += $traffic_usage * 8; - $self->{total}->{drop_usage} += $drop_usage * 8; + $self->{total}->{traffic_usage} += defined($traffic_usage) ? $traffic_usage * 8 : 0; + $self->{total}->{drop_usage} += defined($drop_usage) ? $drop_usage * 8 : 0; } } From b733aa3f607ff15564de3cfa93264ab61f774094 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 1 Apr 2020 12:33:33 +0200 Subject: [PATCH 058/283] better management of multiple counters --- centreon/plugins/templates/counter.pm | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/centreon/plugins/templates/counter.pm b/centreon/plugins/templates/counter.pm index f17ad53bf..5b56573ea 100644 --- a/centreon/plugins/templates/counter.pm +++ b/centreon/plugins/templates/counter.pm @@ -309,7 +309,7 @@ sub run_instances { $self->{lproblems} = 0; $self->{multiple} = 1; - if (scalar(keys %{$self->{$options{config}->{name}}}) == 1) { + if (scalar(keys %{$self->{$options{config}->{name}}}) <= 1) { $self->{multiple} = 0; } @@ -401,7 +401,7 @@ sub run_group { my $multiple = 1; return if (scalar(keys %{$self->{$options{config}->{name}}}) <= 0); - if (scalar(keys %{$self->{$options{config}->{name}}}) == 1) { + if (scalar(keys %{$self->{$options{config}->{name}}}) <= 1) { $multiple = 0; } @@ -478,7 +478,7 @@ sub run_multiple_instances { my $no_message_multiple = 1; my $multiple = 1; - if (scalar(keys %{$self->{$options{config}->{name}}}) == 1) { + if (scalar(keys %{$self->{$options{config}->{name}}}) <= 1) { $multiple = 0; } @@ -580,13 +580,15 @@ sub run_multiple { my ($self, %options) = @_; my $multiple = 1; - if (scalar(keys %{$self->{$options{config}->{name}}}) == 1) { + if (scalar(keys %{$self->{$options{config}->{name}}}) <= 1) { $multiple = 0; } if ($multiple == 1) { - $self->{output}->output_add(severity => 'OK', - short_msg => $options{config}->{message_multiple}); + $self->{output}->output_add( + severity => 'OK', + short_msg => $options{config}->{message_multiple} + ); } foreach my $instance (sort keys %{$self->{$options{config}->{name}}}) { From a9eab59fe1708daa69440bd5a9ab10384ff0602e Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 1 Apr 2020 12:34:04 +0200 Subject: [PATCH 059/283] wip: add meraki mode devices --- .../cloudcontroller/restapi/custom/api.pm | 130 +++++- .../cloudcontroller/restapi/mode/devices.pm | 372 ++++++++++++++++++ .../cloudcontroller/restapi/mode/networks.pm | 8 +- 3 files changed, 498 insertions(+), 12 deletions(-) create mode 100644 network/cisco/meraki/cloudcontroller/restapi/mode/devices.pm diff --git a/network/cisco/meraki/cloudcontroller/restapi/custom/api.pm b/network/cisco/meraki/cloudcontroller/restapi/custom/api.pm index bfc2a979e..f846f6d12 100644 --- a/network/cisco/meraki/cloudcontroller/restapi/custom/api.pm +++ b/network/cisco/meraki/cloudcontroller/restapi/custom/api.pm @@ -116,10 +116,17 @@ sub get_token { sub get_cache_networks { my ($self, %options) = @_; - $self->cache_networks_organizations(); + $self->cache_meraki_entities(); return $self->{cache_networks}; } +sub get_cache_devices { + my ($self, %options) = @_; + + $self->cache_meraki_entities(); + return $self->{cache_devices}; +} + sub build_options_for_httplib { my ($self, %options) = @_; @@ -171,7 +178,7 @@ sub request_api { } while (1); } -sub cache_networks_organizations { +sub cache_meraki_entities { my ($self, %options) = @_; return if ($self->{cache_checked} == 1); @@ -181,16 +188,19 @@ sub cache_networks_organizations { my $timestamp_cache = $self->{cache}->get(name => 'last_timestamp'); $self->{cache_organizations} = $self->{cache}->get(name => 'organizations'); $self->{cache_networks} = $self->{cache}->get(name => 'networks'); + $self->{cache_devices} = $self->{cache}->get(name => 'devices'); if ($has_cache_file == 0 || !defined($timestamp_cache) || ((time() - $timestamp_cache) > (($self->{reload_cache_time}) * 60))) { $self->{cache_organizations} = {}; $self->{cache_organizations} = $self->get_organizations(disable_cache => 1); $self->{cache_networks} = $self->get_networks(organizations => [keys %{$self->{cache_organizations}}], disable_cache => 1); + $self->{cache_devices} = $self->get_devices(organizations => [keys %{$self->{cache_organizations}}], disable_cache => 1); $self->{cache}->write(data => { last_timestamp => time(), organizations => $self->{cache_organizations}, - networks => $self->{cache_networks} + networks => $self->{cache_networks}, + devices => $self->{cache_devices} }); } } @@ -198,7 +208,7 @@ sub cache_networks_organizations { sub get_organizations { my ($self, %options) = @_; - $self->cache_networks_organizations(); + $self->cache_meraki_entities(); return $self->{cache_organizations} if (!defined($options{disable_cache}) || $options{disable_cache} == 0); my $datas = $self->request_api(endpoint => '/organizations'); my $results = {}; @@ -210,7 +220,7 @@ sub get_organizations { sub get_networks { my ($self, %options) = @_; - $self->cache_networks_organizations(); + $self->cache_meraki_entities(); return $self->{cache_networks} if (!defined($options{disable_cache}) || $options{disable_cache} == 0); my $results = {}; @@ -222,6 +232,21 @@ sub get_networks { return $results; } +sub get_devices { + my ($self, %options) = @_; + + $self->cache_meraki_entities(); + return $self->{cache_devices} if (!defined($options{disable_cache}) || $options{disable_cache} == 0); + + my $results = {}; + foreach my $id (keys %{$self->{cache_organizations}}) { + my $datas = $self->request_api(endpoint => '/organizations/' . $id . '/devices'); + $results->{$_->{serial}} = $_ foreach (@$datas); + } + + return $results; +} + sub filter_networks { my ($self, %options) = @_; @@ -242,10 +267,25 @@ sub filter_networks { return $network_ids; } +sub filter_organizations { + my ($self, %options) = @_; + + my $organization_ids = []; + foreach (values %{$self->{cache_organizations}}) { + if (!defined($options{filter_name}) || $options{filter_name} eq '') { + push @$organization_ids, $_->{id}; + } elsif ($_->{name} =~ /$options{filter_name}/) { + push @$organization_ids, $_->{id}; + } + } + + return $organization_ids; +} + sub get_networks_connection_stats { my ($self, %options) = @_; - $self->cache_networks_organizations(); + $self->cache_meraki_entities(); my $network_ids = $self->filter_networks(filter_name => $options{filter_name}); my $timespan = defined($options{timespan}) ? $options{timespan} : 300; @@ -262,7 +302,7 @@ sub get_networks_connection_stats { sub get_networks_clients { my ($self, %options) = @_; - $self->cache_networks_organizations(); + $self->cache_meraki_entities(); my $network_ids = $self->filter_networks(filter_name => $options{filter_name}); my $timespan = defined($options{timespan}) ? $options{timespan} : 300; @@ -276,8 +316,82 @@ sub get_networks_clients { return $results; } -sub get_device_statuses { +sub get_organization_device_statuses { my ($self, %options) = @_; + + $self->cache_meraki_entities(); + my $organization_ids = $self->filter_organizations(filter_name => $options{filter_name}); + my $results = {}; + foreach my $id (@$organization_ids) { + my $datas = $self->request_api(endpoint => '/organizations/' . $id . '/deviceStatuses'); + foreach (@$datas) { + $results->{$_->{serial}} = $_; + $results->{organizationId} = $id; + } + } + + return $results; +} + +sub get_network_device_connection_stats { + my ($self, %options) = @_; + + if (scalar(keys %{$options{devices}}) > 5) { + $self->{output}->add_option_msg(short_msg => 'cannot check more than 5 devices at once (api rate limit)'); + $self->{output}->option_exit(); + } + + $self->cache_meraki_entities(); + my $timespan = defined($options{timespan}) ? $options{timespan} : 300; + $timespan = 1 if ($timespan <= 0); + + my $results = {}; + foreach (keys %{$options{devices}}) { + my $data = $self->request_api(endpoint => '/networks/' . $options{devices}->{$_} . '/devices/' . $_ . '/connectionStats?timespan=' . $options{timespan}); + $results->{$_} = $data; + } + + return $results; +} + +sub get_network_device_uplink { + my ($self, %options) = @_; + + if (scalar(keys %{$options{devices}}) > 5) { + $self->{output}->add_option_msg(short_msg => 'cannot check more than 5 devices at once (api rate limit)'); + $self->{output}->option_exit(); + } + + $self->cache_meraki_entities(); + + my $results = {}; + foreach (keys %{$options{devices}}) { + my $data = $self->request_api(endpoint => '/networks/' . $options{devices}->{$_} . '/devices/' . $_ . '/uplink'); + $results->{$_} = $data; + } + + return $results; +} + +sub get_device_clients { + my ($self, %options) = @_; + + if (scalar(keys %{$options{devices}}) > 5) { + $self->{output}->add_option_msg(short_msg => 'cannot check more than 5 devices at once (api rate limit)'); + $self->{output}->option_exit(); + } + + $self->cache_meraki_entities(); + my $timespan = defined($options{timespan}) ? $options{timespan} : 300; + $timespan = 1 if ($timespan <= 0); + + my $results = {}; + foreach (keys %{$options{devices}}) { + my $data = $self->request_api(endpoint => '/devices/' . $_ . '/clients?timespan=' . $options{timespan}); + $results->{$_} = $data; + } + + return $results; } 1; diff --git a/network/cisco/meraki/cloudcontroller/restapi/mode/devices.pm b/network/cisco/meraki/cloudcontroller/restapi/mode/devices.pm new file mode 100644 index 000000000..26e46067d --- /dev/null +++ b/network/cisco/meraki/cloudcontroller/restapi/mode/devices.pm @@ -0,0 +1,372 @@ +# +# Copyright 2020 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 network::cisco::meraki::cloudcontroller::restapi::mode::devices; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); +use Digest::MD5 qw(md5_hex); + +sub custom_status_output { + my ($self, %options) = @_; + + return 'status: ' . $self->{result_values}->{status}; +} + +sub custom_link_status_output { + my ($self, %options) = @_; + + return 'status: ' . $self->{result_values}->{link_status}; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0, cb_prefix_output => 'prefix_global_output', skipped_code => { -10 => 1 } }, + { name => 'devices', type => 3, cb_prefix_output => 'prefix_device_output', cb_long_output => 'device_long_output', indent_long_output => ' ', message_multiple => 'All devices are ok', + group => [ + { name => 'device_status', type => 0, skipped_code => { -10 => 1 } }, + { name => 'device_connections', type => 0, cb_prefix_output => 'prefix_connection_output', skipped_code => { -10 => 1 } }, + { name => 'device_traffic', type => 0, cb_prefix_output => 'prefix_traffic_output', skipped_code => { -10 => 1, -11 => 1 } }, + { name => 'device_links', display_long => 1, cb_prefix_output => 'prefix_link_output', message_multiple => 'All links are ok', type => 1, skipped_code => { -10 => 1 } }, + ] + } + ]; + + $self->{maps_counters}->{global} = [ + { label => 'total-online', nlabel => 'devices.total.online.count', display_ok => 0, set => { + key_values => [ { name => 'online'}, { name => 'total'} ], + output_template => 'online: %s', + perfdatas => [ + { value => 'online_absolute', template => '%s', min => 0, max => 'total_absolute' } + ] + } + }, + { label => 'total-offline', nlabel => 'devices.total.offline.count', display_ok => 0, set => { + key_values => [ { name => 'offline'}, { name => 'total'} ], + output_template => 'offline: %s', + perfdatas => [ + { value => 'offline_absolute', template => '%s', min => 0, max => 'total_absolute' } + ] + } + }, + { label => 'total-alerting', nlabel => 'devices.total.alerting.count', display_ok => 0, set => { + key_values => [ { name => 'alerting'}, { name => 'total'} ], + output_template => 'alerting: %s', + perfdatas => [ + { value => 'alerting_absolute', template => '%s', min => 0, max => 'total_absolute' } + ] + } + }, + ]; + + $self->{maps_counters}->{device_status} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'status' }, { name => 'display' } ], + closure_custom_calc => \&catalog_status_calc, + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold + } + } + ]; + + $self->{maps_counters}->{device_connections} = [ + { label => 'connections-success', nlabel => 'device.connections.success.count', set => { + key_values => [ { name => 'assoc' }, { name => 'display' } ], + output_template => 'success: %s', + perfdatas => [ + { value => 'assoc_absolute', + template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' } + ] + } + }, + { label => 'connections-auth', nlabel => 'device.connections.auth.count', display_ok => 0, set => { + key_values => [ { name => 'auth' }, { name => 'display' } ], + output_template => 'auth: %s', + perfdatas => [ + { value => 'auth_absolute', + template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' } + ] + } + }, + { label => 'connections-assoc', nlabel => 'device.connections.assoc.count', display_ok => 0, set => { + key_values => [ { name => 'assoc' }, { name => 'display' } ], + output_template => 'assoc: %s', + perfdatas => [ + { value => 'assoc_absolute', + template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' } + ] + } + }, + { label => 'connections-dhcp', nlabel => 'device.connections.dhcp.count', display_ok => 0, set => { + key_values => [ { name => 'dhcp' }, { name => 'display' } ], + output_template => 'dhcp: %s', + perfdatas => [ + { value => 'dhcp_absolute', + template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' } + ] + } + }, + { label => 'connections-dns', nlabel => 'device.connections.dns.count', display_ok => 0, set => { + key_values => [ { name => 'dns' }, { name => 'display' } ], + output_template => 'dns: %s', + perfdatas => [ + { value => 'dns_absolute', + template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' } + ] + } + } + ]; + + $self->{maps_counters}->{device_traffic} = [ + { label => 'traffic-in', nlabel => 'device.traffic.in.bitspersecond', set => { + key_values => [ { name => 'traffic_in', diff => 1 }, { name => 'display' } ], + output_template => 'in: %s %s/s', + per_second => 1, output_change_bytes => 2, + perfdatas => [ + { value => 'traffic_in_per_second', template => '%s', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' } + ] + } + }, + { label => 'traffic-out', nlabel => 'device.traffic.out.bitspersecond', set => { + key_values => [ { name => 'traffic_out', diff => 1 }, { name => 'display' } ], + output_template => 'out: %s %s/s', + per_second => 1, output_change_bytes => 2, + perfdatas => [ + { value => 'traffic_out_per_second', template => '%s', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' } + ] + } + } + ]; + + $self->{maps_counters}->{device_links} = [ + { label => 'link-status', threshold => 0, set => { + key_values => [ { name => 'link_status' }, { name => 'display' } ], + closure_custom_calc => \&catalog_status_calc, + closure_custom_output => $self->can('custom_link_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold + } + } + ]; +} + +sub device_long_output { + my ($self, %options) = @_; + + return "checking device '" . $options{instance_value}->{display} . "'"; +} + +sub prefix_device_output { + my ($self, %options) = @_; + + return "Device '" . $options{instance_value}->{display} . "' "; +} + +sub prefix_global_output { + my ($self, %options) = @_; + + return 'Devices '; +} + +sub prefix_connection_output { + my ($self, %options) = @_; + + return 'connection '; +} + +sub prefix_traffic_output { + my ($self, %options) = @_; + + return 'traffic '; +} + +sub prefix_link_output { + my ($self, %options) = @_; + + return "link '" . $options{instance_value}->{display} . "' "; +} + +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 => { + 'filter-name:s' => { name => 'filter_name' }, + 'unknown-status:s' => { name => 'unknown_status', default => '' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '%{status} =~ /alerting/i' }, + 'unknown-link-status:s' => { name => 'unknown_link_status', default => '' }, + 'warning-link-status:s' => { name => 'warning_link_status', default => '' }, + 'critical-link-status:s' => { name => 'critical_link_status', default => '%{link_status} =~ /failed/i' } + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->change_macros(macros => [ + 'unknown_status', 'warning_status', 'critical_status', + 'unknown_link_status', 'warning_link_status', 'critical_link_status' + ]); +} + +sub manage_selection { + my ($self, %options) = @_; + + $self->{cache_name} = 'meraki_' . $self->{mode} . '_' . $options{custom}->get_token() . '_' . + (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')); + my $last_timestamp = $self->read_statefile_key(key => 'last_timestamp'); + my $timespan = 300; + $timespan = time() - $last_timestamp if (defined($last_timestamp)); + + my $cache_devices = $options{custom}->get_cache_devices(); + my $devices = {}; + foreach (values %$cache_devices) { + 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 device '" . $_->{name} . "': no matching filter.", debug => 1); + next; + } + + $devices->{$_->{serial}} = $_->{networkId}; + } + + my $device_statuses = $options{custom}->get_organization_device_statuses(); + my $connections = $options{custom}->get_network_device_connection_stats(timespan => $timespan, devices => $devices); + my $clients = $options{custom}->get_device_clients(timespan => $timespan, devices => $devices); + my $links = $options{custom}->get_network_device_uplink(devices => $devices); + + $self->{global} = { total => 0, online => 0, offline => 0, alerting => 0 }; + $self->{devices} = {}; + foreach my $serial (keys %$devices) { + $self->{devices}->{$serial} = { + display => $cache_devices->{$serial}->{name}, + device_status => { + display => $cache_devices->{$serial}->{name}, + status => $device_statuses->{$serial}->{status} + }, + device_connections => { + display => $cache_devices->{$serial}->{name}, + assoc => defined($connections->{$serial}->{assoc}) ? $connections->{$serial}->{assoc} : 0, + auth => defined($connections->{$serial}->{auth}) ? $connections->{$serial}->{auth} : 0, + dhcp => defined($connections->{$serial}->{dhcp}) ? $connections->{$serial}->{dhcp} : 0, + dns => defined($connections->{$serial}->{dns}) ? $connections->{$serial}->{dns} : 0, + success => defined($connections->{$serial}->{assoc}) ? $connections->{$serial}->{success} : 0, + }, + device_traffic => { + display => $cache_devices->{$serial}->{name}, + traffic_in => 0, + traffic_out => 0 + }, + device_links => {} + }; + + if (defined($clients->{$serial})) { + foreach (@{$clients->{$serial}}) { + $self->{devices}->{$serial}->{device_traffic}->{traffic_in} += $_->{usage}->{recv} * 8; + $self->{devices}->{$serial}->{device_traffic}->{traffic_out} += $_->{usage}->{sent} * 8; + } + } + + if (defined($links->{$serial})) { + foreach (@{$links->{$serial}}) { + $self->{devices}->{$serial}->{device_links}->{$_->{interface}} = { + display => $_->{interface}, + link_status => lc($_->{status}) + }; + } + } + + $self->{global}->{total}++; + $self->{global}->{ lc($device_statuses->{$serial}->{status}) }++ + if (!defined($self->{global}->{ lc($device_statuses->{$serial}->{status}) })) + } + + if (scalar(keys %{$self->{devices}}) <= 0) { + $self->{output}->output_add(short_msg => 'no devices found'); + } +} + +1; + +__END__ + +=head1 MODE + +Check devices. + +=over 8 + +=item B<--filter-name> + +Filter device name (Can be a regexp). + +=item B<--unknown-status> + +Set unknown threshold for status. +Can used special variables like: %{status}, %{display} + +=item B<--warning-status> + +Set warning threshold for status. +Can used special variables like: %{status}, %{display} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{status} =~ /alerting/i'). +Can used special variables like: %{status}, %{display} + +=item B<--unknown-link-status> + +Set unknown threshold for status. +Can used special variables like: %{link_status}, %{display} + +=item B<--warning-link-status> + +Set warning threshold for status. +Can used special variables like: %{link_status}, %{display} + +=item B<--critical-link-status> + +Set critical threshold for status (Default: '%{link_status} =~ /failed/i'). +Can used special variables like: %{link_status}, %{display} + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'connections-success', 'connections-auth', 'connections-assoc', +'connections-dhcp', 'connections-dns', 'traffic-in', 'traffic-out'. + +=back + +=cut diff --git a/network/cisco/meraki/cloudcontroller/restapi/mode/networks.pm b/network/cisco/meraki/cloudcontroller/restapi/mode/networks.pm index ce53e1e7a..4960262ba 100644 --- a/network/cisco/meraki/cloudcontroller/restapi/mode/networks.pm +++ b/network/cisco/meraki/cloudcontroller/restapi/mode/networks.pm @@ -139,10 +139,10 @@ sub manage_selection { $self->{networks}->{$id} = { display => $cache_networks->{$id}->{name}, assoc => defined($connections->{$id}->{assoc}) ? $connections->{$id}->{assoc} : 0, - auth => defined($connections->{$id}->{assoc}) ? $connections->{$id}->{auth} : 0, - dhcp => defined($connections->{$id}->{assoc}) ? $connections->{$id}->{assoc} : 0, - dns => defined($connections->{$id}->{assoc}) ? $connections->{$id}->{dhcp} : 0, - success => defined($connections->{$id}->{assoc}) ? $connections->{$id}->{success} : 0, + auth => defined($connections->{$id}->{auth}) ? $connections->{$id}->{auth} : 0, + dhcp => defined($connections->{$id}->{dhcp}) ? $connections->{$id}->{dhcp} : 0, + dns => defined($connections->{$id}->{dns}) ? $connections->{$id}->{dns} : 0, + success => defined($connections->{$id}->{success}) ? $connections->{$id}->{success} : 0, traffic_in => 0, traffic_out => 0 }; From be896402c63dbe0a745a5d11b1446200fc608816 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 1 Apr 2020 13:42:24 +0200 Subject: [PATCH 060/283] wip: add cisco meraki api requests --- .../cloudcontroller/restapi/custom/api.pm | 23 +++ .../restapi/mode/apirequests.pm | 136 ++++++++++++++++++ .../meraki/cloudcontroller/restapi/plugin.pm | 5 +- 3 files changed, 162 insertions(+), 2 deletions(-) create mode 100644 network/cisco/meraki/cloudcontroller/restapi/mode/apirequests.pm diff --git a/network/cisco/meraki/cloudcontroller/restapi/custom/api.pm b/network/cisco/meraki/cloudcontroller/restapi/custom/api.pm index f846f6d12..6e866a2f6 100644 --- a/network/cisco/meraki/cloudcontroller/restapi/custom/api.pm +++ b/network/cisco/meraki/cloudcontroller/restapi/custom/api.pm @@ -113,6 +113,13 @@ sub get_token { return md5_hex($self->{api_token}); } +sub get_cache_organizations { + my ($self, %options) = @_; + + $self->cache_meraki_entities(); + return $self->{cache_organizations}; +} + sub get_cache_networks { my ($self, %options) = @_; @@ -333,6 +340,22 @@ sub get_organization_device_statuses { return $results; } +sub get_organization_api_requests_overview { + my ($self, %options) = @_; + + $self->cache_meraki_entities(); + my $organization_ids = $self->filter_organizations(filter_name => $options{filter_name}); + my $timespan = defined($options{timespan}) ? $options{timespan} : 300; + $timespan = 1 if ($timespan <= 0); + + my $results = {}; + foreach my $id (@$organization_ids) { + $results->{$id} = $self->request_api(endpoint => '/organizations/' . $id . '/apiRequests/overview?timespan=' . $options{timespan}); + } + + return $results; +} + sub get_network_device_connection_stats { my ($self, %options) = @_; diff --git a/network/cisco/meraki/cloudcontroller/restapi/mode/apirequests.pm b/network/cisco/meraki/cloudcontroller/restapi/mode/apirequests.pm new file mode 100644 index 000000000..b738ea9db --- /dev/null +++ b/network/cisco/meraki/cloudcontroller/restapi/mode/apirequests.pm @@ -0,0 +1,136 @@ +# +# Copyright 2020 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 network::cisco::meraki::cloudcontroller::restapi::mode::apirequests; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use Digest::MD5 qw(md5_hex); + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'organizations', type => 1, cb_prefix_output => 'prefix_organization_output', message_multiple => 'All organizations are ok' } + ]; + + $self->{maps_counters}->{organizations} = [ + { label => 'api-requests-200', nlabel => 'organization.api.requests.200.count', set => { + key_values => [ { name => 'requests_200' }, { name => 'display' } ], + output_template => 'code 200: %s', + perfdatas => [ + { value => 'requests_200_absolute', + template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' } + ] + } + }, + { label => 'api-requests-404', nlabel => 'organization.api.requests.404.count', set => { + key_values => [ { name => 'requests_404' }, { name => 'display' } ], + output_template => 'code 404: %s', + perfdatas => [ + { value => 'requests_404_absolute', + template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' } + ] + } + }, + { label => 'api-requests-429', nlabel => 'organization.api.requests.429.count', set => { + key_values => [ { name => 'requests_429' }, { name => 'display' } ], + output_template => 'code 429: %s', + perfdatas => [ + { value => 'requests_429_absolute', + template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' } + ] + } + } + ]; +} + +sub prefix_organization_output { + my ($self, %options) = @_; + + return "Organization '" . $options{instance_value}->{display} . "' requests "; +} + +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 => { + 'filter-name:s' => { name => 'filter_name' } + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + $self->{cache_name} = 'meraki_' . $self->{mode} . '_' . $options{custom}->get_token() . '_' . + (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')); + my $last_timestamp = $self->read_statefile_key(key => 'last_timestamp'); + my $timespan = 300; + $timespan = time() - $last_timestamp if (defined($last_timestamp)); + + my $cache_organizations = $options{custom}->get_cache_organizations(); + my $api_requests = $options{custom}->get_organization_api_requests_overview(timespan => $timespan, filter_name => $self->{option_results}->{filter_name}); + + $self->{organizations} = {}; + foreach my $id (keys %$api_requests) { + $self->{organizations}->{$id} = { + display => $cache_organizations->{$id}->{name}, + requests_200 => defined($api_requests->{$id}->{responseCodeCounts}->{200}) ? $api_requests->{$id}->{responseCodeCounts}->{200} : 0, + requests_404 => defined($api_requests->{$id}->{responseCodeCounts}->{404}) ? $api_requests->{$id}->{responseCodeCounts}->{404} : 0, + requests_429 => defined($api_requests->{$id}->{responseCodeCounts}->{429}) ? $api_requests->{$id}->{responseCodeCounts}->{429} : 0, + }; + } + + if (scalar(keys %{$self->{organizations}}) <= 0) { + $self->{output}->add_option_msg(short_msg => "No organizations found."); + $self->{output}->option_exit(); + } +} + +1; + +__END__ + +=head1 MODE + +Check api requests. + +=over 8 + +=item B<--filter-name> + +Filter organization name (Can be a regexp). + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'connections-success', 'connections-auth', 'connections-assoc', +'connections-dhcp', 'connections-dns', 'traffic-in', 'traffic-out'. + +=back + +=cut diff --git a/network/cisco/meraki/cloudcontroller/restapi/plugin.pm b/network/cisco/meraki/cloudcontroller/restapi/plugin.pm index ed31ce585..136e24225 100644 --- a/network/cisco/meraki/cloudcontroller/restapi/plugin.pm +++ b/network/cisco/meraki/cloudcontroller/restapi/plugin.pm @@ -31,8 +31,9 @@ sub new { $self->{version} = '1.0'; %{$self->{modes}} = ( - 'devices' => 'network::cisco::meraki::cloudcontroller::restapi::mode::devices', - 'networks' => 'network::cisco::meraki::cloudcontroller::restapi::mode::networks' + 'api-requests' => 'network::cisco::meraki::cloudcontroller::restapi::mode::apirequests', + 'devices' => 'network::cisco::meraki::cloudcontroller::restapi::mode::devices', + 'networks' => 'network::cisco::meraki::cloudcontroller::restapi::mode::networks' ); $self->{custom_modes}{api} = 'network::cisco::meraki::cloudcontroller::restapi::custom::api'; From 12145154de52c75310daed7d6e268d59915d939b Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 1 Apr 2020 13:43:38 +0200 Subject: [PATCH 061/283] wip: add cisco meraki api requests --- .../cisco/meraki/cloudcontroller/restapi/mode/apirequests.pm | 3 +-- network/cisco/meraki/cloudcontroller/restapi/mode/devices.pm | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/network/cisco/meraki/cloudcontroller/restapi/mode/apirequests.pm b/network/cisco/meraki/cloudcontroller/restapi/mode/apirequests.pm index b738ea9db..d40159f41 100644 --- a/network/cisco/meraki/cloudcontroller/restapi/mode/apirequests.pm +++ b/network/cisco/meraki/cloudcontroller/restapi/mode/apirequests.pm @@ -128,8 +128,7 @@ Filter organization name (Can be a regexp). =item B<--warning-*> B<--critical-*> Thresholds. -Can be: 'connections-success', 'connections-auth', 'connections-assoc', -'connections-dhcp', 'connections-dns', 'traffic-in', 'traffic-out'. +Can be: 'api-requests-200', 'api-requests-404', 'api-requests-429'. =back diff --git a/network/cisco/meraki/cloudcontroller/restapi/mode/devices.pm b/network/cisco/meraki/cloudcontroller/restapi/mode/devices.pm index 26e46067d..8a7bdb35e 100644 --- a/network/cisco/meraki/cloudcontroller/restapi/mode/devices.pm +++ b/network/cisco/meraki/cloudcontroller/restapi/mode/devices.pm @@ -364,8 +364,9 @@ Can used special variables like: %{link_status}, %{display} =item B<--warning-*> B<--critical-*> Thresholds. -Can be: 'connections-success', 'connections-auth', 'connections-assoc', -'connections-dhcp', 'connections-dns', 'traffic-in', 'traffic-out'. +Can be: 'total-online', 'total-offline', 'total-alerting', +'traffic-in', 'traffic-out', 'connections-success', 'connections-auth', +'connections-assoc', 'connections-dhcp', 'connections-dns'. =back From cf37277621a7ea16c21512325e67534ea22ae035 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 1 Apr 2020 14:54:09 +0200 Subject: [PATCH 062/283] add discovery for meraki rest api --- .../cloudcontroller/restapi/mode/discovery.pm | 114 ++++++++++++++++++ .../meraki/cloudcontroller/restapi/plugin.pm | 1 + 2 files changed, 115 insertions(+) create mode 100644 network/cisco/meraki/cloudcontroller/restapi/mode/discovery.pm diff --git a/network/cisco/meraki/cloudcontroller/restapi/mode/discovery.pm b/network/cisco/meraki/cloudcontroller/restapi/mode/discovery.pm new file mode 100644 index 000000000..2ceffee3c --- /dev/null +++ b/network/cisco/meraki/cloudcontroller/restapi/mode/discovery.pm @@ -0,0 +1,114 @@ +# +# Copyright 2020 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 network::cisco::meraki::cloudcontroller::restapi::mode::discovery; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use JSON::XS; + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $options{options}->add_options(arguments => { + 'prettify' => { name => 'prettify' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); +} + +sub run { + my ($self, %options) = @_; + + my (@disco_data, $disco_stats); + $disco_stats->{start_time} = time(); + + my $organizations = $options{custom}->get_organizations(disable_cache => 1); + my $networks = $options{custom}->get_networks(organizations => [keys %{$self->{organizations}}], disable_cache => 1); + my $devices = $options{custom}->get_devices(organizations => [keys %{$self->{organizations}}], disable_cache => 1); + my $devices_statuses = $options{custom}->get_organization_device_statuses(); + + $disco_stats->{end_time} = time(); + $disco_stats->{duration} = $disco_stats->{end_time} - $disco_stats->{start_time}; + + foreach (values %$devices) { + my $node = { + %$_, + %{$devices_statuses->{$_->{serial}}}, + networkName => $networks->{ $devices_statuses->{$_->{serial}}->{networkId} }->{name}, + organizationName => $organizations->{ $networks->{ $devices_statuses->{$_->{serial}}->{networkId} }->{organizationId} }->{name}, + type => 'device' + }; + + push @disco_data, $node; + } + + foreach (values %$networks) { + my $node = { + %$_, + organizationName => $organizations->{ $_->{organizationId} }->{name}, + type => 'network' + }; + + push @disco_data, $node; + } + + $disco_stats->{discovered_items} = @disco_data; + $disco_stats->{results} = \@disco_data; + + my $encoded_data; + eval { + if (defined($self->{option_results}->{prettify})) { + $encoded_data = JSON::XS->new->utf8->pretty->encode($disco_stats); + } else { + $encoded_data = JSON::XS->new->utf8->encode($disco_stats); + } + }; + if ($@) { + $encoded_data = '{"code":"encode_error","message":"Cannot encode discovered data into JSON format"}'; + } + + $self->{output}->output_add(short_msg => $encoded_data); + $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1); + $self->{output}->exit(); +} + +1; + +__END__ + +=head1 MODE + +Resources discovery. + +=over 8 + +=back + +=cut diff --git a/network/cisco/meraki/cloudcontroller/restapi/plugin.pm b/network/cisco/meraki/cloudcontroller/restapi/plugin.pm index 136e24225..30e023dbf 100644 --- a/network/cisco/meraki/cloudcontroller/restapi/plugin.pm +++ b/network/cisco/meraki/cloudcontroller/restapi/plugin.pm @@ -33,6 +33,7 @@ sub new { %{$self->{modes}} = ( 'api-requests' => 'network::cisco::meraki::cloudcontroller::restapi::mode::apirequests', 'devices' => 'network::cisco::meraki::cloudcontroller::restapi::mode::devices', + 'discovery' => 'network::cisco::meraki::cloudcontroller::restapi::mode::discovery', 'networks' => 'network::cisco::meraki::cloudcontroller::restapi::mode::networks' ); From bc2ccf496fef575a7c5d7088175f58e4cb91b83f Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 1 Apr 2020 15:03:13 +0200 Subject: [PATCH 063/283] update variable filter meraki --- .../meraki/cloudcontroller/restapi/mode/devices.pm | 10 +++++----- .../meraki/cloudcontroller/restapi/mode/networks.pm | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/network/cisco/meraki/cloudcontroller/restapi/mode/devices.pm b/network/cisco/meraki/cloudcontroller/restapi/mode/devices.pm index 8a7bdb35e..db4ad3088 100644 --- a/network/cisco/meraki/cloudcontroller/restapi/mode/devices.pm +++ b/network/cisco/meraki/cloudcontroller/restapi/mode/devices.pm @@ -217,7 +217,7 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - 'filter-name:s' => { name => 'filter_name' }, + 'filter-device-name:s' => { name => 'filter_device_name' }, 'unknown-status:s' => { name => 'unknown_status', default => '' }, 'warning-status:s' => { name => 'warning_status', default => '' }, 'critical-status:s' => { name => 'critical_status', default => '%{status} =~ /alerting/i' }, @@ -244,7 +244,7 @@ sub manage_selection { $self->{cache_name} = 'meraki_' . $self->{mode} . '_' . $options{custom}->get_token() . '_' . (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')); + (defined($self->{option_results}->{filter_device_name}) ? md5_hex($self->{option_results}->{filter_device_name}) : md5_hex('all')); my $last_timestamp = $self->read_statefile_key(key => 'last_timestamp'); my $timespan = 300; $timespan = time() - $last_timestamp if (defined($last_timestamp)); @@ -252,8 +252,8 @@ sub manage_selection { my $cache_devices = $options{custom}->get_cache_devices(); my $devices = {}; foreach (values %$cache_devices) { - if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && - $_->{name} !~ /$self->{option_results}->{filter_name}/) { + if (defined($self->{option_results}->{filter_device_name}) && $self->{option_results}->{filter_device_name} ne '' && + $_->{name} !~ /$self->{option_results}->{filter_device_name}/) { $self->{output}->output_add(long_msg => "skipping device '" . $_->{name} . "': no matching filter.", debug => 1); next; } @@ -327,7 +327,7 @@ Check devices. =over 8 -=item B<--filter-name> +=item B<--filter-device-name> Filter device name (Can be a regexp). diff --git a/network/cisco/meraki/cloudcontroller/restapi/mode/networks.pm b/network/cisco/meraki/cloudcontroller/restapi/mode/networks.pm index 4960262ba..64e53ef5e 100644 --- a/network/cisco/meraki/cloudcontroller/restapi/mode/networks.pm +++ b/network/cisco/meraki/cloudcontroller/restapi/mode/networks.pm @@ -114,7 +114,7 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - 'filter-name:s' => { name => 'filter_name' } + 'filter-network-name:s' => { name => 'filter_network_name' } }); return $self; @@ -125,14 +125,14 @@ sub manage_selection { $self->{cache_name} = 'meraki_' . $self->{mode} . '_' . $options{custom}->get_token() . '_' . (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')); + (defined($self->{option_results}->{filter_network_name}) ? md5_hex($self->{option_results}->{filter_network_name}) : md5_hex('all')); my $last_timestamp = $self->read_statefile_key(key => 'last_timestamp'); my $timespan = 300; $timespan = time() - $last_timestamp if (defined($last_timestamp)); my $cache_networks = $options{custom}->get_cache_networks(); - my $connections = $options{custom}->get_networks_connection_stats(timespan => $timespan, filter_name => $self->{option_results}->{filter_name}); - my $clients = $options{custom}->get_networks_clients(timespan => $timespan, filter_name => $self->{option_results}->{filter_name}); + my $connections = $options{custom}->get_networks_connection_stats(timespan => $timespan, filter_name => $self->{option_results}->{filter_network_name}); + my $clients = $options{custom}->get_networks_clients(timespan => $timespan, filter_name => $self->{option_results}->{filter_network_name}); $self->{networks} = {}; foreach my $id (keys %$connections) { @@ -170,7 +170,7 @@ Check networks. =over 8 -=item B<--filter-name> +=item B<--filter-network-name> Filter network name (Can be a regexp). From d7a9641cd4f5ea03a408a4159a31f0d0c976107d Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 1 Apr 2020 15:04:24 +0200 Subject: [PATCH 064/283] update variable filter meraki --- .../meraki/cloudcontroller/restapi/mode/apirequests.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/network/cisco/meraki/cloudcontroller/restapi/mode/apirequests.pm b/network/cisco/meraki/cloudcontroller/restapi/mode/apirequests.pm index d40159f41..092c91dda 100644 --- a/network/cisco/meraki/cloudcontroller/restapi/mode/apirequests.pm +++ b/network/cisco/meraki/cloudcontroller/restapi/mode/apirequests.pm @@ -76,7 +76,7 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - 'filter-name:s' => { name => 'filter_name' } + 'filter-organization-name:s' => { name => 'filter_organization_name' } }); return $self; @@ -87,13 +87,13 @@ sub manage_selection { $self->{cache_name} = 'meraki_' . $self->{mode} . '_' . $options{custom}->get_token() . '_' . (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')); + (defined($self->{option_results}->{filter_organization_name}) ? md5_hex($self->{option_results}->{filter_organization_name}) : md5_hex('all')); my $last_timestamp = $self->read_statefile_key(key => 'last_timestamp'); my $timespan = 300; $timespan = time() - $last_timestamp if (defined($last_timestamp)); my $cache_organizations = $options{custom}->get_cache_organizations(); - my $api_requests = $options{custom}->get_organization_api_requests_overview(timespan => $timespan, filter_name => $self->{option_results}->{filter_name}); + my $api_requests = $options{custom}->get_organization_api_requests_overview(timespan => $timespan, filter_name => $self->{option_results}->{filter_organization_name}); $self->{organizations} = {}; foreach my $id (keys %$api_requests) { @@ -121,7 +121,7 @@ Check api requests. =over 8 -=item B<--filter-name> +=item B<--filter-organization-name> Filter organization name (Can be a regexp). From af235650ee992fab1692e7b53cfb5dfaa5765394 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 1 Apr 2020 17:39:51 +0200 Subject: [PATCH 065/283] enhance indent --- database/oracle/mode/rmanbackupage.pm | 66 +++++++++++++++------------ 1 file changed, 37 insertions(+), 29 deletions(-) diff --git a/database/oracle/mode/rmanbackupage.pm b/database/oracle/mode/rmanbackupage.pm index afd2b6d98..25bd09c06 100644 --- a/database/oracle/mode/rmanbackupage.pm +++ b/database/oracle/mode/rmanbackupage.pm @@ -30,22 +30,22 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - + $options{options}->add_options(arguments => { - "skip-no-backup" => { name => 'skip_no_backup', }, - "filter-type:s" => { name => 'filter_type', }, - "timezone:s" => { name => 'timezone', }, - "incremental-level" => { name => 'incremental_level', }, + 'skip-no-backup' => { name => 'skip_no_backup', }, + 'filter-type:s' => { name => 'filter_type', }, + 'timezone:s' => { name => 'timezone', }, + 'incremental-level' => { name => 'incremental_level', }, }); foreach (('db incr', 'db full', 'archivelog', 'controlfile')) { my $label = $_; $label =~ s/ /-/g; $options{options}->add_options(arguments => { - 'warning-' . $label . ':s' => { name => 'warning-' . $label }, - 'critical-' . $label . ':s' => { name => 'critical-' . $label }, - 'no-' . $label => { name => 'no-' . $label }, - }); + 'warning-' . $label . ':s' => { name => 'warning-' . $label }, + 'critical-' . $label . ':s' => { name => 'critical-' . $label }, + 'no-' . $label => { name => 'no-' . $label }, + }); } return $self; @@ -69,7 +69,7 @@ sub check_options { if (defined($self->{option_results}->{timezone}) && $self->{option_results}->{timezone} ne '') { $ENV{TZ} = $self->{option_results}->{timezone}; } - + if (defined($self->{option_results}->{incremental_level})) { # the special request don't retrieve controlfiles. But controlfiles are saved with archivelog. $self->{option_results}->{'no-controlfile'} = 1; @@ -135,13 +135,13 @@ sub run { my @values = localtime($last_time); my $dt = DateTime->new( - year => $values[5] + 1900, - month => $values[4] + 1, - day => $values[3], - hour => $values[2], - minute => $values[1], - second => $values[0], - time_zone => 'UTC', + year => $values[5] + 1900, + month => $values[4] + 1, + day => $values[3], + hour => $values[2], + minute => $values[1], + second => $values[0], + time_zone => 'UTC' ); my $offset = $last_time - $dt->epoch; $last_time = $last_time + $offset; @@ -152,29 +152,37 @@ sub run { my $type_perfdata = $type; $type_perfdata =~ s/ /_/g; $self->{output}->output_add(long_msg => sprintf("Last Rman '%s' backups : %s", $type, $backup_age_convert)); - $self->{output}->perfdata_add(label => sprintf('%s_backup_age', $type_perfdata), - value => $backup_age, - unit => 's', - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $label), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $label), - min => 0); + $self->{output}->perfdata_add( + label => sprintf('%s_backup_age', $type_perfdata), + value => $backup_age, + unit => 's', + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $label), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $label), + min => 0 + ); my $exit_code = $self->{perfdata}->threshold_check(value => $backup_age, threshold => [ { label => 'critical-' . $label, exit_litteral => 'critical' }, { label => 'warning-' . $label, exit_litteral => 'warning' } ]); if (!$self->{output}->is_status(value => $exit_code, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit_code, - short_msg => sprintf("Last Rman '%s' backups : %s", $type, $backup_age_convert)); + $self->{output}->output_add( + severity => $exit_code, + short_msg => sprintf("Last Rman '%s' backups : %s", $type, $backup_age_convert) + ); } } if ($executed == 0 && !defined($self->{option_results}->{'no-' . $label})) { - $self->{output}->output_add(severity => 'CRITICAL', - short_msg => sprintf("Rman '%s' backups never executed", uc($_))); + $self->{output}->output_add( + severity => 'CRITICAL', + short_msg => sprintf("Rman '%s' backups never executed", uc($_)) + ); } } if (($count_backups == 0) && (!defined($self->{option_results}->{skip_no_backup}))) { - $self->{output}->output_add(severity => 'CRITICAL', - short_msg => sprintf("Rman backups never executed.")); + $self->{output}->output_add( + severity => 'CRITICAL', + short_msg => sprintf("Rman backups never executed.") + ); } $self->{output}->display(); From 8f47b32419ca56edf686927944338295a1f875c6 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 2 Apr 2020 09:44:06 +0200 Subject: [PATCH 066/283] Fix #1908 --- snmp_standard/mode/diskusage.pm | 62 ++++++++++++++++++--------------- snmp_standard/mode/storage.pm | 62 +++++++++++++++++++-------------- 2 files changed, 68 insertions(+), 56 deletions(-) diff --git a/snmp_standard/mode/diskusage.pm b/snmp_standard/mode/diskusage.pm index 850438f35..a4a5824c0 100644 --- a/snmp_standard/mode/diskusage.pm +++ b/snmp_standard/mode/diskusage.pm @@ -33,11 +33,12 @@ sub custom_usage_output { my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_absolute}); my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_absolute}); my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute}); - my $msg = sprintf("Usage Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", - $total_size_value . " " . $total_size_unit, - $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used_absolute}, - $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free_absolute}); - return $msg; + return sprintf( + 'Usage Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)', + $total_size_value . " " . $total_size_unit, + $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used_absolute}, + $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free_absolute} + ); } sub set_counters { @@ -53,10 +54,10 @@ sub set_counters { key_values => [ { name => 'count' } ], output_template => 'Partitions count : %d', perfdatas => [ - { label => 'count', value => 'count_absolute', template => '%d', min => 0 }, - ], + { label => 'count', value => 'count_absolute', template => '%d', min => 0 } + ] } - }, + } ]; $self->{maps_counters}->{diskpath} = [ @@ -65,8 +66,8 @@ sub set_counters { closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ { label => 'used', value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute', - unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' }, - ], + unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' } + ] } }, { label => 'usage-free', display_ok => 0, nlabel => 'storage.space.free.bytes', set => { @@ -74,8 +75,8 @@ sub set_counters { closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ { label => 'free', value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute', - unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' }, - ], + unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' } + ] } }, { label => 'usage-prct', display_ok => 0, nlabel => 'storage.space.usage.percentage', set => { @@ -83,8 +84,8 @@ sub set_counters { output_template => 'Used : %.2f %%', perfdatas => [ { label => 'used_prct', value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, - unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' }, - ], + unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' } + ] } }, { label => 'inodes', nlabel => 'storage.inodes.usage.percentage', set => { @@ -92,10 +93,10 @@ sub set_counters { output_template => 'Inodes Used: %s %%', perfdatas => [ { label => 'inodes', value => 'inodes_absolute', template => '%d', - unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, - ], + unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' } + ] } - }, + } ]; } @@ -179,16 +180,18 @@ sub manage_selection { my $name_diskpath = $self->get_display_value(id => $_); if (!defined($result->{$oid_dskTotalHigh . "." . $_})) { - $self->{output}->add_option_msg(long_msg => sprintf( - "skipping partition '%s': not found (need to reload the cache)", - $name_diskpath) + $self->{output}->add_option_msg( + long_msg => sprintf( + "skipping partition '%s': not found (need to reload the cache)", + $name_diskpath + ) ); next; } my $total_size = (($result->{$oid_dskTotalHigh . "." . $_} << 32) + $result->{$oid_dskTotalLow . "." . $_}) * 1024; if ($total_size == 0) { - $self->{output}->output_add(long_msg => sprintf("skipping partition '%s' (total size is 0)", $name_diskpath)); + $self->{output}->output_add(long_msg => sprintf("skipping partition '%s' (total size is 0)", $name_diskpath), debug => 1); next; } my $total_used = (($result->{$oid_dskUsedHigh . "." . $_} << 32) + $result->{$oid_dskUsedLow . "." . $_}) * 1024; @@ -221,7 +224,7 @@ sub manage_selection { } if (scalar(keys %{$self->{diskpath}}) <= 0) { - $self->{output}->add_option_msg(short_msg => "Issue with disk path information (see details)"); + $self->{output}->add_option_msg(short_msg => 'Issue with disk path information (see details)'); $self->{output}->option_exit(); } } @@ -232,9 +235,9 @@ sub reload_cache { $datas->{last_timestamp} = time(); $datas->{all_ids} = []; - + my $oid_dskPath = '.1.3.6.1.4.1.2021.9.1.2'; - + my $result = $self->{snmp}->get_table(oid => $oid_dskPath); foreach my $key ($self->{snmp}->oid_lex_sort(keys %{$result})) { next if ($key !~ /\.([0-9]+)$/); @@ -270,11 +273,11 @@ sub get_selection { my $all_ids = $self->{statefile_cache}->get(name => 'all_ids'); if (!defined($self->{option_results}->{use_name}) && defined($self->{option_results}->{diskpath})) { # get by ID - my $name = $self->{statefile_cache}->get(name => "dskPath_" . $self->{option_results}->{diskpath}); + my $name = $self->{statefile_cache}->get(name => 'dskPath_' . $self->{option_results}->{diskpath}); push @{$self->{diskpath_id_selected}}, $self->{option_results}->{diskpath} if (defined($name)); } else { foreach my $i (@{$all_ids}) { - my $filter_name = $self->{statefile_cache}->get(name => "dskPath_" . $i); + my $filter_name = $self->{statefile_cache}->get(name => 'dskPath_' . $i); next if (!defined($filter_name)); if (!defined($self->{option_results}->{diskpath})) { @@ -292,7 +295,7 @@ sub get_selection { } } } - + if (scalar(@{$self->{diskpath_id_selected}}) <= 0) { $self->{output}->add_option_msg(short_msg => "No disk path found. Can be: filters, cache file."); $self->{output}->option_exit(); @@ -301,12 +304,13 @@ sub get_selection { sub get_display_value { my ($self, %options) = @_; - my $value = $self->{statefile_cache}->get(name => "dskPath_" . $options{id}); - + my $value = $self->{statefile_cache}->get(name => 'dskPath_' . $options{id}); + if (defined($self->{option_results}->{display_transform_src})) { $self->{option_results}->{display_transform_dst} = '' if (!defined($self->{option_results}->{display_transform_dst})); eval "\$value =~ s{$self->{option_results}->{display_transform_src}}{$self->{option_results}->{display_transform_dst}}"; } + return $value; } diff --git a/snmp_standard/mode/storage.pm b/snmp_standard/mode/storage.pm index f1269077d..9321f5c29 100644 --- a/snmp_standard/mode/storage.pm +++ b/snmp_standard/mode/storage.pm @@ -106,7 +106,13 @@ sub custom_usage_threshold { $threshold_value = $self->{result_values}->{prct_used}; $threshold_value = $self->{result_values}->{prct_free} if (defined($self->{instance_mode}->{option_results}->{free})); } - $exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, { label => 'warning-'. $self->{thlabel}, exit_litteral => 'warning' } ]); + $exit = $self->{perfdata}->threshold_check( + value => $threshold_value, + threshold => [ + { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, + { label => 'warning-'. $self->{thlabel}, exit_litteral => 'warning' } + ] + ); return $exit; } @@ -116,11 +122,12 @@ sub custom_usage_output { my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}); my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}); my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}); - my $msg = sprintf("Usage Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", - $total_size_value . " " . $total_size_unit, - $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used}, - $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free}); - return $msg; + return sprintf( + 'Usage Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)', + $total_size_value . " " . $total_size_unit, + $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used}, + $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free} + ); } sub custom_usage_calc { @@ -160,19 +167,19 @@ sub custom_access_output { sub set_counters { my ($self, %options) = @_; - + $self->{maps_counters_type} = [ { name => 'global', type => 0 }, { name => 'storage', type => 1, cb_prefix_output => 'prefix_storage_output', message_multiple => 'All storages are ok', skipped_code => { -10 => 1 } }, ]; - + $self->{maps_counters}->{global} = [ { label => 'count', nlabel => 'storage.partitions.count', display_ok => 0, set => { key_values => [ { name => 'count' } ], output_template => 'Partitions count : %d', perfdatas => [ - { label => 'count', value => 'count_absolute', template => '%d', min => 0 }, - ], + { label => 'count', value => 'count_absolute', template => '%d', min => 0 } + ] } }, ]; @@ -183,7 +190,7 @@ sub set_counters { 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'), + closure_custom_threshold_check => $self->can('custom_usage_threshold') } }, { label => 'access', nlabel => 'storage.access', set => { @@ -191,22 +198,22 @@ sub set_counters { closure_custom_output => $self->can('custom_access_output'), perfdatas => [ { label => 'access', value => 'access_absolute', template => '%d', min => 1, max => 2, - label_extra_instance => 1, instance_use => 'display_absolute' }, - ], + label_extra_instance => 1, instance_use => 'display_absolute' } + ] } - }, + } ]; } sub prefix_storage_output { my ($self, %options) = @_; - + return "Storage '" . $options{instance_value}->{display} . "' "; } sub default_storage_type { my ($self, %options) = @_; - + return '^(hrStorageFixedDisk|hrStorageNetworkDisk|hrFSBerkeleyFFS)$'; } @@ -214,7 +221,7 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - + $options{options}->add_options(arguments => { 'units:s' => { name => 'units', default => '%' }, 'free' => { name => 'free' }, @@ -235,7 +242,7 @@ sub new { $self->{storage_id_selected} = []; $self->{statefile_cache} = centreon::plugins::statefile->new(%options); - + return $self; } @@ -248,7 +255,7 @@ sub check_options { $self->{output}->add_option_msg(short_msg => "Space reservation argument must be between 0 and 100 percent."); $self->{output}->option_exit(); } - + $self->{option_results}->{oid_filter} = lc($self->{option_results}->{oid_filter}); if ($self->{option_results}->{oid_filter} !~ /^(hrstoragedescr|hrfsmountpoint)$/) { $self->{output}->add_option_msg(short_msg => "Unsupported --oid-filter option."); @@ -265,7 +272,7 @@ sub check_options { sub access_result { my ($self, %options) = @_; - + return {} if (!defined($self->{option_results}->{add_access})); my $oid_hrFSAccess = '.1.3.6.1.2.1.25.3.8.1.5'; @@ -290,20 +297,20 @@ sub access_result { $result->{$_} = $snmp_result->{$oid_hrFSAccess . '.' . $relations->{$_}}; } } - + return $result; } sub manage_selection { my ($self, %options) = @_; - + $self->get_selection(snmp => $options{snmp}); - + my $oid_hrStorageAllocationUnits = '.1.3.6.1.2.1.25.2.3.1.4'; my $oid_hrStorageSize = '.1.3.6.1.2.1.25.2.3.1.5'; my $oid_hrStorageUsed = '.1.3.6.1.2.1.25.2.3.1.6'; my $oid_hrStorageType = '.1.3.6.1.2.1.25.2.3.1.2'; - + $options{snmp}->load( oids => [$oid_hrStorageAllocationUnits, $oid_hrStorageSize, $oid_hrStorageUsed], instances => $self->{storage_id_selected}, @@ -311,7 +318,7 @@ sub manage_selection { ); my $result = $options{snmp}->get_leef(); my $access_result = $self->access_result(snmp => $options{snmp}); - + $self->{global}->{count} = 0; $self->{storage} = {}; foreach (sort @{$self->{storage_id_selected}}) { @@ -330,12 +337,13 @@ sub manage_selection { # in bytes hrStorageAllocationUnits my $total_size = $result->{$oid_hrStorageSize . "." . $_} * $result->{$oid_hrStorageAllocationUnits . "." . $_}; if ($total_size <= 0) { - $self->{output}->add_option_msg( + $self->{output}->output_add( long_msg => sprintf( "skipping storage '%s': total size is <= 0 (%s)", $name_storage, int($total_size) - ) + ), + debug => 1 ); next; } From 707045f71ad12bc4e953c9219b479a6e16bae7a4 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 2 Apr 2020 09:52:25 +0200 Subject: [PATCH 067/283] Fix #1915 --- snmp_standard/mode/memory.pm | 90 +++++++++++++++++++----------------- 1 file changed, 48 insertions(+), 42 deletions(-) diff --git a/snmp_standard/mode/memory.pm b/snmp_standard/mode/memory.pm index 7ad4d8365..79289c4a9 100644 --- a/snmp_standard/mode/memory.pm +++ b/snmp_standard/mode/memory.pm @@ -28,26 +28,27 @@ use warnings; sub custom_usage_output { my ($self, %options) = @_; - my $msg = sprintf("Ram Total: %s %s Used (-buffers/cache): %s %s (%.2f%%) Free: %s %s (%.2f%%)", - $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_absolute}), - $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_absolute}), - $self->{result_values}->{prct_used_absolute}, - $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute}), - $self->{result_values}->{prct_free_absolute}); - return $msg; -} - -sub custom_swap_output { - my ($self, %options) = @_; - - my $msg = sprintf("Swap Total: %s %s Used: %s %s (%.2f%%) Free: %s %s (%.2f%%)", + return sprintf( + 'Ram Total: %s %s Used (-buffers/cache): %s %s (%.2f%%) Free: %s %s (%.2f%%)', + $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_absolute}), + $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_absolute}), + $self->{result_values}->{prct_used_absolute}, + $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute}), + $self->{result_values}->{prct_free_absolute} + ); +} + +sub custom_swap_output { + my ($self, %options) = @_; + + return sprintf( + 'Swap Total: %s %s Used: %s %s (%.2f%%) Free: %s %s (%.2f%%)', $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_absolute}), $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_absolute}), $self->{result_values}->{prct_used_absolute}, $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute}), $self->{result_values}->{prct_free_absolute} ); - return $msg; } sub set_counters { @@ -57,15 +58,15 @@ sub set_counters { { name => 'ram', type => 0, skipped_code => { -10 => 1 } }, { name => 'swap', type => 0, message_separator => ' - ', skipped_code => { -10 => 1 } }, ]; - + $self->{maps_counters}->{ram} = [ { label => 'usage', nlabel => 'memory.usage.bytes', set => { key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ { label => 'used', value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute', - unit => 'B', cast_int => 1 }, - ], + unit => 'B', cast_int => 1 } + ] } }, { label => 'usage-free', display_ok => 0, nlabel => 'memory.free.bytes', set => { @@ -73,8 +74,8 @@ sub set_counters { closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ { label => 'free', value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute', - unit => 'B', cast_int => 1 }, - ], + unit => 'B', cast_int => 1 } + ] } }, { label => 'usage-prct', display_ok => 0, nlabel => 'memory.usage.percentage', set => { @@ -82,8 +83,8 @@ sub set_counters { output_template => 'Ram Used : %.2f %%', perfdatas => [ { label => 'used_prct', value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, - unit => '%' }, - ], + unit => '%' } + ] } }, { label => 'buffer', nlabel => 'memory.buffer.bytes', set => { @@ -92,8 +93,8 @@ sub set_counters { output_change_bytes => 1, perfdatas => [ { label => 'buffer', value => 'memBuffer_absolute', template => '%d', - min => 0, unit => 'B' }, - ], + min => 0, unit => 'B' } + ] } }, { label => 'cached', nlabel => 'memory.cached.bytes', set => { @@ -102,8 +103,8 @@ sub set_counters { output_change_bytes => 1, perfdatas => [ { label => 'cached', value => 'memCached_absolute', template => '%d', - min => 0, unit => 'B' }, - ], + min => 0, unit => 'B' } + ] } }, { label => 'shared', nlabel => 'memory.shared.bytes', set => { @@ -112,8 +113,8 @@ sub set_counters { output_change_bytes => 1, perfdatas => [ { label => 'shared', value => 'memShared_absolute', template => '%d', - min => 0, unit => 'B' }, - ], + min => 0, unit => 'B' } + ] } }, ]; @@ -123,8 +124,8 @@ sub set_counters { closure_custom_output => $self->can('custom_swap_output'), perfdatas => [ { label => 'swap', value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute', - unit => 'B', cast_int => 1 }, - ], + unit => 'B', cast_int => 1 } + ] } }, { label => 'swap-free', display_ok => 0, nlabel => 'swap.free.bytes', set => { @@ -132,8 +133,8 @@ sub set_counters { closure_custom_output => $self->can('custom_swap_output'), perfdatas => [ { label => 'swap_free', value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute', - unit => 'B', cast_int => 1 }, - ], + unit => 'B', cast_int => 1 } + ] } }, { label => 'swap-prct', display_ok => 0, nlabel => 'swap.usage.percentage', set => { @@ -141,10 +142,10 @@ sub set_counters { output_template => 'Swap Used : %.2f %%', perfdatas => [ { label => 'swap_prct', value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, - unit => '%' }, - ], + unit => '%' } + ] } - }, + } ]; } @@ -152,15 +153,15 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - + $options{options}->add_options(arguments => { - 'units:s' => { name => 'units', default => '%' }, - 'free' => { name => 'free' }, - 'swap' => { name => 'check_swap' }, - 'redhat' => { name => 'redhat' }, - 'autodetect-redhat' => { name => 'autodetect_redhat' }, + 'units:s' => { name => 'units', default => '%' }, + 'free' => { name => 'free' }, + 'swap' => { name => 'check_swap' }, + 'redhat' => { name => 'redhat' }, + 'autodetect-redhat' => { name => 'autodetect_redhat' } }); - + return $self; } @@ -268,9 +269,14 @@ sub memory_calc { ## memShared = MemShared in /proc/meminfo ## memBuffer = Buffers in /proc/meminfo ## memCached = Cached + SReclaimable in /proc/meminfo (https://bugzilla.redhat.com/attachment.cgi?id=1554747&action=diff) - + $used = (defined($self->{option_results}->{redhat})) ? $total - $available : $total - $available - $buffer - $cached; $free = (defined($self->{option_results}->{redhat})) ? $available : $total - $used; + # if the value is negative. maybe the autodetect failed. + if ($used < 0 && defined($self->{option_results}->{autodetect_redhat})) { + $used = $total - $available; + $free = $available; + } $prct_used = $used * 100 / $total; $prct_free = 100 - $prct_used; } From ae846ff2703191c9adcf87806fac31ee657bc6cc Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 2 Apr 2020 10:10:28 +0200 Subject: [PATCH 068/283] Fix #1917 --- snmp_standard/mode/diskusage.pm | 58 +++++++++++++++++---------------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/snmp_standard/mode/diskusage.pm b/snmp_standard/mode/diskusage.pm index a4a5824c0..8365d7f40 100644 --- a/snmp_standard/mode/diskusage.pm +++ b/snmp_standard/mode/diskusage.pm @@ -122,12 +122,12 @@ sub new { 'display-transform-src:s' => { name => 'display_transform_src' }, 'display-transform-dst:s' => { name => 'display_transform_dst' }, 'show-cache' => { name => 'show_cache' }, - 'space-reservation:s' => { name => 'space_reservation' }, + 'space-reservation:s' => { name => 'space_reservation' } }); $self->{diskpath_id_selected} = []; $self->{statefile_cache} = centreon::plugins::statefile->new(%options); - + return $self; } @@ -153,33 +153,35 @@ sub check_options { $self->{statefile_cache}->check_options(%options); } +my $mapping = { + dskTotal32 => { oid => '.1.3.6.1.4.1.2021.9.1.6' }, # kB + dskUsed32 => { oid => '.1.3.6.1.4.1.2021.9.1.8' }, # kB + dskPercentNode => { oid => '.1.3.6.1.4.1.2021.9.1.10' }, + dskTotalLow => { oid => '.1.3.6.1.4.1.2021.9.1.11' }, # kB + dskTotalHigh => { oid => '.1.3.6.1.4.1.2021.9.1.12' }, # kB + dskUsedLow => { oid => '.1.3.6.1.4.1.2021.9.1.15' }, # kB + dskUsedHigh => { oid => '.1.3.6.1.4.1.2021.9.1.16' } # kB +}; + sub manage_selection { my ($self, %options) = @_; - $self->{snmp} = $options{snmp}; - $self->get_selection(); - - my $oid_dskTotalLow = '.1.3.6.1.4.1.2021.9.1.11'; # in kB - my $oid_dskTotalHigh = '.1.3.6.1.4.1.2021.9.1.12'; # in kB - my $oid_dskUsedLow = '.1.3.6.1.4.1.2021.9.1.15'; # in kB - my $oid_dskUsedHigh = '.1.3.6.1.4.1.2021.9.1.16'; # in kB - my $oid_dskPercentNode = '.1.3.6.1.4.1.2021.9.1.10'; + $self->get_selection(snmp => $options{snmp}); - $self->{snmp}->load( - oids => [ - $oid_dskTotalLow, $oid_dskTotalHigh, $oid_dskUsedLow, $oid_dskUsedHigh, $oid_dskPercentNode - ], + $options{snmp}->load( + oids => [ map($_->{oid}, values(%$mapping)) ], instances => $self->{diskpath_id_selected}, nothing_quit => 1 ); - my $result = $self->{snmp}->get_leef(); - + my $snmp_result = $options{snmp}->get_leef(); + $self->{global}->{count} = 0; $self->{diskpath} = {}; foreach (sort @{$self->{diskpath_id_selected}}) { my $name_diskpath = $self->get_display_value(id => $_); - if (!defined($result->{$oid_dskTotalHigh . "." . $_})) { + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $_); + if (!defined($result->{dskTotal32}) && !defined($result->{dskTotalHigh})) { $self->{output}->add_option_msg( long_msg => sprintf( "skipping partition '%s': not found (need to reload the cache)", @@ -188,13 +190,13 @@ sub manage_selection { ); next; } - - my $total_size = (($result->{$oid_dskTotalHigh . "." . $_} << 32) + $result->{$oid_dskTotalLow . "." . $_}) * 1024; + + my $total_size = defined($result->{dskTotalHigh}) ? ((($result->{dskTotalHigh} << 32) + $result->{dskTotalLow}) * 1024) : $result->{dskTotal32} * 1024; if ($total_size == 0) { $self->{output}->output_add(long_msg => sprintf("skipping partition '%s' (total size is 0)", $name_diskpath), debug => 1); next; } - my $total_used = (($result->{$oid_dskUsedHigh . "." . $_} << 32) + $result->{$oid_dskUsedLow . "." . $_}) * 1024; + my $total_used = defined($result->{dskUsedHigh}) ? ((($result->{dskUsedHigh} << 32) + $result->{dskUsedLow}) * 1024) : $result->{dskUsed32} * 1024; my $reserved_value = 0; if (defined($self->{option_results}->{space_reservation})) { @@ -211,18 +213,18 @@ sub manage_selection { $prct_free = 0; } - $self->{diskpath}->{$_} = { + $self->{diskpath}->{$name_diskpath} = { display => $name_diskpath, total => $total_size, used => $total_used, free => $free, prct_free => $prct_free, prct_used => $prct_used, - inodes => defined($result->{$oid_dskPercentNode . "." . $_}) ? $result->{$oid_dskPercentNode . "." . $_} : undef, + inodes => $result->{dskPercentNode} }; $self->{global}->{count}++; } - + if (scalar(keys %{$self->{diskpath}}) <= 0) { $self->{output}->add_option_msg(short_msg => 'Issue with disk path information (see details)'); $self->{output}->option_exit(); @@ -230,7 +232,7 @@ sub manage_selection { } sub reload_cache { - my ($self) = @_; + my ($self, %options) = @_; my $datas = {}; $datas->{last_timestamp} = time(); @@ -238,8 +240,8 @@ sub reload_cache { my $oid_dskPath = '.1.3.6.1.4.1.2021.9.1.2'; - my $result = $self->{snmp}->get_table(oid => $oid_dskPath); - foreach my $key ($self->{snmp}->oid_lex_sort(keys %{$result})) { + my $result = $options{snmp}->get_table(oid => $oid_dskPath); + foreach my $key (keys %$result) { next if ($key !~ /\.([0-9]+)$/); my $diskpath_index = $1; push @{$datas->{all_ids}}, $diskpath_index; @@ -258,7 +260,7 @@ sub get_selection { my ($self, %options) = @_; # init cache file - my $has_cache_file = $self->{statefile_cache}->read(statefile => 'cache_snmpstandard_' . $self->{snmp}->get_hostname() . '_' . $self->{snmp}->get_port() . '_' . $self->{mode}); + my $has_cache_file = $self->{statefile_cache}->read(statefile => 'cache_snmpstandard_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode}); if (defined($self->{option_results}->{show_cache})) { $self->{output}->add_option_msg(long_msg => $self->{statefile_cache}->get_string_content()); $self->{output}->option_exit(); @@ -266,7 +268,7 @@ sub get_selection { my $timestamp_cache = $self->{statefile_cache}->get(name => 'last_timestamp'); if ($has_cache_file == 0 || !defined($timestamp_cache) || ((time() - $timestamp_cache) > (($self->{option_results}->{reload_cache_time}) * 60))) { - $self->reload_cache(); + $self->reload_cache(snmp => $options{snmp}); $self->{statefile_cache}->read(); } From 7d8165d521801031b561315ed999e2be2115352b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Schr=C3=B6ter?= Date: Thu, 2 Apr 2020 16:01:49 +0200 Subject: [PATCH 069/283] add support for ACS8000 series (psu oid differs from ACS6000 series) --- .../acs/8000/snmp/mode/components/psu.pm | 71 ++++++++++++ .../avocent/acs/8000/snmp/mode/hardware.pm | 104 ++++++++++++++++++ hardware/kvm/avocent/acs/8000/snmp/plugin.pm | 51 +++++++++ 3 files changed, 226 insertions(+) create mode 100644 hardware/kvm/avocent/acs/8000/snmp/mode/components/psu.pm create mode 100644 hardware/kvm/avocent/acs/8000/snmp/mode/hardware.pm create mode 100644 hardware/kvm/avocent/acs/8000/snmp/plugin.pm diff --git a/hardware/kvm/avocent/acs/8000/snmp/mode/components/psu.pm b/hardware/kvm/avocent/acs/8000/snmp/mode/components/psu.pm new file mode 100644 index 000000000..cc79ec0a1 --- /dev/null +++ b/hardware/kvm/avocent/acs/8000/snmp/mode/components/psu.pm @@ -0,0 +1,71 @@ +# +# Copyright 2019 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 hardware::kvm::avocent::acs::8000::snmp::mode::components::psu; + +use strict; +use warnings; + +my %map_states = (1 => 'statePowerOn', 2 => 'statePowerOff', 9999 => 'powerNotInstalled'); + +my $mapping = { + acsPowerSupplyStatePw1 => { oid => '.1.3.6.1.4.1.10418.26.2.1.8.2', map => \%map_states }, + acsPowerSupplyStatePw2 => { oid => '.1.3.6.1.4.1.10418.26.2.1.8.3', map => \%map_states }, +}; +my $oid_acsPowerSupply = '.1.3.6.1.4.1.10418.26.2.1.8'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_acsPowerSupply }; +} + +sub check_psu { + my ($self, %options) = @_; + + return if ($self->check_filter(section => 'psu', instance => $options{instance})); + return if ($options{state} eq 'powerNotInstalled' && + $self->absent_problem(section => 'psu', instance => $options{instance})); + $self->{components}->{psu}->{total}++; + + $self->{output}->output_add(long_msg => sprintf("power supply '%s' status is %s.", + $options{instance}, $options{state} + )); + my $exit = $self->get_severity(section => 'psu', value => $options{state}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Power supply '%s' status is %s", + $options{instance}, $options{state})); + } +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking power supplies"); + $self->{components}->{psu} = {name => 'psus', total => 0, skip => 0}; + return if ($self->check_filter(section => 'psu')); + + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_acsPowerSupply}, instance => '0'); + check_psu($self, state => $result->{acsPowerSupplyStatePw1}, instance => '1'); + check_psu($self, state => $result->{acsPowerSupplyStatePw2}, instance => '2'); +} + +1; \ No newline at end of file diff --git a/hardware/kvm/avocent/acs/8000/snmp/mode/hardware.pm b/hardware/kvm/avocent/acs/8000/snmp/mode/hardware.pm new file mode 100644 index 000000000..9eabd07b3 --- /dev/null +++ b/hardware/kvm/avocent/acs/8000/snmp/mode/hardware.pm @@ -0,0 +1,104 @@ +# +# Copyright 2019 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 hardware::kvm::avocent::acs::8000::snmp::mode::hardware; + +use base qw(centreon::plugins::templates::hardware); + +use strict; +use warnings; + +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_overload_check_section_option} = '^(psu)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + psu => [ + ['statePowerOn', 'OK'], + ['statePowerOff', 'CRITICAL'], + ['powerNotInstalled', 'OK'], + ], + }; + + $self->{components_path} = 'hardware::kvm::avocent::acs::8000::snmp::mode::components'; + $self->{components_module} = ['psu']; +} + +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_performance => 1); + bless $self, $class; + + $options{options}->add_options(arguments => + { + }); + + return $self; +} + +1; + +__END__ + +=head1 MODE + +Check hardware. + +=over 8 + +=item B<--component> + +Which component to check (Default: '.*'). +Can be: 'psu'. + +=item B<--filter> + +Exclude some parts (comma seperated list) (Example: --filter=psu) +Can also exclude specific instance: --filter=psu,1 + +=item B<--absent-problem> + +Return an error if an entity is not 'present' (default is skipping) (comma seperated list) +Can be specific or global: --absent-problem=psu + +=item B<--no-component> + +Return an error if no compenents are checked. +If total (with skipped) is 0. (Default: 'critical' returns). + +=item B<--threshold-overload> + +Set to overload default threshold values (syntax: section,[instance,]status,regexp) +It used before default thresholds (order stays). +Example: --threshold-overload='psu,CRITICAL,^(?!(statePowerOn)$)' + +=back + +=cut \ No newline at end of file diff --git a/hardware/kvm/avocent/acs/8000/snmp/plugin.pm b/hardware/kvm/avocent/acs/8000/snmp/plugin.pm new file mode 100644 index 000000000..114d91643 --- /dev/null +++ b/hardware/kvm/avocent/acs/8000/snmp/plugin.pm @@ -0,0 +1,51 @@ +# +# Copyright 2019 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 hardware::kvm::avocent::acs::8000::snmp::plugin; + +use strict; +use warnings; +use base qw(centreon::plugins::script_snmp); + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.0'; + %{$self->{modes}} = ( + 'cpu-detailed' => 'snmp_standard::mode::cpudetailed', + 'hardware' => 'hardware::kvm::avocent::acs::8000::snmp::mode::hardware', + 'load' => 'snmp_standard::mode::loadaverage', + 'memory' => 'snmp_standard::mode::memory', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Avocent ACS 8000 series in SNMP. + +=cut From d749650aba793ff4b946e00ad6b8109779db24cf Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 2 Apr 2020 16:31:23 +0200 Subject: [PATCH 070/283] break change: refacto hddtemp plugin --- apps/hddtemp/custom/cli.pm | 264 ++++++++++++++++++++++++ apps/hddtemp/custom/tcp.pm | 198 ++++++++++++++++++ apps/hddtemp/local/mode/temperature.pm | 184 ----------------- apps/hddtemp/local/plugin.pm | 48 ----- apps/hddtemp/mode/listdrives.pm | 97 +++++++++ apps/hddtemp/mode/temperatures.pm | 169 +++++++++++++++ apps/hddtemp/{remote => }/plugin.pm | 17 +- apps/hddtemp/remote/mode/listdrives.pm | 160 -------------- apps/hddtemp/remote/mode/temperature.pm | 210 ------------------- centreon/plugins/backend/ssh/libssh.pm | 2 +- centreon/plugins/backend/ssh/plink.pm | 3 +- centreon/plugins/backend/ssh/sshcli.pm | 3 +- 12 files changed, 744 insertions(+), 611 deletions(-) create mode 100644 apps/hddtemp/custom/cli.pm create mode 100644 apps/hddtemp/custom/tcp.pm delete mode 100644 apps/hddtemp/local/mode/temperature.pm delete mode 100644 apps/hddtemp/local/plugin.pm create mode 100644 apps/hddtemp/mode/listdrives.pm create mode 100644 apps/hddtemp/mode/temperatures.pm rename apps/hddtemp/{remote => }/plugin.pm (65%) delete mode 100644 apps/hddtemp/remote/mode/listdrives.pm delete mode 100644 apps/hddtemp/remote/mode/temperature.pm diff --git a/apps/hddtemp/custom/cli.pm b/apps/hddtemp/custom/cli.pm new file mode 100644 index 000000000..9df6ecfc4 --- /dev/null +++ b/apps/hddtemp/custom/cli.pm @@ -0,0 +1,264 @@ +# +# Copyright 2020 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::hddtemp::custom::cli; + +use strict; +use warnings; +use centreon::plugins::ssh; +use centreon::plugins::misc; + +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' }, + 'timeout:s' => { name => 'timeout', default => 45 }, + 'command-drives:s' => { name => 'command_drives' }, + 'command-path-drives:s' => { name => 'command_path_drives' }, + 'command-options-drives:s' => { name => 'command_options_drives' }, + 'command-hddtemp:s' => { name => 'command_hddtemp' }, + 'command-path-hddtemp:s' => { name => 'command_path_hddtemp' }, + 'command-options-hddtemp:s' => { name => 'command_options_hddtemp' }, + 'sudo:s' => { name => 'sudo' } + }); + } + $options{options}->add_help(package => __PACKAGE__, sections => 'CLI OPTIONS', once => 1); + + $self->{output} = $options{output}; + $self->{mode} = $options{mode}; + $self->{ssh} = centreon::plugins::ssh->new(%options); + + return $self; +} + +sub set_options { + my ($self, %options) = @_; + + $self->{option_results} = $options{option_results}; +} + +sub set_defaults { + my ($self, %options) = @_; + + 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) = @_; + + if (defined($self->{option_results}->{hostname}) && $self->{option_results}->{hostname} ne '') { + $self->{ssh}->check_options(option_results => $self->{option_results}); + } + + return 0; +} + +sub list_drives { + my ($self, %options) = @_; + + my $stdout; + if (defined($self->{option_results}->{hostname}) && $self->{option_results}->{hostname} ne '') { + ($stdout) = $self->{ssh}->execute( + hostname => $self->{option_results}->{hostname}, + command => defined($self->{option_results}->{command_drives}) && $self->{option_results}->{command_drives} ne '' ? $self->{option_results}->{command_drives} : 'lsblk', + command_path => $self->{option_results}->{command_path_drives}, + command_options => defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options_drives} ne '' ? $self->{option_results}->{command_options_drives} : '-I 8 -d -o NAME -p -n', + timeout => $self->{option_results}->{timeout} + ); + } else { + ($stdout) = centreon::plugins::misc::execute( + output => $self->{output}, + options => { timeout => $self->{option_results}->{timeout} }, + command => defined($self->{option_results}->{command_drives}) && $self->{option_results}->{command_drives} ne '' ? $self->{option_results}->{command_drives} : 'lsblk', + command_path => $self->{option_results}->{command_path_drives}, + command_options => defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options_drives} ne '' ? $self->{option_results}->{command_options_drives} : '-I 8 -d -o NAME -p -n' + ); + } + + $self->{output}->output_add(long_msg => "command response: $stdout", debug => 1); + my $drives = {}; + $drives->{$_} = {} foreach (split /\n/, $stdout); + + return $drives; +} + +sub get_drives_information { + my ($self, %options) = @_; + + my $drives = $self->list_drives(); + my $cmd_options = '-u C ' . join(' ', keys %$drives); + + my ($stdout, $exit_code); + if (defined($self->{option_results}->{hostname}) && $self->{option_results}->{hostname} ne '') { + ($stdout, $exit_code) = $self->{ssh}->execute( + hostname => $self->{option_results}->{hostname}, + sudo => $self->{option_results}->{sudo}, + command => defined($self->{option_results}->{command_hddtemp}) && $self->{option_results}->{command_hddtemp} ne '' ? $self->{option_results}->{command_hddtemp} : 'hddtemp', + command_path => $self->{option_results}->{command_path_hddtemp}, + command_options => defined($self->{option_results}->{command_options_hddtemp}) && $self->{option_results}->{command_options_hddtemp} ne '' ? $self->{option_results}->{command_options_hddtemp} : $cmd_options, + timeout => $self->{option_results}->{timeout}, + no_quit => 1 + ); + } else { + ($stdout, $exit_code) = centreon::plugins::misc::execute( + output => $self->{output}, + options => { timeout => $self->{option_results}->{timeout} }, + sudo => $self->{option_results}->{sudo}, + command => defined($self->{option_results}->{command_hddtemp}) && $self->{option_results}->{command_hddtemp} ne '' ? $self->{option_results}->{command_hddtemp} : 'hddtemp', + command_path => $self->{option_results}->{command_path_hddtemp}, + command_options => defined($self->{option_results}->{command_options_hddtemp}) && $self->{option_results}->{command_options_hddtemp} ne '' ? $self->{option_results}->{command_options_hddtemp} : $cmd_options . ' 2> /dev/null', + no_quit => 1, + ); + } + + # exit values can be: 0/1. Need root permissions. + if ($exit_code != 0 && $exit_code != 1) { + $self->{output}->add_option_msg(short_msg => sprintf('command execution error [exit code: %s]', $exit_code)); + $self->{output}->option_exit(); + } + + # OK: + # /dev/sda: SanDisk ...: 32 C + # ERROR: + # message on stderr. So if we don't catch stderr and we have nothing, surely error. for example: + # /dev/sda: open: Permission denied + # UNKNOWN: + # /dev/sda: SanDisk ...: no sensor + # SLEEP: + # /dev/sda: SanDisk ...: drive is sleeping + # NOSENSOR: + # /dev/sda: SanDisk ...: drive supported, but it doesn't have a temperature sensor + # NOT_APPLICABLE: + # /dev/sda: SanDisk ...: misc message + foreach my $name (keys %$drives) { + if ($stdout =~ /^$name:.*?:\s+(\d+).*?C/m) { + $drives->{$name}->{status} = 'ok'; + $drives->{$name}->{temperature_unit} = 'C'; + $drives->{$name}->{temperature} = $1; + } elsif ($stdout =~ /^$name:.*?:\s+(.*)$/m) { + my $message = $1; + $drives->{$name}->{status} = 'notApplicable'; + $drives->{$name}->{status} = 'unknown' if ($message =~ /no sensor/i); + $drives->{$name}->{status} = 'driveSleep' if ($message =~ /drive is sleeping/i); + $drives->{$name}->{status} = 'noSensor' if ($message =~ /drive supported, but it doesn't have a temperature sensor/i); + } else { + $drives->{$name}->{status} = 'error'; + } + } + + return $drives; +} + +1; + +__END__ + +=head1 NAME + +ssh + +=head1 SYNOPSIS + +my ssh + +=head1 CLI OPTIONS + +=over 8 + +=item B<--hostname> + +Hostname to query (ssh mode). + +=item B<--timeout> + +Timeout in seconds for the command (Default: 45). + +=item You can override command for drives listing. +By default, we use 'lsblk -I 8 -d -o NAME -p -n': + +=over 16 + +=item B<--command-drives> + +Command to get information. Used it you have output in a file. + +=item B<--command-path-drives> + +Command path. + +=item B<--command-options-drives> + +Command options. + +=back + +=item You can override command hddtemp used. +By default, we use 'hddtemp -u C /dev/sda /dev/sdb ...' built with the result of drives command: + +=over 16 + +=item B<--command-hddtemp> + +Command to get information. Used it you have output in a file. + +=item B<--command-path-hddtemp> + +Command path. + +=item B<--command-options-hddtemp> + +Command options. + +=item B<--sudo> + +Sudo hddtemp command. + +=back + +=back + +=head1 DESCRIPTION + +B. + +=cut diff --git a/apps/hddtemp/custom/tcp.pm b/apps/hddtemp/custom/tcp.pm new file mode 100644 index 000000000..532026900 --- /dev/null +++ b/apps/hddtemp/custom/tcp.pm @@ -0,0 +1,198 @@ +# +# Copyright 2020 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::hddtemp::custom::tcp; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use IO::Socket; + +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' }, + 'timeout:s' => { name => 'timeout' } + }); + } + $options{options}->add_help(package => __PACKAGE__, sections => 'CUSTOM TCP OPTIONS', once => 1); + + $self->{output} = $options{output}; + $self->{mode} = $options{mode}; + + return $self; +} + +sub set_options { + my ($self, %options) = @_; + + $self->{option_results} = $options{option_results}; +} + +sub set_defaults { + my ($self, %options) = @_; + + 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} = (defined($self->{option_results}->{hostname})) ? $self->{option_results}->{hostname} : ''; + $self->{port} = (defined($self->{option_results}->{port})) && $self->{option_results}->{port} =~ /(\d+)/ ? $1 : 7634; + $self->{timeout} = (defined($self->{option_results}->{timeout})) && $self->{option_results}->{timeout} =~ /(\d+)/ ? $1 : 30; + + if ($self->{hostname} eq '') { + $self->{output}->add_option_msg(short_msg => 'Need to specify --hostname option.'); + $self->{output}->option_exit(); + } + + return 0; +} + +sub get_hddtemp_drives { + my ($self, %options) = @_; + + my $socket = new IO::Socket::INET( + Proto => 'tcp', + PeerAddr => $self->{hostname}, + PeerPort => $self->{port}, + Timeout => $self->{timeout} + ); + + if (!defined($socket)) { + $self->{output}->add_option_msg(short_msg => "could not connect: $@"); + $self->{output}->option_exit(); + } + + my $line; + eval { + local $SIG{ALRM} = sub { die 'Timeout'; }; + alarm($self->{timeout}); + $line = <$socket>; + alarm(0); + }; + $socket->shutdown(2); + if ($@) { + $self->{output}->add_option_msg(short_msg => 'cannot get informations: ' . $@); + $self->{output}->option_exit(); + } + + return $line; +} + +sub list_drives { + my ($self, %options) = @_; + + my $line = $self->get_hddtemp_drives(); + my $drives = {}; + while ($line =~ /\|(.*?)\|(.*?)\|(.*?)\|(.*?)\|/msg) { + $drives->{$1} = {}; + } + + return $drives; +} + +sub get_drives_information { + my ($self, %options) = @_; + + my $line = $self->get_hddtemp_drives(); + + #|/dev/sda|SanDisk ....|33|C| + #|/dev/sda|Scan .... |NA|*| + my $mapping_errors = { + NA => 'notApplicable', + UNK => 'unknown', + NOS => 'noSensor', + SLP => 'driveSleep', + ERR => 'error' + }; + + my $drives = {}; + while ($line =~ /\|(.*?)\|(.*?)\|(.*?)\|(.*?)\|/msg) { + my ($name, $value, $unit) = ($1, $3, $4); + if ($value =~ /\d+/) { + $drives->{$name} = { temperature => $value, temperature_unit => $unit, status => 'ok' }; + } else { + $drives->{$name} = { status => $mapping_errors->{$value} }; + } + } + + return $drives; +} + +1; + +__END__ + +=head1 NAME + +Hddtemp + +=head1 CUSTOM TCP OPTIONS + +Hddtemp tcp + +=over 8 + +=item B<--hostname> + +Hostname or IP address. + +=item B<--port> + +Port used (Default: 7634) + +=item B<--timeout> + +Set timeout in seconds (Default: 30). + +=back + +=head1 DESCRIPTION + +B. + +=cut diff --git a/apps/hddtemp/local/mode/temperature.pm b/apps/hddtemp/local/mode/temperature.pm deleted file mode 100644 index 06091f8a6..000000000 --- a/apps/hddtemp/local/mode/temperature.pm +++ /dev/null @@ -1,184 +0,0 @@ -# -# Copyright 2020 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::hddtemp::local::mode::temperature; - -use base qw(centreon::plugins::mode); - -use strict; -use warnings; -use centreon::plugins::misc; - -sub new { - my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); - bless $self, $class; - - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname' }, - "remote" => { name => 'remote' }, - "ssh-option:s@" => { name => 'ssh_option' }, - "ssh-path:s" => { name => 'ssh_path' }, - "ssh-command:s" => { name => 'ssh_command', default => 'ssh' }, - "timeout:s" => { name => 'timeout', default => 30 }, - "sudo" => { name => 'sudo' }, - "command:s" => { name => 'command', default => 'hddtemp' }, - "command-path:s" => { name => 'command_path', default => '/usr/sbin' }, - "command-options:s" => { name => 'command_options', default => '-u' }, - "warning:s" => { name => 'warning' }, - "critical:s" => { name => 'critical' }, - "disks:s" => { name => 'disks' }, - "unit:s" => { name => 'unit', default => 'C' } - }); - - return $self; -} - -sub check_options { - my ($self, %options) = @_; - $self->SUPER::init(%options); - - if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{warning} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{critical} . "'."); - $self->{output}->option_exit(); - } - if (!defined($self->{option_results}->{disks}) || $self->{option_results}->{disks} eq '') { - $self->{output}->add_option_msg(short_msg => "Need to specify hdd (ex. /dev/sda)."); - $self->{output}->option_exit(); - } - - #### Create command_options - if (defined($self->{option_results}->{unit})) { - $self->{option_results}->{command_options} .= $self->{option_results}->{unit}; - } - $self->{option_results}->{command_options} .= ' ' . $self->{option_results}->{disks}; - $self->{option_results}->{command_options} .= ' 2>&1'; -} - -sub run { - my ($self, %options) = @_; - my $total_size = 0; - - my $stdout = centreon::plugins::misc::execute(output => $self->{output}, - options => $self->{option_results}, - sudo => $self->{option_results}->{sudo}, - command => $self->{option_results}->{command}, - command_path => $self->{option_results}->{command_path}, - command_options => $self->{option_results}->{command_options}); - - $self->{output}->output_add(severity => 'OK', - short_msg => "All temperatures are ok."); - foreach (split(/\n/, $stdout)) { - next if (!/(.*): (.*): ([0-9]*)/); - my ($disk, $model, $temp) = ($1, $2, $3); - - my $exit_code = $self->{perfdata}->threshold_check(value => $temp, - threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); - $self->{output}->output_add(long_msg => sprintf("%s: %s", $disk, $temp . '°' . $self->{option_results}->{unit})); - if (!$self->{output}->is_status(litteral => 1, value => $exit_code, compare => 'ok')) { - $self->{output}->output_add(severity => $exit_code, - short_msg => sprintf("'%s' temp is %s", $disk, $temp . '°' . $self->{option_results}->{unit})); - } - $self->{output}->perfdata_add(label => $disk, unit => $self->{option_results}->{unit}, - value => $temp, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), - min => 0); - } - - $self->{output}->display(); - $self->{output}->exit(); -} - -1; - -__END__ - -=head1 MODE - -Check hdd temperature with hddtemp. - -=over 8 - -=item B<--disks> - -Disks to check (ex: /dev/sda) - -=item B<--unit> - -Temperature unit (default: C). - -=item B<--warning> - -Threshold warning in °. - -=item B<--critical> - -Threshold critical in °. - -=item B<--remote> - -Execute command remotely in 'ssh'. - -=item B<--hostname> - -Hostname to query (need --remote). - -=item B<--ssh-option> - -Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52'). - -=item B<--ssh-path> - -Specify ssh command path (default: none) - -=item B<--ssh-command> - -Specify ssh command (default: 'ssh'). Useful to use 'plink'. - -=item B<--timeout> - -Timeout in seconds for the command (Default: 30). - -=item B<--sudo> - -Use 'sudo' to execute the command. - -=item B<--command> - -Command to get information (Default: 'hddtemp'). -Can be changed if you have output in a file. - -=item B<--command-path> - -Command path (Default: '/usr/sbin'). - -=item B<--command-options> - -Command options (Default: '-u'). - -=back - -=cut diff --git a/apps/hddtemp/local/plugin.pm b/apps/hddtemp/local/plugin.pm deleted file mode 100644 index ff84f189a..000000000 --- a/apps/hddtemp/local/plugin.pm +++ /dev/null @@ -1,48 +0,0 @@ -# -# Copyright 2020 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::hddtemp::local::plugin; - -use strict; -use warnings; -use base qw(centreon::plugins::script_simple); - -sub new { - my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); - bless $self, $class; - - $self->{version} = '0.1'; - %{$self->{modes}} = ( - 'temperature' => 'apps::hddtemp::local::mode::temperature', - ); - - return $self; -} - -1; - -__END__ - -=head1 PLUGIN DESCRIPTION - -Check Linux through local commands (the plugin can use SSH). - -=cut diff --git a/apps/hddtemp/mode/listdrives.pm b/apps/hddtemp/mode/listdrives.pm new file mode 100644 index 000000000..b91957926 --- /dev/null +++ b/apps/hddtemp/mode/listdrives.pm @@ -0,0 +1,97 @@ +# +# Copyright 2020 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::hddtemp::mode::listdrives; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $options{options}->add_options(arguments => {}); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); +} + +sub manage_selection { + my ($self, %options) = @_; + + return $options{custom}->list_drives(); +} + +sub run { + my ($self, %options) = @_; + + my $drives = $self->manage_selection(%options); + foreach (sort keys %$drives) { + $self->{output}->output_add(long_msg => + sprintf( + '[name = %s]', + $_ + ) + ); + } + $self->{output}->output_add( + severity => 'OK', + short_msg => 'List drives:' + ); + + $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']); +} + +sub disco_show { + my ($self, %options) = @_; + + my $drives = $self->manage_selection(%options); + foreach (sort keys %$drives) { + $self->{output}->add_disco_entry(name => $_); + } +} + +1; + +__END__ + +=head1 MODE + +List queues. + +=over 8 + +=back + +=cut diff --git a/apps/hddtemp/mode/temperatures.pm b/apps/hddtemp/mode/temperatures.pm new file mode 100644 index 000000000..61f2e2d77 --- /dev/null +++ b/apps/hddtemp/mode/temperatures.pm @@ -0,0 +1,169 @@ +# +# Copyright 2020 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::hddtemp::mode::temperatures; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); + +sub custom_status_output { + my ($self, %options) = @_; + + return sprintf( + 'status: %s', + $self->{result_values}->{status}, + ); +} + +sub custom_temperature_output { + my ($self, %options) = @_; + + return sprintf('temperature: %s %s', + $self->{result_values}->{temperature_absolute}, + $self->{result_values}->{temperature_unit_absolute} + ); +} + +sub custom_temperature_perfdata { + my ($self, %options) = @_; + + $self->{output}->perfdata_add( + nlabel => 'drive.temperature.' . ($self->{result_values}->{temperature_unit_absolute} eq 'C' ? 'celsius' : 'fahrenheit'), + instances => $self->{result_values}->{display_absolute}, + unit => $self->{result_values}->{temperature_unit_absolute}, + value => $self->{result_values}->{temperature_absolute}, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}), + ); +} + +sub prefix_drive_output { + my ($self, %options) = @_; + + return "Drive '" . $options{instance_value}->{display} . "' "; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'drives', type => 1, cb_prefix_output => 'prefix_drive_output', skipped_code => { -10 => 1 } } + ]; + + $self->{maps_counters}->{drives} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'status' }, { name => 'display' } ], + closure_custom_calc => \&catalog_status_calc, + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold + } + }, + { label => 'temperature', set => { + key_values => [ { name => 'temperature' }, { name => 'temperature_unit' }, { name => 'display' } ], + closure_custom_output => $self->can('custom_temperature_output'), + closure_custom_perfdata => $self->can('custom_temperature_perfdata') + } + } + ]; +} + +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' }, + 'unknown-status:s' => { name => 'unknown_status', default => '' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '%{status} !~ /ok/i' } + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->change_macros(macros => ['unknown_status', 'warning_status', 'critical_status']); +} + +sub manage_selection { + my ($self, %options) = @_; + + my $results = $options{custom}->get_drives_information(); + + $self->{drives} = {}; + foreach (keys %$results) { + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $_ !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping drive '" . $_ . "': no matching filter.", debug => 1); + next; + } + + $self->{drives}->{$_} = { + display => $_, + %{$results->{$_}} + }; + } +} + +1; + +__END__ + +=head1 MODE + +Check drive temperatures. + +=over 8 + +=item B<--filter-name> + +Filter drive name (Can use regexp). + +=item B<--unknown-status> + +Set unknown threshold for status. +Can used special variables like: %{status}, %{display} + +=item B<--warning-status> + +Set warning threshold for status. +Can used special variables like: %{status}, %{display} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{status} !~ /ok/i'). +Can used special variables like: %{status}, %{display} + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'temperature'. + +=back + +=cut diff --git a/apps/hddtemp/remote/plugin.pm b/apps/hddtemp/plugin.pm similarity index 65% rename from apps/hddtemp/remote/plugin.pm rename to apps/hddtemp/plugin.pm index 57b0fb743..2a1a0c83f 100644 --- a/apps/hddtemp/remote/plugin.pm +++ b/apps/hddtemp/plugin.pm @@ -18,23 +18,25 @@ # limitations under the License. # -package apps::hddtemp::remote::plugin; +package apps::hddtemp::plugin; use strict; use warnings; -use base qw(centreon::plugins::script_simple); +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} = '0.1'; + $self->{version} = '1.0'; %{$self->{modes}} = ( - 'temperature' => 'apps::hddtemp::remote::mode::temperature', - 'list-drives' => 'apps::hddtemp::remote::mode::listdrives', + 'list-drives' => 'apps::hddtemp::mode::listdrives', + 'temperatures' => 'apps::hddtemp::mode::temperatures' ); + $self->{custom_modes}{tcp} = 'apps::hddtemp::custom::tcp'; + $self->{custom_modes}{cli} = 'apps::hddtemp::custom::cli'; return $self; } @@ -44,6 +46,9 @@ __END__ =head1 PLUGIN DESCRIPTION -Check HDDTEMP Status throuh TCP Socket +Check drives temperature with hddtemp. +Two custom modes availables: +'tcp' (remotely with hddtemp in daemon mode) +'command' (with hddtemp command. you can execute locally or through ssh). =cut diff --git a/apps/hddtemp/remote/mode/listdrives.pm b/apps/hddtemp/remote/mode/listdrives.pm deleted file mode 100644 index f9ae7e492..000000000 --- a/apps/hddtemp/remote/mode/listdrives.pm +++ /dev/null @@ -1,160 +0,0 @@ -# -# Copyright 2020 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::hddtemp::remote::mode::listdrives; - -use base qw(centreon::plugins::mode); - -use strict; -use warnings; -use IO::Socket; - -sub new { - my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); - bless $self, $class; - - $options{options}->add_options(arguments => - { - "hostname:s" => { name => 'hostname' }, - "port:s" => { name => 'port', default => '7634' }, - "timeout:s" => { name => 'timeout', default => '10' }, - "filter-name:s" => { name => 'filter_name', }, - }); - - $self->{result} = {}; - $self->{hostname} = undef; - return $self; -} - -sub check_options { - my ($self, %options) = @_; - $self->SUPER::init(%options); - - if (!defined($self->{option_results}->{hostname})) { - $self->{output}->add_option_msg(short_msg => "Please set the hostname option"); - $self->{output}->option_exit(); - } - -} - -sub manage_selection { - my ($self, %options) = @_; - - my $oSocketConn = new IO::Socket::INET ( Proto => 'tcp', - PeerAddr => $self->{option_results}->{hostname}, - PeerPort => $self->{option_results}->{port}, - Timeout => $self->{option_results}->{timeout}, - ); - - if (!defined($oSocketConn)) { - $self->{output}->add_option_msg(short_msg => "Could not connect."); - $self->{output}->option_exit(); - } - - #|/dev/sda|SD280813AS|35|C|#|/dev/sdb|ST2000CD005-1CH134|35|C| - - my $line; - - eval { - local $SIG{ALRM} = sub { die "Timeout by signal ALARM\n"; }; - alarm(10); - $line = <$oSocketConn>; - alarm(0); - }; - $oSocketConn->shutdown(2); - if ($@) { - $self->{output}->add_option_msg(short_msg => "Cannot get informations."); - $self->{output}->option_exit(); - } - - while ($line =~ /\|([^|]+)\|([^|]+)\|([^|]+)\|(C|F)\|/g) { - my ($drive, $serial, $temperature, $unit) = ($1, $2, $3, $4); - - if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && - $drive !~ /$self->{option_results}->{filter_name}/) { - $self->{output}->output_add(long_msg => "Skipping drive '" . $drive . "': no matching filter name"); - next; - } - - $self->{result}->{$drive} = {serial => $serial, temperature => $temperature, unit => $unit}; - } -} - -sub run { - my ($self, %options) = @_; - - $self->manage_selection(); - foreach my $name (sort(keys %{$self->{result}})) { - $self->{output}->output_add(long_msg => "'" . $name . "' [temperature = " . $self->{result}->{$name}->{temperature} . $self->{result}->{$name}->{unit} . ']'); - } - - $self->{output}->output_add(severity => 'OK', - short_msg => 'List Drives:'); - $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', 'temperature']); -} - -sub disco_show { - my ($self, %options) = @_; - - $self->manage_selection(); - foreach my $name (sort(keys %{$self->{result}})) { - $self->{output}->add_disco_entry(name => $name, - temperature => $self->{result}->{$name}->{temperature} - ); - } -} - -1; - -__END__ - -=head1 MODE - -List HDDTEMP Harddrives - -=over 8 - -=item B<--hostname> - -IP Address or FQDN of the Server - -=item B<--port> - -Port used by Hddtemp (Default: 7634) - -=item B<--timeout> - -Set Timeout for Socketconnect - -=item B<--filter-name> - -Filter Harddrive name (regexp can be used). - -=back - -=cut diff --git a/apps/hddtemp/remote/mode/temperature.pm b/apps/hddtemp/remote/mode/temperature.pm deleted file mode 100644 index 0e837c94c..000000000 --- a/apps/hddtemp/remote/mode/temperature.pm +++ /dev/null @@ -1,210 +0,0 @@ -# -# Copyright 2020 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::hddtemp::remote::mode::temperature; - -use base qw(centreon::plugins::mode); - -use strict; -use warnings; -use IO::Socket; - -sub new { - my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); - bless $self, $class; - - $options{options}->add_options(arguments => { - "hostname:s" => { name => 'hostname' }, - "port:s" => { name => 'port', default => '7634' }, - "timeout:s" => { name => 'timeout', default => '10' }, - "name:s" => { name => 'name' }, - "warning:s" => { name => 'warning' }, - "critical:s" => { name => 'critical' }, - "regexp" => { name => 'use_regexp' }, - "regexp-isensitive" => { name => 'use_regexpi' }, - }); - - $self->{result} = {}; - $self->{hostname} = undef; - return $self; -} - -sub check_options { - my ($self, %options) = @_; - $self->SUPER::init(%options); - - if (!defined($self->{option_results}->{hostname})) { - $self->{output}->add_option_msg(short_msg => "Please set the hostname option"); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); - $self->{output}->option_exit(); - } - -} - -sub manage_selection { - my ($self, %options) = @_; - - my $oSocketConn = new IO::Socket::INET ( - Proto => 'tcp', - PeerAddr => $self->{option_results}->{hostname}, - PeerPort => $self->{option_results}->{port}, - Timeout => $self->{option_results}->{timeout}, - ); - - if (!defined($oSocketConn)) { - $self->{output}->add_option_msg(short_msg => "Could not connect."); - $self->{output}->option_exit(); - } - - #|/dev/sda|SD280813AS|35|C|#|/dev/sdb|ST2000CD005-1CH134|35|C| - - my $line; - - eval { - local $SIG{ALRM} = sub { die "Timeout by signal ALARM\n"; }; - alarm(10); - $line = <$oSocketConn>; - alarm(0); - }; - $oSocketConn->shutdown(2); - if ($@) { - $self->{output}->add_option_msg(short_msg => "Cannot get informations."); - $self->{output}->option_exit(); - } - - while ($line =~ /\|([^|]+)\|([^|]+)\|([^|]+)\|(C|F)\|/g) { - my ($drive, $serial, $temperature, $unit) = ($1, $2, $3, $4); - - next if (defined($self->{option_results}->{name}) && defined($self->{option_results}->{use_regexp}) && defined($self->{option_results}->{use_regexpi}) - && $drive !~ /$self->{option_results}->{name}/i); - next if (defined($self->{option_results}->{name}) && defined($self->{option_results}->{use_regexp}) && !defined($self->{option_results}->{use_regexpi}) - && $drive !~ /$self->{option_results}->{name}/); - next if (defined($self->{option_results}->{name}) && !defined($self->{option_results}->{use_regexp}) && !defined($self->{option_results}->{use_regexpi}) - && $drive ne $self->{option_results}->{name}); - - $self->{result}->{$drive} = {serial => $serial, temperature => $temperature, unit => $unit}; - } - - if (scalar(keys %{$self->{result}}) <= 0) { - if (defined($self->{option_results}->{name})) { - $self->{output}->add_option_msg(short_msg => "No drives found for name '" . $self->{option_results}->{name} . "'."); - } else { - $self->{output}->add_option_msg(short_msg => "No drives found."); - } - $self->{output}->option_exit(); - } - -} - -sub run { - my ($self, %options) = @_; - - $self->manage_selection(); - - if (!defined($self->{option_results}->{name}) || defined($self->{option_results}->{use_regexp})) { - $self->{output}->output_add(severity => 'OK', - short_msg => 'All Harddrive Temperatures are ok.'); - }; - - foreach my $name (sort(keys %{$self->{result}})) { - my $exit = $self->{perfdata}->threshold_check(value => $self->{result}->{$name}->{temperature}, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); - - $self->{output}->output_add(long_msg => sprintf("Harddrive '%s' Temperature : %s%s", - $name, - $self->{result}->{$name}->{temperature}, - $self->{result}->{$name}->{unit})); - if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1) || (defined($self->{option_results}->{name}) && !defined($self->{option_results}->{use_regexp}))) { - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Harddrive '%s' Temperature : %s%s", - $name, - $self->{result}->{$name}->{temperature}, - $self->{result}->{$name}->{unit})); - } - - my $extra_label; - $extra_label = '_' . $name if (!defined($self->{option_results}->{name}) || defined($self->{option_results}->{use_regexp})); - $self->{output}->perfdata_add( - label => 'temp', - intances => $extra_label, - unit => $self->{result}->{$name}->{unit}, - value => sprintf("%.2f", $self->{result}->{$name}->{temperature}), - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), - min => 0 - ); - }; - - $self->{output}->display(); - $self->{output}->exit(); -}; - -1; - -__END__ - -=head1 MODE - -Check HDDTEMP Temperature by Socket Connect - -=over 8 - -=item B<--hostname> - -IP Address or FQDN of the Server - -=item B<--port> - -Port used by Hddtemp (Default: 7634) - -=item B<--timeout> - -Set Timeout for Socketconnect - -=item B<--warning> - -Warning Threshold for Temperature - -=item B<--critical> - -Critical Threshold for Temperature - -=item B<--name> - -Set the Harddrive name (empty means 'check all Harddrives') - -=item B<--regexp> - -Allows to use regexp to filter Harddrive (with option --name). - -=item B<--regexp-isensitive> - -Allows to use regexp non case-sensitive (with --regexp). - -=back - -=cut diff --git a/centreon/plugins/backend/ssh/libssh.pm b/centreon/plugins/backend/ssh/libssh.pm index d38445166..eae3df26c 100644 --- a/centreon/plugins/backend/ssh/libssh.pm +++ b/centreon/plugins/backend/ssh/libssh.pm @@ -138,7 +138,7 @@ sub execute { $self->{output}->option_exit(); } - if ($exit_code != 0) { + if ($exit_code != 0 && (!defined($options{no_quit}) || $options{no_quit} != 1)) { $self->{output}->add_option_msg(short_msg => sprintf('command execution error [exit code: %s]', $exit_code)); $self->{output}->option_exit(); } diff --git a/centreon/plugins/backend/ssh/plink.pm b/centreon/plugins/backend/ssh/plink.pm index 1b4f745e2..90aab1a3d 100644 --- a/centreon/plugins/backend/ssh/plink.pm +++ b/centreon/plugins/backend/ssh/plink.pm @@ -81,7 +81,8 @@ sub execute { ssh_path => $self->{ssh_path}, ssh_option => $self->{ssh_option}, timeout => $options{timeout} - } + }, + no_quit => $options{no_quit} ); if (defined($options{ssh_pipe}) && $options{ssh_pipe} == 1) { diff --git a/centreon/plugins/backend/ssh/sshcli.pm b/centreon/plugins/backend/ssh/sshcli.pm index 7374b7c21..fd8290212 100644 --- a/centreon/plugins/backend/ssh/sshcli.pm +++ b/centreon/plugins/backend/ssh/sshcli.pm @@ -83,7 +83,8 @@ sub execute { ssh_path => $self->{ssh_path}, ssh_option => $self->{ssh_option}, timeout => $options{timeout} - } + }, + no_quit => $options{no_quit} ); if (defined($options{ssh_pipe}) && $options{ssh_pipe} == 1) { From 9005390af297d1207fa2b3fee0c2255490586c17 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 3 Apr 2020 10:07:22 +0200 Subject: [PATCH 071/283] enhance list-trunks f5 --- network/f5/bigip/snmp/mode/listtrunks.pm | 107 +++++++++++------------ network/f5/bigip/snmp/mode/trunks.pm | 4 +- 2 files changed, 54 insertions(+), 57 deletions(-) diff --git a/network/f5/bigip/snmp/mode/listtrunks.pm b/network/f5/bigip/snmp/mode/listtrunks.pm index e7c687b56..5e0b44125 100644 --- a/network/f5/bigip/snmp/mode/listtrunks.pm +++ b/network/f5/bigip/snmp/mode/listtrunks.pm @@ -29,13 +29,10 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - - $options{options}->add_options(arguments => - { - "name:s" => { name => 'name' }, - "regexp" => { name => 'use_regexp' }, - }); - $self->{trunks_selected} = []; + + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'name' } + }); return $self; } @@ -45,62 +42,67 @@ sub check_options { $self->SUPER::init(%options); } -my %map_trunk_status = ( +my $map_trunk_status = { 0 => 'up', 1 => 'down', 2 => 'disable', 3 => 'uninitialized', 4 => 'loopback', - 5 => 'unpopulated', -); + 5 => 'unpopulated' +}; -my $sysTrunkTable = '.1.3.6.1.4.1.3375.2.1.2.12.1.2'; -my $sysTrunkName = '.1.3.6.1.4.1.3375.2.1.2.12.1.2.1.1'; -my $sysTrunkStatus = '.1.3.6.1.4.1.3375.2.1.2.12.1.2.1.2'; -my $sysTrunkOperBw = '.1.3.6.1.4.1.3375.2.1.2.12.1.2.1.5'; +my $mapping = { + sysTrunkName => { oid => '.1.3.6.1.4.1.3375.2.1.2.12.1.2.1.1' }, + sysTrunkStatus => { oid => '.1.3.6.1.4.1.3375.2.1.2.12.1.2.1.2', map => $map_trunk_status }, + sysTrunkOperBw => { oid => '.1.3.6.1.4.1.3375.2.1.2.12.1.2.1.5' } +}; +my $oid_sysTrunkTable = '.1.3.6.1.4.1.3375.2.1.2.12.1.2'; sub manage_selection { my ($self, %options) = @_; - $self->{result} = $self->{snmp}->get_table(oid => $sysTrunkTable, nothing_quit => 1); - - foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{result}})) { - next if ($oid !~ /^$sysTrunkName\.(.*)$/); + my $snmp_result = $options{snmp}->get_table( + oid => $oid_sysTrunkTable, + end => $mapping->{sysTrunkOperBw}->{oid}, + nothing_quit => 1 + ); + my $trunks = {}; + foreach my $oid (keys %$snmp_result) { + next if ($oid !~ /^$mapping->{sysTrunkName}->{oid}\.(.*)$/); my $instance = $1; + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance); - # Get all without a name - if (!defined($self->{option_results}->{name})) { - push @{$self->{trunks_selected}}, $instance; + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $result->{sysTrunkName} !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping trunk '" . $result->{sysTrunkName} . "': no matching filter name.", debug => 1); next; } - - if (!defined($self->{option_results}->{use_regexp}) && $self->{result}->{$sysTrunkName . '.' . $instance} eq $self->{option_results}->{name}) { - push @{$self->{trunks_selected}}, $instance; - next; - } - if (defined($self->{option_results}->{use_regexp}) && $self->{result}->{$sysTrunkName . '.' . $instance} =~ /$self->{option_results}->{name}/) { - push @{$self->{trunks_selected}}, $instance; - next; - } - - $self->{output}->output_add(long_msg => "Skipping pool '" . $self->{result}->{$sysTrunkName . '.' . $instance} . "': no matching filter name", debug => 1); + + $trunks->{$result->{sysTrunkName}} = $result; } + + return $trunks; } sub run { my ($self, %options) = @_; - $self->{snmp} = $options{snmp}; - $self->manage_selection(); - foreach my $instance (sort @{$self->{trunks_selected}}) { - $self->{output}->output_add(long_msg => sprintf("'%s' [status: %s] [speed: %s]", - $self->{result}->{$sysTrunkName . '.' . $instance}, - $map_trunk_status{$self->{result}->{$sysTrunkStatus . '.' . $instance}}, - $self->{result}->{$sysTrunkOperBw . '.' . $instance})); + my $trunks = $self->manage_selection(snmp => $options{snmp}); + foreach (sort keys %$trunks) { + $self->{output}->output_add( + long_msg => sprintf( + "'%s' [status: %s] [speed: %s]", + $_, + $trunks->{$_}->{sysTrunkStatus}, + $trunks->{$_}->{sysTrunkOperBw} + ) + ); } - $self->{output}->output_add(severity => 'OK', - short_msg => 'List Trunks:'); + $self->{output}->output_add( + severity => 'OK', + short_msg => 'List trunks:' + ); $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1); $self->{output}->exit(); } @@ -113,15 +115,14 @@ sub disco_format { sub disco_show { my ($self, %options) = @_; - $self->{snmp} = $options{snmp}; - $self->manage_selection(disco => 1); - foreach my $instance (sort @{$self->{trunks_selected}}) { - my $name = $self->{result}->{$sysTrunkName . '.' . $instance}; - my $status = $map_trunk_status{$self->{result}->{$sysTrunkStatus . '.' . $instance}}; - my $speed = $self->{result}->{$sysTrunkOperBw . '.' . $instance}; - - $self->{output}->add_disco_entry(name => $name, status => $status, speed => $speed); + my $trunks = $self->manage_selection(snmp => $options{snmp}); + foreach (sort keys %$trunks) { + $self->{output}->add_disco_entry( + name => $_, + status => $trunks->{$_}->{sysTrunkStatus}, + speed => $trunks->{$_}->{sysTrunkOperBw} + ); } } @@ -135,13 +136,9 @@ List Trunks. =over 8 -=item B<--name> +=item B<--filter-name> -Set the trunk name. - -=item B<--regexp> - -Allows to use regexp to filter trunk name (with option --name). +Filter by trunk name (regexp can be used). =back diff --git a/network/f5/bigip/snmp/mode/trunks.pm b/network/f5/bigip/snmp/mode/trunks.pm index c815b2126..44adeddf9 100644 --- a/network/f5/bigip/snmp/mode/trunks.pm +++ b/network/f5/bigip/snmp/mode/trunks.pm @@ -390,8 +390,8 @@ sub manage_selection { my $results = $options{snmp}->get_multiple_table( oids => [ - { oid => $oid_sysTrunkTable }, - { oid => $oid_sysTrunkStatTable }, + { oid => $oid_sysTrunkTable, end => $mapping_sysTrunk->{sysTrunkOperBw}->{oid} }, + { oid => $oid_sysTrunkStatTable } ], nothing_quit => 1 ); From 6c47f4cef198dcb28af27b0170f2a70bcc7e51a4 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 3 Apr 2020 10:50:06 +0200 Subject: [PATCH 072/283] add remove header http class --- centreon/plugins/http.pm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/centreon/plugins/http.pm b/centreon/plugins/http.pm index 7d35bc545..0fc547c6c 100644 --- a/centreon/plugins/http.pm +++ b/centreon/plugins/http.pm @@ -82,6 +82,12 @@ sub add_header { $self->{add_headers}->{$options{key}} = $options{value}; } +sub remove_header { + my ($self, %options) = @_; + + delete $self->{add_headers}->{$options{key}} if (defined($self->{add_headers}->{$options{key}})); +} + sub check_options { my ($self, %options) = @_; From 6b06a1891e3562ec4b7ea16fd0fd8d66b0174f01 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 3 Apr 2020 10:50:37 +0200 Subject: [PATCH 073/283] Ref #1886 --- cloud/azure/custom/api.pm | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/cloud/azure/custom/api.pm b/cloud/azure/custom/api.pm index ff5970c3e..165520f3c 100644 --- a/cloud/azure/custom/api.pm +++ b/cloud/azure/custom/api.pm @@ -153,7 +153,6 @@ sub settings { $self->build_options_for_httplib(); $self->{http}->add_header(key => 'Accept', value => 'application/json'); - $self->{http}->add_header(key => 'Content-Type', value => 'application/x-www-form-urlencoded'); if (defined($self->{access_token})) { $self->{http}->add_header(key => 'Authorization', value => 'Bearer ' . $self->{access_token}); } @@ -163,7 +162,13 @@ sub settings { sub get_access_token { my ($self, %options) = @_; - my $has_cache_file = $options{statefile}->read(statefile => 'azure_api_' . md5_hex($self->{subscription}) . '_' . md5_hex($self->{tenant}) . '_' . md5_hex($self->{client_id})); + my $has_cache_file = $options{statefile}->read( + statefile => + 'azure_api_' . + md5_hex($self->{subscription}) . '_' . + md5_hex($self->{tenant}) . '_' . + md5_hex($self->{client_id}) + ); my $expires_on = $options{statefile}->get(name => 'expires_on'); my $access_token = $options{statefile}->get(name => 'access_token'); @@ -180,7 +185,8 @@ sub get_access_token { my $content = $self->{http}->request( method => 'POST', query_form_post => $post_data, full_url => $self->{login_endpoint} . '/' . $self->{tenant} . '/oauth2/token', - hostname => '' + hostname => '', + header => [ 'Content-Type: application/x-www-form-urlencoded' ] ); if (!defined($content) || $content eq '' || $self->{http}->get_header(name => 'content-length') == 0) { @@ -220,10 +226,7 @@ sub request_api { $self->settings(); - $self->{output}->output_add(long_msg => "URL: '" . $options{full_url} . "'", debug => 1); - - my $content = $self->{http}->request(%options); - + my $content = $self->{http}->request(%options); if (!defined($content) || $content eq '' || $self->{http}->get_header(name => 'content-length') == 0) { $self->{output}->add_option_msg(short_msg => "Management endpoint API returns empty content [code: '" . $self->{http}->get_code() . "'] [message: '" . $self->{http}->get_message() . "']"); $self->{output}->option_exit(); From 062aa94b741db6bd6b7e89996425521e011535d4 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 3 Apr 2020 11:44:18 +0200 Subject: [PATCH 074/283] remove useless dep --- apps/mq/rabbitmq/restapi/custom/api.pm | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/mq/rabbitmq/restapi/custom/api.pm b/apps/mq/rabbitmq/restapi/custom/api.pm index c8a25b796..45526813b 100644 --- a/apps/mq/rabbitmq/restapi/custom/api.pm +++ b/apps/mq/rabbitmq/restapi/custom/api.pm @@ -25,7 +25,6 @@ use base qw(centreon::plugins::mode); use strict; use warnings; use centreon::plugins::http; -use URI::Encode; use JSON::XS; sub new { From 34d3b704c3196c736207c95a50c3049f120427b2 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 3 Apr 2020 11:45:02 +0200 Subject: [PATCH 075/283] Fix #1886 --- .../azure/compute/virtualmachine/mode/cpu.pm | 15 +-- cloud/azure/custom/api.pm | 20 +++ cloud/azure/custom/azcli.pm | 16 +++ cloud/azure/management/monitor/mode/logs.pm | 121 ++++++++++++++++++ cloud/azure/management/monitor/plugin.pm | 3 +- 5 files changed, 166 insertions(+), 9 deletions(-) create mode 100644 cloud/azure/management/monitor/mode/logs.pm diff --git a/cloud/azure/compute/virtualmachine/mode/cpu.pm b/cloud/azure/compute/virtualmachine/mode/cpu.pm index 145c887fb..8149deda8 100644 --- a/cloud/azure/compute/virtualmachine/mode/cpu.pm +++ b/cloud/azure/compute/virtualmachine/mode/cpu.pm @@ -81,13 +81,12 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - "resource:s@" => { name => 'resource' }, - "resource-group:s" => { name => 'resource_group' }, - "filter-metric:s" => { name => 'filter_metric' }, - }); - + $options{options}->add_options(arguments =>v{ + 'resource:s@' => { name => 'resource' }, + 'resource-group:s' => { name => 'resource_group' }, + 'filter-metric:s' => { name => 'filter_metric' } + }); + return $self; } @@ -99,7 +98,7 @@ sub check_options { $self->{output}->add_option_msg(short_msg => "Need to specify either --resource with --resource-group option or --resource ."); $self->{output}->option_exit(); } - + $self->{az_resource} = $self->{option_results}->{resource}; $self->{az_resource_group} = $self->{option_results}->{resource_group} if (defined($self->{option_results}->{resource_group})); $self->{az_resource_type} = 'virtualMachines'; diff --git a/cloud/azure/custom/api.pm b/cloud/azure/custom/api.pm index 165520f3c..5bfa01459 100644 --- a/cloud/azure/custom/api.pm +++ b/cloud/azure/custom/api.pm @@ -635,6 +635,26 @@ sub azure_list_sqldatabases { return $response->{value}; } +sub azure_get_log_analytics_set_url { + my ($self, %options) = @_; + + my $uri = URI::Encode->new({encode_reserved => 1}); + my $encoded_query = $uri->encode($options{query}); + my $encoded_interval = $uri->encode($options{interval}); + my $url = $self->{management_endpoint} . '/v1/workspaces/' . $options{workspace_id} . '/query?query=' . $encoded_query . '×pan=' . $encoded_interval; + + return $url; +} + +sub azure_get_log_analytics { + my ($self, %options) = @_; + + my $full_url = $self->azure_get_log_analytics_set_url(%options); + my $response = $self->request_api(method => 'GET', full_url => $full_url, hostname => ''); + + return $response; +} + 1; __END__ diff --git a/cloud/azure/custom/azcli.pm b/cloud/azure/custom/azcli.pm index 3f2b7deed..5ae02540e 100644 --- a/cloud/azure/custom/azcli.pm +++ b/cloud/azure/custom/azcli.pm @@ -507,6 +507,22 @@ sub azure_list_sqldatabases { return $raw_results; } +sub azure_get_log_analytics_set_cmd { + my ($self, %options) = @_; + + return if (defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne ''); + + my $cmd_options = "monitor log-analytics query --workspace '$options{workspace_id}' --analytics-query \"$options{query}\" --timespan '$options{interval}'"; + return $cmd_options; +} + +sub azure_get_log_analytics { + my ($self, %options) = @_; + + my $cmd_options = $self->azure_get_log_analytics_set_cmd(%options); + return $self->execute(cmd_options => $cmd_options); +} + 1; __END__ diff --git a/cloud/azure/management/monitor/mode/logs.pm b/cloud/azure/management/monitor/mode/logs.pm new file mode 100644 index 000000000..27dc87574 --- /dev/null +++ b/cloud/azure/management/monitor/mode/logs.pm @@ -0,0 +1,121 @@ +# +# Copyright 2020 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 cloud::azure::management::monitor::mode::logs; + +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 => 'total', nlabel => 'logs.total.count', set => { + key_values => [ { name => 'total' } ], + output_template => 'total logs: %s', + perfdatas => [ + { value => 'total_absolute', template => '%s', min => 0 } + ] + } + } + ]; +} + +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 => { + 'workspace-id:s' => { name => 'workspace_id' }, + 'query:s' => { name => 'query'} + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + if (!defined($self->{option_results}->{workspace_id}) || $self->{option_results}->{workspace_id} eq '') { + $self->{output}->add_option_msg(short_msg => "Need to specify --workspace-id ."); + $self->{output}->option_exit(); + } + + if (!defined($self->{option_results}->{query}) || $self->{option_results}->{query} eq '') { + $self->{output}->add_option_msg(short_msg => "Need to specify a query."); + $self->{output}->option_exit(); + } + + $self->{az_interval} = defined($self->{option_results}->{interval}) ? $self->{option_results}->{interval} : 'PT5M'; +} + +sub manage_selection { + my ($self, %options) = @_; + + my ($log_results) = $options{custom}->azure_get_log_analytics( + workspace_id => $self->{option_results}->{workspace_id}, + query => $self->{option_results}->{query}, + interval => $self->{az_interval} + ); + + $self->{global} = { total => 0 }; + foreach my $table (@{$log_results->{tables}}) { + foreach (@{$table->{rows}}) { + $self->{global}->{total} += $_->[2]; + } + } +} + +1; + +__END__ + +=head1 MODE + +Check logs queries. +You should set option: --management-endpoint='https://api.loganalytics.io' + +=over 8 + +=item B<--workspace-id> + +Set workspace id (Required). + +=item B<--query> + +Set query (Required). +Syntax: https://docs.microsoft.com/en-us/azure/kusto/query/ + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: count. + +=back + +=cut diff --git a/cloud/azure/management/monitor/plugin.pm b/cloud/azure/management/monitor/plugin.pm index a217fb34e..197528585 100644 --- a/cloud/azure/management/monitor/plugin.pm +++ b/cloud/azure/management/monitor/plugin.pm @@ -31,10 +31,11 @@ sub new { $self->{version} = '1.0'; %{$self->{modes}} = ( + 'alert' => 'cloud::azure::management::monitor::mode::alert', 'discovery' => 'cloud::azure::management::monitor::mode::discovery', 'get-metrics' => 'cloud::azure::management::monitor::mode::getmetrics', 'health' => 'cloud::azure::management::monitor::mode::health', - 'alert' => 'cloud::azure::management::monitor::mode::alert', + 'logs' => 'cloud::azure::management::monitor::mode::logs' ); $self->{custom_modes}{azcli} = 'cloud::azure::custom::azcli'; From 61340536e97d84178fd77941e16a17832c36afaa Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 3 Apr 2020 13:14:47 +0200 Subject: [PATCH 076/283] perfdata vm memory --- apps/vmware/connector/mode/memoryvm.pm | 106 ++++++++++++------------- 1 file changed, 53 insertions(+), 53 deletions(-) diff --git a/apps/vmware/connector/mode/memoryvm.pm b/apps/vmware/connector/mode/memoryvm.pm index 80b375483..617b1736a 100644 --- a/apps/vmware/connector/mode/memoryvm.pm +++ b/apps/vmware/connector/mode/memoryvm.pm @@ -47,7 +47,7 @@ sub custom_usage_perfdata { my ($label, $nlabel) = ('used', $self->{nlabel}); my $value_perf = $self->{result_values}->{used}; if (defined($self->{instance_mode}->{option_results}->{free})) { - ($label, $nlabel) = ('free', 'vm.memory.free.bytes'); + ($label, $nlabel) = ('free', 'vm.memory.' . $self->{result_values}->{label_ref} . '.free.bytes'); $value_perf = $self->{result_values}->{free}; } @@ -58,7 +58,7 @@ sub custom_usage_perfdata { } $self->{output}->perfdata_add( - label => $label, unit => 'B', + label => $self->{result_values}->{label_ref} . '_' . $label, unit => 'B', instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef, nlabel => $nlabel, value => $value_perf, @@ -88,12 +88,13 @@ sub custom_usage_output { my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}); my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}); my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}); - my $msg = sprintf("Memory %s Usage Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", - $self->{result_values}->{label_ref}, - $total_size_value . " " . $total_size_unit, - $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used}, - $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free}); - return $msg; + my $msg = sprintf( + 'Memory %s Usage Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)', + $self->{result_values}->{label_ref}, + $total_size_value . " " . $total_size_unit, + $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used}, + $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free} + ); } sub custom_usage_calc { @@ -107,7 +108,7 @@ sub custom_usage_calc { $self->{error_msg} = 'size is 0'; return -20; } - + $self->{result_values}->{used} = $options{new_datas}->{$self->{instance} . '_' . $self->{result_values}->{label_ref}}; $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}; @@ -120,24 +121,21 @@ sub custom_overhead_output { my ($self, %options) = @_; my ($value, $unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{overhead_absolute}); - my $msg = sprintf("Memory overhead: %s %s", $value, $unit); - return $msg; + return sprintf('Memory overhead: %s %s', $value, $unit); } sub custom_ballooning_output { my ($self, %options) = @_; my ($value, $unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{vmmemctl_absolute}); - my $msg = sprintf("Memory ballooning: %s %s", $value, $unit); - return $msg; + return sprintf('Memory ballooning: %s %s', $value, $unit); } sub custom_shared_output { my ($self, %options) = @_; my ($value, $unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{shared_absolute}); - my $msg = sprintf("Memory shared: %s %s", $value, $unit); - return $msg; + return sprintf('Memory shared: %s %s', $value, $unit); } sub set_counters { @@ -162,30 +160,30 @@ sub set_counters { closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => \&catalog_status_threshold, + closure_custom_threshold_check => \&catalog_status_threshold } - }, + } ]; $self->{maps_counters}->{global_consumed} = [ - { label => 'consumed', nlabel => 'vm.memory.usage.bytes', set => { + { label => 'consumed', nlabel => 'vm.memory.consumed.usage.bytes', set => { key_values => [ { name => 'consumed' }, { name => 'total' } ], closure_custom_calc => $self->can('custom_usage_calc'), closure_custom_calc_extra_options => { label_ref => 'consumed' }, 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'), + closure_custom_threshold_check => $self->can('custom_usage_threshold') } - }, + } ]; $self->{maps_counters}->{global_active} = [ - { label => 'active', nlabel => 'vm.memory.active.bytes', set => { + { label => 'active', nlabel => 'vm.memory.active.usage.bytes', set => { key_values => [ { name => 'active' }, { name => 'total' } ], closure_custom_calc => $self->can('custom_usage_calc'), closure_custom_calc_extra_options => { label_ref => 'active' }, 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'), + closure_custom_threshold_check => $self->can('custom_usage_threshold') } - }, + } ]; $self->{maps_counters}->{global_overhead} = [ { label => 'overhead', nlabel => 'vm.memory.overhead.bytes', set => { @@ -193,10 +191,10 @@ sub set_counters { closure_custom_output => $self->can('custom_overhead_output'), perfdatas => [ { label => 'overhead', value => 'overhead_absolute', template => '%s', unit => 'B', - min => 0, label_extra_instance => 1 }, - ], + min => 0, label_extra_instance => 1 } + ] } - }, + } ]; $self->{maps_counters}->{global_vmmemctl} = [ { label => 'ballooning', nlabel => 'vm.memory.ballooning.bytes', set => { @@ -204,10 +202,10 @@ sub set_counters { closure_custom_output => $self->can('custom_ballooning_output'), perfdatas => [ { label => 'ballooning', value => 'vmmemctl_absolute', template => '%s', unit => 'B', - min => 0, label_extra_instance => 1 }, - ], + min => 0, label_extra_instance => 1 } + ] } - }, + } ]; $self->{maps_counters}->{global_shared} = [ { label => 'shared', nlabel => 'vm.memory.shared.bytes', set => { @@ -215,10 +213,10 @@ sub set_counters { closure_custom_output => $self->can('custom_shared_output'), perfdatas => [ { label => 'shared', value => 'shared_absolute', template => '%s', unit => 'B', - min => 0, label_extra_instance => 1 }, - ], + min => 0, label_extra_instance => 1 } + ] } - }, + } ]; } @@ -230,7 +228,7 @@ sub prefix_vm_output { $msg .= ' [annotation: ' . $options{instance_value}->{config_annotation} . ']'; } $msg .= ' : '; - + return $msg; } @@ -241,7 +239,7 @@ sub vm_long_output { if (defined($options{instance_value}->{config_annotation})) { $msg .= ' [annotation: ' . $options{instance_value}->{config_annotation} . ']'; } - + return $msg; } @@ -251,20 +249,20 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - "vm-hostname:s" => { name => 'vm_hostname' }, - "filter" => { name => 'filter' }, - "scope-datacenter:s" => { name => 'scope_datacenter' }, - "scope-cluster:s" => { name => 'scope_cluster' }, - "scope-host:s" => { name => 'scope_host' }, - "filter-description:s" => { name => 'filter_description' }, - "filter-os:s" => { name => 'filter_os' }, - "filter-uuid:s" => { name => 'filter_uuid' }, - "display-description" => { name => 'display_description' }, - "units:s" => { name => 'units', default => '%' }, - "free" => { name => 'free' }, - "unknown-status:s" => { name => 'unknown_status', default => '%{connection_state} !~ /^connected$/i or %{power_state} !~ /^poweredOn$/i' }, - "warning-status:s" => { name => 'warning_status', default => '' }, - "critical-status:s" => { name => 'critical_status', default => '' }, + 'vm-hostname:s' => { name => 'vm_hostname' }, + 'filter' => { name => 'filter' }, + 'scope-datacenter:s' => { name => 'scope_datacenter' }, + 'scope-cluster:s' => { name => 'scope_cluster' }, + 'scope-host:s' => { name => 'scope_host' }, + 'filter-description:s' => { name => 'filter_description' }, + 'filter-os:s' => { name => 'filter_os' }, + 'filter-uuid:s' => { name => 'filter_uuid' }, + 'display-description' => { name => 'display_description' }, + 'units:s' => { name => 'units', default => '%' }, + 'free' => { name => 'free' }, + 'unknown-status:s' => { name => 'unknown_status', default => '%{connection_state} !~ /^connected$/i or %{power_state} !~ /^poweredOn$/i' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '' }, }); return $self; @@ -281,19 +279,21 @@ sub manage_selection { my ($self, %options) = @_; $self->{vm} = {}; - my $response = $options{custom}->execute(params => $self->{option_results}, - command => 'memvm'); + my $response = $options{custom}->execute( + params => $self->{option_results}, + command => 'memvm' + ); foreach my $vm_id (keys %{$response->{data}}) { my $vm_name = $response->{data}->{$vm_id}->{name}; - + $self->{vm}->{$vm_name} = { display => $vm_name, global => { connection_state => $response->{data}->{$vm_id}->{connection_state}, power_state => $response->{data}->{$vm_id}->{power_state}, }, }; - + foreach (('consumed', 'active', 'overhead', 'vmmemctl', 'shared')) { next if (!defined($response->{data}->{$vm_id}->{'mem.' . $_ . '.average'})); $self->{vm}->{$vm_name}->{'global_' . $_} = { @@ -301,7 +301,7 @@ sub manage_selection { total => $response->{data}->{$vm_id}->{memory_size} }; } - + if (defined($self->{option_results}->{display_description})) { $self->{vm}->{$vm_name}->{config_annotation} = $options{custom}->strip_cr(value => $response->{data}->{$vm_id}->{'config.annotation'}); } From a6fbd9046af432ff10f2cbaf3cb7fd50505671ab Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 3 Apr 2020 14:43:43 +0200 Subject: [PATCH 077/283] Fix #1902 --- network/arista/snmp/mode/memory.pm | 181 +++++++++++++++++++---------- 1 file changed, 121 insertions(+), 60 deletions(-) diff --git a/network/arista/snmp/mode/memory.pm b/network/arista/snmp/mode/memory.pm index 6ab97efb8..9d8b90d59 100644 --- a/network/arista/snmp/mode/memory.pm +++ b/network/arista/snmp/mode/memory.pm @@ -25,45 +25,144 @@ use base qw(snmp_standard::mode::storage); use strict; use warnings; -sub default_storage_type { +sub custom_usage_output { my ($self, %options) = @_; - - return '^(hrStorageRam|hrStorageFlashMemory)'; + + return sprintf( + 'Ram Total: %s %s Used (-buffers/cache): %s %s (%.2f%%) Free: %s %s (%.2f%%)', + $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_absolute}), + $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_absolute}), + $self->{result_values}->{prct_used_absolute}, + $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute}), + $self->{result_values}->{prct_free_absolute} + ); } sub set_counters { my ($self, %options) = @_; - + $self->{maps_counters_type} = [ - { name => 'storage', type => 1, cb_prefix_output => 'prefix_storage_output', message_multiple => 'All memory spaces are ok' }, + { name => 'ram', type => 0, skipped_code => { -10 => 1 } } ]; - - $self->{maps_counters}->{storage} = [ + + $self->{maps_counters}->{ram} = [ { label => 'usage', nlabel => 'memory.usage.bytes', set => { - key_values => [ { name => 'display' }, { name => 'used' }, { name => 'size' }, { name => 'allocation_units' } ], - closure_custom_calc => $self->can('custom_usage_calc'), + key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], 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'), + perfdatas => [ + { value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute', + unit => 'B', cast_int => 1 } + ] } }, + { label => 'usage-free', display_ok => 0, nlabel => 'memory.free.bytes', set => { + key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], + closure_custom_output => $self->can('custom_usage_output'), + perfdatas => [ + { value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute', + unit => 'B', cast_int => 1 } + ] + } + }, + { label => 'usage-prct', display_ok => 0, nlabel => 'memory.usage.percentage', set => { + key_values => [ { name => 'prct_used' } ], + output_template => 'Ram Used : %.2f %%', + perfdatas => [ + { value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, + unit => '%' } + ] + } + }, + { label => 'buffer', nlabel => 'memory.buffer.bytes', set => { + key_values => [ { name => 'buffer' } ], + output_template => 'Buffer: %s %s', + output_change_bytes => 1, + perfdatas => [ + { value => 'buffer_absolute', template => '%d', + min => 0, unit => 'B' } + ] + } + }, + { label => 'cached', nlabel => 'memory.cached.bytes', set => { + key_values => [ { name => 'cached' } ], + output_template => 'Cached: %s %s', + output_change_bytes => 1, + perfdatas => [ + { value => 'cached_absolute', template => '%d', + min => 0, unit => 'B' } + ] + } + } ]; } -sub prefix_storage_output { - my ($self, %options) = @_; - - return "Memory space '" . $options{instance_value}->{display} . "' "; -} - sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); bless $self, $class; return $self; } +my $mapping = { + hrStorageDescr => { oid => '.1.3.6.1.2.1.25.2.3.1.3' }, + hrStorageAllocationUnits => { oid => '.1.3.6.1.2.1.25.2.3.1.4' }, + hrStorageSize => { oid => '.1.3.6.1.2.1.25.2.3.1.5' }, + hrStorageUsed => { oid => '.1.3.6.1.2.1.25.2.3.1.6' } +}; + +sub manage_selection { + my ($self, %options) = @_; + + my $storage_type_ram = '.1.3.6.1.2.1.25.2.1.2'; + my $oid_hrstoragetype = '.1.3.6.1.2.1.25.2.3.1.2'; + + my $snmp_result = $options{snmp}->get_table(oid => $oid_hrstoragetype, nothing_quit => 1); + my $storages = []; + foreach (keys %$snmp_result) { + next if ($snmp_result->{$_} ne $storage_type_ram); + /^$oid_hrstoragetype\.(.*)$/; + push @$storages, $1; + } + + $options{snmp}->load( + oids => [map($_->{oid}, values(%$mapping))], + instances => $storages, + nothing_quit => 1 + ); + $snmp_result = $options{snmp}->get_leef(); + + my ($total, $used, $cached, $buffer); + #.1.3.6.1.2.1.25.2.3.1.3.1 = STRING: RAM + #.1.3.6.1.2.1.25.2.3.1.3.2 = STRING: RAM (Buffers) + #.1.3.6.1.2.1.25.2.3.1.3.3 = STRING: RAM (Cache) + foreach (@$storages) { + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $_); + my $current = $result->{hrStorageUsed} * $result->{hrStorageAllocationUnits}; + next if ($current < 0); + + if ($result->{hrStorageDescr} =~ /RAM.*?Cache/i) { + $cached = $current; + } elsif ($result->{hrStorageDescr} =~ /RAM.*?Buffers/i) { + $buffer = $current; + } elsif ($result->{hrStorageDescr} =~ /RAM/i) { + $used = $current; + $total = $result->{hrStorageSize} * $result->{hrStorageAllocationUnits}; + } + } + + $used -= (defined($cached) ? $cached : 0) - (defined($buffer) ? $buffer : 0); + $self->{ram} = { + total => $total, + cached => $cached, + buffer => $buffer, + used => $used, + free => $total - $used, + prct_used => $used * 100 / $total, + prct_free => 100 - ($used * 100 / $total) + }; +} + 1; __END__ @@ -74,49 +173,11 @@ Check memory. =over 8 -=item B<--warning-usage> +=item B<--warning-*> B<--critical-*> -Threshold warning. - -=item B<--critical-usage> - -Threshold critical. - -=item B<--units> - -Units of thresholds (Default: '%') ('%', 'B'). - -=item B<--free> - -Thresholds are on free space left. - -=item B<--storage> - -Set the storage (number expected) ex: 1, 2,... (empty means 'check all storage'). - -=item B<--name> - -Allows to use storage name with option --storage instead of storage oid index. - -=item B<--regexp> - -Allows to use regexp to filter storage (with option --name). - -=item B<--regexp-isensitive> - -Allows to use regexp non case-sensitive (with --regexp). - -=item B<--reload-cache-time> - -Time in minutes before reloading cache file (default: 180). - -=item B<--show-cache> - -Display cache storage datas. - -=item B<--filter-storage-type> - -Filter storage types with a regexp (Default: '^(hrStorageRam|hrStorageFlashMemory)$'). +Thresholds. +Can be: 'usage' (B), 'usage-free' (B), 'usage-prct' (%), +'buffer' (B), 'cached' (B). =back From ab702288133e18f78a9ed8b81766c17d6a325ae3 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 3 Apr 2020 14:57:02 +0200 Subject: [PATCH 078/283] enhance typo --- .../acs/6000/snmp/mode/components/psu.pm | 29 +++++++++++------ .../avocent/acs/6000/snmp/mode/hardware.pm | 23 +++++++------ .../acs/8000/snmp/mode/components/psu.pm | 32 ++++++++++++------- .../avocent/acs/8000/snmp/mode/hardware.pm | 19 ++++++----- 4 files changed, 60 insertions(+), 43 deletions(-) diff --git a/hardware/kvm/avocent/acs/6000/snmp/mode/components/psu.pm b/hardware/kvm/avocent/acs/6000/snmp/mode/components/psu.pm index d64ae8273..9e8994891 100644 --- a/hardware/kvm/avocent/acs/6000/snmp/mode/components/psu.pm +++ b/hardware/kvm/avocent/acs/6000/snmp/mode/components/psu.pm @@ -33,32 +33,41 @@ my $oid_acsPowerSupply = '.1.3.6.1.4.1.10418.16.2.1.8'; sub load { my ($self) = @_; - + push @{$self->{request}}, { oid => $oid_acsPowerSupply }; } sub check_psu { my ($self, %options) = @_; - + return if ($self->check_filter(section => 'psu', instance => $options{instance})); return if ($options{state} eq 'powerNotInstalled' && $self->absent_problem(section => 'psu', instance => $options{instance})); $self->{components}->{psu}->{total}++; - $self->{output}->output_add(long_msg => sprintf("power supply '%s' status is %s.", - $options{instance}, $options{state} - )); + $self->{output}->output_add( + long_msg => sprintf( + "power supply '%s' status is %s.", + $options{instance}, $options{state} + ) + ); + my $exit = $self->get_severity(section => 'psu', value => $options{state}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Power supply '%s' status is %s", - $options{instance}, $options{state})); + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "Power supply '%s' status is %s", + $options{instance}, + $options{state} + ) + ); } } sub check { my ($self) = @_; - + $self->{output}->output_add(long_msg => "Checking power supplies"); $self->{components}->{psu} = {name => 'psus', total => 0, skip => 0}; return if ($self->check_filter(section => 'psu')); @@ -68,4 +77,4 @@ sub check { check_psu($self, state => $result->{acsPowerSupplyStatePw2}, instance => '2'); } -1; \ No newline at end of file +1; diff --git a/hardware/kvm/avocent/acs/6000/snmp/mode/hardware.pm b/hardware/kvm/avocent/acs/6000/snmp/mode/hardware.pm index 4b92bb5ff..d8f24ca3a 100644 --- a/hardware/kvm/avocent/acs/6000/snmp/mode/hardware.pm +++ b/hardware/kvm/avocent/acs/6000/snmp/mode/hardware.pm @@ -27,26 +27,26 @@ use warnings; sub set_system { my ($self, %options) = @_; - + $self->{regexp_threshold_overload_check_section_option} = '^(psu)$'; - + $self->{cb_hook2} = 'snmp_execute'; - + $self->{thresholds} = { psu => [ ['statePowerOn', 'OK'], ['statePowerOff', 'CRITICAL'], - ['powerNotInstalled', 'OK'], - ], + ['powerNotInstalled', 'OK'] + ] }; - + $self->{components_path} = 'hardware::kvm::avocent::acs::6000::snmp::mode::components'; $self->{components_module} = ['psu']; } sub snmp_execute { my ($self, %options) = @_; - + $self->{snmp} = $options{snmp}; $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); } @@ -55,10 +55,9 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_performance => 1); bless $self, $class; - - $options{options}->add_options(arguments => - { - }); + + $options{options}->add_options(arguments => { + }); return $self; } @@ -101,4 +100,4 @@ Example: --threshold-overload='psu,CRITICAL,^(?!(statePowerOn)$)' =back -=cut \ No newline at end of file +=cut diff --git a/hardware/kvm/avocent/acs/8000/snmp/mode/components/psu.pm b/hardware/kvm/avocent/acs/8000/snmp/mode/components/psu.pm index cc79ec0a1..c17cb32d4 100644 --- a/hardware/kvm/avocent/acs/8000/snmp/mode/components/psu.pm +++ b/hardware/kvm/avocent/acs/8000/snmp/mode/components/psu.pm @@ -27,38 +27,48 @@ my %map_states = (1 => 'statePowerOn', 2 => 'statePowerOff', 9999 => 'powerNotIn my $mapping = { acsPowerSupplyStatePw1 => { oid => '.1.3.6.1.4.1.10418.26.2.1.8.2', map => \%map_states }, - acsPowerSupplyStatePw2 => { oid => '.1.3.6.1.4.1.10418.26.2.1.8.3', map => \%map_states }, + acsPowerSupplyStatePw2 => { oid => '.1.3.6.1.4.1.10418.26.2.1.8.3', map => \%map_states } }; my $oid_acsPowerSupply = '.1.3.6.1.4.1.10418.26.2.1.8'; sub load { my ($self) = @_; - + push @{$self->{request}}, { oid => $oid_acsPowerSupply }; } sub check_psu { my ($self, %options) = @_; - + return if ($self->check_filter(section => 'psu', instance => $options{instance})); return if ($options{state} eq 'powerNotInstalled' && $self->absent_problem(section => 'psu', instance => $options{instance})); $self->{components}->{psu}->{total}++; - $self->{output}->output_add(long_msg => sprintf("power supply '%s' status is %s.", - $options{instance}, $options{state} - )); + $self->{output}->output_add( + long_msg => sprintf( + "power supply '%s' status is %s.", + $options{instance}, + $options{state} + ) + ); + my $exit = $self->get_severity(section => 'psu', value => $options{state}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Power supply '%s' status is %s", - $options{instance}, $options{state})); + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "Power supply '%s' status is %s", + $options{instance}, + $options{state} + ) + ); } } sub check { my ($self) = @_; - + $self->{output}->output_add(long_msg => "Checking power supplies"); $self->{components}->{psu} = {name => 'psus', total => 0, skip => 0}; return if ($self->check_filter(section => 'psu')); @@ -68,4 +78,4 @@ sub check { check_psu($self, state => $result->{acsPowerSupplyStatePw2}, instance => '2'); } -1; \ No newline at end of file +1; diff --git a/hardware/kvm/avocent/acs/8000/snmp/mode/hardware.pm b/hardware/kvm/avocent/acs/8000/snmp/mode/hardware.pm index 9eabd07b3..8a3283d75 100644 --- a/hardware/kvm/avocent/acs/8000/snmp/mode/hardware.pm +++ b/hardware/kvm/avocent/acs/8000/snmp/mode/hardware.pm @@ -27,17 +27,17 @@ use warnings; sub set_system { my ($self, %options) = @_; - + $self->{regexp_threshold_overload_check_section_option} = '^(psu)$'; - + $self->{cb_hook2} = 'snmp_execute'; - + $self->{thresholds} = { psu => [ ['statePowerOn', 'OK'], ['statePowerOff', 'CRITICAL'], - ['powerNotInstalled', 'OK'], - ], + ['powerNotInstalled', 'OK'] + ] }; $self->{components_path} = 'hardware::kvm::avocent::acs::8000::snmp::mode::components'; @@ -55,10 +55,9 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_performance => 1); bless $self, $class; - - $options{options}->add_options(arguments => - { - }); + + $options{options}->add_options(arguments => { + }); return $self; } @@ -101,4 +100,4 @@ Example: --threshold-overload='psu,CRITICAL,^(?!(statePowerOn)$)' =back -=cut \ No newline at end of file +=cut From 4e6a892afaabebdbc62378bbb9900a4d9baba34b Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 3 Apr 2020 14:59:48 +0200 Subject: [PATCH 079/283] acs 8000 new perfdata --- hardware/kvm/avocent/acs/8000/snmp/mode/hardware.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hardware/kvm/avocent/acs/8000/snmp/mode/hardware.pm b/hardware/kvm/avocent/acs/8000/snmp/mode/hardware.pm index 8a3283d75..4efd2cde9 100644 --- a/hardware/kvm/avocent/acs/8000/snmp/mode/hardware.pm +++ b/hardware/kvm/avocent/acs/8000/snmp/mode/hardware.pm @@ -53,7 +53,7 @@ sub snmp_execute { sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_performance => 1); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_performance => 1, force_new_perfdata => 1); bless $self, $class; $options{options}->add_options(arguments => { From dd9c7f6fd68ec8077f080ad003ae145ff39d6451 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 3 Apr 2020 15:30:51 +0200 Subject: [PATCH 080/283] add endpoint in access token azure --- cloud/azure/custom/api.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cloud/azure/custom/api.pm b/cloud/azure/custom/api.pm index 5bfa01459..6fb27744e 100644 --- a/cloud/azure/custom/api.pm +++ b/cloud/azure/custom/api.pm @@ -167,7 +167,8 @@ sub get_access_token { 'azure_api_' . md5_hex($self->{subscription}) . '_' . md5_hex($self->{tenant}) . '_' . - md5_hex($self->{client_id}) + md5_hex($self->{client_id}) . '_' . + md5_hex($self->{management_endpoint}) ); my $expires_on = $options{statefile}->get(name => 'expires_on'); my $access_token = $options{statefile}->get(name => 'access_token'); From fe59e6c37f3d5a245a51a02d424066027093c9c8 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 3 Apr 2020 16:05:51 +0200 Subject: [PATCH 081/283] add mode for avocent acs 8000 --- .../avocent/acs/8000/snmp/mode/serialports.pm | 196 ++++++++++++++++++ hardware/kvm/avocent/acs/8000/snmp/plugin.pm | 1 + 2 files changed, 197 insertions(+) create mode 100644 hardware/kvm/avocent/acs/8000/snmp/mode/serialports.pm diff --git a/hardware/kvm/avocent/acs/8000/snmp/mode/serialports.pm b/hardware/kvm/avocent/acs/8000/snmp/mode/serialports.pm new file mode 100644 index 000000000..152a73e9c --- /dev/null +++ b/hardware/kvm/avocent/acs/8000/snmp/mode/serialports.pm @@ -0,0 +1,196 @@ +# +# Copyright 2020 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 hardware::kvm::avocent::acs::8000::snmp::mode::serialports; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); +use Digest::MD5 qw(md5_hex); + +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 => 'serials', type => 1, cb_prefix_output => 'prefix_serial_output', message_multiple => 'All serial ports are ok' } + ]; + + $self->{maps_counters}->{serials} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'status' }, { name => 'display' } ], + closure_custom_calc => \&catalog_status_calc, + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold + } + }, + { label => 'traffic-in', nlabel => 'serialport.traffic.in.bitspersecond', set => { + key_values => [ { name => 'traffic_in', diff => 1 }, { name => 'display' } ], + output_template => 'traffic in: %s%s/s', + per_second => 1, output_change_bytes => 2, + perfdatas => [ + { value => 'traffic_in_per_second', template => '%s', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' } + ] + } + }, + { label => 'traffic-out', nlabel => 'serialport.traffic.out.bitspersecond', set => { + key_values => [ { name => 'traffic_out', diff => 1 }, { name => 'display' } ], + output_template => 'traffic out: %s%s/s', + per_second => 1, output_change_bytes => 2, + perfdatas => [ + { value => 'traffic_out_per_second', template => '%s', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' } + ] + } + } + ]; +} + +sub prefix_serial_output { + my ($self, %options) = @_; + + return "Serial port '" . $options{instance_value}->{display} . "' "; +} + +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 => { + 'filter-name:s' => { name => 'filter_name' }, + 'unknown-status:s' => { name => 'unknown_status', default => '' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '' } + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->change_macros( + macros => [ + 'unknown_status', 'warning_status', 'critical_status' + ] + ); +} + +my $map_status = { 1 => 'disabled', 2 => 'idle', 3 => 'inUse' }; + +my $mapping = { + status => { oid => '.1.3.6.1.4.1.10418.26.2.3.2.1.3', map => $map_status }, # acsSerialPortTableStatus + traffic_out => { oid => '.1.3.6.1.4.1.10418.26.2.3.2.1.16' }, # acsSerialPortTableTxBytes + traffic_in => { oid => '.1.3.6.1.4.1.10418.26.2.3.2.1.17' } # acsSerialPortTableRxBytes +}; + +sub manage_selection { + my ($self, %options) = @_; + + my $oid_acsSerialPortTableDeviceName = '.1.3.6.1.4.1.10418.26.2.3.2.1.2'; + my $snmp_result = $options{snmp}->get_table( + oid => $oid_acsSerialPortTableDeviceName, + nothing_quit => 1 + ); + + $self->{serials} = {}; + foreach (keys %$snmp_result) { + /\.(\d+)$/; + my $instance = $1; + my $name = $snmp_result->{$_}; + + 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 port '" . $name . "'.", debug => 1); + next; + } + + $self->{serials}->{$instance} = { display => $name }; + } + + return if (scalar(keys %{$self->{serials}}) <= 0); + + $options{snmp}->load( + oids => [ map($_->{oid}, values(%$mapping)) ], + instances => [ keys %{$self->{serials}} ], + instance_regexp => '^(.*)$' + ); + $snmp_result = $options{snmp}->get_leef(); + foreach (keys %{$self->{serials}}) { + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $_); + $self->{serials}->{$_} = { %{$self->{serials}->{$_}}, %$result }; + } + + $self->{cache_name} = 'avocent_acs_8000_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' . + (defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')); +} + +1; + +__END__ + +=head1 MODE + +Check serial ports. + +=over 8 + +=item B<--filter-name> + +Filter by serial device name (can be a regexp). + +=item B<--unknown-status> + +Set unknown threshold for status. +Can used special variables like: %{status}, %{display} + +=item B<--warning-status> + +Set warning threshold for status. +Can used special variables like: %{status}, %{display} + +=item B<--critical-status> + +Set critical threshold for status. +Can used special variables like: %{status}, %{display} + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'traffic-in', 'traffic-out'. + +=back + +=cut diff --git a/hardware/kvm/avocent/acs/8000/snmp/plugin.pm b/hardware/kvm/avocent/acs/8000/snmp/plugin.pm index 114d91643..0cc231f14 100644 --- a/hardware/kvm/avocent/acs/8000/snmp/plugin.pm +++ b/hardware/kvm/avocent/acs/8000/snmp/plugin.pm @@ -35,6 +35,7 @@ sub new { 'hardware' => 'hardware::kvm::avocent::acs::8000::snmp::mode::hardware', 'load' => 'snmp_standard::mode::loadaverage', 'memory' => 'snmp_standard::mode::memory', + 'serial-ports' => 'hardware::kvm::avocent::acs::8000::snmp::mode::serialports' ); return $self; From 1d7b43ba5443d29fa6f6b52d866bbf45bc203c70 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 3 Apr 2020 16:09:02 +0200 Subject: [PATCH 082/283] fix azure logs --- cloud/azure/management/monitor/mode/logs.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloud/azure/management/monitor/mode/logs.pm b/cloud/azure/management/monitor/mode/logs.pm index 27dc87574..f238c4b81 100644 --- a/cloud/azure/management/monitor/mode/logs.pm +++ b/cloud/azure/management/monitor/mode/logs.pm @@ -86,7 +86,7 @@ sub manage_selection { $self->{global} = { total => 0 }; foreach my $table (@{$log_results->{tables}}) { foreach (@{$table->{rows}}) { - $self->{global}->{total} += $_->[2]; + $self->{global}->{total} += $_->[0]; } } } From 10de268f01f65619a643acd2b73c9f62902378c3 Mon Sep 17 00:00:00 2001 From: Sims24 Date: Sun, 5 Apr 2020 19:06:03 +0200 Subject: [PATCH 083/283] new(plugin) add sfdc minimal check --- apps/salesforce/restapi/custom/api.pm | 168 +++++++++++++++++++ apps/salesforce/restapi/mode/sfdcinstance.pm | 142 ++++++++++++++++ apps/salesforce/restapi/plugin.pm | 48 ++++++ 3 files changed, 358 insertions(+) create mode 100644 apps/salesforce/restapi/custom/api.pm create mode 100644 apps/salesforce/restapi/mode/sfdcinstance.pm create mode 100644 apps/salesforce/restapi/plugin.pm diff --git a/apps/salesforce/restapi/custom/api.pm b/apps/salesforce/restapi/custom/api.pm new file mode 100644 index 000000000..f70c32fc9 --- /dev/null +++ b/apps/salesforce/restapi/custom/api.pm @@ -0,0 +1,168 @@ +# +# Copyright 2020 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::salesforce::restapi::custom::api; + +use strict; +use warnings; +use centreon::plugins::http; +use JSON; + +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' }, + "timeout:s" => { name => 'timeout' }, + "api-versions:s" => { name => 'api_version' }, + }); + } + $options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1); + + $self->{output} = $options{output}; + $self->{mode} = $options{mode}; + $self->{http} = centreon::plugins::http->new(%options); + + return $self; +} + +sub set_options { + my ($self, %options) = @_; + + $self->{option_results} = $options{option_results}; +} + +sub set_defaults { + my ($self, %options) = @_; + + 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} = (defined($self->{option_results}->{hostname})) ? $self->{option_results}->{hostname} : 'api.status.salesforce.com'; + $self->{timeout} = (defined($self->{option_results}->{timeout})) ? $self->{option_results}->{timeout} : 10; + $self->{api_version} = (defined($self->{option_results}->{api_version})) ? $self->{option_results}->{api_version} : 'v1'; + + 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} = 443; + $self->{option_results}->{proto} = 'https'; +} + +sub settings { + my ($self, %options) = @_; + + $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}}); +} + +sub request_api { + my ($self, %options) = @_; + + $self->settings(); + + my $content = $self->{http}->request(method => 'GET', url_path => '/' . $self->{api_version} . $options{path}, + critical_status => '', warning_status => '', unknown_status => ''); + + my $decoded; + eval { + $decoded = decode_json($content); + }; + if ($@) { + $self->{output}->output_add(long_msg => $content, debug => 1); + $self->{output}->add_option_msg(short_msg => "Cannot decode json response"); + $self->{output}->option_exit(); + } + if ($self->{http}->get_code() != 200) { + $self->{output}->add_option_msg(short_msg => "Connection issue: " . $decoded->{msg}); + $self->{output}->option_exit(); + } + + return $decoded; +} + +1; + +__END__ + +=head1 NAME + +SFDC API boilerplate + +=head1 SYNOPSIS + +Get informations from SFDC API + +=head1 REST API OPTIONS + +=over 8 + +=item B<--hostname> + +Set hostname to query (default: 'api.status.salesforce.com') + +=item B<--timeout> + +Set HTTP timeout in seconds (Default: '10'). + +=item B<--api-path> + +API base url path (Default: '/v1'). + +=back + +=head1 DESCRIPTION + +B. + +=cut + diff --git a/apps/salesforce/restapi/mode/sfdcinstance.pm b/apps/salesforce/restapi/mode/sfdcinstance.pm new file mode 100644 index 000000000..ac941ada3 --- /dev/null +++ b/apps/salesforce/restapi/mode/sfdcinstance.pm @@ -0,0 +1,142 @@ +# +# Copyright 2020 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::salesforce::restapi::mode::sfdcinstance; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); + +sub custom_status_output { + my ($self, %options) = @_; + + return sprintf( + "Salesforce '%s' instance status is '%s' (active:'%s') ", + $self->{result_values}->{name}, + $self->{result_values}->{status}, + $self->{result_values}->{active} + ); +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'status', type => 1 }, + ]; + + $self->{maps_counters}->{status} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'status' }, { name => 'active' }, { name => 'name' } ], + closure_custom_calc => \&catalog_status_calc, + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold + } + }, + { label => 'incident', nlabel => 'salesforce.incident.current.count', set => { + key_values => [ { name => 'incident' } ], + output_template => '%s incidents currently', + perfdatas => [ + { label => 'incident', value => 'incident_absolute', template => '%s', + min => 0, label_extra_instance => 1 }, + ], + } + }, + ]; +} + +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 => { + 'instance:s@' => { name => 'instance' }, + 'alias' => { name => 'use_alias' }, + 'unknown-status:s' => { name => 'unknown_status', default => '' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '%{status} !~ /OK/' }, + }); + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->change_macros(macros => ['unknown_status', 'warning_status', 'critical_status']); + +} + +sub manage_selection { + my ($self, %options) = @_; + + my $instance_path = (defined($self->{option_results}->{use_alias})) ? '/instanceAliases/' : '/instances/'; + + foreach my $instance (@{$self->{option_results}->{instance}}) { + my $result = $options{custom}->request_api(path => $instance_path . $instance . '/status'); + + $self->{status}->{$instance} = { + active => $result->{isActive}, + incident => scalar(@{$result->{Incidents}}), + name => $instance, + status => $result->{status}, + }; + } + +} + +1; + +__END__ + +=head1 MODE + +Check instance status and incident count through Salesforce API + +=over 8 + +=item B<--instance> + +Set your instance identifier + +=item B<--alias> + +Add this option if your want to use your instance alias + +=item B<--unknown-status> + +Set unknown threshold for instance status (Default: ''). + +=item B<--warning-status> + +Set warning threshold for instance status (Default: ''). + +=item B<--critical-status> + +Set critical threshold for instance status (Default: '%{status} !~ /OK/'). + +=back + +=cut + diff --git a/apps/salesforce/restapi/plugin.pm b/apps/salesforce/restapi/plugin.pm new file mode 100644 index 000000000..3b2ae71cd --- /dev/null +++ b/apps/salesforce/restapi/plugin.pm @@ -0,0 +1,48 @@ +# +# Copyright 2020 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::salesforce::restapi::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} = '0.1'; + %{$self->{modes}} = ( + 'sfdc-instance' => 'apps::salesforce::restapi::mode::sfdcinstance', + ); + $self->{custom_modes}{api} = 'apps::salesforce::restapi::custom::api'; + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check SFDC service through its status API + +=cut From e1ed27b80c1584e2e3e9128ccf478cdd8c378cbd Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 6 Apr 2020 10:47:50 +0200 Subject: [PATCH 084/283] add name for pnic vmware --- apps/vmware/connector/mode/nethost.pm | 120 +++++++++++++------------- 1 file changed, 61 insertions(+), 59 deletions(-) diff --git a/apps/vmware/connector/mode/nethost.pm b/apps/vmware/connector/mode/nethost.pm index 94f6acb9b..05488e026 100644 --- a/apps/vmware/connector/mode/nethost.pm +++ b/apps/vmware/connector/mode/nethost.pm @@ -29,8 +29,7 @@ use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold) sub custom_status_output { my ($self, %options) = @_; - my $msg = 'status ' . $self->{result_values}->{status}; - return $msg; + return 'status ' . $self->{result_values}->{status}; } sub custom_status_calc { @@ -43,8 +42,7 @@ sub custom_status_calc { sub custom_linkstatus_output { my ($self, %options) = @_; - my $msg = 'status ' . $self->{result_values}->{link_status}; - return $msg; + return 'status ' . $self->{result_values}->{link_status}; } sub custom_linkstatus_calc { @@ -58,9 +56,10 @@ sub custom_traffic_output { my ($self, %options) = @_; my ($value, $unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{traffic}, network => 1); - my $msg = sprintf("traffic %s : %s/s (%.2f %%)", - $self->{result_values}->{label_ref}, $value . $unit, $self->{result_values}->{traffic_prct}); - return $msg; + return sprintf( + "traffic %s : %s/s (%.2f %%)", + $self->{result_values}->{label_ref}, $value . $unit, $self->{result_values}->{traffic_prct} + ); } sub custom_traffic_calc { @@ -78,11 +77,12 @@ sub custom_traffic_calc { sub custom_dropped_output { my ($self, %options) = @_; - my $msg = sprintf("packets %s dropped : %.2f %% (%d/%d packets)", - $self->{result_values}->{label_ref}, - $self->{result_values}->{dropped_prct}, - $self->{result_values}->{dropped}, $self->{result_values}->{packets}); - return $msg; + return sprintf( + 'packets %s dropped : %.2f %% (%d/%d packets)', + $self->{result_values}->{label_ref}, + $self->{result_values}->{dropped_prct}, + $self->{result_values}->{dropped}, $self->{result_values}->{packets} + ); } sub custom_dropped_calc { @@ -109,22 +109,22 @@ sub set_counters { { name => 'global', type => 0, skipped_code => { -10 => 1 } }, { name => 'global_host', type => 0, skipped_code => { -10 => 1 } }, { name => 'pnic', cb_prefix_output => 'prefix_pnic_output', message_multiple => 'All physical interfaces are ok', type => 1, skipped_code => { -10 => 1 } }, - { name => 'vswitch', cb_prefix_output => 'prefix_vswitch_output', message_multiple => 'All vswitchs are ok', type => 1, skipped_code => { -10 => 1 } }, + { name => 'vswitch', cb_prefix_output => 'prefix_vswitch_output', message_multiple => 'All vswitchs are ok', type => 1, skipped_code => { -10 => 1 } } ] } ]; - + $self->{maps_counters}->{global} = [ { label => 'status', threshold => 0, set => { key_values => [ { name => 'state' } ], closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => \&catalog_status_threshold, + closure_custom_threshold_check => \&catalog_status_threshold } - }, + } ]; - + $self->{maps_counters}->{global_host} = [ { label => 'host-traffic-in', nlabel => 'host.traffic.in.bitsperseconds', set => { key_values => [ { name => 'traffic_in' } ], @@ -132,8 +132,8 @@ sub set_counters { output_change_bytes => 2, perfdatas => [ { label => 'host_traffic_in', value => 'traffic_in_absolute', template => '%s', - unit => 'b/s', min => 0, label_extra_instance => 1 }, - ], + unit => 'b/s', min => 0, label_extra_instance => 1 } + ] } }, { label => 'host-traffic-out', nlabel => 'host.traffic.out.bitsperseconds', set => { @@ -142,12 +142,12 @@ sub set_counters { output_change_bytes => 2, perfdatas => [ { label => 'host_traffic_out', value => 'traffic_out_absolute', template => '%s', - unit => 'b/s', min => 0, label_extra_instance => 1 }, - ], + unit => 'b/s', min => 0, label_extra_instance => 1 } + ] } - }, + } ]; - + $self->{maps_counters}->{vswitch} = [ { label => 'vswitch-traffic-in', nlabel => 'host.vswitch.traffic.in.bitsperseconds', set => { key_values => [ { name => 'traffic_in' } ], @@ -165,19 +165,19 @@ sub set_counters { output_change_bytes => 2, perfdatas => [ { label => 'vswitch_traffic_out', value => 'traffic_out_absolute', template => '%s', - unit => 'b/s', min => 0, label_extra_instance => 1 }, - ], + unit => 'b/s', min => 0, label_extra_instance => 1 } + ] } - }, + } ]; - + $self->{maps_counters}->{pnic} = [ { label => 'link-status', threshold => 0, set => { - key_values => [ { name => 'status' } ], + key_values => [ { name => 'status' }, { name => 'display' } ], closure_custom_calc => $self->can('custom_linkstatus_calc'), closure_custom_output => $self->can('custom_linkstatus_output'), closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => \&catalog_status_threshold, + closure_custom_threshold_check => \&catalog_status_threshold } }, { label => 'link-traffic-in', nlabel => 'host.traffic.in.bitsperseconds', set => { @@ -187,8 +187,8 @@ sub set_counters { threshold_use => 'traffic_prct', perfdatas => [ { label => 'traffic_in', value => 'traffic', template => '%s', unit => 'b/s', - min => 0, max => 'speed', threshold_total => 'speed', cast_int => 1, label_extra_instance => 1 }, - ], + min => 0, max => 'speed', threshold_total => 'speed', cast_int => 1, label_extra_instance => 1 } + ] } }, { label => 'link-traffic-out', nlabel => 'host.traffic.out.bitsperseconds', set => { @@ -198,8 +198,8 @@ sub set_counters { threshold_use => 'traffic_prct', perfdatas => [ { label => 'traffic_out', value => 'traffic', template => '%s', unit => 'b/s', - min => 0, max => 'speed', threshold_total => 'speed', cast_int => 1, label_extra_instance => 1 }, - ], + min => 0, max => 'speed', threshold_total => 'speed', cast_int => 1, label_extra_instance => 1 } + ] } }, { label => 'link-dropped-in', nlabel => 'host.packets.in.dropped.percentage', set => { @@ -209,8 +209,8 @@ sub set_counters { threshold_use => 'dropped_prct', perfdatas => [ { label => 'packets_dropped_in', value => 'dropped_prct', template => '%s', unit => '%', - min => 0, max => 100, label_extra_instance => 1 }, - ], + min => 0, max => 100, label_extra_instance => 1 } + ] } }, { label => 'link-dropped-out', nlabel => 'host.packets.out.dropped.percentage', set => { @@ -220,10 +220,10 @@ sub set_counters { threshold_use => 'dropped_prct', perfdatas => [ { label => 'packets_dropped_out', value => 'dropped_prct', template => '%s', unit => '%', - min => 0, max => 100, label_extra_instance => 1 }, - ], + min => 0, max => 100, label_extra_instance => 1 } + ] } - }, + } ]; } @@ -257,20 +257,20 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - "esx-hostname:s" => { name => 'esx_hostname' }, - "nic-name:s" => { name => 'nic_name' }, - "filter" => { name => 'filter' }, - "scope-datacenter:s" => { name => 'scope_datacenter' }, - "scope-cluster:s" => { name => 'scope_cluster' }, - "no-proxyswitch" => { name => 'no_proxyswitch' }, - "unknown-status:s" => { name => 'unknown_status', default => '%{status} !~ /^connected$/i' }, - "warning-status:s" => { name => 'warning_status', default => '' }, - "critical-status:s" => { name => 'critical_status', default => '' }, - "unknown-link-status:s" => { name => 'unknown_link_status', default => '' }, - "warning-link-status:s" => { name => 'warning_link_status', default => '' }, - "critical-link-status:s" => { name => 'critical_link_status', default => '%{link_status} !~ /up/' }, + 'esx-hostname:s' => { name => 'esx_hostname' }, + 'nic-name:s' => { name => 'nic_name' }, + 'filter' => { name => 'filter' }, + 'scope-datacenter:s' => { name => 'scope_datacenter' }, + 'scope-cluster:s' => { name => 'scope_cluster' }, + 'no-proxyswitch' => { name => 'no_proxyswitch' }, + 'unknown-status:s' => { name => 'unknown_status', default => '%{status} !~ /^connected$/i' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '' }, + 'unknown-link-status:s' => { name => 'unknown_link_status', default => '' }, + 'warning-link-status:s' => { name => 'warning_link_status', default => '' }, + 'critical-link-status:s' => { name => 'critical_link_status', default => '%{link_status} !~ /up/' } }); - + return $self; } @@ -278,8 +278,10 @@ sub check_options { my ($self, %options) = @_; $self->SUPER::check_options(%options); - $self->change_macros(macros => ['unknown_status', 'warning_status', 'critical_status', - 'unknown_link_status', 'warning_link_status', 'critical_link_status']); + $self->change_macros(macros => [ + 'unknown_status', 'warning_status', 'critical_status', + 'unknown_link_status', 'warning_link_status', 'critical_link_status' + ]); } sub manage_selection { @@ -308,7 +310,7 @@ sub manage_selection { $pnic_name !~ /$self->{option_results}->{nic_name}/); $self->{host}->{$host_name}->{pnic}->{$pnic_name} = { - display => $pnic_name, + display => $pnic_name, status => $response->{data}->{$host_id}->{pnic}->{$pnic_name}->{status} , traffic_in => $response->{data}->{$host_id}->{pnic}->{$pnic_name}->{'net.received.average'}, traffic_out => $response->{data}->{$host_id}->{pnic}->{$pnic_name}->{'net.transmitted.average'}, @@ -392,18 +394,18 @@ Can used special variables like: %{status} =item B<--unknown-link-status> -Set warning threshold for status (Default: ''). -Can used special variables like: %{link_status} +Set warning threshold for status. +Can used special variables like: %{link_status}, %{display} =item B<--warning-link-status> -Set warning threshold for status (Default: ''). -Can used special variables like: %{link_status} +Set warning threshold for status. +Can used special variables like: %{link_status}, %{display} =item B<--critical-link-status> Set critical threshold for status (Default: '%{link_status} !~ /up/'). -Can used special variables like: %{link_status} +Can used special variables like: %{link_status}, %{display} =item B<--warning-*> From 4e9208b616b9a8ed42c987958839262620212740 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 6 Apr 2020 11:12:09 +0200 Subject: [PATCH 085/283] fix compat datastore uusage --- apps/vmware/connector/mode/datastoreusage.pm | 26 +++++++++++--------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/apps/vmware/connector/mode/datastoreusage.pm b/apps/vmware/connector/mode/datastoreusage.pm index ab9950896..a5edae08b 100644 --- a/apps/vmware/connector/mode/datastoreusage.pm +++ b/apps/vmware/connector/mode/datastoreusage.pm @@ -137,7 +137,7 @@ sub set_counters { min => 0, max => 'total_space', label_extra_instance => 1 }, ], } - }, + } ]; } @@ -153,14 +153,14 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - 'datastore-name:s' => { name => 'datastore_name' }, - 'filter' => { name => 'filter' }, - 'scope-datacenter:s' => { name => 'scope_datacenter' }, - 'units:s' => { name => 'units', default => '%' }, - 'free' => { name => 'free' }, - 'unknown-status:s' => { name => 'unknown_status', default => '%{accessible} !~ /^true|1$/i' }, - 'warning-status:s' => { name => 'warning_status', default => '' }, - 'critical-status:s' => { name => 'critical_status', default => '' }, + 'datastore-name:s' => { name => 'datastore_name' }, + 'filter' => { name => 'filter' }, + 'scope-datacenter:s' => { name => 'scope_datacenter' }, + 'units:s' => { name => 'units', default => '%' }, + 'free' => { name => 'free' }, + 'unknown-status:s' => { name => 'unknown_status', default => '%{accessible} !~ /^true|1$/i' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '' } }); return $self; @@ -172,8 +172,12 @@ sub check_options { # Compatibility $self->compat_threshold_counter(%options, compat => { - th => [ ['usage', { free => 'usage-free', prct => 'usage-prct'} ], [ 'datastore.space.usage.bytes', { free => 'datastore.space.free.bytes', prct => 'datastore.space.usage.percentage' } ] ], - units => $options{option_results}->{units}, free => $options{option_results}->{free} + th => [ + [ 'usage', { free => 'usage-free', prct => 'usage-prct'} ], + [ 'instance-datastore-space-usage-bytes', { free => 'instance-datastore-space-free-bytes', prct => 'instance-datastore-space-usage-percentage' } ] + ], + units => $options{option_results}->{units}, + free => $options{option_results}->{free} } ); From 150107c93ec4872801a9b2b231eb48dabe28f680 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 6 Apr 2020 11:38:01 +0200 Subject: [PATCH 086/283] fix nethost vmware --- apps/vmware/connector/mode/nethost.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/vmware/connector/mode/nethost.pm b/apps/vmware/connector/mode/nethost.pm index 05488e026..61ac63ff1 100644 --- a/apps/vmware/connector/mode/nethost.pm +++ b/apps/vmware/connector/mode/nethost.pm @@ -48,6 +48,7 @@ sub custom_linkstatus_output { sub custom_linkstatus_calc { my ($self, %options) = @_; + $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; $self->{result_values}->{link_status} = $options{new_datas}->{$self->{instance} . '_status'}; return 0; } From a6f2068b8d451cc0693a2eb4ee7eee1cabdc36b4 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 6 Apr 2020 12:07:15 +0200 Subject: [PATCH 087/283] add filter name for pdu eaton --- hardware/pdu/eaton/snmp/mode/group.pm | 34 +++++++++++++++++--------- hardware/pdu/eaton/snmp/mode/outlet.pm | 18 +++++++++++--- 2 files changed, 38 insertions(+), 14 deletions(-) diff --git a/hardware/pdu/eaton/snmp/mode/group.pm b/hardware/pdu/eaton/snmp/mode/group.pm index 71d01ce01..2a11324eb 100644 --- a/hardware/pdu/eaton/snmp/mode/group.pm +++ b/hardware/pdu/eaton/snmp/mode/group.pm @@ -27,9 +27,9 @@ use warnings; sub set_counters { my ($self, %options) = @_; - + $self->{maps_counters_type} = [ - { name => 'group', type => 1, cb_prefix_output => 'prefix_group_output', message_multiple => 'All groups are ok', skipped_code => { -10 => 1 } }, + { name => 'group', type => 1, cb_prefix_output => 'prefix_group_output', message_multiple => 'All groups are ok', skipped_code => { -10 => 1 } } ]; $self->{maps_counters}->{group} = [ @@ -38,8 +38,8 @@ sub set_counters { output_template => 'Current : %.2f A', perfdatas => [ { value => 'groupCurrent_absolute', template => '%.2f', - min => 0, unit => 'A', label_extra_instance => 1, instance_use => 'display_absolute' }, - ], + min => 0, unit => 'A', label_extra_instance => 1, instance_use => 'display_absolute' } + ] } }, { label => 'voltage', nlabel => 'group.voltage.volt', set => { @@ -47,8 +47,8 @@ sub set_counters { output_template => 'Voltage : %.2f V', perfdatas => [ { value => 'groupVoltage_absolute', template => '%.2f', - unit => 'V', label_extra_instance => 1, instance_use => 'display_absolute' }, - ], + unit => 'V', label_extra_instance => 1, instance_use => 'display_absolute' } + ] } }, { label => 'power', nlabel => 'group.power.watt', set => { @@ -56,10 +56,10 @@ sub set_counters { output_template => 'Power : %.2f W', perfdatas => [ { value => 'groupWatts_absolute', template => '%.2f', - unit => 'W', label_extra_instance => 1, instance_use => 'display_absolute' }, - ], + unit => 'W', label_extra_instance => 1, instance_use => 'display_absolute' } + ] } - }, + } ]; } @@ -69,6 +69,7 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' } }); return $self; @@ -90,7 +91,6 @@ my $mapping = { sub manage_selection { my ($self, %options) = @_; - $self->{group} = {}; my $snmp_result = $options{snmp}->get_multiple_table( oids => [ { oid => $mapping->{groupName}->{oid} }, @@ -101,11 +101,12 @@ sub manage_selection { return_type => 1, nothing_quit => 1 ); + $self->{group} = {}; foreach my $oid (keys %{$snmp_result}) { $oid =~ /\.(\d+)\.(\d+)$/; my ($strapping_index, $group_index) = ($1, $2); next if (defined($self->{group}->{$strapping_index . '.' . $group_index})); - + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $strapping_index . '.' . $group_index); $result->{groupVoltage} *= 0.001 if (defined($result->{groupVoltage})); $result->{groupCurrent} *= 0.001 if (defined($result->{groupCurrent})); @@ -113,6 +114,13 @@ sub manage_selection { if (defined($result->{groupName}) && $result->{groupName} ne '') { $display = $result->{groupName} . ' strapping ' . $strapping_index; } + + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $display !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping '" . $display . "': no matching filter.", debug => 1); + next; + } + $self->{group}->{$strapping_index . '.' . $group_index} = { display => $display, %$result }; } @@ -132,6 +140,10 @@ Check group metrics (voltage, current and power). =over 8 +=item B<--filter-name> + +Filter group name (can be a regexp). + =item B<--warning-*> Threshold warning. diff --git a/hardware/pdu/eaton/snmp/mode/outlet.pm b/hardware/pdu/eaton/snmp/mode/outlet.pm index 4604bf97c..0583c293e 100644 --- a/hardware/pdu/eaton/snmp/mode/outlet.pm +++ b/hardware/pdu/eaton/snmp/mode/outlet.pm @@ -69,6 +69,7 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' } }); return $self; @@ -90,7 +91,6 @@ my $mapping = { sub manage_selection { my ($self, %options) = @_; - $self->{outlet} = {}; my $snmp_result = $options{snmp}->get_multiple_table( oids => [ { oid => $mapping->{outletName}->{oid} }, @@ -101,12 +101,13 @@ sub manage_selection { return_type => 1, nothing_quit => 1 ); + $self->{outlet} = {}; foreach my $oid (keys %{$snmp_result}) { $oid =~ /\.(\d+)\.(\d+)$/; my ($strapping_index, $outlet_index) = ($1, $2); - + next if (defined($self->{outlet}->{$strapping_index . '.' . $outlet_index})); - + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $strapping_index . '.' . $outlet_index); $result->{outletVoltage} *= 0.001 if (defined($result->{outletVoltage})); $result->{outletCurrent} *= 0.001 if (defined($result->{outletCurrent})); @@ -114,6 +115,13 @@ sub manage_selection { if (defined($result->{outletName}) && $result->{outletName} ne '') { $display = $result->{outletName} . ' strapping ' . $strapping_index; } + + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $display !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping '" . $display . "': no matching filter.", debug => 1); + next; + } + $self->{outlet}->{$strapping_index . '.' . $outlet_index} = { display => $display, %$result }; } @@ -133,6 +141,10 @@ Check outlet metrics (voltage, current and power). =over 8 +=item B<--filter-name> + +Filter outlet name (can be a regexp). + =item B<--warning-*> Threshold warning. From faa634b6e8f6b00f322eae841eb073af8cfde0d0 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 6 Apr 2020 13:54:44 +0200 Subject: [PATCH 088/283] enhance cluster status vmware --- apps/vmware/connector/mode/statuscluster.pm | 38 +++++++++++-------- .../vmware/connector/mode/vsanclusterusage.pm | 21 ++++------ 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/apps/vmware/connector/mode/statuscluster.pm b/apps/vmware/connector/mode/statuscluster.pm index 07e8f0189..c195c0214 100644 --- a/apps/vmware/connector/mode/statuscluster.pm +++ b/apps/vmware/connector/mode/statuscluster.pm @@ -30,9 +30,9 @@ sub custom_status_output { my ($self, %options) = @_; my $msg = 'status is ' . $self->{result_values}->{overall_status}; - if ($self->{result_values}->{vsan_status} ne '') { - $msg .= ' [vsan status: ' . $self->{result_values}->{vsan_status} . ']'; - } + $msg .= ' [vsan status: ' . $self->{result_values}->{vsan_status} . ']' if ($self->{result_values}->{vsan_status} ne ''); + $msg .= ' [ha enabled: ' . $self->{result_values}->{ha_enabled} . ']' if ($self->{result_values}->{ha_enabled} ne ''); + $msg .= ' [drs enabled: ' . $self->{result_values}->{drs_enabled} . ']' if ($self->{result_values}->{drs_enabled} ne ''); return $msg; } @@ -40,18 +40,24 @@ sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ - { name => 'cluster', type => 1, cb_prefix_output => 'prefix_cluster_output', message_multiple => 'All clusters are ok' }, + { name => 'cluster', type => 1, cb_prefix_output => 'prefix_cluster_output', message_multiple => 'All clusters are ok' } ]; $self->{maps_counters}->{cluster} = [ { label => 'status', threshold => 0, set => { - key_values => [ { name => 'overall_status' }, { name => 'vsan_status' }, { name => 'display' } ], + key_values => [ + { name => 'overall_status' }, + { name => 'vsan_status' }, + { name => 'ha_enabled' }, + { name => 'drs_enabled' }, + { name => 'display' } + ], closure_custom_calc => \&catalog_status_calc, closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => \&catalog_status_threshold, + closure_custom_threshold_check => \&catalog_status_threshold } - }, + } ]; } @@ -65,41 +71,43 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - + $options{options}->add_options(arguments => { 'cluster-name:s' => { name => 'cluster_name' }, 'filter' => { name => 'filter' }, 'scope-datacenter:s' => { name => 'scope_datacenter' }, 'unknown-status:s' => { name => 'unknown_status', default => '%{overall_status} =~ /gray/i || %{vsan_status} =~ /gray/i' }, 'warning-status:s' => { name => 'warning_status', default => '%{overall_status} =~ /yellow/i || %{vsan_status} =~ /yellow/i' }, - 'critical-status:s' => { name => 'critical_status', default => '%{overall_status} =~ /red/i || %{vsan_status} =~ /red/i' }, + 'critical-status:s' => { name => 'critical_status', default => '%{overall_status} =~ /red/i || %{vsan_status} =~ /red/i' } }); - + return $self; } sub check_options { my ($self, %options) = @_; $self->SUPER::check_options(%options); - + $self->change_macros(macros => ['unknown_status', 'warning_status', 'critical_status']); } sub manage_selection { my ($self, %options) = @_; - $self->{cluster} = {}; my $response = $options{custom}->execute( params => $self->{option_results}, command => 'statuscluster' ); + $self->{cluster} = {}; foreach my $cluster_id (keys %{$response->{data}}) { my $cluster_name = $response->{data}->{$cluster_id}->{name}; $self->{cluster}->{$cluster_name} = { display => $cluster_name, overall_status => $response->{data}->{$cluster_id}->{overall_status}, vsan_status => defined($response->{data}->{$cluster_id}->{vsan_cluster_status}) ? $response->{data}->{$cluster_id}->{vsan_cluster_status} : '', + ha_enabled => defined($response->{data}->{$cluster_id}->{ha_enabled}) ? $response->{data}->{$cluster_id}->{ha_enabled} : '', + drs_enabled => defined($response->{data}->{$cluster_id}->{drs_enabled}) ? $response->{data}->{$cluster_id}->{drs_enabled} : '' }; } } @@ -130,17 +138,17 @@ Search in following datacenter(s) (can be a regexp). =item B<--unknown-status> Set warning threshold for status (Default: '%{overall_status} =~ /gray/i || %{vsan_status} =~ /gray/i'). -Can used special variables like: %{overall_status}, %{vsan_status} +Can used special variables like: %{overall_status}, %{vsan_status}, %{drs_enabled}, %{ha_enabled} =item B<--warning-status> Set warning threshold for status (Default: '%{overall_status} =~ /yellow/i || %{vsan_status} =~ /yellow/i'). -Can used special variables like: %{overall_status}, %{vsan_status} +Can used special variables like: %{overall_status}, %{vsan_status}, %{drs_enabled}, %{ha_enabled} =item B<--critical-status> Set critical threshold for status (Default: '%{overall_status} =~ /red/i || %{vsan_status} =~ /red/i'). -Can used special variables like: %{overall_status}, %{vsan_status} +Can used special variables like: %{overall_status}, %{vsan_status}, %{drs_enabled}, %{ha_enabled} =back diff --git a/apps/vmware/connector/mode/vsanclusterusage.pm b/apps/vmware/connector/mode/vsanclusterusage.pm index b7e2e6a89..a2459810a 100644 --- a/apps/vmware/connector/mode/vsanclusterusage.pm +++ b/apps/vmware/connector/mode/vsanclusterusage.pm @@ -112,21 +112,14 @@ 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 => { - 'cluster-name:s' => { name => 'cluster_name' }, - 'filter' => { name => 'filter' }, - 'scope-datacenter:s' => { name => 'scope_datacenter' }, - }); - - return $self; -} -sub check_options { - my ($self, %options) = @_; - $self->SUPER::check_options(%options); - - $self->change_macros(macros => ['unknown_status', 'warning_status', 'critical_status']); + $options{options}->add_options(arguments => { + 'cluster-name:s' => { name => 'cluster_name' }, + 'filter' => { name => 'filter' }, + 'scope-datacenter:s' => { name => 'scope_datacenter' } + }); + + return $self; } sub manage_selection { From 46e977c081d6951a0609270c13d88808e319aad1 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 8 Apr 2020 17:11:02 +0200 Subject: [PATCH 089/283] enhance indent --- apps/vmware/connector/mode/cpuhost.pm | 2 +- cloud/ovh/restapi/custom/api.pm | 42 +++++++++++++-------------- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/apps/vmware/connector/mode/cpuhost.pm b/apps/vmware/connector/mode/cpuhost.pm index 9d59e9299..adcc66c51 100644 --- a/apps/vmware/connector/mode/cpuhost.pm +++ b/apps/vmware/connector/mode/cpuhost.pm @@ -63,7 +63,7 @@ sub set_counters { } }, ]; - + $self->{maps_counters}->{global_cpu} = [ { label => 'total-cpu', nlabel => 'host.cpu.utilization.percentage', set => { key_values => [ { name => 'cpu_average' } ], diff --git a/cloud/ovh/restapi/custom/api.pm b/cloud/ovh/restapi/custom/api.pm index a21f5e04b..0a79255c7 100644 --- a/cloud/ovh/restapi/custom/api.pm +++ b/cloud/ovh/restapi/custom/api.pm @@ -28,7 +28,7 @@ use Digest::SHA 'sha1_hex'; my %map_ovh_type = ( OVH_API_EU => 'https://eu.api.ovh.com/1.0', - OVH_API_CA => 'https://ca.api.ovh.com/1.0', + OVH_API_CA => 'https://ca.api.ovh.com/1.0' ); sub new { @@ -44,14 +44,14 @@ sub new { $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 => { - "ovh-type:s@" => { name => 'ovh_type' }, - "ovh-application-key:s@" => { name => 'ovh_application_key' }, - "ovh-application-secret:s@" => { name => 'ovh_application_secret' }, - "ovh-consumer-key:s@" => { name => 'ovh_consumer_key' }, - "timeout:s@" => { name => 'timeout' }, + 'ovh-type:s@' => { name => 'ovh_type' }, + 'ovh-application-key:s@' => { name => 'ovh_application_key' }, + 'ovh-application-secret:s@' => { name => 'ovh_application_secret' }, + 'ovh-consumer-key:s@' => { name => 'ovh_consumer_key' }, + 'timeout:s@' => { name => 'timeout' } }); } $options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1); @@ -61,23 +61,17 @@ sub new { $self->{http} = centreon::plugins::http->new(%options); 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++) { @@ -117,19 +111,19 @@ sub check_options { scalar(@{$self->{option_results}->{ovh_application_key}}) == 0) { return 0; } - + return 1; } sub build_options_for_httplib { my ($self, %options) = @_; - + $self->{option_results}->{timeout} = $self->{timeout}; } sub settings { my ($self, %options) = @_; - + $self->build_options_for_httplib(); $self->{http}->add_header(key => 'X-Ovh-Application', value => $self->{ovh_application_key}); if (!defined($options{no_signature}) || $options{no_signature} == 0) { @@ -149,7 +143,7 @@ sub settings { $self->{http}->add_header(key => 'Content-type', value => 'application/json'); $self->{option_results}->{query_form_post} = $content; } - + $self->{http}->add_header(key => 'X-Ovh-Consumer', value => $self->{ovh_consumer_key}); $self->{http}->add_header(key => 'X-Ovh-Timestamp', value => $now); $self->{http}->add_header(key => 'X-Ovh-Signature', value => '$1$' . sha1_hex(join('+', ( @@ -172,7 +166,7 @@ sub time_delta { my $response = $self->get(path => '/auth/time', no_signature => 1, no_decode => 1); $self->{time_delta} = $response - time(); } - + return $self->{time_delta}; } @@ -181,14 +175,18 @@ sub get { $self->settings(%options); - my $response = $self->{http}->request(full_url => $map_ovh_type{uc($self->{ovh_type})} . $options{path}, - hostname => '', critical_status => '', warning_status => ''); + my $response = $self->{http}->request( + full_url => $map_ovh_type{uc($self->{ovh_type})} . $options{path}, + hostname => '', + critical_status => '', + warning_status => '' + ); my ($client_warning) = $self->{http}->get_header(name => 'Client-Warning'); if (defined($client_warning) && $client_warning eq 'Internal response') { $self->{output}->add_option_msg(short_msg => "Internal LWP::UserAgent error: $response"); $self->{output}->option_exit(); } - + if (defined($options{no_decode}) && $options{no_decode} == 1) { return $response; } @@ -201,7 +199,7 @@ sub get { $self->{output}->add_option_msg(short_msg => "Cannot decode json response: $@"); $self->{output}->option_exit(); } - + return $content; } From bd12accb4a20c6ff26b086ac5df294b9eb943310 Mon Sep 17 00:00:00 2001 From: UrBnW <40244829+UrBnW@users.noreply.github.com> Date: Wed, 8 Apr 2020 19:02:30 +0200 Subject: [PATCH 090/283] network::ibm::bladecenter new plugin --- .../snmp/mode/components/faultled.pm | 66 ++++++++++ .../snmp/mode/components/temperature.pm | 86 ++++++++++++ network/ibm/bladecenter/snmp/mode/cpu.pm | 87 +++++++++++++ network/ibm/bladecenter/snmp/mode/disk.pm | 104 +++++++++++++++ .../ibm/bladecenter/snmp/mode/environment.pm | 84 ++++++++++++ network/ibm/bladecenter/snmp/mode/memory.pm | 123 ++++++++++++++++++ network/ibm/bladecenter/snmp/plugin.pm | 55 ++++++++ 7 files changed, 605 insertions(+) create mode 100644 network/ibm/bladecenter/snmp/mode/components/faultled.pm create mode 100644 network/ibm/bladecenter/snmp/mode/components/temperature.pm create mode 100644 network/ibm/bladecenter/snmp/mode/cpu.pm create mode 100644 network/ibm/bladecenter/snmp/mode/disk.pm create mode 100644 network/ibm/bladecenter/snmp/mode/environment.pm create mode 100644 network/ibm/bladecenter/snmp/mode/memory.pm create mode 100644 network/ibm/bladecenter/snmp/plugin.pm diff --git a/network/ibm/bladecenter/snmp/mode/components/faultled.pm b/network/ibm/bladecenter/snmp/mode/components/faultled.pm new file mode 100644 index 000000000..7fc415513 --- /dev/null +++ b/network/ibm/bladecenter/snmp/mode/components/faultled.pm @@ -0,0 +1,66 @@ +# +# Copyright 2020 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 network::ibm::bladecenter::snmp::mode::components::faultled; + +use strict; +use warnings; + +my %map_faultled_states = ( 1 => 'on', 2 => 'off' ); + +sub load {} + +sub check_faultled { + my ($self, %options) = @_; + + $self->{components}->{faultled}->{total}++; + + $self->{output}->output_add(long_msg => + sprintf( + "Fault LED state is %s", + $options{value} + ) + ); + my $exit = $self->get_severity(section => 'faultled', value => $options{value}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "Fault LED state is %s", + $options{value} + ) + ); + } +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking fault LED"); + $self->{components}->{faultled} = { name => 'faultled', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'faultled')); + + my $oid_mmspFaultLED = '.1.3.6.1.4.1.26543.2.5.1.3.10.12.0'; + my $results = $self->{snmp}->get_leef(oids => [$oid_mmspFaultLED], nothing_quit => 1); + + check_faultled($self, value => $map_faultled_states{$results->{$oid_mmspFaultLED}}); +} + +1; diff --git a/network/ibm/bladecenter/snmp/mode/components/temperature.pm b/network/ibm/bladecenter/snmp/mode/components/temperature.pm new file mode 100644 index 000000000..036fc21be --- /dev/null +++ b/network/ibm/bladecenter/snmp/mode/components/temperature.pm @@ -0,0 +1,86 @@ +# +# Copyright 2020 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 network::ibm::bladecenter::snmp::mode::components::temperature; + +use strict; +use warnings; + +sub load {} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking temperatures"); + $self->{components}->{temperature} = { name => 'temperatures', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'temperature')); + + my $oid_hwTemperatureWarn = '.1.3.6.1.4.1.26543.2.5.1.3.1.22.0'; + my $oid_hwTemperatureShut = '.1.3.6.1.4.1.26543.2.5.1.3.1.23.0'; + my $results = $self->{snmp}->get_leef(oids => [$oid_hwTemperatureWarn, $oid_hwTemperatureShut], nothing_quit => 1); + + # .1.3.6.1.4.1.20301.2.5.1.3.1.41.1.1.20.1 = STRING: "44 C (Warn at 66 C / Recover at 61 C)" + # .1.3.6.1.4.1.20301.2.5.1.3.1.41.1.1.21.1 = STRING: "44 C (Shutdown at 72 C / Recover at 67 C)" + $results->{$oid_hwTemperatureWarn} =~ /^([.0-9]+)\s*C\s*\(Warn(?:ing)?\s*at\s*([.0-9]+)\s*C/i; + my $temperature = $1; + my $warning = $2; + $results->{$oid_hwTemperatureShut} =~ /^([.0-9]+)\s*C\s*\(Shutdown\s*at\s*([.0-9]+)\s*C/i; + if ($1 > $temperature) { + $temperature = $1; + } + my $critical = ($warning + $2) / 2; + + $self->{components}->{temperature}->{total}++; + + $self->{output}->output_add(long_msg => + sprintf( + "Temperature is %.1f C", + $temperature + ) + ); + + my $exit = 'OK'; + if ($temperature >= $warning) { + $exit = 'WARNING'; + } + if ($temperature >= $critical) { + $exit = 'CRITICAL'; + } + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "Temperature is %.1f C", + $temperature + ) + ); + } + + $self->{output}->perfdata_add( + label => 'temperature', unit => 'C', + nlabel => 'hardware.temperature.celsius', + instances => 'system', + value => $temperature, + warning => $warning, + critical => $critical + ); +} + +1; diff --git a/network/ibm/bladecenter/snmp/mode/cpu.pm b/network/ibm/bladecenter/snmp/mode/cpu.pm new file mode 100644 index 000000000..ef7893af7 --- /dev/null +++ b/network/ibm/bladecenter/snmp/mode/cpu.pm @@ -0,0 +1,87 @@ +# +# Copyright 2020 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 network::ibm::bladecenter::snmp::mode::cpu; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'cpu', type => 0, skipped_code => { -10 => 1 } }, + ]; + + $self->{maps_counters}->{cpu} = [ + { label => 'average', nlabel => 'cpu.utilization.percentage', set => { + key_values => [ { name => 'average' } ], + output_template => '%.2f %%', + perfdatas => [ + { label => 'total_cpu_avg', value => 'average_absolute', template => '%.2f', + min => 0, max => 100, unit => '%' }, + ], + } + }, + ]; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + my $oid_mpCpuStatsUtil1Minute = '.1.3.6.1.4.1.26543.2.5.1.2.2.3.0'; + my $result = $options{snmp}->get_leef(oids => [$oid_mpCpuStatsUtil1Minute], nothing_quit => 1); + + $self->{cpu} = { + average => $result->{$oid_mpCpuStatsUtil1Minute}, + } +} + +1; + +__END__ + +=head1 MODE + +Check CPU usage (over the last minute). + +=over 8 + +=item B<--warning-average> + +Warning threshold average CPU utilization. + +=item B<--critical-average> + +Critical threshold average CPU utilization. + +=back + +=cut diff --git a/network/ibm/bladecenter/snmp/mode/disk.pm b/network/ibm/bladecenter/snmp/mode/disk.pm new file mode 100644 index 000000000..b8466a931 --- /dev/null +++ b/network/ibm/bladecenter/snmp/mode/disk.pm @@ -0,0 +1,104 @@ +# +# Copyright 2020 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 network::ibm::bladecenter::snmp::mode::disk; + +use base qw(snmp_standard::mode::storage); + +use strict; +use warnings; + +sub default_storage_type { + my ($self, %options) = @_; + + return '^(?!(hrStorageRam)$)'; +} + +sub prefix_storage_output { + my ($self, %options) = @_; + + return "Disk '" . $options{instance_value}->{display} . "' "; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + return $self; +} + +1; + +__END__ + +=head1 MODE + +Check disk. + +=over 8 + +=item B<--warning-usage> + +Threshold warning. + +=item B<--critical-usage> + +Threshold critical. + +=item B<--units> + +Units of thresholds (Default: '%') ('%', 'B'). + +=item B<--free> + +Thresholds are on free space left. + +=item B<--storage> + +Set the storage (number expected) ex: 1, 2,... (empty means 'check all storage'). + +=item B<--name> + +Allows to use storage name with option --storage instead of storage oid index. + +=item B<--regexp> + +Allows to use regexp to filter storage (with option --name). + +=item B<--regexp-isensitive> + +Allows to use regexp non case-sensitive (with --regexp). + +=item B<--reload-cache-time> + +Time in minutes before reloading cache file (default: 180). + +=item B<--show-cache> + +Display cache storage datas. + +=item B<--filter-storage-type> + +Filter storage types with a regexp (Default: '^(?!(hrStorageRam)$)'). + +=back + +=cut diff --git a/network/ibm/bladecenter/snmp/mode/environment.pm b/network/ibm/bladecenter/snmp/mode/environment.pm new file mode 100644 index 000000000..935e17f2d --- /dev/null +++ b/network/ibm/bladecenter/snmp/mode/environment.pm @@ -0,0 +1,84 @@ +# +# Copyright 2020 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 network::ibm::bladecenter::snmp::mode::environment; + +use base qw(centreon::plugins::templates::hardware); + +use strict; +use warnings; + +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_overload_check_section_option} = '^(faultled|temperature)$'; + + $self->{cb_hook2} = 'snmp_execute'; + $self->{thresholds} = { + 'faultled' => [ + ['on', 'CRITICAL'], + ['off', 'OK'], + ], + }; + + $self->{components_path} = 'network::ibm::bladecenter::snmp::mode::components'; + $self->{components_module} = ['faultled', 'temperature']; +} + +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $options{options}->add_options(arguments => { + }); + + return $self; +} + +1; + +__END__ + +=head1 MODE + +Check hardware. + +=over 8 + +=item B<--component> + +Which component to check (Default: '.*'). +Can be: 'faultled', 'temperature'. + +=item B<--no-component> + +Return an error if no compenents are checked. +If total (with skipped) is 0. (Default: 'critical' returns). + +=back + +=cut diff --git a/network/ibm/bladecenter/snmp/mode/memory.pm b/network/ibm/bladecenter/snmp/mode/memory.pm new file mode 100644 index 000000000..35c2279bd --- /dev/null +++ b/network/ibm/bladecenter/snmp/mode/memory.pm @@ -0,0 +1,123 @@ +# +# Copyright 2020 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 network::ibm::bladecenter::snmp::mode::memory; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub custom_usage_output { + my ($self, %options) = @_; + + return sprintf( + 'Ram Total: %s %s Used: %s %s (%.2f%%) Free: %s %s (%.2f%%)', + $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_absolute}), + $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_absolute}), + $self->{result_values}->{prct_used_absolute}, + $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute}), + $self->{result_values}->{prct_free_absolute} + ); +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'memory', type => 0, skipped_code => { -10 => 1 } }, + ]; + + $self->{maps_counters}->{memory} = [ + { label => 'usage', nlabel => 'memory.usage.bytes', set => { + key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], + closure_custom_output => $self->can('custom_usage_output'), + perfdatas => [ + { label => 'used', value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute', + unit => 'B', cast_int => 1 }, + ], + } + }, + { label => 'usage-free', display_ok => 0, nlabel => 'memory.free.bytes', set => { + key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], + closure_custom_output => $self->can('custom_usage_output'), + perfdatas => [ + { label => 'free', value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute', + unit => 'B', cast_int => 1 }, + ], + } + }, + { label => 'usage-prct', display_ok => 0, nlabel => 'memory.usage.percentage', set => { + key_values => [ { name => 'prct_used' } ], + output_template => 'Used : %.2f %%', + perfdatas => [ + { label => 'used_prct', value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, + unit => '%' }, + ], + } + }, + ]; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + my $oid_totalMemoryStats = '.1.3.6.1.4.1.26543.2.5.1.2.12.1.0'; # in bytes + my $oid_memoryFreeStats = '.1.3.6.1.4.1.26543.2.5.1.2.12.2.0'; # in bytes + my $result = $options{snmp}->get_leef(oids => [$oid_totalMemoryStats, $oid_memoryFreeStats], nothing_quit => 1); + + my $free = $result->{$oid_memoryFreeStats}; + my $total = $result->{$oid_totalMemoryStats}; + my $prct_used = ($total - $free) * 100 / $total; + $self->{memory} = { + total => $total, + used => $total - $free, + free => $free, + prct_used => $prct_used, + prct_free => 100 - $prct_used, + } +} + +1; + +__END__ + +=head1 MODE + +Check memory usage. + +=over 8 + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'usage' (B), 'usage-free' (B), 'usage-prct' (%). + +=back + +=cut diff --git a/network/ibm/bladecenter/snmp/plugin.pm b/network/ibm/bladecenter/snmp/plugin.pm new file mode 100644 index 000000000..4ec79937b --- /dev/null +++ b/network/ibm/bladecenter/snmp/plugin.pm @@ -0,0 +1,55 @@ +# +# Copyright 2020 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 network::ibm::bladecenter::snmp::plugin; + +use strict; +use warnings; +use base qw(centreon::plugins::script_snmp); + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.0'; + %{$self->{modes}} = ( + 'cpu' => 'network::ibm::bladecenter::snmp::mode::cpu', + 'disk' => 'network::ibm::bladecenter::snmp::mode::disk', + 'environment' => 'network::ibm::bladecenter::snmp::mode::environment', + 'interfaces' => 'snmp_standard::mode::interfaces', + 'list-interfaces' => 'snmp_standard::mode::listinterfaces', + 'memory' => 'network::ibm::bladecenter::snmp::mode::memory', + 'time' => 'snmp_standard::mode::ntp', + 'uptime' => 'snmp_standard::mode::uptime', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check IBM BladeCenter switches in SNMP. + +=cut From 37ce7f69851ef8952a970cd3c14dab71c9f7c0c6 Mon Sep 17 00:00:00 2001 From: UrBnW <40244829+UrBnW@users.noreply.github.com> Date: Wed, 8 Apr 2020 19:08:06 +0200 Subject: [PATCH 091/283] network::lenovo::flexsystem new plugin --- .../snmp/mode/components/faultled.pm | 66 +++++++ .../snmp/mode/components/temperature.pm | 86 +++++++++ network/lenovo/flexsystem/snmp/mode/cpu.pm | 127 ++++++++++++++ network/lenovo/flexsystem/snmp/mode/disk.pm | 104 +++++++++++ .../flexsystem/snmp/mode/environment.pm | 84 +++++++++ network/lenovo/flexsystem/snmp/mode/memory.pm | 163 ++++++++++++++++++ network/lenovo/flexsystem/snmp/plugin.pm | 55 ++++++ 7 files changed, 685 insertions(+) create mode 100644 network/lenovo/flexsystem/snmp/mode/components/faultled.pm create mode 100644 network/lenovo/flexsystem/snmp/mode/components/temperature.pm create mode 100644 network/lenovo/flexsystem/snmp/mode/cpu.pm create mode 100644 network/lenovo/flexsystem/snmp/mode/disk.pm create mode 100644 network/lenovo/flexsystem/snmp/mode/environment.pm create mode 100644 network/lenovo/flexsystem/snmp/mode/memory.pm create mode 100644 network/lenovo/flexsystem/snmp/plugin.pm diff --git a/network/lenovo/flexsystem/snmp/mode/components/faultled.pm b/network/lenovo/flexsystem/snmp/mode/components/faultled.pm new file mode 100644 index 000000000..b987d1162 --- /dev/null +++ b/network/lenovo/flexsystem/snmp/mode/components/faultled.pm @@ -0,0 +1,66 @@ +# +# Copyright 2020 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 network::lenovo::flexsystem::snmp::mode::components::faultled; + +use strict; +use warnings; + +my %map_faultled_states = ( 1 => 'on', 2 => 'off' ); + +sub load {} + +sub check_faultled { + my ($self, %options) = @_; + + $self->{components}->{faultled}->{total}++; + + $self->{output}->output_add(long_msg => + sprintf( + "Fault LED state is %s", + $options{value} + ) + ); + my $exit = $self->get_severity(section => 'faultled', value => $options{value}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "Fault LED state is %s", + $options{value} + ) + ); + } +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking fault LED"); + $self->{components}->{faultled} = { name => 'faultled', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'faultled')); + + my $oid_mmspFaultLED = '.1.3.6.1.4.1.20301.2.5.1.3.10.12.0'; + my $results = $self->{snmp}->get_leef(oids => [$oid_mmspFaultLED], nothing_quit => 1); + + check_faultled($self, value => $map_faultled_states{$results->{$oid_mmspFaultLED}}); +} + +1; diff --git a/network/lenovo/flexsystem/snmp/mode/components/temperature.pm b/network/lenovo/flexsystem/snmp/mode/components/temperature.pm new file mode 100644 index 000000000..3fb804d38 --- /dev/null +++ b/network/lenovo/flexsystem/snmp/mode/components/temperature.pm @@ -0,0 +1,86 @@ +# +# Copyright 2020 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 network::lenovo::flexsystem::snmp::mode::components::temperature; + +use strict; +use warnings; + +sub load {} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking temperatures"); + $self->{components}->{temperature} = { name => 'temperatures', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'temperature')); + + my $oid_hwTemperatureWarn = '.1.3.6.1.4.1.20301.2.5.1.3.1.22.0'; + my $oid_hwTemperatureShut = '.1.3.6.1.4.1.20301.2.5.1.3.1.23.0'; + my $results = $self->{snmp}->get_leef(oids => [$oid_hwTemperatureWarn, $oid_hwTemperatureShut], nothing_quit => 1); + + # .1.3.6.1.4.1.20301.2.5.1.3.1.41.1.1.20.1 = STRING: "44 C (Warning at 66 C / Recover at 61 C)" + # .1.3.6.1.4.1.20301.2.5.1.3.1.41.1.1.21.1 = STRING: "44 C (Shutdown at 72 C / Recover at 67 C)" + $results->{$oid_hwTemperatureWarn} =~ /^([.0-9]+)\s*C\s*\(Warn(?:ing)?\s*at\s*([.0-9]+)\s*C/i; + my $temperature = $1; + my $warning = $2; + $results->{$oid_hwTemperatureShut} =~ /^([.0-9]+)\s*C\s*\(Shutdown\s*at\s*([.0-9]+)\s*C/i; + if ($1 > $temperature) { + $temperature = $1; + } + my $critical = ($warning + $2) / 2; + + $self->{components}->{temperature}->{total}++; + + $self->{output}->output_add(long_msg => + sprintf( + "Temperature is %.1f C", + $temperature + ) + ); + + my $exit = 'OK'; + if ($temperature >= $warning) { + $exit = 'WARNING'; + } + if ($temperature >= $critical) { + $exit = 'CRITICAL'; + } + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "Temperature is %.1f C", + $temperature + ) + ); + } + + $self->{output}->perfdata_add( + label => 'temperature', unit => 'C', + nlabel => 'hardware.temperature.celsius', + instances => 'system', + value => $temperature, + warning => $warning, + critical => $critical + ); +} + +1; diff --git a/network/lenovo/flexsystem/snmp/mode/cpu.pm b/network/lenovo/flexsystem/snmp/mode/cpu.pm new file mode 100644 index 000000000..c17707bcb --- /dev/null +++ b/network/lenovo/flexsystem/snmp/mode/cpu.pm @@ -0,0 +1,127 @@ +# +# Copyright 2020 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 network::lenovo::flexsystem::snmp::mode::cpu; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'cpu', type => 1, cb_prefix_output => 'prefix_message_output', message_multiple => 'All CPU usages are ok' }, + ]; + + $self->{maps_counters}->{cpu} = [ + { label => 'average', nlabel => 'cpu.utilization.percentage', set => { + key_values => [ { name => 'average' }, { name => 'display' } ], + output_template => '%.2f %%', + perfdatas => [ + { label => 'total_cpu_avg', value => 'average_absolute', template => '%.2f', + min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + ]; +} + +sub prefix_message_output { + my ($self, %options) = @_; + + return "Switch '" . $options{instance_value}->{display} . "' "; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $options{options}->add_options(arguments => { + 'filter:s' => { name => 'filter', default => '.*' } + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + my $oid_mpCpuSwitchNumberRev = '.1.3.6.1.4.1.20301.2.5.1.2.2.12.1.1.1'; + my $oid_mpCpuStatsUtil1MinuteSwRev = '.1.3.6.1.4.1.20301.2.5.1.2.2.12.1.1.5'; + + my $result = $options{snmp}->get_table(oid => $oid_mpCpuSwitchNumberRev, nothing_quit => 1); + my @instance_oids = (); + foreach my $oid (keys %$result) { + if ($result->{$oid} =~ /$self->{option_results}->{filter}/i) { + push @instance_oids, $oid; + } + } + + if (scalar(@instance_oids) == 0) { + $self->{output}->add_option_msg(short_msg => "Cannot find switch number '$self->{option_results}->{filter}'."); + $self->{output}->option_exit(); + } + + $options{snmp}->load( + oids => [$oid_mpCpuStatsUtil1MinuteSwRev], + instances => \@instance_oids, + instance_regexp => "^" . $oid_mpCpuSwitchNumberRev . '\.(.+)' + ); + my $result2 = $options{snmp}->get_leef(); + + foreach my $instance (@instance_oids) { + $instance =~ /^$oid_mpCpuSwitchNumberRev\.(.+)/; + $instance = $1; + + $self->{cpu}->{$instance} = { + display => $result->{$oid_mpCpuSwitchNumberRev . '.' . $instance}, + average => $result2->{$oid_mpCpuStatsUtil1MinuteSwRev . '.' . $instance}, + }; + } +} + +1; + +__END__ + +=head1 MODE + +Check CPU usage (over the last minute). + +=over 8 + +=item B<--filter> + +Filter switch number (Default: '.*'). + +=item B<--warning-average> + +Warning threshold average CPU utilization. + +=item B<--critical-average> + +Critical threshold average CPU utilization. + +=back + +=cut diff --git a/network/lenovo/flexsystem/snmp/mode/disk.pm b/network/lenovo/flexsystem/snmp/mode/disk.pm new file mode 100644 index 000000000..16ec7a79b --- /dev/null +++ b/network/lenovo/flexsystem/snmp/mode/disk.pm @@ -0,0 +1,104 @@ +# +# Copyright 2020 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 network::lenovo::flexsystem::snmp::mode::disk; + +use base qw(snmp_standard::mode::storage); + +use strict; +use warnings; + +sub default_storage_type { + my ($self, %options) = @_; + + return '^(?!(hrStorageRam)$)'; +} + +sub prefix_storage_output { + my ($self, %options) = @_; + + return "Disk '" . $options{instance_value}->{display} . "' "; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + return $self; +} + +1; + +__END__ + +=head1 MODE + +Check disk. + +=over 8 + +=item B<--warning-usage> + +Threshold warning. + +=item B<--critical-usage> + +Threshold critical. + +=item B<--units> + +Units of thresholds (Default: '%') ('%', 'B'). + +=item B<--free> + +Thresholds are on free space left. + +=item B<--storage> + +Set the storage (number expected) ex: 1, 2,... (empty means 'check all storage'). + +=item B<--name> + +Allows to use storage name with option --storage instead of storage oid index. + +=item B<--regexp> + +Allows to use regexp to filter storage (with option --name). + +=item B<--regexp-isensitive> + +Allows to use regexp non case-sensitive (with --regexp). + +=item B<--reload-cache-time> + +Time in minutes before reloading cache file (default: 180). + +=item B<--show-cache> + +Display cache storage datas. + +=item B<--filter-storage-type> + +Filter storage types with a regexp (Default: '^(?!(hrStorageRam)$)'). + +=back + +=cut diff --git a/network/lenovo/flexsystem/snmp/mode/environment.pm b/network/lenovo/flexsystem/snmp/mode/environment.pm new file mode 100644 index 000000000..632d32a71 --- /dev/null +++ b/network/lenovo/flexsystem/snmp/mode/environment.pm @@ -0,0 +1,84 @@ +# +# Copyright 2020 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 network::lenovo::flexsystem::snmp::mode::environment; + +use base qw(centreon::plugins::templates::hardware); + +use strict; +use warnings; + +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_overload_check_section_option} = '^(faultled|temperature)$'; + + $self->{cb_hook2} = 'snmp_execute'; + $self->{thresholds} = { + 'faultled' => [ + ['on', 'CRITICAL'], + ['off', 'OK'], + ], + }; + + $self->{components_path} = 'network::lenovo::flexsystem::snmp::mode::components'; + $self->{components_module} = ['faultled', 'temperature']; +} + +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $options{options}->add_options(arguments => { + }); + + return $self; +} + +1; + +__END__ + +=head1 MODE + +Check hardware. + +=over 8 + +=item B<--component> + +Which component to check (Default: '.*'). +Can be: 'faultled', 'temperature'. + +=item B<--no-component> + +Return an error if no compenents are checked. +If total (with skipped) is 0. (Default: 'critical' returns). + +=back + +=cut diff --git a/network/lenovo/flexsystem/snmp/mode/memory.pm b/network/lenovo/flexsystem/snmp/mode/memory.pm new file mode 100644 index 000000000..232a2c98e --- /dev/null +++ b/network/lenovo/flexsystem/snmp/mode/memory.pm @@ -0,0 +1,163 @@ +# +# Copyright 2020 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 network::lenovo::flexsystem::snmp::mode::memory; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub custom_usage_output { + my ($self, %options) = @_; + + return sprintf( + 'Ram Total: %s %s Used: %s %s (%.2f%%) Free: %s %s (%.2f%%)', + $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_absolute}), + $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_absolute}), + $self->{result_values}->{prct_used_absolute}, + $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute}), + $self->{result_values}->{prct_free_absolute} + ); +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'memory', type => 1, cb_prefix_output => 'prefix_message_output', message_multiple => 'All memory usages are ok' }, + ]; + + $self->{maps_counters}->{memory} = [ + { label => 'usage', nlabel => 'memory.usage.bytes', set => { + key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'display' } ], + closure_custom_output => $self->can('custom_usage_output'), + perfdatas => [ + { label => 'used', value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute', + unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'usage-free', display_ok => 0, nlabel => 'memory.free.bytes', set => { + key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], + closure_custom_output => $self->can('custom_usage_output'), + perfdatas => [ + { label => 'free', value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute', + unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'usage-prct', display_ok => 0, nlabel => 'memory.usage.percentage', set => { + key_values => [ { name => 'prct_used' } ], + output_template => 'Used : %.2f %%', + perfdatas => [ + { label => 'used_prct', value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, + unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + ]; +} + +sub prefix_message_output { + my ($self, %options) = @_; + + return "Switch '" . $options{instance_value}->{display} . "' "; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $options{options}->add_options(arguments => { + 'filter:s' => { name => 'filter', default => '.*' } + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + my $oid_switchNumber = '.1.3.6.1.4.1.20301.2.5.1.2.12.9.1.1.1'; + my $oid_totalMemoryStatsRev = '.1.3.6.1.4.1.20301.2.5.1.2.12.9.1.1.3'; # in bytes + my $oid_memoryFreeStatsRev = '.1.3.6.1.4.1.20301.2.5.1.2.12.9.1.1.4'; # in bytes + + my $result = $options{snmp}->get_table(oid => $oid_switchNumber, nothing_quit => 1); + my @instance_oids = (); + foreach my $oid (keys %$result) { + if ($result->{$oid} =~ /$self->{option_results}->{filter}/i) { + push @instance_oids, $oid; + } + } + + if (scalar(@instance_oids) == 0) { + $self->{output}->add_option_msg(short_msg => "Cannot find switch number '$self->{option_results}->{filter}'."); + $self->{output}->option_exit(); + } + + $options{snmp}->load( + oids => [$oid_totalMemoryStatsRev, $oid_memoryFreeStatsRev], + instances => \@instance_oids, + instance_regexp => "^" . $oid_switchNumber . '\.(.+)' + ); + my $result2 = $options{snmp}->get_leef(); + + foreach my $instance (@instance_oids) { + $instance =~ /^$oid_switchNumber\.(.+)/; + $instance = $1; + + my $free = $result2->{$oid_memoryFreeStatsRev . '.' . $instance}; + my $total = $result2->{$oid_totalMemoryStatsRev . '.' . $instance}; + my $prct_used = ($total - $free) * 100 / $total; + $self->{memory}->{$instance} = { + display => $result->{$oid_switchNumber . '.' . $instance}, + total => $total, + used => $total - $free, + free => $free, + prct_used => $prct_used, + prct_free => 100 - $prct_used, + }; + } +} + +1; + +__END__ + +=head1 MODE + +Check memory usage. + +=over 8 + +=item B<--filter> + +Filter switch number (Default: '.*'). + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'usage' (B), 'usage-free' (B), 'usage-prct' (%). + +=back + +=cut diff --git a/network/lenovo/flexsystem/snmp/plugin.pm b/network/lenovo/flexsystem/snmp/plugin.pm new file mode 100644 index 000000000..15dfa65b6 --- /dev/null +++ b/network/lenovo/flexsystem/snmp/plugin.pm @@ -0,0 +1,55 @@ +# +# Copyright 2020 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 network::lenovo::flexsystem::snmp::plugin; + +use strict; +use warnings; +use base qw(centreon::plugins::script_snmp); + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.0'; + %{$self->{modes}} = ( + 'cpu' => 'network::lenovo::flexsystem::snmp::mode::cpu', + 'disk' => 'network::lenovo::flexsystem::snmp::mode::disk', + 'environment' => 'network::lenovo::flexsystem::snmp::mode::environment', + 'interfaces' => 'snmp_standard::mode::interfaces', + 'list-interfaces' => 'snmp_standard::mode::listinterfaces', + 'memory' => 'network::lenovo::flexsystem::snmp::mode::memory', + 'time' => 'snmp_standard::mode::ntp', + 'uptime' => 'snmp_standard::mode::uptime', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Lenovo Flex System switches in SNMP. + +=cut From 9ce1300f088b0fcecaff8cf567dd9a1b8a6a23b7 Mon Sep 17 00:00:00 2001 From: Colin Gagnaire Date: Wed, 8 Apr 2020 22:32:26 +0200 Subject: [PATCH 092/283] add filter-type to ec2 discovery --- cloud/aws/ec2/mode/discovery.pm | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/cloud/aws/ec2/mode/discovery.pm b/cloud/aws/ec2/mode/discovery.pm index ed6e9dd76..a6c43047e 100644 --- a/cloud/aws/ec2/mode/discovery.pm +++ b/cloud/aws/ec2/mode/discovery.pm @@ -32,7 +32,8 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - "prettify" => { name => 'prettify' }, + "prettify" => { name => 'prettify' }, + "filter-type:s" => { name => 'filter_type' }, }); return $self; @@ -86,8 +87,10 @@ sub run { } push @{$ec2{tags}}, { key => $tag->{Key}, value => $tag->{Value} }; } - push @disco_data, \%ec2; - push @disco_data, \%asg if (defined($asg{name}) && $asg{name} ne ''); + push @disco_data, \%ec2 unless (defined($self->{option_results}->{filter_type}) + && $ec2{type} !~ /$self->{option_results}->{filter_type}/); + push @disco_data, \%asg unless ((defined($self->{option_results}->{filter_type}) + && $asg{type} !~ /$self->{option_results}->{filter_type}/) || !defined($asg{name}) || $asg{name} eq ''); } } @@ -123,6 +126,10 @@ EC2/ASG discovery. =over 8 +=item B<--filter-type> + +Filter type. + =item B<--prettify> Prettify JSON output. From ac99f7e592dfb2a4941a5ffe311a0dc47da32c88 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 10 Apr 2020 11:36:04 +0200 Subject: [PATCH 093/283] prepare new release --- changelog | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/changelog b/changelog index 095c7f0f6..9204b28dd 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,20 @@ +2020-04-10 Quentin Garnier + * Plugin added: Dell OS10 SNMP + * Plugin added: Sirportly notification + * Plugin added: Mobotix Camera SNMP + * Plugin added: Ibm MQ MQI + * Plugin added: Supermicro BMC SNMP + * Plugin added: Eltek Enexus SNMP + * Plugin added: Cisco Meraki Rest API + * Plugin added: Aws EFS + * Core: add backend ssh system (plink, ssh and libssh) + * Mode added: [azure] 'alert' + * Mode added: [checkpoint/snmp] 'vsx' + * Mode added: [synology/snmp] 'ha' + * Mode added: [cisco/standard/snmp] 'wan3g' + * Break: [fortigate/snmp] 'cpu', 'memory', 'vdom' (merge) + * Break: [supermicro/snmp] move directory + 2020-02-04 Quentin Garnier * Plugin added: Allied Telesis SNMP * Plugin added: UPS HP SNMP From b6510120875150408c200c8156077365c23235b8 Mon Sep 17 00:00:00 2001 From: thibaults-centreon Date: Fri, 10 Apr 2020 14:25:34 +0200 Subject: [PATCH 094/283] add(plugin): AWS VPN --- cloud/aws/custom/awscli.pm | 67 ++++++-- cloud/aws/custom/paws.pm | 88 +++++----- cloud/aws/vpn/mode/listvpn.pm | 96 +++++++++++ cloud/aws/vpn/mode/traffic.pm | 315 ++++++++++++++++++++++++++++++++++ cloud/aws/vpn/plugin.pm | 52 ++++++ 5 files changed, 559 insertions(+), 59 deletions(-) create mode 100644 cloud/aws/vpn/mode/listvpn.pm create mode 100644 cloud/aws/vpn/mode/traffic.pm create mode 100644 cloud/aws/vpn/plugin.pm diff --git a/cloud/aws/custom/awscli.pm b/cloud/aws/custom/awscli.pm index 3530adfe8..ab62709fb 100644 --- a/cloud/aws/custom/awscli.pm +++ b/cloud/aws/custom/awscli.pm @@ -160,7 +160,7 @@ sub execute { $self->{output}->option_exit(); } - return $raw_results; + return $raw_results; } sub cloudwatch_get_metrics_set_cmd { @@ -176,7 +176,7 @@ sub cloudwatch_get_metrics_set_cmd { } $cmd_options .= " --endpoint-url $self->{endpoint_url}" if (defined($self->{endpoint_url}) && $self->{endpoint_url} ne ''); - return $cmd_options; + return $cmd_options; } sub cloudwatch_get_metrics { @@ -229,7 +229,7 @@ sub discovery_set_cmd { my $cmd_options = $options{service} . " " . $options{command} . " --region $options{region} --output json"; $cmd_options .= " --endpoint-url $self->{endpoint_url}" if (defined($self->{endpoint_url}) && $self->{endpoint_url} ne ''); - return $cmd_options; + return $cmd_options; } sub discovery { @@ -249,7 +249,7 @@ sub cloudwatch_get_alarms_set_cmd { my $cmd_options = "cloudwatch describe-alarms --region $options{region} --output json"; $cmd_options .= " --endpoint-url $self->{endpoint_url}" if (defined($self->{endpoint_url}) && $self->{endpoint_url} ne ''); - return $cmd_options; + return $cmd_options; } sub cloudwatch_get_alarms { @@ -282,7 +282,7 @@ sub cloudwatch_list_metrics_set_cmd { $cmd_options .= " --metric-name $options{metric}" if (defined($options{metric})); $cmd_options .= " --endpoint-url $self->{endpoint_url}" if (defined($self->{endpoint_url}) && $self->{endpoint_url} ne ''); - return $cmd_options; + return $cmd_options; } sub cloudwatch_list_metrics { @@ -302,7 +302,7 @@ sub cloudwatchlogs_describe_log_groups_set_cmd { my $cmd_options = "logs describe-log-groups --region $self->{option_results}->{region} --output json"; $cmd_options .= " --endpoint-url $self->{endpoint_url}" if (defined($self->{endpoint_url}) && $self->{endpoint_url} ne ''); - return $cmd_options; + return $cmd_options; } sub cloudwatchlogs_describe_log_groups { @@ -329,7 +329,7 @@ sub cloudwatchlogs_filter_log_events_set_cmd { } $cmd_options .= " --endpoint-url $self->{endpoint_url}" if (defined($self->{endpoint_url}) && $self->{endpoint_url} ne ''); - return $cmd_options; + return $cmd_options; } sub cloudwatchlogs_filter_log_events { @@ -349,7 +349,7 @@ sub ec2_get_instances_status_set_cmd { my $cmd_options = "ec2 describe-instance-status --include-all-instances --no-dry-run --region $options{region} --output json"; $cmd_options .= " --endpoint-url $self->{endpoint_url}" if (defined($self->{endpoint_url}) && $self->{endpoint_url} ne ''); - return $cmd_options; + return $cmd_options; } sub ec2_get_instances_status { @@ -361,7 +361,7 @@ sub ec2_get_instances_status { my $instance_results = {}; foreach (@{$raw_results->{InstanceStatuses}}) { $instance_results->{$_->{InstanceId}} = { - state => $_->{InstanceState}->{Name}, + state => $_->{InstanceState}->{Name}, status => => $_->{InstanceStatus}->{Status} }; } @@ -377,7 +377,7 @@ sub ec2_list_resources_set_cmd { my $cmd_options = "ec2 describe-instances --no-dry-run --region $options{region} --output json"; $cmd_options .= " --endpoint-url $self->{endpoint_url}" if (defined($self->{endpoint_url}) && $self->{endpoint_url} ne ''); - return $cmd_options; + return $cmd_options; } sub ec2_list_resources { @@ -394,7 +394,7 @@ sub ec2_list_resources { my %already = map { $_->{Name} => $_ } @{$resource_results}; if ($tag->{Key} eq "aws:autoscaling:groupName") { next if (defined($already{$tag->{Value}})); - push @{$resource_results}, { + push @{$resource_results}, { Name => $tag->{Value}, Type => 'asg', }; @@ -402,7 +402,7 @@ sub ec2_list_resources { push @instance_tags, $tag->{Value}; } } - push @{$resource_results}, { + push @{$resource_results}, { Name => $instance->{InstanceId}, Type => 'instance', AvailabilityZone => $instance->{Placement}->{AvailabilityZone}, @@ -411,7 +411,6 @@ sub ec2_list_resources { Tags => join(",", @instance_tags), KeyName => $instance->{KeyName}, }; - } } @@ -426,7 +425,7 @@ sub asg_get_resources_set_cmd { my $cmd_options = "autoscaling describe-auto-scaling-groups --region $options{region} --output json"; $cmd_options .= " --endpoint-url $self->{endpoint_url}" if (defined($self->{endpoint_url}) && $self->{endpoint_url} ne ''); - return $cmd_options; + return $cmd_options; } sub asg_get_resources { @@ -446,7 +445,7 @@ sub rds_get_instances_status_set_cmd { my $cmd_options = "rds describe-db-instances --region $options{region} --output json"; $cmd_options .= " --endpoint-url $self->{endpoint_url}" if (defined($self->{endpoint_url}) && $self->{endpoint_url} ne ''); - return $cmd_options; + return $cmd_options; } sub rds_get_instances_status { @@ -471,7 +470,7 @@ sub rds_list_instances_set_cmd { my $cmd_options = "rds describe-db-instances --region $options{region} --output json"; $cmd_options .= " --endpoint-url $self->{endpoint_url}" if (defined($self->{endpoint_url}) && $self->{endpoint_url} ne ''); - return $cmd_options; + return $cmd_options; } sub rds_list_instances { @@ -502,7 +501,7 @@ sub rds_list_clusters_set_cmd { my $cmd_options = "rds describe-db-clusters --region $options{region} --output json"; $cmd_options .= " --endpoint-url $self->{endpoint_url}" if (defined($self->{endpoint_url}) && $self->{endpoint_url} ne ''); - return $cmd_options; + return $cmd_options; } sub rds_list_clusters { @@ -524,6 +523,40 @@ sub rds_list_clusters { return $cluster_results; } +sub vpn_list_connections_set_cmd { + my ($self, %options) = @_; + + return if (defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne ''); + + my $cmd_options = "ec2 describe-vpn-connections --region $options{region} --output json"; + $cmd_options .= " --endpoint-url $self->{endpoint_url}" if (defined($self->{endpoint_url}) && $self->{endpoint_url} ne ''); + + return $cmd_options; +} + +sub vpn_list_connections { + my ($self, %options) = @_; + + my $cmd_options = $self->vpn_list_connections_set_cmd(%options); + my $raw_results = $self->execute(cmd_options => $cmd_options); + + my $connections_results = []; + foreach my $connection (@{$raw_results->{VpnConnections}}) { + my @name_tags; + foreach my $tag (@{$connection->{Tags}}) { + if ($tag->{Key} eq "Name" && defined($tag->{Value})) { + push @name_tags, $tag->{Value}; + } + } + push @{$connections_results}, { + id => $connection->{VpnConnectionId}, + name => join(",", @name_tags), + state => $connection->{State} + } + }; + return $connections_results; +} + 1; __END__ diff --git a/cloud/aws/custom/paws.pm b/cloud/aws/custom/paws.pm index 44f20e736..030aa81bc 100644 --- a/cloud/aws/custom/paws.pm +++ b/cloud/aws/custom/paws.pm @@ -39,9 +39,8 @@ sub new { $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 => { + $options{options}->add_options(arguments => { 'aws-secret-key:s' => { name => 'aws_secret_key' }, 'aws-access-key:s' => { name => 'aws_access_key' }, 'region:s' => { name => 'region' }, @@ -53,28 +52,23 @@ sub new { }); } $options{options}->add_help(package => __PACKAGE__, sections => 'PAWS OPTIONS', once => 1); - $self->{output} = $options{output}; $self->{mode} = $options{mode}; - return $self; } sub get_region { my ($self, %options) = @_; - return $self->{option_results}->{region}; } sub set_options { my ($self, %options) = @_; - $self->{option_results} = $options{option_results}; } sub set_defaults { my ($self, %options) = @_; - foreach (keys %{$options{default}}) { if ($_ eq $self->{mode}) { for (my $i = 0; $i < scalar(@{$options{default}->{$_}}); $i++) { @@ -95,19 +89,16 @@ sub check_options { $ENV{HTTP_PROXY} = $self->{option_results}->{proxyurl}; $ENV{HTTPS_PROXY} = $self->{option_results}->{proxyurl}; } - if (defined($self->{option_results}->{aws_secret_key}) && $self->{option_results}->{aws_secret_key} ne '') { $ENV{AWS_SECRET_KEY} = $self->{option_results}->{aws_secret_key}; } if (defined($self->{option_results}->{aws_access_key}) && $self->{option_results}->{aws_access_key} ne '') { $ENV{AWS_ACCESS_KEY} = $self->{option_results}->{aws_access_key}; } - if (!defined($self->{option_results}->{region}) || $self->{option_results}->{region} eq '') { $self->{output}->add_option_msg(short_msg => "Need to specify --region option."); $self->{output}->option_exit(); } - if (defined($self->{option_results}->{statistic})) { foreach my $statistic (@{$self->{option_results}->{statistic}}) { if ($statistic !~ /minimum|maximum|average|sum/) { @@ -116,20 +107,18 @@ sub check_options { } } } - return 0; } sub cloudwatch_get_metrics { my ($self, %options) = @_; - + my $metric_results = {}; eval { my $lwp_caller = new Paws::Net::LWPCaller(); my $cw = Paws->service('CloudWatch', caller => $lwp_caller, region => $options{region}); my $start_time = DateTime->now->subtract(seconds => $options{timeframe})->iso8601; my $end_time = DateTime->now->iso8601; - foreach my $metric_name (@{$options{metrics}}) { my $metric_result = $cw->GetMetricStatistics( MetricName => $metric_name, @@ -142,7 +131,6 @@ sub cloudwatch_get_metrics { #Unit => $unit, Dimensions => $options{dimensions}, ); - $metric_results->{$metric_result->{Label}} = { points => 0 }; foreach my $point (@{$metric_result->{Datapoints}}) { if (defined($point->{Average})) { @@ -161,10 +149,9 @@ sub cloudwatch_get_metrics { $metric_results->{$metric_result->{Label}}->{sum} = 0 if (!defined($metric_results->{$metric_result->{Label}}->{sum})); $metric_results->{$metric_result->{Label}}->{sum} += $point->{Sum}; } - $metric_results->{$metric_result->{Label}}->{points}++; } - + if (defined($metric_results->{$metric_result->{Label}}->{average})) { $metric_results->{$metric_result->{Label}}->{average} /= $metric_results->{$metric_result->{Label}}->{points}; } @@ -174,7 +161,6 @@ sub cloudwatch_get_metrics { $self->{output}->add_option_msg(short_msg => "error: $@"); $self->{output}->option_exit(); } - return $metric_results; } @@ -205,7 +191,7 @@ sub cloudwatch_get_alarms { sub cloudwatch_list_metrics { my ($self, %options) = @_; - + my $metric_results = []; eval { my $lwp_caller = new Paws::Net::LWPCaller(); @@ -219,13 +205,13 @@ sub cloudwatch_list_metrics { foreach my $dimension (@{$_->{Dimensions}}) { push @$dimensions, { Name => $dimension->{Name}, Value => $dimension->{Value} }; } - push @{$metric_results}, { + push @{$metric_results}, { Namespace => $_->{Namespace}, MetricName => $_->{MetricName}, Dimensions => $dimensions, }; } - + last if (!defined($list_metrics->{NextToken})); $cw_options{NextToken} = $list_metrics->{NextToken}; } @@ -234,7 +220,6 @@ sub cloudwatch_list_metrics { $self->{output}->add_option_msg(short_msg => "error: $@"); $self->{output}->option_exit(); } - return $metric_results; } @@ -250,7 +235,7 @@ sub cloudwatchlogs_describe_log_groups { foreach (@{$list_log_groups->{logGroups}}) { push @$log_groups_results, $_; } - + last if (!defined($list_log_groups->{NextToken})); $cw_options{NextToken} = $list_log_groups->{NextToken}; } @@ -259,7 +244,6 @@ sub cloudwatchlogs_describe_log_groups { $self->{output}->add_option_msg(short_msg => "error: $@"); $self->{output}->option_exit(); } - return $log_groups_results; } @@ -277,7 +261,6 @@ sub cloudwatchlogs_filter_log_events { foreach (@{$list_log_groups->{logGroups}}) { push @$log_groups_results, $_; } - last if (!defined($list_log_groups->{NextToken})); $cw_options{NextToken} = $list_log_groups->{NextToken}; } @@ -286,19 +269,17 @@ sub cloudwatchlogs_filter_log_events { $self->{output}->add_option_msg(short_msg => "error: $@"); $self->{output}->option_exit(); } - return $log_groups_results; } sub ec2_get_instances_status { my ($self, %options) = @_; - + my $instance_results = {}; eval { my $lwp_caller = new Paws::Net::LWPCaller(); my $ec2 = Paws->service('EC2', caller => $lwp_caller, region => $options{region}); my $instances = $ec2->DescribeInstanceStatus(DryRun => 0, IncludeAllInstances => 1); - foreach (@{$instances->{InstanceStatuses}}) { $instance_results->{$_->{InstanceId}} = { state => $_->{InstanceState}->{Name}, status => => $_->{InstanceStatus}->{Status} }; @@ -308,19 +289,18 @@ sub ec2_get_instances_status { $self->{output}->add_option_msg(short_msg => "error: $@"); $self->{output}->option_exit(); } - + return $instance_results; } sub ec2_list_resources { my ($self, %options) = @_; - + my $resource_results = []; eval { my $lwp_caller = new Paws::Net::LWPCaller(); my $ec2 = Paws->service('EC2', caller => $lwp_caller, region => $options{region}); my $list_instances = $ec2->DescribeInstances(DryRun => 0); - foreach my $reservation (@{$list_instances->{Reservations}}) { foreach my $instance (@{$reservation->{Instances}}) { my @instance_tags; @@ -328,7 +308,7 @@ sub ec2_list_resources { my %already = map { $_->{Name} => $_ } @{$resource_results}; if ($tag->{Key} eq "aws:autoscaling:groupName") { next if (defined($already{$tag->{Value}})); - push @{$resource_results}, { + push @{$resource_results}, { Name => $tag->{Value}, Type => 'asg', }; @@ -336,7 +316,7 @@ sub ec2_list_resources { push @instance_tags, $tag->{Key} . ":" . $tag->{Value}; } } - push @{$resource_results}, { + push @{$resource_results}, { Name => $instance->{InstanceId}, Type => 'instance', AvailabilityZone => $instance->{Placement}->{AvailabilityZone}, @@ -344,7 +324,7 @@ sub ec2_list_resources { State => $instance->{State}->{Name}, Tags => join(",", @instance_tags), }; - + } } }; @@ -352,7 +332,7 @@ sub ec2_list_resources { $self->{output}->add_option_msg(short_msg => "error: $@"); $self->{output}->option_exit(); } - + return $resource_results; } @@ -375,7 +355,7 @@ sub asg_get_resources { sub rds_get_instances_status { my ($self, %options) = @_; - + my $instance_results = {}; eval { my $lwp_caller = new Paws::Net::LWPCaller(); @@ -389,19 +369,18 @@ sub rds_get_instances_status { $self->{output}->add_option_msg(short_msg => "error: $@"); $self->{output}->option_exit(); } - + return $instance_results; } sub rds_list_instances { my ($self, %options) = @_; - + my $instance_results = []; eval { my $lwp_caller = new Paws::Net::LWPCaller(); my $rds = Paws->service('RDS', caller => $lwp_caller, region => $options{region}); my $list_instances = $rds->DescribeDBInstances(); - foreach my $instance (@{$list_instances->{DBInstances}}) { push @{$instance_results}, { Name => $instance->{DBInstanceIdentifier}, @@ -416,19 +395,16 @@ sub rds_list_instances { $self->{output}->add_option_msg(short_msg => "error: $@"); $self->{output}->option_exit(); } - return $instance_results; } sub rds_list_clusters { my ($self, %options) = @_; - my $cluster_results = []; eval { my $lwp_caller = new Paws::Net::LWPCaller(); my $rds = Paws->service('RDS', caller => $lwp_caller, region => $options{region}); my $list_clusters = $rds->DescribeDBClusters(); - foreach my $cluster (@{$list_clusters->{DBClusters}}) { push @{$cluster_results}, { Name => $cluster->{DBClusterIdentifier}, @@ -442,10 +418,38 @@ sub rds_list_clusters { $self->{output}->add_option_msg(short_msg => "error: $@"); $self->{output}->option_exit(); } - return $cluster_results; } +sub vpn_list_connections { + my ($self, %options) = @_; + my $connections_results = []; + eval { + my $lwp_caller = new Paws::Net::LWPCaller(); + my $rds = Paws->service('EC2', caller => $lwp_caller, region => $options{region}); + my $list_vpn = $vpn->DescribeVpnConnections(); + foreach my $connection (@{$list_vpn->{VpnConnections}}) { + my @name_tags; + foreach my $tag (@{$connection->{Tags}}) { + if ($tag->{Key} eq "Name" && defined($tag->{Value})) { + push @name_tags, $tag->{Value}; + } + } + push @{$connections_results}, { + id => $connection->{VpnConnectionId}, + name => join(",", @name_tags), + state => $connection->{State} + } + }; + }; + if ($@) { + $self->{output}->add_option_msg(short_msg => "error: $@"); + $self->{output}->option_exit(); + } + + return $connections_results; +} + 1; __END__ diff --git a/cloud/aws/vpn/mode/listvpn.pm b/cloud/aws/vpn/mode/listvpn.pm new file mode 100644 index 000000000..ff7fdcfc7 --- /dev/null +++ b/cloud/aws/vpn/mode/listvpn.pm @@ -0,0 +1,96 @@ +# +# Copyright 2020 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 cloud::aws::vpn::mode::listvpn; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $options{options}->add_options(arguments => {}); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); +} + +sub manage_selection { + my ($self, %options) = @_; + + $self->{connection} = $options{custom}->vpn_list_connections(region => $self->{option_results}->{region}); +} + +sub run { + my ($self, %options) = @_; + + $self->manage_selection(%options); + foreach (@{$self->{connection}}) { + $self->{output}->output_add( + long_msg => sprintf("[Id = %s][Name = %s][State = %s]", + $_->{id}, $_->{name}, $_->{state} )); + } + + $self->{output}->output_add(severity => 'OK', + short_msg => 'List VPN connections:'); + $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 => ['id', 'name', 'state']); +} + +sub disco_show { + my ($self, %options) = @_; + + $self->manage_selection(%options); + foreach (@{$self->{connection}}) { + $self->{output}->add_disco_entry( + id => $_->{id}, + name => $_->{name}, + state => $_->{state}, + ); + }; +} + +1; + +__END__ + +=head1 MODE + +List EC2 instances. + +=over 8 + +=back + +=cut diff --git a/cloud/aws/vpn/mode/traffic.pm b/cloud/aws/vpn/mode/traffic.pm new file mode 100644 index 000000000..d23cd5552 --- /dev/null +++ b/cloud/aws/vpn/mode/traffic.pm @@ -0,0 +1,315 @@ +# +# Copyright 2020 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 cloud::aws::vpn::mode::traffic; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +my %metrics_mapping = ( + 'TunnelState' => { + 'output' => 'Tunnel State', + 'label' => 'tunnel-state', + 'nlabel' => { + 'absolute' => 'vpn.tunnel.tunnelstate'}, + 'unit' => '' + }, + 'TunnelDataIn' => { + 'output' => 'Tunnel Data In', + 'label' => 'tunnel-datain', + 'nlabel' => { + 'absolute' => 'vpn.tunnel.datain.bytes', + 'per_second' => 'vpn.tunnel.datain.bytespersecond', + }, + 'unit' => 'B' + }, + 'TunnelDataOut' => { + 'output' => 'Tunnel Data Out', + 'label' => 'tunnel-dataout', + 'nlabel' => { + 'absolute' => 'vpn.tunnel.dataout.bytes', + 'per_second' => 'vpn.tunnel.dataout.bytespersecond', + }, + 'unit' => 'B' + } +); + + +sub custom_metric_calc { + my ($self, %options) = @_; + + $self->{result_values}->{timeframe} = $options{new_datas}->{$self->{instance} . '_timeframe'}; + $self->{result_values}->{value} = $options{new_datas}->{$self->{instance} . '_' . $options{extra_options}->{metric}}; + $self->{result_values}->{value_per_sec} = $self->{result_values}->{value} / $self->{result_values}->{timeframe}; + $self->{result_values}->{metric} = $options{extra_options}->{metric}; + return 0; +} + +sub custom_metric_calc_state { + my ($self, %options) = @_; + + $self->{result_values}->{timeframe} = $options{new_datas}->{$self->{instance} . '_timeframe'}; + $self->{result_values}->{value} = $options{new_datas}->{$self->{instance} . '_' . $options{extra_options}->{metric}}; + $self->{result_values}->{value_per_sec} = $self->{result_values}->{value}; + $self->{result_values}->{metric} = $options{extra_options}->{metric}; + return 0; +} + +sub custom_metric_threshold { + my ($self, %options) = @_; + + my $exit = $self->{perfdata}->threshold_check( + value => defined($self->{instance_mode}->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value}, + threshold => [ { label => 'critical-' . $metrics_mapping{$self->{result_values}->{metric}}->{label} , exit_litteral => 'critical' }, + { label => 'warning-' . $metrics_mapping{$self->{result_values}->{metric}}->{label}, exit_litteral => 'warning' } ] + ); + return $exit; +} + +sub custom_metric_perfdata { + my ($self, %options) = @_; + + $self->{output}->perfdata_add( + instances => $self->{instance}, + label => $metrics_mapping{$self->{result_values}->{metric}}->{label}, + nlabel => defined($self->{instance_mode}->{option_results}->{per_sec}) ? + $metrics_mapping{$self->{result_values}->{metric}}->{nlabel}->{per_second} : + $metrics_mapping{$self->{result_values}->{metric}}->{nlabel}->{absolute}, + unit => defined($self->{instance_mode}->{option_results}->{per_sec}) ? + $metrics_mapping{$self->{result_values}->{metric}}->{unit} . '/s' : + $metrics_mapping{$self->{result_values}->{metric}}->{unit}, + value => sprintf("%.2f", defined($self->{instance_mode}->{option_results}->{per_sec}) ? + $self->{result_values}->{value_per_sec} : + $self->{result_values}->{value}), + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $metrics_mapping{$self->{result_values}->{metric}}->{label}), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $metrics_mapping{$self->{result_values}->{metric}}->{label}), + ); +} + +sub custom_metric_perfdata_state { + my ($self, %options) = @_; + + $self->{output}->perfdata_add( + instances => $self->{instance}, + label => $metrics_mapping{$self->{result_values}->{metric}}->{label}, + nlabel => $metrics_mapping{$self->{result_values}->{metric}}->{nlabel}->{absolute}, + unit => $metrics_mapping{$self->{result_values}->{metric}}->{unit}, + value => sprintf("%.2f", $self->{result_values}->{value}), + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $metrics_mapping{$self->{result_values}->{metric}}->{label}), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $metrics_mapping{$self->{result_values}->{metric}}->{label}), + ); +} + +sub custom_metric_output { + my ($self, %options) = @_; + my $msg = ""; + + if (defined($self->{instance_mode}->{option_results}->{per_sec})) { + my ($value, $unit) = ($metrics_mapping{$self->{result_values}->{metric}}->{unit} eq 'B') ? + $self->{perfdata}->change_bytes(value => $self->{result_values}->{value_per_sec}) : + ($self->{result_values}->{value_per_sec}, $metrics_mapping{$self->{result_values}->{metric}}->{unit}); + $msg = sprintf("%s: %.2f %s", $metrics_mapping{$self->{result_values}->{metric}}->{output}, $value, $unit . '/s'); + } else { + my ($value, $unit) = ($metrics_mapping{$self->{result_values}->{metric}}->{unit} eq 'B') ? + $self->{perfdata}->change_bytes(value => $self->{result_values}->{value}) : + ($self->{result_values}->{value}, $metrics_mapping{$self->{result_values}->{metric}}->{unit}); + $msg = sprintf("%s: %.2f %s", $metrics_mapping{$self->{result_values}->{metric}}->{output}, $value, $unit); + } + return $msg; +} + +sub custom_metric_output_state { + my ($self, %options) = @_; + my $msg = ""; + + my $value = $self->{result_values}->{value}; + $msg = sprintf("%s: %.2f", $metrics_mapping{$self->{result_values}->{metric}}->{output}, $value); + return $msg; +} + +sub prefix_metric_output { + my ($self, %options) = @_; + + return "'" . $options{instance_value}->{display} . "' "; +} + +sub prefix_statistics_output { + my ($self, %options) = @_; + + return "Statistic '" . $options{instance_value}->{display} . "' Metrics "; +} + +sub long_output { + my ($self, %options) = @_; + + return "AWS VPN Tunnel'" . $options{instance_value}->{display} . "' "; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'metrics', type => 3, cb_prefix_output => 'prefix_metric_output', cb_long_output => 'long_output', + message_multiple => 'All VPN metrics are ok', indent_long_output => ' ', + group => [ + { name => 'statistics', display_long => 1, cb_prefix_output => 'prefix_statistics_output', + message_multiple => 'All metrics are ok', type => 1, skipped_code => { -10 => 1 } }, + ] + } + ]; + + foreach my $metric (keys %metrics_mapping) { + my $entry = { + label => $metrics_mapping{$metric}->{label}, + set => { + key_values => [ { name => $metric }, { name => 'timeframe' }, { name => 'display' } ], + closure_custom_calc => ($metric =~ /State/) ? $self->can('custom_metric_calc_state') : $self->can('custom_metric_calc'), + closure_custom_calc_extra_options => { metric => $metric }, + closure_custom_output => ($metric =~ /State/) ? $self->can('custom_metric_output_state') : $self->can('custom_metric_output'), + closure_custom_perfdata => ($metric =~ /State/) ? $self->can('custom_metric_perfdata_state') : $self->can('custom_metric_perfdata'), + closure_custom_threshold_check => $self->can('custom_metric_threshold'), + } + } + push @{$self->{maps_counters}->{statistics}}, $entry; + } +} + +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 => { + 'vpnid:s@' => { name => 'vpn_id' }, + 'per-sec' => { name => 'per_sec' }, + 'filter-metric:s' => { name => 'filter_metric' } + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + if (!defined($self->{option_results}->{vpn_id}) || $self->{option_results}->{vpn_id} eq '') { + $self->{output}->add_option_msg(short_msg => "Need to specify --vpnid option."); + $self->{output}->option_exit(); + }; + + foreach my $instance (@{$self->{option_results}->{vpn_id}}) { + if ($instance ne '') { + push @{$self->{aws_instance}}, $instance; + }; + } + + $self->{aws_timeframe} = defined($self->{option_results}->{timeframe}) ? $self->{option_results}->{timeframe} : 600; + $self->{aws_period} = defined($self->{option_results}->{period}) ? $self->{option_results}->{period} : 60; + + $self->{aws_statistics} = ['Average']; + if (defined($self->{option_results}->{statistic})) { + $self->{aws_statistics} = []; + foreach my $stat (@{$self->{option_results}->{statistic}}) { + if ($stat ne '') { + push @{$self->{aws_statistics}}, ucfirst(lc($stat)); + } + } + }; + foreach my $metric (keys %metrics_mapping) { + next if (defined($self->{option_results}->{filter_metric}) && $self->{option_results}->{filter_metric} ne '' + && $metric !~ /$self->{option_results}->{filter_metric}/); + push @{$self->{aws_metrics}}, $metric; + }; +} + +sub manage_selection { + my ($self, %options) = @_; + + my %metric_results; + foreach my $instance (@{$self->{aws_instance}}) { + $metric_results{$instance} = $options{custom}->cloudwatch_get_metrics( + region => $self->{option_results}->{region}, + namespace => 'AWS/VPN', + dimensions => [ { Name => 'VpnId', Value => $instance } ], + metrics => $self->{aws_metrics}, + statistics => $self->{aws_statistics}, + timeframe => $self->{aws_timeframe}, + period => $self->{aws_period}, + ); + + foreach my $metric (@{$self->{aws_metrics}}) { + foreach my $statistic (@{$self->{aws_statistics}}) { + next if (!defined($metric_results{$instance}->{$metric}->{lc($statistic)}) && + !defined($self->{option_results}->{zeroed})); + $self->{metrics}->{$instance}->{display} = $instance; + $self->{metrics}->{$instance}->{statistics}->{lc($statistic)}->{display} = $statistic; + $self->{metrics}->{$instance}->{statistics}->{lc($statistic)}->{timeframe} = $self->{aws_timeframe}; + $self->{metrics}->{$instance}->{statistics}->{lc($statistic)}->{$metric} = + defined($metric_results{$instance}->{$metric}->{lc($statistic)}) ? + $metric_results{$instance}->{$metric}->{lc($statistic)} : 0; + } + } + } + + if (scalar(keys %{$self->{metrics}}) <= 0) { + $self->{output}->add_option_msg(short_msg => 'No metrics. Check your options or use --zeroed option to set 0 on undefined values'); + $self->{output}->option_exit(); + } +} + +1; + +__END__ + +=head1 MODE + +Check AWS VPN Connection. + +Example: +perl centreon_plugins.pl --plugin=cloud::aws::vpn::plugin --custommode=awscli --mode=traffic --region='eu-west-1' +--vpnid='vpn-1234567890abcdefg' --warning-tunnel-state='1:' --critical-tunnel-state='0.5:' --warning --verbose + +See 'https://docs.aws.amazon.com/vpn/latest/s2svpn/monitoring-cloudwatch-vpn.html' for more information. + + +=over 8 + +=item B<--vpnid> + +Set the VpnId (Required). + +=item B<--filter-metric> + +Filter on a specific metric. +Can be: TunnelState, TunnelDataIn, TunnelDataOut + +=item B<--warning-$metric$> + +Warning thresholds ($metric$ can be: 'tunnel-state', 'tunnel-datain', 'tunnel-dataout'). + +=item B<--critical-$metric$> + +Critical thresholds ($metric$ can be: 'tunnel-state', 'tunnel-datain', 'tunnel-dataout'). + +=back + +=cut diff --git a/cloud/aws/vpn/plugin.pm b/cloud/aws/vpn/plugin.pm new file mode 100644 index 000000000..208a13de7 --- /dev/null +++ b/cloud/aws/vpn/plugin.pm @@ -0,0 +1,52 @@ +# +# Copyright 2020 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 cloud::aws::vpn::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} } = ( + 'traffic' => 'cloud::aws::vpn::mode::traffic', + 'listvpn' => 'cloud::aws::vpn::mode::listvpn', + 'discovery' => 'cloud::aws::vpn::mode::discovery' + ); + + $self->{custom_modes}{paws} = 'cloud::aws::custom::paws'; + $self->{custom_modes}{awscli} = 'cloud::aws::custom::awscli'; + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Amazon Site-To-Site VPN (Amazon VPN). + +=cut From 58161e8874da83ea721d64ef0adfd85fa0b555c6 Mon Sep 17 00:00:00 2001 From: thibaults-centreon Date: Fri, 10 Apr 2020 14:27:09 +0200 Subject: [PATCH 095/283] add(plugin): AWS VPN --- cloud/aws/vpn/mode/listvpn.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloud/aws/vpn/mode/listvpn.pm b/cloud/aws/vpn/mode/listvpn.pm index ff7fdcfc7..6cb8eb17d 100644 --- a/cloud/aws/vpn/mode/listvpn.pm +++ b/cloud/aws/vpn/mode/listvpn.pm @@ -87,7 +87,7 @@ __END__ =head1 MODE -List EC2 instances. +List VPN instances. =over 8 From 233a8a00dccb54e3d9e9ab69b3257d857f432d48 Mon Sep 17 00:00:00 2001 From: thibaults-centreon Date: Fri, 10 Apr 2020 14:33:55 +0200 Subject: [PATCH 096/283] fix trailing spaces --- cloud/aws/custom/paws.pm | 57 ++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/cloud/aws/custom/paws.pm b/cloud/aws/custom/paws.pm index 030aa81bc..23b06c1d0 100644 --- a/cloud/aws/custom/paws.pm +++ b/cloud/aws/custom/paws.pm @@ -39,6 +39,7 @@ sub new { $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 => { 'aws-secret-key:s' => { name => 'aws_secret_key' }, @@ -52,23 +53,28 @@ sub new { }); } $options{options}->add_help(package => __PACKAGE__, sections => 'PAWS OPTIONS', once => 1); + $self->{output} = $options{output}; $self->{mode} = $options{mode}; + return $self; } sub get_region { my ($self, %options) = @_; + return $self->{option_results}->{region}; } sub set_options { my ($self, %options) = @_; + $self->{option_results} = $options{option_results}; } sub set_defaults { my ($self, %options) = @_; + foreach (keys %{$options{default}}) { if ($_ eq $self->{mode}) { for (my $i = 0; $i < scalar(@{$options{default}->{$_}}); $i++) { @@ -89,16 +95,19 @@ sub check_options { $ENV{HTTP_PROXY} = $self->{option_results}->{proxyurl}; $ENV{HTTPS_PROXY} = $self->{option_results}->{proxyurl}; } + if (defined($self->{option_results}->{aws_secret_key}) && $self->{option_results}->{aws_secret_key} ne '') { $ENV{AWS_SECRET_KEY} = $self->{option_results}->{aws_secret_key}; } if (defined($self->{option_results}->{aws_access_key}) && $self->{option_results}->{aws_access_key} ne '') { $ENV{AWS_ACCESS_KEY} = $self->{option_results}->{aws_access_key}; } + if (!defined($self->{option_results}->{region}) || $self->{option_results}->{region} eq '') { $self->{output}->add_option_msg(short_msg => "Need to specify --region option."); $self->{output}->option_exit(); } + if (defined($self->{option_results}->{statistic})) { foreach my $statistic (@{$self->{option_results}->{statistic}}) { if ($statistic !~ /minimum|maximum|average|sum/) { @@ -107,6 +116,7 @@ sub check_options { } } } + return 0; } @@ -119,6 +129,7 @@ sub cloudwatch_get_metrics { my $cw = Paws->service('CloudWatch', caller => $lwp_caller, region => $options{region}); my $start_time = DateTime->now->subtract(seconds => $options{timeframe})->iso8601; my $end_time = DateTime->now->iso8601; + foreach my $metric_name (@{$options{metrics}}) { my $metric_result = $cw->GetMetricStatistics( MetricName => $metric_name, @@ -131,6 +142,7 @@ sub cloudwatch_get_metrics { #Unit => $unit, Dimensions => $options{dimensions}, ); + $metric_results->{$metric_result->{Label}} = { points => 0 }; foreach my $point (@{$metric_result->{Datapoints}}) { if (defined($point->{Average})) { @@ -149,6 +161,7 @@ sub cloudwatch_get_metrics { $metric_results->{$metric_result->{Label}}->{sum} = 0 if (!defined($metric_results->{$metric_result->{Label}}->{sum})); $metric_results->{$metric_result->{Label}}->{sum} += $point->{Sum}; } + $metric_results->{$metric_result->{Label}}->{points}++; } @@ -161,6 +174,7 @@ sub cloudwatch_get_metrics { $self->{output}->add_option_msg(short_msg => "error: $@"); $self->{output}->option_exit(); } + return $metric_results; } @@ -220,6 +234,7 @@ sub cloudwatch_list_metrics { $self->{output}->add_option_msg(short_msg => "error: $@"); $self->{output}->option_exit(); } + return $metric_results; } @@ -244,6 +259,7 @@ sub cloudwatchlogs_describe_log_groups { $self->{output}->add_option_msg(short_msg => "error: $@"); $self->{output}->option_exit(); } + return $log_groups_results; } @@ -261,6 +277,7 @@ sub cloudwatchlogs_filter_log_events { foreach (@{$list_log_groups->{logGroups}}) { push @$log_groups_results, $_; } + last if (!defined($list_log_groups->{NextToken})); $cw_options{NextToken} = $list_log_groups->{NextToken}; } @@ -269,6 +286,7 @@ sub cloudwatchlogs_filter_log_events { $self->{output}->add_option_msg(short_msg => "error: $@"); $self->{output}->option_exit(); } + return $log_groups_results; } @@ -280,6 +298,7 @@ sub ec2_get_instances_status { my $lwp_caller = new Paws::Net::LWPCaller(); my $ec2 = Paws->service('EC2', caller => $lwp_caller, region => $options{region}); my $instances = $ec2->DescribeInstanceStatus(DryRun => 0, IncludeAllInstances => 1); + foreach (@{$instances->{InstanceStatuses}}) { $instance_results->{$_->{InstanceId}} = { state => $_->{InstanceState}->{Name}, status => => $_->{InstanceStatus}->{Status} }; @@ -301,6 +320,7 @@ sub ec2_list_resources { my $lwp_caller = new Paws::Net::LWPCaller(); my $ec2 = Paws->service('EC2', caller => $lwp_caller, region => $options{region}); my $list_instances = $ec2->DescribeInstances(DryRun => 0); + foreach my $reservation (@{$list_instances->{Reservations}}) { foreach my $instance (@{$reservation->{Instances}}) { my @instance_tags; @@ -308,7 +328,7 @@ sub ec2_list_resources { my %already = map { $_->{Name} => $_ } @{$resource_results}; if ($tag->{Key} eq "aws:autoscaling:groupName") { next if (defined($already{$tag->{Value}})); - push @{$resource_results}, { + push @{$resource_results}, { Name => $tag->{Value}, Type => 'asg', }; @@ -316,7 +336,7 @@ sub ec2_list_resources { push @instance_tags, $tag->{Key} . ":" . $tag->{Value}; } } - push @{$resource_results}, { + push @{$resource_results}, { Name => $instance->{InstanceId}, Type => 'instance', AvailabilityZone => $instance->{Placement}->{AvailabilityZone}, @@ -381,6 +401,7 @@ sub rds_list_instances { my $lwp_caller = new Paws::Net::LWPCaller(); my $rds = Paws->service('RDS', caller => $lwp_caller, region => $options{region}); my $list_instances = $rds->DescribeDBInstances(); + foreach my $instance (@{$list_instances->{DBInstances}}) { push @{$instance_results}, { Name => $instance->{DBInstanceIdentifier}, @@ -395,16 +416,19 @@ sub rds_list_instances { $self->{output}->add_option_msg(short_msg => "error: $@"); $self->{output}->option_exit(); } + return $instance_results; } sub rds_list_clusters { my ($self, %options) = @_; + my $cluster_results = []; eval { my $lwp_caller = new Paws::Net::LWPCaller(); my $rds = Paws->service('RDS', caller => $lwp_caller, region => $options{region}); my $list_clusters = $rds->DescribeDBClusters(); + foreach my $cluster (@{$list_clusters->{DBClusters}}) { push @{$cluster_results}, { Name => $cluster->{DBClusterIdentifier}, @@ -418,6 +442,7 @@ sub rds_list_clusters { $self->{output}->add_option_msg(short_msg => "error: $@"); $self->{output}->option_exit(); } + return $cluster_results; } @@ -453,56 +478,30 @@ sub vpn_list_connections { 1; __END__ - =head1 NAME - Amazon AWS - =head1 SYNOPSIS - Amazon AWS - =head1 PAWS OPTIONS - =over 8 - =item B<--aws-secret-key> - Set AWS secret key. - =item B<--aws-access-key> - Set AWS access key. - =item B<--region> - Set the region name (Required). - =item B<--period> - Set period in seconds. - =item B<--timeframe> - Set timeframe in seconds. - =item B<--statistic> - Set cloudwatch statistics (Can be: 'minimum', 'maximum', 'average', 'sum'). - =item B<--zeroed> - Set metrics value to 0 if none. Usefull when CloudWatch does not return value when not defined. - =item B<--proxyurl> - Proxy URL if any - =back - =head1 DESCRIPTION - B. - -=cut +=cut \ No newline at end of file From e7863c37b92425bf47ba2a0017ddbca15b67dab9 Mon Sep 17 00:00:00 2001 From: thibaults-centreon Date: Fri, 10 Apr 2020 14:38:32 +0200 Subject: [PATCH 097/283] fix help --- cloud/aws/custom/paws.pm | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/cloud/aws/custom/paws.pm b/cloud/aws/custom/paws.pm index 23b06c1d0..cc899ba34 100644 --- a/cloud/aws/custom/paws.pm +++ b/cloud/aws/custom/paws.pm @@ -478,30 +478,57 @@ sub vpn_list_connections { 1; __END__ + =head1 NAME + Amazon AWS + =head1 SYNOPSIS + Amazon AWS + =head1 PAWS OPTIONS + =over 8 + =item B<--aws-secret-key> + Set AWS secret key. + =item B<--aws-access-key> + Set AWS access key. + =item B<--region> + Set the region name (Required). + =item B<--period> + Set period in seconds. + =item B<--timeframe> + Set timeframe in seconds. + =item B<--statistic> -Set cloudwatch statistics (Can be: 'minimum', 'maximum', 'average', 'sum'). + +Set cloudwatch statistics +(Can be: 'minimum', 'maximum', 'average', 'sum'). + =item B<--zeroed> + Set metrics value to 0 if none. Usefull when CloudWatch does not return value when not defined. + =item B<--proxyurl> + Proxy URL if any + =back + =head1 DESCRIPTION + B. + =cut \ No newline at end of file From 1ab8b50cb90b971557ad661a607ac9fe0fba78fc Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 10 Apr 2020 14:52:27 +0200 Subject: [PATCH 098/283] fix help --- storage/hp/3par/ssh/mode/volumeusage.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/hp/3par/ssh/mode/volumeusage.pm b/storage/hp/3par/ssh/mode/volumeusage.pm index b97f8d6e9..e2a5b502a 100644 --- a/storage/hp/3par/ssh/mode/volumeusage.pm +++ b/storage/hp/3par/ssh/mode/volumeusage.pm @@ -156,7 +156,7 @@ Filter volume name (can be a regexp). =item B<--warning-*> B<--critical-*> -Threshold warning. +Thresholds. Can be: 'usage' (B), 'usage-free' (B), 'usage-prct' (%). =back From 9ab973478676af3adfc8e41c50faf4eacf03bcde Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 10 Apr 2020 14:53:05 +0200 Subject: [PATCH 099/283] add ibm bladecenter and lenovo flexsystem snmp plugins --- .../ibm/nos}/snmp/mode/components/faultled.pm | 11 +- .../nos}/snmp/mode/components/temperature.pm | 57 +++++---- .../common/ibm/nos}/snmp/mode/cpu.pm | 26 ++-- .../common/ibm/nos}/snmp/mode/disk.pm | 6 +- .../common/ibm/nos}/snmp/mode/environment.pm | 35 ++++-- .../common/ibm/nos}/snmp/mode/memory.pm | 30 ++--- network/ibm/bladecenter/snmp/mode/disk.pm | 104 ---------------- network/ibm/bladecenter/snmp/plugin.pm | 20 ++-- .../snmp/mode/components/faultled.pm | 9 +- .../snmp/mode/components/temperature.pm | 111 +++++++++++------- network/lenovo/flexsystem/snmp/mode/cpu.pm | 94 ++++++++------- .../flexsystem/snmp/mode/environment.pm | 28 ++++- network/lenovo/flexsystem/snmp/mode/memory.pm | 99 ++++++++-------- network/lenovo/flexsystem/snmp/plugin.pm | 16 +-- 14 files changed, 305 insertions(+), 341 deletions(-) rename {network/ibm/bladecenter => centreon/common/ibm/nos}/snmp/mode/components/faultled.pm (90%) rename {network/ibm/bladecenter => centreon/common/ibm/nos}/snmp/mode/components/temperature.pm (55%) rename {network/ibm/bladecenter => centreon/common/ibm/nos}/snmp/mode/cpu.pm (74%) rename {network/lenovo/flexsystem => centreon/common/ibm/nos}/snmp/mode/disk.pm (95%) rename {network/ibm/bladecenter => centreon/common/ibm/nos}/snmp/mode/environment.pm (69%) rename {network/ibm/bladecenter => centreon/common/ibm/nos}/snmp/mode/memory.pm (82%) delete mode 100644 network/ibm/bladecenter/snmp/mode/disk.pm diff --git a/network/ibm/bladecenter/snmp/mode/components/faultled.pm b/centreon/common/ibm/nos/snmp/mode/components/faultled.pm similarity index 90% rename from network/ibm/bladecenter/snmp/mode/components/faultled.pm rename to centreon/common/ibm/nos/snmp/mode/components/faultled.pm index 7fc415513..f77620cb9 100644 --- a/network/ibm/bladecenter/snmp/mode/components/faultled.pm +++ b/centreon/common/ibm/nos/snmp/mode/components/faultled.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package network::ibm::bladecenter::snmp::mode::components::faultled; +package centreon::common::ibm::nos::snmp::mode::components::faultled; use strict; use warnings; @@ -31,7 +31,7 @@ sub check_faultled { my ($self, %options) = @_; $self->{components}->{faultled}->{total}++; - + $self->{output}->output_add(long_msg => sprintf( "Fault LED state is %s", @@ -52,13 +52,14 @@ sub check_faultled { sub check { my ($self) = @_; - - $self->{output}->output_add(long_msg => "Checking fault LED"); + + $self->{output}->output_add(long_msg => 'checking fault LED'); $self->{components}->{faultled} = { name => 'faultled', total => 0, skip => 0 }; return if ($self->check_filter(section => 'faultled')); my $oid_mmspFaultLED = '.1.3.6.1.4.1.26543.2.5.1.3.10.12.0'; - my $results = $self->{snmp}->get_leef(oids => [$oid_mmspFaultLED], nothing_quit => 1); + my $results = $self->{snmp}->get_leef(oids => [$oid_mmspFaultLED]); + return if (!defined($results->{$oid_mmspFaultLED})); check_faultled($self, value => $map_faultled_states{$results->{$oid_mmspFaultLED}}); } diff --git a/network/ibm/bladecenter/snmp/mode/components/temperature.pm b/centreon/common/ibm/nos/snmp/mode/components/temperature.pm similarity index 55% rename from network/ibm/bladecenter/snmp/mode/components/temperature.pm rename to centreon/common/ibm/nos/snmp/mode/components/temperature.pm index 036fc21be..704bf3121 100644 --- a/network/ibm/bladecenter/snmp/mode/components/temperature.pm +++ b/centreon/common/ibm/nos/snmp/mode/components/temperature.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package network::ibm::bladecenter::snmp::mode::components::temperature; +package centreon::common::ibm::nos::snmp::mode::components::temperature; use strict; use warnings; @@ -27,59 +27,70 @@ sub load {} sub check { my ($self) = @_; - - $self->{output}->output_add(long_msg => "Checking temperatures"); + + $self->{output}->output_add(long_msg => 'checking temperatures'); $self->{components}->{temperature} = { name => 'temperatures', total => 0, skip => 0 }; return if ($self->check_filter(section => 'temperature')); my $oid_hwTemperatureWarn = '.1.3.6.1.4.1.26543.2.5.1.3.1.22.0'; my $oid_hwTemperatureShut = '.1.3.6.1.4.1.26543.2.5.1.3.1.23.0'; - my $results = $self->{snmp}->get_leef(oids => [$oid_hwTemperatureWarn, $oid_hwTemperatureShut], nothing_quit => 1); + my $results = $self->{snmp}->get_leef(oids => [$oid_hwTemperatureWarn, $oid_hwTemperatureShut]); + return if (!defined($results->{$oid_hwTemperatureWarn})); + + my $instance = 'system'; # .1.3.6.1.4.1.20301.2.5.1.3.1.41.1.1.20.1 = STRING: "44 C (Warn at 66 C / Recover at 61 C)" # .1.3.6.1.4.1.20301.2.5.1.3.1.41.1.1.21.1 = STRING: "44 C (Shutdown at 72 C / Recover at 67 C)" $results->{$oid_hwTemperatureWarn} =~ /^([.0-9]+)\s*C\s*\(Warn(?:ing)?\s*at\s*([.0-9]+)\s*C/i; - my $temperature = $1; - my $warning = $2; + my ($temperature, $warning_mib) = ($1, $2); $results->{$oid_hwTemperatureShut} =~ /^([.0-9]+)\s*C\s*\(Shutdown\s*at\s*([.0-9]+)\s*C/i; - if ($1 > $temperature) { - $temperature = $1; - } - my $critical = ($warning + $2) / 2; + $temperature = $1 if ($1 > $temperature); + my $critical_mib = ($warning_mib + $2) / 2; $self->{components}->{temperature}->{total}++; - + $self->{output}->output_add(long_msg => sprintf( - "Temperature is %.1f C", - $temperature + "temperature '%s' is %.1f C [instance: %s]", + $instance, + $temperature, + $instance ) ); - my $exit = 'OK'; - if ($temperature >= $warning) { - $exit = 'WARNING'; - } - if ($temperature >= $critical) { - $exit = 'CRITICAL'; + my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $temperature); + if ($checked == 0) { + $self->{perfdata}->threshold_validate(label => 'warning-temperature-instance-' . $instance, value => $warning_mib); + $self->{perfdata}->threshold_validate(label => 'critical-temperature-instance-' . $instance, value => $critical_mib); + $warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-temperature-instance-' . $instance); + $crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-temperature-instance-' . $instance); + $exit = $self->{perfdata}->threshold_check( + value => $temperature, + threshold => [ + { label => 'critical-temperature-instance-' . $instance, exit_litteral => 'critical' }, + { label => 'warning-temperature-instance-' . $instance, exit_litteral => 'warning' } + ] + ); } + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add( severity => $exit, short_msg => sprintf( - "Temperature is %.1f C", + "Temperature '%s' is %.1f C", + $instance, $temperature ) ); } $self->{output}->perfdata_add( - label => 'temperature', unit => 'C', + unit => 'C', nlabel => 'hardware.temperature.celsius', instances => 'system', value => $temperature, - warning => $warning, - critical => $critical + warning => $warn, + critical => $crit ); } diff --git a/network/ibm/bladecenter/snmp/mode/cpu.pm b/centreon/common/ibm/nos/snmp/mode/cpu.pm similarity index 74% rename from network/ibm/bladecenter/snmp/mode/cpu.pm rename to centreon/common/ibm/nos/snmp/mode/cpu.pm index ef7893af7..4363afd0b 100644 --- a/network/ibm/bladecenter/snmp/mode/cpu.pm +++ b/centreon/common/ibm/nos/snmp/mode/cpu.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package network::ibm::bladecenter::snmp::mode::cpu; +package centreon::common::ibm::nos::snmp::mode::cpu; use base qw(centreon::plugins::templates::counter); @@ -29,25 +29,25 @@ sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ - { name => 'cpu', type => 0, skipped_code => { -10 => 1 } }, + { name => 'cpu', type => 0, skipped_code => { -10 => 1 } } ]; $self->{maps_counters}->{cpu} = [ - { label => 'average', nlabel => 'cpu.utilization.percentage', set => { - key_values => [ { name => 'average' } ], - output_template => '%.2f %%', + { label => 'average-1m', nlabel => 'cpu.utilization.1m.percentage', set => { + key_values => [ { name => 'average_1m' } ], + output_template => 'CPU(s) average usage: %.2f %% (1min)', perfdatas => [ - { label => 'total_cpu_avg', value => 'average_absolute', template => '%.2f', - min => 0, max => 100, unit => '%' }, - ], + { value => 'average_1m_absolute', template => '%.2f', + min => 0, max => 100, unit => '%' } + ] } - }, + } ]; } sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); bless $self, $class; return $self; @@ -60,7 +60,7 @@ sub manage_selection { my $result = $options{snmp}->get_leef(oids => [$oid_mpCpuStatsUtil1Minute], nothing_quit => 1); $self->{cpu} = { - average => $result->{$oid_mpCpuStatsUtil1Minute}, + average_1m => $result->{$oid_mpCpuStatsUtil1Minute} } } @@ -74,11 +74,11 @@ Check CPU usage (over the last minute). =over 8 -=item B<--warning-average> +=item B<--warning-average-1m> Warning threshold average CPU utilization. -=item B<--critical-average> +=item B<--critical-average-1m> Critical threshold average CPU utilization. diff --git a/network/lenovo/flexsystem/snmp/mode/disk.pm b/centreon/common/ibm/nos/snmp/mode/disk.pm similarity index 95% rename from network/lenovo/flexsystem/snmp/mode/disk.pm rename to centreon/common/ibm/nos/snmp/mode/disk.pm index 16ec7a79b..3a08b9161 100644 --- a/network/lenovo/flexsystem/snmp/mode/disk.pm +++ b/centreon/common/ibm/nos/snmp/mode/disk.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package network::lenovo::flexsystem::snmp::mode::disk; +package centreon::common::ibm::nos::snmp::mode::disk; use base qw(snmp_standard::mode::storage); @@ -39,7 +39,7 @@ sub prefix_storage_output { sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); bless $self, $class; return $self; @@ -51,7 +51,7 @@ __END__ =head1 MODE -Check disk. +Check disks. =over 8 diff --git a/network/ibm/bladecenter/snmp/mode/environment.pm b/centreon/common/ibm/nos/snmp/mode/environment.pm similarity index 69% rename from network/ibm/bladecenter/snmp/mode/environment.pm rename to centreon/common/ibm/nos/snmp/mode/environment.pm index 935e17f2d..c61f15ad4 100644 --- a/network/ibm/bladecenter/snmp/mode/environment.pm +++ b/centreon/common/ibm/nos/snmp/mode/environment.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package network::ibm::bladecenter::snmp::mode::environment; +package centreon::common::ibm::nos::snmp::mode::environment; use base qw(centreon::plugins::templates::hardware); @@ -27,32 +27,33 @@ use warnings; sub set_system { my ($self, %options) = @_; - - $self->{regexp_threshold_overload_check_section_option} = '^(faultled|temperature)$'; + + $self->{regexp_threshold_overload_check_section_option} = '^(faultled)$'; + $self->{regexp_threshold_numeric_check_section_option} = '^(?:temperature)$'; $self->{cb_hook2} = 'snmp_execute'; $self->{thresholds} = { 'faultled' => [ ['on', 'CRITICAL'], - ['off', 'OK'], - ], + ['off', 'OK'] + ] }; - $self->{components_path} = 'network::ibm::bladecenter::snmp::mode::components'; + $self->{components_path} = 'centreon::common::ibm::nos::snmp::mode::components'; $self->{components_module} = ['faultled', 'temperature']; } sub snmp_execute { my ($self, %options) = @_; - + $self->{snmp} = $options{snmp}; } sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); bless $self, $class; - + $options{options}->add_options(arguments => { }); @@ -79,6 +80,22 @@ Can be: 'faultled', 'temperature'. Return an error if no compenents are checked. If total (with skipped) is 0. (Default: 'critical' returns). +=item B<--threshold-overload> + +Set to overload default threshold values (syntax: section,status,regexp) +It used before default thresholds (order stays). +Example: --threshold-overload='faulted,WARNING,on' + +=item B<--warning> + +Set warning threshold for temperatures (syntax: type,regexp,threshold) +Example: --warning='temperature,.*,30' + +=item B<--critical> + +Set critical threshold for temperatures (syntax: type,regexp,threshold) +Example: --critical='temperature,.*,40' + =back =cut diff --git a/network/ibm/bladecenter/snmp/mode/memory.pm b/centreon/common/ibm/nos/snmp/mode/memory.pm similarity index 82% rename from network/ibm/bladecenter/snmp/mode/memory.pm rename to centreon/common/ibm/nos/snmp/mode/memory.pm index 35c2279bd..fe9559cbc 100644 --- a/network/ibm/bladecenter/snmp/mode/memory.pm +++ b/centreon/common/ibm/nos/snmp/mode/memory.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package network::ibm::bladecenter::snmp::mode::memory; +package centreon::common::ibm::nos::snmp::mode::memory; use base qw(centreon::plugins::templates::counter); @@ -42,7 +42,7 @@ sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ - { name => 'memory', type => 0, skipped_code => { -10 => 1 } }, + { name => 'memory', type => 0, skipped_code => { -10 => 1 } } ]; $self->{maps_counters}->{memory} = [ @@ -50,35 +50,35 @@ sub set_counters { key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ - { label => 'used', value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute', - unit => 'B', cast_int => 1 }, - ], + { value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute', + unit => 'B', cast_int => 1 } + ] } }, { label => 'usage-free', display_ok => 0, nlabel => 'memory.free.bytes', set => { key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ - { label => 'free', value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute', - unit => 'B', cast_int => 1 }, - ], + { value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute', + unit => 'B', cast_int => 1 } + ] } }, { label => 'usage-prct', display_ok => 0, nlabel => 'memory.usage.percentage', set => { key_values => [ { name => 'prct_used' } ], - output_template => 'Used : %.2f %%', + output_template => 'Ram Used : %.2f %%', perfdatas => [ - { label => 'used_prct', value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, - unit => '%' }, - ], + { value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, + unit => '%' } + ] } - }, + } ]; } sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); bless $self, $class; return $self; @@ -99,7 +99,7 @@ sub manage_selection { used => $total - $free, free => $free, prct_used => $prct_used, - prct_free => 100 - $prct_used, + prct_free => 100 - $prct_used } } diff --git a/network/ibm/bladecenter/snmp/mode/disk.pm b/network/ibm/bladecenter/snmp/mode/disk.pm deleted file mode 100644 index b8466a931..000000000 --- a/network/ibm/bladecenter/snmp/mode/disk.pm +++ /dev/null @@ -1,104 +0,0 @@ -# -# Copyright 2020 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 network::ibm::bladecenter::snmp::mode::disk; - -use base qw(snmp_standard::mode::storage); - -use strict; -use warnings; - -sub default_storage_type { - my ($self, %options) = @_; - - return '^(?!(hrStorageRam)$)'; -} - -sub prefix_storage_output { - my ($self, %options) = @_; - - return "Disk '" . $options{instance_value}->{display} . "' "; -} - -sub new { - my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); - bless $self, $class; - - return $self; -} - -1; - -__END__ - -=head1 MODE - -Check disk. - -=over 8 - -=item B<--warning-usage> - -Threshold warning. - -=item B<--critical-usage> - -Threshold critical. - -=item B<--units> - -Units of thresholds (Default: '%') ('%', 'B'). - -=item B<--free> - -Thresholds are on free space left. - -=item B<--storage> - -Set the storage (number expected) ex: 1, 2,... (empty means 'check all storage'). - -=item B<--name> - -Allows to use storage name with option --storage instead of storage oid index. - -=item B<--regexp> - -Allows to use regexp to filter storage (with option --name). - -=item B<--regexp-isensitive> - -Allows to use regexp non case-sensitive (with --regexp). - -=item B<--reload-cache-time> - -Time in minutes before reloading cache file (default: 180). - -=item B<--show-cache> - -Display cache storage datas. - -=item B<--filter-storage-type> - -Filter storage types with a regexp (Default: '^(?!(hrStorageRam)$)'). - -=back - -=cut diff --git a/network/ibm/bladecenter/snmp/plugin.pm b/network/ibm/bladecenter/snmp/plugin.pm index 4ec79937b..99f935054 100644 --- a/network/ibm/bladecenter/snmp/plugin.pm +++ b/network/ibm/bladecenter/snmp/plugin.pm @@ -30,16 +30,16 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - %{$self->{modes}} = ( - 'cpu' => 'network::ibm::bladecenter::snmp::mode::cpu', - 'disk' => 'network::ibm::bladecenter::snmp::mode::disk', - 'environment' => 'network::ibm::bladecenter::snmp::mode::environment', - 'interfaces' => 'snmp_standard::mode::interfaces', - 'list-interfaces' => 'snmp_standard::mode::listinterfaces', - 'memory' => 'network::ibm::bladecenter::snmp::mode::memory', - 'time' => 'snmp_standard::mode::ntp', - 'uptime' => 'snmp_standard::mode::uptime', - ); + $self->{modes} = { + 'cpu' => 'centreon::common::ibm::nos::snmp::mode::cpu', + 'disk' => 'centreon::common::ibm::nos::snmp::mode::disk', + 'environment' => 'centreon::common::ibm::nos::snmp::mode::environment', + 'interfaces' => 'snmp_standard::mode::interfaces', + 'list-interfaces' => 'snmp_standard::mode::listinterfaces', + 'memory' => 'centreon::common::ibm::nos::snmp::mode::memory', + 'time' => 'snmp_standard::mode::ntp', + 'uptime' => 'snmp_standard::mode::uptime' + }; return $self; } diff --git a/network/lenovo/flexsystem/snmp/mode/components/faultled.pm b/network/lenovo/flexsystem/snmp/mode/components/faultled.pm index b987d1162..d7635308a 100644 --- a/network/lenovo/flexsystem/snmp/mode/components/faultled.pm +++ b/network/lenovo/flexsystem/snmp/mode/components/faultled.pm @@ -31,7 +31,7 @@ sub check_faultled { my ($self, %options) = @_; $self->{components}->{faultled}->{total}++; - + $self->{output}->output_add(long_msg => sprintf( "Fault LED state is %s", @@ -52,13 +52,14 @@ sub check_faultled { sub check { my ($self) = @_; - - $self->{output}->output_add(long_msg => "Checking fault LED"); + + $self->{output}->output_add(long_msg => 'checking fault LED'); $self->{components}->{faultled} = { name => 'faultled', total => 0, skip => 0 }; return if ($self->check_filter(section => 'faultled')); my $oid_mmspFaultLED = '.1.3.6.1.4.1.20301.2.5.1.3.10.12.0'; - my $results = $self->{snmp}->get_leef(oids => [$oid_mmspFaultLED], nothing_quit => 1); + my $results = $self->{snmp}->get_leef(oids => [$oid_mmspFaultLED]); + return if (!defined($results->{$oid_mmspFaultLED})); check_faultled($self, value => $map_faultled_states{$results->{$oid_mmspFaultLED}}); } diff --git a/network/lenovo/flexsystem/snmp/mode/components/temperature.pm b/network/lenovo/flexsystem/snmp/mode/components/temperature.pm index 3fb804d38..76bc6ca46 100644 --- a/network/lenovo/flexsystem/snmp/mode/components/temperature.pm +++ b/network/lenovo/flexsystem/snmp/mode/components/temperature.pm @@ -23,64 +23,85 @@ package network::lenovo::flexsystem::snmp::mode::components::temperature; use strict; use warnings; -sub load {} +my $mapping = { + hwInfoTemperatureWarn => { oid => '.1.3.6.1.4.1.20301.2.5.1.3.1.41.1.1.20' }, # "44 C (Warning at 66 C / Recover at 61 C)" + hwInfoTemperatureShut => { oid => '.1.3.6.1.4.1.20301.2.5.1.3.1.41.1.1.21' }, # "44 C (Shutdown at 72 C / Recover at 67 C)" +}; +my $oid_hwInfoTableEntry = '.1.3.6.1.4.1.20301.2.5.1.3.1.41.1.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { + oid => $oid_hwInfoTableEntry, + start => $mapping->{hwInfoTemperatureWarn}->{oid}, + end => $mapping->{hwInfoTemperatureShut}->{oid} + }; +} sub check { my ($self) = @_; - - $self->{output}->output_add(long_msg => "Checking temperatures"); + + $self->{output}->output_add(long_msg => "checking temperatures"); $self->{components}->{temperature} = { name => 'temperatures', total => 0, skip => 0 }; return if ($self->check_filter(section => 'temperature')); - my $oid_hwTemperatureWarn = '.1.3.6.1.4.1.20301.2.5.1.3.1.22.0'; - my $oid_hwTemperatureShut = '.1.3.6.1.4.1.20301.2.5.1.3.1.23.0'; - my $results = $self->{snmp}->get_leef(oids => [$oid_hwTemperatureWarn, $oid_hwTemperatureShut], nothing_quit => 1); + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_hwInfoTableEntry}})) { + next if ($oid !~ /^$mapping->{hwInfoTemperatureShut}->{oid}\.(\d+)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_hwInfoTableEntry}, instance => $instance); - # .1.3.6.1.4.1.20301.2.5.1.3.1.41.1.1.20.1 = STRING: "44 C (Warning at 66 C / Recover at 61 C)" - # .1.3.6.1.4.1.20301.2.5.1.3.1.41.1.1.21.1 = STRING: "44 C (Shutdown at 72 C / Recover at 67 C)" - $results->{$oid_hwTemperatureWarn} =~ /^([.0-9]+)\s*C\s*\(Warn(?:ing)?\s*at\s*([.0-9]+)\s*C/i; - my $temperature = $1; - my $warning = $2; - $results->{$oid_hwTemperatureShut} =~ /^([.0-9]+)\s*C\s*\(Shutdown\s*at\s*([.0-9]+)\s*C/i; - if ($1 > $temperature) { - $temperature = $1; - } - my $critical = ($warning + $2) / 2; + next if ($self->check_filter(section => 'temperature', instance => $instance)); + $self->{components}->{temperature}->{total}++; - $self->{components}->{temperature}->{total}++; - - $self->{output}->output_add(long_msg => - sprintf( - "Temperature is %.1f C", - $temperature - ) - ); + $result->{hwInfoTemperatureWarn} =~ /^([.0-9]+)\s*C\s*\(Warn(?:ing)?\s*at\s*([.0-9]+)\s*C/i; + my ($temperature, $warning_mib) = ($1, $2); + $result->{hwInfoTemperatureShut} =~ /^([.0-9]+)\s*C\s*\(Shutdown\s*at\s*([.0-9]+)\s*C/i; + $temperature = $1 if ($1 > $temperature); + my $critical_mib = ($warning_mib + $2) / 2; - my $exit = 'OK'; - if ($temperature >= $warning) { - $exit = 'WARNING'; - } - if ($temperature >= $critical) { - $exit = 'CRITICAL'; - } - if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add( - severity => $exit, - short_msg => sprintf( - "Temperature is %.1f C", - $temperature + long_msg => sprintf( + "temperature switch '%s' is %s C [instance: %s]", + $instance, + $temperature, + $instance ) ); - } - $self->{output}->perfdata_add( - label => 'temperature', unit => 'C', - nlabel => 'hardware.temperature.celsius', - instances => 'system', - value => $temperature, - warning => $warning, - critical => $critical - ); + my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $temperature); + if ($checked == 0) { + $self->{perfdata}->threshold_validate(label => 'warning-temperature-instance-' . $instance, value => $warning_mib); + $self->{perfdata}->threshold_validate(label => 'critical-temperature-instance-' . $instance, value => $critical_mib); + $warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-temperature-instance-' . $instance); + $crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-temperature-instance-' . $instance); + $exit = $self->{perfdata}->threshold_check( + value => $temperature, + threshold => [ + { label => 'critical-temperature-instance-' . $instance, exit_litteral => 'critical' }, + { label => 'warning-temperature-instance-' . $instance, exit_litteral => 'warning' } + ] + ); + } + + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "temperature switch '%s' is %s C", + $instance, + $temperature + ) + ); + } + $self->{output}->perfdata_add( + nlabel => 'hardware.temperature.celsius', unit => 'C', + instances => 'switch=' . $instance, + value => $temperature, + warning => $warn, + critical => $crit + ); + } } 1; diff --git a/network/lenovo/flexsystem/snmp/mode/cpu.pm b/network/lenovo/flexsystem/snmp/mode/cpu.pm index c17707bcb..c297f0eb3 100644 --- a/network/lenovo/flexsystem/snmp/mode/cpu.pm +++ b/network/lenovo/flexsystem/snmp/mode/cpu.pm @@ -29,73 +29,80 @@ sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ - { name => 'cpu', type => 1, cb_prefix_output => 'prefix_message_output', message_multiple => 'All CPU usages are ok' }, + { name => 'cpu', type => 1, cb_prefix_output => 'prefix_message_output', message_multiple => 'All CPU usages are ok' } ]; $self->{maps_counters}->{cpu} = [ - { label => 'average', nlabel => 'cpu.utilization.percentage', set => { - key_values => [ { name => 'average' }, { name => 'display' } ], - output_template => '%.2f %%', + { label => 'average-1min', nlabel => 'switch.cpu.utilization.1min.percentage', set => { + key_values => [ { name => 'average_1min' }, { name => 'display' } ], + output_template => '%.2f %% (1min)', perfdatas => [ - { label => 'total_cpu_avg', value => 'average_absolute', template => '%.2f', - min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' }, - ], + { value => 'average_1min_absolute', template => '%.2f', + min => 0, max => 100, unit => '%', label_extra_instance => 1 } + ] } }, + { label => 'average-5min', nlabel => 'switch.cpu.utilization.5min.percentage', set => { + key_values => [ { name => 'average_5min' }, { name => 'display' } ], + output_template => '%.2f %% (5min)', + perfdatas => [ + { value => 'average_5min_absolute', template => '%.2f', + min => 0, max => 100, unit => '%', label_extra_instance => 1 } + ] + } + } ]; } sub prefix_message_output { my ($self, %options) = @_; - return "Switch '" . $options{instance_value}->{display} . "' "; + return "Switch '" . $options{instance_value}->{display} . "' CPU average usage: "; } sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); bless $self, $class; $options{options}->add_options(arguments => { - 'filter:s' => { name => 'filter', default => '.*' } + 'filter-switch-num:s' => { name => 'filter_switch_num' } }); return $self; } +my $mapping = { + average_1min => { oid => '.1.3.6.1.4.1.20301.2.5.1.2.2.12.1.1.5' }, # mpCpuStatsUtil1MinuteSwRev + average_5min => { oid => '.1.3.6.1.4.1.20301.2.5.1.2.2.12.1.1.6' } # mpCpuStatsUtil5MinutesSwRev +}; + +my $oid_mpCpuStatsRevTableEntry = '.1.3.6.1.4.1.20301.2.5.1.2.2.12.1.1'; + sub manage_selection { my ($self, %options) = @_; - my $oid_mpCpuSwitchNumberRev = '.1.3.6.1.4.1.20301.2.5.1.2.2.12.1.1.1'; - my $oid_mpCpuStatsUtil1MinuteSwRev = '.1.3.6.1.4.1.20301.2.5.1.2.2.12.1.1.5'; - - my $result = $options{snmp}->get_table(oid => $oid_mpCpuSwitchNumberRev, nothing_quit => 1); - my @instance_oids = (); - foreach my $oid (keys %$result) { - if ($result->{$oid} =~ /$self->{option_results}->{filter}/i) { - push @instance_oids, $oid; - } - } - - if (scalar(@instance_oids) == 0) { - $self->{output}->add_option_msg(short_msg => "Cannot find switch number '$self->{option_results}->{filter}'."); - $self->{output}->option_exit(); - } - - $options{snmp}->load( - oids => [$oid_mpCpuStatsUtil1MinuteSwRev], - instances => \@instance_oids, - instance_regexp => "^" . $oid_mpCpuSwitchNumberRev . '\.(.+)' + my $snmp_result = $options{snmp}->get_table( + oid => $oid_mpCpuStatsRevTableEntry, + start => $mapping->{average_1min}->{oid}, + nothing_quit => 1 ); - my $result2 = $options{snmp}->get_leef(); - foreach my $instance (@instance_oids) { - $instance =~ /^$oid_mpCpuSwitchNumberRev\.(.+)/; - $instance = $1; - + $self->{cpu} = {}; + foreach my $oid (keys %$snmp_result) { + next if ($oid !~ /^$mapping->{average_1min}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance); + + if (defined($self->{option_results}->{filter_switch_num}) && $self->{option_results}->{filter_switch_num} ne '' && + $instance !~ /$self->{option_results}->{filter_switch_num}/) { + $self->{output}->output_add(long_msg => "skipping member '" . $instance . "': no matching filter.", debug => 1); + next; + } + $self->{cpu}->{$instance} = { - display => $result->{$oid_mpCpuSwitchNumberRev . '.' . $instance}, - average => $result2->{$oid_mpCpuStatsUtil1MinuteSwRev . '.' . $instance}, + display => $instance, + %$result }; } } @@ -110,17 +117,14 @@ Check CPU usage (over the last minute). =over 8 -=item B<--filter> +=item B<--filter-switch-num> -Filter switch number (Default: '.*'). +Filter switch number. -=item B<--warning-average> +=item B<--warning-*> B<--critical-*> -Warning threshold average CPU utilization. - -=item B<--critical-average> - -Critical threshold average CPU utilization. +Thresholds. +Can be: 'average-1min' (%), 'average-5min' (%). =back diff --git a/network/lenovo/flexsystem/snmp/mode/environment.pm b/network/lenovo/flexsystem/snmp/mode/environment.pm index 632d32a71..ff39352e7 100644 --- a/network/lenovo/flexsystem/snmp/mode/environment.pm +++ b/network/lenovo/flexsystem/snmp/mode/environment.pm @@ -27,15 +27,16 @@ use warnings; sub set_system { my ($self, %options) = @_; - - $self->{regexp_threshold_overload_check_section_option} = '^(faultled|temperature)$'; + + $self->{regexp_threshold_overload_check_section_option} = '^(?:faultled)$'; + $self->{regexp_threshold_numeric_check_section_option} = '^(?:temperature)$'; $self->{cb_hook2} = 'snmp_execute'; $self->{thresholds} = { 'faultled' => [ ['on', 'CRITICAL'], - ['off', 'OK'], - ], + ['off', 'OK'] + ] }; $self->{components_path} = 'network::lenovo::flexsystem::snmp::mode::components'; @@ -46,11 +47,12 @@ sub snmp_execute { my ($self, %options) = @_; $self->{snmp} = $options{snmp}; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); } sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); bless $self, $class; $options{options}->add_options(arguments => { @@ -79,6 +81,22 @@ Can be: 'faultled', 'temperature'. Return an error if no compenents are checked. If total (with skipped) is 0. (Default: 'critical' returns). +=item B<--threshold-overload> + +Set to overload default threshold values (syntax: section,status,regexp) +It used before default thresholds (order stays). +Example: --threshold-overload='faulted,WARNING,on' + +=item B<--warning> + +Set warning threshold for temperatures (syntax: type,regexp,threshold) +Example: --warning='temperature,.*,30' + +=item B<--critical> + +Set critical threshold for temperatures (syntax: type,regexp,threshold) +Example: --critical='temperature,.*,40' + =back =cut diff --git a/network/lenovo/flexsystem/snmp/mode/memory.pm b/network/lenovo/flexsystem/snmp/mode/memory.pm index 232a2c98e..c3eae2c60 100644 --- a/network/lenovo/flexsystem/snmp/mode/memory.pm +++ b/network/lenovo/flexsystem/snmp/mode/memory.pm @@ -46,33 +46,33 @@ sub set_counters { ]; $self->{maps_counters}->{memory} = [ - { label => 'usage', nlabel => 'memory.usage.bytes', set => { + { label => 'usage', nlabel => 'switch.memory.usage.bytes', set => { key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'display' } ], closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ - { label => 'used', value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute', - unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' }, - ], + { value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute', + unit => 'B', cast_int => 1, label_extra_instance => 1 } + ] } }, - { label => 'usage-free', display_ok => 0, nlabel => 'memory.free.bytes', set => { - key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], + { label => 'usage-free', display_ok => 0, nlabel => 'switch.memory.free.bytes', set => { + key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'display' } ], closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ - { label => 'free', value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute', - unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' }, - ], + { value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute', + unit => 'B', cast_int => 1, label_extra_instance => 1 } + ] } }, - { label => 'usage-prct', display_ok => 0, nlabel => 'memory.usage.percentage', set => { - key_values => [ { name => 'prct_used' } ], - output_template => 'Used : %.2f %%', + { label => 'usage-prct', display_ok => 0, nlabel => 'switch.memory.usage.percentage', set => { + key_values => [ { name => 'prct_used' }, { name => 'display' } ], + output_template => 'Ram Used : %.2f %%', perfdatas => [ - { label => 'used_prct', value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, - unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' }, - ], + { value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, + unit => '%', label_extra_instance => 1 } + ] } - }, + } ]; } @@ -84,57 +84,52 @@ sub prefix_message_output { sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); bless $self, $class; $options{options}->add_options(arguments => { - 'filter:s' => { name => 'filter', default => '.*' } + 'filter-switch-num:s' => { name => 'filter_switch_num' } }); return $self; } +my $mapping = { + total => { oid => '.1.3.6.1.4.1.20301.2.5.1.2.12.9.1.1.3' }, # totalMemoryStatsRev + free => { oid => '.1.3.6.1.4.1.20301.2.5.1.2.12.9.1.1.4' } # memoryFreeStatsRev +}; + +my $oid_memoryStatsEntry = '.1.3.6.1.4.1.20301.2.5.1.2.12.9.1.1'; + sub manage_selection { my ($self, %options) = @_; - my $oid_switchNumber = '.1.3.6.1.4.1.20301.2.5.1.2.12.9.1.1.1'; - my $oid_totalMemoryStatsRev = '.1.3.6.1.4.1.20301.2.5.1.2.12.9.1.1.3'; # in bytes - my $oid_memoryFreeStatsRev = '.1.3.6.1.4.1.20301.2.5.1.2.12.9.1.1.4'; # in bytes - - my $result = $options{snmp}->get_table(oid => $oid_switchNumber, nothing_quit => 1); - my @instance_oids = (); - foreach my $oid (keys %$result) { - if ($result->{$oid} =~ /$self->{option_results}->{filter}/i) { - push @instance_oids, $oid; - } - } - - if (scalar(@instance_oids) == 0) { - $self->{output}->add_option_msg(short_msg => "Cannot find switch number '$self->{option_results}->{filter}'."); - $self->{output}->option_exit(); - } - - $options{snmp}->load( - oids => [$oid_totalMemoryStatsRev, $oid_memoryFreeStatsRev], - instances => \@instance_oids, - instance_regexp => "^" . $oid_switchNumber . '\.(.+)' + my $snmp_result = $options{snmp}->get_table( + oid => $oid_memoryStatsEntry, + start => $mapping->{total}->{oid}, + end => $mapping->{free}->{oid}, + nothing_quit => 1 ); - my $result2 = $options{snmp}->get_leef(); - foreach my $instance (@instance_oids) { - $instance =~ /^$oid_switchNumber\.(.+)/; - $instance = $1; + $self->{memory} = {}; + foreach my $oid (keys %$snmp_result) { + next if ($oid !~ /^$mapping->{free}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance); - my $free = $result2->{$oid_memoryFreeStatsRev . '.' . $instance}; - my $total = $result2->{$oid_totalMemoryStatsRev . '.' . $instance}; - my $prct_used = ($total - $free) * 100 / $total; + if (defined($self->{option_results}->{filter_switch_num}) && $self->{option_results}->{filter_switch_num} ne '' && + $instance !~ /$self->{option_results}->{filter_switch_num}/) { + $self->{output}->output_add(long_msg => "skipping member '" . $instance . "': no matching filter.", debug => 1); + next; + } + + my $prct_used = ($result->{total} - $result->{free}) * 100 / $result->{total}; $self->{memory}->{$instance} = { - display => $result->{$oid_switchNumber . '.' . $instance}, - total => $total, - used => $total - $free, - free => $free, + display => $instance, prct_used => $prct_used, prct_free => 100 - $prct_used, + used => $result->{total} - $result->{free}, + %$result }; } } @@ -149,9 +144,9 @@ Check memory usage. =over 8 -=item B<--filter> +=item B<--filter-switch-num> -Filter switch number (Default: '.*'). +Filter switch number. =item B<--warning-*> B<--critical-*> diff --git a/network/lenovo/flexsystem/snmp/plugin.pm b/network/lenovo/flexsystem/snmp/plugin.pm index 15dfa65b6..e8a4cbf1b 100644 --- a/network/lenovo/flexsystem/snmp/plugin.pm +++ b/network/lenovo/flexsystem/snmp/plugin.pm @@ -31,14 +31,14 @@ sub new { $self->{version} = '1.0'; %{$self->{modes}} = ( - 'cpu' => 'network::lenovo::flexsystem::snmp::mode::cpu', - 'disk' => 'network::lenovo::flexsystem::snmp::mode::disk', - 'environment' => 'network::lenovo::flexsystem::snmp::mode::environment', - 'interfaces' => 'snmp_standard::mode::interfaces', - 'list-interfaces' => 'snmp_standard::mode::listinterfaces', - 'memory' => 'network::lenovo::flexsystem::snmp::mode::memory', - 'time' => 'snmp_standard::mode::ntp', - 'uptime' => 'snmp_standard::mode::uptime', + 'cpu' => 'network::lenovo::flexsystem::snmp::mode::cpu', + 'disk' => 'centreon::common::ibm::nos::snmp::mode::disk', + 'environment' => 'network::lenovo::flexsystem::snmp::mode::environment', + 'interfaces' => 'snmp_standard::mode::interfaces', + 'list-interfaces' => 'snmp_standard::mode::listinterfaces', + 'memory' => 'network::lenovo::flexsystem::snmp::mode::memory', + 'time' => 'snmp_standard::mode::ntp', + 'uptime' => 'snmp_standard::mode::uptime', ); return $self; From 1bc2036a969a8f086369d51263707cea49223042 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 10 Apr 2020 14:56:38 +0200 Subject: [PATCH 100/283] small indent fix --- cloud/aws/vpn/mode/listvpn.pm | 6 ++++-- cloud/aws/vpn/mode/traffic.pm | 23 +++++++++++------------ 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/cloud/aws/vpn/mode/listvpn.pm b/cloud/aws/vpn/mode/listvpn.pm index 6cb8eb17d..6499d94e9 100644 --- a/cloud/aws/vpn/mode/listvpn.pm +++ b/cloud/aws/vpn/mode/listvpn.pm @@ -56,8 +56,10 @@ sub run { $_->{id}, $_->{name}, $_->{state} )); } - $self->{output}->output_add(severity => 'OK', - short_msg => 'List VPN connections:'); + $self->{output}->output_add( + severity => 'OK', + short_msg => 'List VPN connections:' + ); $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1); $self->{output}->exit(); } diff --git a/cloud/aws/vpn/mode/traffic.pm b/cloud/aws/vpn/mode/traffic.pm index d23cd5552..7e8e458d9 100644 --- a/cloud/aws/vpn/mode/traffic.pm +++ b/cloud/aws/vpn/mode/traffic.pm @@ -29,8 +29,7 @@ my %metrics_mapping = ( 'TunnelState' => { 'output' => 'Tunnel State', 'label' => 'tunnel-state', - 'nlabel' => { - 'absolute' => 'vpn.tunnel.tunnelstate'}, + 'nlabel' => { 'absolute' => 'vpn.tunnel.tunnelstate' }, 'unit' => '' }, 'TunnelDataIn' => { @@ -38,7 +37,7 @@ my %metrics_mapping = ( 'label' => 'tunnel-datain', 'nlabel' => { 'absolute' => 'vpn.tunnel.datain.bytes', - 'per_second' => 'vpn.tunnel.datain.bytespersecond', + 'per_second' => 'vpn.tunnel.datain.bytespersecond' }, 'unit' => 'B' }, @@ -47,7 +46,7 @@ my %metrics_mapping = ( 'label' => 'tunnel-dataout', 'nlabel' => { 'absolute' => 'vpn.tunnel.dataout.bytes', - 'per_second' => 'vpn.tunnel.dataout.bytespersecond', + 'per_second' => 'vpn.tunnel.dataout.bytespersecond' }, 'unit' => 'B' } @@ -79,8 +78,10 @@ sub custom_metric_threshold { my $exit = $self->{perfdata}->threshold_check( value => defined($self->{instance_mode}->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value}, - threshold => [ { label => 'critical-' . $metrics_mapping{$self->{result_values}->{metric}}->{label} , exit_litteral => 'critical' }, - { label => 'warning-' . $metrics_mapping{$self->{result_values}->{metric}}->{label}, exit_litteral => 'warning' } ] + threshold => [ + { label => 'critical-' . $metrics_mapping{$self->{result_values}->{metric}}->{label} , exit_litteral => 'critical' }, + { label => 'warning-' . $metrics_mapping{$self->{result_values}->{metric}}->{label}, exit_litteral => 'warning' } + ] ); return $exit; } @@ -139,11 +140,9 @@ sub custom_metric_output { sub custom_metric_output_state { my ($self, %options) = @_; - my $msg = ""; my $value = $self->{result_values}->{value}; - $msg = sprintf("%s: %.2f", $metrics_mapping{$self->{result_values}->{metric}}->{output}, $value); - return $msg; + return sprintf("%s: %.2f", $metrics_mapping{$self->{result_values}->{metric}}->{output}, $value); } sub prefix_metric_output { @@ -199,9 +198,9 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - 'vpnid:s@' => { name => 'vpn_id' }, - 'per-sec' => { name => 'per_sec' }, - 'filter-metric:s' => { name => 'filter_metric' } + 'vpnid:s@' => { name => 'vpn_id' }, + 'per-sec' => { name => 'per_sec' }, + 'filter-metric:s' => { name => 'filter_metric' } }); return $self; From c8f769880ae61cbcf7fac1eed0df1abaa9015cfb Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 10 Apr 2020 15:06:55 +0200 Subject: [PATCH 101/283] add --only-show-errors for azure cli --- cloud/azure/custom/azcli.pm | 76 ++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 35 deletions(-) diff --git a/cloud/azure/custom/azcli.pm b/cloud/azure/custom/azcli.pm index 5ae02540e..81dde133d 100644 --- a/cloud/azure/custom/azcli.pm +++ b/cloud/azure/custom/azcli.pm @@ -41,20 +41,20 @@ sub new { if (!defined($options{noptions})) { $options{options}->add_options(arguments => { - "subscription:s" => { name => 'subscription' }, - "tenant:s" => { name => 'tenant' }, - "client-id:s" => { name => 'client_id' }, - "client-secret:s" => { name => 'client_secret' }, - "timeframe:s" => { name => 'timeframe' }, - "interval:s" => { name => 'interval' }, - "aggregation:s@" => { name => 'aggregation' }, - "zeroed" => { name => 'zeroed' }, - "timeout:s" => { name => 'timeout', default => 50 }, - "sudo" => { name => 'sudo' }, - "command:s" => { name => 'command', default => 'az' }, - "command-path:s" => { name => 'command_path' }, - "command-options:s" => { name => 'command_options', default => '' }, - "proxyurl:s" => { name => 'proxyurl' }, + 'subscription:s' => { name => 'subscription' }, + 'tenant:s' => { name => 'tenant' }, + 'client-id:s' => { name => 'client_id' }, + 'client-secret:s' => { name => 'client_secret' }, + 'timeframe:s' => { name => 'timeframe' }, + 'interval:s' => { name => 'interval' }, + 'aggregation:s@' => { name => 'aggregation' }, + 'zeroed' => { name => 'zeroed' }, + 'timeout:s' => { name => 'timeout', default => 50 }, + 'sudo' => { name => 'sudo' }, + 'command:s' => { name => 'command', default => 'az' }, + 'command-path:s' => { name => 'command_path' }, + 'command-options:s' => { name => 'command_options', default => '' }, + 'proxyurl:s' => { name => 'proxyurl' }, }); } $options{options}->add_help(package => __PACKAGE__, sections => 'AZCLI OPTIONS', once => 1); @@ -141,15 +141,21 @@ sub convert_duration { my $duration; if ($options{time_string} =~ /^P.*S$/) { - centreon::plugins::misc::mymodule_load(output => $self->{output}, module => 'DateTime::Format::Duration::ISO8601', - error_msg => "Cannot load module 'DateTime::Format::Duration::ISO8601'."); + centreon::plugins::misc::mymodule_load( + output => $self->{output}, + module => 'DateTime::Format::Duration::ISO8601', + error_msg => "Cannot load module 'DateTime::Format::Duration::ISO8601'." + ); my $format = DateTime::Format::Duration::ISO8601->new; my $d = $format->parse_duration($options{time_string}); $duration = $d->minutes * 60 + $d->seconds; } elsif ($options{time_string} =~ /^(\d+):(\d+):(\d+)\.\d+$/) { - centreon::plugins::misc::mymodule_load(output => $self->{output}, module => 'DateTime::Duration', - error_msg => "Cannot load module 'DateTime::Format::Duration'."); + centreon::plugins::misc::mymodule_load( + output => $self->{output}, + module => 'DateTime::Duration', + error_msg => "Cannot load module 'DateTime::Format::Duration'." + ); my $d = DateTime::Duration->new(hours => $1, minutes => $2, seconds => $3); $duration = $d->minutes * 60 + $d->seconds; @@ -162,9 +168,9 @@ sub azure_get_metrics_set_cmd { my ($self, %options) = @_; return if (defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne ''); - + my $cmd_options = "monitor metrics list --metrics '" . join('\' \'', @{$options{metrics}}) . "' --start-time $options{start_time} --end-time $options{end_time} " . - "--interval $options{interval} --aggregation '" . join('\' \'', @{$options{aggregations}}) . "' --output json --resource '$options{resource}' " . + "--interval $options{interval} --aggregation '" . join('\' \'', @{$options{aggregations}}) . "' --only-show-errors --output json --resource '$options{resource}' " . "--resource-group '$options{resource_group}' --resource-type '$options{resource_type}' --resource-namespace '$options{resource_namespace}'"; $cmd_options .= " --subscription '$self->{subscription}'" if (defined($self->{subscription}) && $self->{subscription} ne ''); @@ -222,7 +228,7 @@ sub azure_list_resources_set_cmd { return if (defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne ''); - my $cmd_options = "resource list --output json"; + my $cmd_options = "resource list --only-show-errors --output json"; $cmd_options .= " --namespace '$options{namespace}'" if (defined($options{namespace}) && $options{namespace} ne ''); $cmd_options .= " --resource-type '$options{resource_type}'" if (defined($options{resource_type}) && $options{resource_type} ne ''); $cmd_options .= " --location '$options{location}'" if (defined($options{location}) && $options{location} ne ''); @@ -246,7 +252,7 @@ sub azure_list_vm_sizes_set_cmd { return if (defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne ''); - my $cmd_options = "vm list-sizes --location '$options{location}' --output json"; + my $cmd_options = "vm list-sizes --location '$options{location}' --only-show-errors --output json"; $cmd_options .= " --subscription '$self->{subscription}'" if (defined($self->{subscription}) && $self->{subscription} ne ''); return $cmd_options; @@ -266,7 +272,7 @@ sub azure_list_vms_set_cmd { return if (defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne ''); - my $cmd_options = "vm list --output json"; + my $cmd_options = "vm list --only-show-errors --output json"; $cmd_options .= " --resource-group '$options{resource_group}'" if (defined($options{resource_group}) && $options{resource_group} ne ''); $cmd_options .= " --show-details" if (defined($options{show_details})); $cmd_options .= " --subscription '$self->{subscription}'" if (defined($self->{subscription}) && $self->{subscription} ne ''); @@ -288,7 +294,7 @@ sub azure_list_groups_set_cmd { return if (defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne ''); - my $cmd_options = "group list --output json"; + my $cmd_options = "group list --only-show-errors --output json"; $cmd_options .= " --subscription '$self->{subscription}'" if (defined($self->{subscription}) && $self->{subscription} ne ''); return $cmd_options; @@ -308,7 +314,7 @@ sub azure_list_deployments_set_cmd { return if (defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne ''); - my $cmd_options = "group deployment list --resource-group '$options{resource_group}' --output json"; + my $cmd_options = "group deployment list --resource-group '$options{resource_group}' --only-show-errors --output json"; $cmd_options .= " --subscription '$self->{subscription}'" if (defined($self->{subscription}) && $self->{subscription} ne ''); return $cmd_options; @@ -328,7 +334,7 @@ sub azure_list_vaults_set_cmd { return if (defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne ''); - my $cmd_options = "backup vault list --output json"; + my $cmd_options = "backup vault list --only-show-errors --output json"; $cmd_options .= " --resource-group '$options{resource_group}'" if (defined($options{resource_group}) && $options{resource_group} ne ''); $cmd_options .= " --subscription '$self->{subscription}'" if (defined($self->{subscription}) && $self->{subscription} ne ''); @@ -349,7 +355,7 @@ sub azure_list_backup_jobs_set_cmd { return if (defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne ''); - my $cmd_options = "backup job list --resource-group '$options{resource_group}' --vault-name '$options{vault_name}' --output json"; + my $cmd_options = "backup job list --resource-group '$options{resource_group}' --vault-name '$options{vault_name}' --only-show-errors --output json"; $cmd_options .= " --subscription '$self->{subscription}'" if (defined($self->{subscription}) && $self->{subscription} ne ''); return $cmd_options; @@ -369,7 +375,7 @@ sub azure_list_backup_items_set_cmd { return if (defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne ''); - my $cmd_options = "backup item list --resource-group '$options{resource_group}' --vault-name '$options{vault_name}' --output json"; + my $cmd_options = "backup item list --resource-group '$options{resource_group}' --vault-name '$options{vault_name}' --only-show-errors --output json"; $cmd_options .= " --subscription '$self->{subscription}'" if (defined($self->{subscription}) && $self->{subscription} ne ''); return $cmd_options; @@ -389,7 +395,7 @@ sub azure_list_expressroute_circuits_set_cmd { return if (defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne ''); - my $cmd_options = "network express-route list --output json"; + my $cmd_options = "network express-route list --only-show-errors --output json"; $cmd_options .= " --resource-group '$options{resource_group}'" if (defined($options{resource_group}) && $options{resource_group} ne ''); $cmd_options .= " --subscription '$self->{subscription}'" if (defined($self->{subscription}) && $self->{subscription} ne ''); @@ -410,7 +416,7 @@ sub azure_list_vpn_gateways_set_cmd { return if (defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne ''); - my $cmd_options = "network vnet-gateway list --resource-group '$options{resource_group}' --output json"; + my $cmd_options = "network vnet-gateway list --resource-group '$options{resource_group}' --only-show-errors --output json"; $cmd_options .= " --subscription '$self->{subscription}'" if (defined($self->{subscription}) && $self->{subscription} ne ''); return $cmd_options; @@ -430,7 +436,7 @@ sub azure_list_virtualnetworks_set_cmd { return if (defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne ''); - my $cmd_options = "network vnet list --output json"; + my $cmd_options = "network vnet list --only-show-errors --output json"; $cmd_options .= " --resource-group '$options{resource_group}'" if (defined($options{resource_group}) && $options{resource_group} ne ''); $cmd_options .= " --subscription '$self->{subscription}'" if (defined($self->{subscription}) && $self->{subscription} ne ''); @@ -451,7 +457,7 @@ sub azure_list_vnet_peerings_set_cmd { return if (defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne ''); - my $cmd_options = "network vnet peering list --resource-group '$options{resource_group}' --vnet-name '$options{vnet_name}' --output json"; + my $cmd_options = "network vnet peering list --resource-group '$options{resource_group}' --vnet-name '$options{vnet_name}' --only-show-errors --output json"; $cmd_options .= " --subscription '$self->{subscription}'" if (defined($self->{subscription}) && $self->{subscription} ne ''); return $cmd_options; @@ -471,7 +477,7 @@ sub azure_list_sqlservers_set_cmd { return if (defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne ''); - my $cmd_options = "sql server list --output json"; + my $cmd_options = "sql server list --only-show-errors --output json"; $cmd_options .= " --resource-group '$options{resource_group}'" if (defined($options{resource_group}) && $options{resource_group} ne ''); $cmd_options .= " --subscription '$self->{subscription}'" if (defined($self->{subscription}) && $self->{subscription} ne ''); @@ -492,7 +498,7 @@ sub azure_list_sqldatabases_set_cmd { return if (defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne ''); - my $cmd_options = "sql db list --resource-group '$options{resource_group}' --server '$options{server}' --output json"; + my $cmd_options = "sql db list --resource-group '$options{resource_group}' --server '$options{server}' --only-show-errors --output json"; $cmd_options .= " --subscription '$self->{subscription}'" if (defined($self->{subscription}) && $self->{subscription} ne ''); return $cmd_options; @@ -512,7 +518,7 @@ sub azure_get_log_analytics_set_cmd { return if (defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne ''); - my $cmd_options = "monitor log-analytics query --workspace '$options{workspace_id}' --analytics-query \"$options{query}\" --timespan '$options{interval}'"; + my $cmd_options = "monitor log-analytics query --workspace '$options{workspace_id}' --analytics-query \"$options{query}\" --timespan '$options{interval}' --only-show-errors"; return $cmd_options; } From 9630d4a06cf60f8a2e9bcff97e5c8ca1ed1f7749 Mon Sep 17 00:00:00 2001 From: UrBnW <40244829+UrBnW@users.noreply.github.com> Date: Fri, 10 Apr 2020 15:23:50 +0200 Subject: [PATCH 102/283] Add NOS 5m CPU --- centreon/common/ibm/nos/snmp/mode/cpu.pm | 32 +++++++++++++++++------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/centreon/common/ibm/nos/snmp/mode/cpu.pm b/centreon/common/ibm/nos/snmp/mode/cpu.pm index 4363afd0b..5a8990d66 100644 --- a/centreon/common/ibm/nos/snmp/mode/cpu.pm +++ b/centreon/common/ibm/nos/snmp/mode/cpu.pm @@ -29,22 +29,37 @@ sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ - { name => 'cpu', type => 0, skipped_code => { -10 => 1 } } + { name => 'cpu', type => 0, cb_prefix_output => 'prefix_message_output', skipped_code => { -10 => 1 } } ]; $self->{maps_counters}->{cpu} = [ { label => 'average-1m', nlabel => 'cpu.utilization.1m.percentage', set => { key_values => [ { name => 'average_1m' } ], - output_template => 'CPU(s) average usage: %.2f %% (1min)', + output_template => '%.2f %% (1min)', perfdatas => [ { value => 'average_1m_absolute', template => '%.2f', min => 0, max => 100, unit => '%' } ] } + }, + { label => 'average-5m', nlabel => 'cpu.utilization.5m.percentage', set => { + key_values => [ { name => 'average_5m' } ], + output_template => '%.2f %% (5min)', + perfdatas => [ + { value => 'average_5m_absolute', template => '%.2f', + min => 0, max => 100, unit => '%' } + ] + } } ]; } +sub prefix_message_output { + my ($self, %options) = @_; + + return "CPU average usage: "; +} + sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); @@ -57,10 +72,12 @@ sub manage_selection { my ($self, %options) = @_; my $oid_mpCpuStatsUtil1Minute = '.1.3.6.1.4.1.26543.2.5.1.2.2.3.0'; - my $result = $options{snmp}->get_leef(oids => [$oid_mpCpuStatsUtil1Minute], nothing_quit => 1); + my $oid_mpCpuStatsUtil5Minutes = '.1.3.6.1.4.1.26543.2.5.1.2.2.6.0'; + my $result = $options{snmp}->get_leef(oids => [$oid_mpCpuStatsUtil1Minute, $oid_mpCpuStatsUtil5Minutes], nothing_quit => 1); $self->{cpu} = { average_1m => $result->{$oid_mpCpuStatsUtil1Minute} + average_5m => $result->{$oid_mpCpuStatsUtil5Minutes} } } @@ -74,13 +91,10 @@ Check CPU usage (over the last minute). =over 8 -=item B<--warning-average-1m> +=item B<--warning-*> B<--critical-*> -Warning threshold average CPU utilization. - -=item B<--critical-average-1m> - -Critical threshold average CPU utilization. +Thresholds. +Can be: 'average-1min' (%), 'average-5min' (%). =back From 9d38ae7907434d6c02817cba61399196bd4b2584 Mon Sep 17 00:00:00 2001 From: UrBnW <40244829+UrBnW@users.noreply.github.com> Date: Fri, 10 Apr 2020 15:26:40 +0200 Subject: [PATCH 103/283] Typo --- centreon/common/ibm/nos/snmp/mode/cpu.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/centreon/common/ibm/nos/snmp/mode/cpu.pm b/centreon/common/ibm/nos/snmp/mode/cpu.pm index 5a8990d66..786883678 100644 --- a/centreon/common/ibm/nos/snmp/mode/cpu.pm +++ b/centreon/common/ibm/nos/snmp/mode/cpu.pm @@ -76,7 +76,7 @@ sub manage_selection { my $result = $options{snmp}->get_leef(oids => [$oid_mpCpuStatsUtil1Minute, $oid_mpCpuStatsUtil5Minutes], nothing_quit => 1); $self->{cpu} = { - average_1m => $result->{$oid_mpCpuStatsUtil1Minute} + average_1m => $result->{$oid_mpCpuStatsUtil1Minute}, average_5m => $result->{$oid_mpCpuStatsUtil5Minutes} } } From 342ce244d3c27255d2c02a9027a3c7c4fc5f45ee Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 13 Apr 2020 18:02:59 +0200 Subject: [PATCH 104/283] enhance saleforce --- apps/salesforce/restapi/custom/api.pm | 19 ++++++++------- apps/salesforce/restapi/mode/sfdcinstance.pm | 25 +++++++++++--------- apps/salesforce/restapi/plugin.pm | 2 +- 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/apps/salesforce/restapi/custom/api.pm b/apps/salesforce/restapi/custom/api.pm index f70c32fc9..5ee420c07 100644 --- a/apps/salesforce/restapi/custom/api.pm +++ b/apps/salesforce/restapi/custom/api.pm @@ -41,9 +41,9 @@ sub new { if (!defined($options{noptions})) { $options{options}->add_options(arguments => { - "hostname:s" => { name => 'hostname' }, - "timeout:s" => { name => 'timeout' }, - "api-versions:s" => { name => 'api_version' }, + 'hostname:s' => { name => 'hostname' }, + 'timeout:s' => { name => 'timeout' }, + 'api-versions:s' => { name => 'api_version' } }); } $options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1); @@ -110,20 +110,24 @@ sub request_api { $self->settings(); - my $content = $self->{http}->request(method => 'GET', url_path => '/' . $self->{api_version} . $options{path}, - critical_status => '', warning_status => '', unknown_status => ''); + my $content = $self->{http}->request( + method => 'GET', + url_path => '/' . $self->{api_version} . $options{path}, + critical_status => '', + warning_status => '', + unknown_status => '' + ); my $decoded; eval { $decoded = decode_json($content); }; if ($@) { - $self->{output}->output_add(long_msg => $content, debug => 1); $self->{output}->add_option_msg(short_msg => "Cannot decode json response"); $self->{output}->option_exit(); } if ($self->{http}->get_code() != 200) { - $self->{output}->add_option_msg(short_msg => "Connection issue: " . $decoded->{msg}); + $self->{output}->add_option_msg(short_msg => "Connection issue: " . $decoded->{message}); $self->{output}->option_exit(); } @@ -165,4 +169,3 @@ API base url path (Default: '/v1'). B. =cut - diff --git a/apps/salesforce/restapi/mode/sfdcinstance.pm b/apps/salesforce/restapi/mode/sfdcinstance.pm index ac941ada3..33ceafcc1 100644 --- a/apps/salesforce/restapi/mode/sfdcinstance.pm +++ b/apps/salesforce/restapi/mode/sfdcinstance.pm @@ -30,21 +30,26 @@ sub custom_status_output { my ($self, %options) = @_; return sprintf( - "Salesforce '%s' instance status is '%s' (active:'%s') ", - $self->{result_values}->{name}, + "status is '%s' (active:'%s') ", $self->{result_values}->{status}, $self->{result_values}->{active} ); } +sub prefix_volume_output { + my ($self, %options) = @_; + + return "Salesforce '" . $options{instance_value}->{name} . "' instance "; +} + sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ - { name => 'status', type => 1 }, + { name => 'salesforce', type => 1, cb_prefix_output => 'prefix_salesforce_output', message_multiple => 'All salesforce instances are ok' } ]; - $self->{maps_counters}->{status} = [ + $self->{maps_counters}->{salesforce} = [ { label => 'status', threshold => 0, set => { key_values => [ { name => 'status' }, { name => 'active' }, { name => 'name' } ], closure_custom_calc => \&catalog_status_calc, @@ -61,7 +66,7 @@ sub set_counters { min => 0, label_extra_instance => 1 }, ], } - }, + } ]; } @@ -75,8 +80,9 @@ sub new { 'alias' => { name => 'use_alias' }, 'unknown-status:s' => { name => 'unknown_status', default => '' }, 'warning-status:s' => { name => 'warning_status', default => '' }, - 'critical-status:s' => { name => 'critical_status', default => '%{status} !~ /OK/' }, + 'critical-status:s' => { name => 'critical_status', default => '%{status} !~ /OK/' } }); + return $self; } @@ -85,7 +91,6 @@ sub check_options { $self->SUPER::check_options(%options); $self->change_macros(macros => ['unknown_status', 'warning_status', 'critical_status']); - } sub manage_selection { @@ -96,14 +101,13 @@ sub manage_selection { foreach my $instance (@{$self->{option_results}->{instance}}) { my $result = $options{custom}->request_api(path => $instance_path . $instance . '/status'); - $self->{status}->{$instance} = { + $self->{salesforce}->{$instance} = { active => $result->{isActive}, incident => scalar(@{$result->{Incidents}}), name => $instance, - status => $result->{status}, + status => $result->{status} }; } - } 1; @@ -139,4 +143,3 @@ Set critical threshold for instance status (Default: '%{status} !~ /OK/'). =back =cut - diff --git a/apps/salesforce/restapi/plugin.pm b/apps/salesforce/restapi/plugin.pm index 3b2ae71cd..0fd4c57d3 100644 --- a/apps/salesforce/restapi/plugin.pm +++ b/apps/salesforce/restapi/plugin.pm @@ -31,7 +31,7 @@ sub new { $self->{version} = '0.1'; %{$self->{modes}} = ( - 'sfdc-instance' => 'apps::salesforce::restapi::mode::sfdcinstance', + 'sfdc-instance' => 'apps::salesforce::restapi::mode::sfdcinstance', ); $self->{custom_modes}{api} = 'apps::salesforce::restapi::custom::api'; return $self; From 4342156afac07b997a650af4fae1f1af676eee95 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 14 Apr 2020 09:02:30 +0200 Subject: [PATCH 105/283] fix salesforce --- apps/salesforce/restapi/mode/sfdcinstance.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/salesforce/restapi/mode/sfdcinstance.pm b/apps/salesforce/restapi/mode/sfdcinstance.pm index 33ceafcc1..aea61d55c 100644 --- a/apps/salesforce/restapi/mode/sfdcinstance.pm +++ b/apps/salesforce/restapi/mode/sfdcinstance.pm @@ -36,7 +36,7 @@ sub custom_status_output { ); } -sub prefix_volume_output { +sub prefix_salesforce_output { my ($self, %options) = @_; return "Salesforce '" . $options{instance_value}->{name} . "' instance "; From 019eeaa07bd1879ba7c12c24d7e726b57e512cdf Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 14 Apr 2020 13:48:11 +0200 Subject: [PATCH 106/283] Ref #1923 --- cloud/azure/management/monitor/mode/alert.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cloud/azure/management/monitor/mode/alert.pm b/cloud/azure/management/monitor/mode/alert.pm index 49a6ed10a..18aeddbfc 100644 --- a/cloud/azure/management/monitor/mode/alert.pm +++ b/cloud/azure/management/monitor/mode/alert.pm @@ -39,10 +39,10 @@ sub custom_perfdata { my ($self, %options) = @_; $self->{output}->perfdata_add( - nlabel => 'alerts.' . $self->{result_values}->{severity_aboluste} . '.count', + nlabel => 'alerts.' . lc($self->{result_values}->{severity_absolute}) . '.count', value => $self->{result_values}->{count_absolute}, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}) ); } @@ -74,7 +74,7 @@ sub new { 'resource-group:s' => { name => 'resource_group', default => '' }, 'group-by:s' => { name => 'group_by', default => 'severity' }, 'time-range:s' => { name => 'time_range', default => '1h' }, - 'filter:s' => { name => 'filter', default => '.*' }, + 'filter:s' => { name => 'filter', default => '.*' } }); return $self; From 05cfc9b3694fbdbfbafae249583dc17f824d4514 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 15 Apr 2020 10:48:27 +0200 Subject: [PATCH 107/283] Ref #1823 --- apps/proxmox/ve/restapi/mode/vmusage.pm | 32 ++++++++++++------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/apps/proxmox/ve/restapi/mode/vmusage.pm b/apps/proxmox/ve/restapi/mode/vmusage.pm index a96770fa8..763ca117c 100644 --- a/apps/proxmox/ve/restapi/mode/vmusage.pm +++ b/apps/proxmox/ve/restapi/mode/vmusage.pm @@ -172,8 +172,8 @@ sub set_counters { output_use => 'prct_cpu', threshold_use => 'prct_cpu', perfdatas => [ { label => 'cpu', value => 'prct_cpu', template => '%.2f', - unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }, - ], + unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' } + ] } }, { label => 'memory', set => { @@ -181,7 +181,7 @@ sub set_counters { closure_custom_calc => $self->can('custom_memory_calc'), closure_custom_output => $self->can('custom_memory_output'), closure_custom_perfdata => $self->can('custom_memory_perfdata'), - closure_custom_threshold_check => $self->can('custom_memory_threshold'), + closure_custom_threshold_check => $self->can('custom_memory_threshold') } }, { label => 'read-iops', set => { @@ -190,8 +190,8 @@ sub set_counters { output_template => 'Read IOPs : %.2f', output_error_template => "Read IOPs : %s", perfdatas => [ { label => 'read_iops', value => 'read_io_per_second', template => '%.2f', - unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, - ], + unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' } + ] } }, { label => 'write-iops', set => { @@ -200,8 +200,8 @@ sub set_counters { output_template => 'Write IOPs : %.2f', output_error_template => "Write IOPs : %s", perfdatas => [ { label => 'write_iops', value => 'write_io_per_second', template => '%.2f', - unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, - ], + unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' } + ] } }, { label => 'swap', set => { @@ -209,9 +209,9 @@ sub set_counters { closure_custom_calc => $self->can('custom_swap_calc'), closure_custom_output => $self->can('custom_swap_output'), closure_custom_perfdata => $self->can('custom_swap_perfdata'), - closure_custom_threshold_check => $self->can('custom_swap_threshold'), + closure_custom_threshold_check => $self->can('custom_swap_threshold') } - }, + } ]; $self->{maps_counters}->{vms_traffic} = [ @@ -221,8 +221,8 @@ sub set_counters { output_template => 'Traffic In : %s %s/s', perfdatas => [ { label => 'traffic_in', value => 'traffic_in_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, - ], + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' } + ] } }, { label => 'traffic-out', set => { @@ -231,10 +231,10 @@ sub set_counters { output_template => 'Traffic Out : %s %s/s', perfdatas => [ { label => 'traffic_out', value => 'traffic_out_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, - ], + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' } + ] } - }, + } ]; } @@ -249,7 +249,7 @@ sub new { 'filter-name:s' => { name => 'filter_name' }, 'use-name' => { name => 'use_name' }, 'warning-vm-status:s' => { name => 'warning_vm_status', default => '' }, - 'critical-vm-status:s' => { name => 'critical_vm_status', default => '' }, + 'critical-vm-status:s' => { name => 'critical_vm_status', default => '' } }); $self->{statefile_cache_vms} = centreon::plugins::statefile->new(%options); return $self; @@ -308,7 +308,7 @@ sub manage_selection { memory_usage => $result->{$vm_id}->{Stats}->{mem}, memory_total => $result->{$vm_id}->{Stats}->{maxmem}, swap_usage => $result->{$vm_id}->{Stats}->{swap}, - swap_total => $result->{$vm_id}->{Stats}->{maxswap}, + swap_total => defined($result->{$vm_id}->{Stats}->{maxswap}) && $result->{$vm_id}->{Stats}->{maxswap} > 0 ? $result->{$vm_id}->{Stats}->{maxswap} : undef }; $self->{vms_traffic}->{$name} = { display => $name, From 4638d97a8b64284e81ddc854a1313fee028daad6 Mon Sep 17 00:00:00 2001 From: Sims24 Date: Wed, 15 Apr 2020 12:13:25 +0200 Subject: [PATCH 108/283] + add capability to NOT aggregate --- apps/centreon/sql/mode/virtualservice.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/centreon/sql/mode/virtualservice.pm b/apps/centreon/sql/mode/virtualservice.pm index 389597712..911381522 100644 --- a/apps/centreon/sql/mode/virtualservice.pm +++ b/apps/centreon/sql/mode/virtualservice.pm @@ -323,7 +323,10 @@ sub manage_selection { $self->{vmetrics}->{$vcurve}->{aggregated_value} = sprintf( $config_data->{formatting}->{printf_metric_value}, max(@{$self->{vmetrics}->{$vcurve}->{values}})) if ($config_data->{virtualcurve}->{$vcurve}->{aggregation} eq 'max'); - $self->{vmetrics}->{$vcurve}->{aggregated_value} = eval "$self->{vmetrics}->{$vcurve}->{aggregated_value} $config_data->{virtualcurve}->{$vcurve}->{custom}" if (defined($config_data->{virtualcurve}->{$vcurve}->{custom})); + + $self->{vmetrics}->{$vcurve}->{aggregated_value} = ($config_data->{virtualcurve}->{$vcurve}->{aggregation} eq 'none' && defined($config_data->{virtualcurve}->{$vcurve}->{custom})) ? + eval "$config_data->{virtualcurve}->{$vcurve}->{custom}" : + eval "$self->{vmetrics}->{$vcurve}->{aggregated_value} $config_data->{virtualcurve}->{$vcurve}->{custom}"; $self->{vmetrics}->{$vcurve}->{unit} = (defined($config_data->{virtualcurve}->{$vcurve}->{unit})) ? $config_data->{virtualcurve}->{$vcurve}->{unit} : ''; $self->{vmetrics}->{$vcurve}->{min} = (defined($config_data->{virtualcurve}->{$vcurve}->{min})) ? $config_data->{virtualcurve}->{$vcurve}->{min} : ''; From d58e3e181523ac6641b50da91a5f6114e24458f1 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 15 Apr 2020 17:30:11 +0200 Subject: [PATCH 109/283] fix azure cpu mode --- cloud/azure/compute/virtualmachine/mode/cpu.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloud/azure/compute/virtualmachine/mode/cpu.pm b/cloud/azure/compute/virtualmachine/mode/cpu.pm index 8149deda8..d068f927e 100644 --- a/cloud/azure/compute/virtualmachine/mode/cpu.pm +++ b/cloud/azure/compute/virtualmachine/mode/cpu.pm @@ -81,7 +81,7 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments =>v{ + $options{options}->add_options(arguments => { 'resource:s@' => { name => 'resource' }, 'resource-group:s' => { name => 'resource_group' }, 'filter-metric:s' => { name => 'filter_metric' } From 31347674f780616f2e47caa447b194dcb06acda5 Mon Sep 17 00:00:00 2001 From: UrBnW <40244829+UrBnW@users.noreply.github.com> Date: Thu, 16 Apr 2020 19:18:56 +0200 Subject: [PATCH 110/283] Better handle Blade/Flex temp thresholds --- centreon/common/ibm/nos/snmp/mode/components/temperature.pm | 5 +++++ .../lenovo/flexsystem/snmp/mode/components/temperature.pm | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/centreon/common/ibm/nos/snmp/mode/components/temperature.pm b/centreon/common/ibm/nos/snmp/mode/components/temperature.pm index 704bf3121..bba2b8448 100644 --- a/centreon/common/ibm/nos/snmp/mode/components/temperature.pm +++ b/centreon/common/ibm/nos/snmp/mode/components/temperature.pm @@ -47,6 +47,11 @@ sub check { $temperature = $1 if ($1 > $temperature); my $critical_mib = ($warning_mib + $2) / 2; + if ($warning_mib == $critical_mib) { #seen on some chassis ! + $warning_mib -= 10; + $critical_mib -= 5; + } + $self->{components}->{temperature}->{total}++; $self->{output}->output_add(long_msg => diff --git a/network/lenovo/flexsystem/snmp/mode/components/temperature.pm b/network/lenovo/flexsystem/snmp/mode/components/temperature.pm index 76bc6ca46..b7d0529b4 100644 --- a/network/lenovo/flexsystem/snmp/mode/components/temperature.pm +++ b/network/lenovo/flexsystem/snmp/mode/components/temperature.pm @@ -60,6 +60,11 @@ sub check { $temperature = $1 if ($1 > $temperature); my $critical_mib = ($warning_mib + $2) / 2; + if ($warning_mib == $critical_mib) { #seen on some chassis ! + $warning_mib -= 10; + $critical_mib -= 5; + } + $self->{output}->output_add( long_msg => sprintf( "temperature switch '%s' is %s C [instance: %s]", From 6c83a0c7960e11afb9fb5ada89194a58af209d44 Mon Sep 17 00:00:00 2001 From: tcharles Date: Fri, 17 Apr 2020 00:48:34 +0200 Subject: [PATCH 111/283] add missing host output to notification --- notification/telegram/mode/alert.pm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/notification/telegram/mode/alert.pm b/notification/telegram/mode/alert.pm index ce452e6ae..2812f8bdc 100644 --- a/notification/telegram/mode/alert.pm +++ b/notification/telegram/mode/alert.pm @@ -111,7 +111,9 @@ sub host_message { } else { $self->{message} .= ' alert'; } - + if (defined($self->{option_results}->{host_output}) && $self->{option_results}->{host_output} ne '') { + $self->{message} .= "\n " . $self->{option_results}->{host_output}; + } if (defined($self->{option_results}->{link_url}) && $self->{option_results}->{link_url} ne '') { $self->{message} .= "\n {option_results}->{link_url} . "\">Link"; } From 0738c714df049b451f5a88fd07f2118c24dbb9d9 Mon Sep 17 00:00:00 2001 From: UrBnW <40244829+UrBnW@users.noreply.github.com> Date: Fri, 17 Apr 2020 10:49:03 +0200 Subject: [PATCH 112/283] Blade/Flex use same time units --- centreon/common/ibm/nos/snmp/mode/cpu.pm | 6 ++--- network/lenovo/flexsystem/snmp/mode/cpu.pm | 26 +++++++++++----------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/centreon/common/ibm/nos/snmp/mode/cpu.pm b/centreon/common/ibm/nos/snmp/mode/cpu.pm index 786883678..5260d01e6 100644 --- a/centreon/common/ibm/nos/snmp/mode/cpu.pm +++ b/centreon/common/ibm/nos/snmp/mode/cpu.pm @@ -35,7 +35,7 @@ sub set_counters { $self->{maps_counters}->{cpu} = [ { label => 'average-1m', nlabel => 'cpu.utilization.1m.percentage', set => { key_values => [ { name => 'average_1m' } ], - output_template => '%.2f %% (1min)', + output_template => '%.2f %% (1m)', perfdatas => [ { value => 'average_1m_absolute', template => '%.2f', min => 0, max => 100, unit => '%' } @@ -44,7 +44,7 @@ sub set_counters { }, { label => 'average-5m', nlabel => 'cpu.utilization.5m.percentage', set => { key_values => [ { name => 'average_5m' } ], - output_template => '%.2f %% (5min)', + output_template => '%.2f %% (5m)', perfdatas => [ { value => 'average_5m_absolute', template => '%.2f', min => 0, max => 100, unit => '%' } @@ -94,7 +94,7 @@ Check CPU usage (over the last minute). =item B<--warning-*> B<--critical-*> Thresholds. -Can be: 'average-1min' (%), 'average-5min' (%). +Can be: 'average-1m' (%), 'average-5m' (%). =back diff --git a/network/lenovo/flexsystem/snmp/mode/cpu.pm b/network/lenovo/flexsystem/snmp/mode/cpu.pm index c297f0eb3..9f3e87c16 100644 --- a/network/lenovo/flexsystem/snmp/mode/cpu.pm +++ b/network/lenovo/flexsystem/snmp/mode/cpu.pm @@ -33,20 +33,20 @@ sub set_counters { ]; $self->{maps_counters}->{cpu} = [ - { label => 'average-1min', nlabel => 'switch.cpu.utilization.1min.percentage', set => { - key_values => [ { name => 'average_1min' }, { name => 'display' } ], - output_template => '%.2f %% (1min)', + { label => 'average-1m', nlabel => 'switch.cpu.utilization.1m.percentage', set => { + key_values => [ { name => 'average_1m' }, { name => 'display' } ], + output_template => '%.2f %% (1m)', perfdatas => [ - { value => 'average_1min_absolute', template => '%.2f', + { value => 'average_1m_absolute', template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 } ] } }, - { label => 'average-5min', nlabel => 'switch.cpu.utilization.5min.percentage', set => { - key_values => [ { name => 'average_5min' }, { name => 'display' } ], - output_template => '%.2f %% (5min)', + { label => 'average-5m', nlabel => 'switch.cpu.utilization.5m.percentage', set => { + key_values => [ { name => 'average_5m' }, { name => 'display' } ], + output_template => '%.2f %% (5m)', perfdatas => [ - { value => 'average_5min_absolute', template => '%.2f', + { value => 'average_5m_absolute', template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 } ] } @@ -73,8 +73,8 @@ sub new { } my $mapping = { - average_1min => { oid => '.1.3.6.1.4.1.20301.2.5.1.2.2.12.1.1.5' }, # mpCpuStatsUtil1MinuteSwRev - average_5min => { oid => '.1.3.6.1.4.1.20301.2.5.1.2.2.12.1.1.6' } # mpCpuStatsUtil5MinutesSwRev + average_1m => { oid => '.1.3.6.1.4.1.20301.2.5.1.2.2.12.1.1.5' }, # mpCpuStatsUtil1MinuteSwRev + average_5m => { oid => '.1.3.6.1.4.1.20301.2.5.1.2.2.12.1.1.6' } # mpCpuStatsUtil5MinutesSwRev }; my $oid_mpCpuStatsRevTableEntry = '.1.3.6.1.4.1.20301.2.5.1.2.2.12.1.1'; @@ -84,13 +84,13 @@ sub manage_selection { my $snmp_result = $options{snmp}->get_table( oid => $oid_mpCpuStatsRevTableEntry, - start => $mapping->{average_1min}->{oid}, + start => $mapping->{average_1m}->{oid}, nothing_quit => 1 ); $self->{cpu} = {}; foreach my $oid (keys %$snmp_result) { - next if ($oid !~ /^$mapping->{average_1min}->{oid}\.(.*)$/); + next if ($oid !~ /^$mapping->{average_1m}->{oid}\.(.*)$/); my $instance = $1; my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance); @@ -124,7 +124,7 @@ Filter switch number. =item B<--warning-*> B<--critical-*> Thresholds. -Can be: 'average-1min' (%), 'average-5min' (%). +Can be: 'average-1m' (%), 'average-5m' (%). =back From 0c5d007cd90ec024be0fb89956bd4057273cbef1 Mon Sep 17 00:00:00 2001 From: UrBnW <40244829+UrBnW@users.noreply.github.com> Date: Fri, 17 Apr 2020 10:56:30 +0200 Subject: [PATCH 113/283] Blade/Flex fix labels --- network/lenovo/flexsystem/snmp/mode/cpu.pm | 6 +++--- network/lenovo/flexsystem/snmp/mode/memory.pm | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/network/lenovo/flexsystem/snmp/mode/cpu.pm b/network/lenovo/flexsystem/snmp/mode/cpu.pm index 9f3e87c16..869d1bdb6 100644 --- a/network/lenovo/flexsystem/snmp/mode/cpu.pm +++ b/network/lenovo/flexsystem/snmp/mode/cpu.pm @@ -33,7 +33,7 @@ sub set_counters { ]; $self->{maps_counters}->{cpu} = [ - { label => 'average-1m', nlabel => 'switch.cpu.utilization.1m.percentage', set => { + { label => 'average-1m', nlabel => 'cpu.utilization.1m.percentage', set => { key_values => [ { name => 'average_1m' }, { name => 'display' } ], output_template => '%.2f %% (1m)', perfdatas => [ @@ -42,7 +42,7 @@ sub set_counters { ] } }, - { label => 'average-5m', nlabel => 'switch.cpu.utilization.5m.percentage', set => { + { label => 'average-5m', nlabel => 'cpu.utilization.5m.percentage', set => { key_values => [ { name => 'average_5m' }, { name => 'display' } ], output_template => '%.2f %% (5m)', perfdatas => [ @@ -100,7 +100,7 @@ sub manage_selection { next; } - $self->{cpu}->{$instance} = { + $self->{cpu}->{'switch' . $instance} = { display => $instance, %$result }; diff --git a/network/lenovo/flexsystem/snmp/mode/memory.pm b/network/lenovo/flexsystem/snmp/mode/memory.pm index c3eae2c60..aeddb4205 100644 --- a/network/lenovo/flexsystem/snmp/mode/memory.pm +++ b/network/lenovo/flexsystem/snmp/mode/memory.pm @@ -46,7 +46,7 @@ sub set_counters { ]; $self->{maps_counters}->{memory} = [ - { label => 'usage', nlabel => 'switch.memory.usage.bytes', set => { + { label => 'usage', nlabel => 'memory.usage.bytes', set => { key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'display' } ], closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ @@ -55,7 +55,7 @@ sub set_counters { ] } }, - { label => 'usage-free', display_ok => 0, nlabel => 'switch.memory.free.bytes', set => { + { label => 'usage-free', display_ok => 0, nlabel => 'memory.free.bytes', set => { key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'display' } ], closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ @@ -64,7 +64,7 @@ sub set_counters { ] } }, - { label => 'usage-prct', display_ok => 0, nlabel => 'switch.memory.usage.percentage', set => { + { label => 'usage-prct', display_ok => 0, nlabel => 'memory.usage.percentage', set => { key_values => [ { name => 'prct_used' }, { name => 'display' } ], output_template => 'Ram Used : %.2f %%', perfdatas => [ @@ -124,7 +124,7 @@ sub manage_selection { } my $prct_used = ($result->{total} - $result->{free}) * 100 / $result->{total}; - $self->{memory}->{$instance} = { + $self->{memory}->{'switch' . $instance} = { display => $instance, prct_used => $prct_used, prct_free => 100 - $prct_used, From 6d3628bc088c37a564df0a6c8f0290f74e66d32e Mon Sep 17 00:00:00 2001 From: UrBnW <40244829+UrBnW@users.noreply.github.com> Date: Fri, 17 Apr 2020 10:59:37 +0200 Subject: [PATCH 114/283] Typo --- network/lenovo/flexsystem/snmp/mode/components/temperature.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/network/lenovo/flexsystem/snmp/mode/components/temperature.pm b/network/lenovo/flexsystem/snmp/mode/components/temperature.pm index b7d0529b4..5c8ac9868 100644 --- a/network/lenovo/flexsystem/snmp/mode/components/temperature.pm +++ b/network/lenovo/flexsystem/snmp/mode/components/temperature.pm @@ -101,7 +101,7 @@ sub check { } $self->{output}->perfdata_add( nlabel => 'hardware.temperature.celsius', unit => 'C', - instances => 'switch=' . $instance, + instances => 'switch' . $instance, value => $temperature, warning => $warn, critical => $crit From f037c947f7f1222c3137a3928c53ab213e7d998f Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 17 Apr 2020 17:20:02 +0200 Subject: [PATCH 115/283] enhance cloud recovery azure --- .../recovery/mode/backupitemsstatus.pm | 76 +++++++++---------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/cloud/azure/management/recovery/mode/backupitemsstatus.pm b/cloud/azure/management/recovery/mode/backupitemsstatus.pm index fa04f48b9..c3960b30f 100644 --- a/cloud/azure/management/recovery/mode/backupitemsstatus.pm +++ b/cloud/azure/management/recovery/mode/backupitemsstatus.pm @@ -28,16 +28,17 @@ use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold) sub custom_status_output { my ($self, %options) = @_; - - my $msg = sprintf("Pre-Check Status '%s', Last Backup Status '%s'", + + return sprintf( + "Pre-Check Status '%s', Last Backup Status '%s'", $self->{result_values}->{precheck_status}, - $self->{result_values}->{last_backup_status}); - return $msg; + $self->{result_values}->{last_backup_status} + ); } sub custom_status_calc { my ($self, %options) = @_; - + $self->{result_values}->{precheck_status} = $options{new_datas}->{$self->{instance} . '_precheck_status'}; $self->{result_values}->{last_backup_status} = $options{new_datas}->{$self->{instance} . '_last_backup_status'}; $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; @@ -52,16 +53,16 @@ sub prefix_global_output { sub prefix_item_output { my ($self, %options) = @_; - + return "Backup Item '" . $options{instance_value}->{display} . "' "; } sub set_counters { my ($self, %options) = @_; - + $self->{maps_counters_type} = [ { name => 'global', type => 0, cb_prefix_output => 'prefix_global_output', cb_init => 'skip_global' }, - { name => 'items', type => 1, cb_prefix_output => 'prefix_item_output', message_multiple => 'All items are ok' }, + { name => 'items', type => 1, cb_prefix_output => 'prefix_item_output', message_multiple => 'All items are ok' } ]; $self->{maps_counters}->{global} = [ @@ -69,18 +70,18 @@ sub set_counters { key_values => [ { name => 'completed' } ], output_template => "completed : %s", perfdatas => [ - { label => 'total_completed', value => 'completed_absolute', template => '%d', min => 0 }, - ], + { label => 'total_completed', value => 'completed_absolute', template => '%d', min => 0 } + ] } }, { label => 'total-failed', set => { key_values => [ { name => 'failed' } ], output_template => "failed : %s", perfdatas => [ - { label => 'total_failed', value => 'failed_absolute', template => '%d', min => 0 }, - ], + { label => 'total_failed', value => 'failed_absolute', template => '%d', min => 0 } + ] } - }, + } ]; $self->{maps_counters}->{items} = [ @@ -89,9 +90,9 @@ sub set_counters { closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => \&catalog_status_threshold, + closure_custom_threshold_check => \&catalog_status_threshold } - }, + } ]; } @@ -105,18 +106,17 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - - $options{options}->add_options(arguments => - { - "vault-name:s" => { name => 'vault_name' }, - "resource-group:s" => { name => 'resource_group' }, - "filter-name:s" => { name => 'filter_name' }, - "filter-vmid:s" => { name => 'filter_vmid' }, - "filter-counters:s" => { name => 'filter_counters' }, - "warning-status:s" => { name => 'warning_status', default => '' }, - "critical-status:s" => { name => 'critical_status', default => '%{precheck_status} ne "Passed" || %{last_backup_status} eq "Failed"' }, - }); - + + $options{options}->add_options(arguments => { + 'vault-name:s' => { name => 'vault_name' }, + 'resource-group:s' => { name => 'resource_group' }, + 'filter-name:s' => { name => 'filter_name' }, + 'filter-vmid:s' => { name => 'filter_vmid' }, + 'filter-counters:s' => { name => 'filter_counters' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '%{precheck_status} ne "Passed" || %{last_backup_status} eq "Failed"' } + }); + return $self; } @@ -139,33 +139,33 @@ sub check_options { sub manage_selection { my ($self, %options) = @_; - $self->{global} = { - completed => 0, failed => 0, inprogress => 0, - }; - $self->{items} = {}; my $items = $options{custom}->azure_list_backup_items( vault_name => $self->{option_results}->{vault_name}, resource_group => $self->{option_results}->{resource_group} ); + + $self->{global} = { + completed => 0, failed => 0, inprogress => 0 + }; + $self->{items} = {}; foreach my $item (@{$items}) { next if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && $item->{properties}->{friendlyName} !~ /$self->{option_results}->{filter_name}/); next if (defined($self->{option_results}->{filter_vmid}) && $self->{option_results}->{filter_vmid} ne '' && $item->{properties}->{virtualMachineId} !~ /$self->{option_results}->{filter_vmid}/); - + $self->{items}->{$item->{id}} = { display => $item->{properties}->{friendlyName}, precheck_status => $item->{properties}->{healthStatus}, - last_backup_status => $item->{properties}->{lastBackupStatus}, + last_backup_status => $item->{properties}->{lastBackupStatus} }; - foreach my $status (keys %{$self->{global}}) { - $self->{global}->{$status}++ if ($item->{properties}->{lastBackupStatus} =~ /$status/i); - } + $self->{global}->{ lc($item->{properties}->{lastBackupStatus}) }++ + if (defined($item->{properties}->{lastBackupStatus}) && defined($self->{global}->{ lc($item->{properties}->{lastBackupStatus}) })); } - + if (scalar(keys %{$self->{items}}) <= 0) { - $self->{output}->add_option_msg(short_msg => "No backup items found."); + $self->{output}->add_option_msg(short_msg => 'No backup items found.'); $self->{output}->option_exit(); } } From 73a84ec879c2a050ae9266a60d295089743ee044 Mon Sep 17 00:00:00 2001 From: lenkoda Date: Sat, 18 Apr 2020 12:14:23 +0200 Subject: [PATCH 116/283] New plugin for TimeLink TMS6001 NTP server --- .../timelinkmicro/tms6001/snmp/mode/alarm.pm | 104 ++++++++++++++++++ .../tms6001/snmp/mode/antenna.pm | 93 ++++++++++++++++ .../tms6001/snmp/mode/frequency.pm | 104 ++++++++++++++++++ .../timelinkmicro/tms6001/snmp/mode/gnss.pm | 90 +++++++++++++++ .../tms6001/snmp/mode/satellites.pm | 104 ++++++++++++++++++ .../timelinkmicro/tms6001/snmp/mode/time.pm | 104 ++++++++++++++++++ .../timelinkmicro/tms6001/snmp/plugin.pm | 55 +++++++++ 7 files changed, 654 insertions(+) create mode 100644 hardware/devices/timelinkmicro/tms6001/snmp/mode/alarm.pm create mode 100644 hardware/devices/timelinkmicro/tms6001/snmp/mode/antenna.pm create mode 100644 hardware/devices/timelinkmicro/tms6001/snmp/mode/frequency.pm create mode 100644 hardware/devices/timelinkmicro/tms6001/snmp/mode/gnss.pm create mode 100644 hardware/devices/timelinkmicro/tms6001/snmp/mode/satellites.pm create mode 100644 hardware/devices/timelinkmicro/tms6001/snmp/mode/time.pm create mode 100644 hardware/devices/timelinkmicro/tms6001/snmp/plugin.pm diff --git a/hardware/devices/timelinkmicro/tms6001/snmp/mode/alarm.pm b/hardware/devices/timelinkmicro/tms6001/snmp/mode/alarm.pm new file mode 100644 index 000000000..868f251a3 --- /dev/null +++ b/hardware/devices/timelinkmicro/tms6001/snmp/mode/alarm.pm @@ -0,0 +1,104 @@ +# +# Copyright 2019 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. +# +# Authors : Thomas Gourdin thomas.gourdin@gmail.com + +package hardware::devices::timelinkmicro::tms6001::snmp::mode::alarm; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $options{options}->add_options(arguments => + { + "warning:s" => { name => 'warning' }, + "critical:s" => { name => 'critical' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + + if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'."); + $self->{output}->option_exit(); + } + if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); + $self->{output}->option_exit(); + } + +} + +sub run { + my ($self, %options) = @_; + $self->{snmp} = $options{snmp}; + $self->{hostname} = $self->{snmp}->get_hostname(); + + my $oid_qualityfrequency = '.1.3.6.1.4.1.22641.100.3.3.0'; + + my $result = $self->{snmp}->get_leef(oids => [ $oid_qualityfrequency ], nothing_quit => 1); + + my $value = $result->{$oid_qualityfrequency}; + + my $exit = $self->{perfdata}->threshold_check(value => $value, + threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("There is %s alarm(s).", $value)); + + $self->{output}->perfdata_add(label => 'value', unit => undef, + value => $value, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), + min => undef, max => undef); + + $self->{output}->display(); + $self->{output}->exit(); +} + +1; + +__END__ + +=head1 MODE + +Check quality of frequency generation + +=over 8 + +=item B<--warning> + +Threshold warning. + +=item B<--critical> + +Threshold critical. + +=back + +=cut diff --git a/hardware/devices/timelinkmicro/tms6001/snmp/mode/antenna.pm b/hardware/devices/timelinkmicro/tms6001/snmp/mode/antenna.pm new file mode 100644 index 000000000..73cf044a7 --- /dev/null +++ b/hardware/devices/timelinkmicro/tms6001/snmp/mode/antenna.pm @@ -0,0 +1,93 @@ +# +# Copyright 2019 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. +# +# Authors : Thomas Gourdin thomas.gourdin@gmail.com + +package hardware::devices::timelinkmicro::tms6001::snmp::mode::antenna; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $options{options}->add_options(arguments => + { + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + +} + +sub run { + my ($self, %options) = @_; + $self->{snmp} = $options{snmp}; + $self->{hostname} = $self->{snmp}->get_hostname(); + + my $oid_qualityfrequency = '.1.3.6.1.4.1.22641.100.4.1.4.0'; + + my $result = $self->{snmp}->get_leef(oids => [ $oid_qualityfrequency ], nothing_quit => 1); + + my $value = $result->{$oid_qualityfrequency}; + + if ($value eq 'C') { + $self->{output}->output_add(severity => 'OK', + short_msg => sprintf("Antenna is connected")); + } elsif ($value eq 'S') { + $self->{output}->output_add(severity => 'WARNING', + short_msg => sprintf("Antenna is shorted or powered off")); + } elsif ($value eq 'N') { + $self->{output}->output_add(severity => 'CRITICAL', + short_msg => sprintf("Antenna is not connected")); + } + + $self->{output}->display(); + $self->{output}->exit(); +} + +1; + +__END__ + +=head1 MODE + +Check quality of frequency generation + +=over 8 + +=item B<--warning> + +Threshold warning. + +=item B<--critical> + +Threshold critical. + +=back + +=cut diff --git a/hardware/devices/timelinkmicro/tms6001/snmp/mode/frequency.pm b/hardware/devices/timelinkmicro/tms6001/snmp/mode/frequency.pm new file mode 100644 index 000000000..e443c5a7d --- /dev/null +++ b/hardware/devices/timelinkmicro/tms6001/snmp/mode/frequency.pm @@ -0,0 +1,104 @@ +# +# Copyright 2019 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. +# +# Authors : Thomas Gourdin thomas.gourdin@gmail.com + +package hardware::devices::timelinkmicro::tms6001::snmp::mode::frequency; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $options{options}->add_options(arguments => + { + "warning:s" => { name => 'warning' }, + "critical:s" => { name => 'critical' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + + if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'."); + $self->{output}->option_exit(); + } + if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); + $self->{output}->option_exit(); + } + +} + +sub run { + my ($self, %options) = @_; + $self->{snmp} = $options{snmp}; + $self->{hostname} = $self->{snmp}->get_hostname(); + + my $oid_qualityfrequency = '.1.3.6.1.4.1.22641.100.3.6.0'; + + my $result = $self->{snmp}->get_leef(oids => [ $oid_qualityfrequency ], nothing_quit => 1); + + my $value = $result->{$oid_qualityfrequency}; + + my $exit = $self->{perfdata}->threshold_check(value => $value, + threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Quality of frequency generation is %s.", $value)); + + $self->{output}->perfdata_add(label => 'value', unit => undef, + value => $value, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), + min => undef, max => undef); + + $self->{output}->display(); + $self->{output}->exit(); +} + +1; + +__END__ + +=head1 MODE + +Check quality of frequency generation + +=over 8 + +=item B<--warning> + +Threshold warning. + +=item B<--critical> + +Threshold critical. + +=back + +=cut diff --git a/hardware/devices/timelinkmicro/tms6001/snmp/mode/gnss.pm b/hardware/devices/timelinkmicro/tms6001/snmp/mode/gnss.pm new file mode 100644 index 000000000..b9d9f7986 --- /dev/null +++ b/hardware/devices/timelinkmicro/tms6001/snmp/mode/gnss.pm @@ -0,0 +1,90 @@ +# +# Copyright 2019 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. +# +# Authors : Thomas Gourdin thomas.gourdin@gmail.com + +package hardware::devices::timelinkmicro::tms6001::snmp::mode::gnss; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $options{options}->add_options(arguments => + { + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + +} + +sub run { + my ($self, %options) = @_; + $self->{snmp} = $options{snmp}; + $self->{hostname} = $self->{snmp}->get_hostname(); + + my $oid_qualityfrequency = '.1.3.6.1.4.1.22641.100.4.1.2.0'; + + my $result = $self->{snmp}->get_leef(oids => [ $oid_qualityfrequency ], nothing_quit => 1); + + my $value = $result->{$oid_qualityfrequency}; + + if ($value eq 'Nominal') { + $self->{output}->output_add(severity => 'OK', + short_msg => sprintf("GNSS status is $value")); + } else { + $self->{output}->output_add(severity => 'CRITICAL', + short_msg => sprintf("GNSS status is $value")); + } + + $self->{output}->display(); + $self->{output}->exit(); +} + +1; + +__END__ + +=head1 MODE + +Check quality of frequency generation + +=over 8 + +=item B<--warning> + +Threshold warning. + +=item B<--critical> + +Threshold critical. + +=back + +=cut diff --git a/hardware/devices/timelinkmicro/tms6001/snmp/mode/satellites.pm b/hardware/devices/timelinkmicro/tms6001/snmp/mode/satellites.pm new file mode 100644 index 000000000..9d6468be2 --- /dev/null +++ b/hardware/devices/timelinkmicro/tms6001/snmp/mode/satellites.pm @@ -0,0 +1,104 @@ +# +# Copyright 2019 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. +# +# Authors : Thomas Gourdin thomas.gourdin@gmail.com + +package hardware::devices::timelinkmicro::tms6001::snmp::mode::satellites; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $options{options}->add_options(arguments => + { + "warning:s" => { name => 'warning' }, + "critical:s" => { name => 'critical' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + + if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'."); + $self->{output}->option_exit(); + } + if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); + $self->{output}->option_exit(); + } + +} + +sub run { + my ($self, %options) = @_; + $self->{snmp} = $options{snmp}; + $self->{hostname} = $self->{snmp}->get_hostname(); + + my $oid_qualityfrequency = '.1.3.6.1.4.1.22641.100.4.1.8.0'; + + my $result = $self->{snmp}->get_leef(oids => [ $oid_qualityfrequency ], nothing_quit => 1); + + my $value = $result->{$oid_qualityfrequency}; + + my $exit = $self->{perfdata}->threshold_check(value => $value, + threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Number of satellites seen is %s.", $value)); + + $self->{output}->perfdata_add(label => 'value', unit => undef, + value => $value, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), + min => undef, max => undef); + + $self->{output}->display(); + $self->{output}->exit(); +} + +1; + +__END__ + +=head1 MODE + +Check quality of frequency generation + +=over 8 + +=item B<--warning> + +Threshold warning. + +=item B<--critical> + +Threshold critical. + +=back + +=cut diff --git a/hardware/devices/timelinkmicro/tms6001/snmp/mode/time.pm b/hardware/devices/timelinkmicro/tms6001/snmp/mode/time.pm new file mode 100644 index 000000000..cdb10572e --- /dev/null +++ b/hardware/devices/timelinkmicro/tms6001/snmp/mode/time.pm @@ -0,0 +1,104 @@ +# +# Copyright 2019 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. +# +# Authors : Thomas Gourdin thomas.gourdin@gmail.com + +package hardware::devices::timelinkmicro::tms6001::snmp::mode::time; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $options{options}->add_options(arguments => + { + "warning:s" => { name => 'warning' }, + "critical:s" => { name => 'critical' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + + if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'."); + $self->{output}->option_exit(); + } + if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) { + $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); + $self->{output}->option_exit(); + } + +} + +sub run { + my ($self, %options) = @_; + $self->{snmp} = $options{snmp}; + $self->{hostname} = $self->{snmp}->get_hostname(); + + my $oid_qualityfrequency = '.1.3.6.1.4.1.22641.100.3.5.0'; + + my $result = $self->{snmp}->get_leef(oids => [ $oid_qualityfrequency ], nothing_quit => 1); + + my $value = $result->{$oid_qualityfrequency}; + + my $exit = $self->{perfdata}->threshold_check(value => $value, + threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + $self->{output}->output_add(severity => $exit, + short_msg => sprintf("Quality of time generation is %s.", $value)); + + $self->{output}->perfdata_add(label => 'value', unit => undef, + value => $value, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), + min => undef, max => undef); + + $self->{output}->display(); + $self->{output}->exit(); +} + +1; + +__END__ + +=head1 MODE + +Check quality of frequency generation + +=over 8 + +=item B<--warning> + +Threshold warning. + +=item B<--critical> + +Threshold critical. + +=back + +=cut diff --git a/hardware/devices/timelinkmicro/tms6001/snmp/plugin.pm b/hardware/devices/timelinkmicro/tms6001/snmp/plugin.pm new file mode 100644 index 000000000..799f11780 --- /dev/null +++ b/hardware/devices/timelinkmicro/tms6001/snmp/plugin.pm @@ -0,0 +1,55 @@ +# +# Copyright 2015 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. +# +# Authors : Thomas Gourdin thomas.gourdin@gmail.com + +package hardware::devices::timelinkmicro::tms6001::snmp::plugin; + +use strict; +use warnings; +use base qw(centreon::plugins::script_snmp); + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '0.1'; + %{$self->{modes}} = ( + 'frequency' => 'hardware::devices::timelinkmicro::tms6001::snmp::mode::frequency', + 'time' => 'hardware::devices::timelinkmicro::tms6001::snmp::mode::time', + 'satellites' => 'hardware::devices::timelinkmicro::tms6001::snmp::mode::satellites', + 'antenna' => 'hardware::devices::timelinkmicro::tms6001::snmp::mode::antenna', + 'gnss' => 'hardware::devices::timelinkmicro::tms6001::snmp::mode::gnss', + 'alarms' => 'hardware::devices::timelinkmicro::tms6001::snmp::mode::alarm', + + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check timelinkmicro TMS6001 NTP servers through SNMP + +=cut From fc2bce000576fe009f850e6f1dbdf903988568ca Mon Sep 17 00:00:00 2001 From: lenkoda Date: Sat, 18 Apr 2020 12:25:45 +0200 Subject: [PATCH 117/283] Modified descriptions --- .../devices/timelinkmicro/tms6001/snmp/mode/alarm.pm | 2 +- .../devices/timelinkmicro/tms6001/snmp/mode/antenna.pm | 10 +--------- .../devices/timelinkmicro/tms6001/snmp/mode/gnss.pm | 10 +--------- .../timelinkmicro/tms6001/snmp/mode/satellites.pm | 2 +- .../devices/timelinkmicro/tms6001/snmp/mode/time.pm | 2 +- 5 files changed, 5 insertions(+), 21 deletions(-) diff --git a/hardware/devices/timelinkmicro/tms6001/snmp/mode/alarm.pm b/hardware/devices/timelinkmicro/tms6001/snmp/mode/alarm.pm index 868f251a3..3f236e7d1 100644 --- a/hardware/devices/timelinkmicro/tms6001/snmp/mode/alarm.pm +++ b/hardware/devices/timelinkmicro/tms6001/snmp/mode/alarm.pm @@ -87,7 +87,7 @@ __END__ =head1 MODE -Check quality of frequency generation +Check number of alarms =over 8 diff --git a/hardware/devices/timelinkmicro/tms6001/snmp/mode/antenna.pm b/hardware/devices/timelinkmicro/tms6001/snmp/mode/antenna.pm index 73cf044a7..e548c2920 100644 --- a/hardware/devices/timelinkmicro/tms6001/snmp/mode/antenna.pm +++ b/hardware/devices/timelinkmicro/tms6001/snmp/mode/antenna.pm @@ -76,18 +76,10 @@ __END__ =head1 MODE -Check quality of frequency generation +Check antenna status =over 8 -=item B<--warning> - -Threshold warning. - -=item B<--critical> - -Threshold critical. - =back =cut diff --git a/hardware/devices/timelinkmicro/tms6001/snmp/mode/gnss.pm b/hardware/devices/timelinkmicro/tms6001/snmp/mode/gnss.pm index b9d9f7986..666fff461 100644 --- a/hardware/devices/timelinkmicro/tms6001/snmp/mode/gnss.pm +++ b/hardware/devices/timelinkmicro/tms6001/snmp/mode/gnss.pm @@ -73,18 +73,10 @@ __END__ =head1 MODE -Check quality of frequency generation +Check GNSS state =over 8 -=item B<--warning> - -Threshold warning. - -=item B<--critical> - -Threshold critical. - =back =cut diff --git a/hardware/devices/timelinkmicro/tms6001/snmp/mode/satellites.pm b/hardware/devices/timelinkmicro/tms6001/snmp/mode/satellites.pm index 9d6468be2..51635f0d2 100644 --- a/hardware/devices/timelinkmicro/tms6001/snmp/mode/satellites.pm +++ b/hardware/devices/timelinkmicro/tms6001/snmp/mode/satellites.pm @@ -87,7 +87,7 @@ __END__ =head1 MODE -Check quality of frequency generation +Check number of satellites seen =over 8 diff --git a/hardware/devices/timelinkmicro/tms6001/snmp/mode/time.pm b/hardware/devices/timelinkmicro/tms6001/snmp/mode/time.pm index cdb10572e..f061e0294 100644 --- a/hardware/devices/timelinkmicro/tms6001/snmp/mode/time.pm +++ b/hardware/devices/timelinkmicro/tms6001/snmp/mode/time.pm @@ -87,7 +87,7 @@ __END__ =head1 MODE -Check quality of frequency generation +Check quality of time generation =over 8 From 54d846f233f1bc5ddb7cbeb21b086b6b95069c2a Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 20 Apr 2020 15:27:44 +0200 Subject: [PATCH 118/283] Fix #1952 --- apps/protocols/dns/lib/dns.pm | 48 +++++++++++----------- apps/protocols/dns/mode/request.pm | 65 ++++++++++++++++++------------ 2 files changed, 63 insertions(+), 50 deletions(-) diff --git a/apps/protocols/dns/lib/dns.pm b/apps/protocols/dns/lib/dns.pm index 59ae923aa..d6b1e9b65 100644 --- a/apps/protocols/dns/lib/dns.pm +++ b/apps/protocols/dns/lib/dns.pm @@ -26,46 +26,44 @@ use Net::DNS; my $handle; -my %map_search_field = ( - MX => 'exchange', - SOA => 'mname', - NS => 'nsdname', - A => 'address', - PTR => 'name', - CNAME => 'cname', - TXT => 'txtdata', -); - sub search { my ($self, %options) = @_; - + + my $map_search_field = { + MX => 'exchange', + SOA => 'mname', + NS => 'nsdname', + A => 'address', + PTR => 'name', + CNAME => 'cname', + TXT => 'txtdata' + }; + my @results = (); my $search_type = $self->{option_results}->{search_type}; - if (defined($search_type) && !defined($map_search_field{$search_type})) { + if (defined($search_type) && !defined($map_search_field->{$search_type})) { $self->{output}->add_option_msg(short_msg => "search-type '$search_type' is unknown or unsupported"); $self->{output}->option_exit(); } - + + $map_search_field->{PTR} = 'ptrdname' if (defined($self->{option_results}->{use_ptr_fqdn})); + my $error_quit = defined($options{error_quit}) ? $options{error_quit} : undef; my $reply = $handle->search($self->{option_results}->{search}, $search_type); if ($reply) { foreach my $rr ($reply->answer) { - if (!defined($search_type)) { - push @results, $rr->address if ($rr->type eq 'A'); - push @results, $rr->name if ($rr->type eq 'PTR'); - push @results, $rr->txtdata if ($rr->type eq 'TXT'); - next; - } - - next if ($rr->type ne $search_type); - my $search_field = $map_search_field{$search_type}; - push @results, $rr->$search_field; + my $type = defined($search_type) ? $search_type : $rr->type; + next if ($type ne $rr->type); + my $attr = $map_search_field->{$type}; + push @results, $rr->$attr; } } else { if (defined($error_quit)) { - $self->{output}->output_add(severity => $error_quit, - short_msg => sprintf("DNS Query Failed: %s", $handle->errorstring)); + $self->{output}->output_add( + severity => $error_quit, + short_msg => sprintf('DNS query failed: %s', $handle->errorstring) + ); $self->{output}->display(); $self->{output}->exit(); } diff --git a/apps/protocols/dns/mode/request.pm b/apps/protocols/dns/mode/request.pm index 4a2306a13..d890249c4 100644 --- a/apps/protocols/dns/mode/request.pm +++ b/apps/protocols/dns/mode/request.pm @@ -34,18 +34,18 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - "nameservers:s@" => { name => 'nameservers' }, - "searchlist:s@" => { name => 'searchlist' }, - "dns-options:s@" => { name => 'dns_options' }, - "search:s" => { name => 'search' }, - "search-type:s" => { name => 'search_type' }, - "expected-answer:s" => { name => 'expected_answer' }, - "warning:s" => { name => 'warning' }, - "critical:s" => { name => 'critical' }, - "memory" => { name => 'memory' }, - }); + $options{options}->add_options(arguments => { + 'nameservers:s@' => { name => 'nameservers' }, + 'searchlist:s@' => { name => 'searchlist' }, + 'dns-options:s@' => { name => 'dns_options' }, + 'search:s' => { name => 'search' }, + 'search-type:s' => { name => 'search_type' }, + 'use-ptr-fqdn' => { name => 'use_ptr_fqdn' }, + 'expected-answer:s' => { name => 'expected_answer' }, + 'warning:s' => { name => 'warning' }, + 'critical:s' => { name => 'critical' }, + 'memory' => { name => 'memory' } + }); $self->{statefile_cache} = centreon::plugins::statefile->new(%options); return $self; @@ -96,14 +96,20 @@ sub run { my $timeelapsed = tv_interval ($timing0, [gettimeofday]); my $result_str = join(', ', @results); - my $exit = $self->{perfdata}->threshold_check(value => $timeelapsed, - threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Response time %.3f second(s) (answer: %s)", $timeelapsed, $result_str)); - $self->{output}->perfdata_add(label => "time", unit => 's', - value => sprintf('%.3f', $timeelapsed), - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical')); + my $exit = $self->{perfdata}->threshold_check( + value => $timeelapsed, + threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ] + ); + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf("Response time %.3f second(s) (answer: %s)", $timeelapsed, $result_str) + ); + $self->{output}->perfdata_add( + label => "time", unit => 's', + value => sprintf('%.3f', $timeelapsed), + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical') + ); if (defined($self->{option_results}->{expected_answer}) && $self->{option_results}->{expected_answer} ne '') { my $match = 0; @@ -114,8 +120,11 @@ sub run { } if ($match == 0) { - $self->{output}->output_add(severity => 'CRITICAL', - short_msg => sprintf("No result values match expected answer (answer: %s)", $result_str)); + $self->{output}->output_add( + severity => 'CRITICAL', + short_msg => sprintf("No result values match expected answer (answer: %s)", $result_str + ) + ); } } @@ -125,15 +134,17 @@ sub run { my $old_result = $self->{statefile_cache}->get(name => "result"); if (defined($old_result)) { if ($old_result ne $result_str) { - $self->{output}->output_add(severity => 'CRITICAL', - short_msg => sprintf("Result has changed [answer: %s] [old answer: %s]", $result_str, $old_result)); + $self->{output}->output_add( + severity => 'CRITICAL', + short_msg => sprintf("Result has changed [answer: %s] [old answer: %s]", $result_str, $old_result) + ); } } else { $self->{output}->output_add(long_msg => 'cache file created.'); } $self->{statefile_cache}->write(data => $datas); } - + $self->{output}->display(); $self->{output}->exit(); } @@ -169,6 +180,10 @@ Set the search value (required). Set the search type. Can be: 'MX', 'SOA', 'NS', 'A', 'CNAME' or 'PTR'. 'A' or 'PTR' is used by default (depends if an IP or not). +=item B<--use-ptr-fqdn> + +Search is done on conical names for PTR type. + =item B<--expected-answer> What the server must answer (can be a regexp). From 775838b8495a612fecb1aeb68463a8688b424470 Mon Sep 17 00:00:00 2001 From: Sims24 Date: Mon, 20 Apr 2020 15:36:37 +0200 Subject: [PATCH 119/283] add ec2 spot fleet instance ocunt ref #172 --- cloud/aws/custom/awscli.pm | 30 ++++++ cloud/aws/custom/paws.pm | 30 +++++- cloud/aws/ec2/mode/spotactiveinstances.pm | 122 ++++++++++++++++++++++ cloud/aws/ec2/plugin.pm | 21 ++-- 4 files changed, 190 insertions(+), 13 deletions(-) create mode 100644 cloud/aws/ec2/mode/spotactiveinstances.pm diff --git a/cloud/aws/custom/awscli.pm b/cloud/aws/custom/awscli.pm index ab62709fb..36510b5d2 100644 --- a/cloud/aws/custom/awscli.pm +++ b/cloud/aws/custom/awscli.pm @@ -369,6 +369,36 @@ sub ec2_get_instances_status { return $instance_results; } +sub ec2spot_get_active_instances_set_cmd { + my ($self, %options) = @_; + + return if (defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne ''); + + my $cmd_options = "ec2 describe-spot-fleet-instances --no-dry-run --region $options{region} --output json"; + $cmd_options .= " --endpoint-url $self->{endpoint_url}" if (defined($self->{endpoint_url}) && $self->{endpoint_url} ne ''); + $cmd_options .= " --spot-fleet-request-id " . $options{spot_fleet_request_id}; + + return $cmd_options; +} + +sub ec2spot_get_active_instances_status { + my ($self, %options) = @_; + + my $cmd_options = $self->ec2spot_get_active_instances_set_cmd(%options); + my $raw_results = $self->execute(cmd_options => $cmd_options); + + my $instance_results = {}; + foreach (@{$raw_results->{ActiveInstances}}) { + $instance_results->{$_->{InstanceId}} = { + health => $_->{InstanceHealth}, + type => $_->{InstanceType}, + request_id => $_->{SpotInstanceRequestId} + }; + } + + return $instance_results; +} + sub ec2_list_resources_set_cmd { my ($self, %options) = @_; diff --git a/cloud/aws/custom/paws.pm b/cloud/aws/custom/paws.pm index cc899ba34..a1cab9d9e 100644 --- a/cloud/aws/custom/paws.pm +++ b/cloud/aws/custom/paws.pm @@ -301,7 +301,31 @@ sub ec2_get_instances_status { foreach (@{$instances->{InstanceStatuses}}) { $instance_results->{$_->{InstanceId}} = { state => $_->{InstanceState}->{Name}, - status => => $_->{InstanceStatus}->{Status} }; + status => $_->{InstanceStatus}->{Status} }; + } + }; + if ($@) { + $self->{output}->add_option_msg(short_msg => "error: $@"); + $self->{output}->option_exit(); + } + + return $instance_results; +} + +sub ec2spot_get_active_instances { + my ($self, %options) = @_; + + my $instance_results = {}; + eval { + my $lwp_caller = new Paws::Net::LWPCaller(); + my $ec2 = Paws->service('EC2', caller => $lwp_caller, region => $options{region}); + my $instances = $ec2->DescribeSpotFleetInstances('SpotFleetRequestId' => $options{spot_fleet_request_id}, DryRun => 0, IncludeAllInstances => 1); + + foreach (@{$instances->{ActiveInstances}}) { + $instance_results->{$_->{InstanceId}} = { + health => $_->{InstanceHealth}, + type => $_->{InstanceType}, + request_id => $_->{SpotInstanceRequestId} }; } }; if ($@) { @@ -451,7 +475,7 @@ sub vpn_list_connections { my $connections_results = []; eval { my $lwp_caller = new Paws::Net::LWPCaller(); - my $rds = Paws->service('EC2', caller => $lwp_caller, region => $options{region}); + my $vpn = Paws->service('EC2', caller => $lwp_caller, region => $options{region}); my $list_vpn = $vpn->DescribeVpnConnections(); foreach my $connection (@{$list_vpn->{VpnConnections}}) { my @name_tags; @@ -531,4 +555,4 @@ Proxy URL if any B. -=cut \ No newline at end of file +=cut diff --git a/cloud/aws/ec2/mode/spotactiveinstances.pm b/cloud/aws/ec2/mode/spotactiveinstances.pm new file mode 100644 index 000000000..1b544efe8 --- /dev/null +++ b/cloud/aws/ec2/mode/spotactiveinstances.pm @@ -0,0 +1,122 @@ +# +# Copyright 2020 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 cloud::aws::ec2::mode::spotactiveinstances; + +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 => 'active', nlabel => 'ec2.spot.instances.active.count', set => { + key_values => [ { name => 'active' } ], + output_template => 'Active instances : %s', + perfdatas => [ + { label => 'active', value => 'active_absolute', template => '%s', + min => 0 }, + ], + } + }, + { label => 'healthy', nlabel => 'ec2.spot.instances.unhealthy.count', set => { + key_values => [ { name => 'healthy' } ], + output_template => 'Healthy instances : %s', + perfdatas => [ + { label => 'healthy', value => 'healthy_absolute', template => '%s', + min => 0 }, + ], + } + }, + { label => 'unhealthy', nlabel => 'ec2.spot.instances.unhealthy.count', set => { + key_values => [ { name => 'unhealthy' } ], + output_template => 'Unhealty instances : %s', + perfdatas => [ + { label => 'unhealthy', value => 'unhealthy_absolute', template => '%s', + min => 0 }, + ], + } + }, + ] +} + +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 => { + 'region:s' => { name => 'region' }, + 'spot-fleet-request-id:s' => { name => 'spot_fleet_request_id' } + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + if (!defined($self->{option_results}->{region}) || $self->{option_results}->{region} eq '') { + $self->{output}->add_option_msg(short_msg => "Need to specify --region option."); + $self->{output}->option_exit(); + } + + if (!defined($self->{option_results}->{spot_fleet_request_id}) || $self->{option_results}->{spot_fleet_request_id} eq '') { + $self->{output}->add_option_msg(short_msg => "Need to specify --spot-fleet-request-id option."); + $self->{output}->option_exit(); + } + +} + +sub manage_selection { + my ($self, %options) = @_; + + $self->{global} = { active => 0, healthy => 0, unhealthy => 0 }; + $self->{instances} = $options{custom}->ec2spot_get_active_instances_status(region => $self->{option_results}->{region}, spot_fleet_request_id => $self->{option_results}->{spot_fleet_request_id}); + + foreach my $instance_id (keys %{$self->{instances}}) { + $self->{global}->{active}++; + $self->{global}->{lc($self->{instances}->{$instance_id}->{health})}++; + } +} + +1; + +__END__ + +=head1 MODE + +Check EC2 Spot active instance for a specific fleet + +=over 8 + +=item B<--warning-*> B<--critical-*> + +Warning and Critical thresholds. You can use 'active', 'healthy', 'unhealthy' + +=back + +=cut diff --git a/cloud/aws/ec2/plugin.pm b/cloud/aws/ec2/plugin.pm index e8eabedaa..a359235ba 100644 --- a/cloud/aws/ec2/plugin.pm +++ b/cloud/aws/ec2/plugin.pm @@ -31,16 +31,17 @@ sub new { $self->{version} = '0.1'; %{ $self->{modes} } = ( - 'asg-status' => 'cloud::aws::ec2::mode::asgstatus', - 'cpu' => 'cloud::aws::ec2::mode::cpu', - 'discovery' => 'cloud::aws::ec2::mode::discovery', - 'diskio' => 'cloud::aws::ec2::mode::diskio', - 'instances-status' => 'cloud::aws::ec2::mode::instancesstatus', - 'instances-types' => 'cloud::aws::ec2::mode::instancestypes', - 'list-asg' => 'cloud::aws::ec2::mode::listasg', - 'list-instances' => 'cloud::aws::ec2::mode::listinstances', - 'network' => 'cloud::aws::ec2::mode::network', - 'status' => 'cloud::aws::ec2::mode::status', + 'asg-status' => 'cloud::aws::ec2::mode::asgstatus', + 'cpu' => 'cloud::aws::ec2::mode::cpu', + 'discovery' => 'cloud::aws::ec2::mode::discovery', + 'diskio' => 'cloud::aws::ec2::mode::diskio', + 'instances-status' => 'cloud::aws::ec2::mode::instancesstatus', + 'instances-types' => 'cloud::aws::ec2::mode::instancestypes', + 'list-asg' => 'cloud::aws::ec2::mode::listasg', + 'list-instances' => 'cloud::aws::ec2::mode::listinstances', + 'network' => 'cloud::aws::ec2::mode::network', + 'status' => 'cloud::aws::ec2::mode::status', + 'spot-active-instances' => 'cloud::aws::ec2::mode::spotactiveinstances' ); $self->{custom_modes}{paws} = 'cloud::aws::custom::paws'; From 368b365f9d468fc7109e0638a6d43b38421f759c Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 20 Apr 2020 17:53:03 +0200 Subject: [PATCH 120/283] Fix #1950 --- network/freebox/restapi/custom/api.pm | 15 ++--- network/freebox/restapi/mode/dslusage.pm | 55 +++++++++--------- network/freebox/restapi/mode/netusage.pm | 68 ++++++++++------------ network/freebox/restapi/mode/system.pm | 74 +++++++++++------------- 4 files changed, 100 insertions(+), 112 deletions(-) diff --git a/network/freebox/restapi/custom/api.pm b/network/freebox/restapi/custom/api.pm index 4140b571b..2b19aa9cc 100644 --- a/network/freebox/restapi/custom/api.pm +++ b/network/freebox/restapi/custom/api.pm @@ -214,15 +214,18 @@ sub get_performance { $encoded = encode_json($json_request); }; if ($@) { - $self->{output}->add_option_msg(short_msg => "Cannot encode json request"); + $self->{output}->add_option_msg(short_msg => 'Cannot encode json request'); $self->{output}->option_exit(); } $self->settings(); - my $content = $self->{http}->request(url_path => '/api/' . $self->{freebox_api_version} . '/' . $options{path}, - method => 'POST', query_form_post => $encoded, - critical_status => '', warning_status => '', unknown_status => ''); + my $content = $self->{http}->request( + url_path => '/api/' . $self->{freebox_api_version} . '/' . $options{path}, + method => 'POST', query_form_post => $encoded, + critical_status => '', warning_status => '', unknown_status => '' + ); my $decoded = $self->manage_response(content => $content); + my ($datas, $total) = ({}, 0); foreach my $data (@{$decoded->{result}->{data}}) { foreach my $label (keys %$data) { @@ -233,9 +236,7 @@ sub get_performance { $total++; } - foreach (keys %$datas) { - $datas->{$_} /= $total; - } + $datas->{$_} = $datas->{$_} / $total / 100 foreach (keys %$datas); return $datas; } diff --git a/network/freebox/restapi/mode/dslusage.pm b/network/freebox/restapi/mode/dslusage.pm index 84856a3ca..42d6ea608 100644 --- a/network/freebox/restapi/mode/dslusage.pm +++ b/network/freebox/restapi/mode/dslusage.pm @@ -27,7 +27,7 @@ use warnings; sub set_counters { my ($self, %options) = @_; - + $self->{maps_counters_type} = [ { name => 'global', type => 0 }, ]; @@ -38,9 +38,9 @@ sub set_counters { output_template => 'Dsl available upload bandwidth : %.2f %s/s', output_change_bytes => 2, perfdatas => [ - { label => 'rate_up', value => 'rate_up_absolute', template => '%.2f', - unit => 'b/s', min => 0 }, - ], + { label => 'rate_up', value => 'rate_up_absolute', template => '%s', + unit => 'b/s', min => 0 } + ] } }, { label => 'rate-down', set => { @@ -48,9 +48,9 @@ sub set_counters { output_template => 'Dsl available download bandwidth : %.2f %s/s', output_change_bytes => 2, perfdatas => [ - { label => 'rate_down', value => 'rate_down_absolute', template => '%.2f', - unit => 'b/s', min => 0 }, - ], + { label => 'rate_down', value => 'rate_down_absolute', template => '%s', + unit => 'b/s', min => 0 } + ] } }, { label => 'snr-up', set => { @@ -59,8 +59,8 @@ sub set_counters { output_change_bytes => 2, perfdatas => [ { label => 'snr_up', value => 'snr_up_absolute', template => '%.2f', - unit => 'dB' }, - ], + unit => 'dB' } + ] } }, { label => 'snr-down', set => { @@ -69,10 +69,10 @@ sub set_counters { output_change_bytes => 2, perfdatas => [ { label => 'snr_down', value => 'snr_down_absolute', template => '%.2f', - unit => 'dB' }, - ], + unit => 'dB' } + ] } - }, + } ]; } @@ -80,21 +80,23 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - - $options{options}->add_options(arguments => - { - }); - + + $options{options}->add_options(arguments => { + }); + return $self; } sub manage_selection { my ($self, %options) = @_; - - my $result = $options{custom}->get_performance(db => 'dsl', path => 'rrd/'); - $result->{snr_up} *= 10 if (defined($result->{snr_up})); - $result->{snr_down} *= 10 if (defined($result->{snr_down})); - $self->{global} = { %{$result} }; + + $self->{global} = $options{custom}->get_performance(db => 'dsl', path => 'rrd/'); + $self->{global}->{snr_up} *= 10 if (defined($self->{global}->{snr_up})); + $self->{global}->{snr_down} *= 10 if (defined($self->{global}->{snr_down})); + $self->{global}->{rate_up} *= int($self->{global}->{rate_up} * 8) + if (defined($self->{global}->{rate_up})); + $self->{global}->{rate_down} *= int($self->{global}->{rate_down} * 8) + if (defined($self->{global}->{rate_down})); } 1; @@ -112,14 +114,9 @@ Check dsl usage. Only display some counters (regexp can be used). Example: --filter-counters='^rate-up$' -=item B<--warning-*> +=item B<--warning-*> B<--critical-*> -Threshold warning. -Can be: 'rate-up', 'rate-down', 'snr-up', 'snr-down'. - -=item B<--critical-*> - -Threshold critical. +Thresholds. Can be: 'rate-up', 'rate-down', 'snr-up', 'snr-down'. =back diff --git a/network/freebox/restapi/mode/netusage.pm b/network/freebox/restapi/mode/netusage.pm index 765ce1840..f0bc001ad 100644 --- a/network/freebox/restapi/mode/netusage.pm +++ b/network/freebox/restapi/mode/netusage.pm @@ -27,9 +27,9 @@ use warnings; sub set_counters { my ($self, %options) = @_; - + $self->{maps_counters_type} = [ - { name => 'global', type => 0, skipped_code => { -10 => 1 } }, + { name => 'global', type => 0, skipped_code => { -10 => 1 } } ]; $self->{maps_counters}->{global} = [ @@ -38,9 +38,9 @@ sub set_counters { output_template => 'Upload available bandwidth : %.2f %s/s', output_change_bytes => 2, perfdatas => [ - { label => 'bw_up', value => 'bw_up_absolute', template => '%.2f', - unit => 'b/s', min => 0 }, - ], + { label => 'bw_up', value => 'bw_up_absolute', template => '%s', + unit => 'b/s', min => 0 } + ] } }, { label => 'bw-down', set => { @@ -48,9 +48,9 @@ sub set_counters { output_template => 'Download available bandwidth : %.2f %s/s', output_change_bytes => 2, perfdatas => [ - { label => 'bw_down', value => 'bw_down_absolute', template => '%.2f', - unit => 'b/s', min => 0 }, - ], + { label => 'bw_down', value => 'bw_down_absolute', template => '%s', + unit => 'b/s', min => 0 } + ] } }, { label => 'rate-up', set => { @@ -58,9 +58,9 @@ sub set_counters { output_template => 'Upload rate : %.2f %s/s', output_change_bytes => 2, perfdatas => [ - { label => 'rate_up', value => 'rate_up_absolute', template => '%.2f', - unit => 'b/s', min => 0 }, - ], + { label => 'rate_up', value => 'rate_up_absolute', template => '%s', + unit => 'b/s', min => 0 } + ] } }, { label => 'rate-down', set => { @@ -68,9 +68,9 @@ sub set_counters { output_template => 'Download rate : %.2f %s/s', output_change_bytes => 2, perfdatas => [ - { label => 'rate_down', value => 'rate_down_absolute', template => '%.2f', - unit => 'b/s', min => 0 }, - ], + { label => 'rate_down', value => 'rate_down_absolute', template => '%s', + unit => 'b/s', min => 0 } + ] } }, { label => 'vpn-rate-up', set => { @@ -78,21 +78,21 @@ sub set_counters { output_template => 'Vpn client upload rate : %.2f %s/s', output_change_bytes => 2, perfdatas => [ - { label => 'vpn_rate_up', value => 'vpn_rate_up_absolute', template => '%.2f', - unit => 'b/s', min => 0 }, - ], + { label => 'vpn_rate_up', value => 'vpn_rate_up_absolute', template => '%s', + unit => 'b/s', min => 0 } + ] } }, - { label => 'vpn-rate-down', set => { + { label => 'vpn-rate-down', set => { key_values => [ { name => 'vpn_rate_down' } ], output_template => 'Vpn client download rate : %.2f %s/s', output_change_bytes => 2, perfdatas => [ - { label => 'vpn_rate_down', value => 'vpn_rate_down_absolute', template => '%.2f', - unit => 'b/s', min => 0 }, - ], + { label => 'vpn_rate_down', value => 'vpn_rate_down_absolute', template => '%s', + unit => 'b/s', min => 0 } + ] } - }, + } ]; } @@ -100,19 +100,18 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - - $options{options}->add_options(arguments => - { - }); - + + $options{options}->add_options(arguments => { + }); + return $self; } sub manage_selection { my ($self, %options) = @_; - - my $result = $options{custom}->get_performance(db => 'net', path => 'rrd/'); - $self->{global} = { %{$result} }; + + $self->{global} = $options{custom}->get_performance(db => 'net', path => 'rrd/'); + $self->{global}->{$_} = int($self->{global}->{$_} * 8) foreach (keys %{$self->{global}}); } 1; @@ -130,14 +129,9 @@ Check network usage. Only display some counters (regexp can be used). Example: --filter-counters='^bw-up$' -=item B<--warning-*> +=item B<--warning-*> B<--critical-*> -Threshold warning. -Can be: 'bw-up', 'bw-down', 'rate-up', 'rate-down', 'vpn-rate-up', 'vpn-rate-down'. - -=item B<--critical-*> - -Threshold critical. +Thresholds. Can be: 'bw-up', 'bw-down', 'rate-up', 'rate-down', 'vpn-rate-up', 'vpn-rate-down'. =back diff --git a/network/freebox/restapi/mode/system.pm b/network/freebox/restapi/mode/system.pm index 505985b88..a57c43ee1 100644 --- a/network/freebox/restapi/mode/system.pm +++ b/network/freebox/restapi/mode/system.pm @@ -28,20 +28,20 @@ use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold) sub set_counters { my ($self, %options) = @_; - + $self->{maps_counters_type} = [ { name => 'global', type => 0 }, { name => 'wifi', type => 1, cb_prefix_output => 'prefix_wifi_output', message_multiple => 'All wifis are ok' } ]; - + $self->{maps_counters}->{global} = [ { label => 'temperature-cpum', set => { key_values => [ { name => 'temp_cpum' } ], output_template => 'Temperature cpum : %s C', perfdatas => [ { label => 'temp_cpum', value => 'temp_cpum_absolute', template => '%s', - unit => 'C' }, - ], + unit => 'C' } + ] } }, { label => 'temperature-cpub', set => { @@ -49,8 +49,8 @@ sub set_counters { output_template => 'Temperature cpub : %s C', perfdatas => [ { label => 'temp_cpub', value => 'temp_cpub_absolute', template => '%s', - unit => 'C' }, - ], + unit => 'C' } + ] } }, { label => 'temperature-switch', set => { @@ -58,8 +58,8 @@ sub set_counters { output_template => 'Temperature switch : %s C', perfdatas => [ { label => 'temp_sw', value => 'temp_sw_absolute', template => '%s', - unit => 'C' }, - ], + unit => 'C' } + ] } }, { label => 'fan-speed', set => { @@ -67,8 +67,8 @@ sub set_counters { output_template => 'fan speed : %s rpm', perfdatas => [ { label => 'fan_rpm', value => 'fan_rpm_absolute', template => '%s', - min => 0, unit => 'rpm' }, - ], + min => 0, unit => 'rpm' } + ] } }, { label => 'disk-status', threshold => 0, set => { @@ -76,10 +76,9 @@ sub set_counters { closure_custom_calc => $self->can('custom_disk_status_calc'), closure_custom_output => $self->can('custom_disk_status_output'), closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => \&catalog_status_threshold, + closure_custom_threshold_check => \&catalog_status_threshold } - }, - + } ]; $self->{maps_counters}->{wifi} = [ @@ -88,17 +87,16 @@ sub set_counters { closure_custom_calc => $self->can('custom_wifi_status_calc'), closure_custom_output => $self->can('custom_wifi_status_output'), closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => \&catalog_status_threshold, + closure_custom_threshold_check => \&catalog_status_threshold } - }, + } ]; } sub custom_disk_status_output { my ($self, %options) = @_; - my $msg = 'Disk status : ' . $self->{result_values}->{status}; - return $msg; + return 'Disk status : ' . $self->{result_values}->{status}; } sub custom_disk_status_calc { @@ -110,9 +108,8 @@ sub custom_disk_status_calc { sub custom_wifi_status_output { my ($self, %options) = @_; - my $msg = "Wifi '" . $self->{result_values}->{display} . "' status : " . $self->{result_values}->{status}; - return $msg; + return "Wifi '" . $self->{result_values}->{display} . "' status : " . $self->{result_values}->{status}; } sub custom_wifi_status_calc { @@ -127,15 +124,14 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - - $options{options}->add_options(arguments => - { - "warning-wifi-status:s" => { name => 'warning_wifi_status', default => '%{status} =~ /bad_param/i' }, - "critical-wifi-status:s" => { name => 'critical_wifi_status', default => '%{status} =~ /failed/i' }, - "warning-disk-status:s" => { name => 'warning_disk_status', default => '' }, - "critical-disk-status:s" => { name => 'critical_disk_status', default => '%{status} =~ /error/i' }, - }); - + + $options{options}->add_options(arguments => { + 'warning-wifi-status:s' => { name => 'warning_wifi_status', default => '%{status} =~ /bad_param/i' }, + 'critical-wifi-status:s' => { name => 'critical_wifi_status', default => '%{status} =~ /failed/i' }, + 'warning-disk-status:s' => { name => 'warning_disk_status', default => '' }, + 'critical-disk-status:s' => { name => 'critical_disk_status', default => '%{status} =~ /error/i' }, + }); + return $self; } @@ -143,18 +139,23 @@ sub check_options { my ($self, %options) = @_; $self->SUPER::check_options(%options); - $self->change_macros(macros => ['warning_wifi_status', 'critical_wifi_status', 'warning_disk_status', 'critical_disk_status']); + $self->change_macros( + macros => [ + 'warning_wifi_status', 'critical_wifi_status', + 'warning_disk_status', 'critical_disk_status' + ] + ); } sub manage_selection { my ($self, %options) = @_; - + my $result = $options{custom}->get_data(path => 'system/'); $self->{global} = { %{$result} }; - + $result = $options{custom}->get_data(path => 'wifi/ap/'); $self->{wifi} = {}; - + $result = [$result] if (ref($result) ne 'ARRAY'); foreach (@$result) { $self->{wifi}->{$_->{id}} = { @@ -199,14 +200,9 @@ Can used special variables like: %{status} Set critical threshold for disk status (Default: '%{status} =~ /error/i'). Can used special variables like: %{status} -=item B<--warning-*> +=item B<--warning-*> B<--critical-*> -Threshold warning. -Can be: 'temperature-cpum', 'temperature-cpub', 'temperature-switch', 'fan-speed'. - -=item B<--critical-*> - -Threshold critical. +Thresholds. Can be: 'temperature-cpum', 'temperature-cpub', 'temperature-switch', 'fan-speed'. =back From 9e1f37a2e2a7b7f385bc96ab842fd99128478ef8 Mon Sep 17 00:00:00 2001 From: thibaults-centreon Date: Mon, 20 Apr 2020 19:37:10 +0200 Subject: [PATCH 121/283] add(plugin): Mulesoft Restapi --- apps/mulesoft/restapi/custom/api.pm | 349 ++++++++++++++++++ apps/mulesoft/restapi/mode/applications.pm | 198 ++++++++++ .../mulesoft/restapi/mode/listapplications.pm | 107 ++++++ apps/mulesoft/restapi/plugin.pm | 50 +++ centreon/plugins/script_custom.pm | 2 +- centreon/plugins/script_sql.pm | 2 +- 6 files changed, 706 insertions(+), 2 deletions(-) create mode 100644 apps/mulesoft/restapi/custom/api.pm create mode 100644 apps/mulesoft/restapi/mode/applications.pm create mode 100644 apps/mulesoft/restapi/mode/listapplications.pm create mode 100644 apps/mulesoft/restapi/plugin.pm diff --git a/apps/mulesoft/restapi/custom/api.pm b/apps/mulesoft/restapi/custom/api.pm new file mode 100644 index 000000000..b8f98d509 --- /dev/null +++ b/apps/mulesoft/restapi/custom/api.pm @@ -0,0 +1,349 @@ +# +# Copyright 2020 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::mulesoft::restapi::custom::api; + +use strict; +use warnings; +use DateTime; +use centreon::plugins::http; +use centreon::plugins::statefile; +use JSON::XS; +use URI::Encode; +use Digest::MD5 qw(md5_hex); + +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 => { + 'api-username:s' => { name => 'api_username' }, + 'api-password:s' => { name => 'api_password' }, + 'environment-id:s' => { name => 'environment_id' }, + 'organization-id:s' => { name => 'organization_id' }, + 'hostname:s' => { name => 'hostname' }, + 'port:s' => { name => 'port' }, + 'proto:s' => { name => 'proto' }, + 'timeout:s' => { name => 'timeout' }, + 'reload-cache-time:s' => { name => 'reload_cache_time' }, + 'authent-endpoint:s' => { name => 'authent_endpoint'}, + 'monitoring-endpoint:s' => { name => 'monitoring_endpoint'}, + }); + } + $options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1); + + $self->{output} = $options{output}; + $self->{mode} = $options{mode}; + $self->{http} = centreon::plugins::http->new(%options); + $self->{cache} = centreon::plugins::statefile->new(%options); + + return $self; +} + +sub set_options { + my ($self, %options) = @_; + + $self->{option_results} = $options{option_results}; +} + +sub set_defaults { + my ($self, %options) = @_; + + 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} = (defined($self->{option_results}->{hostname})) ? $self->{option_results}->{hostname} : 'eu1.anypoint.mulesoft.com'; + $self->{port} = (defined($self->{option_results}->{port})) ? $self->{option_results}->{port} : 443; + $self->{proto} = (defined($self->{option_results}->{proto})) ? $self->{option_results}->{proto} : 'https'; + $self->{timeout} = (defined($self->{option_results}->{timeout})) ? $self->{option_results}->{timeout} : 10; + $self->{authent_endpoint} = (defined($self->{option_results}->{authent_endpoint})) ? $self->{option_results}->{authent_endpoint} : '/accounts/login'; + $self->{monitoring_endpoint} = (defined($self->{option_results}->{monitoring_endpoint})) ? $self->{option_results}->{monitoring_endpoint} : '/hybrid/api/v1'; + $self->{api_username} = (defined($self->{option_results}->{api_username})) ? $self->{option_results}->{api_username} : ''; + $self->{api_password} = (defined($self->{option_results}->{api_password})) ? $self->{option_results}->{api_password} : ''; + $self->{environment_id} = (defined($self->{option_results}->{environment_id})) ? $self->{option_results}->{environment_id} : ''; + $self->{organization_id} = (defined($self->{option_results}->{organization_id})) ? $self->{option_results}->{organization_id} : ''; + $self->{reload_cache_time} = (defined($self->{option_results}->{reload_cache_time})) ? $self->{option_results}->{reload_cache_time} : 180; + $self->{cache}->check_options(option_results => $self->{option_results}); + + if (!defined($self->{environment_id}) || $self->{environment_id} eq '' || !defined($self->{organization_id}) || $self->{organization_id} eq '' ) { + $self->{output}->add_option_msg(short_msg => "--environment-id and --organization-id must be set"); + $self->{output}->option_exit(); + } + if (!defined($self->{api_username}) || $self->{api_username} eq '' || !defined($self->{api_password}) || $self->{api_password} eq '' ) { + $self->{output}->add_option_msg(short_msg => "--api-username and --api-password must be set"); + $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}; + $self->{option_results}->{warning_status} = ''; + $self->{option_results}->{critical_status} = ''; + $self->{option_results}->{unknown_status} = '%{http_code} < 200 or %{http_code} > 400'; +} + +sub settings { + my ($self, %options) = @_; + + $self->build_options_for_httplib(); + $self->{http}->add_header(key => 'Accept', value => 'application/json'); + $self->{http}->add_header(key => 'Content-Type', value => $options{content_type}); + $self->{http}->add_header(key => 'Authorization', value => 'Bearer ' . $self->{access_token}) if (defined($self->{access_token})); + $self->{http}->add_header(key => 'X-ANYPNT-ENV-ID', value => $self->{environment_id}) if (defined $options{environment_header}); + $self->{http}->add_header(key => 'X-ANYPNT-ORG-ID', value => $self->{organization_id}) if (defined $options{organization_header}); + $self->{http}->set_options(%{$self->{option_results}}); +} + +sub get_access_token { + my ($self, %options) = @_; + + my $has_cache_file = $options{statefile}->read(statefile => 'mulesoft_api_' . md5_hex($self->{hostname}) . '_' . md5_hex($self->{api_username})); + my $expires_on = $options{statefile}->get(name => 'expires_on'); + my $access_token = $options{statefile}->get(name => 'access_token'); + if ( $has_cache_file == 0 || !defined($access_token) || (($expires_on - time()) < 10) ) { + #my ($username, $password) = ( $self->{api_username}, $self->{api_password} ); + my $login = { username => $self->{api_username}, password => $self->{api_password} }; + my $post_json = JSON::XS->new->utf8->encode($login); + + $self->settings(content_type => 'application/json'); + + my $content = $self->{http}->request( + method => 'POST', + query_form_post => $post_json, + url_path => $self->{authent_endpoint} + ); + + if (!defined($content) || $content eq '') { + $self->{output}->add_option_msg(short_msg => "Authentication endpoint returns empty content [code: '" . $self->{http}->get_code() . "'] [message: '" . $self->{http}->get_message() . "']"); + $self->{output}->option_exit(); + } + + my $decoded; + eval { + $decoded = JSON::XS->new->utf8->decode($content); + }; + if ($@) { + $self->{output}->output_add(long_msg => $content, debug => 1); + $self->{output}->add_option_msg(short_msg => "Cannot decode response (add --debug option to display returned content)"); + $self->{output}->option_exit(); + } + if (defined($decoded->{error_code})) { + $self->{output}->output_add(long_msg => "Error message : " . $decoded->{error}, debug => 1); + $self->{output}->add_option_msg(short_msg => "Authentication endpoint returns error code '" . $decoded->{error_code} . "' (add --debug option for detailed message)"); + $self->{output}->option_exit(); + } + + $access_token = $decoded->{access_token}; + my $datas = { last_timestamp => time(), access_token => $decoded->{access_token}, expires_on => time() + 3600 }; + $options{statefile}->write(data => $datas); + } + + return $access_token; +} + +sub request_api { + my ($self, %options) = @_; + + if (!defined($self->{access_token})) { + $self->{access_token} = $self->get_access_token(statefile => $self->{cache}); + } + + $self->settings(content_type => 'application/x-www-form-urlencoded', environment_header => 1, organization_header => 1); + + $self->{output}->output_add(long_msg => "URL: '" . $self->{proto} . '://' . $self->{hostname} . ':' . $self->{port} . + $options{url_path} . "'", debug => 1); + + my $content = $self->{http}->request(%options); + + if (!defined($content) || $content 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->utf8->decode($content); + }; + if ($@) { + $self->{output}->output_add(long_msg => $content, debug => 1); + $self->{output}->add_option_msg(short_msg => "Cannot decode response (add --debug option to display returned content)"); + $self->{output}->option_exit(); + } + if (defined($decoded->{error_code})) { + $self->{output}->output_add(long_msg => "Error message : " . $decoded->{error}, debug => 1); + $self->{output}->add_option_msg(short_msg => "API returns error code '" . $decoded->{error_code} . "' (add --debug option for detailed message)"); + $self->{output}->option_exit(); + } + + return $decoded; +} + +sub list_applications { + my ($self, %options) = @_; + + my $url_path = $self->{monitoring_endpoint} . '/applications'; + my $response = $self->request_api(method => 'GET', url_path => $url_path); + + return $response->{data}; +} + +sub get_application_status { + my ($self, %options) = @_; + + my $url_path = $self->{monitoring_endpoint} . '/applications/' . $options{applicationId}; + my $response = $self->request_api(method => 'GET', url_path => $url_path); + + return $response->{data}; +} + +sub get_application_metrics { + my ($self, %options) = @_; + + my $url_path = $self->{monitoring_endpoint} . '/applications/flows/' . $options{applicationId}; + my $response = $self->request_api(method => 'GET', url_path => $url_path); + + return $response->{data}; +} + +sub list_servers { + my ($self, %options) = @_; + + my $url_path = '/servers'; + my $response = $self->request_api(method => 'GET', url_path => $url_path); + + return $response->{servers}; +} + +sub get_server_status { + my ($self, %options) = @_; + + my $url_path = $self->{monitoring_endpoint} . '/servers/' . $options{serverId}; + my $response = $self->request_api(method => 'GET', url_path => $url_path); + + return $response->{server}; +} + + +sub cache_hosts { + my ($self, %options) = @_; + + $self->{cache_hosts} = centreon::plugins::statefile->new(%options); + $self->{cache_hosts}->check_options(option_results => $self->{option_results}); + my $has_cache_file = $self->{cache_hosts}->read(statefile => 'cache_ovirt_hosts_' . md5_hex($self->{hostname}) . '_' . md5_hex($self->{api_username})); + my $timestamp_cache = $self->{cache_hosts}->get(name => 'last_timestamp'); + my $hosts = $self->{cache_hosts}->get(name => 'hosts'); + if ($has_cache_file == 0 || !defined($timestamp_cache) || ((time() - $timestamp_cache) > (($self->{reload_cache_time}) * 60))) { + $hosts = []; + my $datas = { last_timestamp => time(), hosts => $hosts }; + my $list = $self->list_hosts(); + foreach (@{$list}) { + push @{$hosts}, { id => $_->{id}, name => $_->{name} }; + } + $self->{cache_hosts}->write(data => $datas); + } + + return $hosts; +} + +1; + +__END__ + +=head1 NAME + +Mulesoft Rest API + +=head1 REST API OPTIONS + +Mulesoft Rest API + +=over 8 + +=item B<--hostname> + +Mulesoft API hostname (Default: anypoint.mulesoft.com). + +=item B<--port> + +Port used (Default: 443) + +=item B<--proto> + +Specify https if needed (Default: 'https') + +=item B<--api-username> + +Mulesoft API username (mandatory). + +=item B<--api-password> + +Mulesoft API password (mandatory). + +=item B<--environment-id> + +Mulesoft API Environment ID (mandatory). + +=item B<--organization-id> + +Mulesoft API Organization ID (mandatory). + +=item B<--timeout> + +Set timeout in seconds (Default: 10). + +=back + +=head1 DESCRIPTION + +B. + +=cut diff --git a/apps/mulesoft/restapi/mode/applications.pm b/apps/mulesoft/restapi/mode/applications.pm new file mode 100644 index 000000000..31f8840c7 --- /dev/null +++ b/apps/mulesoft/restapi/mode/applications.pm @@ -0,0 +1,198 @@ +# +# Copyright 2020 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::mulesoft::restapi::mode::applications; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold); +use Data::Dumper; + +sub custom_status_output { + my ($self, %options) = @_; + return my $msg = sprintf('Id: %s, Status: %s', $self->{result_values}->{id}, $self->{result_values}->{status}); +} + +sub custom_status_calc { + my ($self, %options) = @_; + $self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_status'}; + $self->{result_values}->{id} = $options{new_datas}->{$self->{instance} . '_id'}; + return 0; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0, cb_prefix_output => 'prefix_global_output' }, + { name => 'applications', type => 1, cb_prefix_output => 'prefix_application_output', + message_multiple => 'All applications are ok' }, + ]; + + $self->{maps_counters}->{global} = [ + { label => 'total', nlabel => 'mulesoft.applications.total.count', set => { + key_values => [ { name => 'total' } ], + output_template => "Total : %s", + perfdatas => [ + { value => 'total_absolute', template => '%d', min => 0 }, + ], + } + }, + { label => 'started', nlabel => 'mulesoft.applications.status.started.count', set => { + key_values => [ { name => 'started' } ], + output_template => "Started : %s", + perfdatas => [ + { value => 'started_absolute', template => '%d', min => 0 }, + ], + } + }, + { label => 'stopped', nlabel => 'mulesoft.applications.status.stopped.count', set => { + key_values => [ { name => 'stopped' } ], + output_template => "Stopped : %s", + perfdatas => [ + { value => 'stopped_absolute', template => '%d', min => 0 }, + ], + } + }, + { label => 'failed', nlabel => 'mulesoft.applications.status.failed.count', set => { + key_values => [ { name => 'failed' } ], + output_template => "Failed : %s", + perfdatas => [ + { value => 'failed_absolute', template => '%d', min => 0 }, + ], + } + } + ]; + + $self->{maps_counters}->{applications} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'id' }, { name => 'status' }, { name => 'name'}, { name => 'display' } ], + closure_custom_calc => $self->can('custom_status_calc'), + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold, + } + }, + ]; +} + +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' }, + "warning-status:s" => { name => 'warning_status', default => '' }, + "critical-status:s" => { name => 'critical_status', default => '%{status} ne "STARTED"' }, + #"critical-status:s" => { name => 'critical_status', default => '' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->change_macros(macros => ['warning_status', 'critical_status']); +} + +sub prefix_global_output { + my ($self, %options) = @_; + + return "Total applications "; +} + +sub prefix_application_output { + my ($self, %options) = @_; + + return "Application '" . $options{instance_value}->{name} . "' "; +} + +sub manage_selection { + my ($self, %options) = @_; + + $self->{global} = { started => 0, stopped => 0, failed => 0 }; + $self->{applications} = {}; + my $result = $options{custom}->list_applications(); + #print Dumper($result); + foreach my $application (@{$result}) { + next if ( defined($self->{option_results}->{filter_name}) + && $self->{option_results}->{filter_name} ne '' + && $application->{name} !~ /$self->{option_results}->{filter_name}/ ); + $self->{applications}->{$application} = { + display => $application, + id => $application->{id}, + name => $application->{name}, + status => $application->{lastReportedStatus}, + }; + $self->{global}->{started}++ if $application->{lastReportedStatus} =~ m/STARTED/; + $self->{global}->{stopped}++ if $application->{lastReportedStatus} =~ m/STOPPED/; + $self->{global}->{failed}++ if $application->{lastReportedStatus} =~ m/FAILED/; + #print Dumper($self->{applications}->{application}); + } + if (scalar(keys %{$self->{applications}}) <= 0) { + $self->{output}->add_option_msg(short_msg => "No application found."); + $self->{output}->option_exit(); + } + $self->{global}->{total} = scalar (keys %{$self->{applications}}); +} + +1; + +__END__ + +=head1 MODE + +Check Mulesoft Applications status. + +Example: +perl centreon_plugins.pl --plugin=apps::mulesoft::restapi::plugin --mode=applications +--environment-id='1234abc-56de-78fg-90hi-1234abcdefg' --organization-id='1234abcd-56ef-78fg-90hi-1234abcdefg' +--api-username='myapiuser' --api-password='myapipassword' --verbose + +More information on'https://anypoint.mulesoft.com/exchange/portals/anypoint-platform/'. + +=over 8 + +=item B<--filter-name> + +Filter by application name (Regexp can be used). +Example: --filter-name='^application1$' + +=item B<--warning-status> + +Set warning threshold for status (Default: ''). +Threshold can be matched on %{name}, %{id} or %{status} and Regexp can be used. +Typical syntax: --warning-status=%{status} ne "STARTED" + +=item B<--critical-status> + +Set warning threshold for status (Default: ''). +Threshold can be matched on %{name}, %{id} or %{status} and Regexp can be used. +Typical syntax: --critical-status=%{status} ~= m/FAILED/" + + +=back + +=cut diff --git a/apps/mulesoft/restapi/mode/listapplications.pm b/apps/mulesoft/restapi/mode/listapplications.pm new file mode 100644 index 000000000..0e2b493aa --- /dev/null +++ b/apps/mulesoft/restapi/mode/listapplications.pm @@ -0,0 +1,107 @@ +# +# Copyright 2020 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::mulesoft::restapi::mode::listapplications; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $options{options}->add_options(arguments => { + "filter-name:s" => { name => 'filter_name' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); +} + +sub manage_selection { + my ($self, %options) = @_; + + $self->{data} = $options{custom}->list_applications(); +} + +sub run { + my ($self, %options) = @_; + + my $result = $options{custom}->list_applications(); + foreach my $application (@{$result}) { + #print $application->{id}; + next if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' + && $application->{name} !~ /$self->{option_results}->{filter_name}/); + + $self->{output}->output_add(long_msg => sprintf("[id = %s][name = %s][status = %s]", + $application->{id}, + $application->{name}, + $application->{lastReportedStatus})); + } + + $self->{output}->output_add(severity => 'OK', + short_msg => 'Mulesoft Applications:'); + $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 => ['id', 'name', 'status']); +} + +sub disco_show { + my ($self, %options) = @_; + + $self->manage_selection(%options); + foreach my $application (@{$self->{data}}) { + $self->{output}->add_disco_entry( + id => $application->{id}, + name => $application->{name}, + status => $application->{lastReportedStatus}, + ); + } +} + +1; + +__END__ + +=head1 MODE + +List Mulesoft applications. + +=over 8 + +=item B<--filter-name> + +Filter host name (Can be a regexp). + +=back + +=cut diff --git a/apps/mulesoft/restapi/plugin.pm b/apps/mulesoft/restapi/plugin.pm new file mode 100644 index 000000000..9abef19bd --- /dev/null +++ b/apps/mulesoft/restapi/plugin.pm @@ -0,0 +1,50 @@ +# +# Copyright 2020 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::mulesoft::restapi::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}} = ( + 'applications' => 'apps::mulesoft::restapi::mode::applications', + 'listapplications' => 'apps::mulesoft::restapi::mode::listapplications' + ); + + $self->{custom_modes}{restapi} = 'apps::mulesoft::restapi::custom::api'; + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Mulesoft components using API. + +=cut diff --git a/centreon/plugins/script_custom.pm b/centreon/plugins/script_custom.pm index ca1f8aa63..636e1ff3b 100644 --- a/centreon/plugins/script_custom.pm +++ b/centreon/plugins/script_custom.pm @@ -294,7 +294,7 @@ List available custom modes. =item B<--multiple> -Multiple custom mode objects (some mode needs it). +Multiple custom mode objects (required by some specific modes) =item B<--pass-manager> diff --git a/centreon/plugins/script_sql.pm b/centreon/plugins/script_sql.pm index 383c70c51..e07be4f8d 100644 --- a/centreon/plugins/script_sql.pm +++ b/centreon/plugins/script_sql.pm @@ -291,7 +291,7 @@ List available sql modes. =item B<--multiple> -Multiple database connections (some mode needs it). +Multiple database connections (required by some specific modes). =item B<--pass-manager> From 1fe23859da5cb1de5c325edd603b9c53c835a5ba Mon Sep 17 00:00:00 2001 From: Colin Gagnaire Date: Mon, 20 Apr 2020 20:08:37 +0200 Subject: [PATCH 122/283] remove carriage return from edge description --- cloud/vmware/velocloud/restapi/mode/discovery.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/cloud/vmware/velocloud/restapi/mode/discovery.pm b/cloud/vmware/velocloud/restapi/mode/discovery.pm index 4cd26f4b2..1f2e14110 100644 --- a/cloud/vmware/velocloud/restapi/mode/discovery.pm +++ b/cloud/vmware/velocloud/restapi/mode/discovery.pm @@ -63,6 +63,7 @@ sub run { $edge{device_family} = $edge->{deviceFamily}; $edge{name} = $edge->{name}; $edge{description} = $edge->{description}; + $edge{description} =~ s/\n//g if (defined($edge{description})); $edge{edge_state} = $edge->{edgeState}; $edge{service_state} = $edge->{serviceState}; $edge{ha_state} = $edge->{haState}; From 77c6e7b50c446e4a469a6787ca1e35d218986b05 Mon Sep 17 00:00:00 2001 From: Matthieu Kermagoret Date: Tue, 21 Apr 2020 09:20:09 +0200 Subject: [PATCH 123/283] limit build history to 50 items. --- Jenkinsfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 769994fd1..b80a35c3b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,3 +1,5 @@ +properties([buildDiscarder(logRotator(numToKeepStr: '50'))]) + stage('Source') { node { sh 'setup_centreon_build.sh' From 8f534c9269e877b8bde32dd21cd67e5515be8257 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 21 Apr 2020 10:48:36 +0200 Subject: [PATCH 124/283] add voice-call for cisco vg --- network/cisco/vg/snmp/plugin.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/network/cisco/vg/snmp/plugin.pm b/network/cisco/vg/snmp/plugin.pm index 8ba0607cd..95a6eb0ee 100644 --- a/network/cisco/vg/snmp/plugin.pm +++ b/network/cisco/vg/snmp/plugin.pm @@ -34,6 +34,7 @@ sub new { 'interfaces' => 'snmp_standard::mode::interfaces', 'isdn-usage' => 'snmp_standard::mode::isdnusage', 'list-interfaces' => 'snmp_standard::mode::listinterfaces', + 'voice-call' => 'centreon::common::cisco::standard::snmp::mode::voicecall' ); return $self; From b0892d270e445d0af49f7c28980d9c9b46ff9791 Mon Sep 17 00:00:00 2001 From: thibaults-centreon Date: Tue, 21 Apr 2020 11:00:30 +0200 Subject: [PATCH 125/283] enh(plugin): Mulesoft cleanup and servers mode --- apps/mulesoft/restapi/custom/api.pm | 15 +- apps/mulesoft/restapi/mode/applications.pm | 63 +++--- .../mulesoft/restapi/mode/listapplications.pm | 8 +- apps/mulesoft/restapi/mode/listservers.pm | 106 ++++++++++ apps/mulesoft/restapi/mode/servers.pm | 183 ++++++++++++++++++ apps/mulesoft/restapi/plugin.pm | 6 +- 6 files changed, 326 insertions(+), 55 deletions(-) create mode 100644 apps/mulesoft/restapi/mode/listservers.pm create mode 100644 apps/mulesoft/restapi/mode/servers.pm diff --git a/apps/mulesoft/restapi/custom/api.pm b/apps/mulesoft/restapi/custom/api.pm index b8f98d509..2b1a2f4f5 100644 --- a/apps/mulesoft/restapi/custom/api.pm +++ b/apps/mulesoft/restapi/custom/api.pm @@ -245,22 +245,13 @@ sub get_application_status { return $response->{data}; } -sub get_application_metrics { - my ($self, %options) = @_; - - my $url_path = $self->{monitoring_endpoint} . '/applications/flows/' . $options{applicationId}; - my $response = $self->request_api(method => 'GET', url_path => $url_path); - - return $response->{data}; -} - sub list_servers { my ($self, %options) = @_; - my $url_path = '/servers'; + my $url_path = $self->{monitoring_endpoint} . '/servers/'; my $response = $self->request_api(method => 'GET', url_path => $url_path); - return $response->{servers}; + return $response->{data}; } sub get_server_status { @@ -269,7 +260,7 @@ sub get_server_status { my $url_path = $self->{monitoring_endpoint} . '/servers/' . $options{serverId}; my $response = $self->request_api(method => 'GET', url_path => $url_path); - return $response->{server}; + return $response->{data}; } diff --git a/apps/mulesoft/restapi/mode/applications.pm b/apps/mulesoft/restapi/mode/applications.pm index 31f8840c7..890e75979 100644 --- a/apps/mulesoft/restapi/mode/applications.pm +++ b/apps/mulesoft/restapi/mode/applications.pm @@ -25,7 +25,6 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold); -use Data::Dumper; sub custom_status_output { my ($self, %options) = @_; @@ -44,52 +43,43 @@ sub set_counters { $self->{maps_counters_type} = [ { name => 'global', type => 0, cb_prefix_output => 'prefix_global_output' }, - { name => 'applications', type => 1, cb_prefix_output => 'prefix_application_output', - message_multiple => 'All applications are ok' }, + { name => 'applications', type => 1, cb_prefix_output => 'prefix_application_output', message_multiple => 'All applications are ok' } ]; $self->{maps_counters}->{global} = [ { label => 'total', nlabel => 'mulesoft.applications.total.count', set => { - key_values => [ { name => 'total' } ], - output_template => "Total : %s", - perfdatas => [ - { value => 'total_absolute', template => '%d', min => 0 }, - ], + key_values => [ { name => 'total' } ], + output_template => "Total : %s", + perfdatas => [ { value => 'total_absolute', template => '%d', min => 0 } ], } }, { label => 'started', nlabel => 'mulesoft.applications.status.started.count', set => { - key_values => [ { name => 'started' } ], - output_template => "Started : %s", - perfdatas => [ - { value => 'started_absolute', template => '%d', min => 0 }, - ], + key_values => [ { name => 'started' } ], + output_template => "Started : %s", + perfdatas => [ { value => 'started_absolute', template => '%d', min => 0 } ] } }, { label => 'stopped', nlabel => 'mulesoft.applications.status.stopped.count', set => { - key_values => [ { name => 'stopped' } ], - output_template => "Stopped : %s", - perfdatas => [ - { value => 'stopped_absolute', template => '%d', min => 0 }, - ], + key_values => [ { name => 'stopped' } ], + output_template => "Stopped : %s", + perfdatas => [ { value => 'stopped_absolute', template => '%d', min => 0 } ] } }, { label => 'failed', nlabel => 'mulesoft.applications.status.failed.count', set => { - key_values => [ { name => 'failed' } ], - output_template => "Failed : %s", - perfdatas => [ - { value => 'failed_absolute', template => '%d', min => 0 }, - ], + key_values => [ { name => 'failed' } ], + output_template => "Failed : %s", + perfdatas => [ { value => 'failed_absolute', template => '%d', min => 0 } ] } } ]; $self->{maps_counters}->{applications} = [ { label => 'status', threshold => 0, set => { - key_values => [ { name => 'id' }, { name => 'status' }, { name => 'name'}, { name => 'display' } ], - closure_custom_calc => $self->can('custom_status_calc'), - closure_custom_output => $self->can('custom_status_output'), - closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => \&catalog_status_threshold, + key_values => [ { name => 'id' }, { name => 'status' }, { name => 'name'}, { name => 'display' } ], + closure_custom_calc => $self->can('custom_status_calc'), + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold, } }, ]; @@ -101,10 +91,9 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - "filter-name:s" => { name => 'filter_name' }, - "warning-status:s" => { name => 'warning_status', default => '' }, - "critical-status:s" => { name => 'critical_status', default => '%{status} ne "STARTED"' }, - #"critical-status:s" => { name => 'critical_status', default => '' }, + "filter-name:s" => { name => 'filter_name' }, + "warning-status:s" => { name => 'warning_status', default => '' }, + "critical-status:s" => { name => 'critical_status', default => '' } }); return $self; @@ -135,7 +124,7 @@ sub manage_selection { $self->{global} = { started => 0, stopped => 0, failed => 0 }; $self->{applications} = {}; my $result = $options{custom}->list_applications(); - #print Dumper($result); + foreach my $application (@{$result}) { next if ( defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' @@ -145,16 +134,18 @@ sub manage_selection { id => $application->{id}, name => $application->{name}, status => $application->{lastReportedStatus}, - }; + }; + $self->{global}->{started}++ if $application->{lastReportedStatus} =~ m/STARTED/; $self->{global}->{stopped}++ if $application->{lastReportedStatus} =~ m/STOPPED/; $self->{global}->{failed}++ if $application->{lastReportedStatus} =~ m/FAILED/; - #print Dumper($self->{applications}->{application}); } + if (scalar(keys %{$self->{applications}}) <= 0) { $self->{output}->add_option_msg(short_msg => "No application found."); $self->{output}->option_exit(); } + $self->{global}->{total} = scalar (keys %{$self->{applications}}); } @@ -164,7 +155,7 @@ __END__ =head1 MODE -Check Mulesoft Applications status. +Check Mulesoft Anypoint Applications status. Example: perl centreon_plugins.pl --plugin=apps::mulesoft::restapi::plugin --mode=applications diff --git a/apps/mulesoft/restapi/mode/listapplications.pm b/apps/mulesoft/restapi/mode/listapplications.pm index 0e2b493aa..2b7641bec 100644 --- a/apps/mulesoft/restapi/mode/listapplications.pm +++ b/apps/mulesoft/restapi/mode/listapplications.pm @@ -53,7 +53,6 @@ sub run { my $result = $options{custom}->list_applications(); foreach my $application (@{$result}) { - #print $application->{id}; next if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && $application->{name} !~ /$self->{option_results}->{filter_name}/); @@ -63,8 +62,7 @@ sub run { $application->{lastReportedStatus})); } - $self->{output}->output_add(severity => 'OK', - short_msg => 'Mulesoft Applications:'); + $self->{output}->output_add(severity => 'OK', short_msg => 'Mulesoft Anypoint Applications:'); $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1); $self->{output}->exit(); } @@ -94,13 +92,13 @@ __END__ =head1 MODE -List Mulesoft applications. +List Mulesoft Anypoint applications. =over 8 =item B<--filter-name> -Filter host name (Can be a regexp). +Filter application name (Can be a regexp). =back diff --git a/apps/mulesoft/restapi/mode/listservers.pm b/apps/mulesoft/restapi/mode/listservers.pm new file mode 100644 index 000000000..e774d5b2d --- /dev/null +++ b/apps/mulesoft/restapi/mode/listservers.pm @@ -0,0 +1,106 @@ +# +# Copyright 2020 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and server 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::mulesoft::restapi::mode::listservers; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $options{options}->add_options(arguments => { + "filter-name:s" => { name => 'filter_name' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); +} + +sub manage_selection { + my ($self, %options) = @_; + + $self->{data} = $options{custom}->list_servers(); +} + +sub run { + my ($self, %options) = @_; + + my $result = $options{custom}->list_servers(); + foreach my $server (@{$result}) { + next if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' + && $server->{name} !~ /$self->{option_results}->{filter_name}/); + + $self->{output}->output_add(long_msg => sprintf("[id = %s][name = %s][status = %s]", + $server->{id}, + $server->{name}, + $server->{status} + )); + } + + $self->{output}->output_add(severity => 'OK', short_msg => 'Mulesoft Anypoint Servers:'); + $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 => ['id', 'name', 'status']); +} + +sub disco_show { + my ($self, %options) = @_; + + $self->manage_selection(%options); + foreach my $server (@{$self->{data}}) { + $self->{output}->add_disco_entry( + id => $server->{id}, + name => $server->{name}, + status => $server->{status}, + ); + } +} + +1; + +__END__ + +=head1 MODE + +List Mulesoft Anypoint Servers. + +=over 8 + +=item B<--filter-name> + +Filter server name (Can be a regexp). + +=back + +=cut diff --git a/apps/mulesoft/restapi/mode/servers.pm b/apps/mulesoft/restapi/mode/servers.pm new file mode 100644 index 000000000..e84f937e6 --- /dev/null +++ b/apps/mulesoft/restapi/mode/servers.pm @@ -0,0 +1,183 @@ +# +# Copyright 2020 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and server 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::mulesoft::restapi::mode::servers; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold); +use DateTime; + +sub custom_status_output { + my ($self, %options) = @_; + return my $msg = sprintf('Id: %s, Status: %s', $self->{result_values}->{id}, $self->{result_values}->{status}); +} + +sub custom_status_calc { + my ($self, %options) = @_; + $self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_status'}; + $self->{result_values}->{id} = $options{new_datas}->{$self->{instance} . '_id'}; + return 0; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0, cb_prefix_output => 'prefix_global_output' }, + { name => 'servers', type => 1, cb_prefix_output => 'prefix_server_output', message_multiple => 'All servers are ok' } + ]; + + $self->{maps_counters}->{global} = [ + { label => 'total', nlabel => 'mulesoft.servers.total.count', set => { + key_values => [ { name => 'total' } ], + output_template => "Total : %s", + perfdatas => [ { value => 'total_absolute', template => '%d', min => 0 } ], + } + }, + { label => 'running', nlabel => 'mulesoft.servers.status.running.count', set => { + key_values => [ { name => 'running' } ], + output_template => "Running : %s", + perfdatas => [ { value => 'running_absolute', template => '%d', min => 0 } ] + } + }, + { label => 'disconnected', nlabel => 'mulesoft.servers.status.disconnected.count', set => { + key_values => [ { name => 'disconnected' } ], + output_template => "Disconnected : %s", + perfdatas => [ { value => 'disconnected_absolute', template => '%d', min => 0 } ] + } + } + ]; + + $self->{maps_counters}->{servers} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'id' }, { name => 'status' }, { name => 'name'}, { name => 'display' } ], + closure_custom_calc => $self->can('custom_status_calc'), + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold, + } + }, + ]; +} + +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' }, + "warning-status:s" => { name => 'warning_status', default => '' }, + "critical-status:s" => { name => 'critical_status', default => '' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->change_macros(macros => ['warning_status', 'critical_status']); +} + +sub prefix_global_output { + my ($self, %options) = @_; + + return "Total servers "; +} + +sub prefix_server_output { + my ($self, %options) = @_; + + return "Server '" . $options{instance_value}->{name} . "' "; +} + +sub manage_selection { + my ($self, %options) = @_; + + $self->{global} = { started => 0, stopped => 0, failed => 0 }; + $self->{servers} = {}; + my $result = $options{custom}->list_servers(); + my $current_time = DateTime->now(); + foreach my $server (@{$result}) { + next if ( defined($self->{option_results}->{filter_name}) + && $self->{option_results}->{filter_name} ne '' + && $server->{name} !~ /$self->{option_results}->{filter_name}/ ); + $self->{servers}->{$server} = { + display => $server, + id => $server->{id}, + name => $server->{name}, + status => $server->{status}, + }; + + $self->{global}->{running}++ if $server->{status} =~ m/RUNNING/; + $self->{global}->{disconnected}++ if $server->{status} =~ m/DISCONNECTED/; + } + + if (scalar(keys %{$self->{servers}}) <= 0) { + $self->{output}->add_option_msg(short_msg => "No server found."); + $self->{output}->option_exit(); + } + + $self->{global}->{total} = scalar (keys %{$self->{servers}}); +} + +1; + +__END__ + +=head1 MODE + +Check Mulesoft Anypoint Servers status. + +Example: +perl centreon_plugins.pl --plugin=apps::mulesoft::restapi::plugin --mode=servers +--environment-id='1234abc-56de-78fg-90hi-1234abcdefg' --organization-id='1234abcd-56ef-78fg-90hi-1234abcdefg' +--api-username='myapiuser' --api-password='myapipassword' --verbose + +More information on'https://anypoint.mulesoft.com/exchange/portals/anypoint-platform/'. + +=over 8 + +=item B<--filter-name> + +Filter by server name (Regexp can be used). +Example: --filter-name='^server1$' + +=item B<--warning-status> + +Set warning threshold for status (Default: ''). +Threshold can be matched on %{name}, %{id} or %{status} and Regexp can be used. +Typical syntax: --warning-status=%{status} ne "RUNNING" + +=item B<--critical-status> + +Set warning threshold for status (Default: ''). +Threshold can be matched on %{name}, %{id} or %{status} and Regexp can be used. +Typical syntax: --critical-status=%{status} ~= m/DISCONNECTED/" + + +=back + +=cut diff --git a/apps/mulesoft/restapi/plugin.pm b/apps/mulesoft/restapi/plugin.pm index 9abef19bd..e693c3dd0 100644 --- a/apps/mulesoft/restapi/plugin.pm +++ b/apps/mulesoft/restapi/plugin.pm @@ -31,8 +31,10 @@ sub new { $self->{version} = '1.0'; %{$self->{modes}} = ( - 'applications' => 'apps::mulesoft::restapi::mode::applications', - 'listapplications' => 'apps::mulesoft::restapi::mode::listapplications' + 'applications' => 'apps::mulesoft::restapi::mode::applications', + 'listapplications' => 'apps::mulesoft::restapi::mode::listapplications', + 'servers' => 'apps::mulesoft::restapi::mode::servers', + 'listservers' => 'apps::mulesoft::restapi::mode::listservers', ); $self->{custom_modes}{restapi} = 'apps::mulesoft::restapi::custom::api'; From 5308993fdcd914c99d948273eade7e8c1fc2a181 Mon Sep 17 00:00:00 2001 From: thibaults-centreon Date: Tue, 21 Apr 2020 11:02:23 +0200 Subject: [PATCH 126/283] Mulesoft cleanup --- apps/mulesoft/restapi/mode/applications.pm | 4 ++-- apps/mulesoft/restapi/mode/servers.pm | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/mulesoft/restapi/mode/applications.pm b/apps/mulesoft/restapi/mode/applications.pm index 890e75979..82cdfe4ac 100644 --- a/apps/mulesoft/restapi/mode/applications.pm +++ b/apps/mulesoft/restapi/mode/applications.pm @@ -175,13 +175,13 @@ Example: --filter-name='^application1$' Set warning threshold for status (Default: ''). Threshold can be matched on %{name}, %{id} or %{status} and Regexp can be used. -Typical syntax: --warning-status=%{status} ne "STARTED" +Typical syntax: --warning-status='%{status} ne "STARTED"' =item B<--critical-status> Set warning threshold for status (Default: ''). Threshold can be matched on %{name}, %{id} or %{status} and Regexp can be used. -Typical syntax: --critical-status=%{status} ~= m/FAILED/" +Typical syntax: --critical-status='%{status} ~= m/FAILED/' =back diff --git a/apps/mulesoft/restapi/mode/servers.pm b/apps/mulesoft/restapi/mode/servers.pm index e84f937e6..a60cd7bc3 100644 --- a/apps/mulesoft/restapi/mode/servers.pm +++ b/apps/mulesoft/restapi/mode/servers.pm @@ -169,13 +169,13 @@ Example: --filter-name='^server1$' Set warning threshold for status (Default: ''). Threshold can be matched on %{name}, %{id} or %{status} and Regexp can be used. -Typical syntax: --warning-status=%{status} ne "RUNNING" +Typical syntax: --warning-status='%{status} ne "RUNNING"' =item B<--critical-status> Set warning threshold for status (Default: ''). Threshold can be matched on %{name}, %{id} or %{status} and Regexp can be used. -Typical syntax: --critical-status=%{status} ~= m/DISCONNECTED/" +Typical syntax: --critical-status='%{status} ~= m/DISCONNECTED/' =back From f1ea8609ca3589963015c6c0c1c87a4e091fe25a Mon Sep 17 00:00:00 2001 From: thibaults-centreon Date: Tue, 21 Apr 2020 11:13:47 +0200 Subject: [PATCH 127/283] cleanup --- apps/mulesoft/restapi/mode/servers.pm | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/mulesoft/restapi/mode/servers.pm b/apps/mulesoft/restapi/mode/servers.pm index a60cd7bc3..2bf7bc006 100644 --- a/apps/mulesoft/restapi/mode/servers.pm +++ b/apps/mulesoft/restapi/mode/servers.pm @@ -25,7 +25,6 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold); -use DateTime; sub custom_status_output { my ($self, %options) = @_; @@ -119,7 +118,6 @@ sub manage_selection { $self->{global} = { started => 0, stopped => 0, failed => 0 }; $self->{servers} = {}; my $result = $options{custom}->list_servers(); - my $current_time = DateTime->now(); foreach my $server (@{$result}) { next if ( defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' From 469e36f8949757ee4e93565482293daa142e39fe Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 21 Apr 2020 11:38:50 +0200 Subject: [PATCH 128/283] enhance performance dell idrac snmp --- .../idrac/snmp/mode/components/amperage.pm | 6 ++- .../snmp/mode/components/coolingdevice.pm | 6 ++- .../idrac/snmp/mode/components/coolingunit.pm | 8 +++- .../dell/idrac/snmp/mode/components/fru.pm | 8 +++- .../dell/idrac/snmp/mode/components/memory.pm | 8 +++- .../idrac/snmp/mode/components/network.pm | 8 +++- .../dell/idrac/snmp/mode/components/pci.pm | 10 +++-- .../idrac/snmp/mode/components/processor.pm | 12 ++++-- .../dell/idrac/snmp/mode/components/psu.pm | 8 +++- .../dell/idrac/snmp/mode/components/punit.pm | 10 +++-- .../dell/idrac/snmp/mode/components/slot.pm | 12 ++++-- .../snmp/mode/components/storagebattery.pm | 10 ++--- .../idrac/snmp/mode/components/storagectrl.pm | 10 ++--- .../snmp/mode/components/systembattery.pm | 37 +++++++++++++----- .../idrac/snmp/mode/components/temperature.pm | 6 ++- .../dell/idrac/snmp/mode/components/vdisk.pm | 38 +++++++++++-------- .../idrac/snmp/mode/components/voltage.pm | 24 ++++++++---- 17 files changed, 151 insertions(+), 70 deletions(-) diff --git a/hardware/server/dell/idrac/snmp/mode/components/amperage.pm b/hardware/server/dell/idrac/snmp/mode/components/amperage.pm index 6b84180a5..6e13ed6ec 100644 --- a/hardware/server/dell/idrac/snmp/mode/components/amperage.pm +++ b/hardware/server/dell/idrac/snmp/mode/components/amperage.pm @@ -40,7 +40,11 @@ my $oid_amperageProbeTableEntry = '.1.3.6.1.4.1.674.10892.5.4.600.30.1'; sub load { my ($self) = @_; - push @{$self->{request}}, { oid => $oid_amperageProbeTableEntry }; + push @{$self->{request}}, { + oid => $oid_amperageProbeTableEntry, + start => $mapping->{amperageProbeStateSettings}->{oid}, + end => $mapping->{amperageProbeLowerCriticalThreshold}->{oid} + }; } sub check { diff --git a/hardware/server/dell/idrac/snmp/mode/components/coolingdevice.pm b/hardware/server/dell/idrac/snmp/mode/components/coolingdevice.pm index e849908a1..a19636d72 100644 --- a/hardware/server/dell/idrac/snmp/mode/components/coolingdevice.pm +++ b/hardware/server/dell/idrac/snmp/mode/components/coolingdevice.pm @@ -39,7 +39,11 @@ my $oid_coolingDeviceTableEntry = '.1.3.6.1.4.1.674.10892.5.4.700.12.1'; sub load { my ($self) = @_; - push @{$self->{request}}, { oid => $oid_coolingDeviceTableEntry }; + push @{$self->{request}}, { + oid => $oid_coolingDeviceTableEntry, + start => $mapping->{coolingDeviceStateSettings}->{oid}, + end => $mapping->{coolingDeviceLowerCriticalThreshold}->{oid} + }; } sub check { diff --git a/hardware/server/dell/idrac/snmp/mode/components/coolingunit.pm b/hardware/server/dell/idrac/snmp/mode/components/coolingunit.pm index fb899a871..3289be91f 100644 --- a/hardware/server/dell/idrac/snmp/mode/components/coolingunit.pm +++ b/hardware/server/dell/idrac/snmp/mode/components/coolingunit.pm @@ -34,7 +34,11 @@ my $oid_coolingUnitTableEntry = '.1.3.6.1.4.1.674.10892.5.4.700.10.1'; sub load { my ($self) = @_; - push @{$self->{request}}, { oid => $oid_coolingUnitTableEntry }; + push @{$self->{request}}, { + oid => $oid_coolingUnitTableEntry, + start => $mapping->{coolingUnitStateSettings}->{oid}, + end => $mapping->{coolingUnitStatus}->{oid} + }; } sub check { @@ -71,4 +75,4 @@ sub check { } } -1; \ No newline at end of file +1; diff --git a/hardware/server/dell/idrac/snmp/mode/components/fru.pm b/hardware/server/dell/idrac/snmp/mode/components/fru.pm index d41a8bba0..d005760b9 100644 --- a/hardware/server/dell/idrac/snmp/mode/components/fru.pm +++ b/hardware/server/dell/idrac/snmp/mode/components/fru.pm @@ -33,7 +33,11 @@ my $oid_fruTableEntry = '.1.3.6.1.4.1.674.10892.5.4.2000.10.1'; sub load { my ($self) = @_; - push @{$self->{request}}, { oid => $oid_fruTableEntry }; + push @{$self->{request}}, { + oid => $oid_fruTableEntry, + start => $mapping->{fruInformationStatus}->{oid}, + end => $mapping->{fruSerialNumberName}->{oid} + }; } sub check { @@ -63,4 +67,4 @@ sub check { } } -1; \ No newline at end of file +1; diff --git a/hardware/server/dell/idrac/snmp/mode/components/memory.pm b/hardware/server/dell/idrac/snmp/mode/components/memory.pm index f093ef9a8..3695e987b 100644 --- a/hardware/server/dell/idrac/snmp/mode/components/memory.pm +++ b/hardware/server/dell/idrac/snmp/mode/components/memory.pm @@ -34,7 +34,11 @@ my $oid_memoryDeviceTableEntry = '.1.3.6.1.4.1.674.10892.5.4.1100.50.1'; sub load { my ($self) = @_; - push @{$self->{request}}, { oid => $oid_memoryDeviceTableEntry }; + push @{$self->{request}}, { + oid => $oid_memoryDeviceTableEntry, + start => $mapping->{memoryDeviceStateSettings}->{oid}, + end => $mapping->{memoryDeviceLocationName}->{oid} + }; } sub check { @@ -71,4 +75,4 @@ sub check { } } -1; \ No newline at end of file +1; diff --git a/hardware/server/dell/idrac/snmp/mode/components/network.pm b/hardware/server/dell/idrac/snmp/mode/components/network.pm index f3ea07638..3fcd32279 100644 --- a/hardware/server/dell/idrac/snmp/mode/components/network.pm +++ b/hardware/server/dell/idrac/snmp/mode/components/network.pm @@ -33,7 +33,11 @@ my $oid_networkDeviceTableEntry = '.1.3.6.1.4.1.674.10892.5.4.1100.90.1'; sub load { my ($self) = @_; - push @{$self->{request}}, { oid => $oid_networkDeviceTableEntry }; + push @{$self->{request}}, { + oid => $oid_networkDeviceTableEntry, + start => $mapping->{networkDeviceStatus}->{oid}, + end => $mapping->{networkDeviceProductName}->{oid} + }; } sub check { @@ -63,4 +67,4 @@ sub check { } } -1; \ No newline at end of file +1; diff --git a/hardware/server/dell/idrac/snmp/mode/components/pci.pm b/hardware/server/dell/idrac/snmp/mode/components/pci.pm index 80498c2b5..68013cd4d 100644 --- a/hardware/server/dell/idrac/snmp/mode/components/pci.pm +++ b/hardware/server/dell/idrac/snmp/mode/components/pci.pm @@ -34,14 +34,18 @@ my $oid_pCIDeviceTableEntry = '.1.3.6.1.4.1.674.10892.5.4.1100.80.1'; sub load { my ($self) = @_; - push @{$self->{request}}, { oid => $oid_pCIDeviceTableEntry }; + push @{$self->{request}}, { + oid => $oid_pCIDeviceTableEntry, + start => $mapping->{pCIDeviceStateSettings}->{oid}, + end => $mapping->{pCIDeviceDescriptionName}->{oid} + }; } sub check { my ($self) = @_; $self->{output}->output_add(long_msg => "Checking pci"); - $self->{components}->{pci} = {name => 'pci', total => 0, skip => 0}; + $self->{components}->{pci} = { name => 'pci', total => 0, skip => 0 }; return if ($self->check_filter(section => 'pci')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_pCIDeviceTableEntry}})) { @@ -71,4 +75,4 @@ sub check { } } -1; \ No newline at end of file +1; diff --git a/hardware/server/dell/idrac/snmp/mode/components/processor.pm b/hardware/server/dell/idrac/snmp/mode/components/processor.pm index 49ed63c66..206f8ee4f 100644 --- a/hardware/server/dell/idrac/snmp/mode/components/processor.pm +++ b/hardware/server/dell/idrac/snmp/mode/components/processor.pm @@ -34,20 +34,24 @@ my $oid_processorDeviceTableEntry = '.1.3.6.1.4.1.674.10892.5.4.1100.30.1'; sub load { my ($self) = @_; - push @{$self->{request}}, { oid => $oid_processorDeviceTableEntry }; + push @{$self->{request}}, + { oid => $oid_processorDeviceTableEntry, start => $mapping->{processorDeviceStateSettings}->{oid}, end => $mapping->{processorDeviceStatus}->{oid} }, + { oid => $mapping->{processorDeviceFQDD}->{oid} } + ; } sub check { my ($self) = @_; $self->{output}->output_add(long_msg => "Checking processors"); - $self->{components}->{processor} = {name => 'processors', total => 0, skip => 0}; + $self->{components}->{processor} = { name => 'processors', total => 0, skip => 0 }; return if ($self->check_filter(section => 'processor')); - foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_processorDeviceTableEntry}})) { + my $snmp_result = { %{$self->{results}->{ $oid_processorDeviceTableEntry }}, %{$self->{results}->{ $mapping->{processorDeviceFQDD}->{oid} }} }; + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %$snmp_result)) { next if ($oid !~ /^$mapping->{processorDeviceStatus}->{oid}\.(.*)$/); my $instance = $1; - my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_processorDeviceTableEntry}, instance => $instance); + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance); next if ($self->check_filter(section => 'processor', instance => $instance)); $self->{components}->{processor}->{total}++; diff --git a/hardware/server/dell/idrac/snmp/mode/components/psu.pm b/hardware/server/dell/idrac/snmp/mode/components/psu.pm index c46e39e36..b9e309b68 100644 --- a/hardware/server/dell/idrac/snmp/mode/components/psu.pm +++ b/hardware/server/dell/idrac/snmp/mode/components/psu.pm @@ -33,14 +33,18 @@ my $oid_powerSupplyTableEntry = '.1.3.6.1.4.1.674.10892.5.4.600.12.1'; sub load { my ($self) = @_; - push @{$self->{request}}, { oid => $oid_powerSupplyTableEntry }; + push @{$self->{request}}, { + oid => $oid_powerSupplyTableEntry, + start => $mapping->{powerSupplyStatus}->{oid}, + end => $mapping->{powerSupplyLocationName}->{oid} + }; } sub check { my ($self) = @_; $self->{output}->output_add(long_msg => "Checking power supplies"); - $self->{components}->{psu} = {name => 'power supplies', total => 0, skip => 0}; + $self->{components}->{psu} = { name => 'power supplies', total => 0, skip => 0 }; return if ($self->check_filter(section => 'psu')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_powerSupplyTableEntry}})) { diff --git a/hardware/server/dell/idrac/snmp/mode/components/punit.pm b/hardware/server/dell/idrac/snmp/mode/components/punit.pm index 06815d7fb..a5a653a10 100644 --- a/hardware/server/dell/idrac/snmp/mode/components/punit.pm +++ b/hardware/server/dell/idrac/snmp/mode/components/punit.pm @@ -34,14 +34,18 @@ my $oid_powerUnitTableEntry = '.1.3.6.1.4.1.674.10892.5.4.600.10.1'; sub load { my ($self) = @_; - push @{$self->{request}}, { oid => $oid_powerUnitTableEntry }; + push @{$self->{request}}, { + oid => $oid_powerUnitTableEntry, + start => $mapping->{powerUnitStateSettings}->{oid}, + end => $mapping->{powerUnitStatus}->{oid} + }; } sub check { my ($self) = @_; $self->{output}->output_add(long_msg => "Checking power units"); - $self->{components}->{punit} = {name => 'power units', total => 0, skip => 0}; + $self->{components}->{punit} = { name => 'power units', total => 0, skip => 0 }; return if ($self->check_filter(section => 'punit')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_powerUnitTableEntry}})) { @@ -71,4 +75,4 @@ sub check { } } -1; \ No newline at end of file +1; diff --git a/hardware/server/dell/idrac/snmp/mode/components/slot.pm b/hardware/server/dell/idrac/snmp/mode/components/slot.pm index 2b4dc6b17..61b934acc 100644 --- a/hardware/server/dell/idrac/snmp/mode/components/slot.pm +++ b/hardware/server/dell/idrac/snmp/mode/components/slot.pm @@ -33,21 +33,25 @@ my $oid_systemSlotTableEntry = '.1.3.6.1.4.1.674.10892.5.4.1200.10.1'; sub load { my ($self) = @_; - push @{$self->{request}}, { oid => $oid_systemSlotTableEntry }; + push @{$self->{request}}, { + oid => $oid_systemSlotTableEntry, + start => $mapping->{systemSlotStatus}->{oid}, + end => $mapping->{systemSlotSlotExternalSlotName}->{oid} + }; } sub check { my ($self) = @_; $self->{output}->output_add(long_msg => "Checking slots"); - $self->{components}->{slot} = {name => 'slots', total => 0, skip => 0}; + $self->{components}->{slot} = { name => 'slots', total => 0, skip => 0 }; return if ($self->check_filter(section => 'slot')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_systemSlotTableEntry}})) { next if ($oid !~ /^$mapping->{systemSlotStatus}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_systemSlotTableEntry}, instance => $instance); - + next if ($self->check_filter(section => 'slot', instance => $instance)); $self->{components}->{slot}->{total}++; @@ -63,4 +67,4 @@ sub check { } } -1; \ No newline at end of file +1; diff --git a/hardware/server/dell/idrac/snmp/mode/components/storagebattery.pm b/hardware/server/dell/idrac/snmp/mode/components/storagebattery.pm index f1c28bb30..647e9e104 100644 --- a/hardware/server/dell/idrac/snmp/mode/components/storagebattery.pm +++ b/hardware/server/dell/idrac/snmp/mode/components/storagebattery.pm @@ -28,12 +28,11 @@ my $mapping = { batteryComponentStatus => { oid => '.1.3.6.1.4.1.674.10892.5.5.1.20.130.15.1.6', map => \%map_status }, batteryFQDD => { oid => '.1.3.6.1.4.1.674.10892.5.5.1.20.130.15.1.20' }, }; -my $oid_batteryTableEntry = '.1.3.6.1.4.1.674.10892.5.5.1.20.130.15.1'; sub load { my ($self) = @_; - push @{$self->{request}}, { oid => $oid_batteryTableEntry }; + push @{$self->{request}}, { oid => $mapping->{batteryComponentStatus}->{oid} }, { oid => $mapping->{batteryFQDD}->{oid} }; } sub check { @@ -43,10 +42,11 @@ sub check { $self->{components}->{storagebattery} = {name => 'storage batteries', total => 0, skip => 0}; return if ($self->check_filter(section => 'storagebattery')); - foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_batteryTableEntry}})) { + my $snmp_result = { %{$self->{results}->{ $mapping->{batteryComponentStatus}->{oid} }}, %{$self->{results}->{ $mapping->{batteryFQDD}->{oid} }} }; + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %$snmp_result)) { next if ($oid !~ /^$mapping->{batteryComponentStatus}->{oid}\.(.*)$/); my $instance = $1; - my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_batteryTableEntry}, instance => $instance); + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance); next if ($self->check_filter(section => 'storagebattery', instance => $instance)); $self->{components}->{storagebattery}->{total}++; @@ -63,4 +63,4 @@ sub check { } } -1; \ No newline at end of file +1; diff --git a/hardware/server/dell/idrac/snmp/mode/components/storagectrl.pm b/hardware/server/dell/idrac/snmp/mode/components/storagectrl.pm index d74062202..ee5afcd4a 100644 --- a/hardware/server/dell/idrac/snmp/mode/components/storagectrl.pm +++ b/hardware/server/dell/idrac/snmp/mode/components/storagectrl.pm @@ -28,12 +28,11 @@ my $mapping = { controllerComponentStatus => { oid => '.1.3.6.1.4.1.674.10892.5.5.1.20.130.1.1.38', map => \%map_status }, controllerFQDD => { oid => '.1.3.6.1.4.1.674.10892.5.5.1.20.130.1.1.78' }, }; -my $oid_controllerTableEntry = '.1.3.6.1.4.1.674.10892.5.5.1.20.130.1.1'; sub load { my ($self) = @_; - push @{$self->{request}}, { oid => $oid_controllerTableEntry }; + push @{$self->{request}}, { oid => $mapping->{controllerComponentStatus}->{oid} }, { oid => $mapping->{controllerFQDD}->{oid} }; } sub check { @@ -43,10 +42,11 @@ sub check { $self->{components}->{storagectrl} = {name => 'storage controllers', total => 0, skip => 0}; return if ($self->check_filter(section => 'storagectrl')); - foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_controllerTableEntry}})) { + my $snmp_result = { %{$self->{results}->{ $mapping->{controllerComponentStatus}->{oid} }}, %{$self->{results}->{ $mapping->{controllerFQDD}->{oid} }} }; + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %$snmp_result)) { next if ($oid !~ /^$mapping->{controllerComponentStatus}->{oid}\.(.*)$/); my $instance = $1; - my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_controllerTableEntry}, instance => $instance); + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance); next if ($self->check_filter(section => 'storagectrl', instance => $instance)); $self->{components}->{storagectrl}->{total}++; @@ -63,4 +63,4 @@ sub check { } } -1; \ No newline at end of file +1; diff --git a/hardware/server/dell/idrac/snmp/mode/components/systembattery.pm b/hardware/server/dell/idrac/snmp/mode/components/systembattery.pm index dc7621d06..3bc5e6c60 100644 --- a/hardware/server/dell/idrac/snmp/mode/components/systembattery.pm +++ b/hardware/server/dell/idrac/snmp/mode/components/systembattery.pm @@ -34,7 +34,11 @@ my $oid_systemBatteryTableEntry = '.1.3.6.1.4.1.674.10892.5.4.600.50.1'; sub load { my ($self) = @_; - push @{$self->{request}}, { oid => $oid_systemBatteryTableEntry }; + push @{$self->{request}}, { + oid => $oid_systemBatteryTableEntry, + start => $mapping->{systemBatteryStateSettings}->{oid}, + start => $mapping->{systemBatteryLocationName}->{oid} + }; } sub check { @@ -52,23 +56,36 @@ sub check { next if ($self->check_filter(section => 'systembattery', instance => $instance)); $self->{components}->{systembattery}->{total}++; - $self->{output}->output_add(long_msg => sprintf("system battery '%s' status is '%s' [instance = %s] [state = %s]", - $result->{systemBatteryLocationName}, $result->{systemBatteryStatus}, $instance, - $result->{systemBatteryStateSettings})); - + $self->{output}->output_add( + long_msg => sprintf( + "system battery '%s' status is '%s' [instance = %s] [state = %s]", + $result->{systemBatteryLocationName}, + $result->{systemBatteryStatus}, $instance, + $result->{systemBatteryStateSettings} + ) + ); + my $exit = $self->get_severity(label => 'default.state', section => 'systembattery.state', value => $result->{systemBatteryStateSettings}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("System battery '%s' state is '%s'", $result->{systemBatteryLocationName}, $result->{systemBatteryStateSettings})); + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "System battery '%s' state is '%s'", $result->{systemBatteryLocationName}, $result->{systemBatteryStateSettings} + ) + ); next; } $exit = $self->get_severity(label => 'default.status', section => 'systembattery.status', value => $result->{systemBatteryStatus}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("System battery '%s' status is '%s'", $result->{systemBatteryLocationName}, $result->{systemBatteryStatus})); + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "System battery '%s' status is '%s'", $result->{systemBatteryLocationName}, $result->{systemBatteryStatus} + ) + ); } } } -1; \ No newline at end of file +1; diff --git a/hardware/server/dell/idrac/snmp/mode/components/temperature.pm b/hardware/server/dell/idrac/snmp/mode/components/temperature.pm index c68ab8677..dc09cdbe5 100644 --- a/hardware/server/dell/idrac/snmp/mode/components/temperature.pm +++ b/hardware/server/dell/idrac/snmp/mode/components/temperature.pm @@ -47,7 +47,11 @@ my $oid_temperatureProbeTableEntry = '.1.3.6.1.4.1.674.10892.5.4.700.20.1'; sub load { my ($self) = @_; - push @{$self->{request}}, { oid => $oid_temperatureProbeTableEntry, begin => $mapping->{temperatureProbeStateSettings}->{oid}, end => $mapping->{temperatureProbeLowerCriticalThreshold}->{oid} }; + push @{$self->{request}}, { + oid => $oid_temperatureProbeTableEntry, + start => $mapping->{temperatureProbeStateSettings}->{oid}, + end => $mapping->{temperatureProbeLowerCriticalThreshold}->{oid} + }; } sub check { diff --git a/hardware/server/dell/idrac/snmp/mode/components/vdisk.pm b/hardware/server/dell/idrac/snmp/mode/components/vdisk.pm index 40d859a0f..272770c2d 100644 --- a/hardware/server/dell/idrac/snmp/mode/components/vdisk.pm +++ b/hardware/server/dell/idrac/snmp/mode/components/vdisk.pm @@ -26,42 +26,48 @@ use hardware::server::dell::idrac::snmp::mode::components::resources qw(%map_vdi my $mapping = { virtualDiskState => { oid => '.1.3.6.1.4.1.674.10892.5.5.1.20.140.1.1.4', map => \%map_vdisk_state }, - virtualDiskFQDD => { oid => '.1.3.6.1.4.1.674.10892.5.5.1.20.140.1.1.35' }, + virtualDiskFQDD => { oid => '.1.3.6.1.4.1.674.10892.5.5.1.20.140.1.1.35' } }; -my $oid_virtualDiskTableEntry = '.1.3.6.1.4.1.674.10892.5.5.1.20.140.1.1'; sub load { my ($self) = @_; - - push @{$self->{request}}, { oid => $oid_virtualDiskTableEntry }; + + push @{$self->{request}}, { oid => $mapping->{virtualDiskState}->{oid} }, { oid => $mapping->{virtualDiskFQDD}->{oid} }; } sub check { my ($self) = @_; $self->{output}->output_add(long_msg => "Checking virtual disks"); - $self->{components}->{vdisk} = {name => 'virtual disks', total => 0, skip => 0}; + $self->{components}->{vdisk} = { name => 'virtual disks', total => 0, skip => 0 }; return if ($self->check_filter(section => 'vdisk')); - foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_virtualDiskTableEntry}})) { + my $snmp_result = { %{$self->{results}->{ $mapping->{virtualDiskState}->{oid} }}, %{$self->{results}->{ $mapping->{virtualDiskFQDD}->{oid} }} }; + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %$snmp_result)) { next if ($oid !~ /^$mapping->{virtualDiskState}->{oid}\.(.*)$/); my $instance = $1; - my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_virtualDiskTableEntry}, instance => $instance); - + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance); + next if ($self->check_filter(section => 'vdisk', instance => $instance)); $self->{components}->{vdisk}->{total}++; - $self->{output}->output_add(long_msg => sprintf("virtual disk '%s' state is '%s' [instance = %s]", - $result->{virtualDiskFQDD}, $result->{virtualDiskState}, $instance, - )); - + $self->{output}->output_add( + long_msg => sprintf( + "virtual disk '%s' state is '%s' [instance = %s]", + $result->{virtualDiskFQDD}, $result->{virtualDiskState}, $instance, + ) + ); + my $exit = $self->get_severity(section => 'vdisk.state', value => $result->{virtualDiskState}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Virtual disk '%s' state is '%s'", $result->{virtualDiskFQDD}, $result->{virtualDiskState})); - next; + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "Virtual disk '%s' state is '%s'", $result->{virtualDiskFQDD}, $result->{virtualDiskState} + ) + ); } } } -1; \ No newline at end of file +1; diff --git a/hardware/server/dell/idrac/snmp/mode/components/voltage.pm b/hardware/server/dell/idrac/snmp/mode/components/voltage.pm index 26d63d92f..8a95f9cb8 100644 --- a/hardware/server/dell/idrac/snmp/mode/components/voltage.pm +++ b/hardware/server/dell/idrac/snmp/mode/components/voltage.pm @@ -39,7 +39,11 @@ my $oid_voltageProbeTableEntry = '.1.3.6.1.4.1.674.10892.5.4.600.20.1'; sub load { my ($self) = @_; - push @{$self->{request}}, { oid => $oid_voltageProbeTableEntry }; + push @{$self->{request}}, { + oid => $oid_voltageProbeTableEntry, + start => $mapping->{voltageProbeStateSettings}->{oid}, + end => $mapping->{voltageProbeLowerCriticalThreshold}->{oid} + }; } sub check { @@ -58,10 +62,14 @@ sub check { $self->{components}->{voltage}->{total}++; $result->{voltageProbeReading} = (defined($result->{voltageProbeReading})) ? $result->{voltageProbeReading} / 1000 : 'unknown'; - $self->{output}->output_add(long_msg => sprintf("voltage '%s' status is '%s' [instance = %s] [state = %s] [value = %s]", - $result->{voltageProbeLocationName}, $result->{voltageProbeStatus}, $instance, - $result->{voltageProbeStateSettings}, $result->{voltageProbeReading})); - + $self->{output}->output_add( + long_msg => sprintf( + "voltage '%s' status is '%s' [instance = %s] [state = %s] [value = %s]", + $result->{voltageProbeLocationName}, $result->{voltageProbeStatus}, $instance, + $result->{voltageProbeStateSettings}, $result->{voltageProbeReading} + ) + ); + my $exit = $self->get_severity(label => 'default.state', section => 'voltage.state', value => $result->{voltageProbeStateSettings}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add(severity => $exit, @@ -98,8 +106,10 @@ sub check { } if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Voltage '%s' is %s V", $result->{voltageProbeLocationName}, $result->{voltageProbeReading})); + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf("Voltage '%s' is %s V", $result->{voltageProbeLocationName}, $result->{voltageProbeReading}) + ); } $self->{output}->perfdata_add( label => 'voltage', unit => 'V', From 5b12b90b6059e92e2cc630ccaf01cc463cbdde09 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 21 Apr 2020 14:14:22 +0200 Subject: [PATCH 129/283] enhance indent --- apps/mulesoft/restapi/mode/applications.pm | 53 ++++++++----------- .../mulesoft/restapi/mode/listapplications.pm | 14 +++-- apps/mulesoft/restapi/mode/listservers.pm | 25 ++++----- apps/mulesoft/restapi/mode/servers.pm | 47 +++++++--------- 4 files changed, 63 insertions(+), 76 deletions(-) diff --git a/apps/mulesoft/restapi/mode/applications.pm b/apps/mulesoft/restapi/mode/applications.pm index 82cdfe4ac..e12a8d173 100644 --- a/apps/mulesoft/restapi/mode/applications.pm +++ b/apps/mulesoft/restapi/mode/applications.pm @@ -24,18 +24,12 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; -use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold); +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); sub custom_status_output { my ($self, %options) = @_; - return my $msg = sprintf('Id: %s, Status: %s', $self->{result_values}->{id}, $self->{result_values}->{status}); -} -sub custom_status_calc { - my ($self, %options) = @_; - $self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_status'}; - $self->{result_values}->{id} = $options{new_datas}->{$self->{instance} . '_id'}; - return 0; + return sprintf('Id: %s, Status: %s', $self->{result_values}->{id}, $self->{result_values}->{status}); } sub set_counters { @@ -48,40 +42,40 @@ sub set_counters { $self->{maps_counters}->{global} = [ { label => 'total', nlabel => 'mulesoft.applications.total.count', set => { - key_values => [ { name => 'total' } ], - output_template => "Total : %s", - perfdatas => [ { value => 'total_absolute', template => '%d', min => 0 } ], + key_values => [ { name => 'total' } ], + output_template => "Total : %s", + perfdatas => [ { value => 'total_absolute', template => '%d', min => 0 } ] } }, { label => 'started', nlabel => 'mulesoft.applications.status.started.count', set => { - key_values => [ { name => 'started' } ], - output_template => "Started : %s", - perfdatas => [ { value => 'started_absolute', template => '%d', min => 0 } ] + key_values => [ { name => 'started' } ], + output_template => "Started : %s", + perfdatas => [ { value => 'started_absolute', template => '%d', min => 0 } ] } }, { label => 'stopped', nlabel => 'mulesoft.applications.status.stopped.count', set => { - key_values => [ { name => 'stopped' } ], - output_template => "Stopped : %s", - perfdatas => [ { value => 'stopped_absolute', template => '%d', min => 0 } ] + key_values => [ { name => 'stopped' } ], + output_template => "Stopped : %s", + perfdatas => [ { value => 'stopped_absolute', template => '%d', min => 0 } ] } }, { label => 'failed', nlabel => 'mulesoft.applications.status.failed.count', set => { - key_values => [ { name => 'failed' } ], - output_template => "Failed : %s", - perfdatas => [ { value => 'failed_absolute', template => '%d', min => 0 } ] + key_values => [ { name => 'failed' } ], + output_template => "Failed : %s", + perfdatas => [ { value => 'failed_absolute', template => '%d', min => 0 } ] } } ]; $self->{maps_counters}->{applications} = [ { label => 'status', threshold => 0, set => { - key_values => [ { name => 'id' }, { name => 'status' }, { name => 'name'}, { name => 'display' } ], - closure_custom_calc => $self->can('custom_status_calc'), - closure_custom_output => $self->can('custom_status_output'), - closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => \&catalog_status_threshold, + key_values => [ { name => 'id' }, { name => 'status' }, { name => 'name'}, { name => 'display' } ], + closure_custom_calc => \&catalog_status_calc, + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold } - }, + } ]; } @@ -91,9 +85,9 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - "filter-name:s" => { name => 'filter_name' }, - "warning-status:s" => { name => 'warning_status', default => '' }, - "critical-status:s" => { name => 'critical_status', default => '' } + 'filter-name:s' => { name => 'filter_name' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '' } }); return $self; @@ -183,7 +177,6 @@ Set warning threshold for status (Default: ''). Threshold can be matched on %{name}, %{id} or %{status} and Regexp can be used. Typical syntax: --critical-status='%{status} ~= m/FAILED/' - =back =cut diff --git a/apps/mulesoft/restapi/mode/listapplications.pm b/apps/mulesoft/restapi/mode/listapplications.pm index 2b7641bec..1d24344fa 100644 --- a/apps/mulesoft/restapi/mode/listapplications.pm +++ b/apps/mulesoft/restapi/mode/listapplications.pm @@ -31,7 +31,7 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - "filter-name:s" => { name => 'filter_name' }, + 'filter-name:s' => { name => 'filter_name' }, }); return $self; @@ -56,10 +56,14 @@ sub run { next if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && $application->{name} !~ /$self->{option_results}->{filter_name}/); - $self->{output}->output_add(long_msg => sprintf("[id = %s][name = %s][status = %s]", - $application->{id}, - $application->{name}, - $application->{lastReportedStatus})); + $self->{output}->output_add( + long_msg => sprintf( + "[id = %s][name = %s][status = %s]", + $application->{id}, + $application->{name}, + $application->{lastReportedStatus} + ) + ); } $self->{output}->output_add(severity => 'OK', short_msg => 'Mulesoft Anypoint Applications:'); diff --git a/apps/mulesoft/restapi/mode/listservers.pm b/apps/mulesoft/restapi/mode/listservers.pm index e774d5b2d..664bfd697 100644 --- a/apps/mulesoft/restapi/mode/listservers.pm +++ b/apps/mulesoft/restapi/mode/listservers.pm @@ -31,7 +31,7 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - "filter-name:s" => { name => 'filter_name' }, + 'filter-name:s' => { name => 'filter_name' }, }); return $self; @@ -42,12 +42,6 @@ sub check_options { $self->SUPER::init(%options); } -sub manage_selection { - my ($self, %options) = @_; - - $self->{data} = $options{custom}->list_servers(); -} - sub run { my ($self, %options) = @_; @@ -56,11 +50,14 @@ sub run { next if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && $server->{name} !~ /$self->{option_results}->{filter_name}/); - $self->{output}->output_add(long_msg => sprintf("[id = %s][name = %s][status = %s]", - $server->{id}, - $server->{name}, - $server->{status} - )); + $self->{output}->output_add( + long_msg => sprintf( + "[id = %s][name = %s][status = %s]", + $server->{id}, + $server->{name}, + $server->{status} + ) + ); } $self->{output}->output_add(severity => 'OK', short_msg => 'Mulesoft Anypoint Servers:'); @@ -77,8 +74,8 @@ sub disco_format { sub disco_show { my ($self, %options) = @_; - $self->manage_selection(%options); - foreach my $server (@{$self->{data}}) { + my $result = $options{custom}->list_servers(); + foreach my $server (@{$result}) { $self->{output}->add_disco_entry( id => $server->{id}, name => $server->{name}, diff --git a/apps/mulesoft/restapi/mode/servers.pm b/apps/mulesoft/restapi/mode/servers.pm index 2bf7bc006..a3db2385d 100644 --- a/apps/mulesoft/restapi/mode/servers.pm +++ b/apps/mulesoft/restapi/mode/servers.pm @@ -24,18 +24,11 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; -use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold); +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); sub custom_status_output { my ($self, %options) = @_; - return my $msg = sprintf('Id: %s, Status: %s', $self->{result_values}->{id}, $self->{result_values}->{status}); -} - -sub custom_status_calc { - my ($self, %options) = @_; - $self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_status'}; - $self->{result_values}->{id} = $options{new_datas}->{$self->{instance} . '_id'}; - return 0; + return sprintf('Id: %s, Status: %s', $self->{result_values}->{id}, $self->{result_values}->{status}); } sub set_counters { @@ -48,21 +41,21 @@ sub set_counters { $self->{maps_counters}->{global} = [ { label => 'total', nlabel => 'mulesoft.servers.total.count', set => { - key_values => [ { name => 'total' } ], - output_template => "Total : %s", - perfdatas => [ { value => 'total_absolute', template => '%d', min => 0 } ], + key_values => [ { name => 'total' } ], + output_template => 'Total : %s', + perfdatas => [ { value => 'total_absolute', template => '%d', min => 0 } ] } }, { label => 'running', nlabel => 'mulesoft.servers.status.running.count', set => { - key_values => [ { name => 'running' } ], - output_template => "Running : %s", - perfdatas => [ { value => 'running_absolute', template => '%d', min => 0 } ] + key_values => [ { name => 'running' } ], + output_template => 'Running : %s', + perfdatas => [ { value => 'running_absolute', template => '%d', min => 0 } ] } }, { label => 'disconnected', nlabel => 'mulesoft.servers.status.disconnected.count', set => { - key_values => [ { name => 'disconnected' } ], - output_template => "Disconnected : %s", - perfdatas => [ { value => 'disconnected_absolute', template => '%d', min => 0 } ] + key_values => [ { name => 'disconnected' } ], + output_template => 'Disconnected : %s', + perfdatas => [ { value => 'disconnected_absolute', template => '%d', min => 0 } ] } } ]; @@ -70,12 +63,12 @@ sub set_counters { $self->{maps_counters}->{servers} = [ { label => 'status', threshold => 0, set => { key_values => [ { name => 'id' }, { name => 'status' }, { name => 'name'}, { name => 'display' } ], - closure_custom_calc => $self->can('custom_status_calc'), - closure_custom_output => $self->can('custom_status_output'), - closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => \&catalog_status_threshold, + closure_custom_calc => \&catalog_status_calc, + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold } - }, + } ]; } @@ -85,9 +78,9 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - "filter-name:s" => { name => 'filter_name' }, - "warning-status:s" => { name => 'warning_status', default => '' }, - "critical-status:s" => { name => 'critical_status', default => '' }, + 'filter-name:s' => { name => 'filter_name' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '' }, }); return $self; @@ -122,6 +115,7 @@ sub manage_selection { next if ( defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && $server->{name} !~ /$self->{option_results}->{filter_name}/ ); + $self->{servers}->{$server} = { display => $server, id => $server->{id}, @@ -175,7 +169,6 @@ Set warning threshold for status (Default: ''). Threshold can be matched on %{name}, %{id} or %{status} and Regexp can be used. Typical syntax: --critical-status='%{status} ~= m/DISCONNECTED/' - =back =cut From 774b447f7fb32fa6b67b3b93e5e6fc65b0b683d8 Mon Sep 17 00:00:00 2001 From: thibaults-centreon Date: Wed, 22 Apr 2020 10:51:19 +0200 Subject: [PATCH 130/283] enh(plugin): add cluster mode --- apps/mulesoft/restapi/custom/api.pm | 9 +- apps/mulesoft/restapi/mode/clusters.pm | 181 +++++++++++++++++++++++++ apps/mulesoft/restapi/plugin.pm | 1 + 3 files changed, 190 insertions(+), 1 deletion(-) create mode 100644 apps/mulesoft/restapi/mode/clusters.pm diff --git a/apps/mulesoft/restapi/custom/api.pm b/apps/mulesoft/restapi/custom/api.pm index 2b1a2f4f5..1b27bee3b 100644 --- a/apps/mulesoft/restapi/custom/api.pm +++ b/apps/mulesoft/restapi/custom/api.pm @@ -150,7 +150,6 @@ sub get_access_token { my $expires_on = $options{statefile}->get(name => 'expires_on'); my $access_token = $options{statefile}->get(name => 'access_token'); if ( $has_cache_file == 0 || !defined($access_token) || (($expires_on - time()) < 10) ) { - #my ($username, $password) = ( $self->{api_username}, $self->{api_password} ); my $login = { username => $self->{api_username}, password => $self->{api_password} }; my $post_json = JSON::XS->new->utf8->encode($login); @@ -263,6 +262,14 @@ sub get_server_status { return $response->{data}; } +sub list_clusters { + my ($self, %options) = @_; + + my $url_path = $self->{monitoring_endpoint} . '/clusters/'; + my $response = $self->request_api(method => 'GET', url_path => $url_path); + + return $response->{data}; +} sub cache_hosts { my ($self, %options) = @_; diff --git a/apps/mulesoft/restapi/mode/clusters.pm b/apps/mulesoft/restapi/mode/clusters.pm new file mode 100644 index 000000000..5f1cfef53 --- /dev/null +++ b/apps/mulesoft/restapi/mode/clusters.pm @@ -0,0 +1,181 @@ +# +# Copyright 2020 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and cluster 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::mulesoft::restapi::mode::clusters; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold); + +sub custom_status_output { + my ($self, %options) = @_; + return my $msg = sprintf('Id: %s, Status: %s', $self->{result_values}->{id}, $self->{result_values}->{status}); +} + +sub custom_status_calc { + my ($self, %options) = @_; + $self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_status'}; + $self->{result_values}->{id} = $options{new_datas}->{$self->{instance} . '_id'}; + return 0; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0, cb_prefix_output => 'prefix_global_output' }, + { name => 'clusters', type => 1, cb_prefix_output => 'prefix_cluster_output', message_multiple => 'All clusters are ok' } + ]; + + $self->{maps_counters}->{global} = [ + { label => 'total', nlabel => 'mulesoft.clusters.total.count', set => { + key_values => [ { name => 'total' } ], + output_template => "Total : %s", + perfdatas => [ { value => 'total_absolute', template => '%d', min => 0 } ], + } + }, + { label => 'running', nlabel => 'mulesoft.clusters.status.running.count', set => { + key_values => [ { name => 'running' } ], + output_template => "Running : %s", + perfdatas => [ { value => 'running_absolute', template => '%d', min => 0 } ] + } + }, + { label => 'disconnected', nlabel => 'mulesoft.clusters.status.disconnected.count', set => { + key_values => [ { name => 'disconnected' } ], + output_template => "Disconnected : %s", + perfdatas => [ { value => 'disconnected_absolute', template => '%d', min => 0 } ] + } + } + ]; + + $self->{maps_counters}->{clusters} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'id' }, { name => 'status' }, { name => 'name'}, { name => 'display' } ], + closure_custom_calc => $self->can('custom_status_calc'), + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold, + } + }, + ]; +} + +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' }, + "warning-status:s" => { name => 'warning_status', default => '' }, + "critical-status:s" => { name => 'critical_status', default => '' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->change_macros(macros => ['warning_status', 'critical_status']); +} + +sub prefix_global_output { + my ($self, %options) = @_; + + return "Total clusters "; +} + +sub prefix_cluster_output { + my ($self, %options) = @_; + + return "cluster '" . $options{instance_value}->{name} . "' "; +} + +sub manage_selection { + my ($self, %options) = @_; + + $self->{global} = { started => 0, stopped => 0, failed => 0 }; + $self->{clusters} = {}; + my $result = $options{custom}->list_clusters(); + foreach my $cluster (@{$result}) { + next if ( defined($self->{option_results}->{filter_name}) + && $self->{option_results}->{filter_name} ne '' + && $cluster->{name} !~ /$self->{option_results}->{filter_name}/ ); + $self->{clusters}->{$cluster} = { + display => $cluster, + id => $cluster->{id}, + name => $cluster->{name}, + status => $cluster->{status}, + }; + + $self->{global}->{running}++ if $cluster->{status} =~ m/RUNNING/; + $self->{global}->{disconnected}++ if $cluster->{status} =~ m/DISCONNECTED/; + } + + if (scalar(keys %{$self->{clusters}}) <= 0) { + $self->{output}->add_option_msg(short_msg => "No cluster found."); + $self->{output}->option_exit(); + } + + $self->{global}->{total} = scalar (keys %{$self->{clusters}}); +} + +1; + +__END__ + +=head1 MODE + +Check Mulesoft Anypoint clusters status. + +Example: +perl centreon_plugins.pl --plugin=apps::mulesoft::restapi::plugin --mode=clusters +--environment-id='1234abc-56de-78fg-90hi-1234abcdefg' --organization-id='1234abcd-56ef-78fg-90hi-1234abcdefg' +--api-username='myapiuser' --api-password='myapipassword' --verbose + +More information on'https://anypoint.mulesoft.com/exchange/portals/anypoint-platform/'. + +=over 8 + +=item B<--filter-name> + +Filter by cluster name (Regexp can be used). +Example: --filter-name='^cluster1$' + +=item B<--warning-status> + +Set warning threshold for status (Default: ''). +Threshold can be matched on %{name}, %{id} or %{status} and Regexp can be used. +Typical syntax: --warning-status='%{status} ne "RUNNING"' + +=item B<--critical-status> + +Set warning threshold for status (Default: ''). +Threshold can be matched on %{name}, %{id} or %{status} and Regexp can be used. +Typical syntax: --critical-status='%{status} ~= m/DISCONNECTED/' + + +=back + +=cut diff --git a/apps/mulesoft/restapi/plugin.pm b/apps/mulesoft/restapi/plugin.pm index e693c3dd0..94ab8528c 100644 --- a/apps/mulesoft/restapi/plugin.pm +++ b/apps/mulesoft/restapi/plugin.pm @@ -35,6 +35,7 @@ sub new { 'listapplications' => 'apps::mulesoft::restapi::mode::listapplications', 'servers' => 'apps::mulesoft::restapi::mode::servers', 'listservers' => 'apps::mulesoft::restapi::mode::listservers', + 'clusters' => 'apps::mulesoft::restapi::mode::clusters' ); $self->{custom_modes}{restapi} = 'apps::mulesoft::restapi::custom::api'; From 7c4316088419f0a2a28faff56ba952a65c929847 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 23 Apr 2020 11:23:52 +0200 Subject: [PATCH 131/283] Fix --- snmp_standard/mode/listspanningtrees.pm | 97 ++++++++++++++----------- snmp_standard/mode/spanningtree.pm | 73 +++++++++++-------- 2 files changed, 95 insertions(+), 75 deletions(-) diff --git a/snmp_standard/mode/listspanningtrees.pm b/snmp_standard/mode/listspanningtrees.pm index e8d3da959..0f3deff3f 100644 --- a/snmp_standard/mode/listspanningtrees.pm +++ b/snmp_standard/mode/listspanningtrees.pm @@ -29,12 +29,10 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - - $options{options}->add_options(arguments => - { - "filter-port:s" => { name => 'filter_port' }, - }); - $self->{spanningtrees} = {}; + + $options{options}->add_options(arguments => { + 'filter-port:s' => { name => 'filter_port' }, + }); return $self; } @@ -44,32 +42,33 @@ sub check_options { $self->SUPER::init(%options); } -my %mapping_state = ( +my $mapping_state = { 1 => 'disabled', 2 => 'blocking', 3 => 'listening', 4 => 'learning', 5 => 'forwarding', 6 => 'broken', - 10 => 'not defined', -); -my %mapping_status = ( + 10 => 'not defined' +}; +my $mapping_status = { 1 => 'enabled', - 2 => 'disabled', -); + 2 => 'disabled' +}; my $mapping = { - dot1dStpPortState => { oid => '.1.3.6.1.2.1.17.2.15.1.3', map => \%mapping_state }, - dot1dStpPortEnable => { oid => '.1.3.6.1.2.1.17.2.15.1.4', map => \%mapping_status }, + dot1dStpPortState => { oid => '.1.3.6.1.2.1.17.2.15.1.3', map => $mapping_state }, + dot1dStpPortEnable => { oid => '.1.3.6.1.2.1.17.2.15.1.4', map => $mapping_status } }; my $oid_dot1dStpPortEntry = '.1.3.6.1.2.1.17.2.15.1'; my $oid_dot1dBasePortIfIndex = '.1.3.6.1.2.1.17.1.4.1.2'; -my %mapping_if_status = ( +my $mapping_if_status = { 1 => 'up', 2 => 'down', 3 => 'testing', 4 => 'unknown', 5 => 'dormant', 6 => 'notPresent', 7 => 'lowerLayerDown', -); + 100 => 'notfound' +}; my $oid_ifDesc = '.1.3.6.1.2.1.2.2.1.2'; my $oid_ifAdminStatus = '.1.3.6.1.2.1.2.2.1.7'; my $oid_ifOpStatus = '.1.3.6.1.2.1.2.2.1.8'; @@ -77,16 +76,17 @@ my $oid_ifOpStatus = '.1.3.6.1.2.1.2.2.1.8'; sub manage_selection { my ($self, %options) = @_; - my $results = $options{snmp}->get_table(oid => $oid_dot1dStpPortEntry, start => $mapping->{dot1dStpPortState}->{oid}, end => $mapping->{dot1dStpPortEnable}->{oid}, nothing_quit => 1); + my $results = {}; + my $snmp_results = $options{snmp}->get_table(oid => $oid_dot1dStpPortEntry, start => $mapping->{dot1dStpPortState}->{oid}, end => $mapping->{dot1dStpPortEnable}->{oid}, nothing_quit => 1); my @instances = (); - foreach my $oid (keys %{$results}) { + foreach my $oid (keys %$snmp_results) { next if ($oid !~ /^$mapping->{dot1dStpPortState}->{oid}\.(.*)/); my $instance = $1; - my $map_result = $options{snmp}->map_instance(mapping => $mapping, results => $results, instance => $instance); + my $map_result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_results, instance => $instance); if ($map_result->{dot1dStpPortEnable} =~ /disabled/) { - $self->{output}->output_add(long_msg => sprintf("Skipping interface '%d': Stp port disabled", $instance), debug => 1); + $self->{output}->output_add(long_msg => sprintf("skipping interface '%d': Stp port disabled", $instance), debug => 1); next; } push @instances, $instance; @@ -102,44 +102,55 @@ sub manage_selection { my $result_if = $options{snmp}->get_leef(); foreach my $instance (@instances) { - my $map_result = $options{snmp}->map_instance(mapping => $mapping, results => $results, instance => $instance); + my $map_result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_results, instance => $instance); my $state = (defined($map_result->{dot1dStpPortState})) ? $map_result->{dot1dStpPortState} : 'not defined'; my $description = (defined($result->{$oid_dot1dBasePortIfIndex . '.' . $instance}) && defined($result_if->{$oid_ifDesc . '.' . $result->{$oid_dot1dBasePortIfIndex . '.' . $instance}})) ? - $result_if->{$oid_ifDesc . '.' . $result->{$oid_dot1dBasePortIfIndex . '.' . $instance}} : 'unknown'; + $result_if->{$oid_ifDesc . '.' . $result->{$oid_dot1dBasePortIfIndex . '.' . $instance}} : $instance . '.unknown'; my $admin_status = (defined($result->{$oid_dot1dBasePortIfIndex . '.' . $instance}) && defined($result_if->{$oid_ifAdminStatus . '.' . $result->{$oid_dot1dBasePortIfIndex . '.' . $instance}})) ? - $result_if->{$oid_ifAdminStatus . '.' . $result->{$oid_dot1dBasePortIfIndex . '.' . $instance}} : 'unknown'; + $result_if->{$oid_ifAdminStatus . '.' . $result->{$oid_dot1dBasePortIfIndex . '.' . $instance}} : 100; my $op_status = (defined($result->{$oid_dot1dBasePortIfIndex . '.' . $instance}) && defined($result_if->{$oid_ifOpStatus . '.' . $result->{$oid_dot1dBasePortIfIndex . '.' . $instance}})) ? - $result_if->{$oid_ifOpStatus . '.' . $result->{$oid_dot1dBasePortIfIndex . '.' . $instance}} : 'unknown'; + $result_if->{$oid_ifOpStatus . '.' . $result->{$oid_dot1dBasePortIfIndex . '.' . $instance}} : 100; if (defined($self->{option_results}->{filter_port}) && $self->{option_results}->{filter_port} ne '' && $description !~ /$self->{option_results}->{filter_port}/) { - $self->{output}->output_add(long_msg => sprintf("Skipping interface '%s': filtered with options", $description), debug => 1); + $self->{output}->output_add(long_msg => sprintf("skipping interface '%s': filtered with options", $description), debug => 1); next; } - $self->{spanningtrees}->{$result->{$oid_dot1dBasePortIfIndex . '.' . $instance}} = { + $results->{$instance} = { state => $state, - admin_status => $mapping_if_status{$admin_status}, - op_status => $mapping_if_status{$op_status}, - index => $result->{$oid_dot1dBasePortIfIndex . '.' . $instance}, + admin_status => $mapping_if_status->{$admin_status}, + op_status => $mapping_if_status->{$op_status}, + index => defined($result->{$oid_dot1dBasePortIfIndex . '.' . $instance}) ? $result->{$oid_dot1dBasePortIfIndex . '.' . $instance} : 'notfound', description => $description }; } + + return $results; } sub run { my ($self, %options) = @_; - $self->manage_selection(%options); - foreach my $instance (sort keys %{$self->{spanningtrees}}) { - $self->{output}->output_add(long_msg => sprintf("[port = %s] [state = %s] [op_status = %s] [admin_status = %s] [index = %s]", - $self->{spanningtrees}->{$instance}->{description}, $self->{spanningtrees}->{$instance}->{state}, $self->{spanningtrees}->{$instance}->{op_status}, - $self->{spanningtrees}->{$instance}->{admin_status}, $self->{spanningtrees}->{$instance}->{index})); + my $results = $self->manage_selection(%options); + foreach my $instance (sort keys %$results) { + $self->{output}->output_add( + long_msg => sprintf( + "[port = %s] [state = %s] [op_status = %s] [admin_status = %s] [index = %s]", + $results->{$instance}->{description}, + $results->{$instance}->{state}, + $results->{$instance}->{op_status}, + $results->{$instance}->{admin_status}, + $results->{$instance}->{index} + ) + ); } - $self->{output}->output_add(severity => 'OK', - short_msg => 'List ports with Spanning Tree Protocol:'); + $self->{output}->output_add( + severity => 'OK', + short_msg => 'List ports with spanning tree protocol:' + ); $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1); $self->{output}->exit(); } @@ -153,14 +164,14 @@ sub disco_format { sub disco_show { my ($self, %options) = @_; - $self->manage_selection(%options); - foreach my $instance (sort keys %{$self->{spanningtrees}}) { + my $results = $self->manage_selection(%options); + foreach my $instance (sort keys %$results) { $self->{output}->add_disco_entry( - port => $self->{spanningtrees}->{$instance}->{description}, - state => $self->{spanningtrees}->{$instance}->{state}, - op_status => $self->{spanningtrees}->{$instance}->{op_status}, - admin_status => $self->{spanningtrees}->{$instance}->{admin_status}, - index => $self->{spanningtrees}->{$instance}->{index} + port => $results->{$instance}->{description}, + state => $results->{$instance}->{state}, + op_status => $results->{$instance}->{op_status}, + admin_status => $results->{$instance}->{admin_status}, + index => $results->{$instance}->{index} ); } } diff --git a/snmp_standard/mode/spanningtree.pm b/snmp_standard/mode/spanningtree.pm index ea9cc88b4..ad31e156a 100644 --- a/snmp_standard/mode/spanningtree.pm +++ b/snmp_standard/mode/spanningtree.pm @@ -29,10 +29,11 @@ use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold) sub custom_status_output { my ($self, %options) = @_; - my $msg = sprintf("spanning tree state is '%s' [op status: '%s'] [admin status: '%s'] [index: '%s']", + return sprintf( + "spanning tree state is '%s' [op status: '%s'] [admin status: '%s'] [index: '%s']", $self->{result_values}->{state}, $self->{result_values}->{op_status}, - $self->{result_values}->{admin_status}, $self->{result_values}->{index}); - return $msg; + $self->{result_values}->{admin_status}, $self->{result_values}->{index} + ) } sub custom_status_calc { @@ -52,10 +53,13 @@ sub set_counters { $self->{maps_counters_type} = [ { name => 'spanningtrees', type => 1, cb_prefix_output => 'prefix_peers_output', message_multiple => 'All spanning trees are ok' }, ]; + $self->{maps_counters}->{spanningtrees} = [ { label => 'status', threshold => 0, set => { - key_values => [ { name => 'state' }, { name => 'admin_status' }, { name => 'op_status' }, - { name => 'index' }, { name => 'description' } ], + key_values => [ + { name => 'state' }, { name => 'admin_status' }, { name => 'op_status' }, + { name => 'index' }, { name => 'description' } + ], closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, @@ -76,12 +80,11 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-port:s" => { name => 'filter_port' }, - "warning-status:s" => { name => 'warning_status', default => '' }, - "critical-status:s" => { name => 'critical_status', default => '%{op_status} =~ /up/ && %{state} =~ /blocking|broken/' }, - }); + $options{options}->add_options(arguments => { + 'filter-port:s' => { name => 'filter_port' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '%{op_status} =~ /up/ && %{state} =~ /blocking|broken/' }, + }); return $self; } @@ -93,50 +96,51 @@ sub check_options { $self->change_macros(macros => ['warning_status', 'critical_status']); } -my %mapping_state = ( +my $mapping_state = { 1 => 'disabled', 2 => 'blocking', 3 => 'listening', 4 => 'learning', 5 => 'forwarding', 6 => 'broken', - 10 => 'not defined', -); -my %mapping_status = ( + 10 => 'not defined' +}; +my $mapping_status = { 1 => 'enabled', - 2 => 'disabled', -); + 2 => 'disabled' +}; my $mapping = { - dot1dStpPortState => { oid => '.1.3.6.1.2.1.17.2.15.1.3', map => \%mapping_state }, - dot1dStpPortEnable => { oid => '.1.3.6.1.2.1.17.2.15.1.4', map => \%mapping_status }, + dot1dStpPortState => { oid => '.1.3.6.1.2.1.17.2.15.1.3', map => $mapping_state }, + dot1dStpPortEnable => { oid => '.1.3.6.1.2.1.17.2.15.1.4', map => $mapping_status } }; my $oid_dot1dStpPortEntry = '.1.3.6.1.2.1.17.2.15.1'; my $oid_dot1dBasePortIfIndex = '.1.3.6.1.2.1.17.1.4.1.2'; -my %mapping_if_status = ( +my $mapping_if_status = { 1 => 'up', 2 => 'down', 3 => 'testing', 4 => 'unknown', 5 => 'dormant', 6 => 'notPresent', 7 => 'lowerLayerDown', -); + 100 => 'notfound' +}; my $oid_ifDesc = '.1.3.6.1.2.1.2.2.1.2'; my $oid_ifAdminStatus = '.1.3.6.1.2.1.2.2.1.7'; my $oid_ifOpStatus = '.1.3.6.1.2.1.2.2.1.8'; sub manage_selection { my ($self, %options) = @_; - + $self->{spanningtrees} = {}; my $results = $options{snmp}->get_table(oid => $oid_dot1dStpPortEntry, start => $mapping->{dot1dStpPortState}->{oid}, end => $mapping->{dot1dStpPortEnable}->{oid}, nothing_quit => 1); my @instances = (); - foreach my $oid (keys %{$results}) { + foreach my $oid (keys %$results) { next if ($oid !~ /^$mapping->{dot1dStpPortState}->{oid}\.(.*)/); my $instance = $1; my $map_result = $options{snmp}->map_instance(mapping => $mapping, results => $results, instance => $instance); if ($map_result->{dot1dStpPortEnable} =~ /disabled/) { - $self->{output}->output_add(long_msg => sprintf("Skipping interface '%d': Stp port disabled", $instance), debug => 1); + $self->{output}->output_add(long_msg => sprintf("skipping interface '%d': Stp port disabled", $instance), debug => 1); next; } push @instances, $instance; @@ -145,7 +149,7 @@ sub manage_selection { $options{snmp}->load(oids => [ $oid_dot1dBasePortIfIndex ], instances => [ @instances ]); my $result = $options{snmp}->get_leef(nothing_quit => 1); - foreach my $oid (keys %{$result}) { + foreach my $oid (keys %$result) { next if ($oid !~ /^$oid_dot1dBasePortIfIndex\./ || !defined($result->{$oid})); $options{snmp}->load(oids => [ $oid_ifDesc . "." . $result->{$oid}, $oid_ifAdminStatus . "." . $result->{$oid}, $oid_ifOpStatus . "." . $result->{$oid} ]); } @@ -156,22 +160,27 @@ sub manage_selection { my $state = (defined($map_result->{dot1dStpPortState})) ? $map_result->{dot1dStpPortState} : 'not defined'; my $description = (defined($result->{$oid_dot1dBasePortIfIndex . '.' . $instance}) && defined($result_if->{$oid_ifDesc . '.' . $result->{$oid_dot1dBasePortIfIndex . '.' . $instance}})) ? - $result_if->{$oid_ifDesc . '.' . $result->{$oid_dot1dBasePortIfIndex . '.' . $instance}} : 'unknown'; + $result_if->{$oid_ifDesc . '.' . $result->{$oid_dot1dBasePortIfIndex . '.' . $instance}} : $instance . '.unknown'; my $admin_status = (defined($result->{$oid_dot1dBasePortIfIndex . '.' . $instance}) && defined($result_if->{$oid_ifAdminStatus . '.' . $result->{$oid_dot1dBasePortIfIndex . '.' . $instance}})) ? - $result_if->{$oid_ifAdminStatus . '.' . $result->{$oid_dot1dBasePortIfIndex . '.' . $instance}} : 'unknown'; + $result_if->{$oid_ifAdminStatus . '.' . $result->{$oid_dot1dBasePortIfIndex . '.' . $instance}} : 100; my $op_status = (defined($result->{$oid_dot1dBasePortIfIndex . '.' . $instance}) && defined($result_if->{$oid_ifOpStatus . '.' . $result->{$oid_dot1dBasePortIfIndex . '.' . $instance}})) ? - $result_if->{$oid_ifOpStatus . '.' . $result->{$oid_dot1dBasePortIfIndex . '.' . $instance}} : 'unknown'; + $result_if->{$oid_ifOpStatus . '.' . $result->{$oid_dot1dBasePortIfIndex . '.' . $instance}} : 100; if (defined($self->{option_results}->{filter_port}) && $self->{option_results}->{filter_port} ne '' && $description !~ /$self->{option_results}->{filter_port}/) { - $self->{output}->output_add(long_msg => sprintf("Skipping interface '%s': filtered with options", $description), debug => 1); + $self->{output}->output_add(long_msg => sprintf("skipping interface '%s': filtered with options", $description), debug => 1); next; } - $self->{spanningtrees}->{$result->{$oid_dot1dBasePortIfIndex . '.' . $instance}} = { + if (!defined($result->{$oid_dot1dBasePortIfIndex . '.' . $instance})) { + $self->{output}->output_add(long_msg => sprintf("skipping spanning '%s': filtered with options", $instance), debug => 1); + next; + } + + $self->{spanningtrees}->{$instance} = { state => $state, - admin_status => $mapping_if_status{$admin_status}, - op_status => $mapping_if_status{$op_status}, + admin_status => $mapping_if_status->{$admin_status}, + op_status => $mapping_if_status->{$op_status}, index => $result->{$oid_dot1dBasePortIfIndex . '.' . $instance}, description => $description }; From 1756105eaa09ff9e3d695db01609805505f9e817 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 23 Apr 2020 11:24:31 +0200 Subject: [PATCH 132/283] typo --- apps/vmware/connector/mode/countvmhost.pm | 41 ++++++++++++----------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/apps/vmware/connector/mode/countvmhost.pm b/apps/vmware/connector/mode/countvmhost.pm index ceafaf862..9b2878e27 100644 --- a/apps/vmware/connector/mode/countvmhost.pm +++ b/apps/vmware/connector/mode/countvmhost.pm @@ -29,8 +29,7 @@ use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold) sub custom_status_output { my ($self, %options) = @_; - my $msg = 'status ' . $self->{result_values}->{status}; - return $msg; + return 'status ' . $self->{result_values}->{status}; } sub custom_status_calc { @@ -45,7 +44,7 @@ sub set_counters { $self->{maps_counters_type} = [ { name => 'global', type => 0, skipped_code => { -10 => 1 } }, - { name => 'host', type => 1, cb_prefix_output => 'prefix_host_output', message_multiple => 'All ESX Hosts are ok' }, + { name => 'host', type => 1, cb_prefix_output => 'prefix_host_output', message_multiple => 'All ESX Hosts are ok' } ]; $self->{maps_counters}->{global} = [ @@ -54,8 +53,8 @@ sub set_counters { output_template => '%s VM(s) poweredon', perfdatas => [ { label => 'poweredon', value => 'poweredon_absolute', template => '%s', - min => 0, max => 'total_absolute' }, - ], + min => 0, max => 'total_absolute' } + ] } }, { label => 'total-off', nlabel => 'host.vm.poweredoff.current.count', set => { @@ -63,8 +62,8 @@ sub set_counters { output_template => '%s VM(s) poweredoff', perfdatas => [ { label => 'poweredoff', value => 'poweredoff_absolute', template => '%s', - min => 0, max => 'total_absolute' }, - ], + min => 0, max => 'total_absolute' } + ] } }, { label => 'total-suspended', nlabel => 'host.vm.suspended.current.count', set => { @@ -72,8 +71,8 @@ sub set_counters { output_template => '%s VM(s) suspended', perfdatas => [ { label => 'suspended', value => 'suspended_absolute', template => '%s', - min => 0, max => 'total_absolute' }, - ], + min => 0, max => 'total_absolute' } + ] } }, ]; @@ -84,7 +83,7 @@ sub set_counters { closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => \&catalog_status_threshold, + closure_custom_threshold_check => \&catalog_status_threshold } }, { label => 'on', nlabel => 'host.vm.poweredon.current.count', set => { @@ -92,8 +91,8 @@ sub set_counters { output_template => '%s VM(s) poweredon', perfdatas => [ { label => 'poweredon', value => 'poweredon_absolute', template => '%s', - min => 0, max => 'total_absolute', label_extra_instance => 1 }, - ], + min => 0, max => 'total_absolute', label_extra_instance => 1 } + ] } }, { label => 'off', nlabel => 'host.vm.poweredoff.current.count', set => { @@ -101,8 +100,8 @@ sub set_counters { output_template => '%s VM(s) poweredoff', perfdatas => [ { label => 'poweredoff', value => 'poweredoff_absolute', template => '%s', - min => 0, max => 'total_absolute', label_extra_instance => 1 }, - ], + min => 0, max => 'total_absolute', label_extra_instance => 1 } + ] } }, { label => 'suspended', nlabel => 'host.vm.suspended.current.count', set => { @@ -110,10 +109,10 @@ sub set_counters { output_template => '%s VM(s) suspended', perfdatas => [ { label => 'suspended', value => 'suspended_absolute', template => '%s', - min => 0, max => 'total_absolute', label_extra_instance => 1 }, - ], + min => 0, max => 'total_absolute', label_extra_instance => 1 } + ] } - }, + } ]; } @@ -153,8 +152,10 @@ sub manage_selection { $self->{global} = { poweredon => 0, poweredoff => 0, suspended => 0, total => 0 }; $self->{host} = {}; - my $response = $options{custom}->execute(params => $self->{option_results}, - command => 'countvmhost'); + my $response = $options{custom}->execute( + params => $self->{option_results}, + command => 'countvmhost' + ); foreach my $host_id (keys %{$response->{data}}) { my $host_name = $response->{data}->{$host_id}->{name}; @@ -170,7 +171,7 @@ sub manage_selection { $self->{global}->{poweredoff} += $response->{data}->{$host_id}->{poweredoff} if (defined($response->{data}->{$host_id}->{poweredoff})); $self->{global}->{suspended} += $response->{data}->{$host_id}->{suspended} if (defined($response->{data}->{$host_id}->{suspended})); } - + $self->{global}->{total} = $self->{global}->{poweredon} + $self->{global}->{poweredoff} + $self->{global}->{suspended}; } From 3a549e7393592ca2d40f03f28ce317df28f55183 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 23 Apr 2020 13:30:17 +0200 Subject: [PATCH 133/283] Fix #1957 --- network/paloalto/ssh/mode/environment.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/network/paloalto/ssh/mode/environment.pm b/network/paloalto/ssh/mode/environment.pm index a5e4c6349..e38707463 100644 --- a/network/paloalto/ssh/mode/environment.pm +++ b/network/paloalto/ssh/mode/environment.pm @@ -37,7 +37,7 @@ sub set_system { $self->{thresholds} = { default => [ ['false', 'OK'], - ['.*', 'CRITICAL'], + ['.*', 'CRITICAL'] ] }; @@ -52,6 +52,7 @@ sub ssh_execute { ($self->{results}, $self->{exit_code}) = $options{custom}->execute_command( command => 'show system environmentals', + ForceArray => ['entry'] ); } From 65108bb9e9efcc5ff4fb381984b6bc94e971135e Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 23 Apr 2020 13:55:18 +0200 Subject: [PATCH 134/283] add ha state --- network/paloalto/ssh/mode/interfaces.pm | 31 +++++++++++++++---------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/network/paloalto/ssh/mode/interfaces.pm b/network/paloalto/ssh/mode/interfaces.pm index 6f481507d..ac4d8e96d 100644 --- a/network/paloalto/ssh/mode/interfaces.pm +++ b/network/paloalto/ssh/mode/interfaces.pm @@ -43,7 +43,7 @@ sub set_counters { $self->{maps_counters_type} = [ { name => 'global', type => 0 }, - { name => 'interface', type => 1, cb_prefix_output => 'prefix_interface_output', message_multiple => 'All interface are ok', skipped_code => { -10 => 1 } }, + { name => 'interface', type => 1, cb_prefix_output => 'prefix_interface_output', message_multiple => 'All interface are ok', skipped_code => { -10 => 1 } } ]; $self->{maps_counters}->{global} = [ @@ -51,21 +51,24 @@ sub set_counters { key_values => [ { name => 'total' } ], output_template => 'total interfaces: %s', perfdatas => [ - { value => 'total_absolute', template => '%s', min => 0 }, - ], + { value => 'total_absolute', template => '%s', min => 0 } + ] } }, ]; $self->{maps_counters}->{interface} = [ { label => 'status', threshold => 0, set => { - key_values => [ { name => 'state' }, { name => 'type' }, { name => 'display' } ], + key_values => [ + { name => 'state' }, { name => 'type' }, + { name => 'ha_state' }, { name => 'display' } + ], closure_custom_calc => \&catalog_status_calc, closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => \&catalog_status_threshold, + closure_custom_threshold_check => \&catalog_status_threshold } - }, + } ]; } @@ -84,7 +87,7 @@ sub new { 'filter-name:s' => { name => 'filter_name' }, 'unknown-status:s' => { name => 'unknown_status', default => '' }, 'warning-status:s' => { name => 'warning_status', default => '' }, - 'critical-status:s' => { name => 'critical_status', default => '%{state} ne "up"' }, + 'critical-status:s' => { name => 'critical_status', default => '%{state} ne "up"' } }); return $self; @@ -104,7 +107,10 @@ sub check_options { sub manage_selection { my ($self, %options) = @_; - my $result = $options{custom}->execute_command(command => 'show interface all', ForceArray => ['entry']); + my $result = $options{custom}->execute_command(command => 'show high-availability state'); + my $ha_state = defined($result->{group}->{'local-info'}->{state}) ? $result->{group}->{'local-info'}->{state} : 'disabled'; + + $result = $options{custom}->execute_command(command => 'show interface all', ForceArray => ['entry']); $self->{global} = { total => 0 }; $self->{interface} = {}; @@ -118,7 +124,8 @@ sub manage_selection { $self->{interface}->{$_->{name}} = { display => $_->{name}, type => $_->{type}, - state => $_->{state} + state => $_->{state}, + ha_state => $ha_state }; $self->{global}->{total}++; } @@ -141,17 +148,17 @@ Filter interface name (can be a regexp). =item B<--unknown-status> Set unknown threshold for status (Default: ''). -Can used special variables like: %{state}, %{type}, %{display} +Can used special variables like: %{state}, %{type}, %{ha_state}, %{display} =item B<--warning-status> Set warning threshold for status (Default: ''). -Can used special variables like: %{state}, %{type}, %{display} +Can used special variables like: %{state}, %{type}, %{ha_state}, %{display} =item B<--critical-status> Set critical threshold for status (Default: '%{state} ne "active"'). -Can used special variables like: %{state}, %{type}, %{display} +Can used special variables like: %{state}, %{type}, %{ha_state}, %{display} =item B<--warning-*> B<--critical-*> From 30436aab3f6eab4c6c84b3e80ec7f425900f525f Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 23 Apr 2020 15:35:34 +0200 Subject: [PATCH 135/283] change vpn to ipsec mode for palo alto ssh --- .../paloalto/ssh/mode/{vpn.pm => ipsec.pm} | 75 +++++++++++-------- network/paloalto/ssh/plugin.pm | 4 +- 2 files changed, 45 insertions(+), 34 deletions(-) rename network/paloalto/ssh/mode/{vpn.pm => ipsec.pm} (58%) diff --git a/network/paloalto/ssh/mode/vpn.pm b/network/paloalto/ssh/mode/ipsec.pm similarity index 58% rename from network/paloalto/ssh/mode/vpn.pm rename to network/paloalto/ssh/mode/ipsec.pm index b4a7def7c..348ffc118 100644 --- a/network/paloalto/ssh/mode/vpn.pm +++ b/network/paloalto/ssh/mode/ipsec.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package network::paloalto::ssh::mode::vpn; +package network::paloalto::ssh::mode::ipsec; use base qw(centreon::plugins::templates::counter); @@ -30,12 +30,12 @@ use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold sub custom_status_output { my ($self, %options) = @_; - my $msg = sprintf( - 'state: %s [type: %s]', + return sprintf( + 'state: %s [monitor status: %s][ike phase1 state: %s]', $self->{result_values}->{state}, - $self->{result_values}->{type} + $self->{result_values}->{monitor_status}, + $self->{result_values}->{ike_phase1_state} ); - return $msg; } sub set_counters { @@ -43,36 +43,39 @@ sub set_counters { $self->{maps_counters_type} = [ { name => 'global', type => 0 }, - { name => 'vpn', type => 1, cb_prefix_output => 'prefix_vpn_output', message_multiple => 'All vpn are ok', skipped_code => { -10 => 1 } }, + { name => 'tunnels', type => 1, cb_prefix_output => 'prefix_ipsec_output', message_multiple => 'All ipsec tunnels are ok', skipped_code => { -10 => 1 } }, ]; $self->{maps_counters}->{global} = [ - { label => 'total-ipsec', nlabel => 'vpn.total.ipsec.count', display_ok => 0, set => { + { label => 'ipsec-total', nlabel => 'tunnels.ipsec.total.count', display_ok => 0, set => { key_values => [ { name => 'total_ipsec' } ], - output_template => 'total ipsec vpn: %s', + output_template => 'total ipsec tunnels: %s', perfdatas => [ - { value => 'total_ipsec_absolute', template => '%s', min => 0 }, - ], + { value => 'total_ipsec_absolute', template => '%s', min => 0 } + ] } - }, + } ]; - $self->{maps_counters}->{vpn} = [ + $self->{maps_counters}->{tunnels} = [ { label => 'status', threshold => 0, set => { - key_values => [ { name => 'state' }, { name => 'type' }, { name => 'display' } ], + key_values => [ + { name => 'state' }, { name => 'ike_phase1_state' }, + { name => 'monitor_status' }, { name => 'display' } + ], closure_custom_calc => \&catalog_status_calc, closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => \&catalog_status_threshold, + closure_custom_threshold_check => \&catalog_status_threshold } - }, + } ]; } -sub prefix_vpn_output { +sub prefix_ipsec_output { my ($self, %options) = @_; - return "vpn '" . $options{instance_value}->{display} . "' "; + return "Tunnel ipsec '" . $options{instance_value}->{display} . "' "; } sub new { @@ -83,7 +86,7 @@ sub new { $options{options}->add_options(arguments => { 'unknown-status:s' => { name => 'unknown_status', default => '' }, 'warning-status:s' => { name => 'warning_status', default => '' }, - 'critical-status:s' => { name => 'critical_status', default => '%{state} ne "active"' }, + 'critical-status:s' => { name => 'critical_status', default => '%{ike_phase1_state} eq "down" or %{state} ne "active"' } }); return $self; @@ -103,18 +106,26 @@ sub check_options { sub manage_selection { my ($self, %options) = @_; - my $result = $options{custom}->execute_command(command => 'show vpn flow', ForceArray => ['entry']); + my $result = $options{custom}->execute_command(command => 'show vpn ike-sa', ForceArray => ['entry']); $self->{global} = { total_ipsec => 0 }; - $self->{vpn} = {}; - foreach (@{$result->{IPSec}->{entry}}) { - $self->{vpn}->{$_->{name}} = { + $self->{tunnels} = {}; + foreach (@{$result->{tunnels}}) { + $self->{tunnels}->{$_->{gwid}} = { display => $_->{name}, - type => 'ipsec', - state => $_->{state} + ike_phase1_state => defined($_->{created}) && $_->{created} ne '' ? 'up' : 'down', + monitor_status => 'unknown', # could be 'up', 'down', 'off' + state => 'unknown' }; + $self->{global}->{total_ipsec}++; } + + $result = $options{custom}->execute_command(command => 'show vpn flow', ForceArray => ['entry']); + foreach (@{$result->{IPSec}->{entry}}) { + $self->{tunnels}->{$_->{gwid}}->{state} = $_->{state}; + $self->{tunnels}->{$_->{gwid}}->{monitor_status} = $_->{mon}; + } } 1; @@ -123,29 +134,29 @@ __END__ =head1 MODE -Check vpn. +Check ipsec tunnels. =over 8 =item B<--unknown-status> -Set unknown threshold for status (Default: ''). -Can used special variables like: %{state}, %{type}, %{display} +Set unknown threshold for status. +Can used special variables like: %{ike_phase1_state}, %{state}, %{monitor_status}, %{display}. =item B<--warning-status> -Set warning threshold for status (Default: ''). -Can used special variables like: %{state}, %{type}, %{display} +Set warning threshold for status. +Can used special variables like: %{ike_phase1_state}, %{state}, %{monitor_status}, %{display}. =item B<--critical-status> -Set critical threshold for status (Default: '%{state} ne "active"'). -Can used special variables like: %{state}, %{type}, %{display} +Set critical threshold for status (Default: '%{ike_phase1_state} eq "down" or %{state} ne "active"'). +Can used special variables like: %{ike_phase1_state}, %{state}, %{monitor_status}, %{display}. =item B<--warning-*> B<--critical-*> Thresholds. -Can be: 'total-ipsec'. +Can be: 'ipsec-total'. =back diff --git a/network/paloalto/ssh/plugin.pm b/network/paloalto/ssh/plugin.pm index 14cdfa82f..52b69c872 100644 --- a/network/paloalto/ssh/plugin.pm +++ b/network/paloalto/ssh/plugin.pm @@ -34,8 +34,8 @@ sub new { 'environment' => 'network::paloalto::ssh::mode::environment', 'ha' => 'network::paloalto::ssh::mode::ha', 'interfaces' => 'network::paloalto::ssh::mode::interfaces', - 'system' => 'network::paloalto::ssh::mode::system', - 'vpn' => 'network::paloalto::ssh::mode::vpn', + 'ipsec' => 'network::paloalto::ssh::mode::ipsec', + 'system' => 'network::paloalto::ssh::mode::system' ); $self->{custom_modes}{ssh} = 'network::paloalto::ssh::custom::cli'; From ab599a156046dd123bc6cde4cdbf2b2f28e03a98 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 23 Apr 2020 16:01:48 +0200 Subject: [PATCH 136/283] add fsp150 wip + palo alto ssh --- network/adva/fsp150/snmp/mode/alarms.pm | 326 +++++++++++++++ network/adva/fsp150/snmp/mode/interfaces.pm | 370 ++++++++++++++++++ .../adva/fsp150/snmp/mode/listinterfaces.pm | 160 ++++++++ network/adva/fsp150/snmp/plugin.pm | 52 +++ network/paloalto/ssh/mode/ipsec.pm | 2 +- 5 files changed, 909 insertions(+), 1 deletion(-) create mode 100644 network/adva/fsp150/snmp/mode/alarms.pm create mode 100644 network/adva/fsp150/snmp/mode/interfaces.pm create mode 100644 network/adva/fsp150/snmp/mode/listinterfaces.pm create mode 100644 network/adva/fsp150/snmp/plugin.pm diff --git a/network/adva/fsp150/snmp/mode/alarms.pm b/network/adva/fsp150/snmp/mode/alarms.pm new file mode 100644 index 000000000..7bbd27ee7 --- /dev/null +++ b/network/adva/fsp150/snmp/mode/alarms.pm @@ -0,0 +1,326 @@ +# +# Copyright 2020 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 network::adva::fsp150::snmp::mode::alarms; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::misc; +use centreon::plugins::statefile; +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold); + +sub custom_status_output { + my ($self, %options) = @_; + + my $msg = sprintf("alarm %s [severity: %s] [type: %s] %s", $self->{result_values}->{label}, $self->{result_values}->{severity}, + $self->{result_values}->{type}, $self->{result_values}->{generation_time}); + return $msg; +} + +sub custom_status_calc { + my ($self, %options) = @_; + + $self->{result_values}->{type} = $options{new_datas}->{$self->{instance} . '_type'}; + $self->{result_values}->{severity} = $options{new_datas}->{$self->{instance} . '_severity'}; + $self->{result_values}->{since} = $options{new_datas}->{$self->{instance} . '_since'}; + $self->{result_values}->{generation_time} = $options{new_datas}->{$self->{instance} . '_generation_time'}; + $self->{result_values}->{label} = $options{new_datas}->{$self->{instance} . '_label'}; + return 0; +} + + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'alarms', type => 2, message_multiple => '0 problem(s) detected', display_counter_problem => { label => 'alerts', min => 0 }, + group => [ { name => 'alarm', skipped_code => { -11 => 1 } } ] + } + ]; + + $self->{maps_counters}->{alarm} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'severity' }, { name => 'type' }, { name => 'label'}, { name => 'since' }, { name => 'generation_time' } ], + closure_custom_calc => $self->can('custom_status_calc'), + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold, + } + }, + ]; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $options{options}->add_options(arguments => + { + "warning-status:s" => { name => 'warning_status', default => '%{severity} =~ /warning|minor/i' }, + "critical-status:s" => { name => 'critical_status', default => '%{severity} =~ /critical|major/i' }, + "memory" => { name => 'memory' }, + "timezone:s" => { name => 'timezone' }, + }); + + centreon::plugins::misc::mymodule_load(output => $self->{output}, module => 'DateTime', + error_msg => "Cannot load module 'DateTime'."); + $self->{statefile_cache} = centreon::plugins::statefile->new(%options); + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->change_macros(macros => ['warning_status', 'critical_status']); + if (defined($self->{option_results}->{memory})) { + $self->{statefile_cache}->check_options(%options); + } + + $self->{option_results}->{timezone} = 'GMT' if (!defined($self->{option_results}->{timezone}) || $self->{option_results}->{timezone} eq ''); +} + +my %map_type = ( + 0 => 'undefined', 5 => 'terminalLoopback', 6 => 'oosDisabled', 7 => 'oosManagement', 8 => 'oosMaintenance', 9 => 'oosAins', 10 => 'removed', + 11 => 'lossOfSignal', 12 => 'optInputPwrReceivedTooLow', 13 => 'optInputPwrReceivedTooHigh', 14 => 'laserTemperatureTooHigh', 15 => 'laserTemperatureTooLow', 16 => 'optOutputPowerTransTooLow', 17 => 'optOutputPowerTransTooHigh', + 18 => 'autoShutdownToHighTemp', 19 => 'autoShutdownToHighTxPwr', 20 => 'laserEndOfLife', 21 => 'serverSignalFailureVf', 22 => 'equalizationProgress', + 23 => 'uPortFailure', 24 => 'autoShutdownBlock', 25 => 'autoPowerShutdown', 26 => 'confOutPowerTransTooHigh', 27 => 'confOutPowerTransTooLow', + 28 => 'optSignalFailure', 29 => 'dsbdChannelPowerTooHigh', 30 => 'lossOfSignalCPort', 31 => 'lossOfSignalNPort', 32 => 'outputPowerFault', + 33 => 'eqlzAdjust', 34 => 'ampFailure', 35 => 'eqptProvMismatch', 36 => 'backreflectionTooHigh', 48 => 'fiberConnLos', 49 => 'fiberConnOptFault', + 50 => 'fiberConnInvalid', 51 => 'fiberConnMismatch', 52 => 'fiberConnCommError', 53 => 'fiberConnProtocolFailure', 54 => 'fiberConnDataFailure', + 55 => 'fiberAttenuationHigh', 57 => 'laserBiasCurrAbnormal', 58 => 'fiberConnInvalidTx', 59 => 'fiberConnMismatchTx', 60 => 'fiberAttenuationHighTx', + 61 => 'laserFailure', 62 => 'lossOfReceiverClockRecovery', 63 => 'fiberAttenuationCond', 64 => 'channelMismatch', 65 => 'alarmIndicationSignalLine', + 66 => 'alarmIndicationSignalLowerOrderPath', 67 => 'alarmIndicationSignalOdu', 68 => 'alarmIndicationSignalOpu', 69 => 'alarmIndicationSignalOtu', + 70 => 'alarmIndicationSignalHigherOrderPath', 71 => 'alarmIndicationSignalOduTcmA', 72 => 'alarmIndicationSignalOduTcmB', 73 => 'alarmIndicationSignalOduTcmC', 74 => 'virtualChannelAis', + 75 => 'amplifierAbnormal', 76 => 'automaticPowerReduction', 77 => 'automaticPowerReductionForEyeSafety', 80 => 'apsConfigMismatch', 81 => 'apsProtocolFailure', 82 => 'aseLow', + 83 => 'aseTableGenFailLow', 84 => 'aseTableGenFailHighBackreflection', 85 => 'aseTableGenFailOscMissing', 86 => 'aseTableGenFailPilot', 87 => 'aseTableGenFailSignalinput', + 88 => 'aseTableNotAvailable', 89 => 'aseTableGenProgress', 90 => 'encryptionPortAuthPasswdMissing', 92 => 'backwardDefectIndicationOdu', 93 => 'backwardDefectIndicationOtu', + 94 => 'backwardDefectIndicationOduTcmA', 95 => 'backwardDefectIndicationOduTcmB', 96 => 'backwardDefectIndicationOduTcmC', 97 => 'topologyDataCalculationInProgress', 99 => 'dispertionTunningCondition', 100 => 'lossOfCharSync', + 101 => 'lossOfCharSyncFromFarEnd', 103 => 'encryptionPortEncryptionSwitchOffEnabled', 104 => 'encryptionModuleCryPasswdMissing', 107 => 'encryptionModuleSelfTestStarted', 108 => 'encryptionPortEncryptionSwitchedOff', 109 => 'opuClientSignalFail', + 110 => 'databaseMismatch', 111 => 'databaseFailure', 112 => 'databaseNcuMismatch', 113 => 'dbReplicationIncompleted', 114 => 'databaseVersionMismatch', 115 => 'xfpDecisionThresSetFailed', 116 => 'duplexLinkFailure', 118 => 'singleFanFailure', + 119 => 'multipleFanFailure', 120 => 'lossOfSignalTransmitter', 122 => 'farEndIpAddressUnknown', 123 => 'farEndCommFailure', 125 => 'backupForcedToHalt', 127 => 'facilityForcedOn', 128 => 'fwdAseTableFailPilot', 129 => 'fwdAseTableOnPilot', + 131 => 'encryptionModuleFwpUpdateEnabled', 132 => 'fwpMismatchDownloadNotServiceAffecting', 133 => 'fwpMismatchDownloadServiceAffecting', 135 => 'gainTiltNotSettable', 136 => 'highBer', 137 => 'receiverOverloadProtection', 138 => 'hwInitializing', 139 => 'hwOprReachedHT', + 140 => 'hwDegrade', 141 => 'hwFailure', 142 => 'switchtoProtectionInhibited', 143 => 'switchtoWorkingInhibited', 148 => 'encryptionPortKeyInitExchgMissed', 149 => 'encryptionPortMaxKeyExchgFailuresReachedIs', 150 => 'encryptionPortMaxKeyExchgFailuresReachedOos', + 151 => 'encryptionPortKeyExchangedForced', 152 => 'laserOnDelay', 153 => 'lockedDefectOdu', 154 => 'lockedDefectOduTcmA', 155 => 'lockedDefectOduTcmB', 156 => 'lockedDefectOduTcmC', 157 => 'linkControlProtocolFailure', 158 => 'linkDown', 159 => 'autoShutdownSendingAisLine', + 160 => 'autoShutdownSendingAisOdu', 161 => 'autoShutdownSendingAisOpu', 162 => 'clientFailForwarding', 163 => 'autoShutdownAls', 164 => 'autoAmpShutdown', 165 => 'autoShutdownAmpAps', 166 => 'aseTableBuild', 167 => 'autoShutdownOpuClientSignalFail', 168 => 'autoShutdownSendingEPC', + 169 => 'autoShutdownSendingLckOdu', 170 => 'autoShutdownSendingOciOdu', 171 => 'autoShutdownLaserOffDueToErrFwd', 172 => 'autoShutdownTxRxLasersDueToHighTemp', 173 => 'localFault', 174 => 'localOscLevelAbnormal', 175 => 'lossOfGfpFrame', 176 => 'lossOfFrameMux', 177 => 'lossOfFrameOtu', + 178 => 'lossOfFrame', 179 => 'lossOfFrameLossOfMultiFrameOdu', 180 => 'lossOfLane', 181 => 'lossofMultiframeLowerOrderPath', 182 => 'lossOfMultiFrameOtu', 183 => 'lossofMultiframeHigherOrderPath', 184 => 'lossOfPointerLowerOrderPath', 185 => 'lossOfPointerHigherOrderPath', + 186 => 'losAttProgress', 187 => 'lossOsc', 188 => 'gfpLossOfClientSig', 189 => 'loopbackError', 190 => 'facilityLoopback', 191 => 'lossofTandemConnectionOduTcmA', 192 => 'lossofTandemConnectionOduTcmB', 193 => 'lossofTandemConnectionOduTcmC', 194 => 'mansw', 197 => 'equipmentNotAccepted', 198 => 'equipmentNotApproved', 199 => 'capabilityLevelMismatch', + 200 => 'equipmentMismatch', 201 => 'equipmentNotSupportedByPhysicalLayer', 202 => 'meaSwRevision', 203 => 'mismatch', 204 => 'midstageFault', 205 => 'multiplexStructureIdentifierMismatchOPU', 206 => 'backupNotResponding', 207 => 'openConnectionIndicationOdu', + 208 => 'openConnectionIndicationOduTcmA', 209 => 'openConnectionIndicationOduTcmB', 210 => 'openConnectionIndicationOduTcmC', 211 => 'oduTribMsiMismatch', 212 => 'transmitterDisabledOff', 213 => 'receiverDisabled', 214 => 'opmAbnormalCondition', 215 => 'faultOnOpm', 216 => 'thresOptPowerCtrlFailureHigh', + 217 => 'thresOptPowerCtrlFailureLow', 218 => 'txPowerLimited', 219 => 'oscOpticalPowerControlFailHigh', 220 => 'oscOpticalPowerControlFailLow', 221 => 'oTDRMeasuringinProgress', 222 => 'encryptionModuleCryPasswdError', 223 => 'peerLink', 224 => 'pilotReceiveLevelHigh', + 225 => 'lossOfPilotSignal', 226 => 'payloadMismatchGfp', 227 => 'payloadMismatchLowerOrderPath', 228 => 'payloadMismatchOPU', 229 => 'payloadMismatchHigherOrderPath', 230 => 'provPayloadMismatch', 231 => 'prbsLossOfSeqSynch', 232 => 'prbsRcvActivated', 233 => 'prbsTrmtActivated', 234 => 'protectionNotAvailable', 235 => 'powerSupplyUnitFailure', 236 => 'maxPowerConsProvModulesToHigh', + 237 => 'maxPowerConsEquipModulesToHigh', 238 => 'powerMissing', 239 => 'remoteDefectIndicationLine', 240 => 'remoteDefectIndicationLowerOrderPath', 241 => 'remoteDefectIndicationHigherOrderPath', 243 => 'dcnCommunicationFail', 244 => 'ntpForSchedEqlzRequired', 245 => 'signalDegradeOlm', 246 => 'signalDegradeLine', 247 => 'signalDegradationonLinkVector', + 248 => 'signalDegradeOdu', 249 => 'signalDegradeOtu', 250 => 'pcsSignalDegrade', 251 => 'signalDegradeScn', 252 => 'signalDegradeOduTcmA', 253 => 'signalDegradeOduTcmB', 254 => 'signalDegradeOduTcmC', 255 => 'encryptionModuleSelfTestFail', 256 => 'encryptionModuleSelfTestFailCritical', + 257 => 'signalFailureOnLink', 258 => 'signalFailureonLinkVector', 259 => 'signalFailureOPU', 260 => 'serverSignalFailTx', 261 => 'facilityDataRateNotSupported', 263 => 'lossofSequenceLowerOrderPath', 264 => 'lossofSequenceHigherOrderPath', 265 => 'serverSignalFail', 266 => 'serverSignalFailureGfp', + 267 => 'serverSignalFailureODU', 268 => 'serverSignalFailurePath', 269 => 'serverSignalFailureSectionRS', 272 => 'switchToDuplexInhibited', 274 => 'switchFailed', 276 => 'currentTooHigh', 277 => 'attOnReceiverFiberHigherThanMonitor', 278 => 'attOnReceiverFiberLowerThanMonitor', 279 => 'attOnTransmitterFiberHigherThanMonitor', + 280 => 'attOnTransmitterFiberLowerThanMonitor', 281 => 'thres15MinExceededOduBbe', 283 => 'thres15MinExceededOtuBbe', 285 => 'thres15MinExceededOduTcmABbe', 287 => 'thres15MinExceededOduTcmBBbe', 289 => 'thres15MinExceededOduTcmCBbe', 291 => 'thres15MinExceededFecBERCE', 293 => 'brPwrRxTooHigh', 294 => 'chromaticDispersionTooHigh', + 295 => 'chromaticDispersionTooLow', 296 => 'dispersionCompensationTooHigh', 297 => 'dispersionCompensationTooLow', 298 => 'thres15MinExceededFecCE', 300 => 'carrierFreqOffsetTooHigh', 301 => 'carrierFreqOffsetTooLow', 302 => 'thres15MinExceededSonetLineCV', 304 => 'thres15MinExceededPhysConvCV', + 306 => 'thres15MinExceededSonetSectCV', 308 => 'thres15MinExceededPhysConvDE', 310 => 'differentialGroupDelayTooHigh', 311 => 'thres15MinExceededFecES', 313 => 'thres15MinExceededSonetLineES', 315 => 'thres15MinExceededOduES', 317 => 'thres15MinExceededOtuES', + 319 => 'thres15MinExceededPhysConvES', 321 => 'thres15MinExceededSonetSectES', 323 => 'thres15MinExceededOduTcmAES', 325 => 'thres15MinExceededOduTcmBES', 327 => 'thres15MinExceededOduTcmCES', 329 => 'latencyTooHigh', 330 => 'latencyTooLow', 331 => 'laserBiasCurrentNormalizedtooHigh', 332 => 'localOscTemperatureTooHigh', 333 => 'localOscTemperatureTooLow', + 334 => 'pumpLaser1TempTooHigh', 335 => 'pumpLaser1TempTooLow', 336 => 'pumpLaser2TempTooHigh', 337 => 'pumpLaser2TempTooLow', 338 => 'pumpLaser3TempTooHigh', 339 => 'pumpLaser3TempTooLow', 340 => 'pumpLaser4TempTooHigh', 341 => 'pumpLaser4TempTooLow', 342 => 'oscPwrTooHigh', + 343 => 'oscPwrTooLow', 344 => 'ramanPumpPwrTooHigh', 345 => 'ramanPumpPwrTooLow', 346 => 'roundTripDelayTooHigh', 347 => 'roundTripDelayTooLow', 348 => 'thres15MinExceededSonetSectSEFS', 350 => 'thres15MinExceededFecSES', 352 => 'thres15MinExceededSonetLineSES', + 354 => 'thres15MinExceededOduSES', 356 => 'thres15MinExceededOtuSES', 358 => 'thres15MinExceededSonetSectSES', 360 => 'thres15MinExceededOduTcmASES', 362 => 'thres15MinExceededOduTcmBSES', 364 => 'thres15MinExceededOduTcmCSES', 366 => 'logicalLanesSkewTooHigh', + 367 => 'signalToNoiseRatioTooLow', 368 => 'subModuleTempTooHigh', 369 => 'temperatureTooHigh', 370 => 'temperatureTooLow', 371 => 'thres15MinExceededSonetLineUAS', 373 => 'thres15MinExceededOduUAS', 375 => 'thres15MinExceededOtuUAS', + 377 => 'thres15MinExceededOduTcmAUAS', 379 => 'thres15MinExceededOduTcmBUAS', 381 => 'thres15MinExceededOduTcmCUAS', 383 => 'thres15MinExceededFecUBE', 385 => 'encryptionModuleTamperDetected', 386 => 'thermoElectricCoolerEndOfLife', 387 => 'alarmInputTIF', 389 => 'traceIdentifierMismatchOdu', + 390 => 'traceIdentifierMismatchOtu', 391 => 'sectionTraceMismatch', 392 => 'traceIdentifierMismatchOduTcmA', 393 => 'traceIdentifierMismatchOduTcmB', 394 => 'traceIdentifierMismatchOduTcmC', 395 => 'turnupFailed', 396 => 'turnupCondition', 397 => 'unequippedLowerOrderPath', 398 => 'unequippedHigherOrderPath', 399 => 'voaControlFail', 400 => 'voltageOutOfRange', 401 => 'inputVoltageFailure', 402 => 'inputVoltageFailurePort1', + 403 => 'inputVoltageFailurePort2', 406 => 'wtrTimerRunning', 407 => 'lossOfLaneOtu', 408 => 'lossOfTestSeqSynchOpu', 409 => 'lossOfMfiOpu', 410 => 'oosDisabledLckOduTrmt', 411 => 'configurationMismatch', 412 => 'oduAutoShutdownRxAIS', 413 => 'oduAutoShutdownTxAIS', 414 => 'oosDisabledLckOduRx', 420 => 'thres15MinExceededBbePcs', + 422 => 'autoShutdownGAis', 423 => 'equipmentMismatchAllow', 424 => 'warmUp', 432 => 'networkPathRestricted', 434 => 'vfClientSignalFail', 435 => 'autoShutdownVfCSF', 439 => 'linkFailToPartner1', 440 => 'linkFailToPartner2', 441 => 'linkFailToPartner3', 442 => 'linkFailToPartner4', 443 => 'partnerUnavailable', + 445 => 'partner1Deleted', 446 => 'partner2Deleted', 447 => 'partner3Deleted', 448 => 'partner4Deleted', 450 => 'thres15MinExceededPhysConvSE', 452 => 'thres15MinExceededPhysConvCVDE', 456 => 'autoShutdownSendingOciOduTx', 457 => 'acpLinkLoss', 458 => 'acpChannelUnAvail', 459 => 'acpPartnerUnassigned', 460 => 'acpPartnerDeleted', 461 => 'thres15MinExceededCrcErrorsRcv', 463 => 'thres15MinExceededCrcFramesEgress', + 465 => 'autoServiceMismatch', 466 => 'batteryNoCharge', 469 => 'tagReceiveFail', 470 => 'tagReceiveFailMaxReached', 473 => 'internalEncryptionFail', 13006 => 'cfmRemoteDefectIndication', 13007 => 'cfmCcmMacStatus', 13008 => 'cfmCcmError', 13009 => 'cfmCcmLost', 13010 => 'cfmCcmXConn', 100005 => 'mepNotPresentL2', 100006 => 'priVidNotEqualExtVidL2', 100009 => 'sfCfmLevel0L2', 100010 => 'sfCfmLevel1L2', 100011 => 'sfCfmLevel2L2', + 100012 => 'sfCfmLevel3L2', 100013 => 'sfCfmLevel4L2 ', 100014 => 'sfCfmLevel5L2', 100015 => 'sfCfmLevel6L2', 100016 => 'sfCfmLevel7L2', 120004 => 'messageLossSpeq', 120005 => 'oscFiberMissingSpeq', 120006 => 'optLowSpeq', 120007 => 'ppcOutOfRangeSpeq', 120008 => 'gainTooHighSpeq', 120009 => 'gainTooLowSpeq', 120010 => 'gainAdoptFailedSpeq', 120011 => 'processLockedOutSpeq', 120012 => 'ppcLimitExceededSpeq', +); +my %map_severity = (1 => 'indeterminate', 2 => 'critical', 3 => 'major', 4 => 'minor', 5 => 'warning', 6 => 'cleared', 7 => 'notReported'); + +my $oids = { + alarmSysTable => { + oid => '.1.3.6.1.4.1.2544.1.11.7.4.1', label => 'sys', + mapping => { + severity => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.1.1.2', map => \%map_severity }, + timestamp => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.1.1.4' }, + } + }, + alarmEqptTable => { + oid => '.1.3.6.1.4.1.2544.1.11.7.4.5', label => 'eqpt', + mapping => { + severity => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.5.1.2', map => \%map_severity }, + timestamp => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.5.1.4' }, + } + }, + alarmFacilityTable => { + oid => '.1.3.6.1.4.1.2544.1.11.7.4.7', label => 'facility', + mapping => { + severity => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.7.1.2', map => \%map_severity }, + timestamp => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.7.1.4' }, + } + }, + alarmTerminPointTable => { + oid => '.1.3.6.1.4.1.2544.1.11.7.4.9', label => 'terminpoint', + mapping => { + severity => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.9.1.2', map => \%map_severity }, + timestamp => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.9.1.4' }, + } + }, + alarmExternalPortTable => { + oid => '.1.3.6.1.4.1.2544.1.11.7.4.11', label => 'externalport', + mapping => { + severity => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.11.1.2', map => \%map_severity }, + timestamp => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.11.1.4' }, + } + }, + alarmDcnTable => { + oid => '.1.3.6.1.4.1.2544.1.11.7.4.16', label => 'dcn', + mapping => { + severity => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.16.1.2', map => \%map_severity }, + timestamp => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.16.1.4' }, + } + }, + alarmEnvTable => { + oid => '.1.3.6.1.4.1.2544.1.11.7.4.20', label => 'env', + mapping => { + severity => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.20.1.2', map => \%map_severity }, + timestamp => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.20.1.4' }, + } + }, + alarmContainerTable => { + oid => '.1.3.6.1.4.1.2544.1.11.7.4.24', label => 'container', + mapping => { + severity => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.24.1.2', map => \%map_severity }, + timestamp => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.24.1.4' }, + } + }, + alarmOpticalMuxTable => { + oid => '.1.3.6.1.4.1.2544.1.11.7.4.28', label => 'opticalmux', + mapping => { + severity => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.28.1.2', map => \%map_severity }, + timestamp => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.28.1.4' }, + } + }, + alarmShelfConnTable => { + oid => '.1.3.6.1.4.1.2544.1.11.7.4.34', label => 'shelfconn', + mapping => { + severity => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.32.1.2', map => \%map_severity }, + timestamp => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.32.1.4' }, + } + }, + alarmNtpIPv4Table => { + oid => '.1.3.6.1.4.1.2544.1.11.7.4.36', label => 'ntpipv4', + mapping => { + severity => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.36.1.2', map => \%map_severity }, + timestamp => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.36.1.4' }, + } + }, +}; + +sub manage_selection { + my ($self, %options) = @_; + + my $snmp_result = $options{snmp}->get_table(oid => '.1.3.6.1.4.1.2544.1.12.3.1.4.1.5'); + use Data::Dumper; print Data::Dumper::Dumper($snmp_result); + print unpack('B*', $snmp_result->{'.1.3.6.1.4.1.2544.1.12.3.1.4.1.5.1.1.5'}); + exit(1); + + $self->{alarms}->{global} = { alarm => {} }; + my $get_oids = []; + foreach (keys %$oids) { + push @$get_oids, { oid => $oids->{$_}->{oid} }; + } + my $snmp_result = $options{snmp}->get_multiple_table(oids => $get_oids); + + my $last_time; + if (defined($self->{option_results}->{memory})) { + $self->{statefile_cache}->read(statefile => "cache_adva_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port(). '_' . $self->{mode}); + $last_time = $self->{statefile_cache}->get(name => 'last_time'); + } + + my ($i, $current_time) = (1, time()); + + foreach (keys %$oids) { + my $branch_oid = $oids->{$_}->{oid}; + next if (!defined($snmp_result->{$branch_oid})); + + foreach my $oid (keys %{$snmp_result->{$branch_oid}}) { + next if ($oid !~ /^$oids->{$_}->{mapping}->{severity}->{oid}\.(.*)\.(.*?)$/); + my $instance = $1 . '.' . $2; + my $type = defined($map_type{$2}) ? $map_type{$2} : 'unknown'; + my $result = $options{snmp}->map_instance(mapping => $oids->{$_}->{mapping}, results => $snmp_result->{$branch_oid}, instance => $instance); + + my @date = unpack 'n C6 a C2', $result->{timestamp}; + my $timezone = $self->{option_results}->{timezone}; + if (defined($date[7])) { + $timezone = sprintf("%s%02d%02d", $date[7], $date[8], $date[9]); + } + + my $tz = centreon::plugins::misc::set_timezone(name => $timezone); + my $dt = DateTime->new(year => $date[0], month => $date[1], day => $date[2], hour => $date[3], minute => $date[4], second => $date[5], + %$tz); + + next if (defined($self->{option_results}->{memory}) && defined($last_time) && $last_time > $dt->epoch); + + my $diff_time = $current_time - $dt->epoch; + + $self->{alarms}->{global}->{alarm}->{$i} = { severity => $result->{severity}, + type => $type, since => $diff_time, + generation_time => centreon::plugins::misc::change_seconds(value => $diff_time), + label => $oids->{$_}->{label} + }; + $i++; + } + } + + if (defined($self->{option_results}->{memory})) { + $self->{statefile_cache}->write(data => { last_time => $current_time }); + } +} + +1; + +__END__ + +=head1 MODE + +Check alarms. + +=over 8 + +=item B<--warning-status> + +Set warning threshold for status (Default: '%{severity} =~ /warning|minor/i') +Can used special variables like: %{severity}, %{type}, %{label}, %{since} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{severity} =~ /critical|major/i'). +Can used special variables like: %{severity}, %{type}, %{label}, %{since} + +=item B<--timezone> + +Timezone options (the date from the equipment overload that option). Default is 'GMT'. + +=item B<--memory> + +Only check new alarms. + +=back + +=cut diff --git a/network/adva/fsp150/snmp/mode/interfaces.pm b/network/adva/fsp150/snmp/mode/interfaces.pm new file mode 100644 index 000000000..c5d33d00f --- /dev/null +++ b/network/adva/fsp150/snmp/mode/interfaces.pm @@ -0,0 +1,370 @@ +# +# Copyright 2020 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 network::adva::fsp3000::snmp::mode::interfaces; + +use base qw(snmp_standard::mode::interfaces); + +use strict; +use warnings; + +sub set_oids_traffic { + my ($self, %options) = @_; + + $self->{currentEthRx15minBytes} = '.1.3.6.1.4.1.2544.1.11.2.6.2.52.1.5'; # in B + $self->{currentEthRx1dayBytes} = '.1.3.6.1.4.1.2544.1.11.2.6.2.53.1.5'; # in B + $self->{currentEthTx15minBytes} = '.1.3.6.1.4.1.2544.1.11.2.6.2.56.1.3'; # in B + $self->{currentEthTx1dayBytes} = '.1.3.6.1.4.1.2544.1.11.2.6.2.57.1.3'; # in B + $self->{currentEthRxHighSpeed15minBytes} = '.1.3.6.1.4.1.2544.1.11.2.6.2.88.1.4'; # in B + $self->{currentEthRxHighSpeed1dayBytes} = '.1.3.6.1.4.1.2544.1.11.2.6.2.89.1.4'; # in B +} + +sub set_counters_traffic { + my ($self, %options) = @_; + + push @{$self->{maps_counters}->{int}}, + { label => 'traffic-in', filter => 'add_traffic', nlabel => 'interface.traffic.in.bitspersecond', set => { + key_values => [ { name => 'traffic_in_15min', diff => 1 }, { name => 'traffic_in_1day', diff => 1 }, { name => 'speed_in'}, { name => 'display' } ], + per_second => 1, + closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'in' }, + closure_custom_output => $self->can('custom_traffic_output'), output_error_template => 'Traffic In : %s', + closure_custom_perfdata => $self->can('custom_traffic_perfdata'), + closure_custom_threshold_check => $self->can('custom_traffic_threshold'), + } + }, + { label => 'traffic-out', filter => 'add_traffic', nlabel => 'interface.traffic.out.bitspersecond', set => { + key_values => [ { name => 'traffic_out_15min', diff => 1 }, { name => 'traffic_out_1day', diff => 1 }, { name => 'speed_out'}, { name => 'display' } ], + per_second => 1, + closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'out' }, + closure_custom_output => $self->can('custom_traffic_output'), output_error_template => 'Traffic Out : %s', + closure_custom_perfdata => $self->can('custom_traffic_perfdata'), + closure_custom_threshold_check => $self->can('custom_traffic_threshold'), + } + }, + ; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->SUPER::set_counters(%options); + + push @{$self->{maps_counters}->{int}}, + { label => 'laser-temp', filter => 'add_optical', nlabel => 'interface.laser.temperature.celsius', set => { + key_values => [ { name => 'laser_temp' }, { name => 'display' } ], + output_template => 'Laser Temperature : %.2f C', output_error_template => 'Laser Temperature : %.2f', + perfdatas => [ + { label => 'laser_temp', value => 'laser_temp_absolute', template => '%.2f', + unit => 'C', label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'input-power', filter => 'add_optical', nlabel => 'interface.input.power.dbm', set => { + key_values => [ { name => 'input_power' }, { name => 'display' } ], + output_template => 'Input Power : %s dBm', output_error_template => 'Input Power : %s', + perfdatas => [ + { label => 'input_power', value => 'input_power_absolute', template => '%s', + unit => 'dBm', label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'output-power', filter => 'add_optical', nlabel => 'interface.output.power.dbm', set => { + key_values => [ { name => 'output_power' }, { name => 'display' } ], + output_template => 'Output Power : %s dBm', output_error_template => 'Output Power : %s', + perfdatas => [ + { label => 'output_power', value => 'output_power_absolute', template => '%s', + unit => 'dBm', label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + ; +} + +sub custom_traffic_perfdata { + my ($self, %options) = @_; + + my ($warning, $critical); + if ($self->{instance_mode}->{option_results}->{units_traffic} eq '%' && defined($self->{result_values}->{speed})) { + $warning = $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, total => $self->{result_values}->{speed}, cast_int => 1); + $critical = $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, total => $self->{result_values}->{speed}, cast_int => 1); + } elsif ($self->{instance_mode}->{option_results}->{units_traffic} eq 'b/s') { + $warning = $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}); + $critical = $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}); + } + + $self->{output}->perfdata_add( + label => 'traffic_' . $self->{result_values}->{label}, unit => 'b/s', + nlabel => $self->{nlabel}, + instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef, + value => sprintf("%.2f", $self->{result_values}->{traffic_per_seconds}), + warning => $warning, + critical => $critical, + min => 0, max => $self->{result_values}->{speed} + ); +} + +sub custom_traffic_threshold { + my ($self, %options) = @_; + + my $exit = 'ok'; + if ($self->{instance_mode}->{option_results}->{units_traffic} eq '%' && defined($self->{result_values}->{speed})) { + $exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{traffic_prct}, threshold => [ { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' } ]); + } elsif ($self->{instance_mode}->{option_results}->{units_traffic} eq 'b/s') { + $exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{traffic_per_seconds}, threshold => [ { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' } ]); + } + return $exit; +} + +sub custom_traffic_output { + my ($self, %options) = @_; + + my $label = $self->{result_values}->{label}; + $label =~ s/_/ /g; + $label =~ s/(\w+)/\u$1/g; + my ($traffic_value, $traffic_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{traffic_per_seconds}, network => 1); + my $msg = sprintf("Traffic %s : %s/s (%s)", + $label, $traffic_value . $traffic_unit, + defined($self->{result_values}->{traffic_prct}) ? sprintf("%.2f%%", $self->{result_values}->{traffic_prct}) : '-'); + return $msg; +} + +sub custom_traffic_calc { + my ($self, %options) = @_; + + return -10 if (defined($self->{instance_mode}->{last_status}) && $self->{instance_mode}->{last_status} == 0); + + # we choose the performance value (1day is updated every 15 minutes. 15min is updated all the time but reset every 15min + my $counter = 'traffic_' . $options{extra_options}->{label_ref} . '_15min'; + if ($options{delta_time} >= 600) { + $counter = 'traffic_' . $options{extra_options}->{label_ref} . '_1day'; + } + + my $diff_traffic = ($options{new_datas}->{$self->{instance} . '_' . $counter} - $options{old_datas}->{$self->{instance} . '_' . $counter}); + + $self->{result_values}->{traffic_per_seconds} = $diff_traffic / $options{delta_time}; + if (defined($options{new_datas}->{$self->{instance} . '_speed_' . $options{extra_options}->{label_ref}}) && + $options{new_datas}->{$self->{instance} . '_speed_' . $options{extra_options}->{label_ref}} > 0) { + $self->{result_values}->{traffic_prct} = $self->{result_values}->{traffic_per_seconds} * 100 / $options{new_datas}->{$self->{instance} . '_speed_' . $options{extra_options}->{label_ref}}; + $self->{result_values}->{speed} = $options{new_datas}->{$self->{instance} . '_speed_' . $options{extra_options}->{label_ref}}; + } + + $self->{result_values}->{label} = $options{extra_options}->{label_ref}; + $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; + return 0; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_set_traffic => 1, no_errors => 1, no_cast => 1); + bless $self, $class; + + $options{options}->add_options(arguments => { + 'add-optical' => { name => 'add_optical' }, + } + ); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->{checking} = ''; + foreach (('add_global', 'add_status', 'add_traffic', 'add_speed', 'add_volume', 'add_optical')) { + if (defined($self->{option_results}->{$_})) { + $self->{checking} .= $_; + } + } +} + +my $oid_opticalIfDiagLaserTemp = '.1.3.6.1.4.1.2544.1.11.2.4.3.5.1.2'; +my $oid_opticalIfDiagInputPower = '.1.3.6.1.4.1.2544.1.11.2.4.3.5.1.3'; +my $oid_opticalIfDiagOutputPower = '.1.3.6.1.4.1.2544.1.11.2.4.3.5.1.4'; + +sub custom_load { + my ($self, %options) = @_; + + return if (!defined($self->{option_results}->{add_optical})); + + $self->{snmp}->load(oids => [$oid_opticalIfDiagLaserTemp, $oid_opticalIfDiagInputPower, $oid_opticalIfDiagOutputPower], + instances => $self->{array_interface_selected}); +} + +sub custom_add_result { + my ($self, %options) = @_; + + return if (!defined($self->{option_results}->{add_optical})); + $self->{int}->{$options{instance}}->{laser_temp} = undef; + if (defined($self->{results}->{$oid_opticalIfDiagLaserTemp . '.' . $options{instance}}) && + $self->{results}->{$oid_opticalIfDiagLaserTemp . '.' . $options{instance}} != -2147483648) { + $self->{int}->{$options{instance}}->{laser_temp} = $self->{results}->{$oid_opticalIfDiagLaserTemp . '.' . $options{instance}} * 0.1; + } + + $self->{int}->{$options{instance}}->{input_power} = undef; + if (defined($self->{results}->{$oid_opticalIfDiagInputPower . '.' . $options{instance}}) && + $self->{results}->{$oid_opticalIfDiagInputPower . '.' . $options{instance}} != -65535) { + $self->{int}->{$options{instance}}->{input_power} = $self->{results}->{$oid_opticalIfDiagInputPower . '.' . $options{instance}} / 10; + } + + $self->{int}->{$options{instance}}->{output_power} = undef; + if (defined($self->{results}->{$oid_opticalIfDiagOutputPower . '.' . $options{instance}}) && + $self->{results}->{$oid_opticalIfDiagOutputPower . '.' . $options{instance}} != -65535) { + $self->{int}->{$options{instance}}->{output_power} = $self->{results}->{$oid_opticalIfDiagOutputPower . '.' . $options{instance}} / 10; + } +} + +sub load_traffic { + my ($self, %options) = @_; + + if ($self->{snmp}->is_snmpv1()) { + $self->{output}->add_option_msg(short_msg => "Can't check SNMP 64 bits counters with SNMPv1."); + $self->{output}->option_exit(); + } + + $self->set_oids_traffic(); + $self->{snmp}->load(oids => [$self->{currentEthRx15minBytes}, $self->{currentEthRx1dayBytes}, + $self->{currentEthTx15minBytes}, $self->{currentEthTx1dayBytes}, + $self->{currentEthRxHighSpeed15minBytes}, $self->{currentEthRxHighSpeed1dayBytes}], instances => $self->{array_interface_selected}); +} + +sub add_result_traffic { + my ($self, %options) = @_; + + $self->{int}->{$options{instance}}->{traffic_in_15min} = + defined($self->{results}->{$self->{currentEthRxHighSpeed15minBytes} . '.' . $options{instance}}) ? $self->{results}->{$self->{currentEthRxHighSpeed15minBytes} . '.' . $options{instance}} * 8 : + (defined($self->{results}->{$self->{currentEthRx15minBytes} . '.' . $options{instance}}) ? $self->{results}->{$self->{currentEthRx15minBytes} . '.' . $options{instance}} * 8 : undef); + $self->{int}->{$options{instance}}->{traffic_in_1day} = + defined($self->{results}->{$self->{currentEthRxHighSpeed1dayBytes} . '.' . $options{instance}}) ? $self->{results}->{$self->{currentEthRxHighSpeed1dayBytes} . '.' . $options{instance}} * 8 : + (defined($self->{results}->{$self->{currentEthRx1dayBytes} . '.' . $options{instance}}) ? $self->{results}->{$self->{currentEthRx1dayBytes} . '.' . $options{instance}} * 8 : undef); + $self->{int}->{$options{instance}}->{traffic_out_15min} = + defined($self->{results}->{$self->{currentEthTx15minBytes} . '.' . $options{instance}}) ? $self->{results}->{$self->{currentEthTx15minBytes} . '.' . $options{instance}} * 8 : undef; + $self->{int}->{$options{instance}}->{traffic_out_1day} = + defined($self->{results}->{$self->{currentEthTx1dayBytes} . '.' . $options{instance}}) ? $self->{results}->{$self->{currentEthTx1dayBytes} . '.' . $options{instance}} * 8 : undef; + + $self->{int}->{$options{instance}}->{speed_in} = 0; + $self->{int}->{$options{instance}}->{speed_out} = 0; + if ($self->{get_speed} == 0) { + if (defined($self->{option_results}->{speed}) && $self->{option_results}->{speed} ne '') { + $self->{int}->{$options{instance}}->{speed_in} = $self->{option_results}->{speed} * 1000000; + $self->{int}->{$options{instance}}->{speed_out} = $self->{option_results}->{speed} * 1000000; + } + $self->{int}->{$options{instance}}->{speed_in} = $self->{option_results}->{speed_in} * 1000000 if (defined($self->{option_results}->{speed_in}) && $self->{option_results}->{speed_in} ne ''); + $self->{int}->{$options{instance}}->{speed_out} = $self->{option_results}->{speed_out} * 1000000 if (defined($self->{option_results}->{speed_out}) && $self->{option_results}->{speed_out} ne ''); + } +} + +1; + +__END__ + +=head1 MODE + +Check interfaces. + +=over 8 + +=item B<--add-status> + +Check interface status. + +=item B<--add-traffic> + +Check interface traffic. + +=item B<--add-optical> + +Check interface optical. + +=item B<--warning-status> + +Set warning threshold for status. +Can used special variables like: %{admstatus}, %{opstatus}, %{display} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{admstatus} eq "up" and %{opstatus} ne "up"'). +Can used special variables like: %{admstatus}, %{opstatus}, %{display} + +=item B<--warning-*> + +Threshold warning. +Can be: 'laser-temp', 'input-power', 'output-power', 'traffic-in', 'traffic-out'. + +=item B<--critical-*> + +Threshold critical. +Can be: 'laser-temp', 'input-power', 'output-power', 'traffic-in', 'traffic-out'. + +=item B<--units-traffic> + +Units of thresholds for the traffic (Default: '%') ('%', 'b/s'). + +=item B<--interface> + +Set the interface (number expected) ex: 1,2,... (empty means 'check all interface'). + +=item B<--name> + +Allows to use interface name with option --interface instead of interface oid index (Can be a regexp) + +=item B<--speed> + +Set interface speed for incoming/outgoing traffic (in Mb). + +=item B<--speed-in> + +Set interface speed for incoming traffic (in Mb). + +=item B<--speed-out> + +Set interface speed for outgoing traffic (in Mb). + +=item B<--reload-cache-time> + +Time in minutes before reloading cache file (default: 180). + +=item B<--oid-filter> + +Choose OID used to filter interface (default: ifName) (values: ifDesc, ifAlias, ifName). + +=item B<--oid-display> + +Choose OID used to display interface (default: ifName) (values: ifDesc, ifAlias, ifName). + +=item B<--oid-extra-display> + +Add an OID to display. + +=item B<--display-transform-src> + +Regexp src to transform display value. + +=item B<--display-transform-dst> + +Regexp dst to transform display value. + +=item B<--show-cache> + +Display cache interface datas. + +=back + +=cut diff --git a/network/adva/fsp150/snmp/mode/listinterfaces.pm b/network/adva/fsp150/snmp/mode/listinterfaces.pm new file mode 100644 index 000000000..167bfa0bc --- /dev/null +++ b/network/adva/fsp150/snmp/mode/listinterfaces.pm @@ -0,0 +1,160 @@ +# +# Copyright 2020 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 network::adva::fsp3000::snmp::mode::listinterfaces; + +use base qw(snmp_standard::mode::listinterfaces); + +use strict; +use warnings; + +my $mapping = { + advaInventoryAidString => { oid => '.1.3.6.1.4.1.2544.1.11.7.10.1.1.6' }, + advaInventoryUnitName => { oid => '.1.3.6.1.4.1.2544.1.11.7.10.1.1.7' }, +}; + +sub set_oids_label { + my ($self, %options) = @_; + + $self->{oids_label} = { + 'ifdesc' => '.1.3.6.1.2.1.2.2.1.2', + 'ifalias' => '.1.3.6.1.2.1.31.1.1.1.18', + }; +} + +sub default_oid_filter_name { + my ($self, %options) = @_; + + return 'ifdesc'; +} + +sub default_oid_display_name { + my ($self, %options) = @_; + + return 'ifdesc'; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + $self->SUPER::manage_selection(%options); + + my $oid_advaInventoryEntry = '.1.3.6.1.4.1.2544.1.11.7.10.1.1'; + my $snmp_result = $self->{snmp}->get_table( + oid => $oid_advaInventoryEntry, + begin => $mapping->{advaInventoryAidString}->{oid}, + end => $mapping->{advaInventoryUnitName}->{oid} + ); + + $self->{extra_oids}->{type} = { oid => $mapping->{advaInventoryUnitName}->{oid}, matching => '%{instance}$' }; + $self->{results}->{ $self->{extra_oids}->{type} } = {}; + foreach my $oid (keys %{$snmp_result}) { + next if ($oid !~ /^$mapping->{advaInventoryUnitName}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance); + + next if ($result->{advaInventoryUnitName} !~ /^(SFP|XFP)/i); + + # interface name example: CH-1-3-N1 + # inventory name example: PL-1-3-N1 + next if ($result->{advaInventoryAidString} !~ /(\d+-\d+-[^\-]+)$/); + my $lookup = $1; + + foreach (sort @{$self->{interface_id_selected}}) { + my $display_value = $self->get_display_value(id => $_); + + if ($display_value =~ /CH-$lookup$/) { + $self->{results}->{ $self->{extra_oids}->{type}->{oid} }->{ $self->{extra_oids}->{type}->{oid} . '.' . $_ } = $result->{advaInventoryUnitName}; + } + } + } +} + +sub disco_format { + my ($self, %options) = @_; + + $self->{extra_oids}->{type} = { oid => $mapping->{advaInventoryUnitName}->{oid}, matching => '%{instance}$' }; + $self->SUPER::disco_format(%options); +} + +1; + +__END__ + +=head1 MODE + +=over 8 + +=item B<--interface> + +Set the interface (number expected) ex: 1,2,... (empty means 'check all interface'). + +=item B<--name> + +Allows to use interface name with option --interface instead of interface oid index (Can be a regexp) + +=item B<--speed> + +Set interface speed (in Mb). + +=item B<--skip-speed0> + +Don't display interface with speed 0. + +=item B<--filter-status> + +Display interfaces matching the filter (example: 'up'). + +=item B<--use-adminstatus> + +Display interfaces with AdminStatus 'up'. + +=item B<--oid-filter> + +Choose OID used to filter interface (default: ifDesc) (values: ifDesc, ifAlias). + +=item B<--oid-display> + +Choose OID used to display interface (default: ifDesc) (values: ifDesc, ifAlias). + +=item B<--display-transform-src> + +Regexp src to transform display value. (security risk!!!) + +=item B<--display-transform-dst> + +Regexp dst to transform display value. (security risk!!!) + +=item B<--add-extra-oid> + +Display an OID. +Example: --add-extra-oid='alias,.1.3.6.1.2.1.31.1.1.1.18' +or --add-extra-oid='vlan,.1.3.6.1.2.1.31.19,%{instance}\..*' + +=back + +=cut diff --git a/network/adva/fsp150/snmp/plugin.pm b/network/adva/fsp150/snmp/plugin.pm new file mode 100644 index 000000000..b4409a7e3 --- /dev/null +++ b/network/adva/fsp150/snmp/plugin.pm @@ -0,0 +1,52 @@ +# +# Copyright 2020 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 network::adva::fsp150::snmp::plugin; + +use strict; +use warnings; +use base qw(centreon::plugins::script_snmp); + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.0'; + %{$self->{modes}} = ( + 'alarms' => 'network::adva::fsp150::snmp::mode::alarms', + 'interfaces' => 'network::adva::fsp3000::snmp::mode::interfaces', + 'list-interfaces' => 'network::adva::fsp3000::snmp::mode::listinterfaces', + 'memory' => 'snmp_standard::mode::memory', + 'uptime' => 'snmp_standard::mode::uptime' + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Adva fsp3000 equipments in SNMP. + +=cut diff --git a/network/paloalto/ssh/mode/ipsec.pm b/network/paloalto/ssh/mode/ipsec.pm index 348ffc118..a11e89aea 100644 --- a/network/paloalto/ssh/mode/ipsec.pm +++ b/network/paloalto/ssh/mode/ipsec.pm @@ -110,7 +110,7 @@ sub manage_selection { $self->{global} = { total_ipsec => 0 }; $self->{tunnels} = {}; - foreach (@{$result->{tunnels}}) { + foreach (@{$result->{entry}}) { $self->{tunnels}->{$_->{gwid}} = { display => $_->{name}, ike_phase1_state => defined($_->{created}) && $_->{created} ne '' ? 'up' : 'down', From a90e82c57d2b3dea497941e409e362e18dbde32d Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 23 Apr 2020 17:15:32 +0200 Subject: [PATCH 137/283] patch ipsec palo alto ssh --- network/paloalto/ssh/mode/ipsec.pm | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/network/paloalto/ssh/mode/ipsec.pm b/network/paloalto/ssh/mode/ipsec.pm index a11e89aea..f1d752066 100644 --- a/network/paloalto/ssh/mode/ipsec.pm +++ b/network/paloalto/ssh/mode/ipsec.pm @@ -121,10 +121,21 @@ sub manage_selection { $self->{global}->{total_ipsec}++; } + $result = $options{custom}->execute_command(command => 'show vpn ipsec-sa', ForceArray => ['entry']); + foreach (@{$result->{entries}->{entry}}) { + if (defined($self->{tunnels}->{$_->{gwid}})) { + $self->{tunnels}->{$_->{gwid}}->{tid} = $_->{tid}; + } + } + $result = $options{custom}->execute_command(command => 'show vpn flow', ForceArray => ['entry']); - foreach (@{$result->{IPSec}->{entry}}) { - $self->{tunnels}->{$_->{gwid}}->{state} = $_->{state}; - $self->{tunnels}->{$_->{gwid}}->{monitor_status} = $_->{mon}; + foreach my $gwid (keys %{$self->{tunnels}}) { + next if (!defined($self->{tunnels}->{$gwid}->{tid})); + foreach (@{$result->{IPSec}->{entry}}) { + next if ($self->{tunnels}->{$gwid}->{tid} ne $_->{id}); + $self->{tunnels}->{$_->{gwid}}->{state} = $_->{state}; + $self->{tunnels}->{$_->{gwid}}->{monitor_status} = $_->{mon}; + } } } From f161136ae14cbe4ffdfb9294d5518791803d7fbf Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 23 Apr 2020 18:05:45 +0200 Subject: [PATCH 138/283] Fix #1958 --- snmp_standard/mode/diskusage.pm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/snmp_standard/mode/diskusage.pm b/snmp_standard/mode/diskusage.pm index 8365d7f40..b51652272 100644 --- a/snmp_standard/mode/diskusage.pm +++ b/snmp_standard/mode/diskusage.pm @@ -122,7 +122,8 @@ sub new { 'display-transform-src:s' => { name => 'display_transform_src' }, 'display-transform-dst:s' => { name => 'display_transform_dst' }, 'show-cache' => { name => 'show_cache' }, - 'space-reservation:s' => { name => 'space_reservation' } + 'space-reservation:s' => { name => 'space_reservation' }, + 'force-use-mib-percent' => { name => 'force_use_mib_percent' } }); $self->{diskpath_id_selected} = []; @@ -156,6 +157,7 @@ sub check_options { my $mapping = { dskTotal32 => { oid => '.1.3.6.1.4.1.2021.9.1.6' }, # kB dskUsed32 => { oid => '.1.3.6.1.4.1.2021.9.1.8' }, # kB + dskPercent => { oid => '.1.3.6.1.4.1.2021.9.1.9' }, dskPercentNode => { oid => '.1.3.6.1.4.1.2021.9.1.10' }, dskTotalLow => { oid => '.1.3.6.1.4.1.2021.9.1.11' }, # kB dskTotalHigh => { oid => '.1.3.6.1.4.1.2021.9.1.12' }, # kB @@ -213,6 +215,7 @@ sub manage_selection { $prct_free = 0; } + $prct_used = $result->{dskPercent} if (defined($self->{option_results}->{force_use_mib_percent})); $self->{diskpath}->{$name_diskpath} = { display => $name_diskpath, total => $total_size, @@ -372,6 +375,10 @@ Display cache disk path datas. Some filesystem has space reserved (like ext4 for root). The value is in percent of total (Default: none) (results like 'df' command). +=item B<--force-use-mib-percent> + +Can be used if you have counters overload by big disks. + =back =cut From 0c9e33a8933eb575bb55432cd44daccd096617a8 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 23 Apr 2020 19:34:11 +0200 Subject: [PATCH 139/283] Fix #1959 --- .../juniper/common/junos/mode/interfaces.pm | 40 +++++++++---------- snmp_standard/mode/interfaces.pm | 4 +- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/network/juniper/common/junos/mode/interfaces.pm b/network/juniper/common/junos/mode/interfaces.pm index d05fad196..c2452c840 100644 --- a/network/juniper/common/junos/mode/interfaces.pm +++ b/network/juniper/common/junos/mode/interfaces.pm @@ -32,7 +32,7 @@ sub set_oids_errors { $self->{oid_ifInErrors} = '.1.3.6.1.2.1.2.2.1.14'; $self->{oid_ifOutDiscards} = '.1.3.6.1.2.1.2.2.1.19'; $self->{oid_ifOutErrors} = '.1.3.6.1.2.1.2.2.1.20'; - $self->{oid_dot3StatsFCSErrors} = '.1.3.6.1.2.1.10.7.2.1.3'; + $self->{oid_ifInFCSError} = '.1.3.6.1.2.1.10.7.2.1.3'; # dot3StatsFCSErrors } sub set_counters { @@ -41,15 +41,15 @@ sub set_counters { $self->SUPER::set_counters(%options); push @{$self->{maps_counters}->{int}}, - { label => 'fcs-errors', filter => 'add_errors', nlabel => 'interface.fcs.errors.count', set => { - key_values => [ { name => 'fcserror', diff => 1 }, { name => 'display' } ], - output_template => 'FCS Errors : %d', - perfdatas => [ - { value => 'fcserror_absolute', template => '%d', - label_extra_instance => 1, instance_use => 'display_absolute' }, - ], + { label => 'fcs-errors', filter => 'add_errors', nlabel => 'interface.packets.in.fcs.errors.count', set => { + key_values => [ { name => 'infcserror', diff => 1 }, { name => 'total_in_packets', diff => 1 }, { name => 'display' }, { name => 'mode_cast' } ], + closure_custom_calc => $self->can('custom_errors_calc'), + closure_custom_calc_extra_options => { label_ref1 => 'in', label_ref2 => 'fcserror' }, + closure_custom_output => $self->can('custom_errors_output'), output_error_template => 'Packets In FCS Error : %s', + closure_custom_perfdata => $self->can('custom_errors_perfdata'), + closure_custom_threshold_check => $self->can('custom_errors_threshold') } - }, + } ; push @{$self->{maps_counters}->{int}}, @@ -58,17 +58,17 @@ sub set_counters { output_template => 'Input Power : %s dBm', perfdatas => [ { value => 'input_power_absolute', template => '%s', - unit => 'dBm', label_extra_instance => 1, instance_use => 'display_absolute' }, - ], + unit => 'dBm', label_extra_instance => 1, instance_use => 'display_absolute' } + ] } }, { label => 'bias-current', filter => 'add_optical', nlabel => 'interface.bias.current.milliampere', set => { key_values => [ { name => 'bias_current' }, { name => 'display' } ], output_template => 'Bias Current : %s mA', perfdatas => [ - { value => 'bias_current_absolute', template => '%s', + { value => 'bias_current_absolute', template => '%s' unit => 'mA', label_extra_instance => 1, instance_use => 'display_absolute' }, - ], + ] } }, { label => 'output-power', filter => 'add_optical', nlabel => 'interface.output.power.dbm', set => { @@ -76,8 +76,8 @@ sub set_counters { output_template => 'Output Power : %s dBm', perfdatas => [ { value => 'output_power_absolute', template => '%s', - unit => 'dBm', label_extra_instance => 1, instance_use => 'display_absolute' }, - ], + unit => 'dBm', label_extra_instance => 1, instance_use => 'display_absolute' } + ] } }, { label => 'module-temperature', filter => 'add_optical', nlabel => 'interface.module.temperature.celsius', set => { @@ -85,10 +85,10 @@ sub set_counters { output_template => 'Module Temperature : %.2f C', perfdatas => [ { value => 'module_temperature_absolute', template => '%.2f', - unit => 'C', label_extra_instance => 1, instance_use => 'display_absolute' }, - ], + unit => 'C', label_extra_instance => 1, instance_use => 'display_absolute' } + ] } - }, + } ; } @@ -127,7 +127,7 @@ sub load_errors { $self->{oid_ifInErrors}, $self->{oid_ifOutDiscards}, $self->{oid_ifOutErrors}, - $self->{oid_dot3StatsFCSErrors} + $self->{oid_ifInFCSError} ], instances => $self->{array_interface_selected} ); @@ -140,7 +140,7 @@ sub add_result_errors { $self->{int}->{$options{instance}}->{inerror} = $self->{results}->{$self->{oid_ifInErrors} . '.' . $options{instance}}; $self->{int}->{$options{instance}}->{outdiscard} = $self->{results}->{$self->{oid_ifOutDiscards} . '.' . $options{instance}}; $self->{int}->{$options{instance}}->{outerror} = $self->{results}->{$self->{oid_ifOutErrors} . '.' . $options{instance}}; - $self->{int}->{$options{instance}}->{fcserror} = $self->{results}->{$self->{oid_dot3StatsFCSErrors} . '.' . $options{instance}}; + $self->{int}->{$options{instance}}->{infcserror} = $self->{results}->{$self->{oid_ifInFCSError} . '.' . $options{instance}}; } my $oid_jnxDomCurrentRxLaserPower = '.1.3.6.1.4.1.2636.3.60.1.1.1.1.5'; diff --git a/snmp_standard/mode/interfaces.pm b/snmp_standard/mode/interfaces.pm index e31c986b1..7b9054b4d 100644 --- a/snmp_standard/mode/interfaces.pm +++ b/snmp_standard/mode/interfaces.pm @@ -200,9 +200,11 @@ sub custom_errors_perfdata { my ($self, %options) = @_; if ($self->{instance_mode}->{option_results}->{units_errors} eq '%') { + my $nlabel = $self->{nlabel}; + $nlabel =~ s/count/percentage/; $self->{output}->perfdata_add( label => 'packets_' . $self->{result_values}->{label2} . '_' . $self->{result_values}->{label1}, unit => '%', - nlabel => 'interface.packets.' . $self->{result_values}->{label1} . '.' . $self->{result_values}->{label2} . '.percentage', + nlabel => $nlabel, instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef, value => sprintf("%.2f", $self->{result_values}->{prct}), warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}), From 16ae24e0fe1afffdd5261daff38aaed983d0eb33 Mon Sep 17 00:00:00 2001 From: UrBnW <40244829+UrBnW@users.noreply.github.com> Date: Thu, 23 Apr 2020 20:11:37 +0200 Subject: [PATCH 140/283] Typos --- network/juniper/common/junos/mode/interfaces.pm | 10 +++++----- snmp_standard/mode/interfaces.pm | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/network/juniper/common/junos/mode/interfaces.pm b/network/juniper/common/junos/mode/interfaces.pm index c2452c840..30e027430 100644 --- a/network/juniper/common/junos/mode/interfaces.pm +++ b/network/juniper/common/junos/mode/interfaces.pm @@ -41,7 +41,7 @@ sub set_counters { $self->SUPER::set_counters(%options); push @{$self->{maps_counters}->{int}}, - { label => 'fcs-errors', filter => 'add_errors', nlabel => 'interface.packets.in.fcs.errors.count', set => { + { label => 'in-fcserror', filter => 'add_errors', nlabel => 'interface.packets.in.fcserror.count', set => { key_values => [ { name => 'infcserror', diff => 1 }, { name => 'total_in_packets', diff => 1 }, { name => 'display' }, { name => 'mode_cast' } ], closure_custom_calc => $self->can('custom_errors_calc'), closure_custom_calc_extra_options => { label_ref1 => 'in', label_ref2 => 'fcserror' }, @@ -66,7 +66,7 @@ sub set_counters { key_values => [ { name => 'bias_current' }, { name => 'display' } ], output_template => 'Bias Current : %s mA', perfdatas => [ - { value => 'bias_current_absolute', template => '%s' + { value => 'bias_current_absolute', template => '%s', unit => 'mA', label_extra_instance => 1, instance_use => 'display_absolute' }, ] } @@ -259,7 +259,7 @@ Set critical threshold for all error counters. Threshold warning (will superseed --warning-errors). Can be: 'total-port', 'total-admin-up', 'total-admin-down', 'total-oper-up', 'total-oper-down', -'in-traffic', 'out-traffic', 'in-error', 'in-discard', 'out-error', 'out-discard', 'fcs-errors', +'in-traffic', 'out-traffic', 'in-error', 'in-discard', 'out-error', 'out-discard', 'in-ucast' (%), 'in-bcast' (%), 'in-mcast' (%), 'out-ucast' (%), 'out-bcast' (%), 'out-mcast' (%), 'speed' (b/s). @@ -269,11 +269,11 @@ And also: 'fcs-errors (%)', 'input-power' (dBm), 'bias-current' (mA), 'output-po Threshold critical (will superseed --warning-errors). Can be: 'total-port', 'total-admin-up', 'total-admin-down', 'total-oper-up', 'total-oper-down', -'in-traffic', 'out-traffic', 'in-error', 'in-discard', 'out-error', 'out-discard', 'fcs-errors', +'in-traffic', 'out-traffic', 'in-error', 'in-discard', 'out-error', 'out-discard', 'in-ucast' (%), 'in-bcast' (%), 'in-mcast' (%), 'out-ucast' (%), 'out-bcast' (%), 'out-mcast' (%), 'speed' (b/s). -And also: 'fcs-errors (%)', 'input-power' (dBm), 'bias-current' (mA), 'output-power' (dBm), 'module-temperature' (C). +And also: 'in-fcserror' (%), 'input-power' (dBm), 'bias-current' (mA), 'output-power' (dBm), 'module-temperature' (C). =item B<--units-traffic> diff --git a/snmp_standard/mode/interfaces.pm b/snmp_standard/mode/interfaces.pm index 7b9054b4d..ff1a38bfa 100644 --- a/snmp_standard/mode/interfaces.pm +++ b/snmp_standard/mode/interfaces.pm @@ -201,7 +201,7 @@ sub custom_errors_perfdata { if ($self->{instance_mode}->{option_results}->{units_errors} eq '%') { my $nlabel = $self->{nlabel}; - $nlabel =~ s/count/percentage/; + $nlabel =~ s/count$/percentage/; $self->{output}->perfdata_add( label => 'packets_' . $self->{result_values}->{label2} . '_' . $self->{result_values}->{label1}, unit => '%', nlabel => $nlabel, @@ -395,7 +395,7 @@ sub set_counters_errors { return if ($self->{no_errors} != 0 && $self->{no_set_errors} != 0); push @{$self->{maps_counters}->{int}}, - { label => 'in-discard', filter => 'add_errors', nlabel => 'interface.packets.in.discards.count', set => { + { label => 'in-discard', filter => 'add_errors', nlabel => 'interface.packets.in.discard.count', set => { key_values => [ { name => 'indiscard', diff => 1 }, { name => 'total_in_packets', diff => 1 }, { name => 'display' }, { name => 'mode_cast' } ], closure_custom_calc => $self->can('custom_errors_calc'), closure_custom_calc_extra_options => { label_ref1 => 'in', label_ref2 => 'discard' }, closure_custom_output => $self->can('custom_errors_output'), output_error_template => 'Packets In Discard : %s', @@ -403,7 +403,7 @@ sub set_counters_errors { closure_custom_threshold_check => $self->can('custom_errors_threshold') } }, - { label => 'in-error', filter => 'add_errors', nlabel => 'interface.packets.in.errors.count', set => { + { label => 'in-error', filter => 'add_errors', nlabel => 'interface.packets.in.error.count', set => { key_values => [ { name => 'inerror', diff => 1 }, { name => 'total_in_packets', diff => 1 }, { name => 'display' }, { name => 'mode_cast' } ], closure_custom_calc => $self->can('custom_errors_calc'), closure_custom_calc_extra_options => { label_ref1 => 'in', label_ref2 => 'error' }, closure_custom_output => $self->can('custom_errors_output'), output_error_template => 'Packets In Error : %s', @@ -411,7 +411,7 @@ sub set_counters_errors { closure_custom_threshold_check => $self->can('custom_errors_threshold') } }, - { label => 'out-discard', filter => 'add_errors', nlabel => 'interface.packets.out.discards.count', set => { + { label => 'out-discard', filter => 'add_errors', nlabel => 'interface.packets.out.discard.count', set => { key_values => [ { name => 'outdiscard', diff => 1 }, { name => 'total_out_packets', diff => 1 }, { name => 'display' }, { name => 'mode_cast' } ], closure_custom_calc => $self->can('custom_errors_calc'), closure_custom_calc_extra_options => { label_ref1 => 'out', label_ref2 => 'discard' }, closure_custom_output => $self->can('custom_errors_output'), output_error_template => 'Packets Out Discard : %s', @@ -419,7 +419,7 @@ sub set_counters_errors { closure_custom_threshold_check => $self->can('custom_errors_threshold') } }, - { label => 'out-error', filter => 'add_errors', nlabel => 'interface.packets.out.errors.count', set => { + { label => 'out-error', filter => 'add_errors', nlabel => 'interface.packets.out.error.count', set => { key_values => [ { name => 'outerror', diff => 1 }, { name => 'total_out_packets', diff => 1 }, { name => 'display' }, { name => 'mode_cast' } ], closure_custom_calc => $self->can('custom_errors_calc'), closure_custom_calc_extra_options => { label_ref1 => 'out', label_ref2 => 'error' }, closure_custom_output => $self->can('custom_errors_output'), output_error_template => 'Packets Out Error : %s', From e72fafa8e3b681c54760241ce4c962aeb0836c67 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 24 Apr 2020 11:18:13 +0200 Subject: [PATCH 141/283] update http response --- apps/protocols/http/mode/response.pm | 171 +++++++++++++++------------ 1 file changed, 93 insertions(+), 78 deletions(-) diff --git a/apps/protocols/http/mode/response.pm b/apps/protocols/http/mode/response.pm index 0423ac4c1..34505851c 100644 --- a/apps/protocols/http/mode/response.pm +++ b/apps/protocols/http/mode/response.pm @@ -20,115 +20,130 @@ package apps::protocols::http::mode::response; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::counter); use strict; use warnings; +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); use Time::HiRes qw(gettimeofday tv_interval); use centreon::plugins::http; +sub custom_status_output { + my ($self, %options) = @_; + + return $self->{result_values}->{http_code} . ' ' . $self->{result_values}->{message}; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0 } + ]; + + $self->{maps_counters}->{global} = [ + { label => 'status', threshold => 0, display_ok => 0, set => { + key_values => [ + { name => 'http_code' }, { name => 'message' } + ], + closure_custom_calc => \&catalog_status_calc, + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold + } + }, + { label => 'time', nlabel => 'http.response.time.seconds', set => { + key_values => [ { name => 'time' } ], + output_template => 'Response time %.3fs', + perfdatas => [ + { label => 'time', value => 'time_absolute', template => '%.3f', min => 0, unit => 's' } + ] + } + }, + { label => 'size', nlabel => 'http.response.size.count', display_ok => 0, set => { + key_values => [ { name => 'size' } ], + output_template => 'Content size : %s', + perfdatas => [ + { label => 'size', value => 'size_absolute', template => '%s', min => 0, unit => 'B' } + ] + } + } + ]; +} + sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; $options{options}->add_options(arguments => { - "hostname:s" => { name => 'hostname' }, - "port:s" => { name => 'port', }, - "method:s" => { name => 'method' }, - "proto:s" => { name => 'proto' }, - "urlpath:s" => { name => 'url_path' }, - "credentials" => { name => 'credentials' }, - "basic" => { name => 'basic' }, - "ntlmv2" => { name => 'ntlmv2' }, - "username:s" => { name => 'username' }, - "password:s" => { name => 'password' }, - "timeout:s" => { name => 'timeout' }, - "no-follow" => { name => 'no_follow', }, - "cert-file:s" => { name => 'cert_file' }, - "key-file:s" => { name => 'key_file' }, - "cacert-file:s" => { name => 'cacert_file' }, - "cert-pwd:s" => { name => 'cert_pwd' }, - "cert-pkcs12" => { name => 'cert_pkcs12' }, - "header:s@" => { name => 'header' }, - "get-param:s@" => { name => 'get_param' }, - "post-param:s@" => { name => 'post_param' }, - "cookies-file:s" => { name => 'cookies_file' }, - "unknown-status:s" => { name => 'unknown_status', default => '' }, - "warning-status:s" => { name => 'warning_status' }, - "critical-status:s" => { name => 'critical_status', default => '%{http_code} < 200 or %{http_code} >= 300' }, - "warning:s" => { name => 'warning' }, - "critical:s" => { name => 'critical' }, - "warning-size:s" => { name => 'warning_size' }, - "critical-size:s" => { name => 'critical_size' }, + 'hostname:s' => { name => 'hostname' }, + 'port:s' => { name => 'port', }, + 'method:s' => { name => 'method' }, + 'proto:s' => { name => 'proto' }, + 'urlpath:s' => { name => 'url_path' }, + 'credentials' => { name => 'credentials' }, + 'basic' => { name => 'basic' }, + 'ntlmv2' => { name => 'ntlmv2' }, + 'username:s' => { name => 'username' }, + 'password:s' => { name => 'password' }, + 'timeout:s' => { name => 'timeout' }, + 'no-follow' => { name => 'no_follow', }, + 'cert-file:s' => { name => 'cert_file' }, + 'key-file:s' => { name => 'key_file' }, + 'cacert-file:s' => { name => 'cacert_file' }, + 'cert-pwd:s' => { name => 'cert_pwd' }, + 'cert-pkcs12' => { name => 'cert_pkcs12' }, + 'header:s@' => { name => 'header' }, + 'get-param:s@' => { name => 'get_param' }, + 'post-param:s@' => { name => 'post_param' }, + 'cookies-file:s' => { name => 'cookies_file' }, + 'unknown-status:s' => { name => 'unknown_status', default => '' }, + 'warning-status:s' => { name => 'warning_status' }, + 'critical-status:s' => { name => 'critical_status', default => '%{http_code} < 200 or %{http_code} >= 300' }, + 'warning:s' => { name => 'warning' }, + 'critical:s' => { name => 'critical' } }); - + $self->{http} = centreon::plugins::http->new(%options); return $self; } sub check_options { my ($self, %options) = @_; - $self->SUPER::init(%options); - if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'warning-size', value => $self->{option_results}->{warning_size})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning-size threshold '" . $self->{option_results}->{warning_size} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'critical-size', value => $self->{option_results}->{critical_size})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical-size threshold '" . $self->{option_results}->{critical_size} . "'."); - $self->{output}->option_exit(); + # Compat + if (defined($options{option_results}->{warning})) { + $options{option_results}->{'warning-time'} = $options{option_results}->{warning}; + $options{option_results}->{'warning-http-response-time-seconds'} = $options{option_results}->{warning}; } + if (defined($options{option_results}->{critical})) { + $options{option_results}->{'critical-time'} = $options{option_results}->{critical}; + $options{option_results}->{'critical-http-response-time-seconds'} = $options{option_results}->{critical}; + } + $self->SUPER::check_options(%options); + $self->change_macros(macros => ['warning_status', 'critical_status', 'unknown_status']); $self->{http}->set_options(%{$self->{option_results}}); } -sub run { +sub manage_selection { my ($self, %options) = @_; + $self->{global} = {}; my $timing0 = [gettimeofday]; - my $webcontent = $self->{http}->request(); - my $timeelapsed = tv_interval($timing0, [gettimeofday]); + my $webcontent = $self->{http}->request( + unknown_status => '', warning_status => '', critical_status => '' + ); + $self->{global}->{time} = tv_interval($timing0, [gettimeofday]); + $self->{global}->{http_code} = $self->{http}->get_code(); + $self->{global}->{message} = $self->{http}->get_message(); - $self->{output}->output_add(long_msg => $webcontent); - - my $exit = $self->{perfdata}->threshold_check(value => $timeelapsed, - threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Response time %.3fs", $timeelapsed)); - $self->{output}->perfdata_add(label => "time", unit => 's', - value => sprintf('%.3f', $timeelapsed), - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), - min => 0); - # Size check { require bytes; - my $content_size = bytes::length($webcontent); - $exit = $self->{perfdata}->threshold_check(value => $content_size, - threshold => [ { label => 'critical-size', exit_litteral => 'critical' }, { label => 'warning-size', exit_litteral => 'warning' } ]); - if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Content size : %s", $content_size)); - } - $self->{output}->perfdata_add(label => "size", unit => 'B', - value => $content_size, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-size'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-size'), - min => 0); + $self->{global}->{size} = bytes::length($webcontent); } - - $self->{output}->display(); - $self->{output}->exit(); } 1; @@ -241,11 +256,11 @@ Threshold warning for http response code Threshold critical for http response code (Default: '%{http_code} < 200 or %{http_code} >= 300') -=item B<--warning> +=item B<--warning-time> Threshold warning in seconds (Webpage response time) -=item B<--critical> +=item B<--critical-time> Threshold critical in seconds (Webpage response time) From 3faa2357f4ea14b850f7b6c2ee861f8c5a1f56b5 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 24 Apr 2020 11:30:37 +0200 Subject: [PATCH 142/283] fix ssh cli --- centreon/plugins/backend/ssh/sshcli.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/centreon/plugins/backend/ssh/sshcli.pm b/centreon/plugins/backend/ssh/sshcli.pm index fd8290212..91101e489 100644 --- a/centreon/plugins/backend/ssh/sshcli.pm +++ b/centreon/plugins/backend/ssh/sshcli.pm @@ -57,7 +57,7 @@ sub check_options { $self->{output}->option_exit(); } - push @{$self->{ssh_option}}, '-o="BatchMode yes"'; + push @{$self->{ssh_option}}, '-o=BatchMode yes'; push @{$self->{ssh_option}}, '-l=' . $self->{ssh_username} if (defined($self->{ssh_username}) && $self->{ssh_username} ne ''); push @{$self->{ssh_option}}, '-p=' . $self->{ssh_port} if (defined($self->{ssh_port}) && $self->{ssh_port} ne ''); push @{$self->{ssh_option}}, '-i=' . $self->{ssh_priv_key} if (defined($self->{ssh_priv_key}) && $self->{ssh_priv_key} ne ''); From 096bebd2bdaec6d2223770ecd92c24a428cf4dd3 Mon Sep 17 00:00:00 2001 From: UrBnW <40244829+UrBnW@users.noreply.github.com> Date: Fri, 24 Apr 2020 12:23:13 +0200 Subject: [PATCH 143/283] 3CX, new version compat --- apps/voip/3cx/restapi/custom/api.pm | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/apps/voip/3cx/restapi/custom/api.pm b/apps/voip/3cx/restapi/custom/api.pm index 4e41dbb42..783d01e42 100644 --- a/apps/voip/3cx/restapi/custom/api.pm +++ b/apps/voip/3cx/restapi/custom/api.pm @@ -136,9 +136,11 @@ sub settings { $self->build_options_for_httplib(); $self->{http}->add_header(key => 'Content-Type', value => 'application/json;charset=UTF-8'); - if (defined($self->{cookie}) && defined($self->{xsrf})) { + if (defined($self->{cookie})) { $self->{http}->add_header(key => 'Cookie', value => '.AspNetCore.Cookies=' . $self->{cookie}); - $self->{http}->add_header(key => 'X-XSRF-TOKEN', value => $self->{xsrf}); + if (defined($self->{xsrf})) { + $self->{http}->add_header(key => 'X-XSRF-TOKEN', value => $self->{xsrf}); + } } $self->{http}->set_options(%{$self->{option_results}}); } @@ -171,12 +173,9 @@ sub authenticate { $self->{output}->add_option_msg(short_msg => "Error retrieving cookie"); $self->{output}->option_exit(); } + # 3CX 16.0.5.611 does not use XSRF-TOKEN anymore if (defined ($header) && $header =~ /(?:^| )XSRF-TOKEN=([^;]+);.*/) { $xsrf = $1; - } else { - $self->{output}->output_add(long_msg => $content, debug => 1); - $self->{output}->add_option_msg(short_msg => "Error retrieving xsrf-token"); - $self->{output}->option_exit(); } my $datas = { last_timestamp => time(), cookie => $cookie, xsrf => $xsrf, expires_on => time() + (3600 * 24) }; From 440337dafc99b106210ea3115b53012d1b94bf40 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 24 Apr 2020 13:40:37 +0200 Subject: [PATCH 144/283] fix typo --- centreon/plugins/backend/ssh/sshcli.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/centreon/plugins/backend/ssh/sshcli.pm b/centreon/plugins/backend/ssh/sshcli.pm index 91101e489..159b871f2 100644 --- a/centreon/plugins/backend/ssh/sshcli.pm +++ b/centreon/plugins/backend/ssh/sshcli.pm @@ -33,7 +33,7 @@ sub new { $options{options}->add_options(arguments => { 'sshcli-command:s' => { name => 'sshcli_command', default => 'ssh' }, 'sshcli-path:s' => { name => 'sshcli_path' }, - 'sslcli-option:s@' => { name => 'sshcli_option' } + 'sshcli-option:s@' => { name => 'sshcli_option' } }); $options{options}->add_help(package => __PACKAGE__, sections => 'BACKEND SSHCLI OPTIONS', once => 1); } From 175e038cd69b2c9df4f61e4b2893c30f4351a1cf Mon Sep 17 00:00:00 2001 From: Simon Bomm Date: Fri, 24 Apr 2020 14:41:48 +0200 Subject: [PATCH 145/283] + fix typo in perfdata --- cloud/aws/ec2/mode/spotactiveinstances.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloud/aws/ec2/mode/spotactiveinstances.pm b/cloud/aws/ec2/mode/spotactiveinstances.pm index 1b544efe8..e343cec54 100644 --- a/cloud/aws/ec2/mode/spotactiveinstances.pm +++ b/cloud/aws/ec2/mode/spotactiveinstances.pm @@ -41,7 +41,7 @@ sub set_counters { ], } }, - { label => 'healthy', nlabel => 'ec2.spot.instances.unhealthy.count', set => { + { label => 'healthy', nlabel => 'ec2.spot.instances.healthy.count', set => { key_values => [ { name => 'healthy' } ], output_template => 'Healthy instances : %s', perfdatas => [ From 29278358ac2d01109ad60b265c3a5967f239e512 Mon Sep 17 00:00:00 2001 From: UrBnW <40244829+UrBnW@users.noreply.github.com> Date: Fri, 24 Apr 2020 16:43:36 +0200 Subject: [PATCH 146/283] fix interfaces discard counter --- snmp_standard/mode/interfaces.pm | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/snmp_standard/mode/interfaces.pm b/snmp_standard/mode/interfaces.pm index ff1a38bfa..b46afc57b 100644 --- a/snmp_standard/mode/interfaces.pm +++ b/snmp_standard/mode/interfaces.pm @@ -1147,8 +1147,8 @@ sub manage_selection { foreach (@{$self->{array_interface_selected}}) { $self->add_result_status(instance => $_) if (defined($self->{option_results}->{add_status})); $self->add_result_traffic(instance => $_) if (defined($self->{option_results}->{add_traffic})); - $self->add_result_cast(instance => $_) if ($self->{no_cast} == 0 && (defined($self->{option_results}->{add_cast}) || defined($self->{option_results}->{add_errors}))); $self->add_result_errors(instance => $_) if (defined($self->{option_results}->{add_errors})); + $self->add_result_cast(instance => $_) if ($self->{no_cast} == 0 && (defined($self->{option_results}->{add_cast}) || defined($self->{option_results}->{add_errors}))); $self->add_result_speed(instance => $_) if (defined($self->{option_results}->{add_speed})); $self->add_result_volume(instance => $_) if (defined($self->{option_results}->{add_volume})); $self->$custom_add_result_method(instance => $_) if ($custom_add_result_method); @@ -1280,7 +1280,19 @@ sub add_result_cast { $self->{int}->{$options{instance}}->{$_} = 0 if (!defined($self->{int}->{$options{instance}}->{$_})); } + # https://tools.ietf.org/html/rfc3635 : The IF-MIB octet counters + # count the number of octets sent to or received from the layer below + # this interface, whereas the packet counters count the number of + # packets sent to or received from the layer above. Therefore, + # received MAC Control frames, ifInDiscards, and ifInUnknownProtos are + # counted by ifInOctets, but not ifInXcastPkts. Transmitted MAC + # Control frames are counted by ifOutOctets, but not ifOutXcastPkts. + # ifOutDiscards and ifOutErrors are counted by ifOutXcastPkts, but not + # ifOutOctets. $self->{int}->{$options{instance}}->{total_in_packets} = $self->{int}->{$options{instance}}->{iucast} + $self->{int}->{$options{instance}}->{imcast} + $self->{int}->{$options{instance}}->{ibcast}; + if (defined($self->{int}->{$options{instance}}->{indiscard})) { + $self->{int}->{$options{instance}}->{total_in_packets} += $self->{int}->{$options{instance}}->{indiscard}; + } $self->{int}->{$options{instance}}->{total_out_packets} = $self->{int}->{$options{instance}}->{oucast} + $self->{int}->{$options{instance}}->{omcast} + $self->{int}->{$options{instance}}->{obcast}; } From de20387a82a878c37c6701a3cba49314b18ae4a8 Mon Sep 17 00:00:00 2001 From: Simon Bomm Date: Fri, 24 Apr 2020 17:53:46 +0200 Subject: [PATCH 147/283] fix(plugin) avoid unwanted perl error in some case --- apps/centreon/sql/mode/virtualservice.pm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/centreon/sql/mode/virtualservice.pm b/apps/centreon/sql/mode/virtualservice.pm index 911381522..e740df078 100644 --- a/apps/centreon/sql/mode/virtualservice.pm +++ b/apps/centreon/sql/mode/virtualservice.pm @@ -324,9 +324,11 @@ sub manage_selection { $config_data->{formatting}->{printf_metric_value}, max(@{$self->{vmetrics}->{$vcurve}->{values}})) if ($config_data->{virtualcurve}->{$vcurve}->{aggregation} eq 'max'); - $self->{vmetrics}->{$vcurve}->{aggregated_value} = ($config_data->{virtualcurve}->{$vcurve}->{aggregation} eq 'none' && defined($config_data->{virtualcurve}->{$vcurve}->{custom})) ? - eval "$config_data->{virtualcurve}->{$vcurve}->{custom}" : - eval "$self->{vmetrics}->{$vcurve}->{aggregated_value} $config_data->{virtualcurve}->{$vcurve}->{custom}"; + if ($config_data->{virtualcurve}->{$vcurve}->{aggregation} eq 'none') { + $self->{vmetrics}->{$vcurve}->{aggregated_value} = ($config_data->{virtualcurve}->{$vcurve}->{aggregation} eq 'none' && defined($config_data->{virtualcurve}->{$vcurve}->{custom})) ? + eval "$config_data->{virtualcurve}->{$vcurve}->{custom}" : + eval "$self->{vmetrics}->{$vcurve}->{aggregated_value} $config_data->{virtualcurve}->{$vcurve}->{custom}"; + } $self->{vmetrics}->{$vcurve}->{unit} = (defined($config_data->{virtualcurve}->{$vcurve}->{unit})) ? $config_data->{virtualcurve}->{$vcurve}->{unit} : ''; $self->{vmetrics}->{$vcurve}->{min} = (defined($config_data->{virtualcurve}->{$vcurve}->{min})) ? $config_data->{virtualcurve}->{$vcurve}->{min} : ''; From a29c68eada1dbbe5d39dcd7c5b540ee4450e353a Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 27 Apr 2020 10:55:55 +0200 Subject: [PATCH 148/283] wip: bluemind --- apps/bluemind/local/custom/api.pm | 183 ++++++++++++++++++++++++ apps/bluemind/local/mode/core.pm | 158 +++++++++++++++++++++ apps/bluemind/local/mode/lmtpd.pm | 191 +++++++++++++++++++++++++ apps/bluemind/local/mode/xmpp.pm | 115 +++++++++++++++ apps/bluemind/{ => local}/plugin.pm | 15 +- apps/bluemind/mode/incoming.pm | 211 ---------------------------- 6 files changed, 656 insertions(+), 217 deletions(-) create mode 100644 apps/bluemind/local/custom/api.pm create mode 100644 apps/bluemind/local/mode/core.pm create mode 100644 apps/bluemind/local/mode/lmtpd.pm create mode 100644 apps/bluemind/local/mode/xmpp.pm rename apps/bluemind/{ => local}/plugin.pm (72%) delete mode 100644 apps/bluemind/mode/incoming.pm diff --git a/apps/bluemind/local/custom/api.pm b/apps/bluemind/local/custom/api.pm new file mode 100644 index 000000000..b0fb2d9fd --- /dev/null +++ b/apps/bluemind/local/custom/api.pm @@ -0,0 +1,183 @@ +# +# Copyright 2020 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::bluemind::local::custom::api; + +use strict; +use warnings; +use centreon::plugins::ssh; +use centreon::plugins::misc; + +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' }, + 'timeout:s' => { name => 'timeout', default => 30 }, + 'sudo' => { name => 'sudo' }, + 'command:s' => { name => 'command' }, + 'command-path:s' => { name => 'command_path' }, + 'command-options:s' => { name => 'command_options' } + }); + } + $options{options}->add_help(package => __PACKAGE__, sections => 'BLUEMIND OPTIONS', once => 1); + + $self->{output} = $options{output}; + $self->{mode} = $options{mode}; + $self->{ssh} = centreon::plugins::ssh->new(%options); + + return $self; +} + +sub set_options { + my ($self, %options) = @_; + + $self->{option_results} = $options{option_results}; +} + +sub set_defaults { + my ($self, %options) = @_; + + 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 get_hostname { + my ($self, %options) = @_; + + return defined($self->{option_results}->{hostname}) ? $self->{option_results}->{hostname} : 'local'; +} + +sub check_options { + my ($self, %options) = @_; + + if (defined($self->{option_results}->{hostname}) && $self->{option_results}->{hostname} ne '') { + $self->{ssh}->check_options(option_results => $self->{option_results}); + } + + return 0; +} + +sub execute_command { + my ($self, %options) = @_; + + my $content; + if (defined($self->{option_results}->{hostname}) && $self->{option_results}->{hostname} ne '') { + ($content) = $self->{ssh}->execute( + hostname => $self->{option_results}->{hostname}, + command => defined($self->{option_results}->{command}) && $self->{option_results}->{command} ne '' ? $self->{option_results}->{command} : $options{command}, + command_path => $self->{option_results}->{command_path}, + command_options => defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne '' ? $self->{option_results}->{command_options} : undef, + timeout => $self->{option_results}->{timeout}, + sudo => $self->{option_results}->{sudo} + ); + } else { + ($content) = centreon::plugins::misc::execute( + output => $self->{output}, + options => { timeout => $self->{option_results}->{timeout} }, + sudo => $self->{option_results}->{sudo}, + command => defined($self->{option_results}->{command}) && $self->{option_results}->{command} ne '' ? $self->{option_results}->{command} : $options{command}, + command_path => $self->{option_results}->{command_path}, + command_options => defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne '' ? $self->{option_results}->{command_options} : undef + ); + } + + my $results = {}; + foreach (split /\n/, $content) { + next if (! /$options{filter}/); + my ($key, $value_str) = split /\s/; + foreach my $value (split /,/, $value_str) { + my ($field1, $field2) = split /=/, $value; + $results->{$key}->{$field1} = $field2; + } + } + + return $results; +} + +1; + +__END__ + +=head1 NAME + +bluemind + +=head1 SYNOPSIS + +bluemind + +=head1 BLUEMIND OPTIONS + +=over 8 + +=item B<--hostname> + +Hostname to query. + +=item B<--timeout> + +Timeout in seconds for the command (Default: 30). + +=item B<--sudo> + +Use 'sudo' to execute the command. + +=item B<--command> + +Command to get information. Used it you have output in a file. + +=item B<--command-path> + +Command path. + +=item B<--command-options> + +Command options. + +=back + +=head1 DESCRIPTION + +B. + +=cut diff --git a/apps/bluemind/local/mode/core.pm b/apps/bluemind/local/mode/core.pm new file mode 100644 index 000000000..29d9a9898 --- /dev/null +++ b/apps/bluemind/local/mode/core.pm @@ -0,0 +1,158 @@ +# +# Copyright 2020 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::bluemind::local::mode::core; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use Digest::MD5 qw(md5_hex); +use bigint; + +sub prefix_core_output { + my ($self, %options) = @_; + + return 'Main engine '; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'bm_core', type => 0, cb_prefix_output => 'prefix_core_output' } + ]; + + $self->{maps_counters}->{bm_core} = [ + { label => 'calls-received-success', nlabel => 'core.calls.received.success.count', display_ok => 0, set => { + key_values => [ { name => 'calls_success', diff => 1 } ], + output_template => 'success calls received: %s', + perfdatas => [ + { value => 'calls_success_absolute', template => '%s', min => 0 } + ] + } + }, + { label => 'calls-received-failed', nlabel => 'core.calls.received.failure.count', set => { + key_values => [ { name => 'calls_failure', diff => 1 } ], + output_template => 'failure calls received: %s', + perfdatas => [ + { value => 'calls_failure_absolute', template => '%s', min => 0 } + ] + } + }, + { label => 'heartbeat-broadcast', nlabel => 'core.heartbeat.broadcast.running.count', display_ok => 0, set => { + key_values => [ { name => 'heartbeat_broadcast', diff => 1 } ], + output_template => 'broadcast heartbeat running: %s', + perfdatas => [ + { value => 'heartbeat_broadcast_absolute', template => '%s', min => 0 } + ] + } + }, + { label => 'directory-cluster-events', nlabel => 'core.directory.cluster.events.count', display_ok => 0, set => { + key_values => [ { name => 'cluster_events', diff => 1 } ], + output_template => 'directory cluster events: %s', + perfdatas => [ + { value => 'cluster_events_absolute', template => '%s', min => 0 } + ] + } + }, + { label => 'request-handling-total', nlabel => 'core.request.handling.total.milliseconds', set => { + key_values => [ { name => 'request_handling_time_total', diff => 1 } ], + output_template => 'total request handling: %s ms', + perfdatas => [ + { value => 'request_handling_time_total_absolute', template => '%s', min => 0, unit => 'ms' } + ] + } + }, + { label => 'request-handling-mean', nlabel => 'core.request.handling.mean.milliseconds', display_ok => 0, set => { + key_values => [ { name => 'request_handling_time_mean', diff => 1 } ], + output_template => 'mean request handling: %s ms', + perfdatas => [ + { value => 'request_handling_time_mean_absolute', template => '%s', min => 0, unit => 'ms' } + ] + } + } + ]; +} + +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 => { + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + # bm-core.heartbeat.broadcast,state=core.state.running,meterType=Counter count=1854550 + # bm-core.handlingDuration,meterType=Timer count=695244256,totalTime=1911292590914929,mean=2749095 + # bm-core.callsCount,status=failure,meterType=Counter count=97 + # bm-core.callsCount,status=success,meterType=Counter count=125244086 + # bm-core.directory.cluster.events,meterType=Counter count=14300 + my $result = $options{custom}->execute_command( + command => 'curl --unix-socket /var/run/bm-metrics/bm-core.sock http://127.0.0.1/metrics', + filter => 'bm-core\.heartbeat\.broadcast|bm-core\.handlingDuration|bm-core\.callsCount|bm-core\.directory\.cluster\.events' + ); + + $self->{bm_core} = {}; + foreach (keys %$result) { + $self->{bm_core}->{'calls_' . $1} = $result->{$_}->{count} if (/bm-core.callsCount.*status=(failure|success)/); + $self->{bm_core}->{cluster_events} = $result->{$_}->{count} if (/bm-core\.directory\.cluster\.events/); + if (/bm-core\.handlingDuration/) { # in nanoseconds + $self->{bm_core}->{request_handling_time_total} = $result->{$_}->{totalTime} / 1000000; + $self->{bm_core}->{request_handling_time_mean} = $result->{$_}->{mean} / 1000000; + } + $self->{bm_core}->{heartbeat_broadcast} = $result->{$_}->{count} if (/bm-core\.heartbeat\.broadcast.*running/); + } + + $self->{cache_name} = 'bluemind_' . $self->{mode} . '_' . $options{custom}->get_hostname() . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); +} + +1; + +__END__ + +=head1 MODE + +Check main bluemind engine. + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='^calls' + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'calls-received-success', 'calls-received-failed', +'heartbeat-broadcast', 'directory-cluster-events', +'request-handling-total', 'request-handling-mean'. + +=back + +=cut diff --git a/apps/bluemind/local/mode/lmtpd.pm b/apps/bluemind/local/mode/lmtpd.pm new file mode 100644 index 000000000..167d70c51 --- /dev/null +++ b/apps/bluemind/local/mode/lmtpd.pm @@ -0,0 +1,191 @@ +# +# Copyright 2020 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::bluemind::local::mode::lmtpd; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use Digest::MD5 qw(md5_hex); +use bigint; + +sub prefix_lmtpd_output { + my ($self, %options) = @_; + + return 'Email delivery service '; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'bm_lmtpd', type => 0, cb_prefix_output => 'prefix_lmtpd_output' } + ]; + + $self->{maps_counters}->{bm_lmtpd} = [ + { label => 'connections-active', nlabel => 'lmtpd.connections.active.count', set => { + key_values => [ { name => 'active_connections' } ], + output_template => 'active connections: %s', + perfdatas => [ + { value => 'active_connections_absolute', template => '%s', min => 0 } + ] + } + }, + { label => 'connections-total', nlabel => 'lmtpd.connections.total.count', display_ok => 0, set => { + key_values => [ { name => 'connections', diff => 1 } ], + output_template => 'total connections: %s', + perfdatas => [ + { value => 'connections_absolute', template => '%s', min => 0 } + ] + } + }, + { label => 'deliveries-success', nlabel => 'lmtpd.deliveries.success.count', display_ok => 0, set => { + key_values => [ { name => 'deliveries_ok', diff => 1 } ], + output_template => 'success deliveries: %s', + perfdatas => [ + { value => 'deliveries_ok_absolute', template => '%s', min => 0 } + ] + } + }, + { label => 'deliveries-failure', nlabel => 'lmtpd.deliveries.failure.count', display_ok => 0, set => { + key_values => [ { name => 'deliveries_ko', diff => 1 } ], + output_template => 'failure deliveries: %s', + perfdatas => [ + { value => 'deliveries_ko_absolute', template => '%s', min => 0 } + ] + } + }, + { label => 'emails-size-total', nlabel => 'lmtpd.emails.size.total.count', display_ok => 0, set => { + key_values => [ { name => 'email_size', diff => 1 } ], + output_template => 'total emails size: %s %s', + output_change_bytes => 1, + perfdatas => [ + { value => 'email_size_absolute', template => '%s', min => 0, unit => 'B' } + ] + } + }, + { label => 'sessions-duration-total', nlabel => 'lmtpd.sessions.duration.total.milliseconds', set => { + key_values => [ { name => 'session_duration_total', diff => 1 } ], + output_template => 'total sessions duration: %s ms', + perfdatas => [ + { value => 'session_duration_total_absolute', template => '%s', min => 0, unit => 'ms' } + ] + } + }, + { label => 'sessions-duration-mean', nlabel => 'lmtpd.sessions.duration.mean.milliseconds', set => { + key_values => [ { name => 'session_duration_mean', diff => 1 } ], + output_template => 'mean sessions duration: %s ms', + perfdatas => [ + { value => 'session_duration_mean_absolute', template => '%s', min => 0, unit => 'ms' } + ] + } + }, + { label => 'traffic-transport-latency-total', nlabel => 'lmtpd.traffic.transport.latency.total.milliseconds', set => { + key_values => [ { name => 'traffic_latency_total', diff => 1 } ], + output_template => 'total traffic transport latency: %s ms', + perfdatas => [ + { value => 'traffic_latency_total_absolute', template => '%s', min => 0, unit => 'ms' } + ] + } + }, + { label => 'traffic-transport-latency-mean', nlabel => 'lmtpd.traffic.transport.latency.mean.milliseconds', set => { + key_values => [ { name => 'traffic_latency_mean', diff => 1 } ], + output_template => 'mean traffic transport latency: %s ms', + perfdatas => [ + { value => 'traffic_latency_mean_absolute', template => '%s', min => 0, unit => 'ms' } + ] + } + } + ]; +} + +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 => { + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + # bm-lmtpd.activeConnections,meterType=Gauge value=0 + # bm-lmtpd.connectionCount,meterType=Counter count=1236057 + # bm-lmtpd.deliveries,status=ko,meterType=Counter count=410 + # bm-lmtpd.deliveries,status=ok,meterType=Counter count=1390933 + # bm-lmtpd.emailSize,meterType=DistSum count=5020456,totalAmount=1170102671020,mean=233067 + # bm-lmtpd.sessionDuration,meterType=Timer count=4941893,totalTime=1052591049892285,mean=212993492 + # bm-lmtpd.traffic.transportLatency,meterType=Timer count=5017208,totalTime=272844528075000000,mean=54381745400 + my $result = $options{custom}->execute_command( + command => 'curl --unix-socket /var/run/bm-metrics/bm-lmtpd.sock http://127.0.0.1/metrics', + filter => 'activeConnections|connectionCount|deliveries|emailSize|sessionDuration|traffic\.transportLatency' + ); + + $self->{bm_lmtpd} = {}; + foreach (keys %$result) { + $self->{bm_lmtpd}->{'deliveries_' . $1} = $result->{$_}->{count} if (/bm-lmtpd\.deliveries.*status=(ok|ko)/); + $self->{bm_lmtpd}->{active_connections} = $result->{$_}->{value} if (/bm-lmtpd\.activeConnections/); + $self->{bm_lmtpd}->{connections} = $result->{$_}->{count} if (/bm-lmtpd\.connectionCount/); + $self->{bm_lmtpd}->{email_size} = $result->{$_}->{totalAmount} if (/bm-lmtpd\.emailSize/); + if (/bm-lmtpd\.sessionDuration/) { + $self->{bm_lmtpd}->{session_duration_total} = $result->{$_}->{totalAmount} / 100000; + $self->{bm_lmtpd}->{session_duration_mean} = $result->{$_}->{mean} / 100000; + } + if (/bm-lmtpd\.traffic\.transportLatency/) { + $self->{bm_lmtpd}->{traffic_latency_total} = $result->{$_}->{totalAmount} / 100000; + $self->{bm_lmtpd}->{traffic_latency_mean} = $result->{$_}->{mean} / 100000; + } + } + + $self->{cache_name} = 'bluemind_' . $self->{mode} . '_' . $options{custom}->get_hostname() . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); +} + +1; + +__END__ + +=head1 MODE + +Check email delivery service. + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='^deliveries' + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'connections-active', 'connections-total', +'deliveries-success', 'deliveries-failure', 'emails-size-total', +'sessions-duration-total', 'sessions-duration-mean', 'traffic-transport-latency-total', +'traffic-transport-latency-mean'. + +=back + +=cut diff --git a/apps/bluemind/local/mode/xmpp.pm b/apps/bluemind/local/mode/xmpp.pm new file mode 100644 index 000000000..5813b598e --- /dev/null +++ b/apps/bluemind/local/mode/xmpp.pm @@ -0,0 +1,115 @@ +# +# Copyright 2020 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::bluemind::local::mode::xmpp; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use Digest::MD5 qw(md5_hex); +use bigint; + +sub prefix_xmpp_output { + my ($self, %options) = @_; + + return 'Instant messaging service '; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'bm_xmpp', type => 0, cb_prefix_output => 'prefix_xmpp_output' } + ]; + + $self->{maps_counters}->{bm_xmpp} = [ + { label => 'packets-all', nlabel => 'xmpp.packets.all.count', set => { + key_values => [ { name => 'packets_all', diff => 1 } ], + output_template => 'all packets sent: %s', + perfdatas => [ + { value => 'packets_all_absolute', template => '%s', min => 0 } + ] + } + }, + { label => 'packets-chat', nlabel => 'xmpp.packets.chat.count', display_ok => 0, set => { + key_values => [ { name => 'packets_chat', diff => 1 } ], + output_template => 'chat packets sent: %s', + perfdatas => [ + { value => 'packets_chat_absolute', template => '%s', min => 0 } + ] + } + } + ]; +} + +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 => { + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + # bm-xmpp.packetsCount,type=all,meterType=Counter count=517791 + # bm-xmpp.packetsCount,type=chat,meterType=Counter count=12 + my $result = $options{custom}->execute_command( + command => 'curl --unix-socket /var/run/bm-metrics/bm-xmpp.sock http://127.0.0.1/metrics', + filter => 'packetsCount' + ); + + $self->{bm_xmpp} = {}; + foreach (keys %$result) { + $self->{bm_xmpp}->{'packets_' . $1} = $result->{$_}->{count} if (/bm-xmpp\.packetsCount.*type=(all|chat)/); + } + + $self->{cache_name} = 'bluemind_' . $self->{mode} . '_' . $options{custom}->get_hostname() . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); +} + +1; + +__END__ + +=head1 MODE + +Check instant Messaging Service. + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='chat' + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'packets-all', 'packets-chat'. + +=back + +=cut diff --git a/apps/bluemind/plugin.pm b/apps/bluemind/local/plugin.pm similarity index 72% rename from apps/bluemind/plugin.pm rename to apps/bluemind/local/plugin.pm index 0e15a8010..3f136b7f1 100644 --- a/apps/bluemind/plugin.pm +++ b/apps/bluemind/local/plugin.pm @@ -18,11 +18,11 @@ # limitations under the License. # -package apps::bluemind::plugin; +package apps::bluemind::local::plugin; use strict; use warnings; -use base qw(centreon::plugins::script_simple); +use base qw(centreon::plugins::script_custom); sub new { my ($class, %options) = @_; @@ -31,10 +31,13 @@ sub new { bless $self, $class; $self->{version} = '0.1'; - %{$self->{modes}} = ( - 'incoming' => 'apps::bluemind::mode::incoming', - ); + $self->{modes} = { + 'core' => 'apps::bluemind::local::mode::core', + 'lmtpd' => 'apps::bluemind::local::mode::lmtpd', + 'xmpp' => 'apps::bluemind::local::mode::xmpp' + }; + $self->{custom_modes}{api} = 'apps::bluemind::local::custom::api'; return $self; } @@ -45,6 +48,6 @@ __END__ =head1 PLUGIN DESCRIPTION -Check BlueMind through InfluxDB API +Check BlueMind through bm-metrics sockets =cut diff --git a/apps/bluemind/mode/incoming.pm b/apps/bluemind/mode/incoming.pm deleted file mode 100644 index ef44860b2..000000000 --- a/apps/bluemind/mode/incoming.pm +++ /dev/null @@ -1,211 +0,0 @@ -# -# Copyright 2020 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::bluemind::mode::incoming; - -use base qw(centreon::plugins::mode); - -use strict; -use warnings; -use centreon::plugins::http; -use centreon::plugins::statefile; -use JSON; - -sub new { - my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); - bless $self, $class; - - $options{options}->add_options(arguments => { - "hostname:s" => { name => 'hostname' }, - "port:s" => { name => 'port', default => '8086'}, - "proto:s" => { name => 'proto' }, - "urlpath:s" => { name => 'url_path', default => "/db" }, - "database:s" => { name => 'database' }, - "username:s" => { name => 'username' }, - "password:s" => { name => 'password' }, - "timeout:s" => { name => 'timeout' }, - "warning:s" => { name => 'warning' }, - "critical:s" => { name => 'critical' }, - }); - - $self->{statefile_value} = centreon::plugins::statefile->new(%options); - $self->{http} = centreon::plugins::http->new(%options); - return $self; -} - -sub check_options { - my ($self, %options) = @_; - $self->SUPER::init(%options); - - if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); - $self->{output}->option_exit(); - } - if (!defined($self->{option_results}->{database})) { - $self->{output}->add_option_msg(short_msg => "Please set the database option"); - $self->{output}->option_exit(); - } - if ((!defined($self->{option_results}->{username}) || !defined($self->{option_results}->{password}))) { - $self->{output}->add_option_msg(short_msg => "You need to set --username= and --password= option"); - $self->{output}->option_exit(); - } - - my $query = 'select sum("success") as "success_sum", sum("failure") as "failure_sum" from lmtpd.deliveries where time > '.$old_timestamp.'s and time < now()'; - $self->{option_results}->{url_path} = $self->{option_results}->{url_path}."/".$self->{option_results}->{database}."/series"; - $self->{option_results}->{get_param} = []; - push @{$self->{option_results}->{get_param}}, "q=" . $query, "p=" . $self->{option_results}->{password}, "u=" . $self->{option_results}->{username}; - - $self->{http}->set_options(%{$self->{option_results}}); - $self->{statefile_value}->check_options(%options); -} - -sub run { - my ($self, %options) = @_; - - $self->{statefile_value}->read(statefile => 'bluemind_' . $self->{option_results}->{hostname} . '_' . $self->{http}->get_port() . '_' . $self->{mode}); - my $old_timestamp = $self->{statefile_value}->get(name => 'last_timestamp'); - - my $new_datas = {}; - $new_datas->{last_timestamp} = time(); - $self->{statefile_value}->write(data => $new_datas); - - if (!defined($old_timestamp)) { - $self->{output}->output_add(severity => 'OK', - short_msg => "Buffer creation..."); - $self->{output}->display(); - $self->{output}->exit(); - } - - my $jsoncontent = $self->{http}->request(); - - my $json = JSON->new; - my $webcontent; - - eval { - $webcontent = $json->decode($jsoncontent); - }; - - if ($@) { - $self->{output}->add_option_msg(short_msg => "Cannot decode json response"); - $self->{output}->option_exit(); - } - - my $hwebcontent; - for my $ref (@{ $webcontent }) { - my $name = $ref->{name}; - my @columns = @{ $ref->{columns} }; - - for my $points (@{ $ref->{points} }) { - my %hash; - @hash{ @columns } = @$points; - push @{ $hwebcontent->{$name} }, \%hash; - } - } - - my $success_incoming_mails = defined($hwebcontent->{qw(lmtpd.deliveries)}->[0]->{success_sum}) ? $hwebcontent->{qw(lmtpd.deliveries)}->[0]->{success_sum} : '0'; - my $failure_incoming_mails = defined($hwebcontent->{qw(lmtpd.deliveries)}->[0]->{failure_sum}) ? $hwebcontent->{qw(lmtpd.deliveries)}->[0]->{failure_sum} : '0'; - - # If not present: failure and success incoming mails are 0 - if (!defined($success_incoming_mails)) { - $success_incoming_mails = 0; - } - - if (!defined($failure_incoming_mails)) { - $failure_incoming_mails = 0; - } - - my $exit = $self->{perfdata}->threshold_check(value => $failure_incoming_mails, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); - - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Success Incoming Mails: %d - Failure Incoming Mails: %d",$success_incoming_mails,$failure_incoming_mails)); - $self->{output}->perfdata_add(label => 'success', - value => sprintf("%d", $success_incoming_mails), - min => 0, - ); - $self->{output}->perfdata_add(label => 'failure', - value => sprintf("%d", $failure_incoming_mails), - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), - min => 0, - ); - - $self->{output}->display(); - $self->{output}->exit(); - -} - -1; - -__END__ - -=head1 MODE - -Check Bluemind incoming_mails (success and failure) - -=over 8 - -=item B<--hostname> - -IP Addr/FQDN of the Bluemind host - -=item B<--port> - -Port used by InfluxDB API (Default: '8086') - -=item B<--proto> - -Specify https if needed (Default: 'http') - -=item B<--urlpath> - -Set path to get influxdb information (Default: '/db') - -=item B<--database> - -InfluxDB Database name - -=item B<--username> - -Specify username for API authentification - -=item B<--password> - -Specify password for API authentification - -=item B<--timeout> - -Threshold for HTTP timeout (Default: 5) - -=item B<--warning> - -Warning Threshold for failure incoming mails - -=item B<--critical> - -Critical Threshold for failure incoming mails - -=back - -=cut From f0b3930a476cca381fb71818440ece15a22f64d6 Mon Sep 17 00:00:00 2001 From: thibaults-centreon Date: Mon, 27 Apr 2020 13:24:06 +0200 Subject: [PATCH 149/283] fix(plugin): fix aws vpn --- cloud/aws/vpn/mode/traffic.pm | 2 +- cloud/aws/vpn/plugin.pm | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/cloud/aws/vpn/mode/traffic.pm b/cloud/aws/vpn/mode/traffic.pm index 7e8e458d9..db56097a3 100644 --- a/cloud/aws/vpn/mode/traffic.pm +++ b/cloud/aws/vpn/mode/traffic.pm @@ -187,7 +187,7 @@ sub set_counters { closure_custom_perfdata => ($metric =~ /State/) ? $self->can('custom_metric_perfdata_state') : $self->can('custom_metric_perfdata'), closure_custom_threshold_check => $self->can('custom_metric_threshold'), } - } + }; push @{$self->{maps_counters}->{statistics}}, $entry; } } diff --git a/cloud/aws/vpn/plugin.pm b/cloud/aws/vpn/plugin.pm index 208a13de7..d07982549 100644 --- a/cloud/aws/vpn/plugin.pm +++ b/cloud/aws/vpn/plugin.pm @@ -32,8 +32,7 @@ sub new { $self->{version} = '1.0'; %{ $self->{modes} } = ( 'traffic' => 'cloud::aws::vpn::mode::traffic', - 'listvpn' => 'cloud::aws::vpn::mode::listvpn', - 'discovery' => 'cloud::aws::vpn::mode::discovery' + 'listvpn' => 'cloud::aws::vpn::mode::listvpn' ); $self->{custom_modes}{paws} = 'cloud::aws::custom::paws'; From ddf847b1157d65b750d3c7fa1d96555c12d1d0a6 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 27 Apr 2020 15:47:53 +0200 Subject: [PATCH 150/283] new version of bluemind plugin --- apps/bluemind/local/mode/core.pm | 4 +- apps/bluemind/local/mode/eas.pm | 128 ++++++++++++++++ apps/bluemind/local/mode/hps.pm | 205 ++++++++++++++++++++++++++ apps/bluemind/local/mode/ips.pm | 96 ++++++++++++ apps/bluemind/local/mode/lmtpd.pm | 12 +- apps/bluemind/local/mode/milter.pm | 168 +++++++++++++++++++++ apps/bluemind/local/mode/webserver.pm | 152 +++++++++++++++++++ apps/bluemind/local/mode/xmpp.pm | 4 +- apps/bluemind/local/plugin.pm | 11 +- 9 files changed, 767 insertions(+), 13 deletions(-) create mode 100644 apps/bluemind/local/mode/eas.pm create mode 100644 apps/bluemind/local/mode/hps.pm create mode 100644 apps/bluemind/local/mode/ips.pm create mode 100644 apps/bluemind/local/mode/milter.pm create mode 100644 apps/bluemind/local/mode/webserver.pm diff --git a/apps/bluemind/local/mode/core.pm b/apps/bluemind/local/mode/core.pm index 29d9a9898..a266e1a23 100644 --- a/apps/bluemind/local/mode/core.pm +++ b/apps/bluemind/local/mode/core.pm @@ -82,7 +82,7 @@ sub set_counters { } }, { label => 'request-handling-mean', nlabel => 'core.request.handling.mean.milliseconds', display_ok => 0, set => { - key_values => [ { name => 'request_handling_time_mean', diff => 1 } ], + key_values => [ { name => 'request_handling_time_mean' } ], output_template => 'mean request handling: %s ms', perfdatas => [ { value => 'request_handling_time_mean_absolute', template => '%s', min => 0, unit => 'ms' } @@ -112,7 +112,7 @@ sub manage_selection { # bm-core.callsCount,status=success,meterType=Counter count=125244086 # bm-core.directory.cluster.events,meterType=Counter count=14300 my $result = $options{custom}->execute_command( - command => 'curl --unix-socket /var/run/bm-metrics/bm-core.sock http://127.0.0.1/metrics', + command => 'curl --unix-socket /var/run/bm-metrics/metrics-bm-core.sock http://127.0.0.1/metrics', filter => 'bm-core\.heartbeat\.broadcast|bm-core\.handlingDuration|bm-core\.callsCount|bm-core\.directory\.cluster\.events' ); diff --git a/apps/bluemind/local/mode/eas.pm b/apps/bluemind/local/mode/eas.pm new file mode 100644 index 000000000..058038c0a --- /dev/null +++ b/apps/bluemind/local/mode/eas.pm @@ -0,0 +1,128 @@ +# +# Copyright 2020 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::bluemind::local::mode::eas; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use Digest::MD5 qw(md5_hex); +use bigint; + +sub prefix_eas_output { + my ($self, %options) = @_; + + return 'Mobile connection service '; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'bm_eas', type => 0, cb_prefix_output => 'prefix_eas_output' } + ]; + + $self->{maps_counters}->{bm_eas} = [ + { label => 'responses-size-total', nlabel => 'eas.responses.size.total.count', display_ok => 0, set => { + key_values => [ { name => 'response_size', diff => 1 } ], + output_template => 'total responses size: %s %s', + output_change_bytes => 1, + perfdatas => [ + { value => 'response_size_absolute', template => '%s', min => 0, unit => 'B' } + ] + } + }, + { label => 'execution-total', nlabel => 'eas.execution.total.milliseconds', display_ok => 0, set => { + key_values => [ { name => 'execution_total', diff => 1 } ], + output_template => 'total execution: %s ms', + perfdatas => [ + { value => 'execution_total_absolute', template => '%s', min => 0, unit => 'ms' } + ] + } + }, + { label => 'execution-mean', nlabel => 'eas.execution.mean.milliseconds', set => { + key_values => [ { name => 'execution_mean' } ], + output_template => 'mean execution: %s ms', + perfdatas => [ + { value => 'execution_mean_absolute', template => '%s', min => 0, unit => 'ms' } + ] + } + } + ]; +} + +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 => { + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + # bm-eas.executionTime,meterType=Timer count=23865528,totalTime=48394780739993049,mean=2027811022 + # bm-eas.responseSize,meterType=DistSum count=31508001,totalAmount=736453775233,mean=23373 + my $result = $options{custom}->execute_command( + command => 'curl --unix-socket /var/run/bm-metrics/metrics-bm-eas.sock http://127.0.0.1/metrics', + filter => 'executionTime|responseSize' + ); + + $self->{bm_eas} = {}; + foreach (keys %$result) { + $self->{bm_eas}->{response_size} = $result->{$_}->{totalAmount} if (/bm-eas.responseSize/); + if (/bm-eas\.executionTime/) { + $self->{bm_eas}->{execution_total} = $result->{$_}->{totalTime} / 100000; + $self->{bm_eas}->{execution_mean} = $result->{$_}->{mean} / 100000; + } + } + + $self->{cache_name} = 'bluemind_' . $self->{mode} . '_' . $options{custom}->get_hostname() . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); +} + +1; + +__END__ + +=head1 MODE + +Check mobile connection service. + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='^execution' + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'responses-size-total', 'execution-total', 'execution-mean'. + +=back + +=cut diff --git a/apps/bluemind/local/mode/hps.pm b/apps/bluemind/local/mode/hps.pm new file mode 100644 index 000000000..235191345 --- /dev/null +++ b/apps/bluemind/local/mode/hps.pm @@ -0,0 +1,205 @@ +# +# Copyright 2020 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::bluemind::local::mode::hps; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use Digest::MD5 qw(md5_hex); +use bigint; + +sub prefix_hps_output { + my ($self, %options) = @_; + + return 'Authentication service '; +} +sub prefix_upstream_output { + my ($self, %options) = @_; + + return "Upstream '" . $options{instance_value}->{display} . "' "; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'bm_hps', type => 0, cb_prefix_output => 'prefix_hps_output' }, + { name => 'bm_hps_upstream', type => 1, cb_prefix_output => 'prefix_upstream_output', message_multiple => 'All upstreams are ok' } + ]; + + $self->{maps_counters}->{bm_hps} = [ + { label => 'authentication-success', nlabel => 'hps.authentication.success.count', display_ok => 0, set => { + key_values => [ { name => 'auth_success', diff => 1 } ], + output_template => 'success authentication: %s', + perfdatas => [ + { value => 'auth_success_absolute', template => '%s', min => 0 } + ] + } + }, + { label => 'authentication-failure', nlabel => 'hps.authentication.failure.count', set => { + key_values => [ { name => 'auth_failure', diff => 1 } ], + output_template => 'failure authentication: %s', + perfdatas => [ + { value => 'auth_failure_absolute', template => '%s', min => 0 } + ] + } + }, + { label => 'requests-protected', nlabel => 'hps.requests.protected.count', display_ok => 0, set => { + key_values => [ { name => 'requests_protected', diff => 1 } ], + output_template => 'protected requests: %s', + perfdatas => [ + { value => 'requests_protected_absolute', template => '%s', min => 0 } + ] + } + }, + { label => 'requests-maintenance', nlabel => 'hps.requests.maintenance.count', set => { + key_values => [ { name => 'requests_maintenance', diff => 1 } ], + output_template => 'maintenance requests: %s', + perfdatas => [ + { value => 'requests_maintenance_absolute', template => '%s', min => 0 } + ] + } + } + ]; + + $self->{maps_counters}->{bm_hps_upstream} = [ + { label => 'upstream-requests-time-total', nlabel => 'hps.upstream.requests.time.milliseconds', display_ok => 0, set => { + key_values => [ { name => 'requests_time_total', diff => 1 }, { name => 'display' } ], + output_template => 'total requests time: %s ms', + perfdatas => [ + { value => 'requests_time_total_absolute', template => '%s', min => 0, unit => 'ms', label_extra_instance => 1 } + ] + } + }, + { label => 'upstream-requests-time-mean', nlabel => 'hps.upstream.requests.time.mean.milliseconds', set => { + key_values => [ { name => 'requests_time_mean' }, { name => 'display' } ], + output_template => 'mean requests time: %s ms', + perfdatas => [ + { value => 'requests_time_mean_absolute', template => '%s', min => 0, unit => 'ms', label_extra_instance => 1 } + ] + } + }, + { label => 'upstream-requests-size-total', nlabel => 'hps.upstream.requests.size.total.bytes', display_ok => 0, set => { + key_values => [ { name => 'requests_size', diff => 1 } ], + output_template => 'total requests size: %s %s', + output_change_bytes => 1, + perfdatas => [ + { value => 'requests_size_absolute', template => '%s', min => 0, unit => 'B' } + ] + } + }, + { label => 'upstream-requests-total', nlabel => 'hps.upstream.requests.total.count', display_ok => 0, set => { + key_values => [ { name => 'requests', diff => 1 } ], + output_template => 'total requests: %s', + perfdatas => [ + { value => 'requests_absolute', template => '%s', min => 0 } + ] + } + } + ]; +} + +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 => { + 'filter-upstream:s' => { name => 'filter_upstream' } + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + # bm-hps.authCount,status=failure,meterType=Counter count=855 + # bm-hps.authCount,status=success,meterType=Counter count=11957 + # bm-hps.ftlTemplates.requests,meterType=Counter count=23064 + # bm-hps.requestsCount,kind=protected,meterType=Counter count=3080815 + # bm-hps.requestsCount,kind=maintenance,meterType=Counter count=1 + # bm-hps.upstreamRequestSize,path=/login,meterType=DistSum count=331977,totalAmount=0,mean=0 + # bm-hps.upstreamRequestTime,path=/login,meterType=Timer count=37864,totalTime=70405376220,mean=1859427 + # bm-hps.upstreamRequestsCount,path=/login,meterType=Counter count=1383 + my $result = $options{custom}->execute_command( + command => 'curl --unix-socket /var/run/bm-metrics/metrics-bm-hps.sock http://127.0.0.1/metrics', + filter => 'authCount|ftlTemplates\.requests|requestsCount|upstreamRequestSize|upstreamRequestTime|upstreamRequestsCount' + ); + + $self->{bm_hps} = {}; + $self->{bm_hps_upstream} = {}; + foreach (keys %$result) { + $self->{bm_hps}->{'auth_' . $1} = $result->{$_}->{count} if (/bm-hps\.authCount.*status=(failure|success)/); + $self->{bm_hps}->{'requests_' . $1} = $result->{$_}->{count} if (/bm-hps\.requestsCount.*kind=(maintenance|protected)/); + + if (/bm-hps\.upstreamRequestTime.*path=(.*?),/) { + my $upstream = $1; + if (defined($self->{option_results}->{filter_upstream}) && $self->{option_results}->{filter_upstream} ne '' && + $upstream !~ /$self->{option_results}->{filter_upstream}/) { + $self->{output}->output_add(long_msg => "skipping upstream '" . $upstream . "': no matching filter.", debug => 1); + next; + } + + $self->{bm_hps_upstream}->{$upstream} = { + display => $upstream, + requests_time_total => $result->{$_}->{totalTime} / 100000, + requests_time_mean => $result->{$_}->{mean} / 100000, + requests_size => $result->{"bm-hps.upstreamRequestSize,path=$upstream,meterType=DistSum"}->{totalAmount}, + requests => $result->{"bm-hps.upstreamRequestsCount,path=$upstream,meterType=Counter"}->{count} + }; + } + } + + $self->{cache_name} = 'bluemind_' . $self->{mode} . '_' . $options{custom}->get_hostname() . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); +} + +1; + +__END__ + +=head1 MODE + +Check authentication service. + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='maintenance' + +=item B<--filter-upstream> + +Filter upstream name (can be a regexp). + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'authentication-success', 'authentication-failure', 'requests-protected', +'requests-maintenance', 'upstream-requests-time-total', 'upstream-requests-time-mean', +'upstream-requests-size-total, 'upstream-requests-total'. + +=back + +=cut diff --git a/apps/bluemind/local/mode/ips.pm b/apps/bluemind/local/mode/ips.pm new file mode 100644 index 000000000..8b7b58c66 --- /dev/null +++ b/apps/bluemind/local/mode/ips.pm @@ -0,0 +1,96 @@ +# +# Copyright 2020 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::bluemind::local::mode::ips; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub prefix_ips_output { + my ($self, %options) = @_; + + return 'IMAP operations tracking '; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'bm_ips', type => 0, cb_prefix_output => 'prefix_ips_output' } + ]; + + $self->{maps_counters}->{bm_ips} = [ + { label => 'connections-active', nlabel => 'ips.connections.active.count', set => { + key_values => [ { name => 'active_connections' } ], + output_template => 'active connections: %s', + perfdatas => [ + { value => 'active_connections_absolute', template => '%s', min => 0 } + ] + } + } + ]; +} + +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 => { + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + # bm-ips.activeConnections,meterType=Gauge value=718 + my $result = $options{custom}->execute_command( + command => 'curl --unix-socket /var/run/bm-metrics/metrics-bm-ips.sock http://127.0.0.1/metrics', + filter => 'activeConnections' + ); + + $self->{bm_ips} = {}; + foreach (keys %$result) { + $self->{bm_ips}->{active_connections} = $result->{$_}->{value} if (/bm-ips\.activeConnections/); + } +} + +1; + +__END__ + +=head1 MODE + +Check IMAP operations tracking. + +=over 8 + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'active-connections'. + +=back + +=cut diff --git a/apps/bluemind/local/mode/lmtpd.pm b/apps/bluemind/local/mode/lmtpd.pm index 167d70c51..0a985bc71 100644 --- a/apps/bluemind/local/mode/lmtpd.pm +++ b/apps/bluemind/local/mode/lmtpd.pm @@ -73,7 +73,7 @@ sub set_counters { ] } }, - { label => 'emails-size-total', nlabel => 'lmtpd.emails.size.total.count', display_ok => 0, set => { + { label => 'emails-size-total', nlabel => 'lmtpd.emails.size.total.bytes', display_ok => 0, set => { key_values => [ { name => 'email_size', diff => 1 } ], output_template => 'total emails size: %s %s', output_change_bytes => 1, @@ -91,7 +91,7 @@ sub set_counters { } }, { label => 'sessions-duration-mean', nlabel => 'lmtpd.sessions.duration.mean.milliseconds', set => { - key_values => [ { name => 'session_duration_mean', diff => 1 } ], + key_values => [ { name => 'session_duration_mean' } ], output_template => 'mean sessions duration: %s ms', perfdatas => [ { value => 'session_duration_mean_absolute', template => '%s', min => 0, unit => 'ms' } @@ -107,7 +107,7 @@ sub set_counters { } }, { label => 'traffic-transport-latency-mean', nlabel => 'lmtpd.traffic.transport.latency.mean.milliseconds', set => { - key_values => [ { name => 'traffic_latency_mean', diff => 1 } ], + key_values => [ { name => 'traffic_latency_mean' } ], output_template => 'mean traffic transport latency: %s ms', perfdatas => [ { value => 'traffic_latency_mean_absolute', template => '%s', min => 0, unit => 'ms' } @@ -139,7 +139,7 @@ sub manage_selection { # bm-lmtpd.sessionDuration,meterType=Timer count=4941893,totalTime=1052591049892285,mean=212993492 # bm-lmtpd.traffic.transportLatency,meterType=Timer count=5017208,totalTime=272844528075000000,mean=54381745400 my $result = $options{custom}->execute_command( - command => 'curl --unix-socket /var/run/bm-metrics/bm-lmtpd.sock http://127.0.0.1/metrics', + command => 'curl --unix-socket /var/run/bm-metrics/metrics-bm-lmtpd.sock http://127.0.0.1/metrics', filter => 'activeConnections|connectionCount|deliveries|emailSize|sessionDuration|traffic\.transportLatency' ); @@ -150,11 +150,11 @@ sub manage_selection { $self->{bm_lmtpd}->{connections} = $result->{$_}->{count} if (/bm-lmtpd\.connectionCount/); $self->{bm_lmtpd}->{email_size} = $result->{$_}->{totalAmount} if (/bm-lmtpd\.emailSize/); if (/bm-lmtpd\.sessionDuration/) { - $self->{bm_lmtpd}->{session_duration_total} = $result->{$_}->{totalAmount} / 100000; + $self->{bm_lmtpd}->{session_duration_total} = $result->{$_}->{totalTime} / 100000; $self->{bm_lmtpd}->{session_duration_mean} = $result->{$_}->{mean} / 100000; } if (/bm-lmtpd\.traffic\.transportLatency/) { - $self->{bm_lmtpd}->{traffic_latency_total} = $result->{$_}->{totalAmount} / 100000; + $self->{bm_lmtpd}->{traffic_latency_total} = $result->{$_}->{totalTime} / 100000; $self->{bm_lmtpd}->{traffic_latency_mean} = $result->{$_}->{mean} / 100000; } } diff --git a/apps/bluemind/local/mode/milter.pm b/apps/bluemind/local/mode/milter.pm new file mode 100644 index 000000000..a762467f5 --- /dev/null +++ b/apps/bluemind/local/mode/milter.pm @@ -0,0 +1,168 @@ +# +# Copyright 2020 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::bluemind::local::mode::milter; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use Digest::MD5 qw(md5_hex); +use bigint; + +sub prefix_milter_output { + my ($self, %options) = @_; + + return 'Milter service '; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'bm_milter', type => 0, cb_prefix_output => 'prefix_milter_output' } + ]; + + $self->{maps_counters}->{bm_milter} = [ + { label => 'connections-total', nlabel => 'milter.connections.total.count', set => { + key_values => [ { name => 'connections', diff => 1 } ], + output_template => 'total connections: %s', + perfdatas => [ + { value => 'connections_absolute', template => '%s', min => 0 } + ] + } + }, + { label => 'traffic-class-inbound', nlabel => 'milter.traffic.class.inbound.count', display_ok => 0, set => { + key_values => [ { name => 'traffic_class_inbound', diff => 1 } ], + output_template => 'traffic class inbound: %s', + perfdatas => [ + { value => 'traffic_class_inbound_absolute', template => '%s', min => 0 } + ] + } + }, + { label => 'traffic-class-outbound', nlabel => 'milter.traffic.class.outbound.count', display_ok => 0, set => { + key_values => [ { name => 'traffic_class_outbound', diff => 1 } ], + output_template => 'traffic class outbound: %s', + perfdatas => [ + { value => 'traffic_class_outbound_absolute', template => '%s', min => 0 } + ] + } + }, + { label => 'traffic-size-inbound', nlabel => 'milter.traffic.size.inbound.bytes', display_ok => 0, set => { + key_values => [ { name => 'traffic_size_inbound', diff => 1 } ], + output_template => 'traffic size inbound: %s %s', + output_change_bytes => 1, + perfdatas => [ + { value => 'traffic_size_inbound_absolute', template => '%s', min => 0, unit => 'B' } + ] + } + }, + { label => 'traffic-size-outbound', nlabel => 'milter.traffic.size.outbound.bytes', display_ok => 0, set => { + key_values => [ { name => 'traffic_size_outbound', diff => 1 } ], + output_template => 'traffic size outbound: %s %s', + output_change_bytes => 1, + perfdatas => [ + { value => 'traffic_size_outbound_absolute', template => '%s', min => 0, unit => 'B' } + ] + } + }, + { label => 'sessions-duration-total', nlabel => 'milter.sessions.duration.total.milliseconds', display_ok => 0, set => { + key_values => [ { name => 'session_duration_total', diff => 1 } ], + output_template => 'total sessions duration: %s ms', + perfdatas => [ + { value => 'session_duration_total_absolute', template => '%s', min => 0, unit => 'ms' } + ] + } + }, + { label => 'sessions-duration-mean', nlabel => 'milter.sessions.duration.mean.milliseconds', set => { + key_values => [ { name => 'session_duration_mean' } ], + output_template => 'mean sessions duration: %s ms', + perfdatas => [ + { value => 'session_duration_mean_absolute', template => '%s', min => 0, unit => 'ms' } + ] + } + } + ]; +} + +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 => { + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + # bm-milter.connectionsCount,meterType=Counter count=2017123 + # bm-milter.sessionDuration,meterType=Timer count=11553431,totalTime=21943249233042775,mean=1899284224 + # bm-milter.traffic.class,type=INBOUND,meterType=Counter count=1289087 + # bm-milter.traffic.class,type=OUTBOUND,meterType=Counter count=415711 + # bm-milter.traffic.size,type=INBOUND,meterType=Counter count=29063863392 + # bm-milter.traffic.size,type=OUTBOUND,meterType=Counter count=10763275492 + my $result = $options{custom}->execute_command( + command => 'curl --unix-socket /var/run/bm-metrics/metrics-bm-milter.sock http://127.0.0.1/metrics', + filter => 'connectionsCount|sessionDuration|traffic\.class|traffic\.size' + ); + + $self->{bm_milter} = {}; + foreach (keys %$result) { + $self->{bm_milter}->{'traffic_class_' . lc($1)} = $result->{$_}->{count} if (/bm-milter\.traffic\.class.*type=(INBOUND|OUTBOUND)/i); + $self->{bm_milter}->{'traffic_size_' . lc($1)} = $result->{$_}->{count} if (/bm-milter\.traffic\.size.*type=(INBOUND|OUTBOUND)/i); + $self->{bm_milter}->{connections} = $result->{$_}->{count} if (/bm-milter\.connectionsCount/); + if (/bm-milter\.sessionDuration/) { + $self->{bm_milter}->{session_duration_total} = $result->{$_}->{totalTime} / 100000; + $self->{bm_milter}->{session_duration_mean} = $result->{$_}->{mean} / 100000; + } + } + + $self->{cache_name} = 'bluemind_' . $self->{mode} . '_' . $options{custom}->get_hostname() . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); +} + +1; + +__END__ + +=head1 MODE + +Check milter service. + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='^deliveries' + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'connections-total', 'traffic-class-inbound', 'traffic-class-outbound', +'traffic-size-inbound', 'traffic-size-outbound', 'sessions-duration-total', 'sessions-duration-mean' . + +=back + +=cut diff --git a/apps/bluemind/local/mode/webserver.pm b/apps/bluemind/local/mode/webserver.pm new file mode 100644 index 000000000..3e2aede4a --- /dev/null +++ b/apps/bluemind/local/mode/webserver.pm @@ -0,0 +1,152 @@ +# +# Copyright 2020 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::bluemind::local::mode::webserver; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use Digest::MD5 qw(md5_hex); +use bigint; + +sub prefix_webserver_output { + my ($self, %options) = @_; + + return 'Web application server '; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'bm_webserver', type => 0, cb_prefix_output => 'prefix_webserver_output' }, + ]; + + $self->{maps_counters}->{bm_webserver} = [ + { label => 'requests-time-total', nlabel => 'webserver.requests.time.milliseconds', display_ok => 0, set => { + key_values => [ { name => 'requests_time_total', diff => 1 } ], + output_template => 'total requests time: %s ms', + perfdatas => [ + { value => 'requests_time_total_absolute', template => '%s', min => 0, unit => 'ms' } + ] + } + }, + { label => 'requests-time-mean', nlabel => 'webserver.requests.time.mean.milliseconds', set => { + key_values => [ { name => 'requests_time_mean' } ], + output_template => 'mean requests time: %s ms', + perfdatas => [ + { value => 'requests_time_mean_absolute', template => '%s', min => 0, unit => 'ms' } + ] + } + }, + { label => 'requests-total', nlabel => 'webserver.requests.total.count', set => { + key_values => [ { name => 'requests', diff => 1 } ], + output_template => 'total requests: %s', + perfdatas => [ + { value => 'requests_absolute', template => '%s', min => 0 } + ] + } + }, + { label => 'requests-status-200', nlabel => 'webserver.requests.status.200.count', display_ok => 0, set => { + key_values => [ { name => 'requests_200', diff => 1 } ], + output_template => 'total 200 requests: %s', + perfdatas => [ + { value => 'requests_200_absolute', template => '%s', min => 0 } + ] + } + }, + { label => 'requests-status-304', nlabel => 'webserver.requests.status.304.count', display_ok => 0, set => { + key_values => [ { name => 'requests_304', diff => 1 } ], + output_template => 'total 304 requests: %s', + perfdatas => [ + { value => 'requests_304_absolute', template => '%s', min => 0 } + ] + } + } + ]; +} + +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 => { + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + # bm-webserver.appCache.requestTime,meterType=Timer count=91005,totalTime=46688008481,mean=513026 + # bm-webserver.appCache.requests,meterType=Counter count=8552 + # bm-webserver.staticFile.requests,status=200,meterType=Counter count=318881 + # bm-webserver.staticFile.requests,status=304,meterType=Counter count=3485778 + my $result = $options{custom}->execute_command( + command => 'curl --unix-socket /var/run/bm-metrics/metrics-bm-webserver.sock http://127.0.0.1/metrics', + filter => 'appCache|staticFile\.requests' + ); + + $self->{bm_webserver} = {}; + foreach (keys %$result) { + $self->{bm_webserver}->{'requests_' . $1} = $result->{$_}->{count} if (/bm-webserver\.staticFile\.requests.*,status=(200|304)/); + $self->{bm_webserver}->{requests} = $result->{$_}->{count} if (/bm-webserver\.appCache\.requests/); + + if (/bm-webserver\.appCache\.requestTime/) { + $self->{bm_webserver}->{requests_time_total} = $result->{$_}->{totalTime} / 100000; + $self->{bm_webserver}->{requests_time_mean} = $result->{$_}->{mean} / 100000; + } + } + + $self->{cache_name} = 'bluemind_' . $self->{mode} . '_' . $options{custom}->get_hostname() . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); +} + +1; + +__END__ + +=head1 MODE + +Check web application server. + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='requests-time-mean' + +=item B<--filter-upstream> + +Filter upstream name (can be a regexp). + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'requests-time-total', 'requests-time-mean', 'requests-total', +'requests-status-200', 'requests-status-304'. + +=back + +=cut diff --git a/apps/bluemind/local/mode/xmpp.pm b/apps/bluemind/local/mode/xmpp.pm index 5813b598e..859d394ce 100644 --- a/apps/bluemind/local/mode/xmpp.pm +++ b/apps/bluemind/local/mode/xmpp.pm @@ -77,7 +77,7 @@ sub manage_selection { # bm-xmpp.packetsCount,type=all,meterType=Counter count=517791 # bm-xmpp.packetsCount,type=chat,meterType=Counter count=12 my $result = $options{custom}->execute_command( - command => 'curl --unix-socket /var/run/bm-metrics/bm-xmpp.sock http://127.0.0.1/metrics', + command => 'curl --unix-socket /var/run/bm-metrics/metrics-bm-xmpp.sock http://127.0.0.1/metrics', filter => 'packetsCount' ); @@ -96,7 +96,7 @@ __END__ =head1 MODE -Check instant Messaging Service. +Check instant messaging service. =over 8 diff --git a/apps/bluemind/local/plugin.pm b/apps/bluemind/local/plugin.pm index 3f136b7f1..7fb8c72db 100644 --- a/apps/bluemind/local/plugin.pm +++ b/apps/bluemind/local/plugin.pm @@ -32,9 +32,14 @@ sub new { $self->{version} = '0.1'; $self->{modes} = { - 'core' => 'apps::bluemind::local::mode::core', - 'lmtpd' => 'apps::bluemind::local::mode::lmtpd', - 'xmpp' => 'apps::bluemind::local::mode::xmpp' + 'core' => 'apps::bluemind::local::mode::core', + 'eas' => 'apps::bluemind::local::mode::eas', + 'hps' => 'apps::bluemind::local::mode::hps', + 'ips' => 'apps::bluemind::local::mode::ips', + 'lmtpd' => 'apps::bluemind::local::mode::lmtpd', + 'milter' => 'apps::bluemind::local::mode::milter', + 'webserver' => 'apps::bluemind::local::mode::webserver', + 'xmpp' => 'apps::bluemind::local::mode::xmpp' }; $self->{custom_modes}{api} = 'apps::bluemind::local::custom::api'; From 03aacd0cc3c9e170747bb5bd1d8fd7d4593b9e2a Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 27 Apr 2020 16:44:29 +0200 Subject: [PATCH 151/283] fix eas bluemind unit --- apps/bluemind/local/mode/eas.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/bluemind/local/mode/eas.pm b/apps/bluemind/local/mode/eas.pm index 058038c0a..fec8f7651 100644 --- a/apps/bluemind/local/mode/eas.pm +++ b/apps/bluemind/local/mode/eas.pm @@ -41,7 +41,7 @@ sub set_counters { ]; $self->{maps_counters}->{bm_eas} = [ - { label => 'responses-size-total', nlabel => 'eas.responses.size.total.count', display_ok => 0, set => { + { label => 'responses-size-total', nlabel => 'eas.responses.size.total.bytes', display_ok => 0, set => { key_values => [ { name => 'response_size', diff => 1 } ], output_template => 'total responses size: %s %s', output_change_bytes => 1, From 82684694a2f3a1a2aa6aa79fa1fa032b6a73fbd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Rameau?= Date: Tue, 28 Apr 2020 10:59:57 +0200 Subject: [PATCH 152/283] Update disk.pm --- storage/emc/DataDomain/mode/components/disk.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/storage/emc/DataDomain/mode/components/disk.pm b/storage/emc/DataDomain/mode/components/disk.pm index 0bc969d3b..f519539d8 100644 --- a/storage/emc/DataDomain/mode/components/disk.pm +++ b/storage/emc/DataDomain/mode/components/disk.pm @@ -33,6 +33,9 @@ my %map_disk_status = ( 4 => 'failed', 5 => 'spare', # since OS 5.4 6 => 'available', # since OS 5.4 + 8 => 'raidReconstruction', # since OS 7.x + 9 => 'copyReconstruction', # since OS 7.x + 10 => 'system', # since OS 7.x ); sub load { @@ -74,4 +77,4 @@ sub check { } } -1; \ No newline at end of file +1; From b9e4f706b1406d5b15fdf6d5f0d663036357f439 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 28 Apr 2020 10:59:58 +0200 Subject: [PATCH 153/283] adva fsp150 wip --- network/adva/fsp150/snmp/mode/alarms.pm | 326 --------------- .../adva/fsp150/snmp/mode/components/card.pm | 106 +++++ .../fsp150/snmp/mode/components/resources.pm | 123 ++++++ .../adva/fsp150/snmp/mode/components/shelf.pm | 116 ++++++ network/adva/fsp150/snmp/mode/hardware.pm | 108 +++++ network/adva/fsp150/snmp/mode/interfaces.pm | 370 ------------------ .../adva/fsp150/snmp/mode/listinterfaces.pm | 160 -------- network/adva/fsp150/snmp/plugin.pm | 10 +- 8 files changed, 457 insertions(+), 862 deletions(-) delete mode 100644 network/adva/fsp150/snmp/mode/alarms.pm create mode 100644 network/adva/fsp150/snmp/mode/components/card.pm create mode 100644 network/adva/fsp150/snmp/mode/components/resources.pm create mode 100644 network/adva/fsp150/snmp/mode/components/shelf.pm create mode 100644 network/adva/fsp150/snmp/mode/hardware.pm delete mode 100644 network/adva/fsp150/snmp/mode/interfaces.pm delete mode 100644 network/adva/fsp150/snmp/mode/listinterfaces.pm diff --git a/network/adva/fsp150/snmp/mode/alarms.pm b/network/adva/fsp150/snmp/mode/alarms.pm deleted file mode 100644 index 7bbd27ee7..000000000 --- a/network/adva/fsp150/snmp/mode/alarms.pm +++ /dev/null @@ -1,326 +0,0 @@ -# -# Copyright 2020 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 network::adva::fsp150::snmp::mode::alarms; - -use base qw(centreon::plugins::templates::counter); - -use strict; -use warnings; -use centreon::plugins::misc; -use centreon::plugins::statefile; -use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold); - -sub custom_status_output { - my ($self, %options) = @_; - - my $msg = sprintf("alarm %s [severity: %s] [type: %s] %s", $self->{result_values}->{label}, $self->{result_values}->{severity}, - $self->{result_values}->{type}, $self->{result_values}->{generation_time}); - return $msg; -} - -sub custom_status_calc { - my ($self, %options) = @_; - - $self->{result_values}->{type} = $options{new_datas}->{$self->{instance} . '_type'}; - $self->{result_values}->{severity} = $options{new_datas}->{$self->{instance} . '_severity'}; - $self->{result_values}->{since} = $options{new_datas}->{$self->{instance} . '_since'}; - $self->{result_values}->{generation_time} = $options{new_datas}->{$self->{instance} . '_generation_time'}; - $self->{result_values}->{label} = $options{new_datas}->{$self->{instance} . '_label'}; - return 0; -} - - -sub set_counters { - my ($self, %options) = @_; - - $self->{maps_counters_type} = [ - { name => 'alarms', type => 2, message_multiple => '0 problem(s) detected', display_counter_problem => { label => 'alerts', min => 0 }, - group => [ { name => 'alarm', skipped_code => { -11 => 1 } } ] - } - ]; - - $self->{maps_counters}->{alarm} = [ - { label => 'status', threshold => 0, set => { - key_values => [ { name => 'severity' }, { name => 'type' }, { name => 'label'}, { name => 'since' }, { name => 'generation_time' } ], - closure_custom_calc => $self->can('custom_status_calc'), - closure_custom_output => $self->can('custom_status_output'), - closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => \&catalog_status_threshold, - } - }, - ]; -} - -sub new { - my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); - bless $self, $class; - - $options{options}->add_options(arguments => - { - "warning-status:s" => { name => 'warning_status', default => '%{severity} =~ /warning|minor/i' }, - "critical-status:s" => { name => 'critical_status', default => '%{severity} =~ /critical|major/i' }, - "memory" => { name => 'memory' }, - "timezone:s" => { name => 'timezone' }, - }); - - centreon::plugins::misc::mymodule_load(output => $self->{output}, module => 'DateTime', - error_msg => "Cannot load module 'DateTime'."); - $self->{statefile_cache} = centreon::plugins::statefile->new(%options); - return $self; -} - -sub check_options { - my ($self, %options) = @_; - $self->SUPER::check_options(%options); - - $self->change_macros(macros => ['warning_status', 'critical_status']); - if (defined($self->{option_results}->{memory})) { - $self->{statefile_cache}->check_options(%options); - } - - $self->{option_results}->{timezone} = 'GMT' if (!defined($self->{option_results}->{timezone}) || $self->{option_results}->{timezone} eq ''); -} - -my %map_type = ( - 0 => 'undefined', 5 => 'terminalLoopback', 6 => 'oosDisabled', 7 => 'oosManagement', 8 => 'oosMaintenance', 9 => 'oosAins', 10 => 'removed', - 11 => 'lossOfSignal', 12 => 'optInputPwrReceivedTooLow', 13 => 'optInputPwrReceivedTooHigh', 14 => 'laserTemperatureTooHigh', 15 => 'laserTemperatureTooLow', 16 => 'optOutputPowerTransTooLow', 17 => 'optOutputPowerTransTooHigh', - 18 => 'autoShutdownToHighTemp', 19 => 'autoShutdownToHighTxPwr', 20 => 'laserEndOfLife', 21 => 'serverSignalFailureVf', 22 => 'equalizationProgress', - 23 => 'uPortFailure', 24 => 'autoShutdownBlock', 25 => 'autoPowerShutdown', 26 => 'confOutPowerTransTooHigh', 27 => 'confOutPowerTransTooLow', - 28 => 'optSignalFailure', 29 => 'dsbdChannelPowerTooHigh', 30 => 'lossOfSignalCPort', 31 => 'lossOfSignalNPort', 32 => 'outputPowerFault', - 33 => 'eqlzAdjust', 34 => 'ampFailure', 35 => 'eqptProvMismatch', 36 => 'backreflectionTooHigh', 48 => 'fiberConnLos', 49 => 'fiberConnOptFault', - 50 => 'fiberConnInvalid', 51 => 'fiberConnMismatch', 52 => 'fiberConnCommError', 53 => 'fiberConnProtocolFailure', 54 => 'fiberConnDataFailure', - 55 => 'fiberAttenuationHigh', 57 => 'laserBiasCurrAbnormal', 58 => 'fiberConnInvalidTx', 59 => 'fiberConnMismatchTx', 60 => 'fiberAttenuationHighTx', - 61 => 'laserFailure', 62 => 'lossOfReceiverClockRecovery', 63 => 'fiberAttenuationCond', 64 => 'channelMismatch', 65 => 'alarmIndicationSignalLine', - 66 => 'alarmIndicationSignalLowerOrderPath', 67 => 'alarmIndicationSignalOdu', 68 => 'alarmIndicationSignalOpu', 69 => 'alarmIndicationSignalOtu', - 70 => 'alarmIndicationSignalHigherOrderPath', 71 => 'alarmIndicationSignalOduTcmA', 72 => 'alarmIndicationSignalOduTcmB', 73 => 'alarmIndicationSignalOduTcmC', 74 => 'virtualChannelAis', - 75 => 'amplifierAbnormal', 76 => 'automaticPowerReduction', 77 => 'automaticPowerReductionForEyeSafety', 80 => 'apsConfigMismatch', 81 => 'apsProtocolFailure', 82 => 'aseLow', - 83 => 'aseTableGenFailLow', 84 => 'aseTableGenFailHighBackreflection', 85 => 'aseTableGenFailOscMissing', 86 => 'aseTableGenFailPilot', 87 => 'aseTableGenFailSignalinput', - 88 => 'aseTableNotAvailable', 89 => 'aseTableGenProgress', 90 => 'encryptionPortAuthPasswdMissing', 92 => 'backwardDefectIndicationOdu', 93 => 'backwardDefectIndicationOtu', - 94 => 'backwardDefectIndicationOduTcmA', 95 => 'backwardDefectIndicationOduTcmB', 96 => 'backwardDefectIndicationOduTcmC', 97 => 'topologyDataCalculationInProgress', 99 => 'dispertionTunningCondition', 100 => 'lossOfCharSync', - 101 => 'lossOfCharSyncFromFarEnd', 103 => 'encryptionPortEncryptionSwitchOffEnabled', 104 => 'encryptionModuleCryPasswdMissing', 107 => 'encryptionModuleSelfTestStarted', 108 => 'encryptionPortEncryptionSwitchedOff', 109 => 'opuClientSignalFail', - 110 => 'databaseMismatch', 111 => 'databaseFailure', 112 => 'databaseNcuMismatch', 113 => 'dbReplicationIncompleted', 114 => 'databaseVersionMismatch', 115 => 'xfpDecisionThresSetFailed', 116 => 'duplexLinkFailure', 118 => 'singleFanFailure', - 119 => 'multipleFanFailure', 120 => 'lossOfSignalTransmitter', 122 => 'farEndIpAddressUnknown', 123 => 'farEndCommFailure', 125 => 'backupForcedToHalt', 127 => 'facilityForcedOn', 128 => 'fwdAseTableFailPilot', 129 => 'fwdAseTableOnPilot', - 131 => 'encryptionModuleFwpUpdateEnabled', 132 => 'fwpMismatchDownloadNotServiceAffecting', 133 => 'fwpMismatchDownloadServiceAffecting', 135 => 'gainTiltNotSettable', 136 => 'highBer', 137 => 'receiverOverloadProtection', 138 => 'hwInitializing', 139 => 'hwOprReachedHT', - 140 => 'hwDegrade', 141 => 'hwFailure', 142 => 'switchtoProtectionInhibited', 143 => 'switchtoWorkingInhibited', 148 => 'encryptionPortKeyInitExchgMissed', 149 => 'encryptionPortMaxKeyExchgFailuresReachedIs', 150 => 'encryptionPortMaxKeyExchgFailuresReachedOos', - 151 => 'encryptionPortKeyExchangedForced', 152 => 'laserOnDelay', 153 => 'lockedDefectOdu', 154 => 'lockedDefectOduTcmA', 155 => 'lockedDefectOduTcmB', 156 => 'lockedDefectOduTcmC', 157 => 'linkControlProtocolFailure', 158 => 'linkDown', 159 => 'autoShutdownSendingAisLine', - 160 => 'autoShutdownSendingAisOdu', 161 => 'autoShutdownSendingAisOpu', 162 => 'clientFailForwarding', 163 => 'autoShutdownAls', 164 => 'autoAmpShutdown', 165 => 'autoShutdownAmpAps', 166 => 'aseTableBuild', 167 => 'autoShutdownOpuClientSignalFail', 168 => 'autoShutdownSendingEPC', - 169 => 'autoShutdownSendingLckOdu', 170 => 'autoShutdownSendingOciOdu', 171 => 'autoShutdownLaserOffDueToErrFwd', 172 => 'autoShutdownTxRxLasersDueToHighTemp', 173 => 'localFault', 174 => 'localOscLevelAbnormal', 175 => 'lossOfGfpFrame', 176 => 'lossOfFrameMux', 177 => 'lossOfFrameOtu', - 178 => 'lossOfFrame', 179 => 'lossOfFrameLossOfMultiFrameOdu', 180 => 'lossOfLane', 181 => 'lossofMultiframeLowerOrderPath', 182 => 'lossOfMultiFrameOtu', 183 => 'lossofMultiframeHigherOrderPath', 184 => 'lossOfPointerLowerOrderPath', 185 => 'lossOfPointerHigherOrderPath', - 186 => 'losAttProgress', 187 => 'lossOsc', 188 => 'gfpLossOfClientSig', 189 => 'loopbackError', 190 => 'facilityLoopback', 191 => 'lossofTandemConnectionOduTcmA', 192 => 'lossofTandemConnectionOduTcmB', 193 => 'lossofTandemConnectionOduTcmC', 194 => 'mansw', 197 => 'equipmentNotAccepted', 198 => 'equipmentNotApproved', 199 => 'capabilityLevelMismatch', - 200 => 'equipmentMismatch', 201 => 'equipmentNotSupportedByPhysicalLayer', 202 => 'meaSwRevision', 203 => 'mismatch', 204 => 'midstageFault', 205 => 'multiplexStructureIdentifierMismatchOPU', 206 => 'backupNotResponding', 207 => 'openConnectionIndicationOdu', - 208 => 'openConnectionIndicationOduTcmA', 209 => 'openConnectionIndicationOduTcmB', 210 => 'openConnectionIndicationOduTcmC', 211 => 'oduTribMsiMismatch', 212 => 'transmitterDisabledOff', 213 => 'receiverDisabled', 214 => 'opmAbnormalCondition', 215 => 'faultOnOpm', 216 => 'thresOptPowerCtrlFailureHigh', - 217 => 'thresOptPowerCtrlFailureLow', 218 => 'txPowerLimited', 219 => 'oscOpticalPowerControlFailHigh', 220 => 'oscOpticalPowerControlFailLow', 221 => 'oTDRMeasuringinProgress', 222 => 'encryptionModuleCryPasswdError', 223 => 'peerLink', 224 => 'pilotReceiveLevelHigh', - 225 => 'lossOfPilotSignal', 226 => 'payloadMismatchGfp', 227 => 'payloadMismatchLowerOrderPath', 228 => 'payloadMismatchOPU', 229 => 'payloadMismatchHigherOrderPath', 230 => 'provPayloadMismatch', 231 => 'prbsLossOfSeqSynch', 232 => 'prbsRcvActivated', 233 => 'prbsTrmtActivated', 234 => 'protectionNotAvailable', 235 => 'powerSupplyUnitFailure', 236 => 'maxPowerConsProvModulesToHigh', - 237 => 'maxPowerConsEquipModulesToHigh', 238 => 'powerMissing', 239 => 'remoteDefectIndicationLine', 240 => 'remoteDefectIndicationLowerOrderPath', 241 => 'remoteDefectIndicationHigherOrderPath', 243 => 'dcnCommunicationFail', 244 => 'ntpForSchedEqlzRequired', 245 => 'signalDegradeOlm', 246 => 'signalDegradeLine', 247 => 'signalDegradationonLinkVector', - 248 => 'signalDegradeOdu', 249 => 'signalDegradeOtu', 250 => 'pcsSignalDegrade', 251 => 'signalDegradeScn', 252 => 'signalDegradeOduTcmA', 253 => 'signalDegradeOduTcmB', 254 => 'signalDegradeOduTcmC', 255 => 'encryptionModuleSelfTestFail', 256 => 'encryptionModuleSelfTestFailCritical', - 257 => 'signalFailureOnLink', 258 => 'signalFailureonLinkVector', 259 => 'signalFailureOPU', 260 => 'serverSignalFailTx', 261 => 'facilityDataRateNotSupported', 263 => 'lossofSequenceLowerOrderPath', 264 => 'lossofSequenceHigherOrderPath', 265 => 'serverSignalFail', 266 => 'serverSignalFailureGfp', - 267 => 'serverSignalFailureODU', 268 => 'serverSignalFailurePath', 269 => 'serverSignalFailureSectionRS', 272 => 'switchToDuplexInhibited', 274 => 'switchFailed', 276 => 'currentTooHigh', 277 => 'attOnReceiverFiberHigherThanMonitor', 278 => 'attOnReceiverFiberLowerThanMonitor', 279 => 'attOnTransmitterFiberHigherThanMonitor', - 280 => 'attOnTransmitterFiberLowerThanMonitor', 281 => 'thres15MinExceededOduBbe', 283 => 'thres15MinExceededOtuBbe', 285 => 'thres15MinExceededOduTcmABbe', 287 => 'thres15MinExceededOduTcmBBbe', 289 => 'thres15MinExceededOduTcmCBbe', 291 => 'thres15MinExceededFecBERCE', 293 => 'brPwrRxTooHigh', 294 => 'chromaticDispersionTooHigh', - 295 => 'chromaticDispersionTooLow', 296 => 'dispersionCompensationTooHigh', 297 => 'dispersionCompensationTooLow', 298 => 'thres15MinExceededFecCE', 300 => 'carrierFreqOffsetTooHigh', 301 => 'carrierFreqOffsetTooLow', 302 => 'thres15MinExceededSonetLineCV', 304 => 'thres15MinExceededPhysConvCV', - 306 => 'thres15MinExceededSonetSectCV', 308 => 'thres15MinExceededPhysConvDE', 310 => 'differentialGroupDelayTooHigh', 311 => 'thres15MinExceededFecES', 313 => 'thres15MinExceededSonetLineES', 315 => 'thres15MinExceededOduES', 317 => 'thres15MinExceededOtuES', - 319 => 'thres15MinExceededPhysConvES', 321 => 'thres15MinExceededSonetSectES', 323 => 'thres15MinExceededOduTcmAES', 325 => 'thres15MinExceededOduTcmBES', 327 => 'thres15MinExceededOduTcmCES', 329 => 'latencyTooHigh', 330 => 'latencyTooLow', 331 => 'laserBiasCurrentNormalizedtooHigh', 332 => 'localOscTemperatureTooHigh', 333 => 'localOscTemperatureTooLow', - 334 => 'pumpLaser1TempTooHigh', 335 => 'pumpLaser1TempTooLow', 336 => 'pumpLaser2TempTooHigh', 337 => 'pumpLaser2TempTooLow', 338 => 'pumpLaser3TempTooHigh', 339 => 'pumpLaser3TempTooLow', 340 => 'pumpLaser4TempTooHigh', 341 => 'pumpLaser4TempTooLow', 342 => 'oscPwrTooHigh', - 343 => 'oscPwrTooLow', 344 => 'ramanPumpPwrTooHigh', 345 => 'ramanPumpPwrTooLow', 346 => 'roundTripDelayTooHigh', 347 => 'roundTripDelayTooLow', 348 => 'thres15MinExceededSonetSectSEFS', 350 => 'thres15MinExceededFecSES', 352 => 'thres15MinExceededSonetLineSES', - 354 => 'thres15MinExceededOduSES', 356 => 'thres15MinExceededOtuSES', 358 => 'thres15MinExceededSonetSectSES', 360 => 'thres15MinExceededOduTcmASES', 362 => 'thres15MinExceededOduTcmBSES', 364 => 'thres15MinExceededOduTcmCSES', 366 => 'logicalLanesSkewTooHigh', - 367 => 'signalToNoiseRatioTooLow', 368 => 'subModuleTempTooHigh', 369 => 'temperatureTooHigh', 370 => 'temperatureTooLow', 371 => 'thres15MinExceededSonetLineUAS', 373 => 'thres15MinExceededOduUAS', 375 => 'thres15MinExceededOtuUAS', - 377 => 'thres15MinExceededOduTcmAUAS', 379 => 'thres15MinExceededOduTcmBUAS', 381 => 'thres15MinExceededOduTcmCUAS', 383 => 'thres15MinExceededFecUBE', 385 => 'encryptionModuleTamperDetected', 386 => 'thermoElectricCoolerEndOfLife', 387 => 'alarmInputTIF', 389 => 'traceIdentifierMismatchOdu', - 390 => 'traceIdentifierMismatchOtu', 391 => 'sectionTraceMismatch', 392 => 'traceIdentifierMismatchOduTcmA', 393 => 'traceIdentifierMismatchOduTcmB', 394 => 'traceIdentifierMismatchOduTcmC', 395 => 'turnupFailed', 396 => 'turnupCondition', 397 => 'unequippedLowerOrderPath', 398 => 'unequippedHigherOrderPath', 399 => 'voaControlFail', 400 => 'voltageOutOfRange', 401 => 'inputVoltageFailure', 402 => 'inputVoltageFailurePort1', - 403 => 'inputVoltageFailurePort2', 406 => 'wtrTimerRunning', 407 => 'lossOfLaneOtu', 408 => 'lossOfTestSeqSynchOpu', 409 => 'lossOfMfiOpu', 410 => 'oosDisabledLckOduTrmt', 411 => 'configurationMismatch', 412 => 'oduAutoShutdownRxAIS', 413 => 'oduAutoShutdownTxAIS', 414 => 'oosDisabledLckOduRx', 420 => 'thres15MinExceededBbePcs', - 422 => 'autoShutdownGAis', 423 => 'equipmentMismatchAllow', 424 => 'warmUp', 432 => 'networkPathRestricted', 434 => 'vfClientSignalFail', 435 => 'autoShutdownVfCSF', 439 => 'linkFailToPartner1', 440 => 'linkFailToPartner2', 441 => 'linkFailToPartner3', 442 => 'linkFailToPartner4', 443 => 'partnerUnavailable', - 445 => 'partner1Deleted', 446 => 'partner2Deleted', 447 => 'partner3Deleted', 448 => 'partner4Deleted', 450 => 'thres15MinExceededPhysConvSE', 452 => 'thres15MinExceededPhysConvCVDE', 456 => 'autoShutdownSendingOciOduTx', 457 => 'acpLinkLoss', 458 => 'acpChannelUnAvail', 459 => 'acpPartnerUnassigned', 460 => 'acpPartnerDeleted', 461 => 'thres15MinExceededCrcErrorsRcv', 463 => 'thres15MinExceededCrcFramesEgress', - 465 => 'autoServiceMismatch', 466 => 'batteryNoCharge', 469 => 'tagReceiveFail', 470 => 'tagReceiveFailMaxReached', 473 => 'internalEncryptionFail', 13006 => 'cfmRemoteDefectIndication', 13007 => 'cfmCcmMacStatus', 13008 => 'cfmCcmError', 13009 => 'cfmCcmLost', 13010 => 'cfmCcmXConn', 100005 => 'mepNotPresentL2', 100006 => 'priVidNotEqualExtVidL2', 100009 => 'sfCfmLevel0L2', 100010 => 'sfCfmLevel1L2', 100011 => 'sfCfmLevel2L2', - 100012 => 'sfCfmLevel3L2', 100013 => 'sfCfmLevel4L2 ', 100014 => 'sfCfmLevel5L2', 100015 => 'sfCfmLevel6L2', 100016 => 'sfCfmLevel7L2', 120004 => 'messageLossSpeq', 120005 => 'oscFiberMissingSpeq', 120006 => 'optLowSpeq', 120007 => 'ppcOutOfRangeSpeq', 120008 => 'gainTooHighSpeq', 120009 => 'gainTooLowSpeq', 120010 => 'gainAdoptFailedSpeq', 120011 => 'processLockedOutSpeq', 120012 => 'ppcLimitExceededSpeq', -); -my %map_severity = (1 => 'indeterminate', 2 => 'critical', 3 => 'major', 4 => 'minor', 5 => 'warning', 6 => 'cleared', 7 => 'notReported'); - -my $oids = { - alarmSysTable => { - oid => '.1.3.6.1.4.1.2544.1.11.7.4.1', label => 'sys', - mapping => { - severity => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.1.1.2', map => \%map_severity }, - timestamp => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.1.1.4' }, - } - }, - alarmEqptTable => { - oid => '.1.3.6.1.4.1.2544.1.11.7.4.5', label => 'eqpt', - mapping => { - severity => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.5.1.2', map => \%map_severity }, - timestamp => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.5.1.4' }, - } - }, - alarmFacilityTable => { - oid => '.1.3.6.1.4.1.2544.1.11.7.4.7', label => 'facility', - mapping => { - severity => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.7.1.2', map => \%map_severity }, - timestamp => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.7.1.4' }, - } - }, - alarmTerminPointTable => { - oid => '.1.3.6.1.4.1.2544.1.11.7.4.9', label => 'terminpoint', - mapping => { - severity => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.9.1.2', map => \%map_severity }, - timestamp => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.9.1.4' }, - } - }, - alarmExternalPortTable => { - oid => '.1.3.6.1.4.1.2544.1.11.7.4.11', label => 'externalport', - mapping => { - severity => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.11.1.2', map => \%map_severity }, - timestamp => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.11.1.4' }, - } - }, - alarmDcnTable => { - oid => '.1.3.6.1.4.1.2544.1.11.7.4.16', label => 'dcn', - mapping => { - severity => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.16.1.2', map => \%map_severity }, - timestamp => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.16.1.4' }, - } - }, - alarmEnvTable => { - oid => '.1.3.6.1.4.1.2544.1.11.7.4.20', label => 'env', - mapping => { - severity => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.20.1.2', map => \%map_severity }, - timestamp => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.20.1.4' }, - } - }, - alarmContainerTable => { - oid => '.1.3.6.1.4.1.2544.1.11.7.4.24', label => 'container', - mapping => { - severity => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.24.1.2', map => \%map_severity }, - timestamp => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.24.1.4' }, - } - }, - alarmOpticalMuxTable => { - oid => '.1.3.6.1.4.1.2544.1.11.7.4.28', label => 'opticalmux', - mapping => { - severity => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.28.1.2', map => \%map_severity }, - timestamp => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.28.1.4' }, - } - }, - alarmShelfConnTable => { - oid => '.1.3.6.1.4.1.2544.1.11.7.4.34', label => 'shelfconn', - mapping => { - severity => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.32.1.2', map => \%map_severity }, - timestamp => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.32.1.4' }, - } - }, - alarmNtpIPv4Table => { - oid => '.1.3.6.1.4.1.2544.1.11.7.4.36', label => 'ntpipv4', - mapping => { - severity => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.36.1.2', map => \%map_severity }, - timestamp => { oid => '.1.3.6.1.4.1.2544.1.11.7.4.36.1.4' }, - } - }, -}; - -sub manage_selection { - my ($self, %options) = @_; - - my $snmp_result = $options{snmp}->get_table(oid => '.1.3.6.1.4.1.2544.1.12.3.1.4.1.5'); - use Data::Dumper; print Data::Dumper::Dumper($snmp_result); - print unpack('B*', $snmp_result->{'.1.3.6.1.4.1.2544.1.12.3.1.4.1.5.1.1.5'}); - exit(1); - - $self->{alarms}->{global} = { alarm => {} }; - my $get_oids = []; - foreach (keys %$oids) { - push @$get_oids, { oid => $oids->{$_}->{oid} }; - } - my $snmp_result = $options{snmp}->get_multiple_table(oids => $get_oids); - - my $last_time; - if (defined($self->{option_results}->{memory})) { - $self->{statefile_cache}->read(statefile => "cache_adva_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port(). '_' . $self->{mode}); - $last_time = $self->{statefile_cache}->get(name => 'last_time'); - } - - my ($i, $current_time) = (1, time()); - - foreach (keys %$oids) { - my $branch_oid = $oids->{$_}->{oid}; - next if (!defined($snmp_result->{$branch_oid})); - - foreach my $oid (keys %{$snmp_result->{$branch_oid}}) { - next if ($oid !~ /^$oids->{$_}->{mapping}->{severity}->{oid}\.(.*)\.(.*?)$/); - my $instance = $1 . '.' . $2; - my $type = defined($map_type{$2}) ? $map_type{$2} : 'unknown'; - my $result = $options{snmp}->map_instance(mapping => $oids->{$_}->{mapping}, results => $snmp_result->{$branch_oid}, instance => $instance); - - my @date = unpack 'n C6 a C2', $result->{timestamp}; - my $timezone = $self->{option_results}->{timezone}; - if (defined($date[7])) { - $timezone = sprintf("%s%02d%02d", $date[7], $date[8], $date[9]); - } - - my $tz = centreon::plugins::misc::set_timezone(name => $timezone); - my $dt = DateTime->new(year => $date[0], month => $date[1], day => $date[2], hour => $date[3], minute => $date[4], second => $date[5], - %$tz); - - next if (defined($self->{option_results}->{memory}) && defined($last_time) && $last_time > $dt->epoch); - - my $diff_time = $current_time - $dt->epoch; - - $self->{alarms}->{global}->{alarm}->{$i} = { severity => $result->{severity}, - type => $type, since => $diff_time, - generation_time => centreon::plugins::misc::change_seconds(value => $diff_time), - label => $oids->{$_}->{label} - }; - $i++; - } - } - - if (defined($self->{option_results}->{memory})) { - $self->{statefile_cache}->write(data => { last_time => $current_time }); - } -} - -1; - -__END__ - -=head1 MODE - -Check alarms. - -=over 8 - -=item B<--warning-status> - -Set warning threshold for status (Default: '%{severity} =~ /warning|minor/i') -Can used special variables like: %{severity}, %{type}, %{label}, %{since} - -=item B<--critical-status> - -Set critical threshold for status (Default: '%{severity} =~ /critical|major/i'). -Can used special variables like: %{severity}, %{type}, %{label}, %{since} - -=item B<--timezone> - -Timezone options (the date from the equipment overload that option). Default is 'GMT'. - -=item B<--memory> - -Only check new alarms. - -=back - -=cut diff --git a/network/adva/fsp150/snmp/mode/components/card.pm b/network/adva/fsp150/snmp/mode/components/card.pm new file mode 100644 index 000000000..5d799452e --- /dev/null +++ b/network/adva/fsp150/snmp/mode/components/card.pm @@ -0,0 +1,106 @@ +# +# Copyright 2020 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 network::adva::fsp150::snmp::mode::components::card; + +use strict; +use warnings; +use network::adva::fsp150::snmp::mode::components::resources qw( + $map_card_type $oids + get_secondary_states +); + +my $mapping = { + slotEntityIndex => { oid => '.1.3.6.1.4.1.2544.1.12.3.1.3.1.2' }, + slotCardType => { oid => '.1.3.6.1.4.1.2544.1.12.3.1.3.1.4', map => $map_card_type }, + slotSecondaryState => { oid => '.1.3.6.1.4.1.2544.1.12.3.1.3.1.15' } +}; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, + { oid => $mapping->{slotEntityIndex}->{oid} }, + { oid => $mapping->{slotCardType}->{oid} }, + { oid => $mapping->{slotSecondaryState}->{oid} }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => 'checking cards'); + $self->{components}->{card} = { name => 'cards', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'card')); + + my $results = { + %{$self->{results}->{ $mapping->{slotEntityIndex}->{oid} }}, + %{$self->{results}->{ $mapping->{slotCardType}->{oid} }}, + %{$self->{results}->{ $mapping->{slotSecondaryState}->{oid} }} + }; + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %$results)) { + next if ($oid !~ /^$mapping->{slotEntityIndex}->{oid}\.(\d+)\.(\d+)\.(\d+)$/); + + my ($ne_index, $shelf_index, $card_index, $instance) = ($1, $2, $3, $1 . '.' . $2 . '.' . $3); + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $results, instance => $instance); + + my $ne_name = $self->{results}->{ $oids->{neName} }->{ $oids->{neName} . '.' . $ne_index }; + my $entity_name = $self->{results}->{ $oids->{entPhysicalName} }->{ $oids->{entPhysicalName} . '.' . $result->{slotEntityIndex} }; + my $name = $ne_name . ':' . $entity_name; + my $secondary_states = get_secondary_states(state => $result->{slotSecondaryState}); + + my $secondary_str = join(',', @$secondary_states); + if ($secondary_str =~ /mainteance/) { + $self->{output}->output_add( + long_msg => sprintf("skipping card '%s': in maintenance mode", $name) + ); + next; + } + + next if ($self->check_filter(section => 'card', instance => $result->{slotCardType} . '.' . $instance)); + $self->{components}->{card}->{total}++; + + $self->{output}->output_add( + long_msg => sprintf( + "card '%s' secondary status is '%s' [instance: %s].", + $name, + $secondary_str, + $result->{slotCardType} . '.' . $instance + ) + ); + + my $exit = 'ok'; + foreach (@$secondary_states) { + my $exit_tmp = $self->get_severity(label => 'secondary', section => 'card', instance => $result->{slotCardType} . '.' . $instance, value => $_); + $exit = $self->{output}->get_most_critical(status => [ $exit, $exit_tmp ]); + } + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "card '%s' secondary status is '%s'", + $name, + $secondary_str + ) + ); + } + } +} + +1; diff --git a/network/adva/fsp150/snmp/mode/components/resources.pm b/network/adva/fsp150/snmp/mode/components/resources.pm new file mode 100644 index 000000000..8570326be --- /dev/null +++ b/network/adva/fsp150/snmp/mode/components/resources.pm @@ -0,0 +1,123 @@ +# +# Copyright 2020 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 network::adva::fsp150::snmp::mode::components::resources; + +use strict; +use warnings; +use Exporter; + +our $map_admin_state; +our $map_oper_state; +our $bits_secondary_state; +our $map_card_type; +our $oids; + +our @ISA = qw(Exporter); +our @EXPORT_OK = qw( + $map_admin_state $map_oper_state $bits_secondary_state $map_card_type + $oids get_secondary_states +); + +$oids = { + neName => '.1.3.6.1.4.1.2544.1.12.3.1.1.1.2', + shelfEntityIndex => '.1.3.6.1.4.1.2544.1.12.3.1.2.1.2', + entPhysicalName => '.1.3.6.1.2.1.47.1.1.1.1.7' +}; + +$map_admin_state = { + 1 => 'in-service', 2 => 'management', + 3 => 'maintenance', 4 => 'disabled', + 5 => 'unassigned', 6 => 'monitored' +}; +$map_oper_state = { + 1 => 'normal', 2 => 'outage' +}; +$bits_secondary_state = { + 0 => 'not-applicable', 1 => 'active', + 2 => 'automaticinservice', 3 => 'facilityfailure', + 4 => 'fault', 5 => 'loopback', 6 => 'maintenance', + 7 => 'mismatchedeqpt', 8 => 'standbyhot', + 9 => 'supportingentityoutage', 10 => 'unassigned', + 11 => 'unequipped', 12 => 'disabled', + 13 => 'forcedoffline', 14 => 'initializing', + 15 => 'prtcl', 16 => 'blckd', 17 => 'mon-tx', + 18 => 'mir-rx', 19 => 'cema', 20 => 'lkdo', + 21 => 'nomber' +}; +$map_card_type = { + 1 => 'none', 2 => 'psu', 3 => 'fan', 4 => 'nemi', + 5 => 'scu', 6 => 'eth-10-100-1000-ntu', 7 => 'eth-cpmr', + 8 => 'eth-ge-101', 9 => 'eth-ge-206', 10 => 'eth-ge-201', + 11 => 'eth-ge-201se', 12 => 'eth-10-100-1000-nte', + 13 => 'scu-t', 14 => 'eth-ge-206f', 15 => 'eth-xg-1x', + 16 => 'swf-140g', 17 => 'stu', 18 => 'eth-ge-10s', + 19 => 'ami', 20 => 'sti', 21 => 'eth-ge-112', + 22 => 'eth-ge-114', 23 => 'eth-ge-206v', + 24 => 'eth-ge-4e-cc', 25 => 'eth-ge-4s-cc', + 26 => 'eth-xg-210', 27 => 'eth-xg-1x-cc', + 28 => 'eth-xg-1s-cc', 29 => 'stm1-4-et', + 30 => 'pwe3-ocnstm', 31 => 'pwe3-e1t1', 32 => 'eth-xg-1x-h', + 33 => 'eth-ge-10s-h', 34 => 'eth-t1804', 35 => 'eth-t3204', + 36 => 'eth-ge-syncprobe', 37 => 'eth-ge-8s-cc', + 38 => 'eth-ge-114h', 39 => 'eth-ge-114ph', + 40 => 'eth-fe-36e', 41 => 'eth-ge-114sh', + 42 => 'eth-ge-114s', 43 => 'sti-h', 44 => 'stu-h', + 45 => 'eth-ge-8e-cc', 46 => 'eth-sh1pcs', 47 => 'eth-osa5411', + 48 => 'ethGe112Pro', 49 => 'ethGe112ProM', + 50 => 'ethGe114Pro', 51 => 'ethGe114ProC', + 52 => 'ethGe114ProSH', 53 => 'ethGe114ProCSH', + 54 => 'ethGe114ProHE', 55 => 'ethGe112ProH', + 56 => 'eth-xg-210c', 57 => 'eth-ge-8sc-cc', + 58 => 'eth-osa5420', 59 => 'eth-osa5421', + 60 => 'bits-x16', 61 => 'eth-ge-114g', + 62 => 'ethGe114ProVmH', 63 => 'ethGe114ProVmCH', + 64 => 'ethGe114ProVmCSH', 65 => 'serverCard', + 66 => 'eth-ptpv2-osa', 67 => 'gnss-osa', + 68 => 'thc-osa', 69 => 'sgc-osa', 70 => 'pps-x16', + 71 => 'clk-x16', 72 => 'todAndPps-x16', 73 => 'eth-ge-101pro', + 74 => 'ethgo102proS',75 => 'ethgo102proSP', + 76 => 'ethcx101pro30A', 77 => 'ethcx102pro30A', + 78 => 'osa-ge-4s', 79 => 'eth-xg-116pro', + 80 => 'eth-xg-120pro', 81 => 'ethGe112ProVm', + 82 => 'eth-osa5401', 83 => 'eth-osa5405', + 84 => 'eth-csm', 85 => 'aux-osa', 86 => 'bits-x16-enhanced', + 87 => 'osa-ge-4s-protected', 88 => 'eth-ge-102pro-h', + 89 => 'eth-ge-102pro-efmh', 90 => 'eth-xg-116pro-h', + 91 => 'ethgo102proSM', 92 => 'eth-xg-118pro-sh', + 93 => 'eth-xg-118proac-sh', 94 => 'ethGe114ProVmSH', + 95 => 'ethGe104', 96 => 'eth-xg-120pro-sh' +}; + +sub get_secondary_states { + my (%options) = @_; + + my @bits_str = split //, unpack('B*', $options{state}); + my $results = []; + foreach (keys %$bits_secondary_state) { + if ($bits_str[$_]) { + push @$results, $bits_secondary_state->{$_}; + } + } + + return $results; +} + +1; diff --git a/network/adva/fsp150/snmp/mode/components/shelf.pm b/network/adva/fsp150/snmp/mode/components/shelf.pm new file mode 100644 index 000000000..e8de6f13b --- /dev/null +++ b/network/adva/fsp150/snmp/mode/components/shelf.pm @@ -0,0 +1,116 @@ +# +# Copyright 2020 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 network::adva::fsp150::snmp::mode::components::shelf; + +use strict; +use warnings; +use network::adva::fsp150::snmp::mode::components::resources qw( + $map_admin_state $map_oper_state $oids + get_secondary_states +); + +my $mapping = { + shelfEntityIndex => { oid => $oids->{shelfEntityIndex} }, + shelfAdminState => { oid => '.1.3.6.1.4.1.2544.1.12.3.1.2.1.8', map => $map_admin_state }, + shelfOperationalState => { oid => '.1.3.6.1.4.1.2544.1.12.3.1.2.1.9', map => $map_oper_state }, + shelfSecondaryState => { oid => '.1.3.6.1.4.1.2544.1.12.3.1.2.1.10' } +}; +my $oid_shelfEntry = '.1.3.6.1.4.1.2544.1.12.3.1.2.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { + oid => $oid_shelfEntry, + start => $mapping->{shelfAdminState}->{oid}, + end => $mapping->{shelfSecondaryState}->{oid} + }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => 'checking shelfs'); + $self->{components}->{shelf} = { name => 'shelfs', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'shelf')); + + $self->{results}->{$oid_shelfEntry} = { %{$self->{results}->{$oid_shelfEntry}}, %{$self->{results}->{ $oids->{shelfEntityIndex} }} }; + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_shelfEntry}})) { + next if ($oid !~ /^$mapping->{shelfAdminState}->{oid}\.(.*?)\.(.*)$/); + + my ($ne_index, $shelf_index, $instance) = ($1, $2, $1 . '.' . $2); + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_shelfEntry}, instance => $instance); + + my $ne_name = $self->{results}->{ $oids->{neName} }->{ $oids->{neName} . '.' . $ne_index }; + my $entity_name = $self->{results}->{ $oids->{entPhysicalName} }->{ $oids->{entPhysicalName} . '.' . $result->{shelfEntityIndex} }; + my $name = $ne_name . ':' . $entity_name; + + if ($result->{shelfAdminState} eq 'maintenance') { + $self->{output}->output_add( + long_msg => sprintf("skipping shelf '%s': in maintenance mode", $name) + ); + next; + } + + next if ($self->check_filter(section => 'shelf', instance => $instance)); + $self->{components}->{shelf}->{total}++; + + my $secondary_states = get_secondary_states(state => $result->{shelfSecondaryState}); + $self->{output}->output_add( + long_msg => sprintf( + "shelf '%s' operational status is '%s' [secondary status: %s][instance: %s].", + $name, + $result->{shelfOperationalState}, + join(',', @$secondary_states), + $instance + ) + ); + my $exit = $self->get_severity(label => 'operational', section => 'shelf', value => $result->{shelfOperationalState}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "shelf '%s' operational status is '%s'", + $name, + $result->{shelfOperationalState} + ) + ); + } + + $exit = 'ok'; + foreach (@$secondary_states) { + my $exit_tmp = $self->get_severity(label => 'secondary', section => 'shelf', instance => $instance, value => $_); + $exit = $self->{output}->get_most_critical(status => [ $exit, $exit_tmp ]); + } + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "shelf '%s' secondary status is '%s'", + $name, + join(',', @$secondary_states) + ) + ); + } + } +} + +1; diff --git a/network/adva/fsp150/snmp/mode/hardware.pm b/network/adva/fsp150/snmp/mode/hardware.pm new file mode 100644 index 000000000..82887d745 --- /dev/null +++ b/network/adva/fsp150/snmp/mode/hardware.pm @@ -0,0 +1,108 @@ +# +# Copyright 2020 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 network::adva::fsp150::snmp::mode::hardware; + +use base qw(centreon::plugins::templates::hardware); + +use strict; +use warnings; +use network::adva::fsp150::snmp::mode::components::resources qw($oids); + +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_overload_check_section_option} = + '^(?:shefl|card)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + operational => [ + ['normal', 'OK'], + ['outage', 'CRITICAL'], + ], + secondary => [ + ['fault', 'CRITICAL'], + ['facilityfailure', 'CRITICAL'], + ['.*', 'OK'] + ] + }; + + $self->{components_path} = 'network::adva::fsp150::snmp::mode::components'; + $self->{components_module} = ['shelf', 'card']; +} + +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + push @{$self->{request}}, + { oid => $oids->{neName} }, + { oid => $oids->{shelfEntityIndex} }, + { oid => $oids->{entPhysicalName} }; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1, no_performance => 1, force_new_perfdata => 1); + bless $self, $class; + + $options{options}->add_options(arguments => { + }); + + return $self; +} + +1; + +__END__ + +=head1 MODE + +Check hardware. + +=over 8 + +=item B<--component> + +Which component to check (Default: '.*'). +Can be: 'shelf', 'card'. + +=item B<--filter> + +Exclude some parts (comma seperated list) (Example: --filter=shelf) +Can also exclude specific instance: --filter=card,psu.1.1.4 + +=item B<--no-component> + +Return an error if no compenents are checked. +If total (with skipped) is 0. (Default: 'critical' returns). + +=item B<--threshold-overload> + +Set to overload default threshold values (syntax: section,[instance,]status,regexp) +It used before default thresholds (order stays). +Example: --threshold-overload='card,WARNING,initializing' + +=back + +=cut diff --git a/network/adva/fsp150/snmp/mode/interfaces.pm b/network/adva/fsp150/snmp/mode/interfaces.pm deleted file mode 100644 index c5d33d00f..000000000 --- a/network/adva/fsp150/snmp/mode/interfaces.pm +++ /dev/null @@ -1,370 +0,0 @@ -# -# Copyright 2020 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 network::adva::fsp3000::snmp::mode::interfaces; - -use base qw(snmp_standard::mode::interfaces); - -use strict; -use warnings; - -sub set_oids_traffic { - my ($self, %options) = @_; - - $self->{currentEthRx15minBytes} = '.1.3.6.1.4.1.2544.1.11.2.6.2.52.1.5'; # in B - $self->{currentEthRx1dayBytes} = '.1.3.6.1.4.1.2544.1.11.2.6.2.53.1.5'; # in B - $self->{currentEthTx15minBytes} = '.1.3.6.1.4.1.2544.1.11.2.6.2.56.1.3'; # in B - $self->{currentEthTx1dayBytes} = '.1.3.6.1.4.1.2544.1.11.2.6.2.57.1.3'; # in B - $self->{currentEthRxHighSpeed15minBytes} = '.1.3.6.1.4.1.2544.1.11.2.6.2.88.1.4'; # in B - $self->{currentEthRxHighSpeed1dayBytes} = '.1.3.6.1.4.1.2544.1.11.2.6.2.89.1.4'; # in B -} - -sub set_counters_traffic { - my ($self, %options) = @_; - - push @{$self->{maps_counters}->{int}}, - { label => 'traffic-in', filter => 'add_traffic', nlabel => 'interface.traffic.in.bitspersecond', set => { - key_values => [ { name => 'traffic_in_15min', diff => 1 }, { name => 'traffic_in_1day', diff => 1 }, { name => 'speed_in'}, { name => 'display' } ], - per_second => 1, - closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'in' }, - closure_custom_output => $self->can('custom_traffic_output'), output_error_template => 'Traffic In : %s', - closure_custom_perfdata => $self->can('custom_traffic_perfdata'), - closure_custom_threshold_check => $self->can('custom_traffic_threshold'), - } - }, - { label => 'traffic-out', filter => 'add_traffic', nlabel => 'interface.traffic.out.bitspersecond', set => { - key_values => [ { name => 'traffic_out_15min', diff => 1 }, { name => 'traffic_out_1day', diff => 1 }, { name => 'speed_out'}, { name => 'display' } ], - per_second => 1, - closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'out' }, - closure_custom_output => $self->can('custom_traffic_output'), output_error_template => 'Traffic Out : %s', - closure_custom_perfdata => $self->can('custom_traffic_perfdata'), - closure_custom_threshold_check => $self->can('custom_traffic_threshold'), - } - }, - ; -} - -sub set_counters { - my ($self, %options) = @_; - - $self->SUPER::set_counters(%options); - - push @{$self->{maps_counters}->{int}}, - { label => 'laser-temp', filter => 'add_optical', nlabel => 'interface.laser.temperature.celsius', set => { - key_values => [ { name => 'laser_temp' }, { name => 'display' } ], - output_template => 'Laser Temperature : %.2f C', output_error_template => 'Laser Temperature : %.2f', - perfdatas => [ - { label => 'laser_temp', value => 'laser_temp_absolute', template => '%.2f', - unit => 'C', label_extra_instance => 1, instance_use => 'display_absolute' }, - ], - } - }, - { label => 'input-power', filter => 'add_optical', nlabel => 'interface.input.power.dbm', set => { - key_values => [ { name => 'input_power' }, { name => 'display' } ], - output_template => 'Input Power : %s dBm', output_error_template => 'Input Power : %s', - perfdatas => [ - { label => 'input_power', value => 'input_power_absolute', template => '%s', - unit => 'dBm', label_extra_instance => 1, instance_use => 'display_absolute' }, - ], - } - }, - { label => 'output-power', filter => 'add_optical', nlabel => 'interface.output.power.dbm', set => { - key_values => [ { name => 'output_power' }, { name => 'display' } ], - output_template => 'Output Power : %s dBm', output_error_template => 'Output Power : %s', - perfdatas => [ - { label => 'output_power', value => 'output_power_absolute', template => '%s', - unit => 'dBm', label_extra_instance => 1, instance_use => 'display_absolute' }, - ], - } - }, - ; -} - -sub custom_traffic_perfdata { - my ($self, %options) = @_; - - my ($warning, $critical); - if ($self->{instance_mode}->{option_results}->{units_traffic} eq '%' && defined($self->{result_values}->{speed})) { - $warning = $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, total => $self->{result_values}->{speed}, cast_int => 1); - $critical = $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, total => $self->{result_values}->{speed}, cast_int => 1); - } elsif ($self->{instance_mode}->{option_results}->{units_traffic} eq 'b/s') { - $warning = $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}); - $critical = $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}); - } - - $self->{output}->perfdata_add( - label => 'traffic_' . $self->{result_values}->{label}, unit => 'b/s', - nlabel => $self->{nlabel}, - instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef, - value => sprintf("%.2f", $self->{result_values}->{traffic_per_seconds}), - warning => $warning, - critical => $critical, - min => 0, max => $self->{result_values}->{speed} - ); -} - -sub custom_traffic_threshold { - my ($self, %options) = @_; - - my $exit = 'ok'; - if ($self->{instance_mode}->{option_results}->{units_traffic} eq '%' && defined($self->{result_values}->{speed})) { - $exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{traffic_prct}, threshold => [ { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' } ]); - } elsif ($self->{instance_mode}->{option_results}->{units_traffic} eq 'b/s') { - $exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{traffic_per_seconds}, threshold => [ { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' } ]); - } - return $exit; -} - -sub custom_traffic_output { - my ($self, %options) = @_; - - my $label = $self->{result_values}->{label}; - $label =~ s/_/ /g; - $label =~ s/(\w+)/\u$1/g; - my ($traffic_value, $traffic_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{traffic_per_seconds}, network => 1); - my $msg = sprintf("Traffic %s : %s/s (%s)", - $label, $traffic_value . $traffic_unit, - defined($self->{result_values}->{traffic_prct}) ? sprintf("%.2f%%", $self->{result_values}->{traffic_prct}) : '-'); - return $msg; -} - -sub custom_traffic_calc { - my ($self, %options) = @_; - - return -10 if (defined($self->{instance_mode}->{last_status}) && $self->{instance_mode}->{last_status} == 0); - - # we choose the performance value (1day is updated every 15 minutes. 15min is updated all the time but reset every 15min - my $counter = 'traffic_' . $options{extra_options}->{label_ref} . '_15min'; - if ($options{delta_time} >= 600) { - $counter = 'traffic_' . $options{extra_options}->{label_ref} . '_1day'; - } - - my $diff_traffic = ($options{new_datas}->{$self->{instance} . '_' . $counter} - $options{old_datas}->{$self->{instance} . '_' . $counter}); - - $self->{result_values}->{traffic_per_seconds} = $diff_traffic / $options{delta_time}; - if (defined($options{new_datas}->{$self->{instance} . '_speed_' . $options{extra_options}->{label_ref}}) && - $options{new_datas}->{$self->{instance} . '_speed_' . $options{extra_options}->{label_ref}} > 0) { - $self->{result_values}->{traffic_prct} = $self->{result_values}->{traffic_per_seconds} * 100 / $options{new_datas}->{$self->{instance} . '_speed_' . $options{extra_options}->{label_ref}}; - $self->{result_values}->{speed} = $options{new_datas}->{$self->{instance} . '_speed_' . $options{extra_options}->{label_ref}}; - } - - $self->{result_values}->{label} = $options{extra_options}->{label_ref}; - $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; - return 0; -} - -sub new { - my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_set_traffic => 1, no_errors => 1, no_cast => 1); - bless $self, $class; - - $options{options}->add_options(arguments => { - 'add-optical' => { name => 'add_optical' }, - } - ); - - return $self; -} - -sub check_options { - my ($self, %options) = @_; - $self->SUPER::check_options(%options); - - $self->{checking} = ''; - foreach (('add_global', 'add_status', 'add_traffic', 'add_speed', 'add_volume', 'add_optical')) { - if (defined($self->{option_results}->{$_})) { - $self->{checking} .= $_; - } - } -} - -my $oid_opticalIfDiagLaserTemp = '.1.3.6.1.4.1.2544.1.11.2.4.3.5.1.2'; -my $oid_opticalIfDiagInputPower = '.1.3.6.1.4.1.2544.1.11.2.4.3.5.1.3'; -my $oid_opticalIfDiagOutputPower = '.1.3.6.1.4.1.2544.1.11.2.4.3.5.1.4'; - -sub custom_load { - my ($self, %options) = @_; - - return if (!defined($self->{option_results}->{add_optical})); - - $self->{snmp}->load(oids => [$oid_opticalIfDiagLaserTemp, $oid_opticalIfDiagInputPower, $oid_opticalIfDiagOutputPower], - instances => $self->{array_interface_selected}); -} - -sub custom_add_result { - my ($self, %options) = @_; - - return if (!defined($self->{option_results}->{add_optical})); - $self->{int}->{$options{instance}}->{laser_temp} = undef; - if (defined($self->{results}->{$oid_opticalIfDiagLaserTemp . '.' . $options{instance}}) && - $self->{results}->{$oid_opticalIfDiagLaserTemp . '.' . $options{instance}} != -2147483648) { - $self->{int}->{$options{instance}}->{laser_temp} = $self->{results}->{$oid_opticalIfDiagLaserTemp . '.' . $options{instance}} * 0.1; - } - - $self->{int}->{$options{instance}}->{input_power} = undef; - if (defined($self->{results}->{$oid_opticalIfDiagInputPower . '.' . $options{instance}}) && - $self->{results}->{$oid_opticalIfDiagInputPower . '.' . $options{instance}} != -65535) { - $self->{int}->{$options{instance}}->{input_power} = $self->{results}->{$oid_opticalIfDiagInputPower . '.' . $options{instance}} / 10; - } - - $self->{int}->{$options{instance}}->{output_power} = undef; - if (defined($self->{results}->{$oid_opticalIfDiagOutputPower . '.' . $options{instance}}) && - $self->{results}->{$oid_opticalIfDiagOutputPower . '.' . $options{instance}} != -65535) { - $self->{int}->{$options{instance}}->{output_power} = $self->{results}->{$oid_opticalIfDiagOutputPower . '.' . $options{instance}} / 10; - } -} - -sub load_traffic { - my ($self, %options) = @_; - - if ($self->{snmp}->is_snmpv1()) { - $self->{output}->add_option_msg(short_msg => "Can't check SNMP 64 bits counters with SNMPv1."); - $self->{output}->option_exit(); - } - - $self->set_oids_traffic(); - $self->{snmp}->load(oids => [$self->{currentEthRx15minBytes}, $self->{currentEthRx1dayBytes}, - $self->{currentEthTx15minBytes}, $self->{currentEthTx1dayBytes}, - $self->{currentEthRxHighSpeed15minBytes}, $self->{currentEthRxHighSpeed1dayBytes}], instances => $self->{array_interface_selected}); -} - -sub add_result_traffic { - my ($self, %options) = @_; - - $self->{int}->{$options{instance}}->{traffic_in_15min} = - defined($self->{results}->{$self->{currentEthRxHighSpeed15minBytes} . '.' . $options{instance}}) ? $self->{results}->{$self->{currentEthRxHighSpeed15minBytes} . '.' . $options{instance}} * 8 : - (defined($self->{results}->{$self->{currentEthRx15minBytes} . '.' . $options{instance}}) ? $self->{results}->{$self->{currentEthRx15minBytes} . '.' . $options{instance}} * 8 : undef); - $self->{int}->{$options{instance}}->{traffic_in_1day} = - defined($self->{results}->{$self->{currentEthRxHighSpeed1dayBytes} . '.' . $options{instance}}) ? $self->{results}->{$self->{currentEthRxHighSpeed1dayBytes} . '.' . $options{instance}} * 8 : - (defined($self->{results}->{$self->{currentEthRx1dayBytes} . '.' . $options{instance}}) ? $self->{results}->{$self->{currentEthRx1dayBytes} . '.' . $options{instance}} * 8 : undef); - $self->{int}->{$options{instance}}->{traffic_out_15min} = - defined($self->{results}->{$self->{currentEthTx15minBytes} . '.' . $options{instance}}) ? $self->{results}->{$self->{currentEthTx15minBytes} . '.' . $options{instance}} * 8 : undef; - $self->{int}->{$options{instance}}->{traffic_out_1day} = - defined($self->{results}->{$self->{currentEthTx1dayBytes} . '.' . $options{instance}}) ? $self->{results}->{$self->{currentEthTx1dayBytes} . '.' . $options{instance}} * 8 : undef; - - $self->{int}->{$options{instance}}->{speed_in} = 0; - $self->{int}->{$options{instance}}->{speed_out} = 0; - if ($self->{get_speed} == 0) { - if (defined($self->{option_results}->{speed}) && $self->{option_results}->{speed} ne '') { - $self->{int}->{$options{instance}}->{speed_in} = $self->{option_results}->{speed} * 1000000; - $self->{int}->{$options{instance}}->{speed_out} = $self->{option_results}->{speed} * 1000000; - } - $self->{int}->{$options{instance}}->{speed_in} = $self->{option_results}->{speed_in} * 1000000 if (defined($self->{option_results}->{speed_in}) && $self->{option_results}->{speed_in} ne ''); - $self->{int}->{$options{instance}}->{speed_out} = $self->{option_results}->{speed_out} * 1000000 if (defined($self->{option_results}->{speed_out}) && $self->{option_results}->{speed_out} ne ''); - } -} - -1; - -__END__ - -=head1 MODE - -Check interfaces. - -=over 8 - -=item B<--add-status> - -Check interface status. - -=item B<--add-traffic> - -Check interface traffic. - -=item B<--add-optical> - -Check interface optical. - -=item B<--warning-status> - -Set warning threshold for status. -Can used special variables like: %{admstatus}, %{opstatus}, %{display} - -=item B<--critical-status> - -Set critical threshold for status (Default: '%{admstatus} eq "up" and %{opstatus} ne "up"'). -Can used special variables like: %{admstatus}, %{opstatus}, %{display} - -=item B<--warning-*> - -Threshold warning. -Can be: 'laser-temp', 'input-power', 'output-power', 'traffic-in', 'traffic-out'. - -=item B<--critical-*> - -Threshold critical. -Can be: 'laser-temp', 'input-power', 'output-power', 'traffic-in', 'traffic-out'. - -=item B<--units-traffic> - -Units of thresholds for the traffic (Default: '%') ('%', 'b/s'). - -=item B<--interface> - -Set the interface (number expected) ex: 1,2,... (empty means 'check all interface'). - -=item B<--name> - -Allows to use interface name with option --interface instead of interface oid index (Can be a regexp) - -=item B<--speed> - -Set interface speed for incoming/outgoing traffic (in Mb). - -=item B<--speed-in> - -Set interface speed for incoming traffic (in Mb). - -=item B<--speed-out> - -Set interface speed for outgoing traffic (in Mb). - -=item B<--reload-cache-time> - -Time in minutes before reloading cache file (default: 180). - -=item B<--oid-filter> - -Choose OID used to filter interface (default: ifName) (values: ifDesc, ifAlias, ifName). - -=item B<--oid-display> - -Choose OID used to display interface (default: ifName) (values: ifDesc, ifAlias, ifName). - -=item B<--oid-extra-display> - -Add an OID to display. - -=item B<--display-transform-src> - -Regexp src to transform display value. - -=item B<--display-transform-dst> - -Regexp dst to transform display value. - -=item B<--show-cache> - -Display cache interface datas. - -=back - -=cut diff --git a/network/adva/fsp150/snmp/mode/listinterfaces.pm b/network/adva/fsp150/snmp/mode/listinterfaces.pm deleted file mode 100644 index 167bfa0bc..000000000 --- a/network/adva/fsp150/snmp/mode/listinterfaces.pm +++ /dev/null @@ -1,160 +0,0 @@ -# -# Copyright 2020 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 network::adva::fsp3000::snmp::mode::listinterfaces; - -use base qw(snmp_standard::mode::listinterfaces); - -use strict; -use warnings; - -my $mapping = { - advaInventoryAidString => { oid => '.1.3.6.1.4.1.2544.1.11.7.10.1.1.6' }, - advaInventoryUnitName => { oid => '.1.3.6.1.4.1.2544.1.11.7.10.1.1.7' }, -}; - -sub set_oids_label { - my ($self, %options) = @_; - - $self->{oids_label} = { - 'ifdesc' => '.1.3.6.1.2.1.2.2.1.2', - 'ifalias' => '.1.3.6.1.2.1.31.1.1.1.18', - }; -} - -sub default_oid_filter_name { - my ($self, %options) = @_; - - return 'ifdesc'; -} - -sub default_oid_display_name { - my ($self, %options) = @_; - - return 'ifdesc'; -} - -sub new { - my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); - bless $self, $class; - return $self; -} - -sub manage_selection { - my ($self, %options) = @_; - - $self->SUPER::manage_selection(%options); - - my $oid_advaInventoryEntry = '.1.3.6.1.4.1.2544.1.11.7.10.1.1'; - my $snmp_result = $self->{snmp}->get_table( - oid => $oid_advaInventoryEntry, - begin => $mapping->{advaInventoryAidString}->{oid}, - end => $mapping->{advaInventoryUnitName}->{oid} - ); - - $self->{extra_oids}->{type} = { oid => $mapping->{advaInventoryUnitName}->{oid}, matching => '%{instance}$' }; - $self->{results}->{ $self->{extra_oids}->{type} } = {}; - foreach my $oid (keys %{$snmp_result}) { - next if ($oid !~ /^$mapping->{advaInventoryUnitName}->{oid}\.(.*)$/); - my $instance = $1; - my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance); - - next if ($result->{advaInventoryUnitName} !~ /^(SFP|XFP)/i); - - # interface name example: CH-1-3-N1 - # inventory name example: PL-1-3-N1 - next if ($result->{advaInventoryAidString} !~ /(\d+-\d+-[^\-]+)$/); - my $lookup = $1; - - foreach (sort @{$self->{interface_id_selected}}) { - my $display_value = $self->get_display_value(id => $_); - - if ($display_value =~ /CH-$lookup$/) { - $self->{results}->{ $self->{extra_oids}->{type}->{oid} }->{ $self->{extra_oids}->{type}->{oid} . '.' . $_ } = $result->{advaInventoryUnitName}; - } - } - } -} - -sub disco_format { - my ($self, %options) = @_; - - $self->{extra_oids}->{type} = { oid => $mapping->{advaInventoryUnitName}->{oid}, matching => '%{instance}$' }; - $self->SUPER::disco_format(%options); -} - -1; - -__END__ - -=head1 MODE - -=over 8 - -=item B<--interface> - -Set the interface (number expected) ex: 1,2,... (empty means 'check all interface'). - -=item B<--name> - -Allows to use interface name with option --interface instead of interface oid index (Can be a regexp) - -=item B<--speed> - -Set interface speed (in Mb). - -=item B<--skip-speed0> - -Don't display interface with speed 0. - -=item B<--filter-status> - -Display interfaces matching the filter (example: 'up'). - -=item B<--use-adminstatus> - -Display interfaces with AdminStatus 'up'. - -=item B<--oid-filter> - -Choose OID used to filter interface (default: ifDesc) (values: ifDesc, ifAlias). - -=item B<--oid-display> - -Choose OID used to display interface (default: ifDesc) (values: ifDesc, ifAlias). - -=item B<--display-transform-src> - -Regexp src to transform display value. (security risk!!!) - -=item B<--display-transform-dst> - -Regexp dst to transform display value. (security risk!!!) - -=item B<--add-extra-oid> - -Display an OID. -Example: --add-extra-oid='alias,.1.3.6.1.2.1.31.1.1.1.18' -or --add-extra-oid='vlan,.1.3.6.1.2.1.31.19,%{instance}\..*' - -=back - -=cut diff --git a/network/adva/fsp150/snmp/plugin.pm b/network/adva/fsp150/snmp/plugin.pm index b4409a7e3..2f45f7132 100644 --- a/network/adva/fsp150/snmp/plugin.pm +++ b/network/adva/fsp150/snmp/plugin.pm @@ -31,11 +31,9 @@ sub new { $self->{version} = '1.0'; %{$self->{modes}} = ( - 'alarms' => 'network::adva::fsp150::snmp::mode::alarms', - 'interfaces' => 'network::adva::fsp3000::snmp::mode::interfaces', - 'list-interfaces' => 'network::adva::fsp3000::snmp::mode::listinterfaces', - 'memory' => 'snmp_standard::mode::memory', - 'uptime' => 'snmp_standard::mode::uptime' + 'interfaces' => 'snmp_standard::mode::interfaces', + 'list-interfaces' => 'snmp_standard::mode::listinterfaces', + 'hardware' => 'network::adva::fsp150::snmp::mode::hardware' ); return $self; @@ -47,6 +45,6 @@ __END__ =head1 PLUGIN DESCRIPTION -Check Adva fsp3000 equipments in SNMP. +Check Adva fsp150 equipments in SNMP. =cut From 552577254826999b2a9f60f8f32f22b171e0f6e6 Mon Sep 17 00:00:00 2001 From: Simon Bomm Date: Tue, 28 Apr 2020 13:56:28 +0200 Subject: [PATCH 154/283] enh(form) small modification --- cloud/aws/vpn/plugin.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloud/aws/vpn/plugin.pm b/cloud/aws/vpn/plugin.pm index d07982549..ca99496d0 100644 --- a/cloud/aws/vpn/plugin.pm +++ b/cloud/aws/vpn/plugin.pm @@ -32,7 +32,7 @@ sub new { $self->{version} = '1.0'; %{ $self->{modes} } = ( 'traffic' => 'cloud::aws::vpn::mode::traffic', - 'listvpn' => 'cloud::aws::vpn::mode::listvpn' + 'list-vpn' => 'cloud::aws::vpn::mode::listvpn' ); $self->{custom_modes}{paws} = 'cloud::aws::custom::paws'; From 1783a9d7e3bba8487a3f3517ce765cca223563c2 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 28 Apr 2020 14:55:55 +0200 Subject: [PATCH 155/283] add fsp150 snmp plugin --- network/adva/fsp150/snmp/mode/systems.pm | 212 +++++++++++++++++++++++ network/adva/fsp150/snmp/plugin.pm | 3 +- 2 files changed, 214 insertions(+), 1 deletion(-) create mode 100644 network/adva/fsp150/snmp/mode/systems.pm diff --git a/network/adva/fsp150/snmp/mode/systems.pm b/network/adva/fsp150/snmp/mode/systems.pm new file mode 100644 index 000000000..d4a345c5e --- /dev/null +++ b/network/adva/fsp150/snmp/mode/systems.pm @@ -0,0 +1,212 @@ +# +# Copyright 2020 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 network::adva::fsp150::snmp::mode::systems; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub prefix_system_output { + my ($self, %options) = @_; + + return "system '" . $options{instance_value}->{display} . "' "; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'systems', type => 1, cb_prefix_output => 'prefix_system_output', message_multiple => 'All systems are ok' } + ]; + + $self->{maps_counters}->{systems} = [ + { label => 'cpu-utilization-15min', nlabel => 'system.cpu.utilization.15min.percentage', set => { + key_values => [ + { name => 'cpu_average' }, { name => 'ne_name' }, { name => 'shelf_name' }, + { name => 'slot_name' }, { name => 'display' } + ], + output_template => 'cpu usage: %.2f%% (15min)', + closure_custom_perfdata => sub { + my ($self) = @_; + + $self->{output}->perfdata_add( + nlabel => $self->{nlabel}, + unit => '%', + instances => [ + $self->{result_values}->{ne_name_absolute}, + $self->{result_values}->{shelf_name_absolute}, + $self->{result_values}->{slot_name_absolute} + ], + value => sprintf('%.2f', $self->{result_values}->{cpu_average_absolute}), + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}), + min => 0, max => 100 + ); + } + } + }, + { label => 'memory-usage', nlabel => 'system.memory.usage.bytes', set => { + key_values => [ + { name => 'memory_used' }, { name => 'ne_name' }, { name => 'shelf_name' }, + { name => 'slot_name' }, { name => 'display' } + ], + output_template => 'memory used: %s%s', + output_change_bytes => 1, + closure_custom_perfdata => sub { + my ($self) = @_; + + $self->{output}->perfdata_add( + nlabel => $self->{nlabel}, + unit => 'B', + instances => [ + $self->{result_values}->{ne_name_absolute}, + $self->{result_values}->{shelf_name_absolute}, + $self->{result_values}->{slot_name_absolute} + ], + value => $self->{result_values}->{memory_used_absolute}, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}), + min => 0 + ); + } + } + } + ]; +} + +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-network-element:s' => { name => 'filter_network_element' } + }); + + return $self; +} + +my $mapping = { + cpu_average => { oid => '.1.3.6.1.4.1.2544.1.12.5.1.75.1.5' }, # f3CardStatsACU + memory_used => { oid => '.1.3.6.1.4.1.2544.1.12.5.1.75.1.10' } # f3CardStatsIMU (KB) +}; +my $map_stat_index = { + 1 => '15min', 2 => '1day', 3 => 'rollover', 4 => '5min' +}; + +sub manage_selection { + my ($self, %options) = @_; + + my $snmp_result = $options{snmp}->get_multiple_table( + oids => [ + { oid => $mapping->{cpu_average}->{oid} }, + { oid => $mapping->{memory_used}->{oid} } + ], + return_type => 1, + nothing_quit => 1 + ); + + my ($ne_indexes, $shelf_indexes, $slot_indexes) = ({}, {}, {}); + foreach (keys %$snmp_result) { + next if (! /^$mapping->{cpu_average}->{oid}\.(\d+)\.(\d+)\.(\d+)\./); + $ne_indexes->{$1} = 1; + $shelf_indexes->{$1 . '.' . $2} = 1; + $slot_indexes->{$1 . '.' . $2 . '.' . $3} = 1; + } + + my $oid_slotEntityIndex = '.1.3.6.1.4.1.2544.1.12.3.1.3.1.2'; + my $oid_shelfEntityIndex = '.1.3.6.1.4.1.2544.1.12.3.1.2.1.2'; + my $oid_neName = '.1.3.6.1.4.1.2544.1.12.3.1.1.1.2'; + my $snmp_indexes = $options{snmp}->get_leef( + oids => [ + map($oid_neName . '.' . $_, keys(%$ne_indexes)), + map($oid_shelfEntityIndex . '.' . $_, keys(%$shelf_indexes)), + map($oid_slotEntityIndex . '.' . $_, keys(%$slot_indexes)) + ] + ); + + my $entity_indexes = {}; + foreach (keys %$snmp_indexes) { + $entity_indexes->{$snmp_indexes->{$_}} = 1 if (/^(?:$oid_shelfEntityIndex|$oid_slotEntityIndex)\./); + } + + my $oid_entPhysicalName = '.1.3.6.1.2.1.47.1.1.1.1.7'; + my $snmp_entities = $options{snmp}->get_leef( + oids => [ + map($oid_entPhysicalName . '.' . $_, keys(%$entity_indexes)) + ] + ); + + $self->{systems} = {}; + foreach (keys %$snmp_result) { + next if (! /^$mapping->{cpu_average}->{oid}\.(\d+)\.(\d+)\.(\d+)\.1/); # we want 15min + my $instance = $1 . '.' . $2 . '.' . $3; + my $ne_name = $snmp_indexes->{ $oid_neName . '.' . $1 }; + my $shelf_name = $snmp_entities->{ $oid_entPhysicalName . '.' . $snmp_indexes->{ $oid_shelfEntityIndex . '.' . $1 . '.' . $2 } }; + my $slot_name = $snmp_entities->{ $oid_entPhysicalName . '.' . $snmp_indexes->{ $oid_slotEntityIndex . '.' . $1 . '.' . $2 . '.' . $3 } }; + + my $result = $options{snmp}->map_instance( + mapping => $mapping, + results => $snmp_result, + instance => $instance. '.1' + ); + $result->{memory_used} *= 1024; + my $display = $ne_name . ':' . $shelf_name . ':' . $slot_name; + + if (defined($self->{option_results}->{filter_network_element}) && $self->{option_results}->{filter_network_element} ne '' && + $ne_name !~ /$self->{option_results}->{filter_network_element}/) { + $self->{output}->output_add(long_msg => "skipping system '" . $display . "': no matching filter.", debug => 1); + next; + } + + $self->{systems}->{$instance} = { + display => $display, + ne_name => $ne_name, + shelf_name => $shelf_name, + slot_name => $slot_name, + %$result + }; + } +} + +1; + +__END__ + +=head1 MODE + +Check systems. + +=over 8 + +=item B<--filter-network-elemet> + +Filter by network element name (can be a regexp). + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'cpu-utilization-15min', 'memory-usage'. + +=back + +=cut diff --git a/network/adva/fsp150/snmp/plugin.pm b/network/adva/fsp150/snmp/plugin.pm index 2f45f7132..3612f6536 100644 --- a/network/adva/fsp150/snmp/plugin.pm +++ b/network/adva/fsp150/snmp/plugin.pm @@ -31,9 +31,10 @@ sub new { $self->{version} = '1.0'; %{$self->{modes}} = ( + 'hardware' => 'network::adva::fsp150::snmp::mode::hardware', 'interfaces' => 'snmp_standard::mode::interfaces', 'list-interfaces' => 'snmp_standard::mode::listinterfaces', - 'hardware' => 'network::adva::fsp150::snmp::mode::hardware' + 'systems' => 'network::adva::fsp150::snmp::mode::systems' ); return $self; From e87c895c9e5ced55baaa48aeca786e6112a76c3f Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 28 Apr 2020 16:09:18 +0200 Subject: [PATCH 156/283] adva fsp150 finished --- network/adva/fsp150/snmp/mode/alarms.pm | 297 ++++++++++++++++++++++++ network/adva/fsp150/snmp/plugin.pm | 1 + 2 files changed, 298 insertions(+) create mode 100644 network/adva/fsp150/snmp/mode/alarms.pm diff --git a/network/adva/fsp150/snmp/mode/alarms.pm b/network/adva/fsp150/snmp/mode/alarms.pm new file mode 100644 index 000000000..919b0d12c --- /dev/null +++ b/network/adva/fsp150/snmp/mode/alarms.pm @@ -0,0 +1,297 @@ +# +# Copyright 2020 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 network::adva::fsp150::snmp::mode::alarms; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::misc; +use centreon::plugins::statefile; +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); + +sub custom_status_output { + my ($self, %options) = @_; + + return sprintf( + 'alarm %s [severity: %s] [type: %s] [object: %s] [description: %s] %s', + $self->{result_values}->{label}, + $self->{result_values}->{severity}, + $self->{result_values}->{type}, + $self->{result_values}->{object}, + $self->{result_values}->{description}, + $self->{result_values}->{generation_time} + ); +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'alarms', type => 2, message_multiple => '0 problem(s) detected', display_counter_problem => { label => 'alerts', min => 0 }, + group => [ { name => 'alarm', skipped_code => { -11 => 1 } } ] + } + ]; + + $self->{maps_counters}->{alarm} = [ + { label => 'status', threshold => 0, set => { + key_values => [ + { name => 'severity' }, { name => 'type' }, + { name => 'label'}, { name => 'since' }, + { name => 'object' }, { name => 'description' }, + { name => 'generation_time' } + ], + closure_custom_calc => \&catalog_status_calc, + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold, + } + }, + ]; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $options{options}->add_options(arguments => { + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '%{severity} eq "serviceAffecting"' }, + 'memory' => { name => 'memory' }, + 'timezone:s' => { name => 'timezone' } + }); + + centreon::plugins::misc::mymodule_load( + output => $self->{output}, + module => 'DateTime', + error_msg => "Cannot load module 'DateTime'." + ); + $self->{statefile_cache} = centreon::plugins::statefile->new(%options); + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->change_macros(macros => ['warning_status', 'critical_status']); + if (defined($self->{option_results}->{memory})) { + $self->{statefile_cache}->check_options(%options); + } + + $self->{option_results}->{timezone} = 'GMT' if (!defined($self->{option_results}->{timezone}) || $self->{option_results}->{timezone} eq ''); +} + +my $map_type = { + 0 => 'none', 1 => 'acoopr', 2 => 'hwinitedsysboot', 3 => 'userinitednemireboot', 4 => 'userinitedsysboot', + 5 => 'userinitedsysbootdefaultdb', 6 => 'userinitedsysbootdbrestore ', 7 => 'userinitedsysrebootswact', + 8 => 'sysrecoveryfailed', 9 => 'primntpsvrFailed', 10 => 'bckupntpsvrFailed', 11 => 'swdl-ftip', 12 => 'swdl-ftfail', + 13 => 'swdl-ftpass', 14 => 'swdl-instip', 15 => 'swdl-instfail', 16 => 'swdl-instpass', 17 => 'swdl-actip', + 18 => 'swdl-actfail', 19 => 'swdl-actpass', 20 => 'swdl-valip', 21 => 'swdl-valfail', 22 => 'swdl-valpass', + 23 => 'db-ftip', 24 => 'db-ftfail', 25 => 'db-ftpass', 26 => 'ctneqpt', 27 => 'eqptflt', 28 => 'forced', + 29 => 'lockout', 30 => 'manualswitch', 31 => 'wkswtopr', 32 => 'wkswbk', 33 => 'mismatch', 34 => 'psu1fail', + 35 => 'psu2fail', 36 => 'eqptremoved', 37 => 'autonegunknown', 38 => 'dyinggasp', 39 => 'efmfail', 40 => 'efmrce', + 41 => 'efmrld', 42 => 'efmrls', 43 => 'lnkdeactivated', 44 => 'lnkdownunisolated', 45 => 'lnkdowncablefault', + 46 => 'lnkdowncableremoved', 47 => 'lnkdownautonegfailed', 48 => 'lnkdownlpbkfault', 49 => 'lnkdowncabletestfault', + 50 => 'lnkdown', 51 => 'rfi', 52 => 'rxjabber', 53 => 'sfpmismatch', 54 => 'sfpremoved', 55 => 'sfptxfault', 56 => 'sfpinserted', + 57 => 'fan-a', 58 => 'fan-b', 59 => 'overtemp', 60 => 'undertemp', 61 => 'overvoltage', 62 => 'undervoltage', + 63 => 'shelfrmvd', 64 => 'rmtefmlpbkfail', 65 => 'inpwrflt', 66 => 'crossconnectccm', 67 => 'erroneousccm', + 68 => 'someremotemepccm', 69 => 'somemacstatus', 70 => 'somerdi', 71 => 'ais', 72 => 'syncref', 73 => 'esmcfail', + 74 => 'qlmismatch', 75 => 'freqoff', 76 => 'los', 77 => 'lof', 78 => 'qlsqlch', 79 => 'frngsync', 80 => 'fstsync', + 81 => 'hldovrsync', 82 => 'losloc', 83 => 'wtr', 84 => 'allsyncref', 85 => 'qlinvalid', 86 => 'snmpdghostunresolved', + 87 => 'snmpdghostresourcesbusy', 88 => 'bwexceedednegspeed', 89 => 'shaperbtd', 90 => 'sfpnonqualified', + 91 => 'avghldovrfrqnotrdy', 92 => 'lnkdownmasterslavecfg', 93 => 'pwrnoinputunitfault', 94 => 'ipaddrconflict', + 95 => 'nomoreresources', 96 => 'syncreflck', 97 => 'syncreffrc', 98 => 'syncrefman', 99 => 'syncrefwtr', + 100 => 'syncrefsw', 101 => 'lcpfail', 102 => 'lcploopback', 103 => 'authservernotreachable', 104 => 'excessiveinterrupts', + 105 => 'dbdowngradeip', 106 => 'testalarm', 107 => 'gen-filexfer-ip', 108 => 'gen-filexfer-fail', 109 => 'gen-filexfer-pass', + 110 => 'gen-oper-ip', 111 => 'gen-oper-fail', 112 => 'gen-oper-pass', 113 => 'trafficfail', 114 => 'clockfail', + 115 => 'rdncyswitchover', 116 => 'rdncyswvermismatch', 117 => 'rdncyoutofsync', 118 => 'rdncylockout', 119 => 'rdncymaintenance', + 120 => 'xfptxfault', 121 => 'xfpmismatch', 122 => 'xfpnonqualified', 123 => 'xfpremoved', 124 => 'xfpinserted', + 125 => 'lagmbrfail', 126 => 'swdl-proip', 127 => 'swdl-propass', 128 => 'swdl-profail', 129 => 'db-proip', + 130 => 'db-propass', 131 => 'db-profail', 132 => 'swdl-rvtip', 133 => 'swdl-rvtpass', 134 => 'swdl-rvtfail', + 135 => 'db-corruption', 136 => 'bpmismatch', 137 => 'popr-oovar', 138 => 'popr-oorange', 139 => 'popr-genfail', + 140 => 'popr-sfpnqual', 141 => 'popr-rta', 142 => 'modemmea', 143 => 'modemnonqualified', 144 => 'modemremoved', + 145 => 'nosimcard', 146 => 'env-genfail', 147 => 'env-misc', 148 => 'env-batterydischarge', 149 => 'env-batteryfail', + 150 => 'env-coolingfanfail', 151 => 'env-enginefail', 152 => 'env-fusefail', 153 => 'env-hightemp', 154 => 'env-intrusion', + 155 => 'env-lowbatteryvoltage', 156 => 'env-lowtemp', 157 => 'env-opendoor', 158 => 'env-powerfail', 159 => 'intctneqpt', + 160 => 'syncnotready', 161 => 'vcgfail', 162 => 'loa', 163 => 'plct', 164 => 'tlct', 165 => 'plcr', 166 => 'tlcr', 167 => 'sqnc', + 168 => 'ais-l', 169 => 'rfi-l', 170 => 'rei-l', 171 => 'exc-l', 172 => 'deg-l', 173 => 'tim-s', 174 => 'ais-p', 175 => 'lop-p', + 176 => 'tim-p', 177 => 'uneq-p', 178 => 'plm-p', 179 => 'lom-p', 180 => 'exc-p', 181 => 'deg-p', 182 => 'rei-p', 183 => 'rfi-p', + 184 => 'lcascrc', 185 => 'sqm', 186 => 'lom', 187 => 'gidmismatch', 188 => 'mnd', 189 => 'ais-v', 190 => 'lop-v', 191 => 'tim-v', + 192 => 'uneq-v', 193 => 'plm-v', 194 => 'exc-v', 195 => 'deg-v', 196 => 'rei-v', 197 => 'rfi-v', 198 => 'rmtinitlpbk', 199 => 'rai', + 200 => 'rei', 201 => 'idle', 202 => 'csf', 203 => 'gfplfd', 204 => 'gfpuplmismatch', 205 => 'gfpexhmismatch', 206 => 'vcat-lom', + 207 => 'fragileecc', 208 => 'elmi-seqnummismatch', 209 => 'elmi-notoper', 210 => 'pw-rlofs', 211 => 'pw-lof', 212 => 'pw-latefrm', + 213 => 'pw-jbovrn', 214 => 'allsoocsfailed', 215 => 'tsholdoverfrqnotready', 216 => 'tsfreerun', 217 => 'tsholdover', 218 => 'ptsflossofsync', + 219 => 'ptsflossofannounce', 220 => 'ptsfunusable', 221 => 'unresolvedsatop', 222 => 'rdi-v', 223 => 'autonegBypass', 224 => 'forcedOffline', + 225 => 'hwcfginconsistent', 226 => 'sjmtiemaskcross', 227 => 'sjoffsetfail', 228 => 'sjnotimelock', 229 => 'sjnofreqlock', 230 => 'sjmtiemargincross', + 231 => 'sjtestreferencefail', 232 => 'sjtestsourcefail', 233 => 'sjtestnotimestamp', 234 => 'sjtestnomessages', 235 => 'gpsantennafail', + 236 => 'ampNoPeer', 237 => 'ampProvFail', 238 => 'ampCfgFail', 239 => 'ltpFailure', 240 => 'ltpInprogress', 241 => 'pse-power-threshold-exceeded', + 242 => 'pse-power-fail', 243 => 'pse-poweroff-overcurrent', 244 => 'pse-poweroff-overvoltage', 245 => 'pse-poweroff-overload', + 246 => 'pse-poweroff-overtemp', 247 => 'pse-poweroff-short', 248 => 'erpFoPPM', 249 => 'erpFoPTO', 250 => 'erpBlockPort0RPL', 251 => 'erpBlockPort0SF', + 252 => 'erpBlockPort0MS', 253 => 'erpBlockPort0FS', 254 => 'erpBlockPort0WTR', 255 => 'erpBlockPort1RPL', 256 => 'erpBlockPort1SF', + 257 => 'erpBlockPort1MS', 258 => 'erpBlockPort1FS', 259 => 'erpBlockPort1WTR', 260 => 'ipv6addr-conflict', 261 => 'macAddrlearntblFull', + 262 => 'timeClockNotLocked', 263 => 'timeNotTraceAble', 264 => 'timeFreqNotTraceAble', 265 => 'timeHoldOver', 266 => 'timeFreqLock', + 267 => 'timeRefLock', 268 => 'timeRefUnavailable', 269 => 'timeRefDegraded', 270 => 'timeRefFrc', 271 => 'tsTimeFrun', 272 => 'tsTimeHoldOver', + 273 => 'timeRefUnavailableWTR', 274 => 'timeRefDegradedWTR', 275 => 'rmtInitSat', 276 => 'lldpRemoteTblChg', 277 => 'soocLck', 278 => 'ampProvSuccess', + 279 => 'ampCfgSuccess', 280 => 'soocSW', 281 => 'soocWTR', 282 => 'sjtealert', 283 => 'dataExportFtpFail', 284 => 'xfpWaveLengthMismatch', + 285 => 'cpmrUpgrading', 286 => 'beaconLightFailure', 287 => 'manualSwitchClear', 288 => 'loopbackActive', 289 => 'loopbackRequest', + 290 => 'trafficResourceLimitExceeded', 291 => 'oduAis', 292 => 'opuAis', 293 => 'otuAis', 294 => 'otnProtMsmtch', 295 => 'otnProtPrtclFail', + 296 => 'oduBdi', 297 => 'otuBdi', 298 => 'lossCharSync', 299 => 'berHigh', 300 => 'laserFail', 301 => 'laserCurrentAbnormal', 302 => 'oduLock', + 303 => 'autoShutdown', 304 => 'localFault', 305 => 'otuLof', 306 => 'otuLom', 307 => 'oduOci', 308 => 'opuPlm', 309 => 'oduSd', 310 => 'otuSd', + 311 => 'opuSf', 312 => 'optPowerHighRx', 313 => 'optPowerLowRx', 314 => 'optPowerHighTx', 315 => 'optPowerLowTx', 316 => 'oduTim', 317 => 'otuTim', + 318 => 'sjConstTeThrshld', 319 => 'sjInstTeThrshld', 320 => 'timeRefSW', 321 => 'aadcfailed', 322 => 'ptpfreqfrun', 323 => 'ptptimefrun', + 324 => 'ptpfreqhldovr', 325 => 'ptptimehldovr', 326 => 'ptptimenottraceable', 327 => 'ptpfreqnottraceable', 328 => 'synctimeout', 329 => 'announcetimeout', + 330 => 'delayresptimeout', 331 => 'multiplepeers', 332 => 'wrongdomain', 333 => 'nosatellitercv', 334 => 'trafficipifoutage', 335 => 'ptpportstatechanged', + 336 => 'physicalSelfLpbk', 337 => 'cfCardRWFail', 338 => 'maxexpectedslaves', 339 => 'external-alarm', 340 => 'maskcrossed', 341 => 'oof', + 342 => 'signalfail', 343 => 'timenottai', 344 => 'perffuncfailure', 345 => 'ptpportnotoper', 346 => 'leapsecondexpected', 347 => 'keyExchangeFail', + 348 => 'keyExchangeAuthPasswordMissing', 349 => 'secureRamCleared', 350 => 'noRouteResources', 351 => 'tamperSwitchOpen', 352 => 'bfdSessionDown', + 353 => 'destinationUnresolved', 354 => 'sjmaxtethrshld', 355 => 'trafficArpTableFull', 357 => 'erpRingSegmentation(356), gpsrcvrfail', + 358 => 'noActiveRoute', 359 => 'vxlanDMac2DIPTableFull', 360 => 'bwExceedLagMemberPortSpeed', 361 => 'greRemoteUnreachable', 362 => 'bweexceedsportspeed', + 363 => 'servicediscarded', 364 => 'bmcaError', 365 => 'freeze', 366 => 'gpsFwUpgrade', 367 => 'storageWearout', 368 => 'pps-not-generated', + 369 => 'min-sat-1-thrshld-crossed', 370 => 'min-sat-2-thrshld-crossed', 371 => 'gatewayNotReachable', 372 => 'pdop-mask-cross', 373 => 'nc-initInProgress', + 374 => 'primaryNtpSvr-auth-failed', 375 => 'backupNtpSvr-auth-failed', 376 => 'clock-class-mismatch', 377 => 'hpg-switch-force', 378 => 'hpg-switch-lockout', + 379 => 'hpg-switch-to-3gpp-path', 380 => 'hpg-switch-to-fixed-path', 381 => 'bgp-linkdown', 382 => 'ospf-neighbour-lost', 383 => 'traffic-ndptable-full', + 384 => 'dup-link-local-address', 385 => 'dup-unicast-address', 386 => 'ztp-failed', 387 => 'ztp-in-progress', 388 => 'nc-runningConfigLocked', + 389 => 'pwrnoinput2', 390 => 'keyExchangeStopped', 391 => 'security-error', 392 => 'pppoe-connection-failed', 393 => 'no-ipv6route-resource', + 394 => 'sfp-firmware-revision-mismatch', 395 => 'vrrp-new-master', 396 => 'nontpkeys', 397 => 'timesrcunavailable', 398 => 'syncsrcunavailable', + 399 => 'local-cooling-fail', 400 => 'jamming', 401 => 'spoofing', 402 => 'httpsSslCertExpiryPending', 403 => 'httpsSslCertExpired', 404 => 'srgb-collision', + 405 => 'sid-collision', 406 => 'sr-index-out-of-range' +}; +my $map_severity = { + 0 => 'none', 1 => 'nonServiceAffecting', 2 => 'serviceAffecting' +}; + +my $oids = { + cmSysAlmEntry => { + oid => '.1.3.6.1.4.1.2544.1.12.6.1.2.1', label => 'sys', + mapping => { + type => { oid => '.1.3.6.1.4.1.2544.1.12.6.1.2.1.2', map => $map_type }, # cmSysAlmType + severity => { oid => '.1.3.6.1.4.1.2544.1.12.6.1.2.1.3', map => $map_severity }, # cmSysAlmSrvEff + timestamp => { oid => '.1.3.6.1.4.1.2544.1.12.6.1.2.1.4' }, # cmSysAlmTime + description => { oid => '.1.3.6.1.4.1.2544.1.12.6.1.2.1.7' }, # cmSysAlmDescr + object => { oid => '.1.3.6.1.4.1.2544.1.12.6.1.2.1.9' }, # cmSysAlmObjectName + } + }, + cmNetworkElementAlmEntry => { + oid => '.1.3.6.1.4.1.2544.1.12.6.1.4.1', label => 'networkElement', + mapping => { + type => { oid => '.1.3.6.1.4.1.2544.1.12.6.1.4.1.2', map => $map_type }, # cmNetworkElementAlmType + severity => { oid => '.1.3.6.1.4.1.2544.1.12.6.1.4.1.3', map => $map_severity }, # cmNetworkElementAlmSrvEff + timestamp => { oid => '.1.3.6.1.4.1.2544.1.12.6.1.4.1.4' }, # cmNetworkElementAlmTime + description => { oid => '.1.3.6.1.4.1.2544.1.12.6.1.4.1.7' }, # cmNetworkElementAlmDescr + object => { oid => '.1.3.6.1.4.1.2544.1.12.6.1.4.1.9' }, # cmNetworkElementAlmObjectName + } + } +}; + +sub manage_selection { + my ($self, %options) = @_; + + $self->{alarms}->{global} = { alarm => {} }; + my $get_oids = []; + foreach (keys %$oids) { + push @$get_oids, { + oid => $oids->{$_}->{oid}, + start => $oids->{$_}->{mapping}->{type}->{oid}, + end => $oids->{$_}->{mapping}->{object}->{oid} + }; + } + my $snmp_result = $options{snmp}->get_multiple_table(oids => $get_oids); + + my $last_time; + if (defined($self->{option_results}->{memory})) { + $self->{statefile_cache}->read(statefile => 'cache_adva_fsp150_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port(). '_' . $self->{mode}); + $last_time = $self->{statefile_cache}->get(name => 'last_time'); + } + + my ($i, $current_time) = (1, time()); + foreach (keys %$oids) { + my $branch_oid = $oids->{$_}->{oid}; + next if (!defined($snmp_result->{$branch_oid})); + + foreach my $oid (keys %{$snmp_result->{$branch_oid}}) { + next if ($oid !~ /^$oids->{$_}->{mapping}->{severity}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $options{snmp}->map_instance(mapping => $oids->{$_}->{mapping}, results => $snmp_result->{$branch_oid}, instance => $instance); + + my @date = unpack 'n C6 a C2', $result->{timestamp}; + my $timezone = $self->{option_results}->{timezone}; + if (defined($date[7])) { + $timezone = sprintf("%s%02d%02d", $date[7], $date[8], $date[9]); + } + + my $tz = centreon::plugins::misc::set_timezone(name => $timezone); + my $dt = DateTime->new( + year => $date[0], month => $date[1], day => $date[2], hour => $date[3], minute => $date[4], second => $date[5], + %$tz + ); + + next if (defined($self->{option_results}->{memory}) && defined($last_time) && $last_time > $dt->epoch); + + my $diff_time = $current_time - $dt->epoch; + + $self->{alarms}->{global}->{alarm}->{$i} = { + since => $diff_time, + generation_time => centreon::plugins::misc::change_seconds(value => $diff_time), + label => $oids->{$_}->{label}, + %$result + }; + $i++; + } + } + + if (defined($self->{option_results}->{memory})) { + $self->{statefile_cache}->write(data => { last_time => $current_time }); + } +} + +1; + +__END__ + +=head1 MODE + +Check alarms. + +=over 8 + +=item B<--warning-status> + +Set warning threshold for status. +Can used special variables like: %{description}, %{object}, %{severity}, %{type}, %{label}, %{since} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{severity} eq "serviceAffecting"'). +Can used special variables like: {description}, %{object}, %{severity}, %{type}, %{label}, %{since} + +=item B<--timezone> + +Timezone options (the date from the equipment overload that option). Default is 'GMT'. + +=item B<--memory> + +Only check new alarms. + +=back + +=cut diff --git a/network/adva/fsp150/snmp/plugin.pm b/network/adva/fsp150/snmp/plugin.pm index 3612f6536..bb9bf77a6 100644 --- a/network/adva/fsp150/snmp/plugin.pm +++ b/network/adva/fsp150/snmp/plugin.pm @@ -31,6 +31,7 @@ sub new { $self->{version} = '1.0'; %{$self->{modes}} = ( + 'alarms' => 'network::adva::fsp150::snmp::mode::alarms', 'hardware' => 'network::adva::fsp150::snmp::mode::hardware', 'interfaces' => 'snmp_standard::mode::interfaces', 'list-interfaces' => 'snmp_standard::mode::listinterfaces', From c450de45f4915a78248edfe31d8e7eb655ecc711 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 28 Apr 2020 17:45:05 +0200 Subject: [PATCH 157/283] add unit component for hardwarefiberalliance mode --- snmp_standard/mode/hardwarefibrealliance.pm | 112 +++++++++++++++++--- 1 file changed, 98 insertions(+), 14 deletions(-) diff --git a/snmp_standard/mode/hardwarefibrealliance.pm b/snmp_standard/mode/hardwarefibrealliance.pm index 1d01547e9..404b432da 100644 --- a/snmp_standard/mode/hardwarefibrealliance.pm +++ b/snmp_standard/mode/hardwarefibrealliance.pm @@ -28,17 +28,24 @@ use warnings; sub set_system { my ($self, %options) = @_; - $self->{regexp_threshold_overload_check_section_option} = '^(sensors|port)$'; + $self->{regexp_threshold_overload_check_section_option} = '^(sensors|port|unit)$'; $self->{cb_hook2} = 'snmp_execute'; $self->{thresholds} = { + unit => [ + ['unknown', 'UNKNOWN'], + ['unused', 'OK'], + ['warning', 'WARNING'], + ['failed', 'CRITICAL'], + ['ok', 'OK'] + ], sensors => [ ['unknown', 'UNKNOWN'], ['other', 'UNKNOWN'], ['warning', 'WARNING'], ['failed', 'CRITICAL'], - ['ok', 'OK'], + ['ok', 'OK'] ], port => [ ['warning', 'WARNING'], @@ -46,18 +53,20 @@ sub set_system { ['unused', 'OK'], ['initializing', 'OK'], ['ready', 'OK'], - ['.*', 'UNKNOWN'], - ], + ['.*', 'UNKNOWN'] + ] }; $self->{components_path} = 'snmp_standard::mode::components'; - $self->{components_module} = ['sensors', 'port']; + $self->{components_module} = ['sensors', 'port', 'unit']; } sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options, - no_absent => 1, no_performance => 1, no_load_components => 1, force_new_perfdata => 1); + my $self = $class->SUPER::new( + package => __PACKAGE__, %options, + no_absent => 1, no_performance => 1, no_load_components => 1, force_new_perfdata => 1 + ); bless $self, $class; $options{options}->add_options(arguments => {}); @@ -84,7 +93,11 @@ http://www.emc.com/microsites/fibrealliance/index.htm =item B<--component> Which component to check (Default: '.*'). -Can be: 'sensors', 'port'. +Can be: 'unit', 'sensors', 'port'. + +=item B<--add-name-instance> + +Add literal description for instance value (used in filter, and threshold options). =item B<--filter> @@ -150,7 +163,7 @@ sub check { my ($self) = @_; $self->{output}->output_add(long_msg => "checking sensors"); - $self->{components}->{sensors} = {name => 'sensors', total => 0, skip => 0}; + $self->{components}->{sensors} = { name => 'sensors', total => 0, skip => 0 }; return if ($self->check_filter(section => 'sensors')); foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_connUnitSensorEntry}})) { @@ -162,9 +175,9 @@ sub check { $self->{components}->{sensors}->{total}++; $self->{output}->output_add(long_msg => sprintf( - "sensor '%s' status is %s [msg: %s] [type: %s] [chara: %s] [instance: %s]", + "sensor '%s' status is %s [msg: %s] [type: %s] [chara: %s]", $result->{connUnitSensorName}, $result->{connUnitSensorStatus}, - $result->{connUnitSensorMessage}, $result->{connUnitSensorType}, $result->{connUnitSensorCharacteristic}, $instance) + $result->{connUnitSensorMessage}, $result->{connUnitSensorType}, $result->{connUnitSensorCharacteristic}) ); my $exit = $self->get_severity(section => 'sensors', name => $result->{connUnitSensorName}, value => $result->{connUnitSensorStatus}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { @@ -208,7 +221,7 @@ sub check { my ($self) = @_; $self->{output}->output_add(long_msg => "checking ports"); - $self->{components}->{port} = {name => 'ports', total => 0, skip => 0}; + $self->{components}->{port} = { name => 'ports', total => 0, skip => 0 }; return if ($self->check_filter(section => 'port')); foreach my $key ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{ $mapping_port->{connUnitPortName}->{oid} }})) { @@ -222,8 +235,8 @@ sub check { $self->{components}->{port}->{total}++; $self->{output}->output_add( long_msg => sprintf( - "port '%s' status is %s [instance: %s]", - $name, $result->{connUnitPortStatus}, $instance + "port '%s' status is %s", + $name, $result->{connUnitPortStatus} ) ); my $exit = $self->get_severity(section => 'port', name => $name, value => $result->{connUnitPortStatus}); @@ -239,3 +252,74 @@ sub check { } } } + +package snmp_standard::mode::components::unit; + +use strict; +use warnings; + +my $map_unit_status = { + 1 => 'unknown', 2 => 'unused', 3 => 'ok', 4 => 'warning', 5 => 'failed' +}; +my $map_unit_type = { + 1 => 'unknown', 2 => 'other', 3 => 'hub', 4 => 'switch', 5 => 'gateway', + 6 => 'converter', 7 => 'hba', 8 => 'proxy-agent', 9 => 'storage-device', + 10 => 'host', 11 => 'storage-subsystem', 12 => 'module', 13 => 'swdriver', + 14 => 'storage-access-device', 15 => 'wdm', 16 => 'ups', 17 => 'nas' +}; + +my $mapping_unit = { + connUnitType => { oid => '.1.3.6.1.3.94.1.6.1.3', map => $map_unit_type }, + connUnitStatus => { oid => '.1.3.6.1.3.94.1.6.1.6', map => $map_unit_status }, + connUnitName => { oid => '.1.3.6.1.3.94.1.6.1.20' } +}; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, + { oid => $mapping_unit->{connUnitType}->{oid} }, + { oid => $mapping_unit->{connUnitStatus}->{oid} }, + { oid => $mapping_unit->{connUnitName}->{oid} }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "checking units"); + $self->{components}->{unit} = { name => 'units', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'unit')); + + my $results = { + %{$self->{results}->{ $mapping_unit->{connUnitType}->{oid} }}, + %{$self->{results}->{ $mapping_unit->{connUnitStatus}->{oid} }}, + %{$self->{results}->{ $mapping_unit->{connUnitName}->{oid} }}, + }; + foreach my $key ($self->{snmp}->oid_lex_sort(keys %$results)) { + next if ($key !~ /^$mapping_unit->{connUnitName}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping_unit, results => $results, instance => $instance); + my $name = $result->{connUnitType} . '.' . $result->{connUnitName}; + + next if ($self->check_filter(section => 'unit', instance => $instance, name => $name)); + + $self->{components}->{unit}->{total}++; + $self->{output}->output_add( + long_msg => sprintf( + "unit '%s' status is %s", + $name, $result->{connUnitStatus} + ) + ); + my $exit = $self->get_severity(section => 'unit', instance => $instance, name => $name, value => $result->{connUnitStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "Unit '%s' status is %s", + $name, + $result->{connUnitStatus} + ) + ); + } + } +} From 1ffc526bd704fcea856adef3f84072ba65a1f4c5 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 29 Apr 2020 09:43:18 +0200 Subject: [PATCH 158/283] update fsp150 --- network/adva/fsp150/snmp/mode/alarms.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/network/adva/fsp150/snmp/mode/alarms.pm b/network/adva/fsp150/snmp/mode/alarms.pm index 919b0d12c..781e6cabb 100644 --- a/network/adva/fsp150/snmp/mode/alarms.pm +++ b/network/adva/fsp150/snmp/mode/alarms.pm @@ -46,7 +46,7 @@ sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ - { name => 'alarms', type => 2, message_multiple => '0 problem(s) detected', display_counter_problem => { label => 'alerts', min => 0 }, + { name => 'alarms', type => 2, message_multiple => '0 problem(s) detected', display_counter_problem => { nlabel => 'alerts.problems.current.count', min => 0 }, group => [ { name => 'alarm', skipped_code => { -11 => 1 } } ] } ]; @@ -70,7 +70,7 @@ sub set_counters { sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); bless $self, $class; $options{options}->add_options(arguments => { From d56897cd47eed54202f1ac1f89fd3cee79a46555 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 29 Apr 2020 15:02:12 +0200 Subject: [PATCH 159/283] add remaining time enexus --- hardware/devices/eltek/enexus/snmp/mode/battery.pm | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/hardware/devices/eltek/enexus/snmp/mode/battery.pm b/hardware/devices/eltek/enexus/snmp/mode/battery.pm index 652603bde..d4e8a6500 100644 --- a/hardware/devices/eltek/enexus/snmp/mode/battery.pm +++ b/hardware/devices/eltek/enexus/snmp/mode/battery.pm @@ -208,6 +208,7 @@ my $mapping = { batteryRemainingCapacityValue => { oid => '.1.3.6.1.4.1.12148.10.10.9.5' }, # ah or % batteryRemainingCapacityMinorLowLevel => { oid => '.1.3.6.1.4.1.12148.10.10.9.6' }, batteryRemainingCapacityMajorLowLevel => { oid => '.1.3.6.1.4.1.12148.10.10.9.7' }, + loadCurrentValue => { oid => '.1.3.6.1.4.1.12148.10.9.2.5' }, # A or dA }; sub threshold_eltek_configured { @@ -246,9 +247,17 @@ sub manage_selection { charge_remaining_unit => $result->{powerSystemCapacityScale} }; # we can calculate the time remaining if unit is ah (amperehour) and current battery is discharging (negative value) - if ($result->{powerSystemCapacityScale} eq 'ah' && $result->{batteryCurrentsValue} < 0) { + my $current; + if ($result->{batteryCurrentsValue} < 0) { + $current = $result->{batteryCurrentsValue} * -1 + } elsif ($result->{loadCurrentValue} > 0) { + $current = $result->{loadCurrentValue}; + } + + + if ($result->{powerSystemCapacityScale} eq 'ah' && defined($current)) { $self->{battery}->{charge_remaining_time} = - int($result->{batteryRemainingCapacityValue} * 3600 / $result->{batteryCurrentsValue} * $scale_current * -1); + int($result->{batteryRemainingCapacityValue} * 3600 / $current * $scale_current); } $self->threshold_eltek_configured( From 6344554d12be6ba74e192b08ca99070150f8a3d5 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 30 Apr 2020 11:13:21 +0200 Subject: [PATCH 160/283] fix unit battery eltek enexus --- hardware/devices/eltek/enexus/snmp/mode/battery.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hardware/devices/eltek/enexus/snmp/mode/battery.pm b/hardware/devices/eltek/enexus/snmp/mode/battery.pm index d4e8a6500..48c23c398 100644 --- a/hardware/devices/eltek/enexus/snmp/mode/battery.pm +++ b/hardware/devices/eltek/enexus/snmp/mode/battery.pm @@ -69,7 +69,7 @@ sub custom_charge_remaining_perfdata { my ($self, %options) = @_; $self->{output}->perfdata_add( - nlabel => 'battery.charge.remaining.' . ($self->{result_values}->{charge_remaining_unit_absolute} eq '%' ? '%' : 'amperehour'), + nlabel => 'battery.charge.remaining.' . ($self->{result_values}->{charge_remaining_unit_absolute} eq '%' ? 'percentage' : 'amperehour'), unit => $self->{result_values}->{charge_remaining_unit_absolute}, value => $self->{result_values}->{charge_remaining_absolute}, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}), From b21485f74d9420a52f99dbac73ff07edd06371cf Mon Sep 17 00:00:00 2001 From: UrBnW <40244829+UrBnW@users.noreply.github.com> Date: Thu, 30 Apr 2020 14:55:40 +0200 Subject: [PATCH 161/283] Fix UDP ping --- apps/protocols/snmp/mode/responsetime.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/protocols/snmp/mode/responsetime.pm b/apps/protocols/snmp/mode/responsetime.pm index e2b65393a..c1a70cdda 100644 --- a/apps/protocols/snmp/mode/responsetime.pm +++ b/apps/protocols/snmp/mode/responsetime.pm @@ -127,7 +127,7 @@ sub manage_selection { } $self->{global} = { - rta => $total_time_elapsed * 1000 / $self->{option_packets}, + rta => $total_time_elapsed * 1000 / ($self->{option_packets} - $total_packet_lost), rtmax => $max_time_elapsed * 1000, rtmin => $min_time_elapsed * 1000, pl => int($total_packet_lost * 100 / $self->{option_packets}), From f3ce610206f0e25c1945dadaea5f1f05ef83b41e Mon Sep 17 00:00:00 2001 From: UrBnW <40244829+UrBnW@users.noreply.github.com> Date: Thu, 30 Apr 2020 15:03:13 +0200 Subject: [PATCH 162/283] fix division by 0 --- apps/protocols/snmp/mode/responsetime.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/protocols/snmp/mode/responsetime.pm b/apps/protocols/snmp/mode/responsetime.pm index c1a70cdda..851394377 100644 --- a/apps/protocols/snmp/mode/responsetime.pm +++ b/apps/protocols/snmp/mode/responsetime.pm @@ -127,7 +127,7 @@ sub manage_selection { } $self->{global} = { - rta => $total_time_elapsed * 1000 / ($self->{option_packets} - $total_packet_lost), + rta => ($self->{option_packets} > $total_packet_lost) ? $total_time_elapsed * 1000 / ($self->{option_packets} - $total_packet_lost) : 0, rtmax => $max_time_elapsed * 1000, rtmin => $min_time_elapsed * 1000, pl => int($total_packet_lost * 100 / $self->{option_packets}), From a5aa4452c5f2838493d6b858d3d93174afa962f1 Mon Sep 17 00:00:00 2001 From: Colin Gagnaire Date: Thu, 30 Apr 2020 15:48:11 +0200 Subject: [PATCH 163/283] fix snmp discovery desc --- os/linux/local/mode/discoverysnmp.pm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/os/linux/local/mode/discoverysnmp.pm b/os/linux/local/mode/discoverysnmp.pm index 65432577f..eb0b4786b 100644 --- a/os/linux/local/mode/discoverysnmp.pm +++ b/os/linux/local/mode/discoverysnmp.pm @@ -84,6 +84,7 @@ my $lookup_type = [ { type => 'stonesoft', re => qr/Forcepoint/i }, { type => 'redback', re => qr/Redback/i }, { type => 'palo alto', re => qr/Palo Alto/i }, + { type => 'hp procurve', re => qr/HP.*Switch/i }, { type => 'hp procurve', re => qr/HP ProCurve/i }, { type => 'hp standard', re => qr/HPE Comware/i }, { type => 'hp msl', re => qr/HP MSL/i }, @@ -152,6 +153,7 @@ sub run { my %host; $host{type} = $self->define_type(desc => $result->{$self->{oid_sysDescr}}); $host{desc} = $result->{$self->{oid_sysDescr}}; + $edge{desc} =~ s/\n/ /g if (defined($edge{desc})); $host{ip} = $ip->addr; $host{hostname} = $result->{$self->{oid_sysName}}; $host{snmp_version} = $last_version; From acf1c14f041700d5f7ecf81fa2956efc6ec46850 Mon Sep 17 00:00:00 2001 From: Colin Gagnaire Date: Thu, 30 Apr 2020 15:49:18 +0200 Subject: [PATCH 164/283] fix snmp discovery desc --- os/linux/local/mode/discoverysnmp.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/os/linux/local/mode/discoverysnmp.pm b/os/linux/local/mode/discoverysnmp.pm index eb0b4786b..ca661460b 100644 --- a/os/linux/local/mode/discoverysnmp.pm +++ b/os/linux/local/mode/discoverysnmp.pm @@ -153,7 +153,7 @@ sub run { my %host; $host{type} = $self->define_type(desc => $result->{$self->{oid_sysDescr}}); $host{desc} = $result->{$self->{oid_sysDescr}}; - $edge{desc} =~ s/\n/ /g if (defined($edge{desc})); + $host{desc} =~ s/\n/ /g if (defined($host{desc})); $host{ip} = $ip->addr; $host{hostname} = $result->{$self->{oid_sysName}}; $host{snmp_version} = $last_version; From 92bbbe8a616b1683d11ba6fd1172fface04ad9a4 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 30 Apr 2020 17:54:36 +0200 Subject: [PATCH 165/283] fix thresholds --- network/alcatel/oxe/snmp/mode/pbxrole.pm | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/network/alcatel/oxe/snmp/mode/pbxrole.pm b/network/alcatel/oxe/snmp/mode/pbxrole.pm index d6183c091..e08ae2de0 100644 --- a/network/alcatel/oxe/snmp/mode/pbxrole.pm +++ b/network/alcatel/oxe/snmp/mode/pbxrole.pm @@ -30,9 +30,9 @@ my $thresholds = { ['indeterminate', 'UNKNOWN'], ['main', 'OK'], ['stand-by', 'OK'], - ['active-pcs', 'CRITICAL'], ['inactive-pcs', 'CRITICAL'], - ], + ['active-pcs', 'CRITICAL'] + ] }; my %map_role = ( 0 => 'indeterminate', @@ -46,11 +46,11 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - - $options{options}->add_options(arguments => - { - "threshold-overload:s@" => { name => 'threshold_overload' }, - }); + + $options{options}->add_options(arguments => { + 'threshold-overload:s@' => { name => 'threshold_overload' }, + }); + return $self; } @@ -82,12 +82,12 @@ sub run { my $oid_pbxRole = '.1.3.6.1.4.1.637.64.4400.1.4.0'; my $oid_pbxRole_buggy = '.1.3.6.1.4.1.637.64.4400.1.4'; my $result = $self->{snmp}->get_leef(oids => [$oid_pbxRole, $oid_pbxRole_buggy], nothing_quit => 1); - + my $pbx_role = defined($result->{$oid_pbxRole}) ? $map_role{$result->{$oid_pbxRole}} : $map_role{$result->{$oid_pbxRole_buggy}}; my $exit = $self->get_severity(section => 'role', value => $pbx_role); $self->{output}->output_add(severity => $exit, short_msg => sprintf("PBX Role is '%s'", $pbx_role)); - + $self->{output}->display(); $self->{output}->exit(); } @@ -95,7 +95,7 @@ sub run { 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) { From 31f34abb15308ab7fd524a1bd8e7f4387b84c2cf Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 30 Apr 2020 17:55:29 +0200 Subject: [PATCH 166/283] fix thresholds --- network/alcatel/oxe/snmp/mode/pbxrole.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/network/alcatel/oxe/snmp/mode/pbxrole.pm b/network/alcatel/oxe/snmp/mode/pbxrole.pm index e08ae2de0..0a72e677e 100644 --- a/network/alcatel/oxe/snmp/mode/pbxrole.pm +++ b/network/alcatel/oxe/snmp/mode/pbxrole.pm @@ -31,7 +31,7 @@ my $thresholds = { ['main', 'OK'], ['stand-by', 'OK'], ['inactive-pcs', 'CRITICAL'], - ['active-pcs', 'CRITICAL'] + ['active-pcs', 'WARNING'] ] }; my %map_role = ( From 8e0de29ea1a67cc437d1290bd577123e375bcbb6 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 30 Apr 2020 17:58:09 +0200 Subject: [PATCH 167/283] fix thresholds alcatel oxe --- network/alcatel/oxe/snmp/mode/pbxrole.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/network/alcatel/oxe/snmp/mode/pbxrole.pm b/network/alcatel/oxe/snmp/mode/pbxrole.pm index 0a72e677e..e3a8790c4 100644 --- a/network/alcatel/oxe/snmp/mode/pbxrole.pm +++ b/network/alcatel/oxe/snmp/mode/pbxrole.pm @@ -30,7 +30,7 @@ my $thresholds = { ['indeterminate', 'UNKNOWN'], ['main', 'OK'], ['stand-by', 'OK'], - ['inactive-pcs', 'CRITICAL'], + ['inactive-pcs', 'OK'], ['active-pcs', 'WARNING'] ] }; From bc37eb37fdcb625b5b5f41f7d82d501103d75156 Mon Sep 17 00:00:00 2001 From: Simon Bomm Date: Fri, 1 May 2020 18:00:24 +0200 Subject: [PATCH 168/283] enh(plugin)add ec2 spot fleet discovery (#1966) Co-authored-by: Thibault S <48209914+thibaults-centreon@users.noreply.github.com> --- cloud/aws/custom/awscli.pm | 29 +++++ cloud/aws/custom/paws.pm | 25 ++++ .../ec2/mode/discoveryspotfleetrequests.pm | 117 ++++++++++++++++++ cloud/aws/ec2/mode/listspotfleetrequests.pm | 96 ++++++++++++++ cloud/aws/ec2/plugin.pm | 24 ++-- 5 files changed, 280 insertions(+), 11 deletions(-) create mode 100644 cloud/aws/ec2/mode/discoveryspotfleetrequests.pm create mode 100644 cloud/aws/ec2/mode/listspotfleetrequests.pm diff --git a/cloud/aws/custom/awscli.pm b/cloud/aws/custom/awscli.pm index 36510b5d2..7c920e8fe 100644 --- a/cloud/aws/custom/awscli.pm +++ b/cloud/aws/custom/awscli.pm @@ -399,6 +399,35 @@ sub ec2spot_get_active_instances_status { return $instance_results; } +sub ec2spot_list_fleet_requests_set_cmd { + my ($self, %options) = @_; + + return if (defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne ''); + + my $cmd_options = "ec2 describe-spot-fleet-requests --no-dry-run --region $options{region} --output json"; + $cmd_options .= " --endpoint-url $self->{endpoint_url}" if (defined($self->{endpoint_url}) && $self->{endpoint_url} ne ''); + + return $cmd_options; +} + +sub ec2spot_list_fleet_requests { + my ($self, %options) = @_; + + my $cmd_options = $self->ec2spot_list_fleet_requests_set_cmd(%options); + my $raw_results = $self->execute(cmd_options => $cmd_options); + + my $resource_results = []; + foreach my $fleet_request (@{$raw_results->{SpotFleetRequestConfigs}}) { + push @{$resource_results}, { + SpotFleetRequestState => $fleet_request->{SpotFleetRequestState}, + SpotFleetRequestId => $fleet_request->{SpotFleetRequestId}, + ActivityStatus => $fleet_request->{ActivityStatus} + }; + } + + return $resource_results; +} + sub ec2_list_resources_set_cmd { my ($self, %options) = @_; diff --git a/cloud/aws/custom/paws.pm b/cloud/aws/custom/paws.pm index a1cab9d9e..06fcc5f29 100644 --- a/cloud/aws/custom/paws.pm +++ b/cloud/aws/custom/paws.pm @@ -336,6 +336,31 @@ sub ec2spot_get_active_instances { return $instance_results; } +sub ec2spot_list_fleet_requests { + my ($self, %options) = @_; + + my $resource_results = []; + eval { + my $lwp_caller = new Paws::Net::LWPCaller(); + my $ec2spot = Paws->service('EC2', caller => $lwp_caller, region => $options{region}); + my $spot_fleet_requests = $ec2spot->DescribeSpotFleetRequests(DryRun => 0); + + foreach (@{$spot_fleet_requests->{SpotFleetRequestConfigs}}) { + push @{$resource_results}, { + SpotFleetRequestState => $_->{SpotFleetRequestState}, + SpotFleetRequestId => $_->{SpotFleetRequestId}, + ActivityStatus => $_->{ActivityStatus} + }; + } + }; + if ($@) { + $self->{output}->add_option_msg(short_msg => "error: $@"); + $self->{output}->option_exit(); + } + + return $resource_results; +} + sub ec2_list_resources { my ($self, %options) = @_; diff --git a/cloud/aws/ec2/mode/discoveryspotfleetrequests.pm b/cloud/aws/ec2/mode/discoveryspotfleetrequests.pm new file mode 100644 index 000000000..64eeaf6f7 --- /dev/null +++ b/cloud/aws/ec2/mode/discoveryspotfleetrequests.pm @@ -0,0 +1,117 @@ +# +# Copyright 2020 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 cloud::aws::ec2::mode::discoveryspotfleetrequests; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use JSON::XS; + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $options{options}->add_options(arguments => { + "prettify" => { name => 'prettify' }, + "filter-state:s" => { name => 'filter_state' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); +} + +sub run { + my ($self, %options) = @_; + + my @disco_data; + my $disco_stats; + + $disco_stats->{start_time} = time(); + + my %asgs; + + my $spot_fleet_requests = $options{custom}->discovery( + region => $self->{option_results}->{region}, + service => 'ec2', + command => 'describe-spot-fleet-requests' + + ); + + foreach my $fleet_request (@{$spot_fleet_requests->{SpotFleetRequestConfigs}}) { + my %sfr; + $sfr{state} = $fleet_request->{SpotFleetRequestState}; + $sfr{id} = $fleet_request->{SpotFleetRequestId}; + $sfr{activity_status} = $fleet_request->{ActivityStatus}; + + push @disco_data, \%sfr unless (defined($self->{option_results}->{filter_state}) + && $sfr{state} !~ /$self->{option_results}->{filter_state}/); + } + + $disco_stats->{end_time} = time(); + $disco_stats->{duration} = $disco_stats->{end_time} - $disco_stats->{start_time}; + $disco_stats->{discovered_items} = @disco_data; + $disco_stats->{results} = \@disco_data; + + my $encoded_data; + eval { + if (defined($self->{option_results}->{prettify})) { + $encoded_data = JSON::XS->new->utf8->pretty->encode($disco_stats); + } else { + $encoded_data = JSON::XS->new->utf8->encode($disco_stats); + } + }; + if ($@) { + $encoded_data = '{"code":"encode_error","message":"Cannot encode discovered data into JSON format"}'; + } + + $self->{output}->output_add(short_msg => $encoded_data); + $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1); + $self->{output}->exit(); +} + +1; + +__END__ + +=head1 MODE + +EC2 Spot Fleet Requests discovery. + + +=over 8 + +=item B<--filter-state> + +Filter on Spot Fleet Request state. + +=item B<--prettify> + +Prettify JSON output. + +=back + +=cut diff --git a/cloud/aws/ec2/mode/listspotfleetrequests.pm b/cloud/aws/ec2/mode/listspotfleetrequests.pm new file mode 100644 index 000000000..340dc0bd9 --- /dev/null +++ b/cloud/aws/ec2/mode/listspotfleetrequests.pm @@ -0,0 +1,96 @@ +# +# Copyright 2020 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 cloud::aws::ec2::mode::listspotfleetrequests; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $options{options}->add_options(arguments => {}); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); +} + +sub manage_selection { + my ($self, %options) = @_; + + $self->{spot_fleet_requests} = $options{custom}->ec2spot_list_fleet_requests(region => $self->{option_results}->{region}); +} + +sub run { + my ($self, %options) = @_; + + $self->manage_selection(%options); + foreach (@{$self->{spot_fleet_requests}}) { + $self->{output}->output_add( + long_msg => sprintf("[id = %s][state = %s][status = %s]", + $_->{SpotFleetRequestId}, $_->{SpotFleetRequestState}, $_->{ActivityStatus})); + } + + $self->{output}->output_add(severity => 'OK', + short_msg => 'List spot fleet requests:'); + $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 => ['id', 'state', 'status']); +} + +sub disco_show { + my ($self, %options) = @_; + + $self->manage_selection(%options); + foreach (@{$self->{spot_fleet_requests}}) { + $self->{output}->add_disco_entry( + id => $_->{SpotFleetRequestId}, + state => $_->{SpotFleetRequestState}, + status => $_->{ActivityStatus} + ); + } +} + +1; + +__END__ + +=head1 MODE + +List EC2 Spot Fleet Requests + +=over 8 + +=back + +=cut diff --git a/cloud/aws/ec2/plugin.pm b/cloud/aws/ec2/plugin.pm index a359235ba..42d7cab05 100644 --- a/cloud/aws/ec2/plugin.pm +++ b/cloud/aws/ec2/plugin.pm @@ -31,17 +31,19 @@ sub new { $self->{version} = '0.1'; %{ $self->{modes} } = ( - 'asg-status' => 'cloud::aws::ec2::mode::asgstatus', - 'cpu' => 'cloud::aws::ec2::mode::cpu', - 'discovery' => 'cloud::aws::ec2::mode::discovery', - 'diskio' => 'cloud::aws::ec2::mode::diskio', - 'instances-status' => 'cloud::aws::ec2::mode::instancesstatus', - 'instances-types' => 'cloud::aws::ec2::mode::instancestypes', - 'list-asg' => 'cloud::aws::ec2::mode::listasg', - 'list-instances' => 'cloud::aws::ec2::mode::listinstances', - 'network' => 'cloud::aws::ec2::mode::network', - 'status' => 'cloud::aws::ec2::mode::status', - 'spot-active-instances' => 'cloud::aws::ec2::mode::spotactiveinstances' + 'asg-status' => 'cloud::aws::ec2::mode::asgstatus', + 'cpu' => 'cloud::aws::ec2::mode::cpu', + 'discovery' => 'cloud::aws::ec2::mode::discovery', + 'discovery-fleet-requests' => 'cloud::aws::ec2::mode::discoveryspotfleetrequests', + 'diskio' => 'cloud::aws::ec2::mode::diskio', + 'instances-status' => 'cloud::aws::ec2::mode::instancesstatus', + 'instances-types' => 'cloud::aws::ec2::mode::instancestypes', + 'list-asg' => 'cloud::aws::ec2::mode::listasg', + 'list-instances' => 'cloud::aws::ec2::mode::listinstances', + 'list-spot-fleet-requests' => 'cloud::aws::ec2::mode::listspotfleetrequests', + 'network' => 'cloud::aws::ec2::mode::network', + 'status' => 'cloud::aws::ec2::mode::status', + 'spot-active-instances' => 'cloud::aws::ec2::mode::spotactiveinstances' ); $self->{custom_modes}{paws} = 'cloud::aws::custom::paws'; From bc8afa16a09a9485345bd449b10f4b903821947a Mon Sep 17 00:00:00 2001 From: Sims24 Date: Sat, 2 May 2020 13:33:39 +0200 Subject: [PATCH 169/283] enh(plugin)add TargetGroup dimension elbv2 resolves #1968 --- cloud/aws/elb/application/mode/connections.pm | 5 +++++ cloud/aws/elb/application/mode/httpcodes.pm | 5 +++++ cloud/aws/elb/application/mode/targetshealth.pm | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/cloud/aws/elb/application/mode/connections.pm b/cloud/aws/elb/application/mode/connections.pm index e47d4ac8c..5b06a1705 100644 --- a/cloud/aws/elb/application/mode/connections.pm +++ b/cloud/aws/elb/application/mode/connections.pm @@ -115,6 +115,7 @@ sub new { "availability-zone:s" => { name => 'availability_zone' }, "filter-metric:s" => { name => 'filter_metric' }, "statistic:s@" => { name => 'statistic' }, + "target-group:s" => { name => 'target_group' } }); return $self; @@ -138,6 +139,10 @@ sub check_options { $self->{aws_timeframe} = defined($self->{option_results}->{timeframe}) ? $self->{option_results}->{timeframe} : 600; $self->{aws_period} = defined($self->{option_results}->{period}) ? $self->{option_results}->{period} : 60; + if (defined($self->{option_results}->{target_group}) && self->{option_results}->{target_group} ne '') { + push @{$self->{aws_dimensions}}, { Name => 'TargetGroup', Value => $self->{option_results}->{target_group} }; + } + $self->{aws_statistics} = ['Sum']; if (defined($self->{option_results}->{statistic})) { $self->{aws_statistics} = []; diff --git a/cloud/aws/elb/application/mode/httpcodes.pm b/cloud/aws/elb/application/mode/httpcodes.pm index 6ff8c5a45..6e0938fa8 100644 --- a/cloud/aws/elb/application/mode/httpcodes.pm +++ b/cloud/aws/elb/application/mode/httpcodes.pm @@ -129,6 +129,7 @@ sub new { "name:s@" => { name => 'name' }, "availability-zone:s" => { name => 'availability_zone' }, "filter-metric:s" => { name => 'filter_metric' }, + "target-group:s" => { name => 'target_group' } }); return $self; @@ -152,6 +153,10 @@ sub check_options { $self->{aws_timeframe} = defined($self->{option_results}->{timeframe}) ? $self->{option_results}->{timeframe} : 600; $self->{aws_period} = defined($self->{option_results}->{period}) ? $self->{option_results}->{period} : 60; + if (defined($self->{option_results}->{target_group}) && self->{option_results}->{target_group} ne '') { + push @{$self->{aws_dimensions}}, { Name => 'TargetGroup', Value => $self->{option_results}->{target_group} }; + } + $self->{aws_statistics} = ['Sum']; if (defined($self->{option_results}->{statistic})) { $self->{aws_statistics} = []; diff --git a/cloud/aws/elb/application/mode/targetshealth.pm b/cloud/aws/elb/application/mode/targetshealth.pm index e15525ae7..8ef5142f5 100644 --- a/cloud/aws/elb/application/mode/targetshealth.pm +++ b/cloud/aws/elb/application/mode/targetshealth.pm @@ -105,6 +105,7 @@ sub new { "availability-zone:s" => { name => 'availability_zone' }, "filter-metric:s" => { name => 'filter_metric' }, "statistic:s@" => { name => 'statistic' }, + "target-group:s" => { name => 'target_group' } }); return $self; @@ -128,6 +129,10 @@ sub check_options { $self->{aws_timeframe} = defined($self->{option_results}->{timeframe}) ? $self->{option_results}->{timeframe} : 600; $self->{aws_period} = defined($self->{option_results}->{period}) ? $self->{option_results}->{period} : 60; + if (defined($self->{option_results}->{target_group}) && self->{option_results}->{target_group} ne '') { + push @{$self->{aws_dimensions}}, { Name => 'TargetGroup', Value => $self->{option_results}->{target_group} }; + } + $self->{aws_statistics} = ['Average']; if (defined($self->{option_results}->{statistic})) { $self->{aws_statistics} = []; From 062b9b079cb43714cc887308810c112479dc284a Mon Sep 17 00:00:00 2001 From: Sims24 Date: Sat, 2 May 2020 13:38:39 +0200 Subject: [PATCH 170/283] fix(plugin) missing $ previous commit --- cloud/aws/elb/application/mode/connections.pm | 2 +- cloud/aws/elb/application/mode/httpcodes.pm | 2 +- cloud/aws/elb/application/mode/targetshealth.pm | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cloud/aws/elb/application/mode/connections.pm b/cloud/aws/elb/application/mode/connections.pm index 5b06a1705..903837b04 100644 --- a/cloud/aws/elb/application/mode/connections.pm +++ b/cloud/aws/elb/application/mode/connections.pm @@ -139,7 +139,7 @@ sub check_options { $self->{aws_timeframe} = defined($self->{option_results}->{timeframe}) ? $self->{option_results}->{timeframe} : 600; $self->{aws_period} = defined($self->{option_results}->{period}) ? $self->{option_results}->{period} : 60; - if (defined($self->{option_results}->{target_group}) && self->{option_results}->{target_group} ne '') { + if (defined($self->{option_results}->{target_group}) && $self->{option_results}->{target_group} ne '') { push @{$self->{aws_dimensions}}, { Name => 'TargetGroup', Value => $self->{option_results}->{target_group} }; } diff --git a/cloud/aws/elb/application/mode/httpcodes.pm b/cloud/aws/elb/application/mode/httpcodes.pm index 6e0938fa8..5838b084b 100644 --- a/cloud/aws/elb/application/mode/httpcodes.pm +++ b/cloud/aws/elb/application/mode/httpcodes.pm @@ -153,7 +153,7 @@ sub check_options { $self->{aws_timeframe} = defined($self->{option_results}->{timeframe}) ? $self->{option_results}->{timeframe} : 600; $self->{aws_period} = defined($self->{option_results}->{period}) ? $self->{option_results}->{period} : 60; - if (defined($self->{option_results}->{target_group}) && self->{option_results}->{target_group} ne '') { + if (defined($self->{option_results}->{target_group}) && $self->{option_results}->{target_group} ne '') { push @{$self->{aws_dimensions}}, { Name => 'TargetGroup', Value => $self->{option_results}->{target_group} }; } diff --git a/cloud/aws/elb/application/mode/targetshealth.pm b/cloud/aws/elb/application/mode/targetshealth.pm index 8ef5142f5..083139090 100644 --- a/cloud/aws/elb/application/mode/targetshealth.pm +++ b/cloud/aws/elb/application/mode/targetshealth.pm @@ -129,7 +129,7 @@ sub check_options { $self->{aws_timeframe} = defined($self->{option_results}->{timeframe}) ? $self->{option_results}->{timeframe} : 600; $self->{aws_period} = defined($self->{option_results}->{period}) ? $self->{option_results}->{period} : 60; - if (defined($self->{option_results}->{target_group}) && self->{option_results}->{target_group} ne '') { + if (defined($self->{option_results}->{target_group}) && $self->{option_results}->{target_group} ne '') { push @{$self->{aws_dimensions}}, { Name => 'TargetGroup', Value => $self->{option_results}->{target_group} }; } From 0ce98a6dbd8e46f6c34f4d7d8e120811fc63126a Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 4 May 2020 09:58:32 +0200 Subject: [PATCH 171/283] Fix #1951 --- .../iomega/snmp/mode/components/disk.pm | 71 +++++++ .../lenovo/iomega/snmp/mode/components/fan.pm | 84 ++++++++ .../iomega/snmp/mode/components/raid.pm | 67 +++++++ .../snmp/mode/components/temperature.pm | 84 ++++++++ .../iomega/snmp/mode/components/voltage.pm | 84 ++++++++ storage/lenovo/iomega/snmp/mode/hardware.pm | 117 +++++++++++ storage/lenovo/iomega/snmp/mode/interfaces.pm | 187 ++++++++++++++++++ storage/lenovo/iomega/snmp/mode/memory.pm | 184 +++++++++++++++++ storage/lenovo/iomega/snmp/plugin.pm | 53 +++++ 9 files changed, 931 insertions(+) create mode 100644 storage/lenovo/iomega/snmp/mode/components/disk.pm create mode 100644 storage/lenovo/iomega/snmp/mode/components/fan.pm create mode 100644 storage/lenovo/iomega/snmp/mode/components/raid.pm create mode 100644 storage/lenovo/iomega/snmp/mode/components/temperature.pm create mode 100644 storage/lenovo/iomega/snmp/mode/components/voltage.pm create mode 100644 storage/lenovo/iomega/snmp/mode/hardware.pm create mode 100644 storage/lenovo/iomega/snmp/mode/interfaces.pm create mode 100644 storage/lenovo/iomega/snmp/mode/memory.pm create mode 100644 storage/lenovo/iomega/snmp/plugin.pm diff --git a/storage/lenovo/iomega/snmp/mode/components/disk.pm b/storage/lenovo/iomega/snmp/mode/components/disk.pm new file mode 100644 index 000000000..59455a96d --- /dev/null +++ b/storage/lenovo/iomega/snmp/mode/components/disk.pm @@ -0,0 +1,71 @@ +# +# Copyright 2020 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 storage::lenovo::iomega::snmp::mode::components::disk; + +use strict; +use warnings; + +my $mapping = { + diskID => { oid => '.1.3.6.1.4.1.11369.10.4.3.1.2' }, + diskStatus => { oid => '.1.3.6.1.4.1.11369.10.4.3.1.4' }, +}; +my $oid_diskEntry = '.1.3.6.1.4.1.11369.10.4.3.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $oid_diskEntry }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => 'checking disks'); + $self->{components}->{disk} = { name => 'disks', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'disk')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{ $oid_diskEntry }})) { + next if ($oid !~ /^$mapping->{diskID}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{ $oid_diskEntry }, instance => $instance); + + next if ($self->check_filter(section => 'disk', instance => $instance)); + + $self->{components}->{disk}->{total}++; + $self->{output}->output_add( + long_msg => sprintf( + "disk '%s' status is '%s' [instance = %s]", + $result->{diskID}, $result->{diskStatus}, $instance + ) + ); + my $exit = $self->get_severity(section => 'disk', value => $result->{diskStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "Disk '%s' status is '%s'", $result->{diskID}, $result->{diskStatus} + ) + ); + } + } +} + +1; diff --git a/storage/lenovo/iomega/snmp/mode/components/fan.pm b/storage/lenovo/iomega/snmp/mode/components/fan.pm new file mode 100644 index 000000000..6775f811d --- /dev/null +++ b/storage/lenovo/iomega/snmp/mode/components/fan.pm @@ -0,0 +1,84 @@ +# +# Copyright 2020 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 storage::lenovo::iomega::snmp::mode::components::fan; + +use strict; +use warnings; + +my $mapping = { + fanName => { oid => '.1.3.6.1.4.1.11369.10.6.1.1.2' }, + fanValue => { oid => '.1.3.6.1.4.1.11369.10.6.1.1.3' } +}; +my $oid_fanEntry = '.1.3.6.1.4.1.11369.10.6.1.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { + oid => $oid_fanEntry, + start => $mapping->{fanName}->{oid} + }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => 'checking fans'); + $self->{components}->{fan} = { name => 'fans', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'fan')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{ $oid_fanEntry }})) { + next if ($oid !~ /^$mapping->{fanValue}->{oid}\.(.*)$/); + my $instance = $1; + + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{ $oid_fanEntry }, instance => $instance); + + next if ($self->check_filter(section => 'fan', instance => $instance)); + + $self->{components}->{fan}->{total}++; + $self->{output}->output_add( + long_msg => sprintf( + "fan '%s' speed is '%s' rpm [instance = %s]", + $result->{fanName}, $result->{fanValue}, $instance + ) + ); + + my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'fan', instance => $instance, value => $result->{fanValue}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "fan '%s' speed is '%s' rpm", $result->{fanName}, $result->{fanValue} + ) + ); + } + $self->{output}->perfdata_add( + nlabel => 'hardware.fan.speed.rpm', + unit => 'rpm', + instances => $result->{fanName}, + value => $result->{fanValue}, + warning => $warn, + critical => $crit, min => 0 + ); + } +} + +1; diff --git a/storage/lenovo/iomega/snmp/mode/components/raid.pm b/storage/lenovo/iomega/snmp/mode/components/raid.pm new file mode 100644 index 000000000..0b6031253 --- /dev/null +++ b/storage/lenovo/iomega/snmp/mode/components/raid.pm @@ -0,0 +1,67 @@ +# +# Copyright 2020 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 storage::lenovo::iomega::snmp::mode::components::raid; + +use strict; +use warnings; + +my $mapping = { + raidStatus => { oid => '.1.3.6.1.4.1.11369.10.4.1' } +}; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { oid => $mapping->{raidStatus}->{oid} }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => 'checking raids'); + $self->{components}->{raid} = { name => 'raids', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'raid')); + + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{ $mapping->{raidStatus}->{oid} }, instance => '0'); + return if (!defined($result->{raidStatus})); + + my $instance = 1; + next if ($self->check_filter(section => 'raid', instance => $instance)); + $self->{components}->{raid}->{total}++; + + $self->{output}->output_add( + long_msg => sprintf( + "raid '%s' status is '%s' [instance = %s]", + $instance, $result->{raidStatus}, $instance + ) + ); + my $exit = $self->get_severity(section => 'raid', value => $result->{raidStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "Raid '%s' status is '%s'", $instance, $result->{raidStatus} + ) + ); + } +} + +1; diff --git a/storage/lenovo/iomega/snmp/mode/components/temperature.pm b/storage/lenovo/iomega/snmp/mode/components/temperature.pm new file mode 100644 index 000000000..84e2e93b2 --- /dev/null +++ b/storage/lenovo/iomega/snmp/mode/components/temperature.pm @@ -0,0 +1,84 @@ +# +# Copyright 2020 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 storage::lenovo::iomega::snmp::mode::components::temperature; + +use strict; +use warnings; + +my $mapping = { + tempName => { oid => '.1.3.6.1.4.1.11369.10.6.2.1.2' }, + tempValue => { oid => '.1.3.6.1.4.1.11369.10.6.2.1.3' } +}; +my $oid_tempEntry = '.1.3.6.1.4.1.11369.10.6.2.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { + oid => $oid_tempEntry, + start => $mapping->{tempName}->{oid} + }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => 'checking temperatures'); + $self->{components}->{temperature} = { name => 'temperatures', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'temperature')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{ $oid_tempEntry }})) { + next if ($oid !~ /^$mapping->{tempValue}->{oid}\.(.*)$/); + my $instance = $1; + + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{ $oid_tempEntry }, instance => $instance); + + next if ($self->check_filter(section => 'temperature', instance => $instance)); + + $self->{components}->{temperature}->{total}++; + $self->{output}->output_add( + long_msg => sprintf( + "temperature '%s' is '%s' celsius [instance = %s]", + $result->{tempName}, $result->{tempValue}, $instance + ) + ); + + my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{tempValue}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "temperature '%s' is '%s' celsius", $result->{tempName}, $result->{tempValue} + ) + ); + } + $self->{output}->perfdata_add( + nlabel => 'hardware.temperature.celsius', + unit => 'C', + instances => $result->{tempName}, + value => $result->{tempValue}, + warning => $warn, + critical => $crit, min => 0 + ); + } +} + +1; diff --git a/storage/lenovo/iomega/snmp/mode/components/voltage.pm b/storage/lenovo/iomega/snmp/mode/components/voltage.pm new file mode 100644 index 000000000..d0df804a3 --- /dev/null +++ b/storage/lenovo/iomega/snmp/mode/components/voltage.pm @@ -0,0 +1,84 @@ +# +# Copyright 2020 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 storage::lenovo::iomega::snmp::mode::components::voltage; + +use strict; +use warnings; + +my $mapping = { + voltName => { oid => '.1.3.6.1.4.1.11369.10.6.3.1.2' }, + voltValue => { oid => '.1.3.6.1.4.1.11369.10.6.3.1.3' } +}; +my $oid_voltEntry = '.1.3.6.1.4.1.11369.10.6.3.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { + oid => $oid_voltEntry, + start => $mapping->{voltName}->{oid} + }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => 'checking voltages'); + $self->{components}->{voltage} = { name => 'voltages', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'voltage')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{ $oid_voltEntry }})) { + next if ($oid !~ /^$mapping->{voltValue}->{oid}\.(.*)$/); + my $instance = $1; + + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{ $oid_voltEntry }, instance => $instance); + + next if ($self->check_filter(section => 'voltage', instance => $instance)); + + $self->{components}->{voltage}->{total}++; + $self->{output}->output_add( + long_msg => sprintf( + "voltage '%s' is '%s' mV [instance = %s]", + $result->{voltName}, $result->{voltValue}, $instance + ) + ); + + my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'voltage', instance => $instance, value => $result->{voltValue}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "voltage '%s' is '%s' mV", $result->{voltName}, $result->{voltValue} + ) + ); + } + $self->{output}->perfdata_add( + nlabel => 'hardware.voltage.millivolt', + unit => 'mV', + instances => $result->{voltName}, + value => $result->{voltValue}, + warning => $warn, + critical => $crit, min => 0 + ); + } +} + +1; diff --git a/storage/lenovo/iomega/snmp/mode/hardware.pm b/storage/lenovo/iomega/snmp/mode/hardware.pm new file mode 100644 index 000000000..08fbbe626 --- /dev/null +++ b/storage/lenovo/iomega/snmp/mode/hardware.pm @@ -0,0 +1,117 @@ +# +# Copyright 2020 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 storage::lenovo::iomega::snmp::mode::hardware; + +use base qw(centreon::plugins::templates::hardware); + +use strict; +use warnings; + +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_overload_check_section_option} = '^(?:raid|disk)$'; + $self->{regexp_threshold_numeric_check_section_option} = '^(?:temperature|temperature|voltage)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + raid => [ + ['normal', 'OK'], + ['rebuilding', 'OK'], + ['degraded', 'WARNING'], + ['rebuildfs', 'OK'], + ['faulted', 'CRITICAL'] + ], + disk => [ + ['normal', 'OK'], + ['foreign', 'WARNING'], + ['faulted', 'CRITICAL'], + ['missing', 'OK'] + ] + }; + + $self->{components_path} = 'storage::lenovo::iomega::snmp::mode::components'; + $self->{components_module} = ['raid', 'disk', 'voltage', 'temperature', 'fan']; +} + +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1, force_new_perfdata => 1); + bless $self, $class; + + $options{options}->add_options(arguments => { + }); + + return $self; +} + +1; + +__END__ + +=head1 MODE + +Check hardware. + +=over 8 + +=item B<--component> + +Which component to check (Default: '.*'). +Can be: 'raid', 'disk', 'voltage', 'temperature', 'fan'. + +=item B<--filter> + +Exclude some parts (comma seperated list) (Example: --filter=fan) +Can also exclude specific instance: --filter=fan,1 + +=item B<--no-component> + +Return an error if no compenents are checked. +If total (with skipped) is 0. (Default: 'critical' returns). + +=item B<--threshold-overload> + +Set to overload default threshold values (syntax: section,[instance,]status,regexp) +It used before default thresholds (order stays). +Example: --threshold-overload='disk,WARNING,missing' + +=item B<--warning> + +Set warning threshold for 'temperature', 'voltage', 'fan' (syntax: type,regexp,threshold) +Example: --warning='temperature,.*,40' + +=item B<--critical> + +Set critical threshold for 'temperature', 'voltage', 'fan' (syntax: type,regexp,threshold) +Example: --critical='temperature,.*,50' + +=back + +=cut diff --git a/storage/lenovo/iomega/snmp/mode/interfaces.pm b/storage/lenovo/iomega/snmp/mode/interfaces.pm new file mode 100644 index 000000000..f33bf5d60 --- /dev/null +++ b/storage/lenovo/iomega/snmp/mode/interfaces.pm @@ -0,0 +1,187 @@ +# +# Copyright 2020 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 storage::lenovo::iomega::snmp::mode::interfaces; + +use base qw(snmp_standard::mode::interfaces); + +use strict; +use warnings; + +sub default_oid_filter_name { + my ($self, %options) = @_; + + return 'ifdesc'; +} + +sub default_oid_display_name { + my ($self, %options) = @_; + + return 'ifdesc'; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + return $self; +} + + +1; + +__END__ + +=head1 MODE + +Check interfaces. + +=over 8 + +=item B<--add-global> + +Check global port statistics (By default if no --add-* option is set). + +=item B<--add-status> + +Check interface status. + +=item B<--add-duplex-status> + +Check duplex status (with --warning-status and --critical-status). + +=item B<--add-traffic> + +Check interface traffic. + +=item B<--add-errors> + +Check interface errors. + +=item B<--add-cast> + +Check interface cast. + +=item B<--add-speed> + +Check interface speed. + +=item B<--add-volume> + +Check interface data volume between two checks (not supposed to be graphed, useful for BI reporting). + +=item B<--warning-status> + +Set warning threshold for status. +Can used special variables like: %{admstatus}, %{opstatus}, %{duplexstatus}, %{display} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{admstatus} eq "up" and %{opstatus} ne "up"'). +Can used special variables like: %{admstatus}, %{opstatus}, %{duplexstatus}, %{display} + +=item B<--warning-*> + +Threshold warning. +Can be: 'total-port', 'total-admin-up', 'total-admin-down', 'total-oper-up', 'total-oper-down', +'in-traffic', 'out-traffic', 'in-error', 'in-discard', 'out-error', 'out-discard', +'in-ucast' (%), 'in-bcast' (%), 'in-mcast' (%), 'out-ucast' (%), 'out-bcast' (%), 'out-mcast' (%), +'speed' (b/s). + +=item B<--critical-*> + +Threshold critical. +Can be: 'total-port', 'total-admin-up', 'total-admin-down', 'total-oper-up', 'total-oper-down', +'in-traffic', 'out-traffic', 'in-error', 'in-discard', 'out-error', 'out-discard', +'in-ucast' (%), 'in-bcast' (%), 'in-mcast' (%), 'out-ucast' (%), 'out-bcast' (%), 'out-mcast' (%), +'speed' (b/s). + +=item B<--units-traffic> + +Units of thresholds for the traffic (Default: '%') ('%', 'b/s'). + +=item B<--units-errors> + +Units of thresholds for errors/discards (Default: '%') ('%', 'absolute'). + +=item B<--nagvis-perfdata> + +Display traffic perfdata to be compatible with nagvis widget. + +=item B<--interface> + +Set the interface (number expected) ex: 1,2,... (empty means 'check all interface'). + +=item B<--name> + +Allows to use interface name with option --interface instead of interface oid index (Can be a regexp) + +=item B<--speed> + +Set interface speed for incoming/outgoing traffic (in Mb). + +=item B<--speed-in> + +Set interface speed for incoming traffic (in Mb). + +=item B<--speed-out> + +Set interface speed for outgoing traffic (in Mb). + +=item B<--no-skipped-counters> + +Don't skip counters when no change. + +=item B<--force-counters32> + +Force to use 32 bits counters (even in snmp v2c and v3). Should be used when 64 bits counters are buggy. + +=item B<--reload-cache-time> + +Time in minutes before reloading cache file (default: 180). + +=item B<--oid-filter> + +Choose OID used to filter interface (default: ifDesc) (values: ifDesc, ifAlias, ifName, IpAddr). + +=item B<--oid-display> + +Choose OID used to display interface (default: ifDesc) (values: ifDesc, ifAlias, ifName, IpAddr). + +=item B<--oid-extra-display> + +Add an OID to display. + +=item B<--display-transform-src> + +Regexp src to transform display value. + +=item B<--display-transform-dst> + +Regexp dst to transform display value. + +=item B<--show-cache> + +Display cache interface datas. + +=back + +=cut diff --git a/storage/lenovo/iomega/snmp/mode/memory.pm b/storage/lenovo/iomega/snmp/mode/memory.pm new file mode 100644 index 000000000..41a997002 --- /dev/null +++ b/storage/lenovo/iomega/snmp/mode/memory.pm @@ -0,0 +1,184 @@ +# +# Copyright 2020 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 storage::lenovo::iomega::snmp::mode::memory; + +use base qw(snmp_standard::mode::storage); + +use strict; +use warnings; + +sub custom_usage_output { + my ($self, %options) = @_; + + return sprintf( + 'Ram Total: %s %s Used (-buffers/cache): %s %s (%.2f%%) Free: %s %s (%.2f%%)', + $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_absolute}), + $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_absolute}), + $self->{result_values}->{prct_used_absolute}, + $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute}), + $self->{result_values}->{prct_free_absolute} + ); +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'ram', type => 0, skipped_code => { -10 => 1 } } + ]; + + $self->{maps_counters}->{ram} = [ + { label => 'usage', nlabel => 'memory.usage.bytes', set => { + key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], + closure_custom_output => $self->can('custom_usage_output'), + perfdatas => [ + { value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute', + unit => 'B', cast_int => 1 } + ] + } + }, + { label => 'usage-free', display_ok => 0, nlabel => 'memory.free.bytes', set => { + key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], + closure_custom_output => $self->can('custom_usage_output'), + perfdatas => [ + { value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute', + unit => 'B', cast_int => 1 } + ] + } + }, + { label => 'usage-prct', display_ok => 0, nlabel => 'memory.usage.percentage', set => { + key_values => [ { name => 'prct_used' } ], + output_template => 'Ram Used : %.2f %%', + perfdatas => [ + { value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, + unit => '%' } + ] + } + }, + { label => 'buffer', nlabel => 'memory.buffer.bytes', set => { + key_values => [ { name => 'buffer' } ], + output_template => 'Buffer: %s %s', + output_change_bytes => 1, + perfdatas => [ + { value => 'buffer_absolute', template => '%d', + min => 0, unit => 'B' } + ] + } + }, + { label => 'cached', nlabel => 'memory.cached.bytes', set => { + key_values => [ { name => 'cached' } ], + output_template => 'Cached: %s %s', + output_change_bytes => 1, + perfdatas => [ + { value => 'cached_absolute', template => '%d', + min => 0, unit => 'B' } + ] + } + } + ]; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); + bless $self, $class; + + return $self; +} + +my $mapping = { + hrStorageDescr => { oid => '.1.3.6.1.2.1.25.2.3.1.3' }, + hrStorageAllocationUnits => { oid => '.1.3.6.1.2.1.25.2.3.1.4' }, + hrStorageSize => { oid => '.1.3.6.1.2.1.25.2.3.1.5' }, + hrStorageUsed => { oid => '.1.3.6.1.2.1.25.2.3.1.6' } +}; + +sub manage_selection { + my ($self, %options) = @_; + + my $oid_hrstoragetype = '.1.3.6.1.2.1.25.2.3.1.2'; + + my $snmp_result = $options{snmp}->get_table(oid => $oid_hrstoragetype, nothing_quit => 1); + my $storages = []; + foreach (keys %$snmp_result) { + next if ($snmp_result->{$_} !~ /(?:\.1|\.2)$/); + /^$oid_hrstoragetype\.(.*)$/; + push @$storages, $1; + } + + $options{snmp}->load( + oids => [map($_->{oid}, values(%$mapping))], + instances => $storages, + nothing_quit => 1 + ); + $snmp_result = $options{snmp}->get_leef(); + + my ($total, $used, $cached, $buffer); + #.1.3.6.1.2.1.25.2.3.1.3.1 = STRING: Physical memory + #.1.3.6.1.2.1.25.2.3.1.3.2 = STRING: Memory buffers + #.1.3.6.1.2.1.25.2.3.1.3.3 = STRING: Cached memory + foreach (@$storages) { + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $_); + next if (!defined($result->{hrStorageUsed})); + my $current = $result->{hrStorageUsed} * $result->{hrStorageAllocationUnits}; + next if ($current < 0); + + if ($result->{hrStorageDescr} =~ /Cached\s+memory/i) { + $cached = $current; + } elsif ($result->{hrStorageDescr} =~ /Memory\s+buffers/i) { + $buffer = $current; + } elsif ($result->{hrStorageDescr} =~ /Physical\s+memory/i) { + $used = $current; + $total = $result->{hrStorageSize} * $result->{hrStorageAllocationUnits}; + } + } + + $used -= (defined($cached) ? $cached : 0) - (defined($buffer) ? $buffer : 0); + $self->{ram} = { + total => $total, + cached => $cached, + buffer => $buffer, + used => $used, + free => $total - $used, + prct_used => $used * 100 / $total, + prct_free => 100 - ($used * 100 / $total) + }; +} + +1; + +__END__ + +=head1 MODE + +Check memory. + +=over 8 + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'usage' (B), 'usage-free' (B), 'usage-prct' (%), +'buffer' (B), 'cached' (B). + +=back + +=cut diff --git a/storage/lenovo/iomega/snmp/plugin.pm b/storage/lenovo/iomega/snmp/plugin.pm new file mode 100644 index 000000000..428dac58c --- /dev/null +++ b/storage/lenovo/iomega/snmp/plugin.pm @@ -0,0 +1,53 @@ +# +# Copyright 2020 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 storage::lenovo::iomega::snmp::plugin; + +use strict; +use warnings; +use base qw(centreon::plugins::script_snmp); + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.0'; + %{$self->{modes}} = ( + 'cpu' => 'snmp_standard::mode::cpu', + 'hardware' => 'storage::lenovo::iomega::snmp::mode::hardware', + 'interfaces' => 'storage::lenovo::iomega::snmp::mode::interfaces', + 'list-interfaces' => 'snmp_standard::mode::listinterfaces', + 'memory' => 'storage::lenovo::iomega::snmp::mode::memory', + 'storage' => 'snmp_standard::mode::storage' + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Lenovo Nas Iomega (ix2) in SNMP. + +=cut From 156c651cd5c16dcc217e29984891d7cbd5ae2d61 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 4 May 2020 10:34:20 +0200 Subject: [PATCH 172/283] add ignore permission errors --- .../cloudcontroller/restapi/custom/api.pm | 69 ++++++++++++++----- .../cloudcontroller/restapi/mode/discovery.pm | 22 ++++-- 2 files changed, 69 insertions(+), 22 deletions(-) diff --git a/network/cisco/meraki/cloudcontroller/restapi/custom/api.pm b/network/cisco/meraki/cloudcontroller/restapi/custom/api.pm index 6e866a2f6..ca32a5106 100644 --- a/network/cisco/meraki/cloudcontroller/restapi/custom/api.pm +++ b/network/cisco/meraki/cloudcontroller/restapi/custom/api.pm @@ -43,12 +43,13 @@ sub new { if (!defined($options{noptions})) { $options{options}->add_options(arguments => { - 'hostname:s' => { name => 'hostname' }, - 'port:s' => { name => 'port' }, - 'proto:s' => { name => 'proto' }, - 'api-token:s' => { name => 'api_token' }, - 'timeout:s' => { name => 'timeout' }, - 'reload-cache-time:s' => { name => 'reload_cache_time' } + 'hostname:s' => { name => 'hostname' }, + 'port:s' => { name => 'port' }, + 'proto:s' => { name => 'proto' }, + 'api-token:s' => { name => 'api_token' }, + 'timeout:s' => { name => 'timeout' }, + 'reload-cache-time:s' => { name => 'reload_cache_time' }, + 'ignore-permission-errors' => { name => 'ignore_permission_errors' } }); } $options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1); @@ -93,6 +94,7 @@ sub check_options { $self->{timeout} = (defined($self->{option_results}->{timeout})) ? $self->{option_results}->{timeout} : 10; $self->{api_token} = (defined($self->{option_results}->{api_token})) ? $self->{option_results}->{api_token} : ''; $self->{reload_cache_time} = (defined($self->{option_results}->{reload_cache_time})) ? $self->{option_results}->{reload_cache_time} : 180; + $self->{ignore_permission_errors} = (defined($self->{option_results}->{ignore_permission_errors})) ? 1 : 0; if (!defined($self->{hostname}) || $self->{hostname} eq '') { $self->{output}->add_option_msg(short_msg => "Need to specify --hostname option."); @@ -168,7 +170,10 @@ sub request_api { unknown_status => '(%{http_code} < 200 or %{http_code} >= 300) and %{http_code} != 429' ); - if ($self->{http}->get_code() == 429) { + my $code = $self->{http}->get_code(); + return [] if ($code == 403 && $self->{ignore_permission_errors} == 1); + + if ($code == 429) { sleep(1); continue; } @@ -199,9 +204,17 @@ sub cache_meraki_entities { if ($has_cache_file == 0 || !defined($timestamp_cache) || ((time() - $timestamp_cache) > (($self->{reload_cache_time}) * 60))) { $self->{cache_organizations} = {}; - $self->{cache_organizations} = $self->get_organizations(disable_cache => 1); - $self->{cache_networks} = $self->get_networks(organizations => [keys %{$self->{cache_organizations}}], disable_cache => 1); - $self->{cache_devices} = $self->get_devices(organizations => [keys %{$self->{cache_organizations}}], disable_cache => 1); + $self->{cache_organizations} = $self->get_organizations( + disable_cache => 1 + ); + $self->{cache_networks} = $self->get_networks( + organizations => [keys %{$self->{cache_organizations}}], + disable_cache => 1 + ); + $self->{cache_devices} = $self->get_devices( + organizations => [keys %{$self->{cache_organizations}}], + disable_cache => 1 + ); $self->{cache}->write(data => { last_timestamp => time(), @@ -232,7 +245,9 @@ sub get_networks { my $results = {}; foreach my $id (keys %{$self->{cache_organizations}}) { - my $datas = $self->request_api(endpoint => '/organizations/' . $id . '/networks'); + my $datas = $self->request_api( + endpoint => '/organizations/' . $id . '/networks' + ); $results->{$_->{id}} = $_ foreach (@$datas); } @@ -247,7 +262,9 @@ sub get_devices { my $results = {}; foreach my $id (keys %{$self->{cache_organizations}}) { - my $datas = $self->request_api(endpoint => '/organizations/' . $id . '/devices'); + my $datas = $self->request_api( + endpoint => '/organizations/' . $id . '/devices' + ); $results->{$_->{serial}} = $_ foreach (@$datas); } @@ -316,7 +333,9 @@ sub get_networks_clients { $timespan = 1 if ($timespan <= 0); my $results = {}; foreach my $id (@$network_ids) { - my $datas = $self->request_api(endpoint => '/networks/' . $id . '/clients?timespan=' . $options{timespan}); + my $datas = $self->request_api( + endpoint => '/networks/' . $id . '/clients?timespan=' . $options{timespan}, + ); $results->{$id} = $datas; } @@ -330,7 +349,9 @@ sub get_organization_device_statuses { my $organization_ids = $self->filter_organizations(filter_name => $options{filter_name}); my $results = {}; foreach my $id (@$organization_ids) { - my $datas = $self->request_api(endpoint => '/organizations/' . $id . '/deviceStatuses'); + my $datas = $self->request_api( + endpoint => '/organizations/' . $id . '/deviceStatuses' + ); foreach (@$datas) { $results->{$_->{serial}} = $_; $results->{organizationId} = $id; @@ -350,7 +371,9 @@ sub get_organization_api_requests_overview { my $results = {}; foreach my $id (@$organization_ids) { - $results->{$id} = $self->request_api(endpoint => '/organizations/' . $id . '/apiRequests/overview?timespan=' . $options{timespan}); + $results->{$id} = $self->request_api( + endpoint => '/organizations/' . $id . '/apiRequests/overview?timespan=' . $options{timespan} + ); } return $results; @@ -370,7 +393,9 @@ sub get_network_device_connection_stats { my $results = {}; foreach (keys %{$options{devices}}) { - my $data = $self->request_api(endpoint => '/networks/' . $options{devices}->{$_} . '/devices/' . $_ . '/connectionStats?timespan=' . $options{timespan}); + my $data = $self->request_api( + endpoint => '/networks/' . $options{devices}->{$_} . '/devices/' . $_ . '/connectionStats?timespan=' . $options{timespan} + ); $results->{$_} = $data; } @@ -389,7 +414,9 @@ sub get_network_device_uplink { my $results = {}; foreach (keys %{$options{devices}}) { - my $data = $self->request_api(endpoint => '/networks/' . $options{devices}->{$_} . '/devices/' . $_ . '/uplink'); + my $data = $self->request_api( + endpoint => '/networks/' . $options{devices}->{$_} . '/devices/' . $_ . '/uplink' + ); $results->{$_} = $data; } @@ -410,7 +437,9 @@ sub get_device_clients { my $results = {}; foreach (keys %{$options{devices}}) { - my $data = $self->request_api(endpoint => '/devices/' . $_ . '/clients?timespan=' . $options{timespan}); + my $data = $self->request_api( + endpoint => '/devices/' . $_ . '/clients?timespan=' . $options{timespan} + ); $results->{$_} = $data; } @@ -457,6 +486,10 @@ Set HTTP timeout Time in minutes before reloading cache file (default: 180). +=item B<--ignore-permission-errors> + +Ignore permission errors (403 status code). + =back =head1 DESCRIPTION diff --git a/network/cisco/meraki/cloudcontroller/restapi/mode/discovery.pm b/network/cisco/meraki/cloudcontroller/restapi/mode/discovery.pm index 2ceffee3c..fcc3047c3 100644 --- a/network/cisco/meraki/cloudcontroller/restapi/mode/discovery.pm +++ b/network/cisco/meraki/cloudcontroller/restapi/mode/discovery.pm @@ -30,9 +30,9 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - + $options{options}->add_options(arguments => { - 'prettify' => { name => 'prettify' }, + 'prettify' => { name => 'prettify' } }); return $self; @@ -50,8 +50,14 @@ sub run { $disco_stats->{start_time} = time(); my $organizations = $options{custom}->get_organizations(disable_cache => 1); - my $networks = $options{custom}->get_networks(organizations => [keys %{$self->{organizations}}], disable_cache => 1); - my $devices = $options{custom}->get_devices(organizations => [keys %{$self->{organizations}}], disable_cache => 1); + my $networks = $options{custom}->get_networks( + organizations => [keys %{$self->{organizations}}], + disable_cache => 1 + ); + my $devices = $options{custom}->get_devices( + organizations => [keys %{$self->{organizations}}], + disable_cache => 1 + ); my $devices_statuses = $options{custom}->get_organization_device_statuses(); $disco_stats->{end_time} = time(); @@ -109,6 +115,14 @@ Resources discovery. =over 8 +=item B<--prettify> + +Prettify JSON output. + +=item B<--ignore-permission-errors> + +Continue the discovery and ignore permission errors (403 status code). + =back =cut From 889403d2cfe2d4dc9b988326c9a901113eb1cdf0 Mon Sep 17 00:00:00 2001 From: UrBnW <40244829+UrBnW@users.noreply.github.com> Date: Mon, 4 May 2020 15:04:29 +0200 Subject: [PATCH 173/283] Interfaces typo --- network/atrica/snmp/mode/connections.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/network/atrica/snmp/mode/connections.pm b/network/atrica/snmp/mode/connections.pm index acc2972d4..01976643c 100644 --- a/network/atrica/snmp/mode/connections.pm +++ b/network/atrica/snmp/mode/connections.pm @@ -189,7 +189,7 @@ sub set_counters_errors { my ($self, %options) = @_; push @{$self->{maps_counters}->{int}}, - { label => 'in-eir-discard', filter => 'add_errors', nlabel => 'interface.packets.in.eir.discards.count', set => { + { label => 'in-eir-discard', filter => 'add_errors', nlabel => 'interface.packets.in.eir.discard.count', set => { key_values => [ { name => 'in_eir_discard', diff => 1 }, { name => 'speed_in'}, { name => 'display' } ], per_second => 1, closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'in_eir_discard' }, @@ -198,7 +198,7 @@ sub set_counters_errors { closure_custom_threshold_check => $self->can('custom_traffic_threshold'), } }, - { label => 'out-eir-discard', filter => 'add_errors', nlabel => 'interface.packets.out.eir.discards.count', set => { + { label => 'out-eir-discard', filter => 'add_errors', nlabel => 'interface.packets.out.eir.discard.count', set => { key_values => [ { name => 'out_eir_discard', diff => 1 }, { name => 'speed_out'}, { name => 'display' } ], per_second => 1, closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'out_eir_discard' }, From ae589af601af196e39e3d56ae9605f3e7542e4c3 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 4 May 2020 15:17:45 +0200 Subject: [PATCH 174/283] fix loop meraki --- network/cisco/meraki/cloudcontroller/restapi/custom/api.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/network/cisco/meraki/cloudcontroller/restapi/custom/api.pm b/network/cisco/meraki/cloudcontroller/restapi/custom/api.pm index ca32a5106..c70f0b2df 100644 --- a/network/cisco/meraki/cloudcontroller/restapi/custom/api.pm +++ b/network/cisco/meraki/cloudcontroller/restapi/custom/api.pm @@ -162,7 +162,7 @@ sub request_api { #403: Forbidden- You don't have permission to do that. #404: Not found- No such URL, or you don't have access to the API or organization at all. #429: Too Many Requests- You submitted more than 5 calls in 1 second to an Organization, triggering rate limiting. This also applies for API calls made across multiple organizations that triggers rate limiting for one of the organizations. - do { + while (1) { my $response = $self->{http}->request( url_path => '/api/v0' . $options{endpoint}, critical_status => '', @@ -186,8 +186,9 @@ sub request_api { $self->{output}->add_option_msg(short_msg => "Cannot decode json response: $@"); $self->{output}->option_exit(); } + return ($content); - } while (1); + } } sub cache_meraki_entities { From 4d7853a1ab24b54da309d07ccffb6fffdff8c8c6 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 4 May 2020 15:50:05 +0200 Subject: [PATCH 175/283] Fix #1937 --- .../zonedirector/snmp/mode/accesspoints.pm | 333 ++++++++++++++++++ .../snmp/mode/listaccesspoints.pm | 131 +++++++ .../ruckus/zonedirector/snmp/mode/system.pm | 292 +++++++++++++++ network/ruckus/zonedirector/snmp/plugin.pm | 50 +++ 4 files changed, 806 insertions(+) create mode 100644 network/ruckus/zonedirector/snmp/mode/accesspoints.pm create mode 100644 network/ruckus/zonedirector/snmp/mode/listaccesspoints.pm create mode 100644 network/ruckus/zonedirector/snmp/mode/system.pm create mode 100644 network/ruckus/zonedirector/snmp/plugin.pm diff --git a/network/ruckus/zonedirector/snmp/mode/accesspoints.pm b/network/ruckus/zonedirector/snmp/mode/accesspoints.pm new file mode 100644 index 000000000..cff5240fe --- /dev/null +++ b/network/ruckus/zonedirector/snmp/mode/accesspoints.pm @@ -0,0 +1,333 @@ +# +# Copyright 2020 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 network::ruckus::zonedirector::snmp::mode::accesspoints; + +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 catalog_status_calc); + +sub custom_status_output { + my ($self, %options) = @_; + + return sprintf('zone directory connection status is %s', + $self->{result_values}->{zd_connection_status} + ); +} + +sub ap_long_output { + my ($self, %options) = @_; + + return "checking access point '" . $options{instance_value}->{display} . "'"; +} + +sub prefix_ap_output { + my ($self, %options) = @_; + + return "access point '" . $options{instance_value}->{display} . "' "; +} + +sub custom_usage_output { + my ($self, %options) = @_; + + return sprintf( + 'ram total: %s %s used: %s %s (%.2f%%) free: %s %s (%.2f%%)', + $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_absolute}), + $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_absolute}), + $self->{result_values}->{prct_used_absolute}, + $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute}), + $self->{result_values}->{prct_free_absolute} + ); +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'accesspoints', type => 3, cb_prefix_output => 'prefix_ap_output', cb_long_output => 'ap_long_output', + indent_long_output => ' ', message_multiple => 'All access points are ok', + group => [ + { name => 'status', type => 0, skipped_code => { -10 => 1 } }, + { name => 'cpu', type => 0, skipped_code => { -10 => 1 } }, + { name => 'memory', type => 0, skipped_code => { -10 => 1 } }, + { name => 'connection', type => 0, skipped_code => { -10 => 1 } }, + { name => 'traffic', type => 0, skipped_code => { -10 => 1 } } + ] + } + ]; + + $self->{maps_counters}->{status} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'zd_connection_status' }, { name => 'display' } ], + closure_custom_calc => \&catalog_status_calc, + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold + } + } + ]; + + $self->{maps_counters}->{cpu} = [ + { label => 'cpu-utilization', nlabel => 'accesspoint.cpu.utilization.percentage', set => { + key_values => [ { name => 'cpu_util' }, { name => 'display' } ], + output_template => 'cpu usage: %.2f%%', + perfdatas => [ + { value => 'cpu_util_absolute', template => '%.2f', unit => '%', + min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' } + ] + } + } + ]; + + $self->{maps_counters}->{memory} = [ + { label => 'memory-usage', nlabel => 'accesspoint.memory.usage.bytes', set => { + key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'display' } ], + closure_custom_output => $self->can('custom_usage_output'), + perfdatas => [ + { value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute', + unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' } + ] + } + }, + { label => 'usage-free', display_ok => 0, nlabel => 'accesspoint.memory.free.bytes', set => { + key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'display' } ], + closure_custom_output => $self->can('custom_usage_output'), + perfdatas => [ + { value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute', + unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' } + ] + } + }, + { label => 'usage-prct', display_ok => 0, nlabel => 'accesspoint.memory.usage.percentage', set => { + key_values => [ { name => 'prct_used' }, { name => 'display' } ], + output_template => 'ram used: %.2f %%', + perfdatas => [ + { value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, + label_extra_instance => 1, instance_use => 'display_absolute' } + ] + } + } + ]; + + $self->{maps_counters}->{connection} = [ + { label => 'connection-accesspoints', nlabel => 'accesspoint.connection.accesspoints.count', set => { + key_values => [ { name => 'ap' }, { name => 'display' } ], + output_template => 'access points connections: %d', + perfdatas => [ + { value => 'ap_absolute', template => '%d', min => 0 } + ] + } + }, + { label => 'connection-client-devices-authorized', nlabel => 'accesspoint.connection.client.devices.authorized.count', set => { + key_values => [ { name => 'authorized_clients' }, { name => 'display' } ], + output_template => 'client devices authorized connections: %d', + perfdatas => [ + { value => 'authorized_clients_absolute', template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' } + ] + } + }, + { label => 'connection-rogue-devices', nlabel => 'accesspoint.connection.rogue.devices.count', display_ok => 0, set => { + key_values => [ { name => 'rogues' }, { name => 'display' } ], + output_template => 'rogue devices connections: %d', + perfdatas => [ + { value => 'rogues_absolute', template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' } + ] + } + } + ]; + + $self->{maps_counters}->{traffic} = [ + { label => 'traffic-in', nlabel => 'accesspoint.traffic.in.bitspersecond', set => { + key_values => [ { name => 'traffic_in', diff => 1 }, { name => 'display' } ], + output_template => 'traffic in: %s%s/s', + per_second => 1, output_change_bytes => 2, + perfdatas => [ + { value => 'traffic_in_per_second', template => '%s', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' } + ] + } + }, + { label => 'traffic-out', nlabel => 'accesspoint.traffic.out.bitspersecond', set => { + key_values => [ { name => 'traffic_out', diff => 1 }, { name => 'display' } ], + output_template => 'traffic in: %s%s/s', + per_second => 1, output_change_bytes => 2, + perfdatas => [ + { value => 'traffic_out_per_second', template => '%s', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' } + ] + } + } + ]; +} + +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 => { + 'filter-name:s' => { name => 'filter_name' }, + 'unknown-status:s' => { name => 'unknown_status', default => '' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '' } + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->change_macros(macros => ['unknown_status', 'warning_status', 'critical_status']); +} + +my $map_zd_connection_status = { + 0 => 'disconnected', 1 => 'connected', 2 => 'approvalPending', 3 => 'upgradingFirmware', 4 => 'provisioning' +}; + +my $mapping = { + zd_connection_status => { oid => '.1.3.6.1.4.1.25053.1.2.2.1.1.2.1.1.3', map => $map_zd_connection_status }, # ruckusZDWLANAPStatus + cpu_util => { oid => '.1.3.6.1.4.1.25053.1.2.2.1.1.2.1.1.29' }, # ruckusZDWLANAPCPUUtil + memory_used => { oid => '.1.3.6.1.4.1.25053.1.2.2.1.1.2.1.1.27' }, # ruckusZDWLANAPMemUtil (% or KB) + memory_size => { oid => '.1.3.6.1.4.1.25053.1.2.2.1.1.2.1.1.28' }, # ruckusZDWLANAPMemTotal (KB) + ap => { oid => '.1.3.6.1.4.1.25053.1.2.2.1.1.2.1.1.14' }, # ruckusZDWLANAPNumVAP + authorized_clients => { oid => '.1.3.6.1.4.1.25053.1.2.2.1.1.2.1.1.15' }, # ruckusZDWLANAPNumSta + rogues => { oid => '.1.3.6.1.4.1.25053.1.2.2.1.1.2.1.1.16' }, # ruckusZDWLANAPNumRogues + traffic_in => { oid => '.1.3.6.1.4.1.25053.1.2.2.1.1.2.1.1.21' }, # ruckusZDWLANAPLANStatsRXByte + traffic_out => { oid => '.1.3.6.1.4.1.25053.1.2.2.1.1.2.1.1.25' } # ruckusZDWLANAPLANStatsTXByte +}; + +sub manage_selection { + my ($self, %options) = @_; + + my $oid_ruckusZDWLANAPDescription = '.1.3.6.1.4.1.25053.1.2.2.1.1.2.1.1.2'; + my $oid_ruckusZDWLANAPSerialNumber = '.1.3.6.1.4.1.25053.1.2.2.1.1.2.1.1.5'; + my $snmp_result = $options{snmp}->get_multiple_table( + oids => [ + { oid => $oid_ruckusZDWLANAPDescription }, + { oid => $oid_ruckusZDWLANAPSerialNumber } + ], + return_type => 1, + nothing_quit => 1 + ); + + $self->{accesspoints} = {}; + foreach (keys %$snmp_result) { + next if (! /^$oid_ruckusZDWLANAPDescription\.(.*)/); + my $instance = $1; + my $name = defined($snmp_result->{$_}) && $snmp_result->{$_} ne '' ? + $snmp_result->{$_} : $snmp_result->{$oid_ruckusZDWLANAPSerialNumber . '.' . $instance}; + + 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 access point '" . $name . "'.", debug => 1); + next; + } + + $self->{accesspoints}->{$instance} = { + display => $name, + status => { display => $name }, + cpu => { display => $name }, + memory => { display => $name }, + connection => { display => $name }, + traffic => { display => $name } + }; + } + + return if (scalar(keys %{$self->{accesspoints}}) <= 0); + + $options{snmp}->load( + oids => [ map($_->{oid}, values(%$mapping)) ], + instances => [ keys %{$self->{accesspoints}} ], + instance_regexp => '^(.*)$' + ); + $snmp_result = $options{snmp}->get_leef(); + foreach (keys %{$self->{accesspoints}}) { + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $_); + + $self->{accesspoints}->{$_}->{status}->{zd_connection_status} = $result->{zd_connection_status}; + $self->{accesspoints}->{$_}->{cpu}->{cpu_util} = $result->{cpu_util}; + + my $memory_total = $result->{memory_size} * 1024; + my $memory_used = $result->{memory_used} <= 100 ? ($result->{memory_used} * $memory_total / 100) : $result->{memory_used} * 1024; + my $memory_used_prct = $result->{memory_used} <= 100 ? $result->{memory_used} : ($memory_used * 100 / $memory_total); + $self->{accesspoints}->{$_}->{memory}->{used} = $memory_used; + $self->{accesspoints}->{$_}->{memory}->{free} = $memory_total - $memory_used; + $self->{accesspoints}->{$_}->{memory}->{prct_used} = $memory_used_prct; + $self->{accesspoints}->{$_}->{memory}->{prct_free} = 100 - $memory_used_prct; + $self->{accesspoints}->{$_}->{memory}->{total} = $memory_total; + + $self->{accesspoints}->{$_}->{connection}->{ap} = $result->{ap}; + $self->{accesspoints}->{$_}->{connection}->{authorized_clients} = $result->{authorized_clients}; + $self->{accesspoints}->{$_}->{connection}->{rogues} = $result->{rogues}; + + $self->{accesspoints}->{$_}->{traffic}->{traffic_in} = $result->{traffic_in} * 8; + $self->{accesspoints}->{$_}->{traffic}->{traffic_out} = $result->{traffic_out} * 8; + } + + $self->{cache_name} = 'ruckus_zd_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' . + (defined($self->{option_results}->{filter_counters_block}) ? md5_hex($self->{option_results}->{filter_counters_block}) : md5_hex('all')) . '_' . + (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 access points. + +=over 8 + +=item B<--filter-name> + +Filter by access point name (can be a regexp). + +=item B<--unknown-status> + +Set unknown threshold for status. +Can used special variables like: %{zd_connection_status} + +=item B<--warning-status> + +Set warning threshold for status. +Can used special variables like: %{zd_connection_status} + +=item B<--critical-status> + +Set critical threshold for status. +Can used special variables like: %{zd_connection_status} + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'memory-usage', 'usage-free', 'usage-prct', 'traffic-in', 'traffic-out', +'cpu-utilization', 'connection-accesspoints', 'connection-client-devices-authorized', +'connection-rogue-devices'. + +=back + +=cut diff --git a/network/ruckus/zonedirector/snmp/mode/listaccesspoints.pm b/network/ruckus/zonedirector/snmp/mode/listaccesspoints.pm new file mode 100644 index 000000000..93209a57e --- /dev/null +++ b/network/ruckus/zonedirector/snmp/mode/listaccesspoints.pm @@ -0,0 +1,131 @@ +# +# Copyright 2020 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 network::ruckus::zonedirector::snmp::mode::listaccesspoints; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +my $map_zd_connection_status = { + 0 => 'disconnected', 1 => 'connected', 2 => 'approvalPending', 3 => 'upgradingFirmware', 4 => 'provisioning' +}; + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $options{options}->add_options(arguments => { + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); +} + +my $mapping = { + description => { oid => '.1.3.6.1.4.1.25053.1.2.2.1.1.2.1.1.2' }, # ruckusZDWLANAPDescription + zd_connection_status => { oid => '.1.3.6.1.4.1.25053.1.2.2.1.1.2.1.1.3', map => $map_zd_connection_status }, # ruckusZDWLANAPStatus + model => { oid => '.1.3.6.1.4.1.25053.1.2.2.1.1.2.1.1.4' }, # ruckusZDWLANAPModel + serial_number => { oid => '.1.3.6.1.4.1.25053.1.2.2.1.1.2.1.1.5' }, # ruckusZDWLANAPSerialNumber +}; +my $oid_ruckusZDWLANAPEntry = '.1.3.6.1.4.1.25053.1.2.2.1.1.2.1.1'; + +sub manage_selection { + my ($self, %options) = @_; + + my $snmp_result = $options{snmp}->get_table( + oid => $oid_ruckusZDWLANAPEntry, + start => $mapping->{description}->{oid}, + end => $mapping->{serial_number}->{oid}, + nothing_quit => 1 + ); + + my $accesspoints = {}; + foreach my $oid (keys %$snmp_result) { + next if ($oid !~ /^$mapping->{description}->{oid}\.(.*)$/); + my $instance = $1; + $accesspoints->{$instance} = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance); + } + + return $accesspoints; +} + +sub run { + my ($self, %options) = @_; + + my $accesspoints = $self->manage_selection(%options); + foreach (sort keys %$accesspoints) { + $self->{output}->output_add( + long_msg => sprintf( + '[description: %s] [serial number: %s] [model: %s] [zonedirector connection status: %s]', + $accesspoints->{$_}->{description}, + $accesspoints->{$_}->{serial_number}, + $accesspoints->{$_}->{model}, + $accesspoints->{$_}->{zd_connection_status} + + ) + ); + } + + $self->{output}->output_add( + severity => 'OK', + short_msg => 'List acess points:' + ); + $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 => [keys %$mapping]); +} + +sub disco_show { + my ($self, %options) = @_; + + my $accesspoints = $self->manage_selection(%options); + foreach (sort keys %$accesspoints) { + $self->{output}->add_disco_entry( + %{$accesspoints->{$_}} + ); + } +} + +1; + +__END__ + +=head1 MODE + +List acess points. + +=over 8 + +=back + +=cut + diff --git a/network/ruckus/zonedirector/snmp/mode/system.pm b/network/ruckus/zonedirector/snmp/mode/system.pm new file mode 100644 index 000000000..54f0886a6 --- /dev/null +++ b/network/ruckus/zonedirector/snmp/mode/system.pm @@ -0,0 +1,292 @@ +# +# Copyright 2020 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 network::ruckus::zonedirector::snmp::mode::system; + +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 catalog_status_calc); + +sub custom_status_output { + my ($self, %options) = @_; + + return sprintf('system status is %s [peer status: %s]', + $self->{result_values}->{system_status}, + $self->{result_values}->{peer_connected_status} + ); +} + +sub system_long_output { + my ($self, %options) = @_; + + return 'checking system '; +} + +sub custom_usage_output { + my ($self, %options) = @_; + + return sprintf( + 'ram total: %s %s used: %s %s (%.2f%%) free: %s %s (%.2f%%)', + $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_absolute}), + $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_absolute}), + $self->{result_values}->{prct_used_absolute}, + $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute}), + $self->{result_values}->{prct_free_absolute} + ); +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'system', type => 3, cb_long_output => 'system_long_output', + indent_long_output => ' ', + group => [ + { name => 'status', type => 0, skipped_code => { -10 => 1 } }, + { name => 'cpu', type => 0, skipped_code => { -10 => 1 } }, + { name => 'memory', type => 0, skipped_code => { -10 => 1 } }, + { name => 'connection', type => 0, skipped_code => { -10 => 1 } }, + { name => 'traffic', type => 0, skipped_code => { -10 => 1 } } + ] + } + ]; + + $self->{maps_counters}->{status} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'system_status' }, { name => 'peer_connected_status' } ], + closure_custom_calc => \&catalog_status_calc, + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold + } + } + ]; + + $self->{maps_counters}->{cpu} = [ + { label => 'cpu-utilization', nlabel => 'system.cpu.utilization.percentage', set => { + key_values => [ { name => 'cpu_util' } ], + output_template => 'cpu usage: %.2f%%', + perfdatas => [ + { value => 'cpu_util_absolute', template => '%.2f', unit => '%', min => 0, max => 100 } + ] + } + } + ]; + + $self->{maps_counters}->{memory} = [ + { label => 'memory-usage', nlabel => 'system.memory.usage.bytes', set => { + key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], + closure_custom_output => $self->can('custom_usage_output'), + perfdatas => [ + { value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute', + unit => 'B', cast_int => 1 } + ] + } + }, + { label => 'usage-free', display_ok => 0, nlabel => 'system.memory.free.bytes', set => { + key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], + closure_custom_output => $self->can('custom_usage_output'), + perfdatas => [ + { value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute', + unit => 'B', cast_int => 1 } + ] + } + }, + { label => 'usage-prct', display_ok => 0, nlabel => 'system.memory.usage.percentage', set => { + key_values => [ { name => 'prct_used' } ], + output_template => 'ram used: %.2f %%', + perfdatas => [ + { value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100 } + ] + } + } + ]; + + $self->{maps_counters}->{connection} = [ + { label => 'connection-accesspoints', nlabel => 'system.connection.accesspoints.count', set => { + key_values => [ { name => 'ap' } ], + output_template => 'access points connections: %d', + perfdatas => [ + { value => 'ap_absolute', template => '%d', min => 0 } + ] + } + }, + { label => 'connection-client-devices-authorized', nlabel => 'system.connection.client.devices.authorized.count', set => { + key_values => [ { name => 'authorized_clients' } ], + output_template => 'client devices authorized connections: %d', + perfdatas => [ + { value => 'authorized_clients_absolute', template => '%d', min => 0 } + ] + } + }, + { label => 'connection-rogue-devices', nlabel => 'system.connection.rogue.devices.count', display_ok => 0, set => { + key_values => [ { name => 'rogues' } ], + output_template => 'rogue devices connections: %d', + perfdatas => [ + { value => 'rogues_absolute', template => '%d', min => 0 } + ] + } + } + ]; + + $self->{maps_counters}->{traffic} = [ + { label => 'traffic-in', nlabel => 'system.traffic.in.bitspersecond', set => { + key_values => [ { name => 'traffic_in', diff => 1 } ], + output_template => 'traffic in: %s%s/s', + per_second => 1, output_change_bytes => 2, + perfdatas => [ + { value => 'traffic_in_per_second', template => '%s', + min => 0, unit => 'b/s' } + ] + } + }, + { label => 'traffic-out', nlabel => 'system.traffic.out.bitspersecond', set => { + key_values => [ { name => 'traffic_out', diff => 1 } ], + output_template => 'traffic in: %s%s/s', + per_second => 1, output_change_bytes => 2, + perfdatas => [ + { value => 'traffic_out_per_second', template => '%s', + min => 0, unit => 'b/s' } + ] + } + } + ]; +} + +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 => { + 'unknown-status:s' => { name => 'unknown_status', default => '' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '' } + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->change_macros(macros => ['unknown_status', 'warning_status', 'critical_status']); +} + +my $map_system_status = { + 1 => 'master', 2 => 'standby', 3 => 'noredundancy' +}; +my $map_peer_connected_status = { + 1 => 'connected', 2 => 'disconnected' +}; + +my $mapping = { + system_status => { oid => '.1.3.6.1.4.1.25053.1.2.1.1.1.1.30', map => $map_system_status }, # ruckusZDSystemStatus + peer_connected_status => { oid => '.1.3.6.1.4.1.25053.1.2.1.1.1.1.31', map => $map_peer_connected_status }, # ruckusZDSystemPeerConnectedStatus + cpu_util => { oid => '.1.3.6.1.4.1.25053.1.2.1.1.1.5.58' }, # ruckusZDSystemCPUUtil + memory_used_prct => { oid => '.1.3.6.1.4.1.25053.1.2.1.1.1.5.59' }, # ruckusZDSystemMemoryUtil (%) + memory_size => { oid => '.1.3.6.1.4.1.25053.1.2.1.1.1.5.60' }, # ruckusZDSystemMemorySize (MB) + ap => { oid => '.1.3.6.1.4.1.25053.1.2.1.1.1.15.1' }, # ruckusZDSystemStatsNumAP + authorized_clients => { oid => '.1.3.6.1.4.1.25053.1.2.1.1.1.15.2' }, # ruckusZDSystemStatsNumSta + rogues => { oid => '.1.3.6.1.4.1.25053.1.2.1.1.1.15.3' }, # ruckusZDSystemStatsNumRogue + traffic_in => { oid => '.1.3.6.1.4.1.25053.1.2.1.1.1.15.6' }, # ruckusZDSystemStatsWLANTotalRxBytes + traffic_out => { oid => '.1.3.6.1.4.1.25053.1.2.1.1.1.15.9' } # ruckusZDSystemStatsWLANTotalTxBytes +}; + +sub manage_selection { + my ($self, %options) = @_; + + my $snmp_result = $options{snmp}->get_leef( + oids => [ map($_->{oid} . '.0', values(%$mapping)) ], + nothing_quit => 1 + ); + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => 0); + + my $memory_total = $result->{memory_size} * 1024 * 1024; + my $memory_used = $result->{memory_used_prct} * $memory_total / 100; + + $self->{system}->{global} = { + status => { + system_status => $result->{system_status}, + peer_connected_status => $result->{peer_connected_status} + }, + cpu => { cpu_util => $result->{cpu_util} }, + memory => { + used => $memory_used, + free => $memory_total - $memory_used, + prct_used => $result->{memory_used_prct}, + prct_free => 100 - $result->{memory_used_prct}, + total => $memory_total + }, + connection => { + ap => $result->{ap}, + authorized_clients => $result->{authorized_clients}, + rogues => $result->{rogues} + }, + traffic => { + traffic_in => $result->{traffic_in} * 8, + traffic_out => $result->{traffic_out} * 8 + } + }; + + $self->{cache_name} = 'ruckus_zd_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' . + (defined($self->{option_results}->{filter_counters_block}) ? md5_hex($self->{option_results}->{filter_counters_block}) : md5_hex('all')) . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); +} + +1; + +__END__ + +=head1 MODE + +Check system. + +=over 8 + +=item B<--unknown-status> + +Set unknown threshold for status (Default: ''). +Can used special variables like: %{system_status}, %{peer_connected_status} + +=item B<--warning-status> + +Set warning threshold for status (Default: ''). +Can used special variables like: %{system_status}, %{peer_connected_status} + +=item B<--critical-status> + +Set critical threshold for status. +Can used special variables like: %{system_status}, %{peer_connected_status} + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'memory-usage', 'usage-free', 'usage-prct', 'traffic-in', 'traffic-out', +'cpu-utilization', 'connection-accesspoints', 'connection-client-devices-authorized', +'connection-rogue-devices'. + +=back + +=cut diff --git a/network/ruckus/zonedirector/snmp/plugin.pm b/network/ruckus/zonedirector/snmp/plugin.pm new file mode 100644 index 000000000..fceea76f4 --- /dev/null +++ b/network/ruckus/zonedirector/snmp/plugin.pm @@ -0,0 +1,50 @@ +# +# Copyright 2020 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 network::ruckus::zonedirector::snmp::plugin; + +use strict; +use warnings; +use base qw(centreon::plugins::script_snmp); + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '0.5'; + %{$self->{modes}} = ( + 'access-points' => 'network::ruckus::zonedirector::snmp::mode::accesspoints', + 'list-access-points' => 'network::ruckus::zonedirector::snmp::mode::listaccesspoints', + 'system' => 'network::ruckus::zonedirector::snmp::mode::system' + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Ruckus ZoneDirector in SNMP. + +=cut From 7088971d51affdfcffaafac9cec35981ee5b31bb Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 4 May 2020 16:20:16 +0200 Subject: [PATCH 176/283] Fix #1979 --- centreon/common/radlan/mode/components/fan.pm | 74 --------- centreon/common/radlan/mode/components/psu.pm | 74 --------- centreon/common/radlan/mode/cpu.pm | 148 ------------------ .../common/radlan/snmp/mode/components/fan.pm | 111 +++++++++++++ .../common/radlan/snmp/mode/components/psu.pm | 140 +++++++++++++++++ .../radlan/snmp/mode/components/resources.pm | 53 +++++++ .../snmp/mode/components/temperature.pm | 124 +++++++++++++++ centreon/common/radlan/snmp/mode/cpu.pm | 120 ++++++++++++++ .../radlan/{ => snmp}/mode/environment.pm | 81 +++++++--- network/dell/xseries/snmp/plugin.pm | 52 ++++++ snmp_standard/mode/loadaverage.pm | 19 +-- 11 files changed, 668 insertions(+), 328 deletions(-) delete mode 100644 centreon/common/radlan/mode/components/fan.pm delete mode 100644 centreon/common/radlan/mode/components/psu.pm delete mode 100644 centreon/common/radlan/mode/cpu.pm create mode 100644 centreon/common/radlan/snmp/mode/components/fan.pm create mode 100644 centreon/common/radlan/snmp/mode/components/psu.pm create mode 100644 centreon/common/radlan/snmp/mode/components/resources.pm create mode 100644 centreon/common/radlan/snmp/mode/components/temperature.pm create mode 100644 centreon/common/radlan/snmp/mode/cpu.pm rename centreon/common/radlan/{ => snmp}/mode/environment.pm (53%) create mode 100644 network/dell/xseries/snmp/plugin.pm diff --git a/centreon/common/radlan/mode/components/fan.pm b/centreon/common/radlan/mode/components/fan.pm deleted file mode 100644 index 79f793da8..000000000 --- a/centreon/common/radlan/mode/components/fan.pm +++ /dev/null @@ -1,74 +0,0 @@ -# -# Copyright 2020 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 centreon::common::radlan::mode::components::fan; - -use strict; -use warnings; - -my %map_states = ( - 1 => 'normal', - 2 => 'warning', - 3 => 'critical', - 4 => 'shutdown', - 5 => 'notPresent', - 6 => 'notFunctioning', -); - -my $mapping = { - rlEnvMonFanStatusDescr => { oid => '.1.3.6.1.4.1.89.83.1.1.1.2' }, - rlEnvMonFanState => { oid => '.1.3.6.1.4.1.89.83.1.1.1.3', map => \%map_states }, -}; -my $oid_rlEnvMonFanStatusEntry = '.1.3.6.1.4.1.89.83.1.1.1'; - -sub load { - my ($self) = @_; - - push @{$self->{request}}, { oid => $oid_rlEnvMonFanStatusEntry }; -} - -sub check { - my ($self) = @_; - - $self->{output}->output_add(long_msg => 'checking fans'); - $self->{components}->{fan} = { name => 'fans', total => 0, skip => 0 }; - return if ($self->check_filter(section => 'fan')); - - foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_rlEnvMonFanStatusEntry}})) { - next if ($oid !~ /^$mapping->{rlEnvMonFanState}->{oid}\.(.*)$/); - my $instance = $1; - my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_rlEnvMonFanStatusEntry}, instance => $instance); - - next if ($self->check_filter(section => 'fan', instance => $instance, name => $result->{rlEnvMonFanStatusDescr})); - next if ($result->{rlEnvMonFanState} eq 'notPresent' && - $self->absent_problem(section => 'fan', instance => $instance, name => $result->{rlEnvMonFanStatusDescr})); - - $self->{components}->{fan}->{total}++; - $self->{output}->output_add(long_msg => sprintf("fan '%s' state is %s [instance: %s]", - $result->{rlEnvMonFanStatusDescr}, $result->{rlEnvMonFanState}, $instance)); - my $exit = $self->get_severity(section => 'fan', value => $result->{rlEnvMonFanState}); - if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Fan '%s' state is %s.", $result->{rlEnvMonFanStatusDescr}, $result->{rlEnvMonFanState})); - } - } -} - -1; diff --git a/centreon/common/radlan/mode/components/psu.pm b/centreon/common/radlan/mode/components/psu.pm deleted file mode 100644 index a87245b83..000000000 --- a/centreon/common/radlan/mode/components/psu.pm +++ /dev/null @@ -1,74 +0,0 @@ -# -# Copyright 2020 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 centreon::common::radlan::mode::components::psu; - -use strict; -use warnings; - -my %map_states = ( - 1 => 'normal', - 2 => 'warning', - 3 => 'critical', - 4 => 'shutdown', - 5 => 'notPresent', - 6 => 'notFunctioning', -); - -my $mapping = { - rlEnvMonSupplyStatusDescr => { oid => '.1.3.6.1.4.1.89.83.1.2.1' }, - rlEnvMonSupplyState => { oid => '.1.3.6.1.4.1.89.83.1.2.1.3', map => \%map_states }, -}; -my $oid_rlEnvMonSupplyStatusEntry = '.1.3.6.1.4.1.89.83.1.2.1.2'; - -sub load { - my ($self) = @_; - - push @{$self->{request}}, { oid => $oid_rlEnvMonSupplyStatusEntry }; -} - -sub check { - my ($self) = @_; - - $self->{output}->output_add(long_msg => 'checking power supplies'); - $self->{components}->{psu} = { name => 'psus', total => 0, skip => 0 }; - return if ($self->check_filter(section => 'psu')); - - foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_rlEnvMonSupplyStatusEntry}})) { - next if ($oid !~ /^$mapping->{rlEnvMonSupplyState}->{oid}\.(.*)$/); - my $instance = $1; - my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_rlEnvMonSupplyStatusEntry}, instance => $instance); - - next if ($self->check_filter(section => 'psu', instance => $instance, name => $result->{rlEnvMonSupplyStatusDescr})); - next if ($result->{rlEnvMonSupplyState} eq 'notPresent' && - $self->absent_problem(section => 'psu', instance => $instance, name => $result->{rlEnvMonSupplyStatusDescr})); - - $self->{components}->{psu}->{total}++; - $self->{output}->output_add(long_msg => sprintf("power supply '%s' state is %s [instance: %s]", - $result->{rlEnvMonSupplyStatusDescr}, $result->{rlEnvMonSupplyState}, $instance)); - my $exit = $self->get_severity(section => 'psu', value => $result->{rlEnvMonSupplyState}); - if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Power supply '%s' state is %s.", $result->{rlEnvMonSupplyStatusDescr}, $result->{rlEnvMonSupplyState})); - } - } -} - -1; diff --git a/centreon/common/radlan/mode/cpu.pm b/centreon/common/radlan/mode/cpu.pm deleted file mode 100644 index 31ce8840c..000000000 --- a/centreon/common/radlan/mode/cpu.pm +++ /dev/null @@ -1,148 +0,0 @@ -# -# Copyright 2020 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 centreon::common::radlan::mode::cpu; - -use base qw(centreon::plugins::mode); - -use strict; -use warnings; - -sub new { - my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); - bless $self, $class; - - $options{options}->add_options(arguments => - { - "warning:s" => { name => 'warning', default => '' }, - "critical:s" => { name => 'critical', default => '' }, - }); - - return $self; -} - -sub check_options { - my ($self, %options) = @_; - $self->SUPER::init(%options); - - ($self->{warn1s}, $self->{warn1m}, $self->{warn5m}) = split /,/, $self->{option_results}->{warning}; - ($self->{crit1s}, $self->{crit1m}, $self->{crit5m}) = split /,/, $self->{option_results}->{critical}; - - if (($self->{perfdata}->threshold_validate(label => 'warn1s', value => $self->{warn1s})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning (1sec) threshold '" . $self->{warn1s} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'warn1m', value => $self->{warn1m})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning (1min) threshold '" . $self->{warn1m} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'warn5m', value => $self->{warn5m})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning (5min) threshold '" . $self->{warn5m} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'crit1s', value => $self->{crit1s})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical (1sec) threshold '" . $self->{crit1s} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'crit1m', value => $self->{crit1m})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical (1min) threshold '" . $self->{crit1m} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'crit5m', value => $self->{crit5})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical (5min) threshold '" . $self->{crit5m} . "'."); - $self->{output}->option_exit(); - } -} - -sub run { - my ($self, %options) = @_; - $self->{snmp} = $options{snmp}; - - my $oid_rlCpuUtilEnable = '.1.3.6.1.4.1.89.1.6.0'; - my $oid_rlCpuUtilDuringLastSecond = '.1.3.6.1.4.1.89.1.7.0'; - my $oid_rlCpuUtilDuringLastMinute = '.1.3.6.1.4.1.89.1.8.0'; - my $oid_rlCpuUtilDuringLast5Minutes = '.1.3.6.1.4.1.89.1.9.0'; - - $self->{result} = $self->{snmp}->get_leef(oids => [ $oid_rlCpuUtilEnable, $oid_rlCpuUtilDuringLastSecond, $oid_rlCpuUtilDuringLastMinute, $oid_rlCpuUtilDuringLast5Minutes ], - nothing_quit => 1); - - if (defined($self->{result}->{$oid_rlCpuUtilEnable}) && $self->{result}->{$oid_rlCpuUtilEnable} == 1) { - my $cpu1sec = $self->{result}->{$oid_rlCpuUtilDuringLastSecond}; - my $cpu1min = $self->{result}->{$oid_rlCpuUtilDuringLastMinute}; - my $cpu5min = $self->{result}->{$oid_rlCpuUtilDuringLast5Minutes}; - - my $exit1 = $self->{perfdata}->threshold_check(value => $cpu1sec, - threshold => [ { label => 'crit1s', exit_litteral => 'critical' }, { label => 'warn1s', exit_litteral => 'warning' } ]); - my $exit2 = $self->{perfdata}->threshold_check(value => $cpu1min, - threshold => [ { label => 'crit1m', exit_litteral => 'critical' }, { label => 'warn1m', exit_litteral => 'warning' } ]); - my $exit3 = $self->{perfdata}->threshold_check(value => $cpu5min, - threshold => [ { label => 'crit5m', exit_litteral => 'critical' }, { label => 'warn5m', exit_litteral => 'warning' } ]); - my $exit = $self->{output}->get_most_critical(status => [ $exit1, $exit2, $exit3 ]); - - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("CPU Usage: %.2f%% (1sec), %.2f%% (1min), %.2f%% (5min)", - $cpu1sec, $cpu1min, $cpu5min)); - - $self->{output}->perfdata_add(label => "cpu_1s", unit => '%', - value => $cpu1sec, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn1s'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit1s'), - min => 0, max => 100); - $self->{output}->perfdata_add(label => "cpu_1m", unit => '%', - value => $cpu1min, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn1m'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit1m'), - min => 0, max => 100); - $self->{output}->perfdata_add(label => "cpu_5m", unit => '%', - value => $cpu5min, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn5m'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit5m'), - min => 0, max => 100); - } else { - $self->{output}->output_add(severity => 'UNKNOWN', - short_msg => sprintf("CPU measurement is not enabled.")); - } - - $self->{output}->display(); - $self->{output}->exit(); -} - -1; - -__END__ - -=head1 MODE - -Check cpu usage (RADLAN-rndMng). - -=over 8 - -=item B<--warning> - -Threshold warning in percent (1s,1min,5min). - -=item B<--critical> - -Threshold critical in percent (1s,1min,5min). - -=back - -=cut \ No newline at end of file diff --git a/centreon/common/radlan/snmp/mode/components/fan.pm b/centreon/common/radlan/snmp/mode/components/fan.pm new file mode 100644 index 000000000..153ae2448 --- /dev/null +++ b/centreon/common/radlan/snmp/mode/components/fan.pm @@ -0,0 +1,111 @@ +# +# Copyright 2020 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 centreon::common::radlan::snmp::mode::components::fan; + +use strict; +use warnings; +use centreon::common::cisco::smallbusiness::snmp::mode::components::resources qw( + $rl_envmon_state + $oid_rlPhdUnitEnvParamMonitorAutoRecoveryEnable + $oid_rlPhdUnitEnvParamEntry +); + +my $mapping_stack = { + new => { + rlPhdUnitEnvParamFan1Status => { oid => '.1.3.6.1.4.1.89.53.15.1.4', map => $rl_envmon_state }, + rlPhdUnitEnvParamFan2Status => { oid => '.1.3.6.1.4.1.89.53.15.1.5', map => $rl_envmon_state }, + rlPhdUnitEnvParamFan3Status => { oid => '.1.3.6.1.4.1.89.53.15.1.6', map => $rl_envmon_state }, + rlPhdUnitEnvParamFan4Status => { oid => '.1.3.6.1.4.1.89.53.15.1.7', map => $rl_envmon_state }, + rlPhdUnitEnvParamFan5Status => { oid => '.1.3.6.1.4.1.89.53.15.1.8', map => $rl_envmon_state }, + rlPhdUnitEnvParamFan6Status => { oid => '.1.3.6.1.4.1.89.53.15.1.9', map => $rl_envmon_state } + }, + old => { + rlPhdUnitEnvParamFan1Status => { oid => '.1.3.6.1.4.1.89.53.15.1.4', map => $rl_envmon_state }, + rlPhdUnitEnvParamFan2Status => { oid => '.1.3.6.1.4.1.89.53.15.1.5', map => $rl_envmon_state }, + rlPhdUnitEnvParamFan3Status => { oid => '.1.3.6.1.4.1.89.53.15.1.6', map => $rl_envmon_state }, + rlPhdUnitEnvParamFan4Status => { oid => '.1.3.6.1.4.1.89.53.15.1.7', map => $rl_envmon_state }, + rlPhdUnitEnvParamFan5Status => { oid => '.1.3.6.1.4.1.89.53.15.1.8', map => $rl_envmon_state } + } +}; + +sub load { + my ($self) = @_; +} + +sub check_fan_stack { + my ($self) = @_; + + my $num_fans = 5; + $num_fans = 6 if ($self->{radlan_new} == 1); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_rlPhdUnitEnvParamEntry}})) { + next if ($oid !~ /^$mapping_stack->{new}->{rlPhdUnitEnvParamFan1Status}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance( + mapping => $self->{radlan_new} == 1 ? $mapping_stack->{new} : $mapping_stack->{old}, + results => $self->{results}->{$oid_rlPhdUnitEnvParamEntry}, + instance => $instance + ); + + for (my $i = 1; $i <= $num_fans; $i++) { + my $instance2 = 'stack.' . $instance . '.fan.' . $i; + my $name = 'rlPhdUnitEnvParamFan' . $i . 'Status'; + + next if ($self->check_filter(section => 'fan', instance => $instance2)); + next if ($result->{$name} =~ /notPresent/i && + $self->absent_problem(section => 'fan', instance => $instance2)); + + $self->{components}->{fan}->{total}++; + $self->{output}->output_add( + long_msg => sprintf( + "fan '%s' status is '%s' [instance: %s]", + $instance2, + $result->{$name}, + $instance2 + ) + ); + + my $exit = $self->get_severity(label => 'default', section => 'fan', value => $result->{$name}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "Fan '%s' status is '%s'", + $instance2, + $result->{$name} + ) + ); + } + } + } +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking fans"); + $self->{components}->{fan} = { name => 'fan', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'fan')); + + check_fan_stack($self); +} + +1; diff --git a/centreon/common/radlan/snmp/mode/components/psu.pm b/centreon/common/radlan/snmp/mode/components/psu.pm new file mode 100644 index 000000000..343bc1d8f --- /dev/null +++ b/centreon/common/radlan/snmp/mode/components/psu.pm @@ -0,0 +1,140 @@ +# +# Copyright 2020 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 centreon::common::radlan::snmp::mode::components::psu; + +use strict; +use warnings; +use centreon::common::radlan::snmp::mode::components::resources qw( + $rl_envmon_state + $oid_rlPhdUnitEnvParamEntry +); + +my $mapping_stack = { + rlPhdUnitEnvParamMainPSStatus => { oid => '.1.3.6.1.4.1.89.53.15.1.2', map => $rl_envmon_state }, + rlPhdUnitEnvParamRedundantPSStatus => { oid => '.1.3.6.1.4.1.89.53.15.1.3', map => $rl_envmon_state } +}; + +my $mapping = { + rlEnvMonSupplyStatusDescr => { oid => '.1.3.6.1.4.1.89.83.1.2.1.2' }, + rlEnvMonSupplyState => { oid => '.1.3.6.1.4.1.89.83.1.2.1.3', map => $rl_envmon_state } +}; +my $oid_rlEnvMonSupplyStatusEntry = '.1.3.6.1.4.1.89.83.1.2.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { + oid => $oid_rlEnvMonSupplyStatusEntry, + $mapping->{rlEnvMonSupplyStatusDescr}->{oid}, + $mapping->{rlEnvMonSupplyState}->{oid} + }; +} + +sub check_psu_stack { + my ($self) = @_; + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_rlPhdUnitEnvParamEntry}})) { + next if ($oid !~ /^$mapping_stack->{rlPhdUnitEnvParamMainPSStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping_stack, results => $self->{results}->{$oid_rlPhdUnitEnvParamEntry}, instance => $instance); + + foreach (['rlPhdUnitEnvParamMainPSStatus', 'main.psu'], ['rlPhdUnitEnvParamRedundantPSStatus', 'redundant.psu']) { + my $instance2 = 'stack.' . $instance . '.' . $_->[1]; + + next if ($self->check_filter(section => 'psu', instance => $instance2)); + next if ($result->{$_->[0]} =~ /notPresent/i && + $self->absent_problem(section => 'psu', instance => $instance2)); + + $self->{components}->{psu}->{total}++; + $self->{output}->output_add( + long_msg => sprintf( + "power supply '%s' status is '%s' [instance: %s]", + $instance2, + $result->{$_->[0]}, + $instance2 + ) + ); + + my $exit = $self->get_severity(label => 'default', section => 'psu', value => $result->{$_->[0]}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "Power supply '%s' status is '%s'", + $instance2, + $result->{$_->[0]} + ) + ); + } + } + } +} + +sub check_psu { + my ($self) = @_; + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_rlEnvMonSupplyStatusEntry}})) { + next if ($oid !~ /^$mapping->{rlEnvMonSupplyState}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_rlEnvMonSupplyStatusEntry}, instance => $instance); + + next if ($self->check_filter(section => 'psu', instance => $instance)); + if ($result->{rlEnvMonSupplyState} =~ /notPresent/i) { + $self->absent_problem(section => 'psu', instance => $instance); + next; + } + + $self->{components}->{psu}->{total}++; + $self->{output}->output_add( + long_msg => sprintf( + "power supply '%s' status is '%s' [instance: %s]", + $result->{rlEnvMonSupplyStatusDescr}, + $result->{rlEnvMonSupplyState}, + $instance + ) + ); + + my $exit = $self->get_severity(label => 'default', section => 'psu', value => $result->{rlEnvMonSupplyState}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "Power supply '%s' status is '%s'", + $result->{rlEnvMonSupplyStatusDescr}, + $result->{rlEnvMonSupplyState} + ) + ); + } + } +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking power supplies"); + $self->{components}->{psu} = { name => 'psu', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'psu')); + + check_psu($self); + check_psu_stack($self); +} + +1; diff --git a/centreon/common/radlan/snmp/mode/components/resources.pm b/centreon/common/radlan/snmp/mode/components/resources.pm new file mode 100644 index 000000000..f06752667 --- /dev/null +++ b/centreon/common/radlan/snmp/mode/components/resources.pm @@ -0,0 +1,53 @@ +# +# Copyright 2020 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 centreon::common::radlan::snmp::mode::components::resources; + +use strict; +use warnings; +use Exporter; + +our $rl_envmon_state; +our $oid_rlPhdUnitEnvParamMonitorAutoRecoveryEnable; +our $oid_rlPhdUnitEnvParamEntry; + +our @ISA = qw(Exporter); +our @EXPORT_OK = qw( + $rl_envmon_state + $oid_rlPhdUnitEnvParamMonitorAutoRecoveryEnable + $oid_rlPhdUnitEnvParamEntry +); + +$rl_envmon_state = { + 1 => 'normal', + 2 => 'warning', + 3 => 'critical', + 4 => 'shutdown', + 5 => 'notPresent', + 6 => 'notFunctioning', + 7 => 'notAvailable', + 8 => 'backingUp', + 9 => 'readingFailed' +}; + +$oid_rlPhdUnitEnvParamMonitorAutoRecoveryEnable = '.1.3.6.1.4.1.89.53.15.1.15'; +$oid_rlPhdUnitEnvParamEntry = '.1.3.6.1.4.1.89.53.15.1'; + +1; diff --git a/centreon/common/radlan/snmp/mode/components/temperature.pm b/centreon/common/radlan/snmp/mode/components/temperature.pm new file mode 100644 index 000000000..fcc6bfa2f --- /dev/null +++ b/centreon/common/radlan/snmp/mode/components/temperature.pm @@ -0,0 +1,124 @@ +# +# Copyright 2020 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 centreon::common::radlan::snmp::mode::components::temperature; + +use strict; +use warnings; +use centreon::common::radlan::snmp::mode::components::resources qw($oid_rlPhdUnitEnvParamEntry); + +my $map_entity_sensor = { 1 => 'ok', 2 => 'unavailable', 3 => 'nonoperational' }; + +my $mapping = { + new => { + rlPhdUnitEnvParamTempSensorValue => { oid => '.1.3.6.1.4.1.89.53.15.1.10' }, + rlPhdUnitEnvParamTempSensorStatus => { oid => '.1.3.6.1.4.1.89.53.15.1.11', map => $map_entity_sensor }, + rlPhdUnitEnvParamTempSensorWarningThresholdValue => { oid => '.1.3.6.1.4.1.89.53.15.1.12' }, + rlPhdUnitEnvParamTempSensorCriticalThresholdValue => { oid => '.1.3.6.1.4.1.89.53.15.1.13' } + }, + old => { + rlPhdUnitEnvParamTempSensorValue => { oid => '.1.3.6.1.4.1.89.53.15.1.9' }, + rlPhdUnitEnvParamTempSensorStatus => { oid => '.1.3.6.1.4.1.89.53.15.1.10', map => $map_entity_sensor }, + } +}; + +sub load {} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking temperatures"); + $self->{components}->{temperature} = { name => 'temperatures', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'temperature')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_rlPhdUnitEnvParamEntry}})) { + next if ($oid !~ /^$mapping->{new}->{rlPhdUnitEnvParamTempSensorValue}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance( + mapping => $self->{radlan_new} == 1 ? $mapping->{new} : $mapping->{old}, + results => $self->{results}->{$oid_rlPhdUnitEnvParamEntry}, + instance => $instance + ); + + next if ($self->check_filter(section => 'temperature', instance => $instance)); + $self->{components}->{temperature}->{total}++; + + $self->{output}->output_add( + long_msg => sprintf( + "temperature '%s' status is '%s' [instance = %s, value: %s degree centigrade]", + $instance, + $result->{rlPhdUnitEnvParamTempSensorStatus}, + $instance, + $result->{rlPhdUnitEnvParamTempSensorValue} + ) + ); + + my $exit = $self->get_severity(section => 'temperature', value => $result->{rlPhdUnitEnvParamTempSensorStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "Temperature '%s' status is '%s'", + $instance, + $result->{rlPhdUnitEnvParamTempSensorStatus} + ) + ); + } + + my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{rlPhdUnitEnvParamTempSensorValue}); + if ($checked == 0 && defined($result->{rlPhdUnitEnvParamTempSensorWarningThresholdValue})) { + my $warn_th = ':' . $result->{rlPhdUnitEnvParamTempSensorWarningThresholdValue}; + my $crit_th = ':' . $result->{rlPhdUnitEnvParamTempSensorCriticalThresholdValue}; + $self->{perfdata}->threshold_validate(label => 'warning-temperature-instance-' . $instance, value => $warn_th); + $self->{perfdata}->threshold_validate(label => 'critical-temperature-instance-' . $instance, value => $crit_th); + + $exit2 = $self->{perfdata}->threshold_check( + value => $result->{rlPhdUnitEnvParamTempSensorValue}, + threshold => [ + { label => 'critical-temperature-instance-' . $instance, exit_litteral => 'critical' }, + { label => 'warning-temperature-instance-' . $instance, exit_litteral => 'warning' } + ] + ); + $warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-temperature-instance-' . $instance); + $crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-temperature-instance-' . $instance); + } + + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit2, + short_msg => sprintf( + "Temperature '%s' is %s degree centigrade", + $instance, + $result->{rlPhdUnitEnvParamTempSensorValue} + ) + ); + } + $self->{output}->perfdata_add( + label => 'temp', unit => 'C', + nlabel => 'hardware.temperature.celsius', + instances => $instance, + value => $result->{rlPhdUnitEnvParamTempSensorValue}, + warning => $warn, + critical => $crit + ); + } +} + +1; diff --git a/centreon/common/radlan/snmp/mode/cpu.pm b/centreon/common/radlan/snmp/mode/cpu.pm new file mode 100644 index 000000000..b30a23b0f --- /dev/null +++ b/centreon/common/radlan/snmp/mode/cpu.pm @@ -0,0 +1,120 @@ +# +# Copyright 2020 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 centreon::common::radlan::snmp::mode::cpu; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'cpu', type => 0, cb_prefix_output => 'prefix_message_output', skipped_code => { -10 => 1 } } + ]; + + $self->{maps_counters}->{cpu} = [ + { label => 'average-1s', nlabel => 'cpu.utilization.1s.percentage', set => { + key_values => [ { name => 'average_1s' } ], + output_template => '%.2f %% (1s)', + perfdatas => [ + { value => 'average_1s_absolute', template => '%.2f', + min => 0, max => 100, unit => '%' } + ] + } + }, + { label => 'average-1m', nlabel => 'cpu.utilization.1m.percentage', set => { + key_values => [ { name => 'average_1m' } ], + output_template => '%.2f %% (1m)', + perfdatas => [ + { value => 'average_1m_absolute', template => '%.2f', + min => 0, max => 100, unit => '%' } + ] + } + }, + { label => 'average-5m', nlabel => 'cpu.utilization.5m.percentage', set => { + key_values => [ { name => 'average_5m' } ], + output_template => '%.2f %% (5m)', + perfdatas => [ + { value => 'average_5m_absolute', template => '%.2f', + min => 0, max => 100, unit => '%' } + ] + } + } + ]; +} + +sub prefix_message_output { + my ($self, %options) = @_; + + return "CPU average usage: "; +} + +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 => { + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + my $oid_rlCpuUtilDuringLastSecond = '.1.3.6.1.4.1.89.1.7.0'; + my $oid_rlCpuUtilDuringLastMinute = '.1.3.6.1.4.1.89.1.8.0'; + my $oid_rlCpuUtilDuringLast5Minutes = '.1.3.6.1.4.1.89.1.9.0'; + my $result = $options{snmp}->get_leef( + oids => [$oid_rlCpuUtilDuringLastSecond, $oid_rlCpuUtilDuringLastMinute, $oid_rlCpuUtilDuringLast5Minutes], + nothing_quit => 1 + ); + + $self->{cpu} = { + average_1s => $result->{$oid_rlCpuUtilDuringLastSecond}, + average_1m => $result->{$oid_rlCpuUtilDuringLastMinute}, + average_5m => $result->{$oid_rlCpuUtilDuringLast5Minutes} + } +} + + + +1; + +__END__ + +=head1 MODE + +Check cpu usage. + +=over 8 + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'average-1s' (%), 'average-1m' (%), 'average-5m' (%). + +=back + +=cut diff --git a/centreon/common/radlan/mode/environment.pm b/centreon/common/radlan/snmp/mode/environment.pm similarity index 53% rename from centreon/common/radlan/mode/environment.pm rename to centreon/common/radlan/snmp/mode/environment.pm index 943b9c332..7e518b74d 100644 --- a/centreon/common/radlan/mode/environment.pm +++ b/centreon/common/radlan/snmp/mode/environment.pm @@ -18,49 +18,73 @@ # limitations under the License. # -package centreon::common::radlan::mode::environment; +package centreon::common::radlan::snmp::mode::environment; use base qw(centreon::plugins::templates::hardware); use strict; use warnings; +use centreon::common::radlan::snmp::mode::components::resources qw( + $oid_rlPhdUnitEnvParamEntry + $oid_rlPhdUnitEnvParamMonitorAutoRecoveryEnable +); sub set_system { my ($self, %options) = @_; - - $self->{regexp_threshold_overload_check_section_option} = '^fan|psu$'; - + + $self->{regexp_threshold_overload_check_section_option} = '^(?:fan|psu|temperature)$'; + $self->{regexp_threshold_numeric_check_section_option} = '^temperature$'; + $self->{cb_hook2} = 'snmp_execute'; - - $self->{thresholds} = { + + $self->{thresholds} = { default => [ - ['shutdown', 'WARNING'], + ['normal', 'OK'], + ['notPresent', 'OK'], ['warning', 'WARNING'], ['critical', 'CRITICAL'], + ['shutdown', 'CRITICAL'], ['notFunctioning', 'CRITICAL'], - ['notPresent', 'OK'], - ['normal', 'OK'], ], + temperature => [ + ['ok', 'OK'], + ['unavailable', 'OK'], + ['nonoperational', 'CRITICAL'], + ] }; - - $self->{components_path} = 'centreon::common::radlan::mode::components'; - $self->{components_module} = ['fan', 'psu']; + + $self->{components_path} = 'centreon::common::radlan::snmp::mode::components'; + $self->{components_module} = ['psu', 'fan', 'temperature']; } sub snmp_execute { my ($self, %options) = @_; $self->{snmp} = $options{snmp}; + push @{$self->{request}}, { + oid => $oid_rlPhdUnitEnvParamEntry, + start => '.1.3.6.1.4.1.89.53.15.1.2', # rlPhdUnitEnvParamMainPSStatus + end => $oid_rlPhdUnitEnvParamMonitorAutoRecoveryEnable + }; $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); + + $self->{radlan_new} = 0; + foreach (keys %{$self->{results}->{$oid_rlPhdUnitEnvParamEntry}}) { + if (/^$oid_rlPhdUnitEnvParamMonitorAutoRecoveryEnable\./) { + $self->{radlan_new} = 1; + last; + } + } } sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_performance => 1); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); bless $self, $class; - - $options{options}->add_options(arguments => {}); - + + $options{options}->add_options(arguments => { + }); + return $self; } @@ -70,24 +94,24 @@ __END__ =head1 MODE -Check environment (RADLAN-HWENVIROMENT). +Check environment. =over 8 =item B<--component> -Which component to check (Default: 'all'). -Can be: 'psu', 'fan'. +Which component to check (Default: '.*'). +Can be: 'fan', 'psu', 'temperature'. =item B<--filter> Exclude some parts (comma seperated list) (Example: --filter=psu) -Can also exclude specific instance: --filter=fan,1 +Can also exclude specific instance: --filter=psu,0 =item B<--absent-problem> Return an error if an entity is not 'present' (default is skipping) (comma seperated list) -Can be specific or global: --absent-problem=psu +Can be specific or global: --absent-problem=fan#2# =item B<--no-component> @@ -96,10 +120,21 @@ If total (with skipped) is 0. (Default: 'critical' returns). =item B<--threshold-overload> -Set to overload default threshold values (syntax: section,status,regexp) +Set to overload default threshold values (syntax: section,[instance,]status,regexp) It used before default thresholds (order stays). -Example: --threshold-overload='psu,CRITICAL,^(?!(normal)$)' +Example: --threshold-overload='fan,CRITICAL,^(?!(normal)$)' + +=item B<--warning> + +Set warning threshold (syntax: type,regexp,threshold) +Example: --warning='temperature,.*,30' + +=item B<--critical> + +Set critical threshold (syntax: type,regexp,threshold) +Example: --critical='temperature,.*,40' =back =cut + diff --git a/network/dell/xseries/snmp/plugin.pm b/network/dell/xseries/snmp/plugin.pm new file mode 100644 index 000000000..2a329586f --- /dev/null +++ b/network/dell/xseries/snmp/plugin.pm @@ -0,0 +1,52 @@ +# +# Copyright 2020 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 network::dell::xseries::snmp::plugin; + +use strict; +use warnings; +use base qw(centreon::plugins::script_snmp); + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.0'; + %{$self->{modes}} = ( + 'cpu' => 'centreon::common::radlan::snmp::mode::cpu', + 'hardware' => 'centreon::common::radlan::snmp::mode::environment', + 'interfaces' => 'snmp_standard::mode::interfaces', + 'list-interfaces' => 'snmp_standard::mode::listinterfaces', + 'uptime' => 'snmp_standard::mode::uptime' + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Dell X-Series in SNMP. + +=cut diff --git a/snmp_standard/mode/loadaverage.pm b/snmp_standard/mode/loadaverage.pm index 6104bf28a..4d5fbb3b2 100644 --- a/snmp_standard/mode/loadaverage.pm +++ b/snmp_standard/mode/loadaverage.pm @@ -30,12 +30,11 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - "warning:s" => { name => 'warning', default => '' }, - "critical:s" => { name => 'critical', default => '' }, - "average" => { name => 'average' }, - }); + $options{options}->add_options(arguments => { + 'warning:s' => { name => 'warning', default => '' }, + 'critical:s' => { name => 'critical', default => '' }, + 'average' => { name => 'average' }, + }); return $self; } @@ -83,7 +82,7 @@ sub run { my $oid_CpuLoad15m = '.1.3.6.1.4.1.2021.10.1.3.3'; my $result = $self->{snmp}->get_leef(oids => [$oid_CpuLoad1m, $oid_CpuLoad5m, $oid_CpuLoad15m], nothing_quit => 1); - + my ($msg, $cpu_load1, $cpu_load5, $cpu_load15); $result->{$oid_CpuLoad1m} =~ s/,/\./g; $result->{$oid_CpuLoad5m} =~ s/,/\./g; @@ -92,8 +91,10 @@ sub run { if (defined($self->{option_results}->{average})) { my $result2 = $self->{snmp}->get_table(oid => $oid_CountCpu); if (scalar(keys %$result2) <= 0){ - $self->{output}->output_add(severity => 'unknown', - short_msg => 'Unable to get number of CPUs'); + $self->{output}->output_add( + severity => 'unknown', + short_msg => 'Unable to get number of CPUs' + ); $self->{output}->display(); $self->{output}->exit(); } From 4bd2db856ad54629e8b69ad903817361e9ea8f1e Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 4 May 2020 16:21:23 +0200 Subject: [PATCH 177/283] Fix #1979 --- centreon/common/radlan/snmp/mode/components/fan.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/centreon/common/radlan/snmp/mode/components/fan.pm b/centreon/common/radlan/snmp/mode/components/fan.pm index 153ae2448..4685fe9ae 100644 --- a/centreon/common/radlan/snmp/mode/components/fan.pm +++ b/centreon/common/radlan/snmp/mode/components/fan.pm @@ -22,7 +22,7 @@ package centreon::common::radlan::snmp::mode::components::fan; use strict; use warnings; -use centreon::common::cisco::smallbusiness::snmp::mode::components::resources qw( +use centreon::common::radlan::snmp::mode::components::resources qw( $rl_envmon_state $oid_rlPhdUnitEnvParamMonitorAutoRecoveryEnable $oid_rlPhdUnitEnvParamEntry From ae345a29c5308218c50c49a88fa4a2c736b60283 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 5 May 2020 09:01:26 +0200 Subject: [PATCH 178/283] Fix #1984 --- apps/antivirus/kaspersky/snmp/mode/updates.pm | 75 +++++++++++-------- 1 file changed, 42 insertions(+), 33 deletions(-) diff --git a/apps/antivirus/kaspersky/snmp/mode/updates.pm b/apps/antivirus/kaspersky/snmp/mode/updates.pm index 684c21cc0..a05aa5a1e 100644 --- a/apps/antivirus/kaspersky/snmp/mode/updates.pm +++ b/apps/antivirus/kaspersky/snmp/mode/updates.pm @@ -31,8 +31,7 @@ use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold) sub custom_status_output { my ($self, %options) = @_; - my $msg = sprintf("Updates status is '%s'", $self->{result_values}->{status}); - return $msg; + return sprintf("Updates status is '%s'", $self->{result_values}->{status}); } sub custom_status_calc { @@ -45,26 +44,34 @@ sub custom_status_calc { sub custom_last_perfdata { my ($self, %options) = @_; - $self->{output}->perfdata_add(label => 'last_server_update', - value => $self->{result_values}->{diff}, - unit => 's', - min => 0); + $self->{output}->perfdata_add( + label => 'last_server_update', + value => $self->{result_values}->{diff}, + unit => 's', + min => 0 + ); } sub custom_last_threshold { my ($self, %options) = @_; - my $exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{diff}, - threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, - { label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]); + my $exit = $self->{perfdata}->threshold_check( + value => $self->{result_values}->{diff}, + threshold => [ + { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, + { label => 'warning-' . $self->{label}, exit_litteral => 'warning' } + ] + ); return $exit; } sub custom_last_output { my ($self, %options) = @_; - my $msg = sprintf("Last server update: %s [%s]", centreon::plugins::misc::change_seconds(value => $self->{result_values}->{diff}), $self->{result_values}->{date_time}); - return $msg; + return sprintf( + 'Last server update: %s [%s]', + centreon::plugins::misc::change_seconds(value => $self->{result_values}->{diff}), $self->{result_values}->{date_time} + ); } sub custom_last_calc { @@ -80,7 +87,7 @@ sub custom_last_calc { hour => $4, minute => $5, second => $6, - %{$self->{tz}} + %{$self->{instance_mode}->{tz}} ); $self->{result_values}->{diff} = time() - $dt->epoch; $self->{result_values}->{date_time} = $dt->datetime(); @@ -93,7 +100,7 @@ sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ - { name => 'global', type => 0, message_separator => ' - ' }, + { name => 'global', type => 0, message_separator => ' - ' } ]; $self->{maps_counters}->{global} = [ @@ -102,7 +109,7 @@ sub set_counters { closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => \&catalog_status_threshold, + closure_custom_threshold_check => \&catalog_status_threshold } }, { label => 'last-server-update', set => { @@ -110,17 +117,17 @@ sub set_counters { closure_custom_calc => $self->can('custom_last_calc'), closure_custom_output => $self->can('custom_last_output'), closure_custom_threshold_check => $self->can('custom_last_threshold'), - closure_custom_perfdata => $self->can('custom_last_perfdata'), + closure_custom_perfdata => $self->can('custom_last_perfdata') } }, { label => 'not-updated', set => { key_values => [ { name => 'hostsNotUpdated' } ], output_template => '%d host(s) not up to date', perfdatas => [ - { label => 'not_updated', value => 'hostsNotUpdated_absolute', template => '%d', min => 0 }, - ], + { label => 'not_updated', value => 'hostsNotUpdated_absolute', template => '%d', min => 0 } + ] } - }, + } ]; } @@ -129,12 +136,12 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - "warning-status:s" => { name => 'warning_status', default => '%{status} =~ /Warning/i' }, - "critical-status:s" => { name => 'critical_status', default => '%{status} =~ /Critical/i' }, - "timezone:s" => { name => 'timezone', default => 'GMT' }, - }); + $options{options}->add_options(arguments => { + 'warning-status:s' => { name => 'warning_status', default => '%{status} =~ /Warning/i' }, + 'critical-status:s' => { name => 'critical_status', default => '%{status} =~ /Critical/i' }, + 'timezone:s' => { name => 'timezone', default => 'GMT' } + }); + return $self; } @@ -146,12 +153,12 @@ sub check_options { $self->change_macros(macros => ['warning_status', 'critical_status']); } -my %map_status = ( +my $map_status = { 0 => 'OK', 1 => 'Info', 2 => 'Warning', - 3 => 'Critical', -); + 3 => 'Critical' +}; my $oid_updatesStatus = '.1.3.6.1.4.1.23668.1093.1.2.1'; my $oid_lastServerUpdateTime = '.1.3.6.1.4.1.23668.1093.1.2.3'; @@ -160,14 +167,16 @@ my $oid_hostsNotUpdated = '.1.3.6.1.4.1.23668.1093.1.2.4'; sub manage_selection { my ($self, %options) = @_; - my $snmp_result = $options{snmp}->get_leef(oids => [ $oid_updatesStatus, $oid_lastServerUpdateTime, - $oid_hostsNotUpdated ], - nothing_quit => 1); - - $self->{global} = {}; + my $snmp_result = $options{snmp}->get_leef( + oids => [ + $oid_updatesStatus, $oid_lastServerUpdateTime, + $oid_hostsNotUpdated + ], + nothing_quit => 1 + ); $self->{global} = { - updatesStatus => $map_status{$snmp_result->{$oid_updatesStatus}}, + updatesStatus => $map_status->{$snmp_result->{$oid_updatesStatus}}, lastServerUpdateTime => $snmp_result->{$oid_lastServerUpdateTime}, hostsNotUpdated => $snmp_result->{$oid_hostsNotUpdated}, }; From 02ac8d55872cafffa3eee290c9a448c8bbdfb3be Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 5 May 2020 09:33:43 +0200 Subject: [PATCH 179/283] Fix #1879 --- network/paloalto/ssh/custom/cli.pm | 2 +- network/paloalto/ssh/mode/licenses.pm | 159 ++++++++++++++++++++++++++ network/paloalto/ssh/plugin.pm | 1 + 3 files changed, 161 insertions(+), 1 deletion(-) create mode 100644 network/paloalto/ssh/mode/licenses.pm diff --git a/network/paloalto/ssh/custom/cli.pm b/network/paloalto/ssh/custom/cli.pm index d3f6d83d5..9871ffbb3 100644 --- a/network/paloalto/ssh/custom/cli.pm +++ b/network/paloalto/ssh/custom/cli.pm @@ -138,7 +138,7 @@ sub execute_command { return $stdout; } - if ($stdout !~ /(.*<\/response>)/ms) { + if ($stdout !~ /(.*<\/response>)/ms) { $self->{output}->add_option_msg(short_msg => "Cannot find xml response"); $self->{output}->option_exit(); } diff --git a/network/paloalto/ssh/mode/licenses.pm b/network/paloalto/ssh/mode/licenses.pm new file mode 100644 index 000000000..e4a2837e6 --- /dev/null +++ b/network/paloalto/ssh/mode/licenses.pm @@ -0,0 +1,159 @@ +# +# Copyright 2020 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 network::paloalto::ssh::mode::licenses; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use DateTime; +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold); + +sub custom_status_output { + my ($self, %options) = @_; + + my $msg = sprintf("expired status is '%s'", $self->{result_values}->{expired}); + if ($self->{result_values}->{expiry_date} eq '') { + $msg .= ', never expires'; + } else { + $msg .= sprintf( + ", expires in %d days [%s]", + $self->{result_values}->{expiry_days}, + $self->{result_values}->{expiry_date} + ); + } + + return $msg; +} + +sub custom_status_calc { + my ($self, %options) = @_; + + $self->{result_values}->{feature} = $options{new_datas}->{$self->{instance} . '_feature'}; + $self->{result_values}->{expired} = $options{new_datas}->{$self->{instance} . '_expired'}; + $self->{result_values}->{expiry_date} = $options{new_datas}->{$self->{instance} . '_expiry_date'}; + $self->{result_values}->{expiry_seconds} = $options{new_datas}->{$self->{instance} . '_expiry_seconds'}; + $self->{result_values}->{expiry_days} = ($self->{result_values}->{expiry_seconds} ne '') ? $self->{result_values}->{expiry_seconds} / 86400 : 0; + return 0; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'features', type => 1, cb_prefix_output => 'prefix_feature_output', message_multiple => 'All features licensing are ok' }, + ]; + + $self->{maps_counters}->{features} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'feature' }, { name => 'expired' }, { name => 'expiry_date' }, { name => 'expiry_seconds' } ], + closure_custom_calc => $self->can('custom_status_calc'), + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold, + } + }, + ]; +} + +sub prefix_feature_output { + my ($self, %options) = @_; + + return "Feature '" . $options{instance_value}->{feature} . "' "; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $options{options}->add_options(arguments => { + "warning-status:s" => { name => 'warning_status', default => '' }, + "critical-status:s" => { name => 'critical_status', default => '%{expired} eq "yes"' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->change_macros(macros => ['warning_status', 'critical_status']); +} + +sub manage_selection { + my ($self, %options) = @_; + + my $result = $options{custom}->execute_command(command => 'request license info', ForceArray => ['entry']); + + my $months = { + january => 1, february => 2, march => 3, april => 4, may => 5, june => 6, + july => 7, august => 8, september => 9, october => 10, november => 11, december => 12 + }; + + $self->{features} = {}; + foreach my $feature (@{$result->{licenses}->{entry}}) { + $feature->{expires} = lc($feature->{expires}); + + # January 30, 2022 + my $dt; + if ($feature->{expires} =~ /^(\w+)\s+(\d+).*?(\d+)$/) { + $dt = DateTime->new(year => $3, month => $months->{$1}, day => $2); + } + + $self->{features}->{$feature->{feature}} = { + feature => $feature->{feature}, + expired => $feature->{expired}, + expiry_date => $feature->{expires} ne 'never' ? $feature->{expires} : '', + expiry_seconds => $feature->{expires} ne 'never' ? $dt->epoch - time() : '' + }; + } + + if (scalar(keys %{$self->{features}}) <= 0) { + $self->{output}->add_option_msg(short_msg => "No features found."); + $self->{output}->option_exit(); + } +} + +1; + +__END__ + +=head1 MODE + +Check features licensing. + +=over 8 + +=item B<--warning-status> + +Set warning threshold for status. +Can use special variables like: %{expired}, %{expiry_days}, %{feature} + +=item B<--critical-status> + +Set critical threshold for status. (Default: '%{expired} eq "yes"'). +Can use special variables like: %{expired}, %{expiry_days}, %{feature} + +=back + +=cut diff --git a/network/paloalto/ssh/plugin.pm b/network/paloalto/ssh/plugin.pm index 52b69c872..3773ac63c 100644 --- a/network/paloalto/ssh/plugin.pm +++ b/network/paloalto/ssh/plugin.pm @@ -35,6 +35,7 @@ sub new { 'ha' => 'network::paloalto::ssh::mode::ha', 'interfaces' => 'network::paloalto::ssh::mode::interfaces', 'ipsec' => 'network::paloalto::ssh::mode::ipsec', + 'licenses' => 'network::paloalto::ssh::mode::licenses', 'system' => 'network::paloalto::ssh::mode::system' ); From a09870ffd2e431b97e3324d3a7715a0a444acaa0 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 5 May 2020 11:39:02 +0200 Subject: [PATCH 180/283] Fix #1927 --- .../foundry/snmp/mode/components/board.pm | 85 +++++++++++ .../foundry/snmp/mode/components/fan.pm | 77 ++++++++++ .../foundry/snmp/mode/components/psu.pm | 79 +++++++++++ .../foundry/snmp/mode/components/resources.pm | 36 +++++ .../snmp/mode/components/temperature.pm | 105 ++++++++++++++ centreon/common/foundry/snmp/mode/cpu.pm | 120 ++++++++++++++++ centreon/common/foundry/snmp/mode/hardware.pm | 119 ++++++++++++++++ centreon/common/foundry/snmp/mode/memory.pm | 133 ++++++++++++++++++ network/ruckus/icx/snmp/plugin.pm | 52 +++++++ 9 files changed, 806 insertions(+) create mode 100644 centreon/common/foundry/snmp/mode/components/board.pm create mode 100644 centreon/common/foundry/snmp/mode/components/fan.pm create mode 100644 centreon/common/foundry/snmp/mode/components/psu.pm create mode 100644 centreon/common/foundry/snmp/mode/components/resources.pm create mode 100644 centreon/common/foundry/snmp/mode/components/temperature.pm create mode 100644 centreon/common/foundry/snmp/mode/cpu.pm create mode 100644 centreon/common/foundry/snmp/mode/hardware.pm create mode 100644 centreon/common/foundry/snmp/mode/memory.pm create mode 100644 network/ruckus/icx/snmp/plugin.pm diff --git a/centreon/common/foundry/snmp/mode/components/board.pm b/centreon/common/foundry/snmp/mode/components/board.pm new file mode 100644 index 000000000..4f4cefa6b --- /dev/null +++ b/centreon/common/foundry/snmp/mode/components/board.pm @@ -0,0 +1,85 @@ +# +# Copyright 2020 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 centreon::common::foundry::snmp::mode::components::board; + +use strict; +use warnings; + +my $mapping_board_status = { + 0 => 'moduleEmpty', 2 => 'moduleGoingDown', 3 => 'moduleRejected', + 4 => 'moduleBad', 8 => 'moduleConfigured', 9 => 'moduleComingUp', + 10 => 'moduleRunning' +}; + +my $mapping = { + snAgentBrdMainBrdDescription => { oid => '.1.3.6.1.4.1.1991.1.1.2.2.1.1.2' }, + snAgentBrdModuleStatus => { oid => '.1.3.6.1.4.1.1991.1.1.2.2.1.1.12', map => $mapping_board_status } +}; +sub load { + my ($self) = @_; + + push @{$self->{request}}, + { oid => $mapping->{snAgentBrdMainBrdDescription}->{oid} }, + { oid => $mapping->{snAgentBrdModuleStatus}->{oid} }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => 'checking boards'); + $self->{components}->{board} = { name => 'boards', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'board')); + + my $result = { + %{$self->{results}->{ $mapping->{snAgentBrdMainBrdDescription}->{oid} }}, + %{$self->{results}->{ $mapping->{snAgentBrdModuleStatus}->{oid} }} + }; + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %$result)) { + next if ($oid !~ /^$mapping->{snAgentBrdModuleStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $result, instance => $instance); + + next if ($self->check_filter(section => 'board', instance => $instance)); + $self->{components}->{board}->{total}++; + + $self->{output}->output_add( + long_msg => sprintf( + "board '%s' status is '%s' [instance: %s].", + $result->{snAgentBrdMainBrdDescription}, + $result->{snAgentBrdModuleStatus}, + $instance + ) + ); + my $exit = $self->get_severity(section => 'board', value => $result->{snAgentBrdModuleStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "board '%s' status is '%s'", + $result->{snAgentBrdMainBrdDescription}, + $result->{snAgentBrdModuleStatus} + ) + ); + } + } +} + +1; diff --git a/centreon/common/foundry/snmp/mode/components/fan.pm b/centreon/common/foundry/snmp/mode/components/fan.pm new file mode 100644 index 000000000..9ee8b6ae2 --- /dev/null +++ b/centreon/common/foundry/snmp/mode/components/fan.pm @@ -0,0 +1,77 @@ +# +# Copyright 2020 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 centreon::common::foundry::snmp::mode::components::fan; + +use strict; +use warnings; +use centreon::common::foundry::snmp::mode::components::resources qw($map_status); + +my $mapping = { + snChasFan2Description => { oid => '.1.3.6.1.4.1.1991.1.1.1.3.2.1.3' }, + snChasFan2OperStatus => { oid => '.1.3.6.1.4.1.1991.1.1.1.3.2.1.4', map => $map_status } +}; +my $oid_snChasFan2Entry = '.1.3.6.1.4.1.1991.1.1.1.3.2.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { + oid => $oid_snChasFan2Entry, + start => $mapping->{snChasFan2Description}->{oid} + }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => 'checking fans'); + $self->{components}->{fan} = { name => 'fans', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'fan')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_snChasFan2Entry}})) { + next if ($oid !~ /^$mapping->{snChasFan2OperStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_snChasFan2Entry}, instance => $instance); + + next if ($self->check_filter(section => 'fan', instance => $instance)); + + $self->{components}->{fan}->{total}++; + $self->{output}->output_add( + long_msg => sprintf( + "fan '%s' status is '%s' [instance = %s]", + $result->{snChasFan2Description}, $result->{snChasFan2OperStatus}, $instance + ) + ); + + my $exit = $self->get_severity(label => 'default', section => 'fan', value => $result->{snChasFan2OperStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "fan '%s' status is '%s'", + $result->{snChasFan2Description}, $result->{snChasFan2OperStatus} + ) + ); + } + } +} + +1; diff --git a/centreon/common/foundry/snmp/mode/components/psu.pm b/centreon/common/foundry/snmp/mode/components/psu.pm new file mode 100644 index 000000000..d1e8dad2a --- /dev/null +++ b/centreon/common/foundry/snmp/mode/components/psu.pm @@ -0,0 +1,79 @@ +# +# Copyright 2020 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 centreon::common::foundry::snmp::mode::components::psu; + +use strict; +use warnings; +use centreon::common::foundry::snmp::mode::components::resources qw($map_status); + +my $mapping = { + snChasPwrSupply2Description => { oid => '.1.3.6.1.4.1.1991.1.1.1.2.2.1.3' }, + snChasPwrSupply2OperStatus => { oid => '.1.3.6.1.4.1.1991.1.1.1.2.2.1.4', map => $map_status } +}; +my $oid_snChasPwrSupply2Entry = '.1.3.6.1.4.1.1991.1.1.1.2.2.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { + oid => $oid_snChasPwrSupply2Entry, + start => $mapping->{snChasPwrSupply2Description}->{oid} + }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => 'checking power supplies'); + $self->{components}->{psu} = { name => 'psu', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'psu')); + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_snChasPwrSupply2Entry}})) { + next if ($oid !~ /^$mapping->{snChasPwrSupply2OperStatus}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_snChasPwrSupply2Entry}, instance => $instance); + + next if ($self->check_filter(section => 'psu', instance => $instance)); + $self->{components}->{psu}->{total}++; + + $self->{output}->output_add( + long_msg => sprintf( + "power supply '%s' status is '%s' [instance: %s].", + $result->{snChasPwrSupply2Description}, + $result->{snChasPwrSupply2OperStatus}, + $instance + ) + ); + my $exit = $self->get_severity(label => 'default', section => 'psu', value => $result->{snChasPwrSupply2OperStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "power supply '%s' status is '%s'", + $result->{snChasPwrSupply2Description}, + $result->{snChasPwrSupply2OperStatus} + ) + ); + } + } +} + +1; diff --git a/centreon/common/foundry/snmp/mode/components/resources.pm b/centreon/common/foundry/snmp/mode/components/resources.pm new file mode 100644 index 000000000..b469e779a --- /dev/null +++ b/centreon/common/foundry/snmp/mode/components/resources.pm @@ -0,0 +1,36 @@ +# +# Copyright 2020 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 centreon::common::foundry::snmp::mode::components::resources; + +use strict; +use warnings; +use Exporter; + +our $map_status; + +our @ISA = qw(Exporter); +our @EXPORT_OK = qw($map_status); + +$map_status = { + 1 => 'other', 2 => 'normal', 3 => 'failure' +}; + +1; diff --git a/centreon/common/foundry/snmp/mode/components/temperature.pm b/centreon/common/foundry/snmp/mode/components/temperature.pm new file mode 100644 index 000000000..1a46b8dc0 --- /dev/null +++ b/centreon/common/foundry/snmp/mode/components/temperature.pm @@ -0,0 +1,105 @@ +# +# Copyright 2020 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 centreon::common::foundry::snmp::mode::components::temperature; + +use strict; +use warnings; + +my $mapping = { + snChasActualTemperature => { oid => '.1.3.6.1.4.1.1991.1.1.1.1.18' }, + snChasWarningTemperature => { oid => '.1.3.6.1.4.1.1991.1.1.1.1.19' }, + snChasShutdownTemperature => { oid => '.1.3.6.1.4.1.1991.1.1.1.1.20' } +}; +my $oid_snChasGen = '.1.3.6.1.4.1.1991.1.1.1.1'; + +sub load { + my ($self) = @_; + + push @{$self->{request}}, { + oid => $oid_snChasGen, + start => $mapping->{snChasActualTemperature}->{oid}, + end => $mapping->{snChasShutdownTemperature}->{oid} + }; +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => 'Checking temperatures'); + $self->{components}->{temperature} = { name => 'temperatures', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'temperature')); + + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_snChasGen}, instance => '0'); + my ($name, $instance) = ('chassi', 1); + + next if ($self->check_filter(section => 'temperature', instance => $instance)); + + $self->{components}->{temperature}->{total}++; + + $result->{snChasActualTemperature} *= 0.5; + $result->{snChasWarningTemperature} *= 0.5; + $result->{snChasShutdownTemperature} *= 0.5; + $self->{output}->output_add( + long_msg => sprintf( + "temperature '%s' is %s celsius [instance = %s]", + $name, $result->{snChasActualTemperature}, $instance + ) + ); + my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{snChasActualTemperature}); + if ($checked == 0) { + my $warn_th = defined($result->{snChasWarningTemperature}) ? $result->{snChasWarningTemperature} : ''; + my $crit_th = defined($result->{snChasShutdownTemperature}) ? $result->{snChasShutdownTemperature} : ''; + $self->{perfdata}->threshold_validate(label => 'warning-temperature-instance-' . $instance, value => $warn_th); + $self->{perfdata}->threshold_validate(label => 'critical-temperature-instance-' . $instance, value => $crit_th); + + $exit = $self->{perfdata}->threshold_check( + value => $result->{snChasActualTemperature}, + threshold => [ + { label => 'critical-temperature-instance-' . $instance, exit_litteral => 'critical' }, + { label => 'warning-temperature-instance-' . $instance, exit_litteral => 'warning' } + ] + ); + $warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-temperature-instance-' . $instance); + $crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-temperature-instance-' . $instance) + } + + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "temperature '%s' is %s celsius", + $name, + $result->{snChasActualTemperature} + ) + ); + } + + $self->{output}->perfdata_add( + nlabel => 'hardware.temperature.celsius', + unit => 'C', + instances => $name, + value => $result->{snChasActualTemperature}, + warning => $warn, + critical => $crit + ); +} + +1; diff --git a/centreon/common/foundry/snmp/mode/cpu.pm b/centreon/common/foundry/snmp/mode/cpu.pm new file mode 100644 index 000000000..a778bd133 --- /dev/null +++ b/centreon/common/foundry/snmp/mode/cpu.pm @@ -0,0 +1,120 @@ +# +# Copyright 2020 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 centreon::common::foundry::snmp::mode::cpu; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'cpu', type => 1, cb_prefix_output => 'prefix_cpu_output', message_multiple => 'All CPUs are ok' } + ]; + + $self->{maps_counters}->{cpu} = [ + { label => 'utilization-5s', nlabel => 'cpu.utilization.5s.percentage', set => { + key_values => [ { name => 'cpu_5s' }, { name => 'display' } ], + output_template => '%.2f %% (5s)', + perfdatas => [ + { value => 'cpu_5s_absolute', template => '%.2f', + unit => '%', min => 0, max => 100, label_extra_instance => 1 } + ] + } + }, + { label => 'utilization-1m', nlabel => 'cpu.utilization.1m.percentage', set => { + key_values => [ { name => 'cpu_1m' }, { name => 'display' } ], + output_template => '%.2f %% (1m)', + perfdatas => [ + { value => 'cpu_1m_absolute', template => '%.2f', + unit => '%', min => 0, max => 100, label_extra_instance => 1 } + ] + } + }, + { label => 'utilization-5m', nlabel => 'cpu.utilization.5m.percentage', set => { + key_values => [ { name => 'cpu_5m' }, { name => 'display' } ], + output_template => '%.2f %% (5m)', + perfdatas => [ + { value => 'cpu_5m_absolute', template => '%.2f', + unit => '%', min => 0, max => 100, label_extra_instance => 1 } + ] + } + } + ]; +} + +sub prefix_cpu_output { + my ($self, %options) = @_; + + return "CPU '" . $options{instance_value}->{display} . "' usage: "; +} + +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 => { + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + my $oid_snAgentCpuUtilPercent = '.1.3.6.1.4.1.1991.1.1.2.11.1.1.5'; + my $snmp_result = $options{snmp}->get_table(oid => $oid_snAgentCpuUtilPercent, nothing_quit => 1); + + $self->{cpu} = {}; + foreach my $oid (keys %$snmp_result) { + next if ($oid !~ /^$oid_snAgentCpuUtilPercent\.(.*?)\.(.*?)\.60/); + my $instance = "slot$1:cpu$2"; + + $self->{cpu}->{$instance} = { + display => $instance, + cpu_5s => $snmp_result->{ $oid_snAgentCpuUtilPercent . '.' . $1 . '.' . $2 . '.5' }, + cpu_1m => $snmp_result->{ $oid_snAgentCpuUtilPercent . '.' . $1 . '.' . $2 . '.60' }, + cpu_5m => $snmp_result->{ $oid_snAgentCpuUtilPercent . '.' . $1 . '.' . $2 . '.300' } + }; + } +} + +1; + +__END__ + +=head1 MODE + +Check CPU usage. + +=over 8 + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'utilization-5s', 'utilization-1m', 'utilization-5m'. + +=back + +=cut diff --git a/centreon/common/foundry/snmp/mode/hardware.pm b/centreon/common/foundry/snmp/mode/hardware.pm new file mode 100644 index 000000000..f63ceb0af --- /dev/null +++ b/centreon/common/foundry/snmp/mode/hardware.pm @@ -0,0 +1,119 @@ +# +# Copyright 2020 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 centreon::common::foundry::snmp::mode::hardware; + +use base qw(centreon::plugins::templates::hardware); + +use strict; +use warnings; + +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_overload_check_section_option} = '^(?:board|fan|psu|temperature)$'; + $self->{regexp_threshold_numeric_check_section_option} = '^(?:temperature)$'; + + $self->{cb_hook2} = 'snmp_execute'; + + $self->{thresholds} = { + default => [ + ['other', 'UNKNOWN'], + ['normal', 'OK'], + ['failure', 'CRITICAL'] + ], + board => [ + ['moduleEmpty', 'OK'], + ['moduleGoingDown', 'WARNING'], + ['moduleRejected', 'CRITICAL'], + ['moduleBad', 'CRITICAL'], + ['moduleConfigured', 'OK'], + ['moduleComingUp', 'OK'], + ['moduleRunning', 'OK'] + ] + }; + + $self->{components_path} = 'centreon::common::foundry::snmp::mode::components'; + $self->{components_module} = ['board', 'fan', 'psu', 'temperature']; +} + +sub snmp_execute { + my ($self, %options) = @_; + + $self->{snmp} = $options{snmp}; + $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1, force_new_perfdata => 1); + bless $self, $class; + + $options{options}->add_options(arguments => { + }); + + return $self; +} + +1; + +__END__ + +=head1 MODE + +Check hardware. + +=over 8 + +=item B<--component> + +Which component to check (Default: '.*'). +Can be: 'board', 'fan', 'temperature', 'psu'. + +=item B<--filter> + +Exclude some parts (comma seperated list) (Example: --filter=fan --filter=psu) +Can also exclude specific instance: --filter=fan,1.1 + +=item B<--no-component> + +Return an error if no compenents are checked. +If total (with skipped) is 0. (Default: 'critical' returns). + +=item B<--threshold-overload> + +Set to overload default threshold values (syntax: section,[instance,]status,regexp) +It used before default thresholds (order stays). +Example: --threshold-overload='psu,CRITICAL,fail' + +=item B<--warning> + +Set warning threshold for 'temperature' (syntax: type,regexp,threshold) +Example: --warning='temperature,.*,30' + +=item B<--critical> + +Set critical threshold for 'temperature' (syntax: type,regexp,threshold) +Example: --critical='temperature,.*,50' + +=back + +=cut + diff --git a/centreon/common/foundry/snmp/mode/memory.pm b/centreon/common/foundry/snmp/mode/memory.pm new file mode 100644 index 000000000..5d3c7c38d --- /dev/null +++ b/centreon/common/foundry/snmp/mode/memory.pm @@ -0,0 +1,133 @@ +# +# Copyright 2020 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 centreon::common::foundry::snmp::mode::memory; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub custom_usage_output { + my ($self, %options) = @_; + + return sprintf( + 'Ram total: %s %s used: %s %s (%.2f%%) free: %s %s (%.2f%%)', + $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_absolute}), + $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_absolute}), + $self->{result_values}->{prct_used_absolute}, + $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute}), + $self->{result_values}->{prct_free_absolute} + ); +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'memory', type => 0 } + ]; + + $self->{maps_counters}->{memory} = [ + { label => 'usage', nlabel => 'memory.usage.bytes', set => { + key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], + closure_custom_output => $self->can('custom_usage_output'), + perfdatas => [ + { value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute', + unit => 'B', cast_int => 1 } + ] + } + }, + { label => 'usage-free', display_ok => 0, nlabel => 'memory.free.bytes', set => { + key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], + closure_custom_output => $self->can('custom_usage_output'), + perfdatas => [ + { value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute', + unit => 'B', cast_int => 1 } + ] + } + }, + { label => 'usage-prct', display_ok => 0, nlabel => 'memory.usage.percentage', set => { + key_values => [ { name => 'prct_used' } ], + output_template => 'Ram used: %.2f %%', + perfdatas => [ + { value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, unit => '%' } + ] + } + } + ]; +} + +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 => { + }); + + return $self; +} + +my $mapping = { + total => { oid => '.1.3.6.1.4.1.20301.2.5.1.2.12.9.1.1.3' }, # totalMemoryStatsRev + free => { oid => '.1.3.6.1.4.1.20301.2.5.1.2.12.9.1.1.4' } # memoryFreeStatsRev +}; + +my $oid_memoryStatsEntry = '.1.3.6.1.4.1.20301.2.5.1.2.12.9.1.1'; + +sub manage_selection { + my ($self, %options) = @_; + + my $oid_snAgGblDynMemUtil = '.1.3.6.1.4.1.1991.1.1.2.1.53.0'; # % + my $oid_snAgGblDynMemTotal = '.1.3.6.1.4.1.1991.1.1.2.1.54.0'; # Bytes + my $snmp_result = $options{snmp}->get_leef( + oids => [$oid_snAgGblDynMemUtil, $oid_snAgGblDynMemTotal], + nothing_quit => 1 + ); + + my $used = $snmp_result->{$oid_snAgGblDynMemUtil} * $snmp_result->{$oid_snAgGblDynMemTotal} / 100; + $self->{memory} = { + prct_used => $snmp_result->{$oid_snAgGblDynMemUtil}, + prct_free => 100 - $snmp_result->{$oid_snAgGblDynMemUtil}, + total => $snmp_result->{$oid_snAgGblDynMemTotal}, + used => $used, + free => $snmp_result->{$oid_snAgGblDynMemTotal} - $used + }; +} + +1; + +__END__ + +=head1 MODE + +Check memory usage. + +=over 8 + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'usage' (B), 'usage-free' (B), 'usage-prct' (%). + +=back + +=cut diff --git a/network/ruckus/icx/snmp/plugin.pm b/network/ruckus/icx/snmp/plugin.pm new file mode 100644 index 000000000..bec60e747 --- /dev/null +++ b/network/ruckus/icx/snmp/plugin.pm @@ -0,0 +1,52 @@ +# +# Copyright 2020 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 network::ruckus::icx::snmp::plugin; + +use strict; +use warnings; +use base qw(centreon::plugins::script_snmp); + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '0.5'; + %{$self->{modes}} = ( + 'cpu' => 'centreon::common::foundry::snmp::mode::cpu', + 'hardware' => 'centreon::common::foundry::snmp::mode::hardware', + 'interfaces' => 'snmp_standard::mode::interfaces', + 'list-interfaces' => 'snmp_standard::mode::listinterfaces', + 'memory' => 'centreon::common::foundry::snmp::mode::memory' + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Ruckus ICX series in SNMP. + +=cut From 64d6fd7e15386ae4cb4976524fb6258c018dd5ce Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 5 May 2020 14:09:04 +0200 Subject: [PATCH 181/283] Fix #1751 --- .../smartzone/snmp/mode/accesspoints.pm | 247 ++++++++++++++++++ .../smartzone/snmp/mode/listaccesspoints.pm | 130 +++++++++ network/ruckus/smartzone/snmp/mode/system.pm | 152 +++++++++++ network/ruckus/smartzone/snmp/plugin.pm | 57 ++++ 4 files changed, 586 insertions(+) create mode 100644 network/ruckus/smartzone/snmp/mode/accesspoints.pm create mode 100644 network/ruckus/smartzone/snmp/mode/listaccesspoints.pm create mode 100644 network/ruckus/smartzone/snmp/mode/system.pm create mode 100644 network/ruckus/smartzone/snmp/plugin.pm diff --git a/network/ruckus/smartzone/snmp/mode/accesspoints.pm b/network/ruckus/smartzone/snmp/mode/accesspoints.pm new file mode 100644 index 000000000..15d0cf6af --- /dev/null +++ b/network/ruckus/smartzone/snmp/mode/accesspoints.pm @@ -0,0 +1,247 @@ +# +# Copyright 2020 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 network::ruckus::smartzone::snmp::mode::accesspoints; + +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 catalog_status_calc); + +sub custom_status_output { + my ($self, %options) = @_; + + return sprintf( + "connection status is '%s' [config status: '%s'] [registration status: '%s']", + $self->{result_values}->{connection_status}, + $self->{result_values}->{config_status}, + $self->{result_values}->{registration_status} + ); +} + +sub ap_long_output { + my ($self, %options) = @_; + + return "checking access point '" . $options{instance_value}->{display} . "'"; +} + +sub prefix_ap_output { + my ($self, %options) = @_; + + return "access point '" . $options{instance_value}->{display} . "' "; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'accesspoints', type => 3, cb_prefix_output => 'prefix_ap_output', cb_long_output => 'ap_long_output', + indent_long_output => ' ', message_multiple => 'All access points are ok', + group => [ + { name => 'status', type => 0, skipped_code => { -10 => 1 } }, + { name => 'connection', type => 0, skipped_code => { -10 => 1 } }, + { name => 'traffic', type => 0, skipped_code => { -10 => 1 } } + ] + } + ]; + + $self->{maps_counters}->{status} = [ + { label => 'status', threshold => 0, set => { + key_values => [ + { name => 'connection_status' }, { name => 'config_status' }, + { name => 'registration_status' }, { name => 'display' } + ], + closure_custom_calc => \&catalog_status_calc, + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold + } + } + ]; + + $self->{maps_counters}->{connection} = [ + { label => 'connection-client-devices-authorized', nlabel => 'accesspoint.connection.client.devices.authorized.count', set => { + key_values => [ { name => 'authorized_clients' }, { name => 'display' } ], + output_template => 'client devices authorized connections: %d', + perfdatas => [ + { value => 'authorized_clients_absolute', template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' } + ] + } + } + ]; + + $self->{maps_counters}->{traffic} = [ + { label => 'traffic-in', nlabel => 'accesspoint.traffic.in.bitspersecond', set => { + key_values => [ { name => 'traffic_in', diff => 1 }, { name => 'display' } ], + output_template => 'traffic in: %s%s/s', + per_second => 1, output_change_bytes => 2, + perfdatas => [ + { value => 'traffic_in_per_second', template => '%s', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' } + ] + } + }, + { label => 'traffic-out', nlabel => 'accesspoint.traffic.out.bitspersecond', set => { + key_values => [ { name => 'traffic_out', diff => 1 }, { name => 'display' } ], + output_template => 'traffic in: %s%s/s', + per_second => 1, output_change_bytes => 2, + perfdatas => [ + { value => 'traffic_out_per_second', template => '%s', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' } + ] + } + } + ]; +} + +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 => { + 'filter-name:s' => { name => 'filter_name' }, + 'unknown-status:s' => { name => 'unknown_status', default => '' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '' } + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->change_macros(macros => ['unknown_status', 'warning_status', 'critical_status']); +} + +my $mapping = { + authorized_clients => { oid => '.1.3.6.1.4.1.25053.1.4.2.1.1.2.2.1.15' }, # ruckusSZAPNumSta + connection_status => { oid => '.1.3.6.1.4.1.25053.1.4.2.1.1.2.2.1.16' }, # ruckusSZAPConnStatus + registration_status => { oid => '.1.3.6.1.4.1.25053.1.4.2.1.1.2.2.1.17' }, # ruckusSZAPRegStatus + config_status => { oid => '.1.3.6.1.4.1.25053.1.4.2.1.1.2.2.1.18' }, # ruckusSZAPConfigStatus + traffic_out => { oid => '.1.3.6.1.4.1.25053.1.4.2.1.1.2.2.1.57' }, # ruckusSZAPIpsecTXBytes + traffic_in => { oid => '.1.3.6.1.4.1.25053.1.4.2.1.1.2.2.1.58' }, # ruckusSZAPIpsecRXBytes +}; + +sub manage_selection { + my ($self, %options) = @_; + + my $oid_ruckusSZAPName = '.1.3.6.1.4.1.25053.1.4.2.1.1.2.2.1.5'; + my $oid_ruckusSZAPSerial = '.1.3.6.1.4.1.25053.1.4.2.1.1.2.2.1.9'; + my $snmp_result = $options{snmp}->get_multiple_table( + oids => [ + { oid => $oid_ruckusSZAPName }, + { oid => $oid_ruckusSZAPSerial } + ], + return_type => 1, + nothing_quit => 1 + ); + + $self->{accesspoints} = {}; + foreach (keys %$snmp_result) { + next if (! /^$oid_ruckusSZAPName\.(.*)/); + my $instance = $1; + my $name = defined($snmp_result->{$_}) && $snmp_result->{$_} ne '' ? + $snmp_result->{$_} : $snmp_result->{$oid_ruckusSZAPSerial . '.' . $instance}; + + 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 access point '" . $name . "'.", debug => 1); + next; + } + + $self->{accesspoints}->{$instance} = { + display => $name, + status => { display => $name }, + connection => { display => $name }, + traffic => { display => $name } + }; + } + + return if (scalar(keys %{$self->{accesspoints}}) <= 0); + + $options{snmp}->load( + oids => [ map($_->{oid}, values(%$mapping)) ], + instances => [ keys %{$self->{accesspoints}} ], + instance_regexp => '^(.*)$' + ); + $snmp_result = $options{snmp}->get_leef(); + foreach (keys %{$self->{accesspoints}}) { + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $_); + + $self->{accesspoints}->{$_}->{status}->{connection_status} = $result->{connection_status}; + $self->{accesspoints}->{$_}->{status}->{registration_status} = $result->{registration_status}; + $self->{accesspoints}->{$_}->{status}->{config_status} = $result->{config_status}; + + $self->{accesspoints}->{$_}->{connection}->{authorized_clients} = $result->{authorized_clients}; + + $self->{accesspoints}->{$_}->{traffic}->{traffic_in} = $result->{traffic_in} * 8; + $self->{accesspoints}->{$_}->{traffic}->{traffic_out} = $result->{traffic_out} * 8; + } + + $self->{cache_name} = 'ruckus_smartzone_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' . + (defined($self->{option_results}->{filter_counters_block}) ? md5_hex($self->{option_results}->{filter_counters_block}) : md5_hex('all')) . '_' . + (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 access points. + +=over 8 + +=item B<--filter-name> + +Filter by access point name (can be a regexp). + +=item B<--unknown-status> + +Set unknown threshold for status. +Can used special variables like: %{config_status}, %{connection_status}, %{registration_status} + +=item B<--warning-status> + +Set warning threshold for status. +Can used special variables like: %{config_status}, %{connection_status}, %{registration_status} + +=item B<--critical-status> + +Set critical threshold for status. +Can used special variables like: %{config_status}, %{connection_status}, %{registration_status} + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'memory-usage', 'usage-free', 'usage-prct', 'traffic-in', 'traffic-out', +'cpu-utilization', 'connection-accesspoints', 'connection-client-devices-authorized', +'connection-rogue-devices'. + +=back + +=cut diff --git a/network/ruckus/smartzone/snmp/mode/listaccesspoints.pm b/network/ruckus/smartzone/snmp/mode/listaccesspoints.pm new file mode 100644 index 000000000..e51950360 --- /dev/null +++ b/network/ruckus/smartzone/snmp/mode/listaccesspoints.pm @@ -0,0 +1,130 @@ +# +# Copyright 2020 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 network::ruckus::smartzone::snmp::mode::listaccesspoints; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $options{options}->add_options(arguments => { + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); +} + +my $mapping = { + name => { oid => '.1.3.6.1.4.1.25053.1.4.2.1.1.2.2.1.5' }, # ruckusSZAPName + model => { oid => '.1.3.6.1.4.1.25053.1.4.2.1.1.2.2.1.8' }, # ruckusSZAPModel + serial_number => { oid => '.1.3.6.1.4.1.25053.1.4.2.1.1.2.2.1.9' }, # ruckusSZAPSerial + connection_status => { oid => '.1.3.6.1.4.1.25053.1.4.2.1.1.2.2.1.16' }, # ruckusSZAPConnStatus + registration_status => { oid => '.1.3.6.1.4.1.25053.1.4.2.1.1.2.2.1.17' }, # ruckusSZAPRegStatus + config_status => { oid => '.1.3.6.1.4.1.25053.1.4.2.1.1.2.2.1.18' }, # ruckusSZAPConfigStatus +}; +my $oid_ruckusSZAPEntry = '.1.3.6.1.4.1.25053.1.4.2.1.1.2.2.1'; + +sub manage_selection { + my ($self, %options) = @_; + + my $snmp_result = $options{snmp}->get_table( + oid => $oid_ruckusSZAPEntry, + start => $mapping->{name}->{oid}, + end => $mapping->{config_status}->{oid}, + nothing_quit => 1 + ); + + my $accesspoints = {}; + foreach my $oid (keys %$snmp_result) { + next if ($oid !~ /^$mapping->{name}->{oid}\.(.*)$/); + my $instance = $1; + $accesspoints->{$instance} = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance); + } + + return $accesspoints; +} + +sub run { + my ($self, %options) = @_; + + my $accesspoints = $self->manage_selection(%options); + foreach (sort keys %$accesspoints) { + $self->{output}->output_add( + long_msg => sprintf( + '[name: %s] [serial number: %s] [model: %s] [connection status: %s] [config status: %s] [registration status: %s]', + $accesspoints->{$_}->{name}, + $accesspoints->{$_}->{serial_number}, + $accesspoints->{$_}->{model}, + $accesspoints->{$_}->{connection_status}, + $accesspoints->{$_}->{config_status}, + $accesspoints->{$_}->{registration_status} + ) + ); + } + + $self->{output}->output_add( + severity => 'OK', + short_msg => 'List acess points:' + ); + $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 => [keys %$mapping]); +} + +sub disco_show { + my ($self, %options) = @_; + + my $accesspoints = $self->manage_selection(%options); + foreach (sort keys %$accesspoints) { + $self->{output}->add_disco_entry( + %{$accesspoints->{$_}} + ); + } +} + +1; + +__END__ + +=head1 MODE + +List acess points. + +=over 8 + +=back + +=cut + diff --git a/network/ruckus/smartzone/snmp/mode/system.pm b/network/ruckus/smartzone/snmp/mode/system.pm new file mode 100644 index 000000000..42f89bb79 --- /dev/null +++ b/network/ruckus/smartzone/snmp/mode/system.pm @@ -0,0 +1,152 @@ +# +# Copyright 2020 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 network::ruckus::smartzone::snmp::mode::system; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use Digest::MD5 qw(md5_hex); + +sub system_long_output { + my ($self, %options) = @_; + + return 'checking system '; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'system', type => 3, cb_long_output => 'system_long_output', + indent_long_output => ' ', + group => [ + { name => 'connection', type => 0, skipped_code => { -10 => 1 } }, + { name => 'traffic', type => 0, skipped_code => { -10 => 1 } } + ] + } + ]; + + $self->{maps_counters}->{connection} = [ + { label => 'connection-accesspoints', nlabel => 'system.connection.accesspoints.count', set => { + key_values => [ { name => 'ap' } ], + output_template => 'access points connections: %d', + perfdatas => [ + { value => 'ap_absolute', template => '%d', min => 0 } + ] + } + }, + { label => 'connection-client-devices-authorized', nlabel => 'system.connection.client.devices.authorized.count', set => { + key_values => [ { name => 'authorized_clients' } ], + output_template => 'client devices authorized connections: %d', + perfdatas => [ + { value => 'authorized_clients_absolute', template => '%d', min => 0 } + ] + } + } + ]; + + $self->{maps_counters}->{traffic} = [ + { label => 'traffic-in', nlabel => 'system.traffic.in.bitspersecond', set => { + key_values => [ { name => 'traffic_in', diff => 1 } ], + output_template => 'traffic in: %s%s/s', + per_second => 1, output_change_bytes => 2, + perfdatas => [ + { value => 'traffic_in_per_second', template => '%s', + min => 0, unit => 'b/s' } + ] + } + }, + { label => 'traffic-out', nlabel => 'system.traffic.out.bitspersecond', set => { + key_values => [ { name => 'traffic_out', diff => 1 } ], + output_template => 'traffic in: %s%s/s', + per_second => 1, output_change_bytes => 2, + perfdatas => [ + { value => 'traffic_out_per_second', template => '%s', + min => 0, unit => 'b/s' } + ] + } + } + ]; +} + +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 => { + }); + + return $self; +} + +my $mapping = { + ap => { oid => '.1.3.6.1.4.1.25053.1.4.1.1.1.15.1' }, # ruckusSZSystemStatsNumAP + authorized_clients => { oid => '.1.3.6.1.4.1.25053.1.4.1.1.1.15.2' }, # ruckusSZSystemStatsNumSta + traffic_in => { oid => '.1.3.6.1.4.1.25053.1.4.1.1.1.15.6' }, # ruckusSZSystemStatsWLANTotalRxBytes + traffic_out => { oid => '.1.3.6.1.4.1.25053.1.4.1.1.1.15.9' } # ruckusSZSystemStatsWLANTotalTxBytes +}; + +sub manage_selection { + my ($self, %options) = @_; + + my $snmp_result = $options{snmp}->get_leef( + oids => [ map($_->{oid} . '.0', values(%$mapping)) ], + nothing_quit => 1 + ); + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => 0); + + $self->{system}->{global} = { + connection => { + ap => $result->{ap}, + authorized_clients => $result->{authorized_clients} + }, + traffic => { + traffic_in => $result->{traffic_in} * 8, + traffic_out => $result->{traffic_out} * 8 + } + }; + + $self->{cache_name} = 'ruckus_smartzone_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' . + (defined($self->{option_results}->{filter_counters_block}) ? md5_hex($self->{option_results}->{filter_counters_block}) : md5_hex('all')) . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); +} + +1; + +__END__ + +=head1 MODE + +Check system. + +=over 8 + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'traffic-in', 'traffic-out', 'connection-accesspoints', +'connection-client-devices-authorized'. + +=back + +=cut diff --git a/network/ruckus/smartzone/snmp/plugin.pm b/network/ruckus/smartzone/snmp/plugin.pm new file mode 100644 index 000000000..8edf382f3 --- /dev/null +++ b/network/ruckus/smartzone/snmp/plugin.pm @@ -0,0 +1,57 @@ +# +# Copyright 2020 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 network::ruckus::smartzone::snmp::plugin; + +use strict; +use warnings; +use base qw(centreon::plugins::script_snmp); + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '0.5'; + %{$self->{modes}} = ( + 'access-points' => 'network::ruckus::smartzone::snmp::mode::accesspoints', + 'cpu' => 'snmp_standard::mode::cpu', + 'interfaces' => 'snmp_standard::mode::interfaces', + 'list-access-points' => 'network::ruckus::smartzone::snmp::mode::listaccesspoints', + 'list-interfaces' => 'snmp_standard::mode::listinterfaces', + 'list-storages' => 'snmp_standard::mode::liststorages', + 'load' => 'snmp_standard::mode::loadaverage', + 'memory' => 'snmp_standard::mode::memory', + 'storage' => 'snmp_standard::mode::storage', + 'system' => 'network::ruckus::smartzone::snmp::mode::system', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Ruckus SmartZone in SNMP. + +=cut From 140d43162c17915a338f575d4ab5c77a2dda21ab Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 5 May 2020 14:53:41 +0200 Subject: [PATCH 182/283] Break change: move netapp directories - can add some new plugins for netapp --- .../oncommandapi/custom/api.pm} | 12 +-- .../oncommandapi}/mode/aggregateraidstatus.pm | 19 +++-- .../oncommandapi}/mode/aggregatestatus.pm | 19 +++-- .../oncommandapi}/mode/aggregateusage.pm | 16 ++-- .../oncommandapi}/mode/clusterio.pm | 16 ++-- .../oncommandapi}/mode/clusterstatus.pm | 15 ++-- .../oncommandapi}/mode/clusterusage.pm | 14 +--- .../oncommandapi}/mode/diskfailed.pm | 11 ++- .../oncommandapi}/mode/diskspare.pm | 13 ++-- .../oncommandapi}/mode/fcportstatus.pm | 17 ++--- .../oncommandapi}/mode/listaggregates.pm | 17 ++--- .../oncommandapi}/mode/listclusters.pm | 13 ++-- .../oncommandapi}/mode/listfcports.pm | 17 ++--- .../oncommandapi}/mode/listluns.pm | 15 ++-- .../oncommandapi}/mode/listnodes.pm | 13 ++-- .../oncommandapi}/mode/listsnapmirrors.pm | 15 ++-- .../oncommandapi}/mode/listvolumes.pm | 15 ++-- .../oncommandapi}/mode/lunalignment.pm | 11 ++- .../oncommandapi}/mode/lunonline.pm | 11 ++- .../oncommandapi}/mode/lunusage.pm | 8 +- .../oncommandapi}/mode/nodefailoverstatus.pm | 17 ++--- .../oncommandapi}/mode/nodehardwarestatus.pm | 19 +++-- .../oncommandapi}/mode/qtreestatus.pm | 17 ++--- .../oncommandapi}/mode/snapmirrorstatus.pm | 17 ++--- .../oncommandapi}/mode/snapmirrorusage.pm | 9 +-- .../oncommandapi}/mode/volumeio.pm | 17 ++--- .../oncommandapi}/mode/volumestatus.pm | 13 ++-- .../oncommandapi}/mode/volumeusage.pm | 14 ++-- storage/netapp/ontap/oncommandapi/plugin.pm | 75 +++++++++++++++++++ .../{ => ontap}/snmp/mode/aggregatestate.pm | 6 +- .../netapp/{ => ontap}/snmp/mode/cacheage.pm | 12 +-- .../snmp/mode/components/communication.pm | 2 +- .../snmp/mode/components/electronics.pm | 2 +- .../{ => ontap}/snmp/mode/components/fan.pm | 2 +- .../{ => ontap}/snmp/mode/components/psu.pm | 2 +- .../{ => ontap}/snmp/mode/components/raid.pm | 2 +- .../snmp/mode/components/temperature.pm | 2 +- .../snmp/mode/components/voltage.pm | 2 +- .../{ => ontap}/snmp/mode/cpstatistics.pm | 2 +- .../netapp/{ => ontap}/snmp/mode/cpuload.pm | 13 ++-- .../{ => ontap}/snmp/mode/diskfailed.pm | 11 ++- .../netapp/{ => ontap}/snmp/mode/failover.pm | 2 +- storage/netapp/{ => ontap}/snmp/mode/fan.pm | 11 ++- .../netapp/{ => ontap}/snmp/mode/filesys.pm | 14 ++-- .../{ => ontap}/snmp/mode/globalstatus.pm | 2 +- .../{ => ontap}/snmp/mode/listfilesys.pm | 8 +- .../{ => ontap}/snmp/mode/listsnapvault.pm | 2 +- .../{ => ontap}/snmp/mode/ndmpsessions.pm | 13 ++-- storage/netapp/{ => ontap}/snmp/mode/nvram.pm | 11 ++- .../{ => ontap}/snmp/mode/partnerstatus.pm | 11 ++- storage/netapp/{ => ontap}/snmp/mode/psu.pm | 26 ++++--- .../{ => ontap}/snmp/mode/qtreeusage.pm | 14 ++-- .../{ => ontap}/snmp/mode/sharecalls.pm | 2 +- storage/netapp/{ => ontap}/snmp/mode/shelf.pm | 11 ++- storage/netapp/{ => ontap}/snmp/mode/sis.pm | 2 +- .../{ => ontap}/snmp/mode/snapmirrorlag.pm | 2 +- .../{ => ontap}/snmp/mode/snapshotage.pm | 17 ++--- .../{ => ontap}/snmp/mode/snapvaultusage.pm | 10 +-- .../{ => ontap}/snmp/mode/temperature.pm | 24 +++--- .../{ => ontap}/snmp/mode/volumeoptions.pm | 20 ++--- storage/netapp/ontap/snmp/plugin.pm | 72 ++++++++++++++++++ storage/netapp/restapi/plugin.pm | 75 ------------------- storage/netapp/snmp/plugin.pm | 72 ------------------ 63 files changed, 463 insertions(+), 501 deletions(-) rename storage/netapp/{restapi/custom/restapi.pm => ontap/oncommandapi/custom/api.pm} (96%) rename storage/netapp/{restapi => ontap/oncommandapi}/mode/aggregateraidstatus.pm (89%) rename storage/netapp/{restapi => ontap/oncommandapi}/mode/aggregatestatus.pm (89%) rename storage/netapp/{restapi => ontap/oncommandapi}/mode/aggregateusage.pm (96%) rename storage/netapp/{restapi => ontap/oncommandapi}/mode/clusterio.pm (92%) rename storage/netapp/{restapi => ontap/oncommandapi}/mode/clusterstatus.pm (90%) rename storage/netapp/{restapi => ontap/oncommandapi}/mode/clusterusage.pm (92%) rename storage/netapp/{restapi => ontap/oncommandapi}/mode/diskfailed.pm (93%) rename storage/netapp/{restapi => ontap/oncommandapi}/mode/diskspare.pm (93%) rename storage/netapp/{restapi => ontap/oncommandapi}/mode/fcportstatus.pm (90%) rename storage/netapp/{restapi => ontap/oncommandapi}/mode/listaggregates.pm (91%) rename storage/netapp/{restapi => ontap/oncommandapi}/mode/listclusters.pm (91%) rename storage/netapp/{restapi => ontap/oncommandapi}/mode/listfcports.pm (90%) rename storage/netapp/{restapi => ontap/oncommandapi}/mode/listluns.pm (91%) rename storage/netapp/{restapi => ontap/oncommandapi}/mode/listnodes.pm (91%) rename storage/netapp/{restapi => ontap/oncommandapi}/mode/listsnapmirrors.pm (91%) rename storage/netapp/{restapi => ontap/oncommandapi}/mode/listvolumes.pm (91%) rename storage/netapp/{restapi => ontap/oncommandapi}/mode/lunalignment.pm (95%) rename storage/netapp/{restapi => ontap/oncommandapi}/mode/lunonline.pm (94%) rename storage/netapp/{restapi => ontap/oncommandapi}/mode/lunusage.pm (96%) rename storage/netapp/{restapi => ontap/oncommandapi}/mode/nodefailoverstatus.pm (90%) rename storage/netapp/{restapi => ontap/oncommandapi}/mode/nodehardwarestatus.pm (89%) rename storage/netapp/{restapi => ontap/oncommandapi}/mode/qtreestatus.pm (89%) rename storage/netapp/{restapi => ontap/oncommandapi}/mode/snapmirrorstatus.pm (88%) rename storage/netapp/{restapi => ontap/oncommandapi}/mode/snapmirrorusage.pm (94%) rename storage/netapp/{restapi => ontap/oncommandapi}/mode/volumeio.pm (94%) rename storage/netapp/{restapi => ontap/oncommandapi}/mode/volumestatus.pm (88%) rename storage/netapp/{restapi => ontap/oncommandapi}/mode/volumeusage.pm (98%) create mode 100644 storage/netapp/ontap/oncommandapi/plugin.pm rename storage/netapp/{ => ontap}/snmp/mode/aggregatestate.pm (97%) rename storage/netapp/{ => ontap}/snmp/mode/cacheage.pm (90%) rename storage/netapp/{ => ontap}/snmp/mode/components/communication.pm (97%) rename storage/netapp/{ => ontap}/snmp/mode/components/electronics.pm (97%) rename storage/netapp/{ => ontap}/snmp/mode/components/fan.pm (98%) rename storage/netapp/{ => ontap}/snmp/mode/components/psu.pm (97%) rename storage/netapp/{ => ontap}/snmp/mode/components/raid.pm (97%) rename storage/netapp/{ => ontap}/snmp/mode/components/temperature.pm (98%) rename storage/netapp/{ => ontap}/snmp/mode/components/voltage.pm (99%) rename storage/netapp/{ => ontap}/snmp/mode/cpstatistics.pm (99%) rename storage/netapp/{ => ontap}/snmp/mode/cpuload.pm (89%) rename storage/netapp/{ => ontap}/snmp/mode/diskfailed.pm (93%) rename storage/netapp/{ => ontap}/snmp/mode/failover.pm (99%) rename storage/netapp/{ => ontap}/snmp/mode/fan.pm (96%) rename storage/netapp/{ => ontap}/snmp/mode/filesys.pm (97%) rename storage/netapp/{ => ontap}/snmp/mode/globalstatus.pm (99%) rename storage/netapp/{ => ontap}/snmp/mode/listfilesys.pm (95%) rename storage/netapp/{ => ontap}/snmp/mode/listsnapvault.pm (98%) rename storage/netapp/{ => ontap}/snmp/mode/ndmpsessions.pm (89%) rename storage/netapp/{ => ontap}/snmp/mode/nvram.pm (95%) rename storage/netapp/{ => ontap}/snmp/mode/partnerstatus.pm (96%) rename storage/netapp/{ => ontap}/snmp/mode/psu.pm (82%) rename storage/netapp/{ => ontap}/snmp/mode/qtreeusage.pm (95%) rename storage/netapp/{ => ontap}/snmp/mode/sharecalls.pm (98%) rename storage/netapp/{ => ontap}/snmp/mode/shelf.pm (95%) rename storage/netapp/{ => ontap}/snmp/mode/sis.pm (99%) rename storage/netapp/{ => ontap}/snmp/mode/snapmirrorlag.pm (99%) rename storage/netapp/{ => ontap}/snmp/mode/snapshotage.pm (93%) rename storage/netapp/{ => ontap}/snmp/mode/snapvaultusage.pm (96%) rename storage/netapp/{ => ontap}/snmp/mode/temperature.pm (84%) rename storage/netapp/{ => ontap}/snmp/mode/volumeoptions.pm (92%) create mode 100644 storage/netapp/ontap/snmp/plugin.pm delete mode 100644 storage/netapp/restapi/plugin.pm delete mode 100644 storage/netapp/snmp/plugin.pm diff --git a/storage/netapp/restapi/custom/restapi.pm b/storage/netapp/ontap/oncommandapi/custom/api.pm similarity index 96% rename from storage/netapp/restapi/custom/restapi.pm rename to storage/netapp/ontap/oncommandapi/custom/api.pm index 79808d4c4..e231c59be 100644 --- a/storage/netapp/restapi/custom/restapi.pm +++ b/storage/netapp/ontap/oncommandapi/custom/api.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::restapi::custom::restapi; +package storage::netapp::ontap::oncommandapi::custom::api; use strict; use warnings; @@ -48,10 +48,10 @@ sub new { "proto:s@" => { name => 'proto' }, "username:s@" => { name => 'username' }, "password:s@" => { name => 'password' }, - "timeout:s@" => { name => 'timeout' }, + "timeout:s@" => { name => 'timeout' } }); } - $options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1); + $options{options}->add_help(package => __PACKAGE__, sections => 'OnCommand API OPTIONS', once => 1); $self->{output} = $options{output}; $self->{mode} = $options{mode}; @@ -202,13 +202,13 @@ __END__ =head1 NAME -NetApp OnCommand REST API +NetApp OnCommand API =head1 SYNOPSIS -NetApp OnCommand Rest API custom mode +NetApp OnCommand API custom mode -=head1 REST API OPTIONS +=head1 OnCommand API OPTIONS =over 8 diff --git a/storage/netapp/restapi/mode/aggregateraidstatus.pm b/storage/netapp/ontap/oncommandapi/mode/aggregateraidstatus.pm similarity index 89% rename from storage/netapp/restapi/mode/aggregateraidstatus.pm rename to storage/netapp/ontap/oncommandapi/mode/aggregateraidstatus.pm index 2e5fe5aab..efabba77d 100644 --- a/storage/netapp/restapi/mode/aggregateraidstatus.pm +++ b/storage/netapp/ontap/oncommandapi/mode/aggregateraidstatus.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::restapi::mode::aggregateraidstatus; +package storage::netapp::ontap::oncommandapi::mode::aggregateraidstatus; use base qw(centreon::plugins::templates::counter); @@ -75,15 +75,14 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - "filter-node:s" => { name => 'filter_node' }, - "filter-cluster:s" => { name => 'filter_cluster' }, - "warning-status:s" => { name => 'warning_status' }, - "critical-status:s" => { name => 'critical_status', default => '%{status} !~ /normal/i' }, - }); - + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' }, + 'filter-node:s' => { name => 'filter_node' }, + 'filter-cluster:s' => { name => 'filter_cluster' }, + 'warning-status:s' => { name => 'warning_status' }, + 'critical-status:s' => { name => 'critical_status', default => '%{status} !~ /normal/i' } + }); + return $self; } diff --git a/storage/netapp/restapi/mode/aggregatestatus.pm b/storage/netapp/ontap/oncommandapi/mode/aggregatestatus.pm similarity index 89% rename from storage/netapp/restapi/mode/aggregatestatus.pm rename to storage/netapp/ontap/oncommandapi/mode/aggregatestatus.pm index f8a3c302a..0b4cfc128 100644 --- a/storage/netapp/restapi/mode/aggregatestatus.pm +++ b/storage/netapp/ontap/oncommandapi/mode/aggregatestatus.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::restapi::mode::aggregatestatus; +package storage::netapp::ontap::oncommandapi::mode::aggregatestatus; use base qw(centreon::plugins::templates::counter); @@ -74,15 +74,14 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - "filter-node:s" => { name => 'filter_node' }, - "filter-cluster:s" => { name => 'filter_cluster' }, - "warning-status:s" => { name => 'warning_status' }, - "critical-status:s" => { name => 'critical_status', default => '%{state} !~ /online/i' }, - }); - + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' }, + 'filter-node:s' => { name => 'filter_node' }, + 'filter-cluster:s' => { name => 'filter_cluster' }, + 'warning-status:s' => { name => 'warning_status' }, + 'critical-status:s' => { name => 'critical_status', default => '%{state} !~ /online/i' } + }); + return $self; } diff --git a/storage/netapp/restapi/mode/aggregateusage.pm b/storage/netapp/ontap/oncommandapi/mode/aggregateusage.pm similarity index 96% rename from storage/netapp/restapi/mode/aggregateusage.pm rename to storage/netapp/ontap/oncommandapi/mode/aggregateusage.pm index 0d40d551e..98343674c 100644 --- a/storage/netapp/restapi/mode/aggregateusage.pm +++ b/storage/netapp/ontap/oncommandapi/mode/aggregateusage.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::restapi::mode::aggregateusage; +package storage::netapp::ontap::oncommandapi::mode::aggregateusage; use base qw(centreon::plugins::templates::counter); @@ -190,13 +190,13 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - "filter-name:s" => { name => 'filter_name' }, - "filter-node:s" => { name => 'filter_node' }, - "filter-cluster:s" => { name => 'filter_cluster' }, - "filter-state:s" => { name => 'filter_state' }, - "filter-type:s" => { name => 'filter_type' }, - "units:s" => { name => 'units', default => '%' }, - "free" => { name => 'free' }, + 'filter-name:s' => { name => 'filter_name' }, + 'filter-node:s' => { name => 'filter_node' }, + 'filter-cluster:s' => { name => 'filter_cluster' }, + 'filter-state:s' => { name => 'filter_state' }, + 'filter-type:s' => { name => 'filter_type' }, + 'units:s' => { name => 'units', default => '%' }, + 'free' => { name => 'free' } }); return $self; diff --git a/storage/netapp/restapi/mode/clusterio.pm b/storage/netapp/ontap/oncommandapi/mode/clusterio.pm similarity index 92% rename from storage/netapp/restapi/mode/clusterio.pm rename to storage/netapp/ontap/oncommandapi/mode/clusterio.pm index 8d1d7098b..93b09c122 100644 --- a/storage/netapp/restapi/mode/clusterio.pm +++ b/storage/netapp/ontap/oncommandapi/mode/clusterio.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::restapi::mode::clusterio; +package storage::netapp::ontap::oncommandapi::mode::clusterio; use base qw(centreon::plugins::templates::counter); @@ -66,17 +66,11 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - }); - - return $self; -} + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' } + }); -sub check_options { - my ($self, %options) = @_; - $self->SUPER::check_options(%options); + return $self; } sub manage_selection { diff --git a/storage/netapp/restapi/mode/clusterstatus.pm b/storage/netapp/ontap/oncommandapi/mode/clusterstatus.pm similarity index 90% rename from storage/netapp/restapi/mode/clusterstatus.pm rename to storage/netapp/ontap/oncommandapi/mode/clusterstatus.pm index 204125de0..6669aaa4b 100644 --- a/storage/netapp/restapi/mode/clusterstatus.pm +++ b/storage/netapp/ontap/oncommandapi/mode/clusterstatus.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::restapi::mode::clusterstatus; +package storage::netapp::ontap::oncommandapi::mode::clusterstatus; use base qw(centreon::plugins::templates::counter); @@ -77,13 +77,12 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - "warning-status:s" => { name => 'warning_status' }, - "critical-status:s" => { name => 'critical_status', default => '%{status} !~ /ok/i' }, - }); - + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' }, + 'warning-status:s' => { name => 'warning_status' }, + 'critical-status:s' => { name => 'critical_status', default => '%{status} !~ /ok/i' }, + }); + return $self; } diff --git a/storage/netapp/restapi/mode/clusterusage.pm b/storage/netapp/ontap/oncommandapi/mode/clusterusage.pm similarity index 92% rename from storage/netapp/restapi/mode/clusterusage.pm rename to storage/netapp/ontap/oncommandapi/mode/clusterusage.pm index e1fa5b455..a90f45f24 100644 --- a/storage/netapp/restapi/mode/clusterusage.pm +++ b/storage/netapp/ontap/oncommandapi/mode/clusterusage.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::restapi::mode::clusterusage; +package storage::netapp::ontap::oncommandapi::mode::clusterusage; use base qw(centreon::plugins::templates::counter); @@ -65,19 +65,13 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - }); + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' } + }); return $self; } -sub check_options { - my ($self, %options) = @_; - $self->SUPER::check_options(%options); -} - sub manage_selection { my ($self, %options) = @_; diff --git a/storage/netapp/restapi/mode/diskfailed.pm b/storage/netapp/ontap/oncommandapi/mode/diskfailed.pm similarity index 93% rename from storage/netapp/restapi/mode/diskfailed.pm rename to storage/netapp/ontap/oncommandapi/mode/diskfailed.pm index a889a8c3c..6ba8e3680 100644 --- a/storage/netapp/restapi/mode/diskfailed.pm +++ b/storage/netapp/ontap/oncommandapi/mode/diskfailed.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::restapi::mode::diskfailed; +package storage::netapp::ontap::oncommandapi::mode::diskfailed; use base qw(centreon::plugins::templates::counter); @@ -59,11 +59,10 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-node:s" => { name => 'filter_node' }, - "filter-cluster:s" => { name => 'filter_cluster' }, - }); + $options{options}->add_options(arguments => { + 'filter-node:s' => { name => 'filter_node' }, + 'filter-cluster:s' => { name => 'filter_cluster' } + }); return $self; } diff --git a/storage/netapp/restapi/mode/diskspare.pm b/storage/netapp/ontap/oncommandapi/mode/diskspare.pm similarity index 93% rename from storage/netapp/restapi/mode/diskspare.pm rename to storage/netapp/ontap/oncommandapi/mode/diskspare.pm index f374105f3..49fa4ffb1 100644 --- a/storage/netapp/restapi/mode/diskspare.pm +++ b/storage/netapp/ontap/oncommandapi/mode/diskspare.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::restapi::mode::diskspare; +package storage::netapp::ontap::oncommandapi::mode::diskspare; use base qw(centreon::plugins::templates::counter); @@ -68,12 +68,11 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-node:s" => { name => 'filter_node' }, - "filter-cluster:s" => { name => 'filter_cluster' }, - }); - + $options{options}->add_options(arguments => { + 'filter-node:s' => { name => 'filter_node' }, + 'filter-cluster:s' => { name => 'filter_cluster' } + }); + return $self; } diff --git a/storage/netapp/restapi/mode/fcportstatus.pm b/storage/netapp/ontap/oncommandapi/mode/fcportstatus.pm similarity index 90% rename from storage/netapp/restapi/mode/fcportstatus.pm rename to storage/netapp/ontap/oncommandapi/mode/fcportstatus.pm index 2fb447760..91e9892ea 100644 --- a/storage/netapp/restapi/mode/fcportstatus.pm +++ b/storage/netapp/ontap/oncommandapi/mode/fcportstatus.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::restapi::mode::fcportstatus; +package storage::netapp::ontap::oncommandapi::mode::fcportstatus; use base qw(centreon::plugins::templates::counter); @@ -78,14 +78,13 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - "warning-status:s" => { name => 'warning_status' }, - "critical-status:s" => { name => 'critical_status', default => '%{status} !~ /online/i || %{state} !~ /online/i' }, - }); - + + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' }, + 'warning-status:s' => { name => 'warning_status' }, + 'critical-status:s' => { name => 'critical_status', default => '%{status} !~ /online/i || %{state} !~ /online/i' }, + }); + return $self; } diff --git a/storage/netapp/restapi/mode/listaggregates.pm b/storage/netapp/ontap/oncommandapi/mode/listaggregates.pm similarity index 91% rename from storage/netapp/restapi/mode/listaggregates.pm rename to storage/netapp/ontap/oncommandapi/mode/listaggregates.pm index ad6d9523b..5ecff30f3 100644 --- a/storage/netapp/restapi/mode/listaggregates.pm +++ b/storage/netapp/ontap/oncommandapi/mode/listaggregates.pm @@ -18,9 +18,9 @@ # limitations under the License. # -package storage::netapp::restapi::mode::listaggregates; +package storage::netapp::ontap::oncommandapi::mode::listaggregates; -use base qw(centreon::plugins::templates::counter); +use base qw(centreon::plugins::mode); use strict; use warnings; @@ -30,19 +30,18 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - "filter-node:s" => { name => 'filter_node' }, - "filter-cluster:s" => { name => 'filter_cluster' }, - }); + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' }, + 'filter-node:s' => { name => 'filter_node' }, + 'filter-cluster:s' => { name => 'filter_cluster' } + }); return $self; } sub check_options { my ($self, %options) = @_; - $self->SUPER::check_options(%options); + $self->SUPER::init(%options); } sub manage_selection { diff --git a/storage/netapp/restapi/mode/listclusters.pm b/storage/netapp/ontap/oncommandapi/mode/listclusters.pm similarity index 91% rename from storage/netapp/restapi/mode/listclusters.pm rename to storage/netapp/ontap/oncommandapi/mode/listclusters.pm index e53c40921..8a37cfcdf 100644 --- a/storage/netapp/restapi/mode/listclusters.pm +++ b/storage/netapp/ontap/oncommandapi/mode/listclusters.pm @@ -18,9 +18,9 @@ # limitations under the License. # -package storage::netapp::restapi::mode::listclusters; +package storage::netapp::ontap::oncommandapi::mode::listclusters; -use base qw(centreon::plugins::templates::counter); +use base qw(centreon::plugins::mode); use strict; use warnings; @@ -30,17 +30,16 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - }); + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' } + }); return $self; } sub check_options { my ($self, %options) = @_; - $self->SUPER::check_options(%options); + $self->SUPER::init(%options); } sub manage_selection { diff --git a/storage/netapp/restapi/mode/listfcports.pm b/storage/netapp/ontap/oncommandapi/mode/listfcports.pm similarity index 90% rename from storage/netapp/restapi/mode/listfcports.pm rename to storage/netapp/ontap/oncommandapi/mode/listfcports.pm index cfa4d1f2a..6d6db9dc4 100644 --- a/storage/netapp/restapi/mode/listfcports.pm +++ b/storage/netapp/ontap/oncommandapi/mode/listfcports.pm @@ -18,9 +18,9 @@ # limitations under the License. # -package storage::netapp::restapi::mode::listfcports; +package storage::netapp::ontap::oncommandapi::mode::listfcports; -use base qw(centreon::plugins::templates::counter); +use base qw(centreon::plugins::mode); use strict; use warnings; @@ -29,18 +29,17 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - }); - + + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' } + }); + return $self; } sub check_options { my ($self, %options) = @_; - $self->SUPER::check_options(%options); + $self->SUPER::init(%options); } sub manage_selection { diff --git a/storage/netapp/restapi/mode/listluns.pm b/storage/netapp/ontap/oncommandapi/mode/listluns.pm similarity index 91% rename from storage/netapp/restapi/mode/listluns.pm rename to storage/netapp/ontap/oncommandapi/mode/listluns.pm index e32683eaa..f1573d14f 100644 --- a/storage/netapp/restapi/mode/listluns.pm +++ b/storage/netapp/ontap/oncommandapi/mode/listluns.pm @@ -18,9 +18,9 @@ # limitations under the License. # -package storage::netapp::restapi::mode::listluns; +package storage::netapp::ontap::oncommandapi::mode::listluns; -use base qw(centreon::plugins::templates::counter); +use base qw(centreon::plugins::mode); use strict; use warnings; @@ -30,17 +30,16 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - }); - + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' } + }); + return $self; } sub check_options { my ($self, %options) = @_; - $self->SUPER::check_options(%options); + $self->SUPER::init(%options); } sub manage_selection { diff --git a/storage/netapp/restapi/mode/listnodes.pm b/storage/netapp/ontap/oncommandapi/mode/listnodes.pm similarity index 91% rename from storage/netapp/restapi/mode/listnodes.pm rename to storage/netapp/ontap/oncommandapi/mode/listnodes.pm index 2582ac4d5..3aa48728b 100644 --- a/storage/netapp/restapi/mode/listnodes.pm +++ b/storage/netapp/ontap/oncommandapi/mode/listnodes.pm @@ -18,9 +18,9 @@ # limitations under the License. # -package storage::netapp::restapi::mode::listnodes; +package storage::netapp::ontap::oncommandapi::mode::listnodes; -use base qw(centreon::plugins::templates::counter); +use base qw(centreon::plugins::mode); use strict; use warnings; @@ -30,17 +30,16 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - }); + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' } + }); return $self; } sub check_options { my ($self, %options) = @_; - $self->SUPER::check_options(%options); + $self->SUPER::init(%options); } sub manage_selection { diff --git a/storage/netapp/restapi/mode/listsnapmirrors.pm b/storage/netapp/ontap/oncommandapi/mode/listsnapmirrors.pm similarity index 91% rename from storage/netapp/restapi/mode/listsnapmirrors.pm rename to storage/netapp/ontap/oncommandapi/mode/listsnapmirrors.pm index 9c7fbdabf..4daaa6ec3 100644 --- a/storage/netapp/restapi/mode/listsnapmirrors.pm +++ b/storage/netapp/ontap/oncommandapi/mode/listsnapmirrors.pm @@ -18,9 +18,9 @@ # limitations under the License. # -package storage::netapp::restapi::mode::listsnapmirrors; +package storage::netapp::ontap::oncommandapi::mode::listsnapmirrors; -use base qw(centreon::plugins::templates::counter); +use base qw(centreon::plugins::mode); use strict; use warnings; @@ -30,17 +30,16 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - }); - + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' } + }); + return $self; } sub check_options { my ($self, %options) = @_; - $self->SUPER::check_options(%options); + $self->SUPER::init(%options); } sub manage_selection { diff --git a/storage/netapp/restapi/mode/listvolumes.pm b/storage/netapp/ontap/oncommandapi/mode/listvolumes.pm similarity index 91% rename from storage/netapp/restapi/mode/listvolumes.pm rename to storage/netapp/ontap/oncommandapi/mode/listvolumes.pm index 5e691600f..9aef0f99b 100644 --- a/storage/netapp/restapi/mode/listvolumes.pm +++ b/storage/netapp/ontap/oncommandapi/mode/listvolumes.pm @@ -18,9 +18,9 @@ # limitations under the License. # -package storage::netapp::restapi::mode::listvolumes; +package storage::netapp::ontap::oncommandapi::mode::listvolumes; -use base qw(centreon::plugins::templates::counter); +use base qw(centreon::plugins::mode); use strict; use warnings; @@ -30,17 +30,16 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - }); - + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' } + }); + return $self; } sub check_options { my ($self, %options) = @_; - $self->SUPER::check_options(%options); + $self->SUPER::init(%options); } sub manage_selection { diff --git a/storage/netapp/restapi/mode/lunalignment.pm b/storage/netapp/ontap/oncommandapi/mode/lunalignment.pm similarity index 95% rename from storage/netapp/restapi/mode/lunalignment.pm rename to storage/netapp/ontap/oncommandapi/mode/lunalignment.pm index 7107e6aca..b2604736a 100644 --- a/storage/netapp/restapi/mode/lunalignment.pm +++ b/storage/netapp/ontap/oncommandapi/mode/lunalignment.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::restapi::mode::lunalignment; +package storage::netapp::ontap::oncommandapi::mode::lunalignment; use base qw(centreon::plugins::templates::counter); @@ -95,11 +95,10 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-volume:s" => { name => 'filter_volume' }, - }); - + $options{options}->add_options(arguments => { + 'filter-volume:s' => { name => 'filter_volume' } + }); + return $self; } diff --git a/storage/netapp/restapi/mode/lunonline.pm b/storage/netapp/ontap/oncommandapi/mode/lunonline.pm similarity index 94% rename from storage/netapp/restapi/mode/lunonline.pm rename to storage/netapp/ontap/oncommandapi/mode/lunonline.pm index 4081006f1..b587ebed7 100644 --- a/storage/netapp/restapi/mode/lunonline.pm +++ b/storage/netapp/ontap/oncommandapi/mode/lunonline.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::restapi::mode::lunonline; +package storage::netapp::ontap::oncommandapi::mode::lunonline; use base qw(centreon::plugins::templates::counter); @@ -77,11 +77,10 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-volume:s" => { name => 'filter_volume' }, - }); - + $options{options}->add_options(arguments => { + 'filter-volume:s' => { name => 'filter_volume' } + }); + return $self; } diff --git a/storage/netapp/restapi/mode/lunusage.pm b/storage/netapp/ontap/oncommandapi/mode/lunusage.pm similarity index 96% rename from storage/netapp/restapi/mode/lunusage.pm rename to storage/netapp/ontap/oncommandapi/mode/lunusage.pm index bb29b6b78..670374608 100644 --- a/storage/netapp/restapi/mode/lunusage.pm +++ b/storage/netapp/ontap/oncommandapi/mode/lunusage.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::restapi::mode::lunusage; +package storage::netapp::ontap::oncommandapi::mode::lunusage; use base qw(centreon::plugins::templates::counter); @@ -119,9 +119,9 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - "filter-name:s" => { name => 'filter_name' }, - "units:s" => { name => 'units', default => '%' }, - "free" => { name => 'free' }, + 'filter-name:s' => { name => 'filter_name' }, + 'units:s' => { name => 'units', default => '%' }, + 'free' => { name => 'free' } }); return $self; diff --git a/storage/netapp/restapi/mode/nodefailoverstatus.pm b/storage/netapp/ontap/oncommandapi/mode/nodefailoverstatus.pm similarity index 90% rename from storage/netapp/restapi/mode/nodefailoverstatus.pm rename to storage/netapp/ontap/oncommandapi/mode/nodefailoverstatus.pm index 284ff0f04..b29e252f9 100644 --- a/storage/netapp/restapi/mode/nodefailoverstatus.pm +++ b/storage/netapp/ontap/oncommandapi/mode/nodefailoverstatus.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::restapi::mode::nodefailoverstatus; +package storage::netapp::ontap::oncommandapi::mode::nodefailoverstatus; use base qw(centreon::plugins::templates::counter); @@ -80,14 +80,13 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - "filter-cluster:s" => { name => 'filter_cluster' }, - "warning-status:s" => { name => 'warning_status' }, - "critical-status:s" => { name => 'critical_status', default => '%{state} !~ /connected/i || %{interconnect} !~ /up/i'}, - }); - + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' }, + 'filter-cluster:s' => { name => 'filter_cluster' }, + 'warning-status:s' => { name => 'warning_status' }, + 'critical-status:s' => { name => 'critical_status', default => '%{state} !~ /connected/i || %{interconnect} !~ /up/i'} + }); + return $self; } diff --git a/storage/netapp/restapi/mode/nodehardwarestatus.pm b/storage/netapp/ontap/oncommandapi/mode/nodehardwarestatus.pm similarity index 89% rename from storage/netapp/restapi/mode/nodehardwarestatus.pm rename to storage/netapp/ontap/oncommandapi/mode/nodehardwarestatus.pm index ca92f5068..73cff9aa7 100644 --- a/storage/netapp/restapi/mode/nodehardwarestatus.pm +++ b/storage/netapp/ontap/oncommandapi/mode/nodehardwarestatus.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::restapi::mode::nodehardwarestatus; +package storage::netapp::ontap::oncommandapi::mode::nodehardwarestatus; use base qw(centreon::plugins::templates::counter); @@ -96,15 +96,14 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - "filter-cluster:s" => { name => 'filter_cluster' }, - "warning-status:s" => { name => 'warning_status' }, - "critical-status:s" => { name => 'critical_status', default => '%{status} =~ /not healthy/i || ' . - '%{temperature} !~ /ok/i || %{battery_status} !~ /battery_ok|battery_fully_charge|battery_over_charged/i' }, - }); - + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' }, + 'filter-cluster:s' => { name => 'filter_cluster' }, + 'warning-status:s' => { name => 'warning_status' }, + 'critical-status:s' => { name => 'critical_status', default => '%{status} =~ /not healthy/i || ' . + '%{temperature} !~ /ok/i || %{battery_status} !~ /battery_ok|battery_fully_charge|battery_over_charged/i' }, + }); + return $self; } diff --git a/storage/netapp/restapi/mode/qtreestatus.pm b/storage/netapp/ontap/oncommandapi/mode/qtreestatus.pm similarity index 89% rename from storage/netapp/restapi/mode/qtreestatus.pm rename to storage/netapp/ontap/oncommandapi/mode/qtreestatus.pm index 28140e10b..f74c34678 100644 --- a/storage/netapp/restapi/mode/qtreestatus.pm +++ b/storage/netapp/ontap/oncommandapi/mode/qtreestatus.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::restapi::mode::qtreestatus; +package storage::netapp::ontap::oncommandapi::mode::qtreestatus; use base qw(centreon::plugins::templates::counter); @@ -77,14 +77,13 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - "filter-volume:s" => { name => 'filter_volume' }, - "warning-status:s" => { name => 'warning_status' }, - "critical-status:s" => { name => 'critical_status' }, - }); - + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' }, + 'filter-volume:s' => { name => 'filter_volume' }, + 'warning-status:s' => { name => 'warning_status' }, + 'critical-status:s' => { name => 'critical_status' } + }); + return $self; } diff --git a/storage/netapp/restapi/mode/snapmirrorstatus.pm b/storage/netapp/ontap/oncommandapi/mode/snapmirrorstatus.pm similarity index 88% rename from storage/netapp/restapi/mode/snapmirrorstatus.pm rename to storage/netapp/ontap/oncommandapi/mode/snapmirrorstatus.pm index 11c42f7e0..e193f4ec2 100644 --- a/storage/netapp/restapi/mode/snapmirrorstatus.pm +++ b/storage/netapp/ontap/oncommandapi/mode/snapmirrorstatus.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::restapi::mode::snapmirrorstatus; +package storage::netapp::ontap::oncommandapi::mode::snapmirrorstatus; use base qw(centreon::plugins::templates::counter); @@ -72,14 +72,13 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - "warning-status:s" => { name => 'warning_status' }, - "critical-status:s" => { name => 'critical_status', default => '%{state} !~ /snapmirrored/i || %{update} =~ /not healthy/i' }, - }); - + + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' }, + 'warning-status:s' => { name => 'warning_status' }, + 'critical-status:s' => { name => 'critical_status', default => '%{state} !~ /snapmirrored/i || %{update} =~ /not healthy/i' }, + }); + return $self; } diff --git a/storage/netapp/restapi/mode/snapmirrorusage.pm b/storage/netapp/ontap/oncommandapi/mode/snapmirrorusage.pm similarity index 94% rename from storage/netapp/restapi/mode/snapmirrorusage.pm rename to storage/netapp/ontap/oncommandapi/mode/snapmirrorusage.pm index f10fd42eb..b035117fd 100644 --- a/storage/netapp/restapi/mode/snapmirrorusage.pm +++ b/storage/netapp/ontap/oncommandapi/mode/snapmirrorusage.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::restapi::mode::snapmirrorusage; +package storage::netapp::ontap::oncommandapi::mode::snapmirrorusage; use base qw(centreon::plugins::templates::counter); @@ -75,10 +75,9 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - }); + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' } + }); return $self; } diff --git a/storage/netapp/restapi/mode/volumeio.pm b/storage/netapp/ontap/oncommandapi/mode/volumeio.pm similarity index 94% rename from storage/netapp/restapi/mode/volumeio.pm rename to storage/netapp/ontap/oncommandapi/mode/volumeio.pm index bef4bd515..674020deb 100644 --- a/storage/netapp/restapi/mode/volumeio.pm +++ b/storage/netapp/ontap/oncommandapi/mode/volumeio.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::restapi::mode::volumeio; +package storage::netapp::ontap::oncommandapi::mode::volumeio; use base qw(centreon::plugins::templates::counter); @@ -110,14 +110,13 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - "filter-state:s" => { name => 'filter_state' }, - "filter-style:s" => { name => 'filter_style' }, - "filter-type:s" => { name => 'filter_type' }, - }); - + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' }, + 'filter-state:s' => { name => 'filter_state' }, + 'filter-style:s' => { name => 'filter_style' }, + 'filter-type:s' => { name => 'filter_type' } + }); + return $self; } diff --git a/storage/netapp/restapi/mode/volumestatus.pm b/storage/netapp/ontap/oncommandapi/mode/volumestatus.pm similarity index 88% rename from storage/netapp/restapi/mode/volumestatus.pm rename to storage/netapp/ontap/oncommandapi/mode/volumestatus.pm index 7d0788a35..be5fe5f38 100644 --- a/storage/netapp/restapi/mode/volumestatus.pm +++ b/storage/netapp/ontap/oncommandapi/mode/volumestatus.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::restapi::mode::volumestatus; +package storage::netapp::ontap::oncommandapi::mode::volumestatus; use base qw(centreon::plugins::templates::counter); @@ -73,12 +73,11 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - "warning-status:s" => { name => 'warning_status' }, - "critical-status:s" => { name => 'critical_status', default => '%{state} !~ /online/i' }, - }); + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' }, + 'warning-status:s' => { name => 'warning_status' }, + 'critical-status:s' => { name => 'critical_status', default => '%{state} !~ /online/i' }, + }); return $self; } diff --git a/storage/netapp/restapi/mode/volumeusage.pm b/storage/netapp/ontap/oncommandapi/mode/volumeusage.pm similarity index 98% rename from storage/netapp/restapi/mode/volumeusage.pm rename to storage/netapp/ontap/oncommandapi/mode/volumeusage.pm index a17a9053b..8b0e6a76f 100644 --- a/storage/netapp/restapi/mode/volumeusage.pm +++ b/storage/netapp/ontap/oncommandapi/mode/volumeusage.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::restapi::mode::volumeusage; +package storage::netapp::ontap::oncommandapi::mode::volumeusage; use base qw(centreon::plugins::templates::counter); @@ -371,12 +371,12 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - "filter-name:s" => { name => 'filter_name' }, - "filter-state:s" => { name => 'filter_state' }, - "filter-style:s" => { name => 'filter_style' }, - "filter-type:s" => { name => 'filter_type' }, - "units:s" => { name => 'units', default => '%' }, - "free" => { name => 'free' }, + 'filter-name:s' => { name => 'filter_name' }, + 'filter-state:s' => { name => 'filter_state' }, + 'filter-style:s' => { name => 'filter_style' }, + 'filter-type:s' => { name => 'filter_type' }, + 'units:s' => { name => 'units', default => '%' }, + 'free' => { name => 'free' } }); return $self; diff --git a/storage/netapp/ontap/oncommandapi/plugin.pm b/storage/netapp/ontap/oncommandapi/plugin.pm new file mode 100644 index 000000000..4ad4c4235 --- /dev/null +++ b/storage/netapp/ontap/oncommandapi/plugin.pm @@ -0,0 +1,75 @@ +# +# Copyright 2020 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 storage::netapp::ontap::oncommandapi::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}} = ( + 'aggregate-raid-status' => 'storage::netapp::ontap::oncommandapi::mode::aggregateraidstatus', + 'aggregate-status' => 'storage::netapp::ontap::oncommandapi::mode::aggregatestatus', + 'aggregate-usage' => 'storage::netapp::ontap::oncommandapi::mode::aggregateusage', + 'cluster-io' => 'storage::netapp::ontap::oncommandapi::mode::clusterio', + 'cluster-status' => 'storage::netapp::ontap::oncommandapi::mode::clusterstatus', + 'cluster-usage' => 'storage::netapp::ontap::oncommandapi::mode::clusterusage', + 'disk-failed' => 'storage::netapp::ontap::oncommandapi::mode::diskfailed', + 'disk-spare' => 'storage::netapp::ontap::oncommandapi::mode::diskspare', + 'fc-port-status' => 'storage::netapp::ontap::oncommandapi::mode::fcportstatus', + 'list-aggregates' => 'storage::netapp::ontap::oncommandapi::mode::listaggregates', + 'list-clusters' => 'storage::netapp::ontap::oncommandapi::mode::listclusters', + 'list-fc-ports' => 'storage::netapp::ontap::oncommandapi::mode::listfcports', + 'list-luns' => 'storage::netapp::ontap::oncommandapi::mode::listluns', + 'list-nodes' => 'storage::netapp::ontap::oncommandapi::mode::listnodes', + 'list-snapmirrors' => 'storage::netapp::ontap::oncommandapi::mode::listsnapmirrors', + 'list-volumes' => 'storage::netapp::ontap::oncommandapi::mode::listvolumes', + 'lun-alignment' => 'storage::netapp::ontap::oncommandapi::mode::lunalignment', + 'lun-online' => 'storage::netapp::ontap::oncommandapi::mode::lunonline', + 'lun-usage' => 'storage::netapp::ontap::oncommandapi::mode::lunusage', + 'node-failover-status' => 'storage::netapp::ontap::oncommandapi::mode::nodefailoverstatus', + 'node-hardware-status' => 'storage::netapp::ontap::oncommandapi::mode::nodehardwarestatus', + 'qtree-status' => 'storage::netapp::ontap::oncommandapi::mode::qtreestatus', + 'snapmirror-status' => 'storage::netapp::ontap::oncommandapi::mode::snapmirrorstatus', + 'snapmirror-usage' => 'storage::netapp::ontap::oncommandapi::mode::snapmirrorusage', + 'volume-io' => 'storage::netapp::ontap::oncommandapi::mode::volumeio', + 'volume-status' => 'storage::netapp::ontap::oncommandapi::mode::volumestatus', + 'volume-usage' => 'storage::netapp::ontap::oncommandapi::mode::volumeusage' + ); + + $self->{custom_modes}{api} = 'storage::netapp::ontap::oncommandapi::custom::api'; + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check NetApp ONTAP with OnCommand API. + +=cut diff --git a/storage/netapp/snmp/mode/aggregatestate.pm b/storage/netapp/ontap/snmp/mode/aggregatestate.pm similarity index 97% rename from storage/netapp/snmp/mode/aggregatestate.pm rename to storage/netapp/ontap/snmp/mode/aggregatestate.pm index a87b0d1bf..823eeab8e 100644 --- a/storage/netapp/snmp/mode/aggregatestate.pm +++ b/storage/netapp/ontap/snmp/mode/aggregatestate.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::snmp::mode::aggregatestate; +package storage::netapp::ontap::snmp::mode::aggregatestate; use base qw(centreon::plugins::templates::counter); @@ -92,8 +92,8 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - "filter-name:s" => { name => 'filter_name' }, - "threshold-overload:s@" => { name => 'threshold_overload' }, + 'filter-name:s' => { name => 'filter_name' }, + 'threshold-overload:s@' => { name => 'threshold_overload' }, }); return $self; diff --git a/storage/netapp/snmp/mode/cacheage.pm b/storage/netapp/ontap/snmp/mode/cacheage.pm similarity index 90% rename from storage/netapp/snmp/mode/cacheage.pm rename to storage/netapp/ontap/snmp/mode/cacheage.pm index 42a635250..4179acdfd 100644 --- a/storage/netapp/snmp/mode/cacheage.pm +++ b/storage/netapp/ontap/snmp/mode/cacheage.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::snmp::mode::cacheage; +package storage::netapp::ontap::snmp::mode::cacheage; use base qw(centreon::plugins::mode); @@ -30,11 +30,11 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - "warning:s" => { name => 'warning' }, - "critical:s" => { name => 'critical' }, - }); + $options{options}->add_options(arguments => { + 'warning:s' => { name => 'warning' }, + 'critical:s' => { name => 'critical' } + }); + return $self; } diff --git a/storage/netapp/snmp/mode/components/communication.pm b/storage/netapp/ontap/snmp/mode/components/communication.pm similarity index 97% rename from storage/netapp/snmp/mode/components/communication.pm rename to storage/netapp/ontap/snmp/mode/components/communication.pm index af300bd00..7ade3583c 100644 --- a/storage/netapp/snmp/mode/components/communication.pm +++ b/storage/netapp/ontap/snmp/mode/components/communication.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::snmp::mode::components::communication; +package storage::netapp::ontap::snmp::mode::components::communication; use base qw(centreon::plugins::mode); diff --git a/storage/netapp/snmp/mode/components/electronics.pm b/storage/netapp/ontap/snmp/mode/components/electronics.pm similarity index 97% rename from storage/netapp/snmp/mode/components/electronics.pm rename to storage/netapp/ontap/snmp/mode/components/electronics.pm index baa71f596..26a46f461 100644 --- a/storage/netapp/snmp/mode/components/electronics.pm +++ b/storage/netapp/ontap/snmp/mode/components/electronics.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::snmp::mode::components::electronics; +package storage::netapp::ontap::snmp::mode::components::electronics; use base qw(centreon::plugins::mode); diff --git a/storage/netapp/snmp/mode/components/fan.pm b/storage/netapp/ontap/snmp/mode/components/fan.pm similarity index 98% rename from storage/netapp/snmp/mode/components/fan.pm rename to storage/netapp/ontap/snmp/mode/components/fan.pm index adaad1e0e..0bbb27e8d 100644 --- a/storage/netapp/snmp/mode/components/fan.pm +++ b/storage/netapp/ontap/snmp/mode/components/fan.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::snmp::mode::components::fan; +package storage::netapp::ontap::snmp::mode::components::fan; use base qw(centreon::plugins::mode); diff --git a/storage/netapp/snmp/mode/components/psu.pm b/storage/netapp/ontap/snmp/mode/components/psu.pm similarity index 97% rename from storage/netapp/snmp/mode/components/psu.pm rename to storage/netapp/ontap/snmp/mode/components/psu.pm index 976d6128d..af0e15c2c 100644 --- a/storage/netapp/snmp/mode/components/psu.pm +++ b/storage/netapp/ontap/snmp/mode/components/psu.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::snmp::mode::components::psu; +package storage::netapp::ontap::snmp::mode::components::psu; use base qw(centreon::plugins::mode); diff --git a/storage/netapp/snmp/mode/components/raid.pm b/storage/netapp/ontap/snmp/mode/components/raid.pm similarity index 97% rename from storage/netapp/snmp/mode/components/raid.pm rename to storage/netapp/ontap/snmp/mode/components/raid.pm index b45687a41..81f6d444d 100644 --- a/storage/netapp/snmp/mode/components/raid.pm +++ b/storage/netapp/ontap/snmp/mode/components/raid.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::snmp::mode::components::raid; +package storage::netapp::ontap::snmp::mode::components::raid; use base qw(centreon::plugins::mode); diff --git a/storage/netapp/snmp/mode/components/temperature.pm b/storage/netapp/ontap/snmp/mode/components/temperature.pm similarity index 98% rename from storage/netapp/snmp/mode/components/temperature.pm rename to storage/netapp/ontap/snmp/mode/components/temperature.pm index a65fe4520..07ab84fed 100644 --- a/storage/netapp/snmp/mode/components/temperature.pm +++ b/storage/netapp/ontap/snmp/mode/components/temperature.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::snmp::mode::components::temperature; +package storage::netapp::ontap::snmp::mode::components::temperature; use strict; use warnings; diff --git a/storage/netapp/snmp/mode/components/voltage.pm b/storage/netapp/ontap/snmp/mode/components/voltage.pm similarity index 99% rename from storage/netapp/snmp/mode/components/voltage.pm rename to storage/netapp/ontap/snmp/mode/components/voltage.pm index 44cb565d0..7c005ef84 100644 --- a/storage/netapp/snmp/mode/components/voltage.pm +++ b/storage/netapp/ontap/snmp/mode/components/voltage.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::snmp::mode::components::voltage; +package storage::netapp::ontap::snmp::mode::components::voltage; use strict; use warnings; diff --git a/storage/netapp/snmp/mode/cpstatistics.pm b/storage/netapp/ontap/snmp/mode/cpstatistics.pm similarity index 99% rename from storage/netapp/snmp/mode/cpstatistics.pm rename to storage/netapp/ontap/snmp/mode/cpstatistics.pm index ee376e7c6..bf5d06254 100644 --- a/storage/netapp/snmp/mode/cpstatistics.pm +++ b/storage/netapp/ontap/snmp/mode/cpstatistics.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::snmp::mode::cpstatistics; +package storage::netapp::ontap::snmp::mode::cpstatistics; use base qw(centreon::plugins::templates::counter); diff --git a/storage/netapp/snmp/mode/cpuload.pm b/storage/netapp/ontap/snmp/mode/cpuload.pm similarity index 89% rename from storage/netapp/snmp/mode/cpuload.pm rename to storage/netapp/ontap/snmp/mode/cpuload.pm index 3e72d960f..3618e3f55 100644 --- a/storage/netapp/snmp/mode/cpuload.pm +++ b/storage/netapp/ontap/snmp/mode/cpuload.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::snmp::mode::cpuload; +package storage::netapp::ontap::snmp::mode::cpuload; use base qw(centreon::plugins::mode); @@ -30,11 +30,10 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - "warning:s" => { name => 'warning' }, - "critical:s" => { name => 'critical' }, - }); + $options{options}->add_options(arguments => { + 'warning:s' => { name => 'warning' }, + 'critical:s' => { name => 'critical' } + }); return $self; } @@ -94,4 +93,4 @@ Threshold critical in percent. =back =cut - \ No newline at end of file + diff --git a/storage/netapp/snmp/mode/diskfailed.pm b/storage/netapp/ontap/snmp/mode/diskfailed.pm similarity index 93% rename from storage/netapp/snmp/mode/diskfailed.pm rename to storage/netapp/ontap/snmp/mode/diskfailed.pm index 7bc508245..9d598479d 100644 --- a/storage/netapp/snmp/mode/diskfailed.pm +++ b/storage/netapp/ontap/snmp/mode/diskfailed.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::snmp::mode::diskfailed; +package storage::netapp::ontap::snmp::mode::diskfailed; use base qw(centreon::plugins::mode); @@ -29,10 +29,9 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - - $options{options}->add_options(arguments => - { - }); + + $options{options}->add_options(arguments => { + }); return $self; } @@ -81,4 +80,4 @@ If you are in cluster mode, the following mode doesn't work. Ask to netapp to ad =back =cut - \ No newline at end of file + diff --git a/storage/netapp/snmp/mode/failover.pm b/storage/netapp/ontap/snmp/mode/failover.pm similarity index 99% rename from storage/netapp/snmp/mode/failover.pm rename to storage/netapp/ontap/snmp/mode/failover.pm index af106abf5..cfb350a99 100644 --- a/storage/netapp/snmp/mode/failover.pm +++ b/storage/netapp/ontap/snmp/mode/failover.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::snmp::mode::failover; +package storage::netapp::ontap::snmp::mode::failover; use base qw(centreon::plugins::templates::counter); diff --git a/storage/netapp/snmp/mode/fan.pm b/storage/netapp/ontap/snmp/mode/fan.pm similarity index 96% rename from storage/netapp/snmp/mode/fan.pm rename to storage/netapp/ontap/snmp/mode/fan.pm index 4da8e0931..911d155b2 100644 --- a/storage/netapp/snmp/mode/fan.pm +++ b/storage/netapp/ontap/snmp/mode/fan.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::snmp::mode::fan; +package storage::netapp::ontap::snmp::mode::fan; use base qw(centreon::plugins::mode); @@ -29,10 +29,9 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - - $options{options}->add_options(arguments => - { - }); + + $options{options}->add_options(arguments => { + }); return $self; } @@ -104,4 +103,4 @@ Check if fans are failed (not operating within the recommended RPM range). =back =cut - \ No newline at end of file + diff --git a/storage/netapp/snmp/mode/filesys.pm b/storage/netapp/ontap/snmp/mode/filesys.pm similarity index 97% rename from storage/netapp/snmp/mode/filesys.pm rename to storage/netapp/ontap/snmp/mode/filesys.pm index ec864f19d..b197795b9 100644 --- a/storage/netapp/snmp/mode/filesys.pm +++ b/storage/netapp/ontap/snmp/mode/filesys.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::snmp::mode::filesys; +package storage::netapp::ontap::snmp::mode::filesys; use base qw(centreon::plugins::templates::counter); @@ -186,12 +186,12 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - 'units:s' => { name => 'units', default => '%' }, - 'free' => { name => 'free' }, - 'filter-name:s' => { name => 'filter_name' }, - 'filter-type:s' => { name => 'filter_type' }, - 'filter-vserver:s' => { name => 'filter_vserver' }, - 'filter-vserver-state:s' => { name => 'filter_vserver_state' }, + 'units:s' => { name => 'units', default => '%' }, + 'free' => { name => 'free' }, + 'filter-name:s' => { name => 'filter_name' }, + 'filter-type:s' => { name => 'filter_type' }, + 'filter-vserver:s' => { name => 'filter_vserver' }, + 'filter-vserver-state:s' => { name => 'filter_vserver_state' }, 'unknown-vserver-status:s' => { name => 'unknown_vserver_status', default => '' }, 'warning-vserver-status:s' => { name => 'warning_vserver_status', default => '' }, 'critical-vserver-status:s' => { name => 'critical_vserver_status', default => '' }, diff --git a/storage/netapp/snmp/mode/globalstatus.pm b/storage/netapp/ontap/snmp/mode/globalstatus.pm similarity index 99% rename from storage/netapp/snmp/mode/globalstatus.pm rename to storage/netapp/ontap/snmp/mode/globalstatus.pm index 476f1a798..7aead567f 100644 --- a/storage/netapp/snmp/mode/globalstatus.pm +++ b/storage/netapp/ontap/snmp/mode/globalstatus.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::snmp::mode::globalstatus; +package storage::netapp::ontap::snmp::mode::globalstatus; use base qw(centreon::plugins::templates::counter); diff --git a/storage/netapp/snmp/mode/listfilesys.pm b/storage/netapp/ontap/snmp/mode/listfilesys.pm similarity index 95% rename from storage/netapp/snmp/mode/listfilesys.pm rename to storage/netapp/ontap/snmp/mode/listfilesys.pm index 606864535..3885646a9 100644 --- a/storage/netapp/snmp/mode/listfilesys.pm +++ b/storage/netapp/ontap/snmp/mode/listfilesys.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::snmp::mode::listfilesys; +package storage::netapp::ontap::snmp::mode::listfilesys; use base qw(centreon::plugins::mode); @@ -31,9 +31,9 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - 'filter-name:s' => { name => 'filter_name' }, - 'filter-type:s' => { name => 'filter_type' }, - 'skip-total-zero' => { name => 'skip_total_zero' }, + 'filter-name:s' => { name => 'filter_name' }, + 'filter-type:s' => { name => 'filter_type' }, + 'skip-total-zero' => { name => 'skip_total_zero' } }); return $self; diff --git a/storage/netapp/snmp/mode/listsnapvault.pm b/storage/netapp/ontap/snmp/mode/listsnapvault.pm similarity index 98% rename from storage/netapp/snmp/mode/listsnapvault.pm rename to storage/netapp/ontap/snmp/mode/listsnapvault.pm index 56b89f058..8c2ce7957 100644 --- a/storage/netapp/snmp/mode/listsnapvault.pm +++ b/storage/netapp/ontap/snmp/mode/listsnapvault.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::snmp::mode::listsnapvault; +package storage::netapp::ontap::snmp::mode::listsnapvault; use base qw(centreon::plugins::mode); diff --git a/storage/netapp/snmp/mode/ndmpsessions.pm b/storage/netapp/ontap/snmp/mode/ndmpsessions.pm similarity index 89% rename from storage/netapp/snmp/mode/ndmpsessions.pm rename to storage/netapp/ontap/snmp/mode/ndmpsessions.pm index 5876197c8..a84a75a2e 100644 --- a/storage/netapp/snmp/mode/ndmpsessions.pm +++ b/storage/netapp/ontap/snmp/mode/ndmpsessions.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::snmp::mode::ndmpsessions; +package storage::netapp::ontap::snmp::mode::ndmpsessions; use base qw(centreon::plugins::mode); @@ -30,11 +30,10 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - "warning:s" => { name => 'warning' }, - "critical:s" => { name => 'critical' }, - }); + $options{options}->add_options(arguments => { + 'warning:s' => { name => 'warning' }, + 'critical:s' => { name => 'critical' } + }); return $self; } @@ -94,4 +93,4 @@ Threshold critical. =back =cut - \ No newline at end of file + diff --git a/storage/netapp/snmp/mode/nvram.pm b/storage/netapp/ontap/snmp/mode/nvram.pm similarity index 95% rename from storage/netapp/snmp/mode/nvram.pm rename to storage/netapp/ontap/snmp/mode/nvram.pm index 1251c00f9..822b8198d 100644 --- a/storage/netapp/snmp/mode/nvram.pm +++ b/storage/netapp/ontap/snmp/mode/nvram.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::snmp::mode::nvram; +package storage::netapp::ontap::snmp::mode::nvram; use base qw(centreon::plugins::mode); @@ -56,10 +56,9 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - "threshold-overload:s@" => { name => 'threshold_overload' }, - }); + $options{options}->add_options(arguments => { + 'threshold-overload:s@' => { name => 'threshold_overload' }, + }); return $self; } @@ -172,4 +171,4 @@ Example: --threshold-overload='nvram,CRITICAL,^(?!(ok)$)' =back =cut - \ No newline at end of file + diff --git a/storage/netapp/snmp/mode/partnerstatus.pm b/storage/netapp/ontap/snmp/mode/partnerstatus.pm similarity index 96% rename from storage/netapp/snmp/mode/partnerstatus.pm rename to storage/netapp/ontap/snmp/mode/partnerstatus.pm index 04e8a4f01..f9fda6ba0 100644 --- a/storage/netapp/snmp/mode/partnerstatus.pm +++ b/storage/netapp/ontap/snmp/mode/partnerstatus.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::snmp::mode::partnerstatus; +package storage::netapp::ontap::snmp::mode::partnerstatus; use base qw(centreon::plugins::mode); @@ -55,10 +55,9 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - "threshold-overload:s@" => { name => 'threshold_overload' }, - }); + $options{options}->add_options(arguments => { + 'threshold-overload:s@' => { name => 'threshold_overload' }, + }); return $self; } @@ -196,4 +195,4 @@ Example: --threshold-overload='partner,CRITICAL,^(?!(ok)$)' =back =cut - \ No newline at end of file + diff --git a/storage/netapp/snmp/mode/psu.pm b/storage/netapp/ontap/snmp/mode/psu.pm similarity index 82% rename from storage/netapp/snmp/mode/psu.pm rename to storage/netapp/ontap/snmp/mode/psu.pm index 9b922ce07..afc08db3a 100644 --- a/storage/netapp/snmp/mode/psu.pm +++ b/storage/netapp/ontap/snmp/mode/psu.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::snmp::mode::psu; +package storage::netapp::ontap::snmp::mode::psu; use base qw(centreon::plugins::mode); @@ -30,9 +30,8 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - }); + $options{options}->add_options(arguments => { + }); return $self; } @@ -51,13 +50,16 @@ sub run { my $oid_nodeName = '.1.3.6.1.4.1.789.1.25.2.1.1'; my $oid_nodeEnvFailedPowerSupplyCount = '.1.3.6.1.4.1.789.1.25.2.1.21'; my $oid_nodeEnvFailedPowerSupplyMessage = '.1.3.6.1.4.1.789.1.25.2.1.22'; - my $results = $self->{snmp}->get_multiple_table(oids => [ - { oid => $oid_envFailedPowerSupplyCount }, - { oid => $oid_envFailedPowerSupplyMessage }, - { oid => $oid_nodeName }, - { oid => $oid_nodeEnvFailedPowerSupplyCount }, - { oid => $oid_nodeEnvFailedPowerSupplyMessage } - ], nothing_quit => 1); + my $results = $self->{snmp}->get_multiple_table( + oids => [ + { oid => $oid_envFailedPowerSupplyCount }, + { oid => $oid_envFailedPowerSupplyMessage }, + { oid => $oid_nodeName }, + { oid => $oid_nodeEnvFailedPowerSupplyCount }, + { oid => $oid_nodeEnvFailedPowerSupplyMessage } + ], + nothing_quit => 1 + ); if (defined($results->{$oid_envFailedPowerSupplyCount}->{$oid_envFailedPowerSupplyCount . '.0'})) { $self->{output}->output_add(severity => 'OK', @@ -104,4 +106,4 @@ Check if power supplies are failed (in degraded mode). =back =cut - \ No newline at end of file + diff --git a/storage/netapp/snmp/mode/qtreeusage.pm b/storage/netapp/ontap/snmp/mode/qtreeusage.pm similarity index 95% rename from storage/netapp/snmp/mode/qtreeusage.pm rename to storage/netapp/ontap/snmp/mode/qtreeusage.pm index 921dc4784..9271687a4 100644 --- a/storage/netapp/snmp/mode/qtreeusage.pm +++ b/storage/netapp/ontap/snmp/mode/qtreeusage.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::snmp::mode::qtreeusage; +package storage::netapp::ontap::snmp::mode::qtreeusage; use base qw(centreon::plugins::templates::counter); @@ -136,12 +136,12 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - "units:s" => { name => 'units', default => '%' }, - "free" => { name => 'free' }, - "filter-vserver:s" => { name => 'filter_vserver' }, - "filter-volume:s" => { name => 'filter_volume' }, - "filter-qtree:s" => { name => 'filter_qtree' }, - "not-kbytes" => { name => 'not_kbytes' }, + 'units:s' => { name => 'units', default => '%' }, + 'free' => { name => 'free' }, + 'filter-vserver:s' => { name => 'filter_vserver' }, + 'filter-volume:s' => { name => 'filter_volume' }, + 'filter-qtree:s' => { name => 'filter_qtree' }, + 'not-kbytes' => { name => 'not_kbytes' }, }); return $self; diff --git a/storage/netapp/snmp/mode/sharecalls.pm b/storage/netapp/ontap/snmp/mode/sharecalls.pm similarity index 98% rename from storage/netapp/snmp/mode/sharecalls.pm rename to storage/netapp/ontap/snmp/mode/sharecalls.pm index 582e18395..f524fdfe6 100644 --- a/storage/netapp/snmp/mode/sharecalls.pm +++ b/storage/netapp/ontap/snmp/mode/sharecalls.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::snmp::mode::sharecalls; +package storage::netapp::ontap::snmp::mode::sharecalls; use base qw(centreon::plugins::templates::counter); diff --git a/storage/netapp/snmp/mode/shelf.pm b/storage/netapp/ontap/snmp/mode/shelf.pm similarity index 95% rename from storage/netapp/snmp/mode/shelf.pm rename to storage/netapp/ontap/snmp/mode/shelf.pm index 298eb8f31..86b80fa1b 100644 --- a/storage/netapp/snmp/mode/shelf.pm +++ b/storage/netapp/ontap/snmp/mode/shelf.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::snmp::mode::shelf; +package storage::netapp::ontap::snmp::mode::shelf; use base qw(centreon::plugins::templates::hardware); @@ -79,7 +79,7 @@ sub set_system { ], }; - $self->{components_path} = 'storage::netapp::snmp::mode::components'; + $self->{components_path} = 'storage::netapp::ontap::snmp::mode::components'; $self->{components_module} = ['communication', 'psu', 'fan', 'temperature', 'voltage', 'electronics', 'raid']; } @@ -100,9 +100,8 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - }); + $options{options}->add_options(arguments => { + }); return $self; } @@ -162,4 +161,4 @@ Example: --critical='temperature,.*,25' --warning='temperature,.*,35' =back =cut - \ No newline at end of file + diff --git a/storage/netapp/snmp/mode/sis.pm b/storage/netapp/ontap/snmp/mode/sis.pm similarity index 99% rename from storage/netapp/snmp/mode/sis.pm rename to storage/netapp/ontap/snmp/mode/sis.pm index 46e12663d..5b8ecd318 100644 --- a/storage/netapp/snmp/mode/sis.pm +++ b/storage/netapp/ontap/snmp/mode/sis.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::snmp::mode::sis; +package storage::netapp::ontap::snmp::mode::sis; use base qw(centreon::plugins::templates::counter); diff --git a/storage/netapp/snmp/mode/snapmirrorlag.pm b/storage/netapp/ontap/snmp/mode/snapmirrorlag.pm similarity index 99% rename from storage/netapp/snmp/mode/snapmirrorlag.pm rename to storage/netapp/ontap/snmp/mode/snapmirrorlag.pm index 3f5eb2087..da872b363 100644 --- a/storage/netapp/snmp/mode/snapmirrorlag.pm +++ b/storage/netapp/ontap/snmp/mode/snapmirrorlag.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::snmp::mode::snapmirrorlag; +package storage::netapp::ontap::snmp::mode::snapmirrorlag; use base qw(centreon::plugins::templates::counter); diff --git a/storage/netapp/snmp/mode/snapshotage.pm b/storage/netapp/ontap/snmp/mode/snapshotage.pm similarity index 93% rename from storage/netapp/snmp/mode/snapshotage.pm rename to storage/netapp/ontap/snmp/mode/snapshotage.pm index cc147816a..c0c30e266 100644 --- a/storage/netapp/snmp/mode/snapshotage.pm +++ b/storage/netapp/ontap/snmp/mode/snapshotage.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::snmp::mode::snapshotage; +package storage::netapp::ontap::snmp::mode::snapshotage; use base qw(centreon::plugins::mode); @@ -38,15 +38,14 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - "name:s" => { name => 'name' }, - "regexp" => { name => 'use_regexp' }, - "warning:s" => { name => 'warning' }, - "critical:s" => { name => 'critical' }, - }); - $self->{snapshot_id_selected} = []; + $options{options}->add_options(arguments => { + 'name:s' => { name => 'name' }, + 'regexp' => { name => 'use_regexp' }, + 'warning:s' => { name => 'warning' }, + 'critical:s' => { name => 'critical' }, + }); + $self->{snapshot_id_selected} = []; return $self; } diff --git a/storage/netapp/snmp/mode/snapvaultusage.pm b/storage/netapp/ontap/snmp/mode/snapvaultusage.pm similarity index 96% rename from storage/netapp/snmp/mode/snapvaultusage.pm rename to storage/netapp/ontap/snmp/mode/snapvaultusage.pm index 24ac978e7..e39bc7c0c 100644 --- a/storage/netapp/snmp/mode/snapvaultusage.pm +++ b/storage/netapp/ontap/snmp/mode/snapvaultusage.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::snmp::mode::snapvaultusage; +package storage::netapp::ontap::snmp::mode::snapvaultusage; use base qw(centreon::plugins::templates::counter); @@ -111,10 +111,10 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - "filter-name:s" => { name => 'filter_name' }, - "unknown-status:s" => { name => 'unknown_status', default => '' }, - "warning-status:s" => { name => 'warning_status', default => '' }, - "critical-status:s" => { name => 'critical_status', default => '' }, + 'filter-name:s' => { name => 'filter_name' }, + 'unknown-status:s' => { name => 'unknown_status', default => '' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '' }, }); return $self; diff --git a/storage/netapp/snmp/mode/temperature.pm b/storage/netapp/ontap/snmp/mode/temperature.pm similarity index 84% rename from storage/netapp/snmp/mode/temperature.pm rename to storage/netapp/ontap/snmp/mode/temperature.pm index 18100d5b5..75c4fbdad 100644 --- a/storage/netapp/snmp/mode/temperature.pm +++ b/storage/netapp/ontap/snmp/mode/temperature.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::snmp::mode::temperature; +package storage::netapp::ontap::snmp::mode::temperature; use base qw(centreon::plugins::mode); @@ -34,10 +34,9 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - - $options{options}->add_options(arguments => - { - }); + + $options{options}->add_options(arguments => { + }); return $self; } @@ -54,11 +53,14 @@ sub run { my $oid_envOverTemperature = '.1.3.6.1.4.1.789.1.2.4.1'; my $oid_nodeName = '.1.3.6.1.4.1.789.1.25.2.1.1'; my $oid_nodeEnvOverTemperature = '.1.3.6.1.4.1.789.1.25.2.1.18'; - my $results = $self->{snmp}->get_multiple_table(oids => [ - { oid => $oid_envOverTemperature }, - { oid => $oid_nodeName }, - { oid => $oid_nodeEnvOverTemperature }, - ], nothing_quit => 1); + my $results = $self->{snmp}->get_multiple_table( + oids => [ + { oid => $oid_envOverTemperature }, + { oid => $oid_nodeName }, + { oid => $oid_nodeEnvOverTemperature }, + ], + nothing_quit => 1 + ); if (defined($results->{$oid_envOverTemperature}->{$oid_envOverTemperature . '.0'})) { $self->{output}->output_add(severity => 'OK', @@ -101,4 +103,4 @@ Check if hardware is currently operating outside of its recommended temperature =back =cut - \ No newline at end of file + diff --git a/storage/netapp/snmp/mode/volumeoptions.pm b/storage/netapp/ontap/snmp/mode/volumeoptions.pm similarity index 92% rename from storage/netapp/snmp/mode/volumeoptions.pm rename to storage/netapp/ontap/snmp/mode/volumeoptions.pm index 07f308682..5bef56586 100644 --- a/storage/netapp/snmp/mode/volumeoptions.pm +++ b/storage/netapp/ontap/snmp/mode/volumeoptions.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package storage::netapp::snmp::mode::volumeoptions; +package storage::netapp::ontap::snmp::mode::volumeoptions; use base qw(centreon::plugins::templates::counter); @@ -28,7 +28,7 @@ use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold) sub custom_options_threshold { my ($self, %options) = @_; - + my $status = catalog_status_threshold($self, %options); if (!$self->{output}->is_status(value => $status, compare => 'ok', litteral => 1)) { $self->{instance_mode}->{global}->{failed}++; @@ -105,14 +105,14 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - "filter-name:s" => { name => 'filter_name' }, - "filter-status:s" => { name => 'filter_status' }, - "unknown-status:s" => { name => 'unknown_status', default => '' }, - "warning-status:s" => { name => 'warning_status', default => '' }, - "critical-status:s" => { name => 'critical_status', default => '' }, - "unknown-options:s" => { name => 'unknown_options', default => '' }, - "warning-options:s" => { name => 'warning_options', default => '' }, - "critical-options:s" => { name => 'critical_options', default => '' }, + 'filter-name:s' => { name => 'filter_name' }, + 'filter-status:s' => { name => 'filter_status' }, + 'unknown-status:s' => { name => 'unknown_status', default => '' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '' }, + 'unknown-options:s' => { name => 'unknown_options', default => '' }, + 'warning-options:s' => { name => 'warning_options', default => '' }, + 'critical-options:s' => { name => 'critical_options', default => '' }, }); return $self; diff --git a/storage/netapp/ontap/snmp/plugin.pm b/storage/netapp/ontap/snmp/plugin.pm new file mode 100644 index 000000000..8eabd7c9e --- /dev/null +++ b/storage/netapp/ontap/snmp/plugin.pm @@ -0,0 +1,72 @@ +# +# Copyright 2020 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 storage::netapp::ontap::snmp::plugin; + +use strict; +use warnings; +use base qw(centreon::plugins::script_snmp); + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.0'; + %{$self->{modes}} = ( + 'aggregatestate' => 'storage::netapp::ontap::snmp::mode::aggregatestate', + 'cache-age' => 'storage::netapp::ontap::snmp::mode::cacheage', + 'cp-statistics' => 'storage::netapp::ontap::snmp::mode::cpstatistics', + 'cpuload' => 'storage::netapp::ontap::snmp::mode::cpuload', + 'diskfailed' => 'storage::netapp::ontap::snmp::mode::diskfailed', + 'failover' => 'storage::netapp::ontap::snmp::mode::failover', + 'fan' => 'storage::netapp::ontap::snmp::mode::fan', + 'filesys' => 'storage::netapp::ontap::snmp::mode::filesys', + 'list-filesys' => 'storage::netapp::ontap::snmp::mode::listfilesys', + 'list-snapvault' => 'storage::netapp::ontap::snmp::mode::listsnapvault', + 'global-status' => 'storage::netapp::ontap::snmp::mode::globalstatus', + 'ndmpsessions' => 'storage::netapp::ontap::snmp::mode::ndmpsessions', + 'nvram' => 'storage::netapp::ontap::snmp::mode::nvram', + 'partnerstatus' => 'storage::netapp::ontap::snmp::mode::partnerstatus', + 'psu' => 'storage::netapp::ontap::snmp::mode::psu', + 'qtree-usage' => 'storage::netapp::ontap::snmp::mode::qtreeusage', + 'share-calls' => 'storage::netapp::ontap::snmp::mode::sharecalls', + 'shelf' => 'storage::netapp::ontap::snmp::mode::shelf', + 'sis' => 'storage::netapp::ontap::snmp::mode::sis', + 'snapmirrorlag' => 'storage::netapp::ontap::snmp::mode::snapmirrorlag', + 'snapshotage' => 'storage::netapp::ontap::snmp::mode::snapshotage', + 'snapvault-usage' => 'storage::netapp::ontap::snmp::mode::snapvaultusage', + 'temperature' => 'storage::netapp::ontap::snmp::mode::temperature', + 'uptime' => 'snmp_standard::mode::uptime', + 'volumeoptions' => 'storage::netapp::ontap::snmp::mode::volumeoptions' + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Netapp ONTAP in SNMP. + +=cut diff --git a/storage/netapp/restapi/plugin.pm b/storage/netapp/restapi/plugin.pm deleted file mode 100644 index 64709c915..000000000 --- a/storage/netapp/restapi/plugin.pm +++ /dev/null @@ -1,75 +0,0 @@ -# -# Copyright 2020 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 storage::netapp::restapi::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}} = ( - 'aggregate-raid-status' => 'storage::netapp::restapi::mode::aggregateraidstatus', - 'aggregate-status' => 'storage::netapp::restapi::mode::aggregatestatus', - 'aggregate-usage' => 'storage::netapp::restapi::mode::aggregateusage', - 'cluster-io' => 'storage::netapp::restapi::mode::clusterio', - 'cluster-status' => 'storage::netapp::restapi::mode::clusterstatus', - 'cluster-usage' => 'storage::netapp::restapi::mode::clusterusage', - 'disk-failed' => 'storage::netapp::restapi::mode::diskfailed', - 'disk-spare' => 'storage::netapp::restapi::mode::diskspare', - 'fc-port-status' => 'storage::netapp::restapi::mode::fcportstatus', - 'list-aggregates' => 'storage::netapp::restapi::mode::listaggregates', - 'list-clusters' => 'storage::netapp::restapi::mode::listclusters', - 'list-fc-ports' => 'storage::netapp::restapi::mode::listfcports', - 'list-luns' => 'storage::netapp::restapi::mode::listluns', - 'list-nodes' => 'storage::netapp::restapi::mode::listnodes', - 'list-snapmirrors' => 'storage::netapp::restapi::mode::listsnapmirrors', - 'list-volumes' => 'storage::netapp::restapi::mode::listvolumes', - 'lun-alignment' => 'storage::netapp::restapi::mode::lunalignment', - 'lun-online' => 'storage::netapp::restapi::mode::lunonline', - 'lun-usage' => 'storage::netapp::restapi::mode::lunusage', - 'node-failover-status' => 'storage::netapp::restapi::mode::nodefailoverstatus', - 'node-hardware-status' => 'storage::netapp::restapi::mode::nodehardwarestatus', - 'qtree-status' => 'storage::netapp::restapi::mode::qtreestatus', - 'snapmirror-status' => 'storage::netapp::restapi::mode::snapmirrorstatus', - 'snapmirror-usage' => 'storage::netapp::restapi::mode::snapmirrorusage', - 'volume-io' => 'storage::netapp::restapi::mode::volumeio', - 'volume-status' => 'storage::netapp::restapi::mode::volumestatus', - 'volume-usage' => 'storage::netapp::restapi::mode::volumeusage', - ); - - $self->{custom_modes}{api} = 'storage::netapp::restapi::custom::restapi'; - return $self; -} - -1; - -__END__ - -=head1 PLUGIN DESCRIPTION - -Check NetApp with OnCommand API. - -=cut diff --git a/storage/netapp/snmp/plugin.pm b/storage/netapp/snmp/plugin.pm deleted file mode 100644 index 134b9e3c0..000000000 --- a/storage/netapp/snmp/plugin.pm +++ /dev/null @@ -1,72 +0,0 @@ -# -# Copyright 2020 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 storage::netapp::snmp::plugin; - -use strict; -use warnings; -use base qw(centreon::plugins::script_snmp); - -sub new { - my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); - bless $self, $class; - - $self->{version} = '1.0'; - %{$self->{modes}} = ( - 'aggregatestate' => 'storage::netapp::snmp::mode::aggregatestate', - 'cache-age' => 'storage::netapp::snmp::mode::cacheage', - 'cp-statistics' => 'storage::netapp::snmp::mode::cpstatistics', - 'cpuload' => 'storage::netapp::snmp::mode::cpuload', - 'diskfailed' => 'storage::netapp::snmp::mode::diskfailed', - 'failover' => 'storage::netapp::snmp::mode::failover', - 'fan' => 'storage::netapp::snmp::mode::fan', - 'filesys' => 'storage::netapp::snmp::mode::filesys', - 'list-filesys' => 'storage::netapp::snmp::mode::listfilesys', - 'list-snapvault' => 'storage::netapp::snmp::mode::listsnapvault', - 'global-status' => 'storage::netapp::snmp::mode::globalstatus', - 'ndmpsessions' => 'storage::netapp::snmp::mode::ndmpsessions', - 'nvram' => 'storage::netapp::snmp::mode::nvram', - 'partnerstatus' => 'storage::netapp::snmp::mode::partnerstatus', - 'psu' => 'storage::netapp::snmp::mode::psu', - 'qtree-usage' => 'storage::netapp::snmp::mode::qtreeusage', - 'share-calls' => 'storage::netapp::snmp::mode::sharecalls', - 'shelf' => 'storage::netapp::snmp::mode::shelf', - 'sis' => 'storage::netapp::snmp::mode::sis', - 'snapmirrorlag' => 'storage::netapp::snmp::mode::snapmirrorlag', - 'snapshotage' => 'storage::netapp::snmp::mode::snapshotage', - 'snapvault-usage' => 'storage::netapp::snmp::mode::snapvaultusage', - 'temperature' => 'storage::netapp::snmp::mode::temperature', - 'uptime' => 'snmp_standard::mode::uptime', - 'volumeoptions' => 'storage::netapp::snmp::mode::volumeoptions', - ); - - return $self; -} - -1; - -__END__ - -=head1 PLUGIN DESCRIPTION - -Check Netapp in SNMP (Some Check needs ONTAP 8.x). - -=cut From 13a16f437b39f4b1c8765c561efe22a33e36430b Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 5 May 2020 16:05:35 +0200 Subject: [PATCH 183/283] fix eltek battery calc --- hardware/devices/eltek/enexus/snmp/mode/battery.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hardware/devices/eltek/enexus/snmp/mode/battery.pm b/hardware/devices/eltek/enexus/snmp/mode/battery.pm index 48c23c398..c0582dea4 100644 --- a/hardware/devices/eltek/enexus/snmp/mode/battery.pm +++ b/hardware/devices/eltek/enexus/snmp/mode/battery.pm @@ -257,7 +257,7 @@ sub manage_selection { if ($result->{powerSystemCapacityScale} eq 'ah' && defined($current)) { $self->{battery}->{charge_remaining_time} = - int($result->{batteryRemainingCapacityValue} * 3600 / $current * $scale_current); + int(($result->{batteryRemainingCapacityValue} * 3600) / ($current * $scale_current)); } $self->threshold_eltek_configured( From b524cfe7fdc70d6e5a9a00af2c05b5aa6e08accf Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 5 May 2020 17:25:32 +0200 Subject: [PATCH 184/283] change eltek power calc --- .../devices/eltek/enexus/snmp/mode/load.pm | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/hardware/devices/eltek/enexus/snmp/mode/load.pm b/hardware/devices/eltek/enexus/snmp/mode/load.pm index 5c80df04e..2c55a4048 100644 --- a/hardware/devices/eltek/enexus/snmp/mode/load.pm +++ b/hardware/devices/eltek/enexus/snmp/mode/load.pm @@ -25,12 +25,12 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); -use Digest::MD5 qw(md5_hex); sub custom_status_output { my ($self, %options) = @_; - return sprintf('status: %s', + return sprintf( + 'status: %s', $self->{result_values}->{status} ); } @@ -60,11 +60,11 @@ sub set_counters { ] } }, - { label => 'energy-delivered', nlabel => 'load.energy.delivered.watt', display_ok => 0, set => { - key_values => [ { name => 'energy', diff => 1 } ], - output_template => 'accumulated energy delivered: %s W', + { label => 'power', nlabel => 'load.power.watt', display_ok => 0, set => { + key_values => [ { name => 'power' } ], + output_template => 'power: %s W', perfdatas => [ - { value => 'energy_absolute', template => '%s', unit => 'W', min => 0 } + { value => 'power_absolute', template => '%s', unit => 'W', min => 0 } ] } } @@ -96,7 +96,7 @@ sub prefix_phase_output { sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1, force_new_perfdata => 1); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); bless $self, $class; $options{options}->add_options(arguments => { @@ -135,6 +135,7 @@ my $mapping = { loadCurrentMajorHighLevel => { oid => '.1.3.6.1.4.1.12148.10.9.2.6' }, loadCurrentMinorHighLevel => { oid => '.1.3.6.1.4.1.12148.10.9.2.7' }, loadEnergyLogAccumulated => { oid => '.1.3.6.1.4.1.12148.10.9.8.1' }, # Watt + batteryVoltageValue => { oid => '.1.3.6.1.4.1.12148.10.10.5.5' } # not sure we should use that value }; sub threshold_eltek_configured { @@ -165,7 +166,7 @@ sub manage_selection { $scale_current = 0.1 if ($result->{powerSystemCurrentDecimalSetting} eq 'deciAmpere'); $self->{load} = { status => $result->{loadStatus}, - energy => $result->{loadEnergyLogAccumulated}, + power => $result->{loadCurrentValue} * $scale_current * ($result->{batteryVoltageValue} * 0.01), current => $result->{loadCurrentValue} * $scale_current }; @@ -182,9 +183,6 @@ sub manage_selection { /\.(\d+)$/; $self->{phase}->{$1} = { display => $1, voltage => $snmp_result->{$_} * 0.01 }; } - - $self->{cache_name} = 'eltek_enexus_' . $self->{mode} . '_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . - (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); } 1; @@ -215,7 +213,7 @@ Can used special variables like: %{status} =item B<--warning-*> B<--critical-*> Thresholds. -Can be: 'current', 'energy-delivered'. +Can be: 'current', 'power'. =back From 258233ae72c3bcfaa542135c4421123da0fd1fa2 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 5 May 2020 17:55:09 +0200 Subject: [PATCH 185/283] enhance cisco meraki --- network/cisco/meraki/cloudcontroller/restapi/custom/api.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/network/cisco/meraki/cloudcontroller/restapi/custom/api.pm b/network/cisco/meraki/cloudcontroller/restapi/custom/api.pm index c70f0b2df..86243d21c 100644 --- a/network/cisco/meraki/cloudcontroller/restapi/custom/api.pm +++ b/network/cisco/meraki/cloudcontroller/restapi/custom/api.pm @@ -180,7 +180,7 @@ sub request_api { my $content; eval { - $content = JSON::XS->new->utf8->decode($response); + $content = JSON::XS->new->allow_nonref(1)->utf8->decode($response); }; if ($@) { $self->{output}->add_option_msg(short_msg => "Cannot decode json response: $@"); From 50a2e0928c3f489cc8bc1b9148f3676b98308902 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 6 May 2020 15:19:24 +0200 Subject: [PATCH 186/283] wip: netapp santricity --- .../netapp/santricity/restapi/custom/api.pm | 263 ++++++++++++++++++ .../restapi/mode/components/battery.pm | 67 +++++ .../restapi/mode/components/board.pm | 67 +++++ .../santricity/restapi/mode/components/cbd.pm | 67 +++++ .../santricity/restapi/mode/components/cmd.pm | 67 +++++ .../restapi/mode/components/ctrl.pm | 67 +++++ .../restapi/mode/components/drive.pm | 101 +++++++ .../santricity/restapi/mode/components/fan.pm | 67 +++++ .../santricity/restapi/mode/components/psu.pm | 67 +++++ .../restapi/mode/components/storage.pm | 58 ++++ .../restapi/mode/components/thsensor.pm | 67 +++++ .../santricity/restapi/mode/hardware.pm | 194 +++++++++++++ storage/netapp/santricity/restapi/plugin.pm | 49 ++++ 13 files changed, 1201 insertions(+) create mode 100644 storage/netapp/santricity/restapi/custom/api.pm create mode 100644 storage/netapp/santricity/restapi/mode/components/battery.pm create mode 100644 storage/netapp/santricity/restapi/mode/components/board.pm create mode 100644 storage/netapp/santricity/restapi/mode/components/cbd.pm create mode 100644 storage/netapp/santricity/restapi/mode/components/cmd.pm create mode 100644 storage/netapp/santricity/restapi/mode/components/ctrl.pm create mode 100644 storage/netapp/santricity/restapi/mode/components/drive.pm create mode 100644 storage/netapp/santricity/restapi/mode/components/fan.pm create mode 100644 storage/netapp/santricity/restapi/mode/components/psu.pm create mode 100644 storage/netapp/santricity/restapi/mode/components/storage.pm create mode 100644 storage/netapp/santricity/restapi/mode/components/thsensor.pm create mode 100644 storage/netapp/santricity/restapi/mode/hardware.pm create mode 100644 storage/netapp/santricity/restapi/plugin.pm diff --git a/storage/netapp/santricity/restapi/custom/api.pm b/storage/netapp/santricity/restapi/custom/api.pm new file mode 100644 index 000000000..ac5f26aa5 --- /dev/null +++ b/storage/netapp/santricity/restapi/custom/api.pm @@ -0,0 +1,263 @@ +# +# Copyright 2020 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 storage::netapp::santricity::restapi::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 => { + 'api-username:s' => { name => 'api_username' }, + 'api-password:s' => { name => 'api_password' }, + 'hostname:s' => { name => 'hostname' }, + 'port:s' => { name => 'port' }, + 'proto:s' => { name => 'proto' }, + 'timeout:s' => { name => 'timeout' }, + 'api-path:s' => { name => 'api_path' }, + 'unknown-http-status:s' => { name => 'unknown_http_status' }, + 'warning-http-status:s' => { name => 'warning_http_status' }, + 'critical-http-status:s' => { name => 'critical_http_status' } + }); + } + $options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1); + + $self->{output} = $options{output}; + $self->{mode} = $options{mode}; + $self->{http} = centreon::plugins::http->new(%options); + + return $self; +} + +sub set_options { + my ($self, %options) = @_; + + $self->{option_results} = $options{option_results}; +} + +sub set_defaults { + my ($self, %options) = @_; + + 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} = (defined($self->{option_results}->{hostname})) ? $self->{option_results}->{hostname} : ''; + $self->{port} = (defined($self->{option_results}->{port})) ? $self->{option_results}->{port} : 8080; + $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->{api_username} = (defined($self->{option_results}->{api_username})) ? $self->{option_results}->{api_username} : ''; + $self->{api_password} = (defined($self->{option_results}->{api_password})) ? $self->{option_results}->{api_password} : ''; + $self->{api_path} = (defined($self->{option_results}->{api_path})) ? $self->{option_results}->{api_path} : '/devmgr/v2'; + $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(); + } + if (!defined($self->{api_username}) || $self->{api_username} eq '') { + $self->{output}->add_option_msg(short_msg => "Need to specify --api-username option."); + $self->{output}->option_exit(); + } + if (!defined($self->{api_password}) || $self->{api_password} eq '') { + $self->{output}->add_option_msg(short_msg => "Need to specify --api-password 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}; + $self->{option_results}->{credentials} = 1; + $self->{option_results}->{basic} = 1; + $self->{option_results}->{username} = $self->{api_username}; + $self->{option_results}->{password} = $self->{api_password}; +} + +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 request_api { + my ($self, %options) = @_; + + $self->settings(); + my $content = $self->{http}->request( + method => defined($options{method}) ? $options{method} : 'GET', + url_path => $self->{api_path} . '/' . $options{endpoint}, + unknown_status => $self->{unknown_http_status}, + warning_status => $self->{warning_http_status}, + critical_status => $self->{critical_http_status}, + cookies_file => '' # in memory + ); + + # code 424 = storageDevice offline + my $code = $self->{http}->get_code(); + if (!defined($content) || $content 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(); + } + + return undef if ($code == 424); + + my $decoded; + eval { + $decoded = JSON::XS->new->utf8->decode($content); + }; + if ($@) { + $self->{output}->add_option_msg(short_msg => "Cannot decode response (add --debug option to display returned content)"); + $self->{output}->option_exit(); + } + + return { $options{name} => $decoded }; +} + +sub execute_storages_request { + my ($self, %options) = @_; + + my $content = do { + local $/ = undef; + if (!open my $fh, "<", '/home/qgarnier/clients/plugins/todo/santricity/test-inventory.txt') { + $self->{output}->add_option_msg(short_msg => "Could not open file $self->{option_results}->{$_} : $!"); + $self->{output}->option_exit(); + } + <$fh>; + }; + eval { + $content = JSON::XS->new->utf8->decode($content); + }; + return $content; + + my $storages = $self->request_api(name => 'storages', endpoint => '/storage-systems'); + for (my $i = 0; $i < scalar(@{$storages->{storages}}); $i++) { + next if (defined($options{filter_name}) && $options{filter_name} ne '' && + $storages->{storages}->{$i}->{name} !~ /$options{filter_name}/); + + my $info = $self->request_api(name => 'info', endpoint => '/' . $storages->{storages}->{$i}->{wwn} . '/' . $options{endpoint}); + $storages->{storages}->{$i}->{offline} = 0; + $storages->{storages}->{$i}->{offline} = 1 if (!defined($info)); + + $storages->{storages}->{$i}->{ $options{endpoint} } = defined($info) ? $info->{info} : undef; + } + + return $storages; +} + + + +1; + +__END__ + +=head1 NAME + +Netapp Santricity Rest API + +=head1 REST API OPTIONS + +Netapp Santricity Rest API + +=over 8 + +=item B<--hostname> + +Santricity hostname. + +=item B<--port> + +Port used (Default: 8080) + +=item B<--proto> + +Specify https if needed (Default: 'http') + +=item B<--api-username> + +Santricity API username. + +=item B<--api-password> + +Santricity API password. + +=item B<--api-path> + +Specify api path (Default: '/devmgr/v2') + +=item B<--timeout> + +Set timeout in seconds (Default: 10). + +=back + +=head1 DESCRIPTION + +B. + +=cut diff --git a/storage/netapp/santricity/restapi/mode/components/battery.pm b/storage/netapp/santricity/restapi/mode/components/battery.pm new file mode 100644 index 000000000..0809ce812 --- /dev/null +++ b/storage/netapp/santricity/restapi/mode/components/battery.pm @@ -0,0 +1,67 @@ +# +# Copyright 2020 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 storage::netapp::santricity::restapi::mode::components::battery; + +use strict; +use warnings; + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => 'checking batteries'); + $self->{components}->{battery} = { name => 'batteries', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'battery')); + + return if (!defined($self->{json_results}->{storages})); + + foreach (@{$self->{json_results}->{storages}}) { + my $storage_name = $_->{name}; + + next if ($self->check_filter(section => 'storage', instance => $_->{chassisSerialNumber})); + + next if (!defined($_->{'/hardware-inventory'}->{batteries})); + + foreach my $entry (@{$_->{'/hardware-inventory'}->{batteries}}) { + my $instance = $entry->{batteryRef}; + my $name = $storage_name . ':' . $entry->{physicalLocation}->{locationPosition} . ':' . $entry->{physicalLocation}->{slot}; + + next if ($self->check_filter(section => 'battery', instance => $instance)); + $self->{components}->{battery}->{total}++; + + $self->{output}->output_add( + long_msg => sprintf( + "battery '%s' status is '%s' [instance = %s]", + $name, $entry->{status}, $instance + ) + ); + + my $exit = $self->get_severity(section => 'battery', instance => $instance, value => $entry->{status}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf("Battery '%s' status is '%s'", $name, $entry->{status}) + ); + } + } + } +} + +1; diff --git a/storage/netapp/santricity/restapi/mode/components/board.pm b/storage/netapp/santricity/restapi/mode/components/board.pm new file mode 100644 index 000000000..99fc7f7a8 --- /dev/null +++ b/storage/netapp/santricity/restapi/mode/components/board.pm @@ -0,0 +1,67 @@ +# +# Copyright 2020 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 storage::netapp::santricity::restapi::mode::components::board; + +use strict; +use warnings; + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => 'checking boards'); + $self->{components}->{board} = { name => 'boards', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'board')); + + return if (!defined($self->{json_results}->{storages})); + + foreach (@{$self->{json_results}->{storages}}) { + my $storage_name = $_->{name}; + + next if ($self->check_filter(section => 'storage', instance => $_->{chassisSerialNumber})); + + next if (!defined($_->{'/hardware-inventory'}->{hostBoards})); + + foreach my $entry (@{$_->{'/hardware-inventory'}->{hostBoards}}) { + my $instance = $entry->{hostBoardRef}; + my $name = $storage_name . ':' . $entry->{physicalLocation}->{locationPosition} . ':' . $entry->{physicalLocation}->{slot}; + + next if ($self->check_filter(section => 'board', instance => $instance)); + $self->{components}->{board}->{total}++; + + $self->{output}->output_add( + long_msg => sprintf( + "board '%s' status is '%s' [instance = %s]", + $name, $entry->{status}, $instance + ) + ); + + my $exit = $self->get_severity(section => 'board', instance => $instance, value => $entry->{status}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf("Board '%s' status is '%s'", $name, $entry->{status}) + ); + } + } + } +} + +1; diff --git a/storage/netapp/santricity/restapi/mode/components/cbd.pm b/storage/netapp/santricity/restapi/mode/components/cbd.pm new file mode 100644 index 000000000..299e036b6 --- /dev/null +++ b/storage/netapp/santricity/restapi/mode/components/cbd.pm @@ -0,0 +1,67 @@ +# +# Copyright 2020 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 storage::netapp::santricity::restapi::mode::components::cbd; + +use strict; +use warnings; + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => 'checking cache backup devices'); + $self->{components}->{cbd} = { name => 'cbd', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'cbd')); + + return if (!defined($self->{json_results}->{storages})); + + foreach (@{$self->{json_results}->{storages}}) { + my $storage_name = $_->{name}; + + next if ($self->check_filter(section => 'storage', instance => $_->{chassisSerialNumber})); + + next if (!defined($_->{'/hardware-inventory'}->{cacheBackupDevices})); + + foreach my $entry (@{$_->{'/hardware-inventory'}->{cacheBackupDevices}}) { + my $instance = $entry->{backupDeviceRef}; + my $name = $storage_name . ':' . $entry->{physicalLocation}->{locationPosition} . ':' . $entry->{physicalLocation}->{slot}; + + next if ($self->check_filter(section => 'cbd', instance => $instance)); + $self->{components}->{cbd}->{total}++; + + $self->{output}->output_add( + long_msg => sprintf( + "cache backup device '%s' status is '%s' [instance = %s]", + $name, $entry->{backupDeviceStatus}, $instance + ) + ); + + my $exit = $self->get_severity(section => 'cbd', instance => $instance, value => $entry->{backupDeviceStatus}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf("Cache backup device '%s' status is '%s'", $name, $entry->{backupDeviceStatus}) + ); + } + } + } +} + +1; diff --git a/storage/netapp/santricity/restapi/mode/components/cmd.pm b/storage/netapp/santricity/restapi/mode/components/cmd.pm new file mode 100644 index 000000000..7be23cb11 --- /dev/null +++ b/storage/netapp/santricity/restapi/mode/components/cmd.pm @@ -0,0 +1,67 @@ +# +# Copyright 2020 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 storage::netapp::santricity::restapi::mode::components::cmd; + +use strict; +use warnings; + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => 'checking cache memory dimms'); + $self->{components}->{cmd} = { name => 'cmd', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'cmd')); + + return if (!defined($self->{json_results}->{storages})); + + foreach (@{$self->{json_results}->{storages}}) { + my $storage_name = $_->{name}; + + next if ($self->check_filter(section => 'storage', instance => $_->{chassisSerialNumber})); + + next if (!defined($_->{'/hardware-inventory'}->{cacheMemoryDimms})); + + foreach my $entry (@{$_->{'/hardware-inventory'}->{cacheMemoryDimms}}) { + my $instance = $entry->{cacheMemoryDimmRef}; + my $name = $storage_name . ':' . $entry->{physicalLocation}->{locationPosition} . ':' . $entry->{physicalLocation}->{slot}; + + next if ($self->check_filter(section => 'cmd', instance => $instance)); + $self->{components}->{cbd}->{total}++; + + $self->{output}->output_add( + long_msg => sprintf( + "cache memory dimm '%s' status is '%s' [instance = %s]", + $name, $entry->{status}, $instance + ) + ); + + my $exit = $self->get_severity(section => 'cmd', instance => $instance, value => $entry->{status}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf("Cache memory dimm '%s' status is '%s'", $name, $entry->{status}) + ); + } + } + } +} + +1; diff --git a/storage/netapp/santricity/restapi/mode/components/ctrl.pm b/storage/netapp/santricity/restapi/mode/components/ctrl.pm new file mode 100644 index 000000000..25a2c7ab8 --- /dev/null +++ b/storage/netapp/santricity/restapi/mode/components/ctrl.pm @@ -0,0 +1,67 @@ +# +# Copyright 2020 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 storage::netapp::santricity::restapi::mode::components::ctrl; + +use strict; +use warnings; + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => 'checking controllers'); + $self->{components}->{ctrl} = { name => 'ctrl', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'ctrl')); + + return if (!defined($self->{json_results}->{storages})); + + foreach (@{$self->{json_results}->{storages}}) { + my $storage_name = $_->{name}; + + next if ($self->check_filter(section => 'storage', instance => $_->{chassisSerialNumber})); + + next if (!defined($_->{'/hardware-inventory'}->{controllers})); + + foreach my $entry (@{$_->{'/hardware-inventory'}->{controllers}}) { + my $instance = $entry->{controllerRef}; + my $name = $storage_name . ':' . $entry->{physicalLocation}->{locationPosition} . ':' . $entry->{physicalLocation}->{slot}; + + next if ($self->check_filter(section => 'ctrl', instance => $instance)); + $self->{components}->{ctrl}->{total}++; + + $self->{output}->output_add( + long_msg => sprintf( + "controller '%s' status is '%s' [instance = %s]", + $name, $entry->{status}, $instance + ) + ); + + my $exit = $self->get_severity(section => 'ctrl', instance => $instance, value => $entry->{status}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf("Controller '%s' status is '%s'", $name, $entry->{status}) + ); + } + } + } +} + +1; diff --git a/storage/netapp/santricity/restapi/mode/components/drive.pm b/storage/netapp/santricity/restapi/mode/components/drive.pm new file mode 100644 index 000000000..a0ad52ccf --- /dev/null +++ b/storage/netapp/santricity/restapi/mode/components/drive.pm @@ -0,0 +1,101 @@ +# +# Copyright 2020 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 storage::netapp::santricity::restapi::mode::components::drive; + +use strict; +use warnings; + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => 'checking drives'); + $self->{components}->{drive} = { name => 'drive', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'drive')); + + return if (!defined($self->{json_results}->{storages})); + + foreach (@{$self->{json_results}->{storages}}) { + my $storage_name = $_->{name}; + + next if ($self->check_filter(section => 'storage', instance => $_->{chassisSerialNumber})); + + next if (!defined($_->{'/hardware-inventory'}->{drives})); + + foreach my $entry (@{$_->{'/hardware-inventory'}->{drives}}) { + my $instance = $entry->{driveRef}; + my $name = $storage_name . ':' . $entry->{physicalLocation}->{locationPosition} . ':' . $entry->{physicalLocation}->{slot}; + + next if ($self->check_filter(section => 'drive', instance => $instance)); + $self->{components}->{drive}->{total}++; + + $self->{output}->output_add( + long_msg => sprintf( + "drive '%s' status is '%s' [instance = %s] [temperature: %s]", + $name, $entry->{status}, $instance, $entry->{driveTemperature}->{currentTemp} + ) + ); + + my $exit = $self->get_severity(section => 'drive', instance => $instance, value => $entry->{status}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf("Drive '%s' status is '%s'", $name, $entry->{status}) + ); + } + + my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'drive.temperature', instance => $instance, value => $entry->{driveTemperature}->{currentTemp}); + if ($checked == 0) { + my $warn_th = ''; + my $crit_th = defined($entry->{driveTemperature}->{refTemp}) ? $entry->{driveTemperature}->{refTemp} : ''; + $self->{perfdata}->threshold_validate(label => 'warning-drive.temperature-instance-' . $instance, value => $warn_th); + $self->{perfdata}->threshold_validate(label => 'critical-drive.temperature-instance-' . $instance, value => $crit_th); + + $exit = $self->{perfdata}->threshold_check( + value => $entry->{driveTemperature}->{currentTemp}, + threshold => [ + { label => 'critical-drive.temperature-instance-' . $instance, exit_litteral => 'critical' }, + { label => 'warning-drive.temperature-instance-' . $instance, exit_litteral => 'warning' } + ] + ); + $warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-drive.temperature-instance-' . $instance); + $crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-drive.temperature-instance-' . $instance) + } + + if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit2, + short_msg => sprintf("drive '%s' temperature is %s C", $name, $entry->{driveTemperature}->{currentTemp}) + ); + } + + $self->{output}->perfdata_add( + nlabel => 'hardware.drive.temperature.celsius', + unit => 'C', + instances => $name, + value => $entry->{driveTemperature}->{currentTemp}, + warning => $warn, + critical => $crit + ); + } + } +} + +1; diff --git a/storage/netapp/santricity/restapi/mode/components/fan.pm b/storage/netapp/santricity/restapi/mode/components/fan.pm new file mode 100644 index 000000000..d96ec6f6b --- /dev/null +++ b/storage/netapp/santricity/restapi/mode/components/fan.pm @@ -0,0 +1,67 @@ +# +# Copyright 2020 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 storage::netapp::santricity::restapi::mode::components::fan; + +use strict; +use warnings; + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => 'checking fans'); + $self->{components}->{fan} = { name => 'fans', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'fan')); + + return if (!defined($self->{json_results}->{storages})); + + foreach (@{$self->{json_results}->{storages}}) { + my $storage_name = $_->{name}; + + next if ($self->check_filter(section => 'storage', instance => $_->{chassisSerialNumber})); + + next if (!defined($_->{'/hardware-inventory'}->{fans})); + + foreach my $entry (@{$_->{'/hardware-inventory'}->{fans}}) { + my $instance = $entry->{fanRef}; + my $name = $storage_name . ':' . $entry->{physicalLocation}->{locationPosition} . ':' . $entry->{physicalLocation}->{slot}; + + next if ($self->check_filter(section => 'fan', instance => $instance)); + $self->{components}->{fan}->{total}++; + + $self->{output}->output_add( + long_msg => sprintf( + "fan '%s' status is '%s' [instance = %s]", + $name, $entry->{status}, $instance + ) + ); + + my $exit = $self->get_severity(section => 'fan', instance => $instance, value => $entry->{status}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf("Fan '%s' status is '%s'", $name, $entry->{status}) + ); + } + } + } +} + +1; diff --git a/storage/netapp/santricity/restapi/mode/components/psu.pm b/storage/netapp/santricity/restapi/mode/components/psu.pm new file mode 100644 index 000000000..9178a4e52 --- /dev/null +++ b/storage/netapp/santricity/restapi/mode/components/psu.pm @@ -0,0 +1,67 @@ +# +# Copyright 2020 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 storage::netapp::santricity::restapi::mode::components::psu; + +use strict; +use warnings; + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => 'checking power supplies'); + $self->{components}->{psu} = { name => 'psu', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'psu')); + + return if (!defined($self->{json_results}->{storages})); + + foreach (@{$self->{json_results}->{storages}}) { + my $storage_name = $_->{name}; + + next if ($self->check_filter(section => 'storage', instance => $_->{chassisSerialNumber})); + + next if (!defined($_->{'/hardware-inventory'}->{powerSupplies})); + + foreach my $entry (@{$_->{'/hardware-inventory'}->{powerSupplies}}) { + my $instance = $entry->{powerSupplyRef}; + my $name = $storage_name . ':' . $entry->{physicalLocation}->{locationPosition} . ':' . $entry->{physicalLocation}->{slot}; + + next if ($self->check_filter(section => 'psu', instance => $instance)); + $self->{components}->{psu}->{total}++; + + $self->{output}->output_add( + long_msg => sprintf( + "power supply '%s' status is '%s' [instance = %s]", + $name, $entry->{status}, $instance, + ) + ); + + my $exit = $self->get_severity(section => 'psu', instance => $instance, value => $entry->{status}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf("Power supply '%s' status is '%s'", $name, $entry->{status}) + ); + } + } + } +} + +1; diff --git a/storage/netapp/santricity/restapi/mode/components/storage.pm b/storage/netapp/santricity/restapi/mode/components/storage.pm new file mode 100644 index 000000000..0f4332dc9 --- /dev/null +++ b/storage/netapp/santricity/restapi/mode/components/storage.pm @@ -0,0 +1,58 @@ +# +# Copyright 2020 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 storage::netapp::santricity::restapi::mode::components::storage; + +use strict; +use warnings; + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => 'checking storages'); + $self->{components}->{storage} = { name => 'storages', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'storage')); + + return if (!defined($self->{json_results}->{storages})); + + foreach (@{$self->{json_results}->{storages}}) { + my $instance = $_->{chassisSerialNumber}; + + next if ($self->check_filter(section => 'storage', instance => $instance)); + $self->{components}->{storage}->{total}++; + + $self->{output}->output_add( + long_msg => sprintf( + "storage '%s' status is '%s' [instance = %s]", + $_->{name}, $_->{status}, $instance, + ) + ); + + my $exit = $self->get_severity(section => 'storage', instance => $instance, value => $_->{status}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf("Storage '%s' status is '%s'", $_{name}, $_->{status}) + ); + } + } +} + +1; diff --git a/storage/netapp/santricity/restapi/mode/components/thsensor.pm b/storage/netapp/santricity/restapi/mode/components/thsensor.pm new file mode 100644 index 000000000..d97a07882 --- /dev/null +++ b/storage/netapp/santricity/restapi/mode/components/thsensor.pm @@ -0,0 +1,67 @@ +# +# Copyright 2020 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 storage::netapp::santricity::restapi::mode::components::thsensor; + +use strict; +use warnings; + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => 'checking thermal sensors'); + $self->{components}->{thsensor} = { name => 'thsensor', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'thsensor')); + + return if (!defined($self->{json_results}->{storages})); + + foreach (@{$self->{json_results}->{storages}}) { + my $storage_name = $_->{name}; + + next if ($self->check_filter(section => 'storage', instance => $_->{chassisSerialNumber})); + + next if (!defined($_->{'/hardware-inventory'}->{thermalSensors})); + + foreach my $entry (@{$_->{'/hardware-inventory'}->{thermalSensors}}) { + my $instance = $entry->{thermalSensorRef}; + my $name = $storage_name . ($entry->{physicalLocation}->{label} ne '' ? ':' . $entry->{physicalLocation}->{label} : '') . ':' . $entry->{physicalLocation}->{locationPosition} . ':' . $entry->{physicalLocation}->{slot}; + + next if ($self->check_filter(section => 'thsensor', instance => $instance)); + $self->{components}->{thsensor}->{total}++; + + $self->{output}->output_add( + long_msg => sprintf( + "thermal sensor '%s' status is '%s' [instance = %s]", + $name, $entry->{status}, $instance, + ) + ); + + my $exit = $self->get_severity(section => 'thsensor', instance => $instance, value => $entry->{status}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf("Thermal sensor '%s' status is '%s'", $name, $entry->{status}) + ); + } + } + } +} + +1; diff --git a/storage/netapp/santricity/restapi/mode/hardware.pm b/storage/netapp/santricity/restapi/mode/hardware.pm new file mode 100644 index 000000000..fd025d731 --- /dev/null +++ b/storage/netapp/santricity/restapi/mode/hardware.pm @@ -0,0 +1,194 @@ +# +# Copyright 2020 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 storage::netapp::santricity::restapi::mode::hardware; + +use base qw(centreon::plugins::templates::hardware); + +use strict; +use warnings; + +sub set_system { + my ($self, %options) = @_; + + $self->{regexp_threshold_overload_check_section_option} = + '^(?:storage|battery|cbd|cmd|boards|psu|fan|thsensor|ctrl|drive)$'; + $self->{regexp_threshold_numeric_check_section_option} = '^(?:drive.temperature)$'; + + $self->{cb_hook2} = 'execute_custom'; + + $self->{thresholds} = { + battery => [ + ['optimal', 'OK'], + ['fullCharging', 'OK'], + ['nearExpiration', 'WARNING'], + ['failed', 'CRITICAL'], + ['removed', 'OK'], + ['unknown', 'UNKNOWN'], + ['notInConfig', 'WARNING'], + ['configMismatch', 'WARNING'], + ['learning', 'OK'], + ['overtemp', ''], + ['expired', 'WARNING'], + ['maintenanceCharging', 'OK'], + ['replacementRequired', 'CRTICICAL'] + ], + board => [ + ['unknown', 'UNKNOWN'], + ['optimal', 'OK'], + ['needsAttention', 'WARNING'], + ['notPresent', 'OK'], + ['degraded', 'WARNING'], + ['failed', 'CRITICAL'], + ['diagInProgress', 'OK'] + ], + cbd => [ + ['unknown', 'UNKNOWN'], + ['optimal', 'OK'], + ['failed', 'CRITICAL'], + ['removed', 'OK'], + ['writeProtected', 'OK'], + ['incompatible', 'CRITICAL'] + ], + cmd => [ + ['unknown', 'UNKNOWN'], + ['optimal', 'OK'], + ['failed', 'CRITICAL'], + ['empty', 'OK'] + ], + ctrl => [ + ['unknown', 'UNKNOWN'], + ['optimal', 'OK'], + ['failed', 'CRITICAL'], + ['removed', 'OK'], + ['rpaParErr', 'WAARNING'], + ['serviceMode', 'OK'], + ['suspended', 'OK'], + ['degraded', 'WARNING'] + ], + drive => [ + ['optimal', 'OK'], + ['failed', 'CRITICAL'], + ['replaced', 'OK'], + ['bypassed', 'OK'], + ['unresponsive', 'WARNING'], + ['removed', 'OK'], + ['incompatible', 'WARNING'], + ['dataRelocation', 'OK'], + ['preFailCopy', 'WARNING'], + ['preFailCopyPending', 'WARNING'] + ], + fan => [ + ['optimal', 'OK'], + ['removed', 'OK'], + ['failed', 'CRITICAL'], + ['unknown', 'UNKNOWN'] + ], + psu => [ + ['optimal', 'OK'], + ['removed', 'OK'], + ['failed', 'CRITICAL'], + ['unknown', 'UNKNOWN'], + ['noinput', 'WARNING'] + ], + storage => [ + ['neverContacted', 'UNKNOWN'], + ['offline', 'OK'], + ['optimal', 'OK'], + ['needsAttn', 'WARNING'], + ['newDevice', 'OK'], + ['lockDown', 'WARNING'] + ], + thsensor => [ + ['optimal', 'OK'], + ['nominalTempExceed', 'WARNING'], + ['maxTempExceed', 'CRITICAL'], + ['unknown', 'UNKNOWN'], + ['removed', 'OK'] + ] + }; + + $self->{components_exec_load} = 0; + + $self->{components_path} = 'storage::netapp::santricity::restapi::mode::components'; + $self->{components_module} = [ + 'storage', 'ctrl', 'battery', 'board', 'cbd', 'cmd', 'drive', 'psu', 'fan', + 'thsensor' + ]; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1, force_new_perfdata => 1); + bless $self, $class; + + $options{options}->add_options(arguments => {}); + + return $self; +} + +sub execute_custom { + my ($self, %options) = @_; + + $self->{json_results} = $options{custom}->execute_storages_request(endpoint => '/hardware-inventory'); +} + +1; + +=head1 MODE + +Check hardware. + +=over 8 + +=item B<--component> + +Which component to check (Default: '.*'). +Can be: 'storage', 'ctrl', 'battery', 'board', 'cbd', 'cmd', 'drive', 'psu', 'fan', 'thsensor'. + +=item B<--filter> + +Exclude some parts (comma seperated list) +Can also exclude specific instance: --filter='drive,010000005000C500C244251B0000000000000000' + +=item B<--no-component> + +Return an error if no compenents are checked. +If total (with skipped) is 0. (Default: 'critical' returns). + +=item B<--threshold-overload> + +Set to overload default threshold values (syntax: section,[instance,]status,regexp) +It used before default thresholds (order stays). +Example: --threshold-overload='drive,OK,preFailCopy' + +=item B<--warning> + +Set warning threshold for 'temperature' (syntax: type,regexp,threshold) +Example: --warning='drive.temperature,.*,40' + +=item B<--critical> + +Set critical threshold for 'drive.temperature' (syntax: type,regexp,threshold) +Example: --critical='drive.temperature,.*,50' + +=back + +=cut diff --git a/storage/netapp/santricity/restapi/plugin.pm b/storage/netapp/santricity/restapi/plugin.pm new file mode 100644 index 000000000..d201c68c0 --- /dev/null +++ b/storage/netapp/santricity/restapi/plugin.pm @@ -0,0 +1,49 @@ +# +# Copyright 2020 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 storage::netapp::santricity::restapi::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} = '0.1'; + %{ $self->{modes} } = ( + 'hardware' => 'storage::netapp::santricity::restapi::mode::hardware' + ); + + $self->{custom_modes}{api} = 'storage::netapp::santricity::restapi::custom::api'; + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Netapp storages with Santricity using Rest API. + +=cut From 52314d95a8dfc66cb4860482e2086bd80d550d6f Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 6 May 2020 16:25:22 +0200 Subject: [PATCH 187/283] enhance counter template --- centreon/plugins/templates/counter.pm | 36 ++++++++++++++++----------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/centreon/plugins/templates/counter.pm b/centreon/plugins/templates/counter.pm index 5b56573ea..4ab923489 100644 --- a/centreon/plugins/templates/counter.pm +++ b/centreon/plugins/templates/counter.pm @@ -441,8 +441,10 @@ sub run_group { $prefix_output = '' if (!defined($prefix_output)); if ($multiple == 0 && (!defined($group->{display}) || $group->{display} != 0)) { - $self->{output}->output_add(severity => $self->{most_critical_instance}, - short_msg => sprintf("${prefix_output}" . $format_output, $self->{lproblems})); + $self->{output}->output_add( + severity => $self->{most_critical_instance}, + short_msg => sprintf("${prefix_output}" . $format_output, $self->{lproblems}) + ); } } } @@ -450,8 +452,10 @@ sub run_group { if ($multiple == 1) { my $exit = $self->{output}->get_most_critical(status => [ @{$global_exit} ]); if (!$self->{output}->is_status(litteral => 1, value => $exit, compare => 'ok')) { - $self->{output}->output_add(severity => $exit, - short_msg => sprintf($format_output, $total_problems)); + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf($format_output, $total_problems) + ); } } @@ -476,12 +480,12 @@ sub run_multiple_instances { my $multiple_parent = defined($options{multiple_parent}) && $options{multiple_parent} == 1 ? $options{multiple_parent} : 0; my $indent_long_output = defined($options{indent_long_output}) ? $options{indent_long_output} : ''; my $no_message_multiple = 1; - + my $multiple = 1; if (scalar(keys %{$self->{$options{config}->{name}}}) <= 1) { $multiple = 0; } - + my $message_separator = defined($options{config}->{message_separator}) ? $options{config}->{message_separator} : ', '; my $sort_method = 'cmp'; @@ -506,8 +510,10 @@ sub run_multiple_instances { $no_message_multiple = 0; $obj->set(instance => $instance); - my ($value_check) = $obj->execute(new_datas => $self->{new_datas}, - values => $self->{$options{config}->{name}}->{$id}); + my ($value_check) = $obj->execute( + new_datas => $self->{new_datas}, + values => $self->{$options{config}->{name}}->{$id} + ); next if (defined($options{config}->{skipped_code}) && defined($options{config}->{skipped_code}->{$value_check})); if ($value_check != 0) { $long_msg .= $long_msg_append . $obj->output_error(); @@ -549,17 +555,19 @@ sub run_multiple_instances { } if (!$self->{output}->is_status(litteral => 1, value => $exit, compare => 'ok')) { - $self->run_multiple_prefix_output(severity => $exit, - short_msg => $prefix_output . $short_msg . $suffix_output); + $self->run_multiple_prefix_output( + severity => $exit, + short_msg => $prefix_output . $short_msg . $suffix_output + ); } - + if ($multiple == 0 && $multiple_parent == 0) { $self->run_multiple_prefix_output(severity => 'ok', short_msg => $prefix_output . $long_msg . $suffix_output); } } - + if ($no_message_multiple == 0 && $multiple == 1 && $multiple_parent == 0) { - $self->{output}->output_add(short_msg => $options{config}->{message_multiple}); + $self->run_multiple_prefix_output(severity => 'ok', short_msg => $options{config}->{message_multiple}); } } @@ -572,7 +580,7 @@ sub run_multiple_prefix_output { $self->{prefix_multiple_output_done}->{lc($options{severity})} = 1; $separator{separator} = ''; } - + $self->{output}->output_add(severity => $options{severity}, short_msg => "$options{short_msg}", %separator); } From 2b1c7160a219be7e29573cd34784f085bf8245af Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 6 May 2020 16:26:04 +0200 Subject: [PATCH 188/283] Fix #1807 --- .../netapp/santricity/restapi/custom/api.pm | 4 +- .../santricity/restapi/mode/storagepools.pm | 176 ++++++++++++++++ .../santricity/restapi/mode/storagesystems.pm | 194 ++++++++++++++++++ .../santricity/restapi/mode/storagevolumes.pm | 189 +++++++++++++++++ storage/netapp/santricity/restapi/plugin.pm | 5 +- 5 files changed, 566 insertions(+), 2 deletions(-) create mode 100644 storage/netapp/santricity/restapi/mode/storagepools.pm create mode 100644 storage/netapp/santricity/restapi/mode/storagesystems.pm create mode 100644 storage/netapp/santricity/restapi/mode/storagevolumes.pm diff --git a/storage/netapp/santricity/restapi/custom/api.pm b/storage/netapp/santricity/restapi/custom/api.pm index ac5f26aa5..227aaeb99 100644 --- a/storage/netapp/santricity/restapi/custom/api.pm +++ b/storage/netapp/santricity/restapi/custom/api.pm @@ -184,7 +184,7 @@ sub execute_storages_request { my $content = do { local $/ = undef; - if (!open my $fh, "<", '/home/qgarnier/clients/plugins/todo/santricity/test-inventory.txt') { + if (!open my $fh, "<", '/home/qgarnier/clients/plugins/todo/santricity/test-storages.txt') { $self->{output}->add_option_msg(short_msg => "Could not open file $self->{option_results}->{$_} : $!"); $self->{output}->option_exit(); } @@ -196,6 +196,8 @@ sub execute_storages_request { return $content; my $storages = $self->request_api(name => 'storages', endpoint => '/storage-systems'); + return $storages if (!defined($options{endpoint})); + for (my $i = 0; $i < scalar(@{$storages->{storages}}); $i++) { next if (defined($options{filter_name}) && $options{filter_name} ne '' && $storages->{storages}->{$i}->{name} !~ /$options{filter_name}/); diff --git a/storage/netapp/santricity/restapi/mode/storagepools.pm b/storage/netapp/santricity/restapi/mode/storagepools.pm new file mode 100644 index 000000000..ce91c0354 --- /dev/null +++ b/storage/netapp/santricity/restapi/mode/storagepools.pm @@ -0,0 +1,176 @@ +# +# Copyright 2020 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 storage::netapp::santricity::restapi::mode::storagepools; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); + +sub custom_status_output { + my ($self, %options) = @_; + + return sprintf( + 'state: %s [raid status: %s]', + $self->{result_values}->{state}, + $self->{result_values}->{raid_status} + ); +} + +sub ss_long_output { + my ($self, %options) = @_; + + return "checking storage system '" . $options{instance_value}->{display} . "'"; +} + +sub prefix_ss_output { + my ($self, %options) = @_; + + return "storage system '" . $options{instance_value}->{display} . "' "; +} + +sub prefix_pool_output { + my ($self, %options) = @_; + + return "pool '" . $options{instance_value}->{display} . "' "; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'ss', type => 3, cb_prefix_output => 'prefix_ss_output', cb_long_output => 'ss_long_output', indent_long_output => ' ', message_multiple => 'All storage systems are ok', + group => [ + { name => 'pools', display_long => 1, cb_prefix_output => 'prefix_pool_output', message_multiple => 'pools are ok', type => 1, skipped_code => { -10 => 1 } } + ] + } + ]; + + $self->{maps_counters}->{pools} = [ + { label => 'pool-status', threshold => 0, set => { + key_values => [ { name => 'raid_status' }, { name => 'state'}, { name => 'display' } ], + closure_custom_calc => \&catalog_status_calc, + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold + } + } + ]; +} + +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-storage-name:s' => { name => 'filter_storage_name' }, + 'filter-pool-name:s' => { name => 'filter_pool_name' }, + 'unknown-pool-status:s' => { name => 'unknown_pool_status', default => '' }, + 'warning-pool-status:s' => { name => 'warning_pool_status', default => '%{raid_status} =~ /degraded/i' }, + 'critical-pool-status:s' => { name => 'critical_pool_status', default => '%{raid_status} =~ /failed/i' } + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->change_macros(macros => ['warning_pool_status', 'critical_pool_status', 'unknown_pool_status']); +} + +sub manage_selection { + my ($self, %options) = @_; + + my $results = $options{custom}->execute_storages_request( + endpoint => '/storage-pools', + filter_name => $self->{option_results}->{filter_storage_name} + ); + + $self->{ss} = {}; + foreach (@{$results->{storages}}) { + my $storage_name = $_->{name}; + + $self->{ss}->{$storage_name} = { + display => $storage_name, + pools => {} + }; + + next if (!defined($_->{'/storage-pools'})); + + foreach my $entry (@{$_->{'/storage-pools'}}) { + + next if (defined($self->{option_results}->{filter_pool_name}) && $self->{option_results}->{filter_pool_name} ne '' && + $entry->{name} !~ /$self->{option_results}->{filter_pool_name}/); + + $self->{ss}->{$storage_name}->{pools}->{ $entry->{name} } = { + display => $entry->{name}, + state => $entry->{state}, + raid_status => $entry->{raidStatus} + }; + } + } +} + +1; + +__END__ + +=head1 MODE + +Check storage pools. + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='^pool-status$' + +=item B<--filter-storage-name> + +Filter storage name (can be a regexp). + +=item B<--filter-pool-name> + +Filter pool name (can be a regexp). + +=item B<--unknown-pool-status> + +Set unknown threshold for status. +Can used special variables like: %{raid_status}, %{state}, %{display} + +=item B<--warning-pool-status> + +Set warning threshold for status (Default: '%{raid_status} =~ /degraded/i'). +Can used special variables like: %{raid_status}, %{state}, %{display} + +=item B<--critical-pool-status> + +Set critical threshold for status (Default: '%{raid_status} =~ /failed/i'). +Can used special variables like: %{raid_status}, %{state}, %{display} + +=back + +=cut diff --git a/storage/netapp/santricity/restapi/mode/storagesystems.pm b/storage/netapp/santricity/restapi/mode/storagesystems.pm new file mode 100644 index 000000000..a1ca67925 --- /dev/null +++ b/storage/netapp/santricity/restapi/mode/storagesystems.pm @@ -0,0 +1,194 @@ +# +# Copyright 2020 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 storage::netapp::santricity::restapi::mode::storagesystems; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); + +sub custom_status_output { + my ($self, %options) = @_; + + return sprintf( + 'status: %s', + $self->{result_values}->{status} + ); +} + +sub custom_usage_output { + my ($self, %options) = @_; + + my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_space_absolute}); + my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_space_absolute}); + my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_space_absolute}); + my $msg = sprintf( + 'space usage total: %s used: %s (%.2f%%) free: %s (%.2f%%)', + $total_size_value . " " . $total_size_unit, + $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used_space_absolute}, + $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free_space_absolute} + ); + return $msg; +} + +sub prefix_ss_output { + my ($self, %options) = @_; + + return "storage system '" . $options{instance_value}->{display} . "' "; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'ss', type => 1, cb_prefix_output => 'prefix_ss_output', message_multiple => 'All storage systems are ok' } + ]; + + $self->{maps_counters}->{ss} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'status' }, { name => 'display' } ], + closure_custom_calc => \&catalog_status_calc, + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold + } + }, + { label => 'usage', nlabel => 'pool.space.usage.bytes', set => { + key_values => [ { name => 'used_space' }, { name => 'free_space' }, { name => 'prct_used_space' }, { name => 'prct_free_space' }, { name => 'total_space' }, { name => 'display' }, ], + closure_custom_output => $self->can('custom_usage_output'), + perfdatas => [ + { value => 'used_space_absolute', template => '%d', min => 0, max => 'total_space_absolute', + unit => 'B', cast_int => 1, label_extra_instance => 1 } + ] + } + }, + { label => 'usage-free', nlabel => 'pool.space.free.bytes', display_ok => 0, set => { + key_values => [ { name => 'free_space' }, { name => 'used_space' }, { name => 'prct_used_space' }, { name => 'prct_free_space' }, { name => 'total_space' }, { name => 'display' }, ], + closure_custom_output => $self->can('custom_usage_output'), + perfdatas => [ + { value => 'free_space_absolute', template => '%d', min => 0, max => 'total_space_absolute', + unit => 'B', cast_int => 1, label_extra_instance => 1 } + ] + } + }, + { label => 'usage-prct', nlabel => 'pool.space.usage.percentage', display_ok => 0, set => { + key_values => [ { name => 'prct_used_space' }, { name => 'display' } ], + output_template => 'used : %.2f %%', + perfdatas => [ + { value => 'prct_used_space_absolute', template => '%.2f', min => 0, max => 100, + unit => '%', label_extra_instance => 1 } + ] + } + } + ]; +} + +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-storage-name:s' => { name => 'filter_storage_name' }, + 'unknown-status:s' => { name => 'unknown_status', default => '' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '%{status} =~ /needsAttn/i' } + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->change_macros(macros => ['warning_status', 'critical_status', 'unknown_status']); +} + +sub manage_selection { + my ($self, %options) = @_; + + my $results = $options{custom}->execute_storages_request(); + + $self->{ss} = {}; + foreach (@{$results->{storages}}) { + my $storage_name = $_->{name}; + + next if (defined($options{filter_storage_name}) && $options{filter_storage_name} ne '' && + $storage_name !~ /$options{filter_storage_name}/); + + $self->{ss}->{$storage_name} = { + display => $_->{name}, + status => $_->{status}, + total_space => $_->{usedPoolSpace} + $_->{freePoolSpace}, + used_space => $_->{usedPoolSpace}, + free_space => $_->{freePoolSpace}, + prct_used_space => + ($_->{usedPoolSpace} * 100 / ($_->{usedPoolSpace} + $_->{freePoolSpace})), + prct_free_space => + ($_->{freePoolSpace} * 100 / ($_->{usedPoolSpace} + $_->{freePoolSpace})) + }; + } +} + +1; + +__END__ + +=head1 MODE + +Check storage systems. + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='status' + +=item B<--filter-storage-name> + +Filter storage name (can be a regexp). + +=item B<--unknown-status> + +Set unknown threshold for status. +Can used special variables like: %{status}, %{state}, %{display} + +=item B<--warning-status> + +Set warning threshold for status. +Can used special variables like: %{status}, %{display} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{status} =~ /needsAttn/i'). +Can used special variables like: %{status}, %{display} + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'usage' (B), 'usage-free' (B), 'usage-prct' (%). + +=back + +=cut diff --git a/storage/netapp/santricity/restapi/mode/storagevolumes.pm b/storage/netapp/santricity/restapi/mode/storagevolumes.pm new file mode 100644 index 000000000..1746a8052 --- /dev/null +++ b/storage/netapp/santricity/restapi/mode/storagevolumes.pm @@ -0,0 +1,189 @@ +# +# Copyright 2020 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 storage::netapp::santricity::restapi::mode::storagevolumes; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); + +sub custom_status_output { + my ($self, %options) = @_; + + return sprintf( + 'status: %s', + $self->{result_values}->{status} + ); +} + +sub custom_usage_output { + my ($self, %options) = @_; + + my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_space_absolute}); + my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_space_absolute}); + my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_space_absolute}); + my $msg = sprintf( + 'space usage total: %s used: %s (%.2f%%) free: %s (%.2f%%)', + $total_size_value . " " . $total_size_unit, + $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used_space_absolute}, + $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free_space_absolute} + ); + return $msg; +} + +sub ss_long_output { + my ($self, %options) = @_; + + return "checking storage system '" . $options{instance_value}->{display} . "'"; +} + +sub prefix_ss_output { + my ($self, %options) = @_; + + return "storage system '" . $options{instance_value}->{display} . "' "; +} + +sub prefix_volume_output { + my ($self, %options) = @_; + + return "volume '" . $options{instance_value}->{display} . "' "; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'ss', type => 3, cb_prefix_output => 'prefix_ss_output', cb_long_output => 'ss_long_output', indent_long_output => ' ', message_multiple => 'All storage systems are ok', + group => [ + { name => 'volumes', display_long => 1, cb_prefix_output => 'prefix_volume_output', message_multiple => 'volumes are ok', type => 1, skipped_code => { -10 => 1 } } + ] + } + ]; + + $self->{maps_counters}->{volumes} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'status' }, { name => 'display' } ], + closure_custom_calc => \&catalog_status_calc, + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold + } + } + ]; +} + +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-storage-name:s' => { name => 'filter_storage_name' }, + 'filter-volume-name:s' => { name => 'filter_volume_name' }, + 'unknown-volyme-status:s' => { name => 'unknown_volume_status', default => '' }, + 'warning-volume-status:s' => { name => 'warning_volume_status', default => '%{status} =~ /degraded/i' }, + 'critical-volume-status:s' => { name => 'critical_volume_status', default => '%{status} =~ /failed/i' } + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->change_macros(macros => ['warning_volume_status', 'critical_volume_status', 'unknown_volume_status']); +} + +sub manage_selection { + my ($self, %options) = @_; + + my $results = $options{custom}->execute_storages_request( + endpoint => '/storage-volumes', + filter_name => $self->{option_results}->{filter_storage_name} + ); + + $self->{ss} = {}; + foreach (@{$results->{storages}}) { + my $storage_name = $_->{name}; + + $self->{ss}->{$storage_name} = { + display => $storage_name, + volumes => {} + }; + + next if (!defined($_->{'/storage-volumes'})); + + foreach my $entry (@{$_->{'/storage-volumes'}}) { + + next if (defined($options{filter_volume_name}) && $options{filter_volume_name} ne '' && + $entry->{name} !~ /$options{filter_volume_name}/); + + $self->{ss}->{$storage_name}->{volumes}->{ $entry->{name} } = { + display => $entry->{name}, + status => $entry->{status} + }; + } + } +} + +1; + +__END__ + +=head1 MODE + +Check storage volumes. + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='volume-status' + +=item B<--filter-storage-name> + +Filter storage name (can be a regexp). + +=item B<--filter-volume-name> + +Filter volume name (can be a regexp). + +=item B<--unknown-volume-status> + +Set unknown threshold for status. +Can used special variables like: %{status}, %{display} + +=item B<--warning-volume-status> + +Set warning threshold for status (Default: '%{status} =~ /degraded/i'). +Can used special variables like: %{status}, %{display} + +=item B<--critical-volume-status> + +Set critical threshold for status (Default: '%{status} =~ /failed/i'). +Can used special variables like: %{status}, %{display} + +=back + +=cut diff --git a/storage/netapp/santricity/restapi/plugin.pm b/storage/netapp/santricity/restapi/plugin.pm index d201c68c0..1ede0b11e 100644 --- a/storage/netapp/santricity/restapi/plugin.pm +++ b/storage/netapp/santricity/restapi/plugin.pm @@ -31,7 +31,10 @@ sub new { $self->{version} = '0.1'; %{ $self->{modes} } = ( - 'hardware' => 'storage::netapp::santricity::restapi::mode::hardware' + 'hardware' => 'storage::netapp::santricity::restapi::mode::hardware', + 'storage-pools' => 'storage::netapp::santricity::restapi::mode::storagepools', + 'storage-systems' => 'storage::netapp::santricity::restapi::mode::storagesystems', + 'storage-volumes' => 'storage::netapp::santricity::restapi::mode::storagevolumes' ); $self->{custom_modes}{api} = 'storage::netapp::santricity::restapi::custom::api'; From b564fe5db73a1e03ea41d7ae73fc0497c8871c4c Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 6 May 2020 16:27:31 +0200 Subject: [PATCH 189/283] Fix #1807 --- storage/netapp/santricity/restapi/custom/api.pm | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/storage/netapp/santricity/restapi/custom/api.pm b/storage/netapp/santricity/restapi/custom/api.pm index 227aaeb99..b74f810c7 100644 --- a/storage/netapp/santricity/restapi/custom/api.pm +++ b/storage/netapp/santricity/restapi/custom/api.pm @@ -182,19 +182,6 @@ sub request_api { sub execute_storages_request { my ($self, %options) = @_; - my $content = do { - local $/ = undef; - if (!open my $fh, "<", '/home/qgarnier/clients/plugins/todo/santricity/test-storages.txt') { - $self->{output}->add_option_msg(short_msg => "Could not open file $self->{option_results}->{$_} : $!"); - $self->{output}->option_exit(); - } - <$fh>; - }; - eval { - $content = JSON::XS->new->utf8->decode($content); - }; - return $content; - my $storages = $self->request_api(name => 'storages', endpoint => '/storage-systems'); return $storages if (!defined($options{endpoint})); From b03a72063ae65958df20dc26f20e1d9f14c13e15 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 6 May 2020 17:21:23 +0200 Subject: [PATCH 190/283] wip netapp santricity --- storage/netapp/santricity/restapi/custom/api.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/netapp/santricity/restapi/custom/api.pm b/storage/netapp/santricity/restapi/custom/api.pm index b74f810c7..d68cbec38 100644 --- a/storage/netapp/santricity/restapi/custom/api.pm +++ b/storage/netapp/santricity/restapi/custom/api.pm @@ -151,7 +151,7 @@ sub request_api { $self->settings(); my $content = $self->{http}->request( method => defined($options{method}) ? $options{method} : 'GET', - url_path => $self->{api_path} . '/' . $options{endpoint}, + url_path => $self->{api_path} . $options{endpoint}, unknown_status => $self->{unknown_http_status}, warning_status => $self->{warning_http_status}, critical_status => $self->{critical_http_status}, From 144ad46775897d592f88951e8f59b23db2241ed5 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 6 May 2020 17:30:00 +0200 Subject: [PATCH 191/283] wip netapp santricity --- storage/netapp/santricity/restapi/custom/api.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/storage/netapp/santricity/restapi/custom/api.pm b/storage/netapp/santricity/restapi/custom/api.pm index d68cbec38..fb5df8190 100644 --- a/storage/netapp/santricity/restapi/custom/api.pm +++ b/storage/netapp/santricity/restapi/custom/api.pm @@ -189,11 +189,11 @@ sub execute_storages_request { next if (defined($options{filter_name}) && $options{filter_name} ne '' && $storages->{storages}->{$i}->{name} !~ /$options{filter_name}/); - my $info = $self->request_api(name => 'info', endpoint => '/' . $storages->{storages}->{$i}->{wwn} . '/' . $options{endpoint}); - $storages->{storages}->{$i}->{offline} = 0; - $storages->{storages}->{$i}->{offline} = 1 if (!defined($info)); + my $info = $self->request_api(name => 'info', endpoint => '/' . $storages->{storages}->[$i]->{wwn} . '/' . $options{endpoint}); + $storages->{storages}->[$i]->{offline} = 0; + $storages->{storages}->[$i]->{offline} = 1 if (!defined($info)); - $storages->{storages}->{$i}->{ $options{endpoint} } = defined($info) ? $info->{info} : undef; + $storages->{storages}->[$i]->{ $options{endpoint} } = defined($info) ? $info->{info} : undef; } return $storages; From 42f2f1a54dc0a4e3f86764e943ee2fd67a847ffc Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 6 May 2020 17:30:13 +0200 Subject: [PATCH 192/283] wip netapp santricity --- storage/netapp/santricity/restapi/custom/api.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/netapp/santricity/restapi/custom/api.pm b/storage/netapp/santricity/restapi/custom/api.pm index fb5df8190..0fe7f72d7 100644 --- a/storage/netapp/santricity/restapi/custom/api.pm +++ b/storage/netapp/santricity/restapi/custom/api.pm @@ -187,7 +187,7 @@ sub execute_storages_request { for (my $i = 0; $i < scalar(@{$storages->{storages}}); $i++) { next if (defined($options{filter_name}) && $options{filter_name} ne '' && - $storages->{storages}->{$i}->{name} !~ /$options{filter_name}/); + $storages->{storages}->[$i]->{name} !~ /$options{filter_name}/); my $info = $self->request_api(name => 'info', endpoint => '/' . $storages->{storages}->[$i]->{wwn} . '/' . $options{endpoint}); $storages->{storages}->[$i]->{offline} = 0; From 569bf939bd880b5267cec3dffda515fa40455a3c Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 6 May 2020 17:35:16 +0200 Subject: [PATCH 193/283] wip netapp santricity --- storage/netapp/santricity/restapi/custom/api.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/netapp/santricity/restapi/custom/api.pm b/storage/netapp/santricity/restapi/custom/api.pm index 0fe7f72d7..c6bbaa9d2 100644 --- a/storage/netapp/santricity/restapi/custom/api.pm +++ b/storage/netapp/santricity/restapi/custom/api.pm @@ -189,7 +189,7 @@ sub execute_storages_request { next if (defined($options{filter_name}) && $options{filter_name} ne '' && $storages->{storages}->[$i]->{name} !~ /$options{filter_name}/); - my $info = $self->request_api(name => 'info', endpoint => '/' . $storages->{storages}->[$i]->{wwn} . '/' . $options{endpoint}); + my $info = $self->request_api(name => 'info', endpoint => '/' . $storages->{storages}->[$i]->{wwn} . $options{endpoint}); $storages->{storages}->[$i]->{offline} = 0; $storages->{storages}->[$i]->{offline} = 1 if (!defined($info)); From 939e6c9aaa82316b8ccb0aa71a928a59bc9dd994 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 6 May 2020 17:45:24 +0200 Subject: [PATCH 194/283] wip netapp santricity --- storage/netapp/santricity/restapi/custom/api.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/netapp/santricity/restapi/custom/api.pm b/storage/netapp/santricity/restapi/custom/api.pm index c6bbaa9d2..18ed368ae 100644 --- a/storage/netapp/santricity/restapi/custom/api.pm +++ b/storage/netapp/santricity/restapi/custom/api.pm @@ -189,7 +189,7 @@ sub execute_storages_request { next if (defined($options{filter_name}) && $options{filter_name} ne '' && $storages->{storages}->[$i]->{name} !~ /$options{filter_name}/); - my $info = $self->request_api(name => 'info', endpoint => '/' . $storages->{storages}->[$i]->{wwn} . $options{endpoint}); + my $info = $self->request_api(name => 'info', endpoint => '/storage-systems/' . $storages->{storages}->[$i]->{wwn} . $options{endpoint}); $storages->{storages}->[$i]->{offline} = 0; $storages->{storages}->[$i]->{offline} = 1 if (!defined($info)); From d21db6a91bc1a65d31d2668c4c4580f98c2e79a9 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 6 May 2020 17:55:51 +0200 Subject: [PATCH 195/283] wip netapp santricity --- storage/netapp/santricity/restapi/mode/storagevolumes.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/storage/netapp/santricity/restapi/mode/storagevolumes.pm b/storage/netapp/santricity/restapi/mode/storagevolumes.pm index 1746a8052..92a7df658 100644 --- a/storage/netapp/santricity/restapi/mode/storagevolumes.pm +++ b/storage/netapp/santricity/restapi/mode/storagevolumes.pm @@ -118,7 +118,7 @@ sub manage_selection { my ($self, %options) = @_; my $results = $options{custom}->execute_storages_request( - endpoint => '/storage-volumes', + endpoint => '/volumes', filter_name => $self->{option_results}->{filter_storage_name} ); @@ -131,9 +131,9 @@ sub manage_selection { volumes => {} }; - next if (!defined($_->{'/storage-volumes'})); + next if (!defined($_->{'/volumes'})); - foreach my $entry (@{$_->{'/storage-volumes'}}) { + foreach my $entry (@{$_->{'/volumes'}}) { next if (defined($options{filter_volume_name}) && $options{filter_volume_name} ne '' && $entry->{name} !~ /$options{filter_volume_name}/); From 11b785085d23cb913927dd854a8c110e9979f6ee Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 7 May 2020 08:58:47 +0200 Subject: [PATCH 196/283] fix typo --- storage/netapp/santricity/restapi/mode/hardware.pm | 4 ++-- storage/netapp/santricity/restapi/mode/storagevolumes.pm | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/storage/netapp/santricity/restapi/mode/hardware.pm b/storage/netapp/santricity/restapi/mode/hardware.pm index fd025d731..0fb65c47c 100644 --- a/storage/netapp/santricity/restapi/mode/hardware.pm +++ b/storage/netapp/santricity/restapi/mode/hardware.pm @@ -48,7 +48,7 @@ sub set_system { ['overtemp', ''], ['expired', 'WARNING'], ['maintenanceCharging', 'OK'], - ['replacementRequired', 'CRTICICAL'] + ['replacementRequired', 'CRITICAL'] ], board => [ ['unknown', 'UNKNOWN'], @@ -78,7 +78,7 @@ sub set_system { ['optimal', 'OK'], ['failed', 'CRITICAL'], ['removed', 'OK'], - ['rpaParErr', 'WAARNING'], + ['rpaParErr', 'WARNING'], ['serviceMode', 'OK'], ['suspended', 'OK'], ['degraded', 'WARNING'] diff --git a/storage/netapp/santricity/restapi/mode/storagevolumes.pm b/storage/netapp/santricity/restapi/mode/storagevolumes.pm index 92a7df658..a3cac70db 100644 --- a/storage/netapp/santricity/restapi/mode/storagevolumes.pm +++ b/storage/netapp/santricity/restapi/mode/storagevolumes.pm @@ -80,7 +80,7 @@ sub set_counters { ]; $self->{maps_counters}->{volumes} = [ - { label => 'status', threshold => 0, set => { + { label => 'volume-status', threshold => 0, set => { key_values => [ { name => 'status' }, { name => 'display' } ], closure_custom_calc => \&catalog_status_calc, closure_custom_output => $self->can('custom_status_output'), @@ -99,7 +99,7 @@ sub new { $options{options}->add_options(arguments => { 'filter-storage-name:s' => { name => 'filter_storage_name' }, 'filter-volume-name:s' => { name => 'filter_volume_name' }, - 'unknown-volyme-status:s' => { name => 'unknown_volume_status', default => '' }, + 'unknown-volume-status:s' => { name => 'unknown_volume_status', default => '' }, 'warning-volume-status:s' => { name => 'warning_volume_status', default => '%{status} =~ /degraded/i' }, 'critical-volume-status:s' => { name => 'critical_volume_status', default => '%{status} =~ /failed/i' } }); From 5a6b2f15223b610c98fee8b094df9455341425b7 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 7 May 2020 10:16:30 +0200 Subject: [PATCH 197/283] add some checks for netapp santricity --- .../netapp/santricity/restapi/custom/api.pm | 24 +- .../santricity/restapi/mode/hardware.pm | 4 +- .../restapi/mode/storagecontrollers.pm | 252 ++++++++++++++++++ .../santricity/restapi/mode/storagepools.pm | 2 +- .../santricity/restapi/mode/storagevolumes.pm | 82 ++++-- storage/netapp/santricity/restapi/plugin.pm | 9 +- 6 files changed, 344 insertions(+), 29 deletions(-) create mode 100644 storage/netapp/santricity/restapi/mode/storagecontrollers.pm diff --git a/storage/netapp/santricity/restapi/custom/api.pm b/storage/netapp/santricity/restapi/custom/api.pm index 18ed368ae..2974c381a 100644 --- a/storage/netapp/santricity/restapi/custom/api.pm +++ b/storage/netapp/santricity/restapi/custom/api.pm @@ -182,18 +182,30 @@ sub request_api { sub execute_storages_request { my ($self, %options) = @_; - my $storages = $self->request_api(name => 'storages', endpoint => '/storage-systems'); - return $storages if (!defined($options{endpoint})); + my $storages = $self->request_api( + name => 'storages', + endpoint => '/storage-systems' + ); + return $storages if (!defined($options{endpoints})); for (my $i = 0; $i < scalar(@{$storages->{storages}}); $i++) { next if (defined($options{filter_name}) && $options{filter_name} ne '' && $storages->{storages}->[$i]->{name} !~ /$options{filter_name}/); - my $info = $self->request_api(name => 'info', endpoint => '/storage-systems/' . $storages->{storages}->[$i]->{wwn} . $options{endpoint}); $storages->{storages}->[$i]->{offline} = 0; - $storages->{storages}->[$i]->{offline} = 1 if (!defined($info)); - - $storages->{storages}->[$i]->{ $options{endpoint} } = defined($info) ? $info->{info} : undef; + + foreach (@{$options{endpoints}}) { + my $info = $self->request_api( + name => 'info', + endpoint => '/storage-systems/' . $storages->{storages}->[$i]->{wwn} . $_->{endpoint} . (defined($_->{get_param}) ? '?' . $_->{get_param} : '') + ); + if (!defined($info)) { + $storages->{storages}->[$i]->{offline} = 1; + last; + } + + $storages->{storages}->[$i]->{ $_->{endpoint} } = defined($info) ? $info->{info} : undef; + } } return $storages; diff --git a/storage/netapp/santricity/restapi/mode/hardware.pm b/storage/netapp/santricity/restapi/mode/hardware.pm index 0fb65c47c..e651fcb00 100644 --- a/storage/netapp/santricity/restapi/mode/hardware.pm +++ b/storage/netapp/santricity/restapi/mode/hardware.pm @@ -147,7 +147,9 @@ sub new { sub execute_custom { my ($self, %options) = @_; - $self->{json_results} = $options{custom}->execute_storages_request(endpoint => '/hardware-inventory'); + $self->{json_results} = $options{custom}->execute_storages_request( + endpoints => [ { endpoint => '/hardware-inventory' } ] + ); } 1; diff --git a/storage/netapp/santricity/restapi/mode/storagecontrollers.pm b/storage/netapp/santricity/restapi/mode/storagecontrollers.pm new file mode 100644 index 000000000..7ac1d81e9 --- /dev/null +++ b/storage/netapp/santricity/restapi/mode/storagecontrollers.pm @@ -0,0 +1,252 @@ +# +# Copyright 2020 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 storage::netapp::santricity::restapi::mode::storagecontrollers; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); +use Digest::MD5 qw(md5_hex); + +sub custom_status_output { + my ($self, %options) = @_; + + return sprintf( + 'status: %s', + $self->{result_values}->{status} + ); +} + +sub ss_long_output { + my ($self, %options) = @_; + + return "checking storage system '" . $options{instance_value}->{display} . "'"; +} + +sub prefix_ss_output { + my ($self, %options) = @_; + + return "storage system '" . $options{instance_value}->{display} . "' "; +} + +sub prefix_controller_output { + my ($self, %options) = @_; + + return "controller '" . $options{instance_value}->{display} . "' "; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'ss', type => 3, cb_prefix_output => 'prefix_ss_output', cb_long_output => 'ss_long_output', indent_long_output => ' ', message_multiple => 'All storage systems are ok', + group => [ + { name => 'controllers', display_long => 1, cb_prefix_output => 'prefix_controller_output', message_multiple => 'controllers are ok', type => 1, skipped_code => { -10 => 1 } } + ] + } + ]; + + $self->{maps_counters}->{controllers} = [ + { label => 'controller-status', threshold => 0, set => { + key_values => [ { name => 'status' }, { name => 'display' } ], + closure_custom_calc => \&catalog_status_calc, + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold + } + }, + { label => 'cpu-utilization', nlabel => 'volume.cpu.utilization.percentage', set => { + key_values => [ { name => 'cpu_util', diff => 1 }, { name => 'display' } ], + per_second => 1, + output_template => 'cpu usage: %.2f %%', + perfdatas => [ + { value => 'cpu_util_per_second', template => '%d', + unit => '%', label_extra_instance => 1 } + ] + } + }, + { label => 'read', nlabel => 'volume.io.read.usage.bytespersecond', set => { + key_values => [ { name => 'read_bytes', diff => 1 }, { name => 'display' } ], + output_template => 'read: %s %s/s', + per_second => 1, output_change_bytes => 1, + perfdatas => [ + { value => 'read_bytes_per_second', template => '%d', + unit => 'B/s', label_extra_instance => 1 } + ] + } + }, + { label => 'write', nlabel => 'volume.io.write.usage.bytespersecond', set => { + key_values => [ { name => 'write_bytes', diff => 1 }, { name => 'display' } ], + output_template => 'write: %s %s/s', + per_second => 1, output_change_bytes => 1, + perfdatas => [ + { value => 'write_bytes_per_second', template => '%d', + unit => 'B/s', min => 0, label_extra_instance => 1 } + ] + } + }, + { label => 'read-iops', nlabel => 'system.io.read.usage.iops', set => { + key_values => [ { name => 'read_iops', diff => 1 }, { name => 'display' } ], + output_template => 'read: %.2f iops', + per_second => 1, + perfdatas => [ + { value => 'read_iops_per_second', template => '%.2f', + unit => 'iops', min => 0, label_extra_instance => 1 } + ] + } + }, + { label => 'write-iops', nlabel => 'system.io.write.usage.iops', set => { + key_values => [ { name => 'write_iops', diff => 1 }, { name => 'display' } ], + output_template => 'write: %.2f iops', + per_second => 1, + perfdatas => [ + { value => 'write_iops_per_second', template => '%.2f', + unit => 'iops', min => 0, label_extra_instance => 1 } + ] + } + } + ]; +} + +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 => { + 'filter-storage-name:s' => { name => 'filter_storage_name' }, + 'filter-controller-name:s' => { name => 'filter_controller_name' }, + 'unknown-controller-status:s' => { name => 'unknown_controller_status', default => '%{status} =~ /unknown/i' }, + 'warning-controller-status:s' => { name => 'warning_controller_status', default => '%{status} =~ /rpaParErr|degraded/i' }, + 'critical-controller-status:s' => { name => 'critical_controller_status', default => '%{status} =~ /failed/i' } + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->change_macros(macros => ['warning_controller_status', 'critical_controller_status', 'unknown_controller_status']); +} + +sub manage_selection { + my ($self, %options) = @_; + + my $results = $options{custom}->execute_storages_request( + endpoints => [ + { endpoint => '/controllers' }, + { endpoint => '/controller-statistics', get_param => 'usecache=false' } + ], + filter_name => $self->{option_results}->{filter_storage_name} + ); + + my $mapping_controller = {}; + $self->{ss} = {}; + foreach (@{$results->{storages}}) { + my $storage_name = $_->{name}; + + $self->{ss}->{$storage_name} = { + display => $storage_name, + controllers => {} + }; + + next if (!defined($_->{'/controllers'})); + + foreach my $entry (@{$_->{'/controllers'}}) { + my $name = $entry->{physicalLocation}->{label} ne '' ? $entry->{physicalLocation}->{label} : + $entry->{physicalLocation}->{locationPosition} . ':' . $entry->{physicalLocation}->{slot}; + + next if (defined($options{filter_controller_name}) && $options{filter_controller_name} ne '' && + $name !~ /$options{filter_controller_name}/); + + $mapping_controller->{ $entry->{id} } = $name; + $self->{ss}->{$storage_name}->{controllers}->{ $name } = { + display => $name, + status => $entry->{status} + }; + } + + foreach my $entry (@{$_->{'/controller-statistics'}}) { + next if (!defined($mapping_controller->{ $entry->{controllerId} })); + + $self->{ss}->{$storage_name}->{controllers}->{ $mapping_controller->{ $entry->{controllerId} } }->{write_bytes} = $entry->{writeBytesTotal}; + $self->{ss}->{$storage_name}->{controllers}->{ $mapping_controller->{ $entry->{controllerId} } }->{read_bytes} = $entry->{readBytesTotal}; + $self->{ss}->{$storage_name}->{controllers}->{ $mapping_controller->{ $entry->{controllerId} } }->{read_iops} = $entry->{readIopsTotal}; + $self->{ss}->{$storage_name}->{controllers}->{ $mapping_controller->{ $entry->{controllerId} } }->{write_iops} = $entry->{writeIopsTotal}; + $self->{ss}->{$storage_name}->{controllers}->{ $mapping_controller->{ $entry->{controllerId} } }->{cpu_util} = $entry->{cpuUtilizationStats}->[0]->{sumCpuUtilization}; + } + } + + $self->{cache_name} = 'netapp_santricity' . $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_storage_name}) ? md5_hex($self->{option_results}->{filter_storage_name}) : md5_hex('all')) . '_' . + (defined($self->{option_results}->{filter_controller_name}) ? md5_hex($self->{option_results}->{filter_controller_name}) : md5_hex('all')); +} + +1; + +__END__ + +=head1 MODE + +Check storage controllers. + +=over 8 + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='volume-status' + +=item B<--filter-storage-name> + +Filter storage name (can be a regexp). + +=item B<--filter-controller-name> + +Filter controller name (can be a regexp). + +=item B<--unknown-controller-status> + +Set unknown threshold for status (Default: '%{status} =~ /unknown/i'). +Can used special variables like: %{status}, %{display} + +=item B<--warning-controller-status> + +Set warning threshold for status (Default: '%{status} =~ /rpaParErr|degraded/i'). +Can used special variables like: %{status}, %{display} + +=item B<--critical-controller-status> + +Set critical threshold for status (Default: '%{status} =~ /failed/i'). +Can used special variables like: %{status}, %{display} + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'read' (B/s), 'write' (B/s), 'read-iops', 'write-iops'. + +=back + +=cut diff --git a/storage/netapp/santricity/restapi/mode/storagepools.pm b/storage/netapp/santricity/restapi/mode/storagepools.pm index ce91c0354..752538a13 100644 --- a/storage/netapp/santricity/restapi/mode/storagepools.pm +++ b/storage/netapp/santricity/restapi/mode/storagepools.pm @@ -104,7 +104,7 @@ sub manage_selection { my ($self, %options) = @_; my $results = $options{custom}->execute_storages_request( - endpoint => '/storage-pools', + endpoints => [ { endpoint => '/storage-pools' } ], filter_name => $self->{option_results}->{filter_storage_name} ); diff --git a/storage/netapp/santricity/restapi/mode/storagevolumes.pm b/storage/netapp/santricity/restapi/mode/storagevolumes.pm index a3cac70db..544ef1b40 100644 --- a/storage/netapp/santricity/restapi/mode/storagevolumes.pm +++ b/storage/netapp/santricity/restapi/mode/storagevolumes.pm @@ -25,6 +25,7 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); +use Digest::MD5 qw(md5_hex); sub custom_status_output { my ($self, %options) = @_; @@ -35,21 +36,6 @@ sub custom_status_output { ); } -sub custom_usage_output { - my ($self, %options) = @_; - - my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_space_absolute}); - my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_space_absolute}); - my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_space_absolute}); - my $msg = sprintf( - 'space usage total: %s used: %s (%.2f%%) free: %s (%.2f%%)', - $total_size_value . " " . $total_size_unit, - $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used_space_absolute}, - $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free_space_absolute} - ); - return $msg; -} - sub ss_long_output { my ($self, %options) = @_; @@ -87,13 +73,53 @@ sub set_counters { closure_custom_perfdata => sub { return 0; }, closure_custom_threshold_check => \&catalog_status_threshold } + }, + { label => 'read', nlabel => 'volume.io.read.usage.bytespersecond', set => { + key_values => [ { name => 'read_bytes', diff => 1 }, { name => 'display' } ], + per_second => 1, + output_change_bytes => 1, output_template => 'read: %s %s/s', + perfdatas => [ + { value => 'read_bytes_per_second', template => '%d', + unit => 'B/s', label_extra_instance => 1 } + ] + } + }, + { label => 'write', nlabel => 'volume.io.write.usage.bytespersecond', set => { + key_values => [ { name => 'write_bytes', diff => 1 }, { name => 'display' } ], + output_template => 'write: %s %s/s', + per_second => 1, output_change_bytes => 1, + perfdatas => [ + { value => 'write_bytes_per_second', template => '%d', + unit => 'B/s', min => 0, label_extra_instance => 1 } + ] + } + }, + { label => 'read-iops', nlabel => 'system.io.read.usage.iops', set => { + key_values => [ { name => 'read_iops', diff => 1 }, { name => 'display' } ], + output_template => 'read: %.2f iops', + per_second => 1, + perfdatas => [ + { value => 'read_iops_per_second', template => '%.2f', + unit => 'iops', min => 0, label_extra_instance => 1 } + ] + } + }, + { label => 'write-iops', nlabel => 'system.io.write.usage.iops', set => { + key_values => [ { name => 'write_iops', diff => 1 }, { name => 'display' } ], + output_template => 'write: %.2f iops', + per_second => 1, + perfdatas => [ + { value => 'write_iops_per_second', template => '%.2f', + unit => 'iops', min => 0, label_extra_instance => 1 } + ] + } } ]; } sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1, force_new_perfdata => 1); bless $self, $class; $options{options}->add_options(arguments => { @@ -118,7 +144,10 @@ sub manage_selection { my ($self, %options) = @_; my $results = $options{custom}->execute_storages_request( - endpoint => '/volumes', + endpoints => [ + { endpoint => '/volumes' }, + { endpoint => '/volume-statistics', get_param => 'usecache=false' } + ], filter_name => $self->{option_results}->{filter_storage_name} ); @@ -143,7 +172,21 @@ sub manage_selection { status => $entry->{status} }; } + + foreach my $entry (@{$_->{'/volume-statistics'}}) { + next if (!defined($self->{ss}->{$storage_name}->{volumes}->{ $entry->{volumeName} })); + + $self->{ss}->{$storage_name}->{volumes}->{ $entry->{volumeName} }->{write_bytes} = $entry->{writeBytes}; + $self->{ss}->{$storage_name}->{volumes}->{ $entry->{volumeName} }->{read_bytes} = $entry->{readBytes}; + $self->{ss}->{$storage_name}->{volumes}->{ $entry->{volumeName} }->{read_iops} = $entry->{readOps}; + $self->{ss}->{$storage_name}->{volumes}->{ $entry->{volumeName} }->{write_iops} = $entry->{writeOps}; + } } + + $self->{cache_name} = 'netapp_santricity' . $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_storage_name}) ? md5_hex($self->{option_results}->{filter_storage_name}) : md5_hex('all')) . '_' . + (defined($self->{option_results}->{filter_volume_name}) ? md5_hex($self->{option_results}->{filter_volume_name}) : md5_hex('all')); } 1; @@ -184,6 +227,11 @@ Can used special variables like: %{status}, %{display} Set critical threshold for status (Default: '%{status} =~ /failed/i'). Can used special variables like: %{status}, %{display} +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'read' (B/s), 'write' (B/s), 'read-iops', 'write-iops'. + =back =cut diff --git a/storage/netapp/santricity/restapi/plugin.pm b/storage/netapp/santricity/restapi/plugin.pm index 1ede0b11e..20945ee97 100644 --- a/storage/netapp/santricity/restapi/plugin.pm +++ b/storage/netapp/santricity/restapi/plugin.pm @@ -31,10 +31,11 @@ sub new { $self->{version} = '0.1'; %{ $self->{modes} } = ( - 'hardware' => 'storage::netapp::santricity::restapi::mode::hardware', - 'storage-pools' => 'storage::netapp::santricity::restapi::mode::storagepools', - 'storage-systems' => 'storage::netapp::santricity::restapi::mode::storagesystems', - 'storage-volumes' => 'storage::netapp::santricity::restapi::mode::storagevolumes' + 'hardware' => 'storage::netapp::santricity::restapi::mode::hardware', + 'storage-controllers' => 'storage::netapp::santricity::restapi::mode::storagecontrollers', + 'storage-pools' => 'storage::netapp::santricity::restapi::mode::storagepools', + 'storage-systems' => 'storage::netapp::santricity::restapi::mode::storagesystems', + 'storage-volumes' => 'storage::netapp::santricity::restapi::mode::storagevolumes' ); $self->{custom_modes}{api} = 'storage::netapp::santricity::restapi::custom::api'; From a72f89d7b19c74f18be5d60e390eef4e23e682a6 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 7 May 2020 10:41:36 +0200 Subject: [PATCH 198/283] add dell me4 interfaces + typo --- storage/dell/me4/restapi/mode/interfaces.pm | 265 ++++++++++++++++++ storage/dell/me4/restapi/plugin.pm | 3 +- .../restapi/mode/storagecontrollers.pm | 4 +- 3 files changed, 269 insertions(+), 3 deletions(-) create mode 100644 storage/dell/me4/restapi/mode/interfaces.pm diff --git a/storage/dell/me4/restapi/mode/interfaces.pm b/storage/dell/me4/restapi/mode/interfaces.pm new file mode 100644 index 000000000..5aee01ee5 --- /dev/null +++ b/storage/dell/me4/restapi/mode/interfaces.pm @@ -0,0 +1,265 @@ +# +# Copyright 2020 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 storage::dell::me4::restapi::mode::interfaces; + +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 catalog_status_calc); + +sub custom_status_output { + my ($self, %options) = @_; + + return sprintf( + 'status: %s [health: %s]', + $self->{result_values}->{status}, + $self->{result_values}->{health} + ); +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'ports', type => 3, cb_prefix_output => 'prefix_port_output', cb_long_output => 'port_long_output', indent_long_output => ' ', message_multiple => 'All interfaces are ok', + group => [ + { name => 'port_global', type => 0, skipped_code => { -10 => 1 } }, + { name => 'interfaces', display_long => 1, cb_prefix_output => 'prefix_interface_output', message_multiple => 'All interfaces are ok', type => 1, skipped_code => { -10 => 1 } }, + ] + } + ]; + + $self->{maps_counters}->{port_global} = [ + { label => 'port-status', threshold => 0, set => { + key_values => [ { name => 'status' }, { name => 'health'}, { name => 'display' } ], + closure_custom_calc => \&catalog_status_calc, + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold + } + }, + { label => 'read-iops', nlabel => 'port.io.read.usage.iops', set => { + key_values => [ { name => 'number_of_reads', diff => 1 }, { name => 'display' } ], + output_template => 'read iops: %.2f', + per_second => 1, + perfdatas => [ + { value => 'number_of_reads_per_second', template => '%.2f', + unit => 'iops', min => 0, label_extra_instance => 1 } + ] + } + }, + { label => 'write-iops', nlabel => 'port.io.write.usage.iops', set => { + key_values => [ { name => 'number_of_writes', diff => 1 }, { name => 'display' } ], + output_template => 'write iops: %.2f', + per_second => 1, + perfdatas => [ + { value => 'number_of_writes_per_second', template => '%.2f', + unit => 'iops', min => 0, label_extra_instance => 1 } + ] + } + }, + { label => 'read-traffic', nlabel => 'port.traffic.read.usage.bitspersecond', set => { + key_values => [ { name => 'data_read_numeric', diff => 1 }, { name => 'display' } ], + output_template => 'read traffic: %s %s/s', + per_second => 1, output_change_bytes => 2, + perfdatas => [ + { value => 'data_read_numeric_per_second', template => '%d', + unit => 'b/s', min => 0, label_extra_instance => 1 } + ] + } + }, + { label => 'write-traffic', nlabel => 'port.traffic.write.usage.bitspersecond', set => { + key_values => [ { name => 'data_write_numeric' }, { name => 'display' } ], + output_template => 'write traffic: %s %s/s', + per_second => 1, output_change_bytes => 2, + perfdatas => [ + { value => 'data_write_numeric_per_second', template => '%d', + unit => 'b/s', min => 0, label_extra_instance => 1 } + ] + } + } + ]; + + $self->{maps_counters}->{interfaces} = [ + { label => 'interface-disparity-errors', nlabel => 'port.interface.disparity.errors.count', set => { + key_values => [ { name => 'disparity_errors' }, { name => 'display' } ], + output_template => 'disparity errors: %s', + perfdatas => [ + { value => 'disparity_errors_absolute', template => '%d', + min => 0, label_extra_instance => 1 } + ] + } + }, + { label => 'interface-lost-dwords', nlabel => 'port.interface.lost.dwords.count', set => { + key_values => [ { name => 'lost_dwords' }, { name => 'display' } ], + output_template => 'lost dwords: %s', + perfdatas => [ + { value => 'lost_dwords_absolute', template => '%d', + min => 0, label_extra_instance => 1 } + ] + } + }, + { label => 'interface-invalid-dwords', nlabel => 'port.interface.invalid.dwords.count', set => { + key_values => [ { name => 'lost_dwords' }, { name => 'display' } ], + output_template => 'invalid dwords: %s', + perfdatas => [ + { value => 'invalid_dwords_absolute', template => '%d', + min => 0, label_extra_instance => 1 } + ] + } + } + ]; +} + +sub port_long_output { + my ($self, %options) = @_; + + return "checking port '" . $options{instance_value}->{display} . "'"; +} + +sub prefix_port_output { + my ($self, %options) = @_; + + return "port '" . $options{instance_value}->{display} . "' "; +} + +sub prefix_interface_output { + my ($self, %options) = @_; + + return "interface '" . $options{instance_value}->{display} . "' "; +} + +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 => { + 'unknown-port-status:s' => { name => 'unknown_port_status', default => '%{health} =~ /unknown/i' }, + 'warning-port-status:s' => { name => 'warning_port_status', default => '%{health} =~ /degraded/i' }, + 'critical-port-status:s' => { name => 'critical_port_status', default => '%{health} =~ /fault/i' } + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->change_macros(macros => ['warning_port_status', 'critical_port_status', 'unknown_port_status']); +} + +my $mapping_status = { + 0 => 'up', + 1 => 'down', + 2 => 'notInstalled' +}; +my $mapping_health = { + 0 => 'ok', 1 => 'degraded', 2 => 'fault', 3 => 'unknown', 4 => 'notAvailable' +}; + +sub manage_selection { + my ($self, %options) = @_; + + my $result_ports = $options{custom}->request_api(method => 'GET', url_path => '/api/show/ports'); + my $result_ports_stats = $options{custom}->request_api(method => 'GET', url_path => '/api/show/host-port-statistics'); + my $result_logical_interfaces = $options{custom}->request_api(method => 'GET', url_path => '/api/show/host-phy-statistics'); + + my $mapping_ports = {}; + + $self->{ports} = {}; + foreach my $port (@{$result_ports->{port}}) { + my $port_name = $port->{port}; + $mapping_ports->{ $port->{'durable-id'} } = $port_name; + + $self->{ports}->{$port_name} = { + display => $port_name, + port_global => { + display => $port_name, + health => $mapping_health->{ $port->{'health-numeric'} }, + status => $mapping_status->{ $port->{'status-numeric'} } + }, + interfaces => {} + }; + } + + foreach (@{$result_ports_stats->{'host-port-statistics'}}) { + next if (!defined($mapping_ports->{ $_->{'durable-id'} })); + + $self->{ports}->{ $mapping_ports->{ $_->{'durable-id'} } }->{port_global}->{number_of_reads} = $_->{'number-of-reads'}; + $self->{ports}->{ $mapping_ports->{ $_->{'durable-id'} } }->{port_global}->{number_of_writes} = $_->{'number-of-writes'}; + $self->{ports}->{ $mapping_ports->{ $_->{'durable-id'} } }->{port_global}->{data_read_numeric} = $_->{'data-read-numeric'}; + $self->{ports}->{ $mapping_ports->{ $_->{'durable-id'} } }->{port_global}->{data_write_numeric} = $_->{'data-write-numeric'}; + + } + + foreach (@{$result_logical_interfaces->{'sas-host-phy-statistics'}}) { + next if ($self->{ports}->{ $_->{port} }); + + $self->{ports}->{ $_->{port} }->{interfaces}->{ $_->{phy} } = { + display => $_->{phy}, + disparity_errors => $_->{'disparity-errors'}, + invalid_dwords => $_->{'invalid-dwords'}, + lost_dwords => $_->{'lost-dwords'} + }; + } + + $self->{cache_name} = 'dell_me4_' . $self->{mode} . '_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); +} + +1; + +__END__ + +=head1 MODE + +Check interfaces. + +=over 8 + +=item B<--unknown-port-status> + +Set unknown threshold for status (Default: '%{status} =~ /unknown/i'). +Can used special variables like: %{status}, %{health}, %{display} + +=item B<--warning-port-status> + +Set warning threshold for status (Default: '%{status} =~ /degraded/i'). +Can used special variables like: %{status}, %{health}, %{display} + +=item B<--critical-port-status> + +Set critical threshold for status (Default: '%{status} =~ /fault/i'). +Can used special variables like: %{status}, %{health}, %{display} + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'read-iops', 'write-iops', 'read-traffic', 'write-traffic', +'interface-disparity-errors', 'interface-lost-dwords', 'interface-invalid-dwords'. + +=back + +=cut diff --git a/storage/dell/me4/restapi/plugin.pm b/storage/dell/me4/restapi/plugin.pm index e044c3d94..ddb9a2c2d 100644 --- a/storage/dell/me4/restapi/plugin.pm +++ b/storage/dell/me4/restapi/plugin.pm @@ -33,9 +33,10 @@ sub new { %{ $self->{modes} } = ( 'controller-statistics' => 'storage::dell::me4::restapi::mode::controllerstatistics', 'hardware' => 'storage::dell::me4::restapi::mode::hardware', + 'interfaces' => 'storage::dell::me4::restapi::mode::interfaces', 'list-controllers' => 'storage::dell::me4::restapi::mode::listcontrollers', 'list-volumes' => 'storage::dell::me4::restapi::mode::listvolumes', - 'volume-statistics' => 'storage::dell::me4::restapi::mode::volumestatistics', + 'volume-statistics' => 'storage::dell::me4::restapi::mode::volumestatistics' ); $self->{custom_modes}{api} = 'storage::dell::me4::restapi::custom::api'; diff --git a/storage/netapp/santricity/restapi/mode/storagecontrollers.pm b/storage/netapp/santricity/restapi/mode/storagecontrollers.pm index 7ac1d81e9..b8af42419 100644 --- a/storage/netapp/santricity/restapi/mode/storagecontrollers.pm +++ b/storage/netapp/santricity/restapi/mode/storagecontrollers.pm @@ -217,7 +217,7 @@ Check storage controllers. =item B<--filter-counters> Only display some counters (regexp can be used). -Example: --filter-counters='volume-status' +Example: --filter-counters='controller-status' =item B<--filter-storage-name> @@ -245,7 +245,7 @@ Can used special variables like: %{status}, %{display} =item B<--warning-*> B<--critical-*> Thresholds. -Can be: 'read' (B/s), 'write' (B/s), 'read-iops', 'write-iops'. +Can be: 'cpu-utilization' (%), 'read' (B/s), 'write' (B/s), 'read-iops', 'write-iops'. =back From 4081bbfab522bf2f11ce96b6f0eee07423961e55 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 7 May 2020 10:42:32 +0200 Subject: [PATCH 199/283] add dell me4 interfaces --- storage/dell/me4/restapi/mode/interfaces.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/storage/dell/me4/restapi/mode/interfaces.pm b/storage/dell/me4/restapi/mode/interfaces.pm index 5aee01ee5..0936724b2 100644 --- a/storage/dell/me4/restapi/mode/interfaces.pm +++ b/storage/dell/me4/restapi/mode/interfaces.pm @@ -219,9 +219,9 @@ sub manage_selection { $self->{ports}->{ $_->{port} }->{interfaces}->{ $_->{phy} } = { display => $_->{phy}, - disparity_errors => $_->{'disparity-errors'}, - invalid_dwords => $_->{'invalid-dwords'}, - lost_dwords => $_->{'lost-dwords'} + disparity_errors => int($_->{'disparity-errors'}), + invalid_dwords => int($_->{'invalid-dwords'}), + lost_dwords => int($_->{'lost-dwords'}) }; } From ebf501a921d581e1ddf7c63da30efe073b902b7e Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 7 May 2020 11:04:56 +0200 Subject: [PATCH 200/283] update changelog --- changelog | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/changelog b/changelog index 9204b28dd..4b477357f 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,17 @@ +2020-XX-XX Quentin Garnier + * Plugin added: Ruckus SmartZone SNMP + * Plugin added: Ruckus ZoneDirector SNMP + * Plugin added: Ruckus ICX SNMP + * Plugin added: Dell Xseries SNMP + * Plugin added: Adva FSP150 SNMP + * Plugin added: Lenovo Iomega SNMP + * Plugin added: Netapp Santricity Rest API + * Plugin added: Bluemind + * Plugin added: Mulesoft Rest API + * Plugin added: Salesforce Rest API + * Break: [netapp/snmp] move directory + * Break: [netapp/restapi] move directory + 2020-04-10 Quentin Garnier * Plugin added: Dell OS10 SNMP * Plugin added: Sirportly notification From 19e58ca3db4944e036b3a95930c0e3fd950066ca Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 7 May 2020 16:40:22 +0200 Subject: [PATCH 201/283] add unit for nethost --- apps/vmware/connector/mode/nethost.pm | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/apps/vmware/connector/mode/nethost.pm b/apps/vmware/connector/mode/nethost.pm index 61ac63ff1..dc2da0c98 100644 --- a/apps/vmware/connector/mode/nethost.pm +++ b/apps/vmware/connector/mode/nethost.pm @@ -408,17 +408,11 @@ Can used special variables like: %{link_status}, %{display} Set critical threshold for status (Default: '%{link_status} !~ /up/'). Can used special variables like: %{link_status}, %{display} -=item B<--warning-*> +=item B<--warning-*> B<--critical-*> -Threshold warning. -Can be: 'host-traffic-in', 'host-traffic-out', 'vswitch-traffic-in', 'vswitch-traffic-out', -'link-traffic-in', 'link-traffic-out', 'link-dropped-in', 'link-dropped-out'. - -=item B<--critical-*> - -Threshold critical. -Can be: 'host-traffic-in', 'host-traffic-out', 'vswitch-traffic-in', 'vswitch-traffic-out', -'link-traffic-in', 'link-traffic-out', 'link-dropped-in', 'link-dropped-out'. +Thresholds. +Can be: 'host-traffic-in' (b/s), 'host-traffic-out' (b/s), 'vswitch-traffic-in' (b/s), 'vswitch-traffic-out' (b/s), +'link-traffic-in' (%), 'link-traffic-out' (%), 'link-dropped-in', 'link-dropped-out'. =item B<--no-proxyswitch> From b9d092734ca19f6489081a7d9ebb5f1662c7c924 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 11 May 2020 09:46:59 +0200 Subject: [PATCH 202/283] Fix #1987 --- network/nortel/standard/snmp/mode/cpu.pm | 133 ++++++++++++-------- network/nortel/standard/snmp/mode/memory.pm | 117 +++++++++++++---- 2 files changed, 171 insertions(+), 79 deletions(-) diff --git a/network/nortel/standard/snmp/mode/cpu.pm b/network/nortel/standard/snmp/mode/cpu.pm index 166bb8f0e..0801b93f9 100644 --- a/network/nortel/standard/snmp/mode/cpu.pm +++ b/network/nortel/standard/snmp/mode/cpu.pm @@ -33,94 +33,124 @@ sub set_counters { ]; $self->{maps_counters}->{cpu} = [ - { label => 'total', set => { - key_values => [ { name => 'total' }, { name => 'num' } ], - output_template => 'Total CPU Usage : %.2f %%', - perfdatas => [ - { label => 'cpu_total', value => 'total_absolute', template => '%.2f', min => 0, max => 100, unit => '%', - label_extra_instance => 1, instance_use => 'num_absolute' }, - ], - } - }, - { label => '1m', set => { + { label => '1m', nlabel => 'cpu.utilization.1m.percentage', set => { key_values => [ { name => '1m' }, { name => 'num' } ], - output_template => '1 minute : %.2f %%', + output_template => '%.2f %% (1min)', perfdatas => [ { label => 'cpu_1min', value => '1m_absolute', template => '%.2f', - min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'num_absolute' }, - ], + min => 0, max => 100, unit => '%', label_extra_instance => 1 } + ] } }, - { label => '10m', set => { + { label => '5m', nlabel => 'cpu.utilization.5m.percentage', set => { + key_values => [ { name => '5m' }, { name => 'num' } ], + output_template => '%.2f %% (5min)', + perfdatas => [ + { label => 'cpu_5min', value => '5m_absolute', template => '%.2f', + min => 0, max => 100, unit => '%', label_extra_instance => 1 } + ] + } + }, + { label => '10m', nlabel => 'cpu.utilization.10m.percentage', set => { key_values => [ { name => '10m' }, { name => 'num' } ], - output_template => '10 minutes : %.2f %%', + output_template => '%.2f %% (10min)', perfdatas => [ { label => 'cpu_10min', value => '10m_absolute', template => '%.2f', - min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'num_absolute' }, - ], + min => 0, max => 100, unit => '%', label_extra_instance => 1 } + ] } }, - { label => '1h', set => { + { label => '1h', nlabel => 'cpu.utilization.1h.percentage', set => { key_values => [ { name => '1h' }, { name => 'num' } ], - output_template => '1 hour : %.2f %%', + output_template => '%.2f %% (1h)', perfdatas => [ { label => 'cpu_1h', value => '1h_absolute', template => '%.2f', - min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'num_absolute' }, - ], + min => 0, max => 100, unit => '%', label_extra_instance => 1 } + ] } - }, + } ]; } sub prefix_cpu_output { my ($self, %options) = @_; - - return "CPU '" . $options{instance_value}->{num} . "' "; + + return "CPU '" . $options{instance_value}->{num} . "' usage "; } sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - - $options{options}->add_options(arguments => - { - }); - + + $options{options}->add_options(arguments => { + }); + return $self; } my $mapping = { - s5ChasUtilTotalCPUUsage => { oid => '.1.3.6.1.4.1.45.1.6.3.8.1.1.4' }, s5ChasUtilCPUUsageLast1Minute => { oid => '.1.3.6.1.4.1.45.1.6.3.8.1.1.5' }, s5ChasUtilCPUUsageLast10Minutes => { oid => '.1.3.6.1.4.1.45.1.6.3.8.1.1.6' }, - s5ChasUtilCPUUsageLast1Hour => { oid => '.1.3.6.1.4.1.45.1.6.3.8.1.1.7' }, + s5ChasUtilCPUUsageLast1Hour => { oid => '.1.3.6.1.4.1.45.1.6.3.8.1.1.7' } }; my $oid_rcSysCpuUtil = '.1.3.6.1.4.1.2272.1.1.20'; # without .0 my $oid_s5ChasUtilEntry = '.1.3.6.1.4.1.45.1.6.3.8.1.1'; +sub check_khi { + my ($self, %options) = @_; + + my $oid_rcKhiSlotCpu5MinAve = '.1.3.6.1.4.1.2272.1.85.10.1.1.3'; + my $snmp_result = $options{snmp}->get_table( + oid => $oid_rcKhiSlotCpu5MinAve, + nothing_quit => 1 + ); + + foreach (keys %$snmp_result) { + /.(\d+)$/; + + $self->{cpu}->{'slot_' . $1} = { + num => 'slot_' . $1, + '5m' => $snmp_result->{$_} + }; + } +} + sub manage_selection { my ($self, %options) = @_; - $self->{results} = $options{snmp}->get_multiple_table(oids => [ - { oid => $oid_rcSysCpuUtil }, - { oid => $oid_s5ChasUtilEntry }, - ], nothing_quit => 1); - + my $snmp_result = $options{snmp}->get_multiple_table( + oids => [ + { oid => $oid_rcSysCpuUtil }, + { + oid => $oid_s5ChasUtilEntry, + start => $mapping->{s5ChasUtilCPUUsageLast1Minute}->{oid}, + end => $mapping->{s5ChasUtilCPUUsageLast1Hour}->{oid} + } + ] + ); + $self->{cpu} = {}; - foreach my $oid (keys %{$self->{results}->{$oid_s5ChasUtilEntry}}) { - next if ($oid !~ /^$mapping->{s5ChasUtilTotalCPUUsage}->{oid}\.(.*)$/); + foreach my $oid (keys %{$snmp_result->{$oid_s5ChasUtilEntry}}) { + next if ($oid !~ /^$mapping->{s5ChasUtilCPUUsageLast1Minute}->{oid}\.(.*)$/); my $instance = $1; - my $result = $options{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_s5ChasUtilEntry}, instance => $instance); + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result->{$oid_s5ChasUtilEntry}, instance => $instance); - $self->{cpu}->{$instance} = { num => $instance, total => $result->{s5ChasUtilTotalCPUUsage}, - '1m' => $result->{s5ChasUtilCPUUsageLast1Minute}, '10m' => $result->{s5ChasUtilCPUUsageLast10Minutes}, - '1h' => $result->{s5ChasUtilCPUUsageLast1Hour} }; + $self->{cpu}->{$instance} = { + num => $instance, + '1m' => $result->{s5ChasUtilCPUUsageLast1Minute}, + '10m' => $result->{s5ChasUtilCPUUsageLast10Minutes}, + '1h' => $result->{s5ChasUtilCPUUsageLast1Hour} + }; } - - if (scalar(keys %{$self->{results}->{$oid_rcSysCpuUtil}}) > 0) { - $self->{cpu}->{0} = { num => 0, total => $self->{results}->{$oid_rcSysCpuUtil}->{$oid_rcSysCpuUtil . '.0'} }; + + if (scalar(keys %{$snmp_result->{$oid_rcSysCpuUtil}}) > 0) { + $self->{cpu}->{0} = { num => 0, total => $snmp_result->{$oid_rcSysCpuUtil}->{$oid_rcSysCpuUtil . '.0'} }; + } + + if (scalar(keys %{$self->{cpu}}) <= 0) { + $self->check_khi(snmp => $options{snmp}); } } @@ -137,17 +167,12 @@ Check CPU usages. =item B<--filter-counters> Only display some counters (regexp can be used). -Example: --filter-counters='^(1m|10m)$' +Example: --filter-counters='1m|10m' -=item B<--warning-*> +=item B<--warning-*> B<--critical-*> -Threshold warning. -Can be: 'total', '1m', '5m', '10m', '1h'. - -=item B<--critical-*> - -Threshold critical. -Can be: 'total', '1m', '5m', '10m', '1h'. +Thresholds. +Can be: '1m', '5m', '10m', '1h'. =back diff --git a/network/nortel/standard/snmp/mode/memory.pm b/network/nortel/standard/snmp/mode/memory.pm index 0a89d76cb..6a18a407b 100644 --- a/network/nortel/standard/snmp/mode/memory.pm +++ b/network/nortel/standard/snmp/mode/memory.pm @@ -25,23 +25,54 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; +sub custom_usage_output { + my ($self, %options) = @_; + + return sprintf( + 'total: %s %s used: %s %s (%.2f%%) free: %s %s (%.2f%%)', + $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_absolute}), + $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_absolute}), + $self->{result_values}->{prct_used_absolute}, + $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute}), + $self->{result_values}->{prct_free_absolute} + ); +} + sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ - { name => 'memory', type => 1, cb_prefix_output => 'prefix_memory_output', message_multiple => 'All memory usages are ok' } + { name => 'memory', type => 1, cb_prefix_output => 'prefix_memory_output', message_multiple => 'All memory usages are ok', skipped_code => { -10 => 1 } } ]; $self->{maps_counters}->{memory} = [ - { label => 'usage', set => { - key_values => [ { name => 'used' }, { name => 'display' } ], - output_template => 'Used : %.2f %%', + { label => 'usage', display_ok => 0, nlabel => 'memory.usage.bytes', set => { + key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'display' } ], + closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ - { label => 'used', value => 'used_absolute', template => '%.2f', min => 0, max => 100, unit => '%', - label_extra_instance => 1, instance_use => 'display_absolute' }, - ], + { value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute', + unit => 'B', cast_int => 1, label_extra_instance => 1 } + ] } }, + { label => 'usage-free', display_ok => 0, nlabel => 'memory.free.bytes', set => { + key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'display' } ], + closure_custom_output => $self->can('custom_usage_output'), + perfdatas => [ + { value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute', + unit => 'B', cast_int => 1, label_extra_instance => 1 } + ] + } + }, + { label => 'usage-prct', nlabel => 'memory.usage.percentage', set => { + key_values => [ { name => 'prct_used' }, { name => 'display' } ], + output_template => 'used: %.2f %%', + perfdatas => [ + { value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, unit => '%', + label_extra_instance => 1 }, + ] + } + } ]; } @@ -53,33 +84,72 @@ sub prefix_memory_output { sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); bless $self, $class; - - $options{options}->add_options(arguments => - { - }); - + + $options{options}->add_options(arguments => { + }); + return $self; } my $mapping = { - s5ChasUtilMemoryAvailable => { oid => '.1.3.6.1.4.1.45.1.6.3.8.1.1.9' }, + s5ChasUtilMemoryAvailable => { oid => '.1.3.6.1.4.1.45.1.6.3.8.1.1.9' } }; +my $mapping_khi = { + rcKhiSlotMemUsed => { oid => '.1.3.6.1.4.1.2272.1.85.10.1.1.6' }, # KB + rcKhiSlotMemFree => { oid => '.1.3.6.1.4.1.2272.1.85.10.1.1.7' } # KB +}; +my $oid_rcKhiSlotPerfEntry = '.1.3.6.1.4.1.2272.1.85.10.1.1'; + +sub check_khi { + my ($self, %options) = @_; + + my $snmp_result = $options{snmp}->get_table( + oid => $oid_rcKhiSlotPerfEntry, + start => $mapping_khi->{rcKhiSlotMemUsed}->{oid}, + end => $mapping_khi->{rcKhiSlotMemFree}->{oid}, + nothing_quit => 1 + ); + + foreach (keys %$snmp_result) { + next if (! /^$mapping_khi->{rcKhiSlotMemUsed}->{oid}\.(\d+)$/); + my $instance = $1; + my $result = $options{snmp}->map_instance(mapping => $mapping_khi, results => $snmp_result, instance => $instance); + + my $total = $result->{rcKhiSlotMemUsed} * 1024 + $result->{rcKhiSlotMemFree} * 1024; + $self->{memory}->{'slot_' . $1} = { + display => 'slot_' . $1, + used => $result->{rcKhiSlotMemUsed} * 1024, + free => $result->{rcKhiSlotMemFree} * 1024, + prct_used => $result->{rcKhiSlotMemUsed} * 1024 / $total, + prct_free => $result->{rcKhiSlotMemFree} * 1024 / $total, + total => $total + }; + } +} sub manage_selection { my ($self, %options) = @_; + my $snmp_result = $options{snmp}->get_table( + oid => $mapping->{s5ChasUtilMemoryAvailable}->{oid}, + ); + $self->{memory} = {}; - $self->{results} = $options{snmp}->get_table(oid => $mapping->{s5ChasUtilMemoryAvailable}->{oid}, - nothing_quit => 1); foreach my $oid (keys %{$self->{results}}) { next if ($oid !~ /^$mapping->{s5ChasUtilMemoryAvailable}->{oid}\.(.*)/); my $instance = $1; - my $result = $options{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => $instance); + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance); - $self->{memory}->{$instance} = { display => $instance, - used => 100 - $result->{s5ChasUtilMemoryAvailable}}; + $self->{memory}->{$instance} = { + display => $instance, + prct_used => 100 - $result->{s5ChasUtilMemoryAvailable} + }; + } + + if (scalar(keys %{$self->{memory}}) <= 0) { + $self->check_khi(snmp => $options{snmp}); } } @@ -93,13 +163,10 @@ Check memory usages. =over 8 -=item B<--warning-usage> +=item B<--warning-*> B<--critical-*> -Threshold warning (in percent). - -=item B<--critical-usage> - -Threshold critical (in percent). +Thresholds. +Can be: 'usage' (B), 'usage-free' (B), 'usage-prct' (%). =back From d9d4351655067ff0483e912e236f36f72684157c Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 11 May 2020 09:52:02 +0200 Subject: [PATCH 203/283] set back total for cpu nortel --- network/nortel/standard/snmp/mode/cpu.pm | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/network/nortel/standard/snmp/mode/cpu.pm b/network/nortel/standard/snmp/mode/cpu.pm index 0801b93f9..f95ef9523 100644 --- a/network/nortel/standard/snmp/mode/cpu.pm +++ b/network/nortel/standard/snmp/mode/cpu.pm @@ -33,6 +33,15 @@ sub set_counters { ]; $self->{maps_counters}->{cpu} = [ + { label => 'total', nlabel => 'cpu.utilization.total.percentage', set => { + key_values => [ { name => 'total' }, { name => 'num' } ], + output_template => '%.2f %% (total)', + perfdatas => [ + { label => 'cpu_total', value => 'total_absolute', template => '%.2f', + min => 0, max => 100, unit => '%', label_extra_instance => 1 } + ] + } + }, { label => '1m', nlabel => 'cpu.utilization.1m.percentage', set => { key_values => [ { name => '1m' }, { name => 'num' } ], output_template => '%.2f %% (1min)', @@ -90,6 +99,7 @@ sub new { } my $mapping = { + s5ChasUtilTotalCPUUsage => { oid => '.1.3.6.1.4.1.45.1.6.3.8.1.1.4' }, s5ChasUtilCPUUsageLast1Minute => { oid => '.1.3.6.1.4.1.45.1.6.3.8.1.1.5' }, s5ChasUtilCPUUsageLast10Minutes => { oid => '.1.3.6.1.4.1.45.1.6.3.8.1.1.6' }, s5ChasUtilCPUUsageLast1Hour => { oid => '.1.3.6.1.4.1.45.1.6.3.8.1.1.7' } @@ -139,6 +149,7 @@ sub manage_selection { $self->{cpu}->{$instance} = { num => $instance, + total => $result->{s5ChasUtilTotalCPUUsage}, '1m' => $result->{s5ChasUtilCPUUsageLast1Minute}, '10m' => $result->{s5ChasUtilCPUUsageLast10Minutes}, '1h' => $result->{s5ChasUtilCPUUsageLast1Hour} @@ -172,7 +183,7 @@ Example: --filter-counters='1m|10m' =item B<--warning-*> B<--critical-*> Thresholds. -Can be: '1m', '5m', '10m', '1h'. +Can be: 'total', '1m', '5m', '10m', '1h'. =back From cf4cfbfbc848ea46c6bf83d7aae6682fed9915e9 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 11 May 2020 11:01:46 +0200 Subject: [PATCH 204/283] add vernemq plugin --- apps/mq/vernemq/restapi/custom/api.pm | 220 ++++++++++++++++++++++ apps/mq/vernemq/restapi/mode/clusters.pm | 165 ++++++++++++++++ apps/mq/vernemq/restapi/mode/listeners.pm | 165 ++++++++++++++++ apps/mq/vernemq/restapi/mode/plugins.pm | 99 ++++++++++ apps/mq/vernemq/restapi/mode/sessions.pm | 103 ++++++++++ apps/mq/vernemq/restapi/plugin.pm | 52 +++++ 6 files changed, 804 insertions(+) create mode 100644 apps/mq/vernemq/restapi/custom/api.pm create mode 100644 apps/mq/vernemq/restapi/mode/clusters.pm create mode 100644 apps/mq/vernemq/restapi/mode/listeners.pm create mode 100644 apps/mq/vernemq/restapi/mode/plugins.pm create mode 100644 apps/mq/vernemq/restapi/mode/sessions.pm create mode 100644 apps/mq/vernemq/restapi/plugin.pm diff --git a/apps/mq/vernemq/restapi/custom/api.pm b/apps/mq/vernemq/restapi/custom/api.pm new file mode 100644 index 000000000..a4e498482 --- /dev/null +++ b/apps/mq/vernemq/restapi/custom/api.pm @@ -0,0 +1,220 @@ +# +# Copyright 2020 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::mq::vernemq::restapi::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 => { + 'api-key:s' => { name => 'api_key' }, + 'hostname:s' => { name => 'hostname' }, + 'port:s' => { name => 'port' }, + 'proto:s' => { name => 'proto' }, + 'timeout:s' => { name => 'timeout' }, + 'unknown-http-status:s' => { name => 'unknown_http_status' }, + 'warning-http-status:s' => { name => 'warning_http_status' }, + 'critical-http-status:s' => { name => 'critical_http_status' } + }); + } + $options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1); + + $self->{output} = $options{output}; + $self->{mode} = $options{mode}; + $self->{http} = centreon::plugins::http->new(%options); + + return $self; +} + +sub set_options { + my ($self, %options) = @_; + + $self->{option_results} = $options{option_results}; +} + +sub set_defaults { + my ($self, %options) = @_; + + 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} = (defined($self->{option_results}->{hostname})) ? $self->{option_results}->{hostname} : ''; + $self->{port} = (defined($self->{option_results}->{port})) ? $self->{option_results}->{port} : 8888; + $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->{api_key} = (defined($self->{option_results}->{api_key})) ? $self->{option_results}->{api_key} : undef; + $self->{unknown_http_status} = (defined($self->{option_results}->{unknown_http_status})) ? $self->{option_results}->{unknown_http_status} : '%{http_code} < 200 or %{http_code} >= 300'; + $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(); + } + if (!defined($self->{api_key}) || $self->{api_key} eq '') { + $self->{output}->add_option_msg(short_msg => "Need to specify --api-key option."); + $self->{output}->option_exit(); + } + + return 0; +} + +sub build_options_for_httplib { + my ($self, %options) = @_; + + $self->{option_results}->{hostname} = $self->{api_key} . '@' . $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_port { + my ($self, %options) = @_; + + return $self->{port}; +} + +sub request_api { + my ($self, %options) = @_; + + $self->settings(); + + my $content = do { + local $/ = undef; + if (!open my $fh, "<", '/tmp/plop.txt') { + $self->{output}->add_option_msg(short_msg => "Could not open file $self->{option_results}->{$_} : $!"); + $self->{output}->option_exit(); + } + <$fh>; + }; + #my $content = $self->{http}->request( + # method => defined($options{method}) ? $options{method} : 'GET', + # url_path => '/api/v1' . $options{endpoint}, + # unknown_status => $self->{unknown_http_status}, + # warning_status => $self->{warning_http_status}, + # critical_status => $self->{critical_http_status} + #); + + if (!defined($content) || $content 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->utf8->decode($content); + }; + if ($@) { + $self->{output}->add_option_msg(short_msg => "Cannot decode response (add --debug option to display returned content)"); + $self->{output}->option_exit(); + } + + return $decoded; +} + +1; + +__END__ + +=head1 NAME + +VerneMQ Rest API + +=head1 REST API OPTIONS + +VerneMQ Rest API + +=over 8 + +=item B<--hostname> + +Set hostname. + +=item B<--port> + +Port used (Default: 8888) + +=item B<--proto> + +Specify https if needed (Default: 'http') + +=item B<--api-key> + +VerneMQ API Token. + +=item B<--timeout> + +Set timeout in seconds (Default: 10). + +=back + +=head1 DESCRIPTION + +B. + +=cut diff --git a/apps/mq/vernemq/restapi/mode/clusters.pm b/apps/mq/vernemq/restapi/mode/clusters.pm new file mode 100644 index 000000000..0dc8c8618 --- /dev/null +++ b/apps/mq/vernemq/restapi/mode/clusters.pm @@ -0,0 +1,165 @@ +# +# Copyright 2020 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::mq::vernemq::restapi::mode::clusters; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); + +sub custom_status_output { + my ($self, %options) = @_; + + return 'status: ' . $self->{result_values}->{status}; +} + +sub prefix_cluster_output { + my ($self, %options) = @_; + + return "Cluster '" . $options{instance_value}->{display} . "' "; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0 }, + { name => 'clusters', type => 1, cb_prefix_output => 'prefix_cluster_output', message_multiple => 'All clusters are ok', skipped_code => { -10 => 1 } }, + ]; + + $self->{maps_counters}->{global} = [ + { label => 'running', nlabel => 'clusters.running.count', display_ok => 0, set => { + key_values => [ { name => 'running' } ], + output_template => 'current clusters running: %s', + perfdatas => [ + { value => 'running_absolute', template => '%s', min => 0 } + ] + } + }, + { label => 'notrunning', nlabel => 'clusters.notrunning.count', display_ok => 0, set => { + key_values => [ { name => 'notrunning' } ], + output_template => 'current clusters not running: %s', + perfdatas => [ + { value => 'notrunning_absolute', template => '%s', min => 0 } + ] + } + } + ]; + + $self->{maps_counters}->{clusters} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'status' }, { name => 'display' } ], + closure_custom_calc => \&catalog_status_calc, + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold + } + } + ]; +} + +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' }, + 'unknown-status:s' => { name => 'unknown_status', default => '' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '%{status} eq "notRunning"' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->change_macros(macros => ['warning_status', 'critical_status', 'unknown_status']); +} + +sub manage_selection { + my ($self, %options) = @_; + + my $clusters = $options{custom}->request_api(endpoint => '/cluster/show'); + + $self->{global} = { running => 0, notrunning => 0 }; + $self->{clusters} = {}; + foreach (@{$clusters->{table}}) { + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $_->{Node} !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping cluster '" . $_->{Node} . "': no matching filter.", debug => 1); + next; + } + + $_->{Running} ? $self->{global}->{running}++ : $self->{global}->{notrunning}++; + $self->{clusters}->{$_->{Node}} = { + display => $_->{Node}, + status => $_->{Running} ? 'running' : 'notRunning' + }; + } + + if (scalar(keys %{$self->{clusters}}) <= 0) { + $self->{output}->add_option_msg(short_msg => "No cluster found"); + $self->{output}->option_exit(); + } +} + +1; + +__END__ + +=head1 MODE + +Check clusters. + +=over 8 + +=item B<--filter-name> + +Filter cluster name (can be a regexp). + +=item B<--unknown-status> + +Set unknown threshold for status. +Can used special variables like: %{status}, %{display} + +=item B<--warning-status> + +Set warning threshold for status. +Can used special variables like: %{status}, %{display} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{status} eq "notRunning"'). +Can used special variables like: %{status}, %{display} + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'running', 'notrunning'. + +=back + +=cut diff --git a/apps/mq/vernemq/restapi/mode/listeners.pm b/apps/mq/vernemq/restapi/mode/listeners.pm new file mode 100644 index 000000000..8da916ebe --- /dev/null +++ b/apps/mq/vernemq/restapi/mode/listeners.pm @@ -0,0 +1,165 @@ +# +# Copyright 2020 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::mq::vernemq::restapi::mode::listeners; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); + +sub custom_status_output { + my ($self, %options) = @_; + + return 'status: ' . $self->{result_values}->{status}; +} + +sub prefix_listener_output { + my ($self, %options) = @_; + + return "Listener '" . $options{instance_value}->{display} . "' "; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0 }, + { name => 'listeners', type => 1, cb_prefix_output => 'prefix_listener_output', message_multiple => 'All listeners are ok', skipped_code => { -10 => 1 } }, + ]; + + $self->{maps_counters}->{global} = [ + { label => 'running', nlabel => 'listeners.running.count', display_ok => 0, set => { + key_values => [ { name => 'running' } ], + output_template => 'current listeners running: %s', + perfdatas => [ + { value => 'running_absolute', template => '%s', min => 0 } + ] + } + }, + { label => 'notrunning', nlabel => 'listeners.notrunning.count', display_ok => 0, set => { + key_values => [ { name => 'notrunning' } ], + output_template => 'current listeners not running: %s', + perfdatas => [ + { value => 'notrunning_absolute', template => '%s', min => 0 } + ] + } + } + ]; + + $self->{maps_counters}->{listeners} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'status' }, { name => 'display' } ], + closure_custom_calc => \&catalog_status_calc, + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold + } + } + ]; +} + +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-type:s' => { name => 'filter_type' }, + 'unknown-status:s' => { name => 'unknown_status', default => '' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '%{status} ne "running"' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->change_macros(macros => ['warning_status', 'critical_status', 'unknown_status']); +} + +sub manage_selection { + my ($self, %options) = @_; + + my $clusters = $options{custom}->request_api(endpoint => '/listener/show'); + + $self->{global} = { running => 0, notrunning => 0 }; + $self->{listeners} = {}; + foreach (@{$clusters->{table}}) { + if (defined($self->{option_results}->{filter_type}) && $self->{option_results}->{filter_type} ne '' && + $_->{type} !~ /$self->{option_results}->{filter_type}/) { + $self->{output}->output_add(long_msg => "skipping listeners '" . $_->{type} . "': no matching filter.", debug => 1); + next; + } + + $_->{status} eq 'running' ? $self->{global}->{running}++ : $self->{global}->{notrunning}++; + $self->{listeners}->{$_->{type}} = { + display => $_->{type}, + status => $_->{status} + }; + } + + if (scalar(keys %{$self->{listeners}}) <= 0) { + $self->{output}->add_option_msg(short_msg => "No listener found"); + $self->{output}->option_exit(); + } +} + +1; + +__END__ + +=head1 MODE + +Check listeners. + +=over 8 + +=item B<--filter-type> + +Filter listener type (can be a regexp). + +=item B<--unknown-status> + +Set unknown threshold for status. +Can used special variables like: %{status}, %{display} + +=item B<--warning-status> + +Set warning threshold for status. +Can used special variables like: %{status}, %{display} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{status} ne "running"'). +Can used special variables like: %{status}, %{display} + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'running', 'notrunning'. + +=back + +=cut diff --git a/apps/mq/vernemq/restapi/mode/plugins.pm b/apps/mq/vernemq/restapi/mode/plugins.pm new file mode 100644 index 000000000..49fef8ace --- /dev/null +++ b/apps/mq/vernemq/restapi/mode/plugins.pm @@ -0,0 +1,99 @@ +# +# Copyright 2020 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::mq::vernemq::restapi::mode::plugins; + +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, skipped_code => { -10 => 1 } } + ]; + + $self->{maps_counters}->{global} = [ + { label => 'total', nlabel => 'plugins.total.count', set => { + key_values => [ { name => 'total' } ], + output_template => 'current total plugins: %s', + perfdatas => [ + { value => 'total_absolute', template => '%s', min => 0 } + ] + } + } + ]; +} + +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' } + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + my $plugins = $options{custom}->request_api( + endpoint => '/plugin/show' + ); + + $self->{global} = { total => 0 }; + foreach (@{$plugins->{table}}) { + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $_->{Plugin} !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping plugin '" . $_->{Plugin} . "': no matching filter.", debug => 1); + next; + } + + $self->{global}->{total}++; + } +} + +1; + +__END__ + +=head1 MODE + +Check plugins. + +=over 8 + +=item B<--filter-name> + +Filter plugin name (can be a regexp). + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'total'. + +=back + +=cut diff --git a/apps/mq/vernemq/restapi/mode/sessions.pm b/apps/mq/vernemq/restapi/mode/sessions.pm new file mode 100644 index 000000000..d3f2cdde7 --- /dev/null +++ b/apps/mq/vernemq/restapi/mode/sessions.pm @@ -0,0 +1,103 @@ +# +# Copyright 2020 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::mq::vernemq::restapi::mode::sessions; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub prefix_session_output { + my ($self, %options) = @_; + + return 'Sessions '; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0, cb_prefix_output => 'prefix_session_output', skipped_code => { -10 => 1 } } + ]; + + $self->{maps_counters}->{global} = [ + { label => 'online', nlabel => 'sessions.online.count', set => { + key_values => [ { name => 'online' } ], + output_template => 'current online: %s', + perfdatas => [ + { value => 'online_absolute', template => '%s', min => 0 } + ] + } + }, + { label => 'total', nlabel => 'sessions.total.count', set => { + key_values => [ { name => 'total' } ], + output_template => 'current total: %s', + perfdatas => [ + { value => 'total_absolute', template => '%s', min => 0 } + ] + } + } + ]; +} + +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 => { + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + my $sessions = $options{custom}->request_api( + endpoint => '/session/show' + ); + + $self->{global} = { total => 0, online => 0 }; + foreach (@{$sessions->{table}}) { + $self->{global}->{online}++ if ($_->{is_online}); + $self->{global}->{total}++; + } +} + +1; + +__END__ + +=head1 MODE + +Check sessions. + +=over 8 + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'total', 'online'. + +=back + +=cut diff --git a/apps/mq/vernemq/restapi/plugin.pm b/apps/mq/vernemq/restapi/plugin.pm new file mode 100644 index 000000000..a861913d3 --- /dev/null +++ b/apps/mq/vernemq/restapi/plugin.pm @@ -0,0 +1,52 @@ +# +# Copyright 2020 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::mq::vernemq::restapi::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} = '0.1'; + %{ $self->{modes} } = ( + 'clusters' => 'apps::mq::vernemq::restapi::mode::clusters', + 'listeners' => 'apps::mq::vernemq::restapi::mode::listeners', + 'plugins' => 'apps::mq::vernemq::restapi::mode::plugins', + 'sessions' => 'apps::mq::vernemq::restapi::mode::sessions' + ); + + $self->{custom_modes}{api} = 'apps::mq::vernemq::restapi::custom::api'; + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check VerneMQ using Rest API. + +=cut From 72fa807d03c38e18408cfc95345e57bce4fd14ee Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 11 May 2020 11:02:06 +0200 Subject: [PATCH 205/283] add vernemq plugin --- apps/mq/vernemq/restapi/custom/api.pm | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/apps/mq/vernemq/restapi/custom/api.pm b/apps/mq/vernemq/restapi/custom/api.pm index a4e498482..b59b70166 100644 --- a/apps/mq/vernemq/restapi/custom/api.pm +++ b/apps/mq/vernemq/restapi/custom/api.pm @@ -143,22 +143,13 @@ sub request_api { my ($self, %options) = @_; $self->settings(); - - my $content = do { - local $/ = undef; - if (!open my $fh, "<", '/tmp/plop.txt') { - $self->{output}->add_option_msg(short_msg => "Could not open file $self->{option_results}->{$_} : $!"); - $self->{output}->option_exit(); - } - <$fh>; - }; - #my $content = $self->{http}->request( - # method => defined($options{method}) ? $options{method} : 'GET', - # url_path => '/api/v1' . $options{endpoint}, - # unknown_status => $self->{unknown_http_status}, - # warning_status => $self->{warning_http_status}, - # critical_status => $self->{critical_http_status} - #); + my $content = $self->{http}->request( + method => defined($options{method}) ? $options{method} : 'GET', + url_path => '/api/v1' . $options{endpoint}, + unknown_status => $self->{unknown_http_status}, + warning_status => $self->{warning_http_status}, + critical_status => $self->{critical_http_status} + ); if (!defined($content) || $content eq '') { $self->{output}->add_option_msg(short_msg => "API returns empty content [code: '" . $self->{http}->get_code() . "'] [message: '" . $self->{http}->get_message() . "']"); From d8accac7759b5642d190e9c75a0ccfa413f00793 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 11 May 2020 13:54:40 +0200 Subject: [PATCH 206/283] add active msq --- .../java/solr/jmx/mode/requesthandlerusage.pm | 11 +- apps/mq/activemq/jmx/mode/brokers.pm | 284 ++++++++++++++++++ apps/mq/activemq/jmx/mode/listbrokers.pm | 116 +++++++ apps/mq/activemq/jmx/plugin.pm | 50 +++ 4 files changed, 455 insertions(+), 6 deletions(-) create mode 100644 apps/mq/activemq/jmx/mode/brokers.pm create mode 100644 apps/mq/activemq/jmx/mode/listbrokers.pm create mode 100644 apps/mq/activemq/jmx/plugin.pm diff --git a/apps/java/solr/jmx/mode/requesthandlerusage.pm b/apps/java/solr/jmx/mode/requesthandlerusage.pm index 735f5d26f..244f703de 100644 --- a/apps/java/solr/jmx/mode/requesthandlerusage.pm +++ b/apps/java/solr/jmx/mode/requesthandlerusage.pm @@ -77,12 +77,11 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; - - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name', default => '(/select|/update)$' }, - }); - + + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name', default => '(/select|/update)$' } + }); + return $self; } diff --git a/apps/mq/activemq/jmx/mode/brokers.pm b/apps/mq/activemq/jmx/mode/brokers.pm new file mode 100644 index 000000000..b8f1c746b --- /dev/null +++ b/apps/mq/activemq/jmx/mode/brokers.pm @@ -0,0 +1,284 @@ +# +# Copyright 2020 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::mq::activemq::jmx::mode::brokers; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use Digest::MD5 qw(md5_hex); + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'brokers', type => 3, cb_prefix_output => 'prefix_broker_output', cb_long_output => 'broker_long_output', indent_long_output => ' ', message_multiple => 'All brokers are ok', + group => [ + { name => 'global', type => 0, skipped_code => { -10 => 1 } }, + { name => 'queues', display_long => 1, cb_prefix_output => 'prefix_queue_output', message_multiple => 'All queue destinations are ok', type => 1, skipped_code => { -10 => 1 } } + ] + } + ]; + + $self->{maps_counters}->{global} = [ + { label => 'store-usage', nlabel => 'broker.store.usage.percentage', set => { + key_values => [ { name => 'StorePercentUsage' }, { name => 'display' } ], + output_template => 'store usage: %.2f %%', + perfdatas => [ + { value => 'StorePercentUsage_absolute', template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1 } + ] + } + }, + { label => 'temporary-usage', nlabel => 'broker.temporary.usage.percentage', set => { + key_values => [ { name => 'TempPercentUsage' }, { name => 'display' } ], + output_template => 'temporary usage: %.2f %%', + perfdatas => [ + { value => 'TempPercentUsage_absolute', template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1 } + ] + } + }, + { label => 'memory-usage', nlabel => 'broker.memory.usage.percentage', set => { + key_values => [ { name => 'MemoryPercentUsage' }, { name => 'display' } ], + output_template => 'memory usage: %.2f %%', + perfdatas => [ + { value => 'MemoryPercentUsage_absolute', template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1 } + ] + } + } + ]; + + $self->{maps_counters}->{queues} = [ + { label => 'queue-average-enqueue-time', nlabel => 'broker.queue.average.enqueue.time.milliseconds', set => { + key_values => [ { name => 'AverageEnqueueTime' }, { name => 'display' } ], + output_template => 'average time messages remained enqueued: %.3f ms', + perfdatas => [ + { value => 'AverageEnqueueTime_absolute', + template => '%.3f', unit => 'ms', min => 0, label_extra_instance => 1 } + ] + } + }, + { label => 'queue-consumers-connected', nlabel => 'broker.queue.consumers.connected.count', set => { + key_values => [ { name => 'ConsumerCount' }, { name => 'display' } ], + output_template => 'consumers connected: %s', + perfdatas => [ + { value => 'ConsumerCount_absolute', + template => '%s', min => 0, label_extra_instance => 1 } + ] + } + }, + { label => 'queue-producers-connected', nlabel => 'broker.queue.producers.connected.count', display_ok => 0, set => { + key_values => [ { name => 'ProducerCount' }, { name => 'display' } ], + output_template => 'producers connected: %s', + perfdatas => [ + { value => 'ProducerCount_absolute', + template => '%s', min => 0, label_extra_instance => 1 } + ] + } + }, + { label => 'queue-memory-usage', nlabel => 'broker.queue.memory.usage.percentage', display_ok => 0, set => { + key_values => [ { name => 'MemoryPercentUsage' }, { name => 'display' } ], + output_template => 'memory usage: %.2f %%', + perfdatas => [ + { value => 'MemoryPercentUsage_absolute', + template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1 } + ] + } + }, + { label => 'queue-size', nlabel => 'broker.queue.size.count', set => { + key_values => [ { name => 'QueueSize' }, { name => 'display' } ], + output_template => 'queue size: %s', + perfdatas => [ + { value => 'QueueSize_absolute', + template => '%s', min => 0, label_extra_instance => 1 } + ] + } + }, + { label => 'queue-enqueued', nlabel => 'broker.queue.enqueued.count', display_ok => 0, set => { + key_values => [ { name => 'EnqueueCount', diff => 1 }, { name => 'display' } ], + output_template => 'messages enqueued: %s', + perfdatas => [ + { value => 'EnqueueCount_absolute', + template => '%s', min => 0, label_extra_instance => 1 } + ] + } + }, + { label => 'queue-dequeued', nlabel => 'broker.queue.dequeue.count', display_ok => 0, set => { + key_values => [ { name => 'DequeueCount', diff => 1 }, { name => 'display' } ], + output_template => 'messages dequeued: %s', + perfdatas => [ + { value => 'DequeueCount_absolute', + template => '%s', min => 0, label_extra_instance => 1 } + ] + } + }, + { label => 'queue-expired', nlabel => 'broker.queue.expired.count', display_ok => 0, set => { + key_values => [ { name => 'ExpiredCount', diff => 1 }, { name => 'display' } ], + output_template => 'messages expired: %s', + perfdatas => [ + { value => 'ExpiredCount_absolute', + template => '%s', min => 0, label_extra_instance => 1 } + ] + } + }, + { label => 'queue-inflighted', nlabel => 'broker.queue.inflighted.count', display_ok => 0, set => { + key_values => [ { name => 'InFlightCount', diff => 1 }, { name => 'display' } ], + output_template => 'messages in-flighted: %s', + perfdatas => [ + { value => 'InFlightCount_absolute', + template => '%s', min => 0, label_extra_instance => 1 } + ] + } + } + ]; +} + +sub broker_long_output { + my ($self, %options) = @_; + + return "checking broker '" . $options{instance_value}->{display} . "'"; +} + +sub prefix_broker_output { + my ($self, %options) = @_; + + return "Broker '" . $options{instance_value}->{display} . "' "; +} + +sub prefix_qeueue_output { + my ($self, %options) = @_; + + return "queue destination '" . $options{instance_value}->{display} . "' "; +} + +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 => { + 'filter-broker-name:s' => { name => 'filter_broker_name' }, + 'filter-destination-name:s' => { name => 'filter_destination_name' } + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + my $request = [ + { + mbean => 'org.apache.activemq:brokerName=*,destinationName=*,destinationType=Topic,type=Broker', + attributes => [ + { name => 'AverageEnqueueTime' }, { name => 'ConsumerCount' }, + { name => 'ProducerCount' }, { name => 'MemoryPercentUsage' }, + { name => 'QueueSize' }, { name => 'EnqueueCount' }, + { name => 'DequeueCount' }, { name => 'ExpiredCount' }, + { name => 'InFlightCount' } + ] + }, + { + mbean => 'org.apache.activemq:brokerName=*,type=Broker', + attributes => [ + { name => 'StorePercentUsage' }, { name => 'TempPercentUsage' }, + { name => 'MemoryPercentUsage' } + ] + } + ]; + my $result = $options{custom}->get_attributes(request => $request, nothing_quit => 1); + + $self->{cache_name} = 'activemq_' . $self->{mode} . '_' . md5_hex($options{custom}->get_connection_info()) . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' . + (defined($self->{option_results}->{filter_broker_name}) ? md5_hex($self->{option_results}->{filter_broker_name}) : md5_hex('all')) . '_' . + (defined($self->{option_results}->{filter_destination_name}) ? md5_hex($self->{option_results}->{filter_destination_name}) : md5_hex('all')); + + $self->{brokers} = {}; + foreach my $mbean (keys %$result) { + next if ($mbean !~ /org.apache.activemq:brokerName=(.*?),(?:destinationName=(.*?),|type=Broker)/); + my ($broker_name, $destination_name) = ($1, $2); + + if (defined($self->{option_results}->{filter_broker_name}) && $self->{option_results}->{filter_broker_name} ne '' && + $broker_name !~ /$self->{option_results}->{filter_broker_name}/) { + $self->{output}->output_add(long_msg => "skipping '" . $broker_name . "': no matching filter.", debug => 1); + next; + } + + if (!defined($self->{brokers}->{$broker_name})) { + $self->{brokers}->{$broker_name} = { + display => $broker_name, + queues => {} + }; + } + + if (defined($destination_name)) { + if (defined($self->{option_results}->{filter_destination_name}) && $self->{option_results}->{filter_destination_name} ne '' && + $destination_name !~ /$self->{option_results}->{filter_destination_name}/) { + $self->{output}->output_add(long_msg => "skipping '" . $destination_name . "': no matching filter.", debug => 1); + next; + } + + $self->{brokers}->{$broker_name}->{queues}->{$destination_name} = { + display => $destination_name, + %{$result->{$mbean}} + }; + } else { + $self->{brokers}->{$broker_name}->{global} = { + display => $broker_name, + %{$result->{$mbean}} + }; + } + + } + + if (scalar(keys %{$self->{brokers}}) <= 0) { + $self->{output}->output_add(short_msg => 'no brokers found'); + } +} + +1; + +__END__ + +=head1 MODE + +Check brokers. + +=over 8 + +=item B<--filter-broker-name> + +Filter broker name (Can be a regexp). + +=item B<--filter-destination-name> + +Filter destination name (Can be a regexp). + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'store-usage' (%), 'temporary-usage' (%), 'memory-usage' (%), +'queue-average-enqueue-time' (ms), 'queue-consumers-connected', +'queue-producers-connected', 'queue-memory-usage' (%), 'queue-size', +'queue-enqueued', 'queue-dequeued', 'queue-expired', 'queue-inflighted'. + +=back + +=cut diff --git a/apps/mq/activemq/jmx/mode/listbrokers.pm b/apps/mq/activemq/jmx/mode/listbrokers.pm new file mode 100644 index 000000000..0457cbae7 --- /dev/null +++ b/apps/mq/activemq/jmx/mode/listbrokers.pm @@ -0,0 +1,116 @@ +# +# Copyright 2020 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::mq::activemq::jmx::mode::listbrokers; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $options{options}->add_options(arguments => { + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); +} + +sub manage_selection { + my ($self, %options) = @_; + + my $request = [ + { + mbean => 'org.apache.activemq:brokerName=*,type=Broker', + attributes => [ + { name => 'BrokerName' } + ] + } + ]; + my $datas = $options{custom}->get_attributes(request => $request); + + my $results = {}; + foreach (keys %$datas) { + $results->{$datas->{$_}->{BrokerName}} = { name => $datas->{$_}->{BrokerName} }; + } + + return $results; +} + +sub run { + my ($self, %options) = @_; + + my $results = $self->manage_selection(custom => $options{custom}); + foreach (sort keys %$results) { + $self->{output}->output_add( + long_msg => sprintf( + '[name = %s]', + $_ + ) + ); + } + + $self->{output}->output_add( + severity => 'OK', + short_msg => 'List brokers:' + ); + $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']); +} + +sub disco_show { + my ($self, %options) = @_; + + my $results = $self->manage_selection(custom => $options{custom}); + foreach (sort keys %$results) { + $self->{output}->add_disco_entry( + name => $_ + ); + } +} + +1; + +__END__ + +=head1 MODE + +List brokers. + +=over 8 + +=back + +=cut + diff --git a/apps/mq/activemq/jmx/plugin.pm b/apps/mq/activemq/jmx/plugin.pm new file mode 100644 index 000000000..553b638e7 --- /dev/null +++ b/apps/mq/activemq/jmx/plugin.pm @@ -0,0 +1,50 @@ +# +# Copyright 2020 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::mq::activemq::jmx::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} = '0.1'; + %{$self->{modes}} = ( + 'brokers' => 'apps::mq::activemq::jmx::mode::brokers', + 'list-brokers' => 'apps::mq::activemq::jmx::mode::listbrokers' + ); + + $self->{custom_modes}{jolokia} = 'centreon::common::protocols::jmx::custom::jolokia'; + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check ActiveMQ in JMX. Need Jolokia agent. + +=cut From ff96c2886e5464af2552d662ba52eb88e11d2d67 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 11 May 2020 14:51:11 +0200 Subject: [PATCH 207/283] update timelink --- .../timelinkmicro/tms6001/snmp/mode/alarm.pm | 104 ------------------ .../timelinkmicro/tms6001/snmp/mode/alarms.pm | 87 +++++++++++++++ .../tms6001/snmp/mode/antenna.pm | 95 +++++++++++----- .../tms6001/snmp/mode/frequency.pm | 86 ++++++--------- .../timelinkmicro/tms6001/snmp/mode/gnss.pm | 86 ++++++++++----- .../tms6001/snmp/mode/satellites.pm | 87 ++++++--------- .../timelinkmicro/tms6001/snmp/mode/time.pm | 85 ++++++-------- .../timelinkmicro/tms6001/snmp/plugin.pm | 17 ++- 8 files changed, 323 insertions(+), 324 deletions(-) delete mode 100644 hardware/devices/timelinkmicro/tms6001/snmp/mode/alarm.pm create mode 100644 hardware/devices/timelinkmicro/tms6001/snmp/mode/alarms.pm diff --git a/hardware/devices/timelinkmicro/tms6001/snmp/mode/alarm.pm b/hardware/devices/timelinkmicro/tms6001/snmp/mode/alarm.pm deleted file mode 100644 index 3f236e7d1..000000000 --- a/hardware/devices/timelinkmicro/tms6001/snmp/mode/alarm.pm +++ /dev/null @@ -1,104 +0,0 @@ -# -# Copyright 2019 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. -# -# Authors : Thomas Gourdin thomas.gourdin@gmail.com - -package hardware::devices::timelinkmicro::tms6001::snmp::mode::alarm; - -use base qw(centreon::plugins::mode); - -use strict; -use warnings; - -sub new { - my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); - bless $self, $class; - - $options{options}->add_options(arguments => - { - "warning:s" => { name => 'warning' }, - "critical:s" => { name => 'critical' }, - }); - - return $self; -} - -sub check_options { - my ($self, %options) = @_; - $self->SUPER::init(%options); - - if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); - $self->{output}->option_exit(); - } - -} - -sub run { - my ($self, %options) = @_; - $self->{snmp} = $options{snmp}; - $self->{hostname} = $self->{snmp}->get_hostname(); - - my $oid_qualityfrequency = '.1.3.6.1.4.1.22641.100.3.3.0'; - - my $result = $self->{snmp}->get_leef(oids => [ $oid_qualityfrequency ], nothing_quit => 1); - - my $value = $result->{$oid_qualityfrequency}; - - my $exit = $self->{perfdata}->threshold_check(value => $value, - threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("There is %s alarm(s).", $value)); - - $self->{output}->perfdata_add(label => 'value', unit => undef, - value => $value, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), - min => undef, max => undef); - - $self->{output}->display(); - $self->{output}->exit(); -} - -1; - -__END__ - -=head1 MODE - -Check number of alarms - -=over 8 - -=item B<--warning> - -Threshold warning. - -=item B<--critical> - -Threshold critical. - -=back - -=cut diff --git a/hardware/devices/timelinkmicro/tms6001/snmp/mode/alarms.pm b/hardware/devices/timelinkmicro/tms6001/snmp/mode/alarms.pm new file mode 100644 index 000000000..d89a21330 --- /dev/null +++ b/hardware/devices/timelinkmicro/tms6001/snmp/mode/alarms.pm @@ -0,0 +1,87 @@ +# +# Copyright 2020 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. +# +# Authors : Thomas Gourdin thomas.gourdin@gmail.com + +package hardware::devices::timelinkmicro::tms6001::snmp::mode::alarms; + +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 => 'total', nlabel => 'alarms.total.count', set => { + key_values => [ { name => 'alarms_count' } ], + output_template => 'current number of alarms: %s', + perfdatas => [ + { value => 'alarms_count_absolute', template => '%s', min => 0 } + ] + } + } + ]; +} + +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 => { + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + my $oid_infoAlarmsCount = '.1.3.6.1.4.1.22641.100.3.3.0'; + my $snmp_result = $options{snmp}->get_leef(oids => [ $oid_infoAlarmsCount ], nothing_quit => 1); + + $self->{global} = { + alarms_count => $snmp_result->{$oid_infoAlarmsCount} + }; +} + +1; + +__END__ + +=head1 MODE + +Check alarms. + +=over 8 + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'total'. + +=back + +=cut diff --git a/hardware/devices/timelinkmicro/tms6001/snmp/mode/antenna.pm b/hardware/devices/timelinkmicro/tms6001/snmp/mode/antenna.pm index e548c2920..ea0a94a19 100644 --- a/hardware/devices/timelinkmicro/tms6001/snmp/mode/antenna.pm +++ b/hardware/devices/timelinkmicro/tms6001/snmp/mode/antenna.pm @@ -1,5 +1,5 @@ # -# Copyright 2019 Centreon (http://www.centreon.com/) +# Copyright 2020 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -21,53 +21,73 @@ package hardware::devices::timelinkmicro::tms6001::snmp::mode::antenna; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::counter); use strict; use warnings; +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); + +sub custom_status_output { + my ($self, %options) = @_; + + return 'antenna status: ' . $self->{result_values}->{status}; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0 } + ]; + + $self->{maps_counters}->{global} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'status' } ], + closure_custom_calc => \&catalog_status_calc, + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold, + } + } + ]; +} sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); bless $self, $class; - - $options{options}->add_options(arguments => - { - }); + + $options{options}->add_options(arguments => { + 'unknown-status:s' => { name => 'unknown_status', default => '' }, + 'warning-status:s' => { name => 'warning_status', default => '%{status} =~ /shorted/i' }, + 'critical-status:s' => { name => 'critical_status', default => '%{status} =~ /notConnected/i' } + }); return $self; } sub check_options { my ($self, %options) = @_; - $self->SUPER::init(%options); + $self->SUPER::check_options(%options); + $self->change_macros(macros => ['warning_status', 'critical_status', 'unknown_status']); } -sub run { +my $mapping_status = { + C => 'connected', + S => 'shorted/poweroff', + N => 'notConnected' +}; + +sub manage_selection { my ($self, %options) = @_; - $self->{snmp} = $options{snmp}; - $self->{hostname} = $self->{snmp}->get_hostname(); - my $oid_qualityfrequency = '.1.3.6.1.4.1.22641.100.4.1.4.0'; + my $oid_tsGNSSAntenna = '.1.3.6.1.4.1.22641.100.4.1.4.0'; + my $snmp_result = $options{snmp}->get_leef(oids => [ $oid_tsGNSSAntenna ], nothing_quit => 1); - my $result = $self->{snmp}->get_leef(oids => [ $oid_qualityfrequency ], nothing_quit => 1); - - my $value = $result->{$oid_qualityfrequency}; - - if ($value eq 'C') { - $self->{output}->output_add(severity => 'OK', - short_msg => sprintf("Antenna is connected")); - } elsif ($value eq 'S') { - $self->{output}->output_add(severity => 'WARNING', - short_msg => sprintf("Antenna is shorted or powered off")); - } elsif ($value eq 'N') { - $self->{output}->output_add(severity => 'CRITICAL', - short_msg => sprintf("Antenna is not connected")); - } - - $self->{output}->display(); - $self->{output}->exit(); + $self->{global} = { + status => $mapping_status->{ $snmp_result->{$oid_tsGNSSAntenna} } + }; } 1; @@ -76,10 +96,25 @@ __END__ =head1 MODE -Check antenna status +Check antenna. =over 8 +=item B<--unknown-status> + +Set unknown threshold for status. +Can used special variables like: %{status} + +=item B<--warning-status> + +Set warning threshold for status (Default: '%{status} =~ /shorted/i'). +Can used special variables like: %{status} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{status} =~ /notConnected/i'). +Can used special variables like: %{status} + =back =cut diff --git a/hardware/devices/timelinkmicro/tms6001/snmp/mode/frequency.pm b/hardware/devices/timelinkmicro/tms6001/snmp/mode/frequency.pm index e443c5a7d..11072dd37 100644 --- a/hardware/devices/timelinkmicro/tms6001/snmp/mode/frequency.pm +++ b/hardware/devices/timelinkmicro/tms6001/snmp/mode/frequency.pm @@ -1,5 +1,5 @@ # -# Copyright 2019 Centreon (http://www.centreon.com/) +# Copyright 2020 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -21,65 +21,52 @@ package hardware::devices::timelinkmicro::tms6001::snmp::mode::frequency; -use base qw(centreon::plugins::mode); +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 => 'frequency-quality', nlabel => 'generation.frequency.quality.count', set => { + key_values => [ { name => 'qual_frequency' } ], + output_template => 'quality of frequency generation: %s', + perfdatas => [ + { value => 'qual_frequency_absolute', template => '%s' } + ] + } + } + ]; +} + sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); bless $self, $class; - - $options{options}->add_options(arguments => - { - "warning:s" => { name => 'warning' }, - "critical:s" => { name => 'critical' }, - }); + + $options{options}->add_options(arguments => { + }); return $self; } -sub check_options { +sub manage_selection { my ($self, %options) = @_; - $self->SUPER::init(%options); - if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); - $self->{output}->option_exit(); - } - + my $oid_infoQualFreq = '.1.3.6.1.4.1.22641.100.3.6.0'; + my $snmp_result = $options{snmp}->get_leef(oids => [ $oid_infoQualFreq ], nothing_quit => 1); + + $self->{global} = { + qual_frequency => $snmp_result->{$oid_infoQualFreq} + }; } -sub run { - my ($self, %options) = @_; - $self->{snmp} = $options{snmp}; - $self->{hostname} = $self->{snmp}->get_hostname(); - - my $oid_qualityfrequency = '.1.3.6.1.4.1.22641.100.3.6.0'; - - my $result = $self->{snmp}->get_leef(oids => [ $oid_qualityfrequency ], nothing_quit => 1); - - my $value = $result->{$oid_qualityfrequency}; - - my $exit = $self->{perfdata}->threshold_check(value => $value, - threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Quality of frequency generation is %s.", $value)); - - $self->{output}->perfdata_add(label => 'value', unit => undef, - value => $value, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), - min => undef, max => undef); - - $self->{output}->display(); - $self->{output}->exit(); -} 1; @@ -91,13 +78,10 @@ Check quality of frequency generation =over 8 -=item B<--warning> +=item B<--warning-*> B<--critical-*> -Threshold warning. - -=item B<--critical> - -Threshold critical. +Thresholds. +Can be: 'frequency-quality'. =back diff --git a/hardware/devices/timelinkmicro/tms6001/snmp/mode/gnss.pm b/hardware/devices/timelinkmicro/tms6001/snmp/mode/gnss.pm index 666fff461..db5c06768 100644 --- a/hardware/devices/timelinkmicro/tms6001/snmp/mode/gnss.pm +++ b/hardware/devices/timelinkmicro/tms6001/snmp/mode/gnss.pm @@ -1,5 +1,5 @@ # -# Copyright 2019 Centreon (http://www.centreon.com/) +# Copyright 2020 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -21,50 +21,67 @@ package hardware::devices::timelinkmicro::tms6001::snmp::mode::gnss; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::counter); use strict; use warnings; +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); + +sub custom_status_output { + my ($self, %options) = @_; + + return 'GNSS status: ' . $self->{result_values}->{status}; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0 } + ]; + + $self->{maps_counters}->{global} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'status' } ], + closure_custom_calc => \&catalog_status_calc, + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold, + } + } + ]; +} sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); bless $self, $class; - - $options{options}->add_options(arguments => - { - }); + + $options{options}->add_options(arguments => { + 'unknown-status:s' => { name => 'unknown_status', default => '' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '%{status} !~ /nominal/i' } + }); return $self; } sub check_options { my ($self, %options) = @_; - $self->SUPER::init(%options); + $self->SUPER::check_options(%options); + $self->change_macros(macros => ['warning_status', 'critical_status', 'unknown_status']); } -sub run { +sub manage_selection { my ($self, %options) = @_; - $self->{snmp} = $options{snmp}; - $self->{hostname} = $self->{snmp}->get_hostname(); - my $oid_qualityfrequency = '.1.3.6.1.4.1.22641.100.4.1.2.0'; + my $oid_tsGNSSStatus = '.1.3.6.1.4.1.22641.100.4.1.2.0'; + my $snmp_result = $options{snmp}->get_leef(oids => [ $oid_tsGNSSStatus ], nothing_quit => 1); - my $result = $self->{snmp}->get_leef(oids => [ $oid_qualityfrequency ], nothing_quit => 1); - - my $value = $result->{$oid_qualityfrequency}; - - if ($value eq 'Nominal') { - $self->{output}->output_add(severity => 'OK', - short_msg => sprintf("GNSS status is $value")); - } else { - $self->{output}->output_add(severity => 'CRITICAL', - short_msg => sprintf("GNSS status is $value")); - } - - $self->{output}->display(); - $self->{output}->exit(); + $self->{global} = { + status => lc($snmp_result->{$oid_tsGNSSStatus}) + }; } 1; @@ -73,10 +90,25 @@ __END__ =head1 MODE -Check GNSS state +Check GNSS. =over 8 +=item B<--unknown-status> + +Set unknown threshold for status. +Can used special variables like: %{status} + +=item B<--warning-status> + +Set warning threshold for status. +Can used special variables like: %{status} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{status} !~ /nominal/i'). +Can used special variables like: %{status} + =back =cut diff --git a/hardware/devices/timelinkmicro/tms6001/snmp/mode/satellites.pm b/hardware/devices/timelinkmicro/tms6001/snmp/mode/satellites.pm index 51635f0d2..533a72e85 100644 --- a/hardware/devices/timelinkmicro/tms6001/snmp/mode/satellites.pm +++ b/hardware/devices/timelinkmicro/tms6001/snmp/mode/satellites.pm @@ -1,5 +1,5 @@ # -# Copyright 2019 Centreon (http://www.centreon.com/) +# Copyright 2020 Centreon (http://www.centreon.com/) # # Centreon is a full-fledged industry-strength solution that meets # the needs in IT infrastructure and application monitoring for @@ -21,64 +21,50 @@ package hardware::devices::timelinkmicro::tms6001::snmp::mode::satellites; -use base qw(centreon::plugins::mode); +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 => 'seen', nlabel => 'satellites.seen.count', set => { + key_values => [ { name => 'sat_count' } ], + output_template => 'current number of satellites seen: %s', + perfdatas => [ + { value => 'sat_count_absolute', template => '%s', min => 0 } + ] + } + } + ]; +} + sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); bless $self, $class; - - $options{options}->add_options(arguments => - { - "warning:s" => { name => 'warning' }, - "critical:s" => { name => 'critical' }, - }); + + $options{options}->add_options(arguments => { + }); return $self; } -sub check_options { +sub manage_selection { my ($self, %options) = @_; - $self->SUPER::init(%options); - if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); - $self->{output}->option_exit(); - } - -} + my $oid_tsGNSSSatCount = '.1.3.6.1.4.1.22641.100.4.1.8.0'; + my $snmp_result = $options{snmp}->get_leef(oids => [ $oid_tsGNSSSatCount ], nothing_quit => 1); -sub run { - my ($self, %options) = @_; - $self->{snmp} = $options{snmp}; - $self->{hostname} = $self->{snmp}->get_hostname(); - - my $oid_qualityfrequency = '.1.3.6.1.4.1.22641.100.4.1.8.0'; - - my $result = $self->{snmp}->get_leef(oids => [ $oid_qualityfrequency ], nothing_quit => 1); - - my $value = $result->{$oid_qualityfrequency}; - - my $exit = $self->{perfdata}->threshold_check(value => $value, - threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Number of satellites seen is %s.", $value)); - - $self->{output}->perfdata_add(label => 'value', unit => undef, - value => $value, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), - min => undef, max => undef); - - $self->{output}->display(); - $self->{output}->exit(); + $self->{global} = { + sat_count => $snmp_result->{$oid_tsGNSSSatCount} + }; } 1; @@ -87,17 +73,14 @@ __END__ =head1 MODE -Check number of satellites seen +Check satellites. =over 8 -=item B<--warning> +=item B<--warning-*> B<--critical-*> -Threshold warning. - -=item B<--critical> - -Threshold critical. +Thresholds. +Can be: 'seen'. =back diff --git a/hardware/devices/timelinkmicro/tms6001/snmp/mode/time.pm b/hardware/devices/timelinkmicro/tms6001/snmp/mode/time.pm index f061e0294..c9c5b06f8 100644 --- a/hardware/devices/timelinkmicro/tms6001/snmp/mode/time.pm +++ b/hardware/devices/timelinkmicro/tms6001/snmp/mode/time.pm @@ -21,64 +21,50 @@ package hardware::devices::timelinkmicro::tms6001::snmp::mode::time; -use base qw(centreon::plugins::mode); +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 => 'time-quality', nlabel => 'generation.time.quality.count', set => { + key_values => [ { name => 'qual_time' } ], + output_template => 'quality of time generation: %s', + perfdatas => [ + { value => 'qual_time_absolute', template => '%s' } + ] + } + } + ]; +} + sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); bless $self, $class; - - $options{options}->add_options(arguments => - { - "warning:s" => { name => 'warning' }, - "critical:s" => { name => 'critical' }, - }); + + $options{options}->add_options(arguments => { + }); return $self; } -sub check_options { +sub manage_selection { my ($self, %options) = @_; - $self->SUPER::init(%options); - if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); - $self->{output}->option_exit(); - } - -} + my $oid_infoQualTime = '.1.3.6.1.4.1.22641.100.3.5.0'; + my $snmp_result = $options{snmp}->get_leef(oids => [ $oid_infoQualTime ], nothing_quit => 1); -sub run { - my ($self, %options) = @_; - $self->{snmp} = $options{snmp}; - $self->{hostname} = $self->{snmp}->get_hostname(); - - my $oid_qualityfrequency = '.1.3.6.1.4.1.22641.100.3.5.0'; - - my $result = $self->{snmp}->get_leef(oids => [ $oid_qualityfrequency ], nothing_quit => 1); - - my $value = $result->{$oid_qualityfrequency}; - - my $exit = $self->{perfdata}->threshold_check(value => $value, - threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Quality of time generation is %s.", $value)); - - $self->{output}->perfdata_add(label => 'value', unit => undef, - value => $value, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), - min => undef, max => undef); - - $self->{output}->display(); - $self->{output}->exit(); + $self->{global} = { + qual_time => $snmp_result->{$oid_infoQualTime} + }; } 1; @@ -87,17 +73,14 @@ __END__ =head1 MODE -Check quality of time generation +Check quality of time generation. =over 8 -=item B<--warning> +=item B<--warning-*> B<--critical-*> -Threshold warning. - -=item B<--critical> - -Threshold critical. +Thresholds. +Can be: 'time-quality'. =back diff --git a/hardware/devices/timelinkmicro/tms6001/snmp/plugin.pm b/hardware/devices/timelinkmicro/tms6001/snmp/plugin.pm index 799f11780..b4bda3092 100644 --- a/hardware/devices/timelinkmicro/tms6001/snmp/plugin.pm +++ b/hardware/devices/timelinkmicro/tms6001/snmp/plugin.pm @@ -31,15 +31,14 @@ sub new { bless $self, $class; $self->{version} = '0.1'; - %{$self->{modes}} = ( - 'frequency' => 'hardware::devices::timelinkmicro::tms6001::snmp::mode::frequency', - 'time' => 'hardware::devices::timelinkmicro::tms6001::snmp::mode::time', - 'satellites' => 'hardware::devices::timelinkmicro::tms6001::snmp::mode::satellites', - 'antenna' => 'hardware::devices::timelinkmicro::tms6001::snmp::mode::antenna', - 'gnss' => 'hardware::devices::timelinkmicro::tms6001::snmp::mode::gnss', - 'alarms' => 'hardware::devices::timelinkmicro::tms6001::snmp::mode::alarm', - - ); + $self->{modes} = { + 'alarms' => 'hardware::devices::timelinkmicro::tms6001::snmp::mode::alarms', + 'antenna' => 'hardware::devices::timelinkmicro::tms6001::snmp::mode::antenna', + 'frequency' => 'hardware::devices::timelinkmicro::tms6001::snmp::mode::frequency', + 'gnss' => 'hardware::devices::timelinkmicro::tms6001::snmp::mode::gnss', + 'satellites' => 'hardware::devices::timelinkmicro::tms6001::snmp::mode::satellites', + 'time' => 'hardware::devices::timelinkmicro::tms6001::snmp::mode::time' + }; return $self; } From 7de5f44a1e137111ade1b123c4c069a0e19d43f7 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 11 May 2020 15:11:38 +0200 Subject: [PATCH 208/283] add plugin in verbose --- apps/mq/vernemq/restapi/mode/plugins.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/mq/vernemq/restapi/mode/plugins.pm b/apps/mq/vernemq/restapi/mode/plugins.pm index 49fef8ace..ad1919677 100644 --- a/apps/mq/vernemq/restapi/mode/plugins.pm +++ b/apps/mq/vernemq/restapi/mode/plugins.pm @@ -71,6 +71,7 @@ sub manage_selection { next; } + $self->{output}->output_add(long_msg => "plugin '" . $_->{Plugin} . "'"); $self->{global}->{total}++; } } From 9972dd78e65ede4d20e50f38be22b2e2e45013ad Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 11 May 2020 15:46:01 +0200 Subject: [PATCH 209/283] add average message size --- apps/mq/activemq/jmx/mode/brokers.pm | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/apps/mq/activemq/jmx/mode/brokers.pm b/apps/mq/activemq/jmx/mode/brokers.pm index b8f1c746b..53720030d 100644 --- a/apps/mq/activemq/jmx/mode/brokers.pm +++ b/apps/mq/activemq/jmx/mode/brokers.pm @@ -111,7 +111,7 @@ sub set_counters { ] } }, - { label => 'queue-enqueued', nlabel => 'broker.queue.enqueued.count', display_ok => 0, set => { + { label => 'queue-messages-enqueued', nlabel => 'broker.queue.messages.enqueued.count', display_ok => 0, set => { key_values => [ { name => 'EnqueueCount', diff => 1 }, { name => 'display' } ], output_template => 'messages enqueued: %s', perfdatas => [ @@ -120,7 +120,7 @@ sub set_counters { ] } }, - { label => 'queue-dequeued', nlabel => 'broker.queue.dequeue.count', display_ok => 0, set => { + { label => 'queue-messages-dequeued', nlabel => 'broker.queue.messages.dequeue.count', display_ok => 0, set => { key_values => [ { name => 'DequeueCount', diff => 1 }, { name => 'display' } ], output_template => 'messages dequeued: %s', perfdatas => [ @@ -129,7 +129,7 @@ sub set_counters { ] } }, - { label => 'queue-expired', nlabel => 'broker.queue.expired.count', display_ok => 0, set => { + { label => 'queue-messages-expired', nlabel => 'broker.queue.messages.expired.count', display_ok => 0, set => { key_values => [ { name => 'ExpiredCount', diff => 1 }, { name => 'display' } ], output_template => 'messages expired: %s', perfdatas => [ @@ -138,7 +138,7 @@ sub set_counters { ] } }, - { label => 'queue-inflighted', nlabel => 'broker.queue.inflighted.count', display_ok => 0, set => { + { label => 'queue-messages-inflighted', nlabel => 'broker.queue.messages.inflighted.count', display_ok => 0, set => { key_values => [ { name => 'InFlightCount', diff => 1 }, { name => 'display' } ], output_template => 'messages in-flighted: %s', perfdatas => [ @@ -146,6 +146,16 @@ sub set_counters { template => '%s', min => 0, label_extra_instance => 1 } ] } + }, + { label => 'queue-messages-size-average', nlabel => 'broker.queue.messages.size.average.bytes', display_ok => 0, set => { + key_values => [ { name => 'AverageMessageSize' }, { name => 'display' } ], + output_template => 'average messages size: %s %s', + output_change_bytes => 1, + perfdatas => [ + { value => 'AverageMessageSize_absolute', + template => '%s', unit => 'B', min => 0, label_extra_instance => 1 } + ] + } } ]; } @@ -192,7 +202,7 @@ sub manage_selection { { name => 'ProducerCount' }, { name => 'MemoryPercentUsage' }, { name => 'QueueSize' }, { name => 'EnqueueCount' }, { name => 'DequeueCount' }, { name => 'ExpiredCount' }, - { name => 'InFlightCount' } + { name => 'InFlightCount' }, { name => 'AverageMessageSize' } ] }, { @@ -277,7 +287,8 @@ Thresholds. Can be: 'store-usage' (%), 'temporary-usage' (%), 'memory-usage' (%), 'queue-average-enqueue-time' (ms), 'queue-consumers-connected', 'queue-producers-connected', 'queue-memory-usage' (%), 'queue-size', -'queue-enqueued', 'queue-dequeued', 'queue-expired', 'queue-inflighted'. +'queue-messages-enqueued', 'queue-messages-dequeued', 'queue-messages-expired', +'queue-messages-inflighted'. =back From 883ff1babb5b0ee0c10d49f7699f02cdd84b21de Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 11 May 2020 16:16:43 +0200 Subject: [PATCH 210/283] enhance activemq --- apps/mq/activemq/jmx/mode/brokers.pm | 234 +++++++++++++++------------ 1 file changed, 131 insertions(+), 103 deletions(-) diff --git a/apps/mq/activemq/jmx/mode/brokers.pm b/apps/mq/activemq/jmx/mode/brokers.pm index 53720030d..7072d4500 100644 --- a/apps/mq/activemq/jmx/mode/brokers.pm +++ b/apps/mq/activemq/jmx/mode/brokers.pm @@ -33,7 +33,8 @@ sub set_counters { { name => 'brokers', type => 3, cb_prefix_output => 'prefix_broker_output', cb_long_output => 'broker_long_output', indent_long_output => ' ', message_multiple => 'All brokers are ok', group => [ { name => 'global', type => 0, skipped_code => { -10 => 1 } }, - { name => 'queues', display_long => 1, cb_prefix_output => 'prefix_queue_output', message_multiple => 'All queue destinations are ok', type => 1, skipped_code => { -10 => 1 } } + { name => 'queue', display_long => 1, cb_prefix_output => 'prefix_queue_output', message_multiple => 'All queues are ok', type => 1, skipped_code => { -10 => 1 } }, + { name => 'topic', display_long => 1, cb_prefix_output => 'prefix_topic_output', message_multiple => 'All topics are ok', type => 1, skipped_code => { -10 => 1 } } ] } ]; @@ -65,99 +66,101 @@ sub set_counters { } ]; - $self->{maps_counters}->{queues} = [ - { label => 'queue-average-enqueue-time', nlabel => 'broker.queue.average.enqueue.time.milliseconds', set => { - key_values => [ { name => 'AverageEnqueueTime' }, { name => 'display' } ], - output_template => 'average time messages remained enqueued: %.3f ms', - perfdatas => [ - { value => 'AverageEnqueueTime_absolute', - template => '%.3f', unit => 'ms', min => 0, label_extra_instance => 1 } - ] + foreach (('queue', 'topic')) { + $self->{maps_counters}->{$_} = [ + { label => $_ . '-average-enqueue-time', nlabel => 'broker.' . $_ . '.average.enqueue.time.milliseconds', set => { + key_values => [ { name => 'AverageEnqueueTime' }, { name => 'display' } ], + output_template => 'average time messages remained enqueued: %.3f ms', + perfdatas => [ + { value => 'AverageEnqueueTime_absolute', + template => '%.3f', unit => 'ms', min => 0, label_extra_instance => 1 } + ] + } + }, + { label => $_ . '-consumers-connected', nlabel => 'broker.' . $_ . '.consumers.connected.count', set => { + key_values => [ { name => 'ConsumerCount' }, { name => 'display' } ], + output_template => 'consumers connected: %s', + perfdatas => [ + { value => 'ConsumerCount_absolute', + template => '%s', min => 0, label_extra_instance => 1 } + ] + } + }, + { label => $_ . '-producers-connected', nlabel => 'broker.' . $_ . '.producers.connected.count', display_ok => 0, set => { + key_values => [ { name => 'ProducerCount' }, { name => 'display' } ], + output_template => 'producers connected: %s', + perfdatas => [ + { value => 'ProducerCount_absolute', + template => '%s', min => 0, label_extra_instance => 1 } + ] + } + }, + { label => $_ . '-memory-usage', nlabel => 'broker.' . $_ . '.memory.usage.percentage', display_ok => 0, set => { + key_values => [ { name => 'MemoryPercentUsage' }, { name => 'display' } ], + output_template => 'memory usage: %.2f %%', + perfdatas => [ + { value => 'MemoryPercentUsage_absolute', + template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1 } + ] + } + }, + { label => $_ . '-size', nlabel => 'broker.' . $_ . '.size.count', set => { + key_values => [ { name => 'QueueSize' }, { name => 'display' } ], + output_template => 'queue size: %s', + perfdatas => [ + { value => 'QueueSize_absolute', + template => '%s', min => 0, label_extra_instance => 1 } + ] + } + }, + { label => $_ . '-messages-enqueued', nlabel => 'broker.' . $_ . '.messages.enqueued.count', display_ok => 0, set => { + key_values => [ { name => 'EnqueueCount', diff => 1 }, { name => 'display' } ], + output_template => 'messages enqueued: %s', + perfdatas => [ + { value => 'EnqueueCount_absolute', + template => '%s', min => 0, label_extra_instance => 1 } + ] + } + }, + { label => $_ . '-messages-dequeued', nlabel => 'broker.' . $_ . '.messages.dequeue.count', display_ok => 0, set => { + key_values => [ { name => 'DequeueCount', diff => 1 }, { name => 'display' } ], + output_template => 'messages dequeued: %s', + perfdatas => [ + { value => 'DequeueCount_absolute', + template => '%s', min => 0, label_extra_instance => 1 } + ] + } + }, + { label => $_ . '-messages-expired', nlabel => 'broker.' . $_ . '.messages.expired.count', display_ok => 0, set => { + key_values => [ { name => 'ExpiredCount', diff => 1 }, { name => 'display' } ], + output_template => 'messages expired: %s', + perfdatas => [ + { value => 'ExpiredCount_absolute', + template => '%s', min => 0, label_extra_instance => 1 } + ] + } + }, + { label => $_ . '-messages-inflighted', nlabel => 'broker.' . $_ . '.messages.inflighted.count', display_ok => 0, set => { + key_values => [ { name => 'InFlightCount', diff => 1 }, { name => 'display' } ], + output_template => 'messages in-flighted: %s', + perfdatas => [ + { value => 'InFlightCount_absolute', + template => '%s', min => 0, label_extra_instance => 1 } + ] + } + }, + { label => $_ . '-messages-size-average', nlabel => 'broker.' . $_ . '.messages.size.average.bytes', display_ok => 0, set => { + key_values => [ { name => 'AverageMessageSize' }, { name => 'display' } ], + output_template => 'average messages size: %s %s', + output_change_bytes => 1, + perfdatas => [ + { value => 'AverageMessageSize_absolute', + template => '%s', unit => 'B', min => 0, label_extra_instance => 1 } + ] + } } - }, - { label => 'queue-consumers-connected', nlabel => 'broker.queue.consumers.connected.count', set => { - key_values => [ { name => 'ConsumerCount' }, { name => 'display' } ], - output_template => 'consumers connected: %s', - perfdatas => [ - { value => 'ConsumerCount_absolute', - template => '%s', min => 0, label_extra_instance => 1 } - ] - } - }, - { label => 'queue-producers-connected', nlabel => 'broker.queue.producers.connected.count', display_ok => 0, set => { - key_values => [ { name => 'ProducerCount' }, { name => 'display' } ], - output_template => 'producers connected: %s', - perfdatas => [ - { value => 'ProducerCount_absolute', - template => '%s', min => 0, label_extra_instance => 1 } - ] - } - }, - { label => 'queue-memory-usage', nlabel => 'broker.queue.memory.usage.percentage', display_ok => 0, set => { - key_values => [ { name => 'MemoryPercentUsage' }, { name => 'display' } ], - output_template => 'memory usage: %.2f %%', - perfdatas => [ - { value => 'MemoryPercentUsage_absolute', - template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1 } - ] - } - }, - { label => 'queue-size', nlabel => 'broker.queue.size.count', set => { - key_values => [ { name => 'QueueSize' }, { name => 'display' } ], - output_template => 'queue size: %s', - perfdatas => [ - { value => 'QueueSize_absolute', - template => '%s', min => 0, label_extra_instance => 1 } - ] - } - }, - { label => 'queue-messages-enqueued', nlabel => 'broker.queue.messages.enqueued.count', display_ok => 0, set => { - key_values => [ { name => 'EnqueueCount', diff => 1 }, { name => 'display' } ], - output_template => 'messages enqueued: %s', - perfdatas => [ - { value => 'EnqueueCount_absolute', - template => '%s', min => 0, label_extra_instance => 1 } - ] - } - }, - { label => 'queue-messages-dequeued', nlabel => 'broker.queue.messages.dequeue.count', display_ok => 0, set => { - key_values => [ { name => 'DequeueCount', diff => 1 }, { name => 'display' } ], - output_template => 'messages dequeued: %s', - perfdatas => [ - { value => 'DequeueCount_absolute', - template => '%s', min => 0, label_extra_instance => 1 } - ] - } - }, - { label => 'queue-messages-expired', nlabel => 'broker.queue.messages.expired.count', display_ok => 0, set => { - key_values => [ { name => 'ExpiredCount', diff => 1 }, { name => 'display' } ], - output_template => 'messages expired: %s', - perfdatas => [ - { value => 'ExpiredCount_absolute', - template => '%s', min => 0, label_extra_instance => 1 } - ] - } - }, - { label => 'queue-messages-inflighted', nlabel => 'broker.queue.messages.inflighted.count', display_ok => 0, set => { - key_values => [ { name => 'InFlightCount', diff => 1 }, { name => 'display' } ], - output_template => 'messages in-flighted: %s', - perfdatas => [ - { value => 'InFlightCount_absolute', - template => '%s', min => 0, label_extra_instance => 1 } - ] - } - }, - { label => 'queue-messages-size-average', nlabel => 'broker.queue.messages.size.average.bytes', display_ok => 0, set => { - key_values => [ { name => 'AverageMessageSize' }, { name => 'display' } ], - output_template => 'average messages size: %s %s', - output_change_bytes => 1, - perfdatas => [ - { value => 'AverageMessageSize_absolute', - template => '%s', unit => 'B', min => 0, label_extra_instance => 1 } - ] - } - } - ]; + ]; + } } sub broker_long_output { @@ -172,10 +175,16 @@ sub prefix_broker_output { return "Broker '" . $options{instance_value}->{display} . "' "; } -sub prefix_qeueue_output { +sub prefix_queue_output { my ($self, %options) = @_; - return "queue destination '" . $options{instance_value}->{display} . "' "; + return "queue '" . $options{instance_value}->{display} . "' "; +} + +sub prefix_topic_output { + my ($self, %options) = @_; + + return "topic '" . $options{instance_value}->{display} . "' "; } sub new { @@ -185,7 +194,8 @@ sub new { $options{options}->add_options(arguments => { 'filter-broker-name:s' => { name => 'filter_broker_name' }, - 'filter-destination-name:s' => { name => 'filter_destination_name' } + 'filter-destination-name:s' => { name => 'filter_destination_name' }, + 'filter-destination-type:s' => { name => 'filter_destination_type' } }); return $self; @@ -196,7 +206,7 @@ sub manage_selection { my $request = [ { - mbean => 'org.apache.activemq:brokerName=*,destinationName=*,destinationType=Topic,type=Broker', + mbean => 'org.apache.activemq:brokerName=*,destinationName=*,destinationType=*,type=Broker', attributes => [ { name => 'AverageEnqueueTime' }, { name => 'ConsumerCount' }, { name => 'ProducerCount' }, { name => 'MemoryPercentUsage' }, @@ -218,34 +228,44 @@ sub manage_selection { $self->{cache_name} = 'activemq_' . $self->{mode} . '_' . md5_hex($options{custom}->get_connection_info()) . '_' . (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' . (defined($self->{option_results}->{filter_broker_name}) ? md5_hex($self->{option_results}->{filter_broker_name}) : md5_hex('all')) . '_' . - (defined($self->{option_results}->{filter_destination_name}) ? md5_hex($self->{option_results}->{filter_destination_name}) : md5_hex('all')); + (defined($self->{option_results}->{filter_destination_name}) ? md5_hex($self->{option_results}->{filter_destination_name}) : md5_hex('all')) . '_' . + (defined($self->{option_results}->{filter_destination_type}) ? md5_hex($self->{option_results}->{filter_destination_type}) : md5_hex('all')); $self->{brokers} = {}; foreach my $mbean (keys %$result) { - next if ($mbean !~ /org.apache.activemq:brokerName=(.*?),(?:destinationName=(.*?),|type=Broker)/); - my ($broker_name, $destination_name) = ($1, $2); + next if ($mbean !~ /org.apache.activemq:brokerName=(.*?),(?:destinationName=(.*?),destinationType=(.*?),|type=Broker)/); + my ($broker_name, $destination_name, $destination_type) = ($1, $2, $3); if (defined($self->{option_results}->{filter_broker_name}) && $self->{option_results}->{filter_broker_name} ne '' && $broker_name !~ /$self->{option_results}->{filter_broker_name}/) { $self->{output}->output_add(long_msg => "skipping '" . $broker_name . "': no matching filter.", debug => 1); next; } + if (defined($self->{option_results}->{filter_destination_type}) && $self->{option_results}->{filter_destination_type} ne '' && + $destination_type !~ /$self->{option_results}->{filter_destination_type}/) { + $self->{output}->output_add(long_msg => "skipping '" . $broker_name . "': no matching filter.", debug => 1); + next; + } if (!defined($self->{brokers}->{$broker_name})) { $self->{brokers}->{$broker_name} = { display => $broker_name, - queues => {} + queue => {}, + topic => {} }; } if (defined($destination_name)) { + my $type = lc($destination_type); + next if ($type ne 'topic' && $type ne 'queue'); + if (defined($self->{option_results}->{filter_destination_name}) && $self->{option_results}->{filter_destination_name} ne '' && $destination_name !~ /$self->{option_results}->{filter_destination_name}/) { $self->{output}->output_add(long_msg => "skipping '" . $destination_name . "': no matching filter.", debug => 1); next; } - $self->{brokers}->{$broker_name}->{queues}->{$destination_name} = { + $self->{brokers}->{$broker_name}->{$type}->{$destination_name} = { display => $destination_name, %{$result->{$mbean}} }; @@ -281,6 +301,10 @@ Filter broker name (Can be a regexp). Filter destination name (Can be a regexp). +=item B<--filter-destination-type> + +Filter destination type (Can be a regexp). + =item B<--warning-*> B<--critical-*> Thresholds. @@ -288,7 +312,11 @@ Can be: 'store-usage' (%), 'temporary-usage' (%), 'memory-usage' (%), 'queue-average-enqueue-time' (ms), 'queue-consumers-connected', 'queue-producers-connected', 'queue-memory-usage' (%), 'queue-size', 'queue-messages-enqueued', 'queue-messages-dequeued', 'queue-messages-expired', -'queue-messages-inflighted'. +'queue-messages-inflighted', +'topic-average-enqueue-time' (ms), 'topic-consumers-connected', +'topic-producers-connected', 'topic-memory-usage' (%), 'topic-size', +'topic-messages-enqueued', 'topic-messages-dequeued', 'topic-messages-expired', +'topic-messages-inflighted'. =back From d76fcd730a2883b443a8a2f8d96640d978707272 Mon Sep 17 00:00:00 2001 From: Thibault S <48209914+thibaults-centreon@users.noreply.github.com> Date: Tue, 12 May 2020 16:25:39 +0200 Subject: [PATCH 211/283] add(plugin): Amazon EBS (#1990) * add(plugin): Amazon EBS --- cloud/aws/custom/awscli.pm | 36 ++++ cloud/aws/custom/paws.pm | 38 +++- cloud/aws/ebs/mode/discovery.pm | 115 +++++++++++ cloud/aws/ebs/mode/listvolumes.pm | 99 ++++++++++ cloud/aws/ebs/mode/volumeio.pm | 281 +++++++++++++++++++++++++++ cloud/aws/ebs/mode/volumeiops.pm | 309 ++++++++++++++++++++++++++++++ cloud/aws/ebs/mode/volumetime.pm | 270 ++++++++++++++++++++++++++ cloud/aws/ebs/plugin.pm | 10 +- 8 files changed, 1152 insertions(+), 6 deletions(-) create mode 100644 cloud/aws/ebs/mode/discovery.pm create mode 100644 cloud/aws/ebs/mode/listvolumes.pm create mode 100644 cloud/aws/ebs/mode/volumeio.pm create mode 100644 cloud/aws/ebs/mode/volumeiops.pm create mode 100644 cloud/aws/ebs/mode/volumetime.pm diff --git a/cloud/aws/custom/awscli.pm b/cloud/aws/custom/awscli.pm index 7c920e8fe..f4f064bf7 100644 --- a/cloud/aws/custom/awscli.pm +++ b/cloud/aws/custom/awscli.pm @@ -341,6 +341,42 @@ sub cloudwatchlogs_filter_log_events { return $raw_results->{events}; } +sub ebs_list_volumes_set_cmd { + my ($self, %options) = @_; + + return if (defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne ''); + + my $cmd_options = "ec2 describe-volumes --no-dry-run --region $options{region} --output json"; + $cmd_options .= " --endpoint-url $self->{endpoint_url}" if (defined($self->{endpoint_url}) && $self->{endpoint_url} ne ''); + + return $cmd_options; +} + +sub ebs_list_volumes { + my ($self, %options) = @_; + + my $cmd_options = $self->ebs_list_volumes_set_cmd(%options); + my $raw_results = $self->execute(cmd_options => $cmd_options); + + my $resource_results = []; + foreach my $volume_request (@{$raw_results->{Volumes}}) { + my @name_tags; + foreach my $tag (@{$volume_request->{Tags}}) { + if ($tag->{Key} eq "Name" && defined($tag->{Value})) { + push @name_tags, $tag->{Value}; + } + }; + push @{$resource_results}, { + VolumeId => $volume_request->{VolumeId}, + VolumeName => join(",", @name_tags), + VolumeType => $volume_request->{VolumeType}, + VolumeState => $volume_request->{State} + }; + } + + return $resource_results; +} + sub ec2_get_instances_status_set_cmd { my ($self, %options) = @_; diff --git a/cloud/aws/custom/paws.pm b/cloud/aws/custom/paws.pm index 06fcc5f29..8b433e7ab 100644 --- a/cloud/aws/custom/paws.pm +++ b/cloud/aws/custom/paws.pm @@ -25,6 +25,7 @@ use warnings; use Paws; use Paws::Net::LWPCaller; use DateTime; +use Data::Dumper; sub new { my ($class, %options) = @_; @@ -290,6 +291,37 @@ sub cloudwatchlogs_filter_log_events { return $log_groups_results; } +sub ebs_list_volumes { + my ($self, %options) = @_; + + my $volume_results = []; + eval { + my $lwp_caller = new Paws::Net::LWPCaller(); + my $ebsvolume = Paws->service('EC2', caller => $lwp_caller, region => $options{region}); + my $ebsvolume_requests = $ebsvolume->DescribeVolumes(DryRun => 0); + foreach my $request (@{$ebsvolume_requests->{Volumes}}) { + my @name_tags; + foreach my $tag (@{$request->{Tags}}) { + if ($tag->{Key} eq "Name" && defined($tag->{Value})) { + push @name_tags, $tag->{Value}; + } + }; + push @{$volume_results}, { + VolumeId => $request->{VolumeId}, + VolumeName => join(",", @name_tags), + VolumeType => $request->{VolumeType}, + VolumeState => $request->{State} + }; + } + }; + if ($@) { + $self->{output}->add_option_msg(short_msg => "error: $@"); + $self->{output}->option_exit(); + } + + return $volume_results; +} + sub ec2_get_instances_status { my ($self, %options) = @_; @@ -300,8 +332,10 @@ sub ec2_get_instances_status { my $instances = $ec2->DescribeInstanceStatus(DryRun => 0, IncludeAllInstances => 1); foreach (@{$instances->{InstanceStatuses}}) { - $instance_results->{$_->{InstanceId}} = { state => $_->{InstanceState}->{Name}, - status => $_->{InstanceStatus}->{Status} }; + $instance_results->{$_->{InstanceId}} = { + state => $_->{InstanceState}->{Name}, + status => $_->{InstanceStatus}->{Status} + }; } }; if ($@) { diff --git a/cloud/aws/ebs/mode/discovery.pm b/cloud/aws/ebs/mode/discovery.pm new file mode 100644 index 000000000..186e29ee0 --- /dev/null +++ b/cloud/aws/ebs/mode/discovery.pm @@ -0,0 +1,115 @@ +# +# Copyright 2020 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 cloud::aws::ebs::mode::discovery; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use JSON::XS; + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $options{options}->add_options(arguments => { + "prettify" => { name => 'prettify' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); +} + +sub run { + my ($self, %options) = @_; + + my @disco_data; + my $disco_stats; + + $disco_stats->{start_time} = time(); + + my $volumes = $options{custom}->discovery( + region => $self->{option_results}->{region}, + service => 'ec2', + command => 'describe-volumes' + ); + + foreach my $volume (@{$volumes->{Volumes}}) { + my %volume; + my @name_tags; + foreach my $tag (@{$volume->{Tags}}) { + if ($tag->{Key} eq "Name" && defined($tag->{Value})) { + push @name_tags, $tag->{Value}; + } + } + $volume{id} = $volume->{VolumeId}; + $volume{name} = join(",", @name_tags); + $volume{type} = $volume->{VolumeType}; + $volume{state} = $volume->{State}; + $volume{snapshotid} = $volume->{SnapshotId}; + $volume{encrypted} = $volume->{Encrypted}; + push @disco_data, \%volume; + } + + $disco_stats->{end_time} = time(); + $disco_stats->{duration} = $disco_stats->{end_time} - $disco_stats->{start_time}; + $disco_stats->{discovered_items} = @disco_data; + $disco_stats->{results} = \@disco_data; + + my $encoded_data; + eval { + if (defined($self->{option_results}->{prettify})) { + $encoded_data = JSON::XS->new->utf8->pretty->encode($disco_stats); + } else { + $encoded_data = JSON::XS->new->utf8->encode($disco_stats); + } + }; + if ($@) { + $encoded_data = '{"code":"encode_error","message":"Cannot encode discovered data into JSON format"}'; + } + + $self->{output}->output_add(short_msg => $encoded_data); + $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1); + $self->{output}->exit(); +} + +1; + +__END__ + +=head1 MODE + +Amazon EBS volumes discovery. + +=over 8 + +=item B<--prettify> + +Prettify JSON output. + +=back + +=cut diff --git a/cloud/aws/ebs/mode/listvolumes.pm b/cloud/aws/ebs/mode/listvolumes.pm new file mode 100644 index 000000000..63106d7cb --- /dev/null +++ b/cloud/aws/ebs/mode/listvolumes.pm @@ -0,0 +1,99 @@ +# +# Copyright 2020 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 cloud::aws::ebs::mode::listvolumes; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $options{options}->add_options(arguments => {}); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); +} + +sub manage_selection { + my ($self, %options) = @_; + + $self->{volume} = $options{custom}->ebs_list_volumes(region => $self->{option_results}->{region}); +} + +sub run { + my ($self, %options) = @_; + + $self->manage_selection(%options); + foreach (@{$self->{volume}}) { + $self->{output}->output_add( + long_msg => sprintf("[Name = %s][Id = %s][Type = %s][State = %s]", + $_->{VolumeName}, $_->{VolumeId}, $_->{VolumeType}, $_->{VolumeState} )); + } + + $self->{output}->output_add( + severity => 'OK', + short_msg => 'List EBS volumes:' + ); + $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', 'Id', 'Type', 'State']); +} + +sub disco_show { + my ($self, %options) = @_; + + $self->manage_selection(%options); + foreach (@{$self->{volume}}) { + $self->{output}->add_disco_entry( + VolumeName => $_->{VolumeName}, + VolumeId => $_->{VolumeId}, + VolumeType => $_->{VolumeType}, + VolumeState => $_->{VolumeState}, + ); + }; +} + +1; + +__END__ + +=head1 MODE + +List Amazon Elastic Block Store volumes. + +=over 8 + +=back + +=cut diff --git a/cloud/aws/ebs/mode/volumeio.pm b/cloud/aws/ebs/mode/volumeio.pm new file mode 100644 index 000000000..d58c02afd --- /dev/null +++ b/cloud/aws/ebs/mode/volumeio.pm @@ -0,0 +1,281 @@ +# +# Copyright 2020 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 cloud::aws::ebs::mode::volumeio; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +my %metrics_mapping = ( + 'VolumeReadBytes' => { + 'output' => 'Volume Read Bytes', + 'label' => 'volume-read-bytes', + 'nlabel' => { + 'absolute' => 'ebs.volume.bytes.read.bytes', + 'per_second' => 'ebs.volume.bytes.read.bytespersecond' + }, + 'unit' => 'B' + }, + 'VolumeWriteBytes' => { + 'output' => 'Volume Write Bytes', + 'label' => 'volume-write-bytes', + 'nlabel' => { + 'absolute' => 'ebs.volume.bytes.write.bytes', + 'per_second' => 'ebs.volume.bytes.write.bytespersecond' + }, + 'unit' => 'B' + } +); + + +sub custom_metric_calc { + my ($self, %options) = @_; + + $self->{result_values}->{timeframe} = $options{new_datas}->{$self->{instance} . '_timeframe'}; + $self->{result_values}->{value} = $options{new_datas}->{$self->{instance} . '_' . $options{extra_options}->{metric}}; + $self->{result_values}->{value_per_sec} = $self->{result_values}->{value} / $self->{result_values}->{timeframe}; + $self->{result_values}->{metric} = $options{extra_options}->{metric}; + return 0; +} + +sub custom_metric_threshold { + my ($self, %options) = @_; + + my $exit = $self->{perfdata}->threshold_check( + value => defined($self->{instance_mode}->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value}, + threshold => [ + { label => 'critical-' . $metrics_mapping{$self->{result_values}->{metric}}->{label} , exit_litteral => 'critical' }, + { label => 'warning-' . $metrics_mapping{$self->{result_values}->{metric}}->{label}, exit_litteral => 'warning' } + ] + ); + return $exit; +} + +sub custom_metric_perfdata { + my ($self, %options) = @_; + + $self->{output}->perfdata_add( + instances => $self->{instance}, + label => $metrics_mapping{$self->{result_values}->{metric}}->{label}, + nlabel => defined($self->{instance_mode}->{option_results}->{per_sec}) ? + $metrics_mapping{$self->{result_values}->{metric}}->{nlabel}->{per_second} : + $metrics_mapping{$self->{result_values}->{metric}}->{nlabel}->{absolute}, + unit => defined($self->{instance_mode}->{option_results}->{per_sec}) ? + $metrics_mapping{$self->{result_values}->{metric}}->{unit} . '/s' : + $metrics_mapping{$self->{result_values}->{metric}}->{unit}, + value => sprintf("%.2f", defined($self->{instance_mode}->{option_results}->{per_sec}) ? + $self->{result_values}->{value_per_sec} : + $self->{result_values}->{value}), + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $metrics_mapping{$self->{result_values}->{metric}}->{label}), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $metrics_mapping{$self->{result_values}->{metric}}->{label}), + ); +} + +sub custom_metric_output { + my ($self, %options) = @_; + my $msg = ""; + + if (defined($self->{instance_mode}->{option_results}->{per_sec})) { + my ($value, $unit) = ($metrics_mapping{$self->{result_values}->{metric}}->{unit} eq 'B') ? + $self->{perfdata}->change_bytes(value => $self->{result_values}->{value_per_sec}) : + ($self->{result_values}->{value_per_sec}, $metrics_mapping{$self->{result_values}->{metric}}->{unit}); + $msg = sprintf("%s: %.2f %s", $metrics_mapping{$self->{result_values}->{metric}}->{output}, $value, $unit . '/s'); + } else { + my ($value, $unit) = ($metrics_mapping{$self->{result_values}->{metric}}->{unit} eq 'B') ? + $self->{perfdata}->change_bytes(value => $self->{result_values}->{value}) : + ($self->{result_values}->{value}, $metrics_mapping{$self->{result_values}->{metric}}->{unit}); + $msg = sprintf("%s: %.2f %s", $metrics_mapping{$self->{result_values}->{metric}}->{output}, $value, $unit); + } + return $msg; +} + +sub prefix_metric_output { + my ($self, %options) = @_; + + return "'" . $options{instance_value}->{display} . "' "; +} + +sub prefix_statistics_output { + my ($self, %options) = @_; + + return "Statistic '" . $options{instance_value}->{display} . "' Metrics "; +} + +sub long_output { + my ($self, %options) = @_; + + return "AWS EBS Volume'" . $options{instance_value}->{display} . "' "; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'metrics', type => 3, cb_prefix_output => 'prefix_metric_output', cb_long_output => 'long_output', + message_multiple => 'All EBS metrics are ok', indent_long_output => ' ', + group => [ + { name => 'statistics', display_long => 1, cb_prefix_output => 'prefix_statistics_output', + message_multiple => 'All metrics are ok', type => 1, skipped_code => { -10 => 1 } }, + ] + } + ]; + + foreach my $metric (keys %metrics_mapping) { + my $entry = { + label => $metrics_mapping{$metric}->{label}, + set => { + key_values => [ { name => $metric }, { name => 'timeframe' }, { name => 'display' } ], + closure_custom_calc => $self->can('custom_metric_calc'), + closure_custom_calc_extra_options => { metric => $metric }, + closure_custom_output => $self->can('custom_metric_output'), + closure_custom_perfdata => $self->can('custom_metric_perfdata'), + closure_custom_threshold_check => $self->can('custom_metric_threshold') + } + }; + push @{$self->{maps_counters}->{statistics}}, $entry; + } +} + +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 => { + 'volumeid:s@' => { name => 'volume_id' }, + 'per-sec' => { name => 'per_sec' }, + 'filter-metric:s' => { name => 'filter_metric' } + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + if (!defined($self->{option_results}->{volume_id}) || $self->{option_results}->{volume_id} eq '') { + $self->{output}->add_option_msg(short_msg => "Need to specify --volumeid option."); + $self->{output}->option_exit(); + }; + + foreach my $instance (@{$self->{option_results}->{volume_id}}) { + if ($instance ne '') { + push @{$self->{aws_instance}}, $instance; + }; + } + + $self->{aws_timeframe} = defined($self->{option_results}->{timeframe}) ? $self->{option_results}->{timeframe} : 600; + $self->{aws_period} = defined($self->{option_results}->{period}) ? $self->{option_results}->{period} : 60; + + $self->{aws_statistics} = ['Average']; + if (defined($self->{option_results}->{statistic})) { + $self->{aws_statistics} = []; + foreach my $stat (@{$self->{option_results}->{statistic}}) { + if ($stat ne '') { + push @{$self->{aws_statistics}}, ucfirst(lc($stat)); + } + } + }; + foreach my $metric (keys %metrics_mapping) { + next if (defined($self->{option_results}->{filter_metric}) && $self->{option_results}->{filter_metric} ne '' + && $metric !~ /$self->{option_results}->{filter_metric}/); + push @{$self->{aws_metrics}}, $metric; + }; +} + +sub manage_selection { + my ($self, %options) = @_; + + my %metric_results; + foreach my $instance (@{$self->{aws_instance}}) { + $metric_results{$instance} = $options{custom}->cloudwatch_get_metrics( + region => $self->{option_results}->{region}, + namespace => 'AWS/EBS', + dimensions => [ { Name => 'VolumeId', Value => $instance } ], + metrics => $self->{aws_metrics}, + statistics => $self->{aws_statistics}, + timeframe => $self->{aws_timeframe}, + period => $self->{aws_period}, + ); + + foreach my $metric (@{$self->{aws_metrics}}) { + foreach my $statistic (@{$self->{aws_statistics}}) { + next if (!defined($metric_results{$instance}->{$metric}->{lc($statistic)}) && + !defined($self->{option_results}->{zeroed})); + $self->{metrics}->{$instance}->{display} = $instance; + $self->{metrics}->{$instance}->{statistics}->{lc($statistic)}->{display} = $statistic; + $self->{metrics}->{$instance}->{statistics}->{lc($statistic)}->{timeframe} = $self->{aws_timeframe}; + $self->{metrics}->{$instance}->{statistics}->{lc($statistic)}->{$metric} = + defined($metric_results{$instance}->{$metric}->{lc($statistic)}) ? + $metric_results{$instance}->{$metric}->{lc($statistic)} : 0; + } + } + } + + if (scalar(keys %{$self->{metrics}}) <= 0) { + $self->{output}->add_option_msg(short_msg => 'No metrics. Check your options or use --zeroed option to set 0 on undefined values'); + $self->{output}->option_exit(); + } +} + +1; + +__END__ + +=head1 MODE + +Check Amazon Elastic Block Store volumes IO usage. + +Example: +perl centreon_plugins.pl --plugin=cloud::aws::ebs::plugin --custommode=awscli --mode=volumeio --region='eu-west-1' +--volumeid='vol-1234abcd' --warning-write-bytes='100000' --critical-write-bytes='200000' --warning --verbose + +See 'https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using_cloudwatch_ebs.html' for more information. + + +=over 8 + +=item B<--volumeid> + +Set the VolumeId (Required). + +=item B<--filter-metric> + +Filter on a specific metric. +Can be: VolumeReadBytes, VolumeWriteBytes + +=item B<--warning-$metric$> + +Warning thresholds ($metric$ can be: 'volume-read-bytes', 'volume-write-bytes'). + +=item B<--critical-$metric$> + +Critical thresholds ($metric$ can be: 'volume-read-bytes', 'volume-write-bytes'). + +=item B<--per-sec> + +Change the data to be unit/sec. + +=back + +=cut diff --git a/cloud/aws/ebs/mode/volumeiops.pm b/cloud/aws/ebs/mode/volumeiops.pm new file mode 100644 index 000000000..8207c81e0 --- /dev/null +++ b/cloud/aws/ebs/mode/volumeiops.pm @@ -0,0 +1,309 @@ +# +# Copyright 2020 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 cloud::aws::ebs::mode::volumeiops; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +my %metrics_mapping = ( + 'VolumeReadOps' => { + 'output' => 'IOPS Read', + 'label' => 'iops-read', + 'nlabel' => { + 'absolute' => 'ebs.volume.iops.read.count', + 'per_second' => 'ebs.volume.iops.read.countpersecond' + }, + 'unit' => '' + }, + 'VolumeWriteOps' => { + 'output' => 'IOPS Write', + 'label' => 'iops-write', + 'nlabel' => { + 'absolute' => 'ebs.volume.iops.write.count', + 'per_second' => 'ebs.volume.iops.write.countpersecond' + }, + 'unit' => '' + }, + 'VolumeThroughputPercentage' => { + 'output' => 'IOPS Throughput', + 'label' => 'iops-throughput', + 'nlabel' => { + 'absolute' => 'ebs.volume.iops.throughput.percentage', + 'per_second' => 'ebs.volume.iops.throughput.percentagepersecond' + }, + 'unit' => '%' + }, + 'VolumeConsumedReadWriteOps' => { + 'output' => 'IOPS Consumed', + 'label' => 'iops-consumed', + 'nlabel' => { + 'absolute' => 'ebs.volume.iops.consumed.count', + 'per_second' => 'ebs.volume.iops.consumed.countpersecond' + }, + 'unit' => '' + }, + 'VolumeQueueLength' => { + 'output' => 'IOPS Queue Length', + 'label' => 'iops-queue-length', + 'nlabel' => { + 'absolute' => 'ebs.volume.iops.queuelength.count', + 'per_second' => 'ebs.volume.iops.queuelength.countpersecond' + }, + 'unit' => '' + }, + +); + + +sub custom_metric_calc { + my ($self, %options) = @_; + + $self->{result_values}->{timeframe} = $options{new_datas}->{$self->{instance} . '_timeframe'}; + $self->{result_values}->{value} = $options{new_datas}->{$self->{instance} . '_' . $options{extra_options}->{metric}}; + $self->{result_values}->{value_per_sec} = $self->{result_values}->{value} / $self->{result_values}->{timeframe}; + $self->{result_values}->{metric} = $options{extra_options}->{metric}; + return 0; +} + +sub custom_metric_threshold { + my ($self, %options) = @_; + + my $exit = $self->{perfdata}->threshold_check( + value => defined($self->{instance_mode}->{option_results}->{per_sec}) ? $self->{result_values}->{value_per_sec} : $self->{result_values}->{value}, + threshold => [ + { label => 'critical-' . $metrics_mapping{$self->{result_values}->{metric}}->{label} , exit_litteral => 'critical' }, + { label => 'warning-' . $metrics_mapping{$self->{result_values}->{metric}}->{label}, exit_litteral => 'warning' } + ] + ); + return $exit; +} + +sub custom_metric_perfdata { + my ($self, %options) = @_; + + $self->{output}->perfdata_add( + instances => $self->{instance}, + label => $metrics_mapping{$self->{result_values}->{metric}}->{label}, + nlabel => defined($self->{instance_mode}->{option_results}->{per_sec}) ? + $metrics_mapping{$self->{result_values}->{metric}}->{nlabel}->{per_second} : + $metrics_mapping{$self->{result_values}->{metric}}->{nlabel}->{absolute}, + unit => defined($self->{instance_mode}->{option_results}->{per_sec}) ? + $metrics_mapping{$self->{result_values}->{metric}}->{unit} . '/s' : + $metrics_mapping{$self->{result_values}->{metric}}->{unit}, + value => sprintf("%.2f", defined($self->{instance_mode}->{option_results}->{per_sec}) ? + $self->{result_values}->{value_per_sec} : + $self->{result_values}->{value}), + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $metrics_mapping{$self->{result_values}->{metric}}->{label}), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $metrics_mapping{$self->{result_values}->{metric}}->{label}), + ); +} + +sub custom_metric_output { + my ($self, %options) = @_; + my $msg = ""; + + if (defined($self->{instance_mode}->{option_results}->{per_sec})) { + my ($value, $unit) = ($metrics_mapping{$self->{result_values}->{metric}}->{unit} eq 'B') ? + $self->{perfdata}->change_bytes(value => $self->{result_values}->{value_per_sec}) : + ($self->{result_values}->{value_per_sec}, $metrics_mapping{$self->{result_values}->{metric}}->{unit}); + $msg = sprintf("%s: %.2f %s", $metrics_mapping{$self->{result_values}->{metric}}->{output}, $value, $unit . '/s'); + } else { + my ($value, $unit) = ($metrics_mapping{$self->{result_values}->{metric}}->{unit} eq 'B') ? + $self->{perfdata}->change_bytes(value => $self->{result_values}->{value}) : + ($self->{result_values}->{value}, $metrics_mapping{$self->{result_values}->{metric}}->{unit}); + $msg = sprintf("%s: %.2f %s", $metrics_mapping{$self->{result_values}->{metric}}->{output}, $value, $unit); + } + return $msg; +} + +sub prefix_metric_output { + my ($self, %options) = @_; + + return "'" . $options{instance_value}->{display} . "' "; +} + +sub prefix_statistics_output { + my ($self, %options) = @_; + + return "Statistic '" . $options{instance_value}->{display} . "' Metrics "; +} + +sub long_output { + my ($self, %options) = @_; + + return "AWS EBS Volume'" . $options{instance_value}->{display} . "' "; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'metrics', type => 3, cb_prefix_output => 'prefix_metric_output', cb_long_output => 'long_output', + message_multiple => 'All EBS metrics are ok', indent_long_output => ' ', + group => [ + { name => 'statistics', display_long => 1, cb_prefix_output => 'prefix_statistics_output', + message_multiple => 'All metrics are ok', type => 1, skipped_code => { -10 => 1 } }, + ] + } + ]; + + foreach my $metric (keys %metrics_mapping) { + my $entry = { + label => $metrics_mapping{$metric}->{label}, + set => { + key_values => [ { name => $metric }, { name => 'timeframe' }, { name => 'display' } ], + closure_custom_calc => $self->can('custom_metric_calc'), + closure_custom_calc_extra_options => { metric => $metric }, + closure_custom_output => $self->can('custom_metric_output'), + closure_custom_perfdata => $self->can('custom_metric_perfdata'), + closure_custom_threshold_check => $self->can('custom_metric_threshold') + } + }; + push @{$self->{maps_counters}->{statistics}}, $entry; + } +} + +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 => { + 'volumeid:s@' => { name => 'volume_id' }, + 'per-sec' => { name => 'per_sec' }, + 'filter-metric:s' => { name => 'filter_metric' } + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + if (!defined($self->{option_results}->{volume_id}) || $self->{option_results}->{volume_id} eq '') { + $self->{output}->add_option_msg(short_msg => "Need to specify --volumeid option."); + $self->{output}->option_exit(); + }; + + foreach my $instance (@{$self->{option_results}->{volume_id}}) { + if ($instance ne '') { + push @{$self->{aws_instance}}, $instance; + }; + } + + $self->{aws_timeframe} = defined($self->{option_results}->{timeframe}) ? $self->{option_results}->{timeframe} : 600; + $self->{aws_period} = defined($self->{option_results}->{period}) ? $self->{option_results}->{period} : 60; + + $self->{aws_statistics} = ['Average']; + if (defined($self->{option_results}->{statistic})) { + $self->{aws_statistics} = []; + foreach my $stat (@{$self->{option_results}->{statistic}}) { + if ($stat ne '') { + push @{$self->{aws_statistics}}, ucfirst(lc($stat)); + } + } + }; + foreach my $metric (keys %metrics_mapping) { + next if (defined($self->{option_results}->{filter_metric}) && $self->{option_results}->{filter_metric} ne '' + && $metric !~ /$self->{option_results}->{filter_metric}/); + push @{$self->{aws_metrics}}, $metric; + }; +} + +sub manage_selection { + my ($self, %options) = @_; + + my %metric_results; + foreach my $instance (@{$self->{aws_instance}}) { + $metric_results{$instance} = $options{custom}->cloudwatch_get_metrics( + region => $self->{option_results}->{region}, + namespace => 'AWS/EBS', + dimensions => [ { Name => 'VolumeId', Value => $instance } ], + metrics => $self->{aws_metrics}, + statistics => $self->{aws_statistics}, + timeframe => $self->{aws_timeframe}, + period => $self->{aws_period}, + ); + + foreach my $metric (@{$self->{aws_metrics}}) { + foreach my $statistic (@{$self->{aws_statistics}}) { + next if (!defined($metric_results{$instance}->{$metric}->{lc($statistic)}) && + !defined($self->{option_results}->{zeroed})); + $self->{metrics}->{$instance}->{display} = $instance; + $self->{metrics}->{$instance}->{statistics}->{lc($statistic)}->{display} = $statistic; + $self->{metrics}->{$instance}->{statistics}->{lc($statistic)}->{timeframe} = $self->{aws_timeframe}; + $self->{metrics}->{$instance}->{statistics}->{lc($statistic)}->{$metric} = + defined($metric_results{$instance}->{$metric}->{lc($statistic)}) ? + $metric_results{$instance}->{$metric}->{lc($statistic)} : 0; + } + } + } + + if (scalar(keys %{$self->{metrics}}) <= 0) { + $self->{output}->add_option_msg(short_msg => 'No metrics. Check your options or use --zeroed option to set 0 on undefined values'); + $self->{output}->option_exit(); + } +} + +1; + +__END__ + +=head1 MODE + +Check Amazon Elastic Block Store volumes IOPS. + +Example: +perl centreon_plugins.pl --plugin=cloud::aws::ebs::plugin --custommode=awscli --mode=volumeiops --region='eu-west-1' +--volumeid='vol-1234abcd' --warning-iops-queue-length='100' --critical-iops-queue-length='200' --warning --verbose + +See 'https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using_cloudwatch_ebs.html' for more information. + + +=over 8 + +=item B<--volumeid> + +Set the VolumeId (Required). + +=item B<--filter-metric> + +Filter on a specific metric. +Can be: VolumeReadOps, VolumeWriteOps, VolumeThroughputPercentage, VolumeConsumedReadWriteOps + +=item B<--warning-$metric$> + +Warning thresholds ($metric$ can be: 'iops-read', 'iops-write', 'iops-throughput', 'iops-consumed-rw', 'iops-queue-length'). + +=item B<--critical-$metric$> + +Critical thresholds ($metric$ can be: 'iops-read', 'iops-write', 'iops-throughput', 'iops-consumed-rw', 'iops-queue-length'). + +=item B<--per-sec> + +Change the data to be unit/sec. + +=back + +=cut diff --git a/cloud/aws/ebs/mode/volumetime.pm b/cloud/aws/ebs/mode/volumetime.pm new file mode 100644 index 000000000..aea3122e9 --- /dev/null +++ b/cloud/aws/ebs/mode/volumetime.pm @@ -0,0 +1,270 @@ +# +# Copyright 2020 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 cloud::aws::ebs::mode::volumetime; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +my %metrics_mapping = ( + 'VolumeTotalReadTime' => { + 'output' => 'Total Read Time', + 'label' => 'total-read-time', + 'nlabel' => { 'absolute' => 'ebs.volume.totalread.time.second' }, + 'unit' => 's' + }, + 'VolumeTotalWriteTime' => { + 'output' => 'Total Write Time', + 'label' => 'total-write-time', + 'nlabel' => { 'absolute' => 'ebs.volume.totalwrite.time.second' }, + 'unit' => 's' + }, + 'VolumeIdleTime' => { + 'output' => 'Idle Time', + 'label' => 'idle-time', + 'nlabel' => { 'absolute' => 'ebs.volume.idle.time.second' }, + 'unit' => 's', + 'display_percent' => 1 + } +); + + +sub custom_metric_calc { + my ($self, %options) = @_; + + $self->{result_values}->{timeframe} = $options{new_datas}->{$self->{instance} . '_timeframe'}; + $self->{result_values}->{period} = $options{new_datas}->{$self->{instance} . '_period'}; + $self->{result_values}->{value} = $options{new_datas}->{$self->{instance} . '_' . $options{extra_options}->{metric}}; + $self->{result_values}->{metric} = $options{extra_options}->{metric}; + return 0; +} + +sub custom_metric_threshold { + my ($self, %options) = @_; + + my $exit = $self->{perfdata}->threshold_check( + value => $self->{result_values}->{value}, + threshold => [ + { label => 'critical-' . $metrics_mapping{$self->{result_values}->{metric}}->{label} , exit_litteral => 'critical' }, + { label => 'warning-' . $metrics_mapping{$self->{result_values}->{metric}}->{label}, exit_litteral => 'warning' } + ] + ); + return $exit; +} + +sub custom_metric_perfdata { + my ($self, %options) = @_; + + $self->{output}->perfdata_add( + instances => $self->{instance}, + label => $metrics_mapping{$self->{result_values}->{metric}}->{label}, + nlabel => $metrics_mapping{$self->{result_values}->{metric}}->{nlabel}->{absolute}, + unit => $metrics_mapping{$self->{result_values}->{metric}}->{unit}, + value => $self->{result_values}->{value}, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $metrics_mapping{$self->{result_values}->{metric}}->{label}), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $metrics_mapping{$self->{result_values}->{metric}}->{label}), + ); +} + +sub custom_metric_output { + my ($self, %options) = @_; + my $msg = ""; + + my ($value, $unit) = ($metrics_mapping{$self->{result_values}->{metric}}->{unit} eq 'B') ? + $self->{perfdata}->change_bytes(value => $self->{result_values}->{value}) : + ($self->{result_values}->{value}, $metrics_mapping{$self->{result_values}->{metric}}->{unit}); + if (defined($metrics_mapping{$self->{result_values}->{metric}}->{display_percent})) { + my $percent = ($self->{result_values}->{value} / $self->{result_values}->{period} * 100); + $msg = sprintf("%s: %.2f%s (%.2f%)", $metrics_mapping{$self->{result_values}->{metric}}->{output}, $value, $unit, $percent); + } else { + $msg = sprintf("%s: %.2f%s", $metrics_mapping{$self->{result_values}->{metric}}->{output}, $value, $unit); + }; + return $msg; +} + +sub prefix_metric_output { + my ($self, %options) = @_; + + return "'" . $options{instance_value}->{display} . "' "; +} + +sub prefix_statistics_output { + my ($self, %options) = @_; + + return "Statistic '" . $options{instance_value}->{display} . "' Metrics "; +} + +sub long_output { + my ($self, %options) = @_; + + return "AWS EBS Volume'" . $options{instance_value}->{display} . "' "; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'metrics', type => 3, cb_prefix_output => 'prefix_metric_output', cb_long_output => 'long_output', + message_multiple => 'All EBS metrics are ok', indent_long_output => ' ', + group => [ + { name => 'statistics', display_long => 1, cb_prefix_output => 'prefix_statistics_output', + message_multiple => 'All metrics are ok', type => 1, skipped_code => { -10 => 1 } }, + ] + } + ]; + + foreach my $metric (keys %metrics_mapping) { + my $entry = { + label => $metrics_mapping{$metric}->{label}, + set => { + key_values => [ { name => $metric }, { name => 'timeframe' }, { name => 'display' }, { name => 'period'} ], + closure_custom_calc => $self->can('custom_metric_calc'), + closure_custom_calc_extra_options => { metric => $metric }, + closure_custom_output => $self->can('custom_metric_output'), + closure_custom_perfdata => $self->can('custom_metric_perfdata'), + closure_custom_threshold_check => $self->can('custom_metric_threshold') + } + }; + push @{$self->{maps_counters}->{statistics}}, $entry; + } +} + +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 => { + 'volumeid:s@' => { name => 'volume_id' }, + 'filter-metric:s' => { name => 'filter_metric' } + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + if (!defined($self->{option_results}->{volume_id}) || $self->{option_results}->{volume_id} eq '') { + $self->{output}->add_option_msg(short_msg => "Need to specify --volumeid option."); + $self->{output}->option_exit(); + }; + + foreach my $instance (@{$self->{option_results}->{volume_id}}) { + if ($instance ne '') { + push @{$self->{aws_instance}}, $instance; + }; + } + + $self->{aws_timeframe} = defined($self->{option_results}->{timeframe}) ? $self->{option_results}->{timeframe} : 600; + $self->{aws_period} = defined($self->{option_results}->{period}) ? $self->{option_results}->{period} : 60; + + $self->{aws_statistics} = ['Average']; + if (defined($self->{option_results}->{statistic})) { + $self->{aws_statistics} = []; + foreach my $stat (@{$self->{option_results}->{statistic}}) { + if ($stat ne '') { + push @{$self->{aws_statistics}}, ucfirst(lc($stat)); + } + } + }; + foreach my $metric (keys %metrics_mapping) { + next if (defined($self->{option_results}->{filter_metric}) && $self->{option_results}->{filter_metric} ne '' + && $metric !~ /$self->{option_results}->{filter_metric}/); + push @{$self->{aws_metrics}}, $metric; + }; +} + +sub manage_selection { + my ($self, %options) = @_; + + my %metric_results; + foreach my $instance (@{$self->{aws_instance}}) { + $metric_results{$instance} = $options{custom}->cloudwatch_get_metrics( + region => $self->{option_results}->{region}, + namespace => 'AWS/EBS', + dimensions => [ { Name => 'VolumeId', Value => $instance } ], + metrics => $self->{aws_metrics}, + statistics => $self->{aws_statistics}, + timeframe => $self->{aws_timeframe}, + period => $self->{aws_period}, + ); + + foreach my $metric (@{$self->{aws_metrics}}) { + foreach my $statistic (@{$self->{aws_statistics}}) { + next if (!defined($metric_results{$instance}->{$metric}->{lc($statistic)}) && + !defined($self->{option_results}->{zeroed})); + $self->{metrics}->{$instance}->{display} = $instance; + $self->{metrics}->{$instance}->{statistics}->{lc($statistic)}->{display} = $statistic; + $self->{metrics}->{$instance}->{statistics}->{lc($statistic)}->{timeframe} = $self->{aws_timeframe}; + $self->{metrics}->{$instance}->{statistics}->{lc($statistic)}->{period} = $self->{aws_period}; + $self->{metrics}->{$instance}->{statistics}->{lc($statistic)}->{$metric} = + defined($metric_results{$instance}->{$metric}->{lc($statistic)}) ? + $metric_results{$instance}->{$metric}->{lc($statistic)} : 0; + } + } + } + + if (scalar(keys %{$self->{metrics}}) <= 0) { + $self->{output}->add_option_msg(short_msg => 'No metrics. Check your options or use --zeroed option to set 0 on undefined values'); + $self->{output}->option_exit(); + } +} + +1; + +__END__ + +=head1 MODE + +Check Amazon Elastic Block Store volumes operations time. + +Example: +perl centreon_plugins.pl --plugin=cloud::aws::ebs::plugin --custommode=awscli --mode=volumetime --region='eu-west-1' +--volumeid='vol-1234abcd' --warning-write-time='40' --critical-write-time='50' --warning --verbose + +See 'https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using_cloudwatch_ebs.html' for more information. + + +=over 8 + +=item B<--volumeid> + +Set the VolumeId (Required). + +=item B<--filter-metric> + +Filter on a specific metric. +Can be: VolumeTotalReadTime, VolumeTotalWriteTime, VolumeIdleTime + +=item B<--warning-$metric$> + +Warning thresholds ($metric$ can be: 'total-read-time', 'total-write-time', 'idle-time'). + +=item B<--critical-$metric$> + +Critical thresholds ($metric$ can be: 'total-read-time', 'total-write-time', 'idle-time'). + +=back + +=cut diff --git a/cloud/aws/ebs/plugin.pm b/cloud/aws/ebs/plugin.pm index 324a9fc65..c0a96660e 100644 --- a/cloud/aws/ebs/plugin.pm +++ b/cloud/aws/ebs/plugin.pm @@ -29,11 +29,13 @@ sub new { my $self = $class->SUPER::new( package => __PACKAGE__, %options ); bless $self, $class; - $self->{version} = '0.1'; + $self->{version} = '1.0'; %{ $self->{modes} } = ( - 'volume-throughput' => 'cloud::aws::ebs::mode::volumethroughput', - 'volume-iops' => 'cloud::aws::ebs::mode::volumeiops', - 'volume-time' => 'cloud::aws::ebs::mode::volumetime', + 'discovery' => 'cloud::aws::ebs::mode::discovery', + 'list-volumes' => 'cloud::aws::ebs::mode::listvolumes', + 'volumeio' => 'cloud::aws::ebs::mode::volumeio', + 'volumeiops' => 'cloud::aws::ebs::mode::volumeiops', + 'volumetime' => 'cloud::aws::ebs::mode::volumetime' ); $self->{custom_modes}{paws} = 'cloud::aws::custom::paws'; From f3e58b57718f82a1a773e28fa08e125da7c413dc Mon Sep 17 00:00:00 2001 From: Simon Bomm Date: Tue, 12 May 2020 16:30:25 +0200 Subject: [PATCH 212/283] + remove unwanted Dumper --- cloud/aws/custom/paws.pm | 1 - 1 file changed, 1 deletion(-) diff --git a/cloud/aws/custom/paws.pm b/cloud/aws/custom/paws.pm index 8b433e7ab..7ba46bf51 100644 --- a/cloud/aws/custom/paws.pm +++ b/cloud/aws/custom/paws.pm @@ -25,7 +25,6 @@ use warnings; use Paws; use Paws::Net::LWPCaller; use DateTime; -use Data::Dumper; sub new { my ($class, %options) = @_; From 71e7f63f2bd4bfa959a98194c4ce4ff08548c8bd Mon Sep 17 00:00:00 2001 From: UrBnW <40244829+UrBnW@users.noreply.github.com> Date: Wed, 13 May 2020 09:35:52 +0200 Subject: [PATCH 213/283] enh(aix) Add uptime mode --- os/aix/snmp/plugin.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/os/aix/snmp/plugin.pm b/os/aix/snmp/plugin.pm index 131e534c6..40d179eec 100644 --- a/os/aix/snmp/plugin.pm +++ b/os/aix/snmp/plugin.pm @@ -40,6 +40,7 @@ sub new { 'storage' => 'snmp_standard::mode::storage', 'swap' => 'os::aix::snmp::mode::swap', 'time' => 'snmp_standard::mode::ntp', + 'uptime' => 'snmp_standard::mode::uptime', ); return $self; From 0dedcd20549bc2d539755cee45158149f52b751d Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 13 May 2020 14:18:28 +0200 Subject: [PATCH 214/283] simplify class counters naming --- .../activedirectory/local/mode/dfsrbacklog.pm | 2 +- .../kaspersky/snmp/mode/deployment.pm | 2 +- apps/antivirus/kaspersky/snmp/mode/events.pm | 2 +- .../antivirus/kaspersky/snmp/mode/fullscan.pm | 2 +- .../kaspersky/snmp/mode/logicalnetwork.pm | 8 +- .../kaspersky/snmp/mode/protection.pm | 10 +- apps/antivirus/kaspersky/snmp/mode/updates.pm | 2 +- .../mcafee/webgateway/snmp/mode/clients.pm | 4 +- .../webgateway/snmp/mode/connections.pm | 42 ++---- .../mcafee/webgateway/snmp/mode/detections.pm | 35 ++--- .../webgateway/snmp/mode/ftpstatistics.pm | 36 ++--- .../webgateway/snmp/mode/httpsstatistics.pm | 42 ++---- .../webgateway/snmp/mode/httpstatistics.pm | 57 +++----- .../ansible/tower/mode/dashboard.pm | 18 +-- .../ansible/tower/mode/inventorystatistics.pm | 36 ++--- .../arcserve/udp/mssql/mode/jobstatus.pm | 2 +- .../netapp/snapcenter/restapi/mode/jobs.pm | 2 +- .../netbackup/local/mode/dedupstatus.pm | 8 +- .../netbackup/local/mode/drivecleaning.pm | 4 +- apps/backup/netbackup/local/mode/jobstatus.pm | 2 +- .../quadstor/local/mode/vtltapeusage.pm | 2 +- apps/backup/rapidrecovery/snmp/mode/agent.pm | 6 +- .../rapidrecovery/snmp/mode/repository.pm | 22 +-- apps/backup/tsm/local/mode/drives.pm | 16 +-- apps/backup/tsm/local/mode/nodes.pm | 6 +- apps/backup/tsm/local/mode/sessions.pm | 2 +- apps/backup/tsm/local/mode/volumes.pm | 18 +-- apps/backup/veeam/local/mode/jobstatus.pm | 2 +- apps/backup/veeam/local/mode/tapejobs.pm | 2 +- apps/bind9/web/mode/serverusage.pm | 2 +- apps/bind9/web/mode/zoneusage.pm | 4 +- apps/bluemind/local/mode/core.pm | 12 +- apps/bluemind/local/mode/eas.pm | 6 +- apps/bluemind/local/mode/hps.pm | 16 +-- apps/bluemind/local/mode/ips.pm | 2 +- apps/bluemind/local/mode/lmtpd.pm | 18 +-- apps/bluemind/local/mode/milter.pm | 14 +- apps/bluemind/local/mode/webserver.pm | 10 +- apps/bluemind/local/mode/xmpp.pm | 4 +- apps/centreon/local/mode/brokerstats.pm | 12 +- apps/centreon/local/mode/centenginestats.pm | 82 +++++------ apps/centreon/map/jmx/mode/brokerstats.pm | 31 ++--- apps/centreon/map/jmx/mode/enginestats.pm | 24 ++-- apps/centreon/map/jmx/mode/events.pm | 24 ++-- apps/centreon/map/jmx/mode/openviews.pm | 2 +- apps/centreon/map/jmx/mode/sessions.pm | 4 +- apps/centreon/map/jmx/mode/syncstats.pm | 30 ++-- apps/centreon/restapi/mode/submitresult.pm | 6 +- apps/centreon/sql/mode/countservices.pm | 4 +- apps/centreon/sql/mode/dsmqueue.pm | 6 +- apps/centreon/sql/mode/pollerdelay.pm | 2 +- apps/cisco/cms/restapi/mode/calls.pm | 8 +- apps/cisco/cms/restapi/mode/systemstatus.pm | 12 +- apps/cisco/ise/restapi/mode/session.pm | 6 +- apps/citrix/local/mode/license.pm | 16 +-- apps/haproxy/snmp/mode/backendusage.pm | 34 ++--- apps/haproxy/snmp/mode/frontendusage.pm | 44 +++--- apps/hddtemp/mode/temperatures.pm | 12 +- apps/hyperv/2012/local/mode/nodesnapshot.pm | 4 +- apps/hyperv/2012/local/mode/scvmmsnapshot.pm | 2 +- apps/inin/ig/snmp/mode/spanusage.pm | 4 +- apps/inin/ig/snmp/mode/stats.pm | 8 +- .../mediaserver/snmp/mode/audioengineusage.pm | 8 +- .../inin/mediaserver/snmp/mode/cmdsrvusage.pm | 4 +- .../inin/mediaserver/snmp/mode/memoryusage.pm | 2 +- apps/java/hibernate/jmx/mode/stats.pm | 20 +-- apps/java/jboss/jmx/mode/datasourceusage.pm | 16 +-- apps/java/kafka/jmx/mode/globalstats.pm | 35 +++-- apps/java/solr/jmx/mode/cacheusage.pm | 16 +-- .../java/solr/jmx/mode/requesthandlerusage.pm | 16 +-- apps/java/weblogic/jmx/mode/workmanager.pm | 12 +- apps/java/zookeeper/jmx/mode/stats.pm | 12 +- apps/kingdee/eas/mode/activeusers.pm | 4 +- apps/kingdee/eas/mode/classloading.pm | 4 +- apps/kingdee/eas/mode/datasource.pm | 16 +-- apps/kingdee/eas/mode/handlers.pm | 30 ++-- apps/kingdee/eas/mode/ibmjvmgc.pm | 4 +- apps/kingdee/eas/mode/javaruntime.pm | 4 +- apps/kingdee/eas/mode/memory.pm | 2 +- apps/kingdee/eas/mode/oraclejvmgc.pm | 8 +- apps/kingdee/eas/mode/oracleksqltemptable.pm | 2 +- apps/kingdee/eas/mode/oraclerecyclebin.pm | 2 +- apps/kingdee/eas/mode/oracleredolog.pm | 6 +- apps/kingdee/eas/mode/oraclesession.pm | 6 +- apps/kingdee/eas/mode/oracletable.pm | 4 +- apps/kingdee/eas/mode/ormrpc.pm | 18 +-- apps/kingdee/eas/mode/transaction.pm | 16 +-- apps/lync/2013/mssql/mode/lyncusers.pm | 4 +- .../dynatrace/restapi/mode/problems.pm | 2 +- apps/monitoring/mip/restapi/mode/scenarios.pm | 18 +-- .../restapi/mode/webscenariosavailability.pm | 12 +- apps/monitoring/scom/restapi/mode/alerts.pm | 2 +- apps/mq/activemq/jmx/mode/brokers.pm | 26 ++-- apps/mq/ibmmq/mqi/mode/channels.pm | 21 +-- apps/mq/ibmmq/mqi/mode/queuemanager.pm | 4 +- apps/mq/ibmmq/mqi/mode/queues.pm | 14 +- apps/mq/rabbitmq/restapi/mode/nodeusage.pm | 20 ++- apps/mq/rabbitmq/restapi/mode/queueusage.pm | 8 +- apps/mq/rabbitmq/restapi/mode/systemusage.pm | 34 ++--- apps/mq/rabbitmq/restapi/mode/vhostusage.pm | 8 +- apps/mq/vernemq/restapi/mode/clusters.pm | 4 +- apps/mq/vernemq/restapi/mode/listeners.pm | 4 +- apps/mq/vernemq/restapi/mode/plugins.pm | 2 +- apps/mq/vernemq/restapi/mode/sessions.pm | 4 +- apps/mulesoft/restapi/mode/applications.pm | 8 +- apps/mulesoft/restapi/mode/clusters.pm | 6 +- apps/mulesoft/restapi/mode/servers.pm | 6 +- apps/openldap/ldap/mode/systemusage.pm | 33 ++--- apps/openvpn/omi/mode/serverusage.pm | 23 ++-- .../restapi/mode/cityweather.pm | 8 +- apps/pfsense/snmp/mode/packetstats.pm | 45 +++--- apps/pfsense/snmp/mode/pfinterfaces.pm | 45 +++--- apps/php/apc/web/mode/filecache.pm | 22 +-- apps/php/apc/web/mode/memory.pm | 4 +- apps/php/fpm/web/mode/usage.pm | 44 +++--- apps/pineapp/securemail/snmp/mode/system.pm | 14 +- apps/protocols/bgp/4/mode/bgppeerstate.pm | 4 +- apps/protocols/http/mode/expectedcontent.pm | 6 +- apps/protocols/http/mode/response.pm | 4 +- apps/protocols/ldap/mode/search.pm | 4 +- apps/protocols/ospf/snmp/mode/neighbor.pm | 2 +- apps/protocols/radius/mode/login.pm | 2 +- apps/protocols/snmp/mode/responsetime.pm | 8 +- apps/protocols/ssh/mode/login.pm | 2 +- apps/protocols/tftp/mode/commands.pm | 4 +- apps/proxmox/ve/restapi/mode/vmusage.pm | 31 ++--- apps/pvx/restapi/mode/httphits.pm | 12 +- apps/pvx/restapi/mode/networkconnection.pm | 16 +-- apps/pvx/restapi/mode/networktraffic.pm | 18 +-- .../pvx/restapi/mode/networkuserexperience.pm | 4 +- apps/redis/cli/mode/clients.pm | 8 +- apps/redis/cli/mode/commands.pm | 4 +- apps/redis/cli/mode/connections.pm | 22 ++- apps/redis/cli/mode/cpu.pm | 12 +- apps/redis/cli/mode/memory.pm | 6 +- apps/redis/cli/mode/persistence.pm | 10 +- apps/redis/cli/mode/replication.pm | 12 +- apps/redis/restapi/mode/clusterstats.pm | 16 +-- apps/redis/restapi/mode/databasesstats.pm | 44 +++--- apps/redis/restapi/mode/nodesstats.pm | 38 +++--- apps/redis/restapi/mode/shardsstats.pm | 44 +++--- apps/rudder/restapi/mode/globalcompliance.pm | 2 +- apps/rudder/restapi/mode/nodecompliance.pm | 4 +- apps/rudder/restapi/mode/rulecompliance.pm | 2 +- apps/rudder/restapi/mode/statistics.pm | 12 +- apps/sahipro/restapi/mode/scenario.pm | 12 +- apps/salesforce/restapi/mode/sfdcinstance.pm | 2 +- apps/selenium/mode/scenariokatalon.pm | 6 +- apps/slack/restapi/mode/countchannels.pm | 2 +- apps/slack/restapi/mode/countmembers.pm | 2 +- apps/squid/snmp/mode/cacheusage.pm | 8 +- apps/squid/snmp/mode/protocolstats.pm | 47 ++++--- apps/tomcat/jmx/mode/connectorusage.pm | 27 ++-- apps/tomcat/jmx/mode/webappssessions.pm | 4 +- apps/tomcat/web/mode/applications.pm | 4 +- apps/tomcat/web/mode/connectors.pm | 24 ++-- apps/tomcat/web/mode/memory.pm | 16 +-- apps/toshiba/storemate/sql/mode/posstatus.pm | 32 ++--- apps/varnish/local/mode/stats.pm | 128 +++++++++--------- apps/video/openheadend/snmp/mode/nodeusage.pm | 4 +- .../restapi/mode/broadcasterinputusage.pm | 33 +++-- .../restapi/mode/broadcasteroutputusage.pm | 43 +++--- .../restapi/mode/broadcastersystemusage.pm | 6 +- .../zixi/restapi/mode/feederinputusage.pm | 29 ++-- .../zixi/restapi/mode/feederoutputusage.pm | 4 +- apps/virtualization/ovirt/mode/cpuhost.pm | 8 +- apps/vmware/connector/mode/alarmdatacenter.pm | 4 +- apps/vmware/connector/mode/alarmhost.pm | 4 +- apps/vmware/connector/mode/countvmhost.pm | 24 ++-- apps/vmware/connector/mode/cpuhost.pm | 8 +- apps/vmware/connector/mode/cpuvm.pm | 8 +- .../vmware/connector/mode/datastorecountvm.pm | 24 ++-- apps/vmware/connector/mode/datastorehost.pm | 4 +- apps/vmware/connector/mode/datastoreio.pm | 8 +- apps/vmware/connector/mode/datastoreiops.pm | 12 +- .../connector/mode/datastoresnapshot.pm | 2 +- apps/vmware/connector/mode/datastoreusage.pm | 22 +-- apps/vmware/connector/mode/datastorevm.pm | 8 +- apps/vmware/connector/mode/devicevm.pm | 6 +- apps/vmware/connector/mode/healthhost.pm | 22 +-- apps/vmware/connector/mode/memoryhost.pm | 8 +- apps/vmware/connector/mode/memoryvm.pm | 12 +- apps/vmware/connector/mode/nethost.pm | 8 +- apps/vmware/connector/mode/statconnectors.pm | 4 +- apps/vmware/connector/mode/swaphost.pm | 4 +- apps/vmware/connector/mode/swapvm.pm | 4 +- apps/vmware/connector/mode/timehost.pm | 4 +- apps/vmware/connector/mode/uptimehost.pm | 4 +- .../connector/mode/vmoperationcluster.pm | 6 +- .../vmware/connector/mode/vsanclusterusage.pm | 16 +-- apps/voip/3cx/restapi/mode/system.pm | 4 +- apps/voip/asterisk/ami/mode/channelusage.pm | 8 +- apps/voip/asterisk/ami/mode/sippeersusage.pm | 10 +- apps/voip/asterisk/snmp/mode/channelusage.pm | 6 +- apps/vtom/restapi/mode/jobstatus.pm | 20 +-- apps/wazuh/restapi/mode/agents.pm | 2 +- apps/wazuh/restapi/mode/manager.pm | 4 +- apps/wsus/local/mode/computersstatus.pm | 10 +- apps/wsus/local/mode/serverstatistics.pm | 16 +-- apps/wsus/local/mode/updatesstatus.pm | 10 +- .../hyperledger/exporter/mode/channels.pm | 12 +- .../snmp/mode/apchannelinterference.pm | 8 +- .../airespace/snmp/mode/apchannelnoise.pm | 4 +- .../common/airespace/snmp/mode/apstatus.pm | 10 +- .../common/airespace/snmp/mode/apusers.pm | 28 ++-- .../common/aruba/snmp/mode/apconnections.pm | 18 +-- .../aruba/snmp/mode/apssidstatistics.pm | 10 +- centreon/common/aruba/snmp/mode/apstatus.pm | 14 +- centreon/common/aruba/snmp/mode/apusers.pm | 24 ++-- .../aruba/snmp/mode/controllerstatus.pm | 2 +- centreon/common/aruba/snmp/mode/cpu.pm | 4 +- centreon/common/avaya/snmp/mode/cpu.pm | 4 +- .../common/broadcom/fastpath/snmp/mode/cpu.pm | 6 +- .../common/cisco/ironport/snmp/mode/cpu.pm | 4 +- .../cisco/ironport/snmp/mode/mailusage.pm | 20 +-- .../cisco/ironport/snmp/mode/proxyusage.pm | 43 +++--- .../cisco/ironport/xmlapi/mode/systemusage.pm | 35 ++--- .../common/cisco/standard/snmp/mode/cpu.pm | 18 +-- .../cisco/standard/snmp/mode/ipsectunnel.pm | 34 ++--- .../common/cisco/standard/snmp/mode/ipsla.pm | 2 +- .../common/cisco/standard/snmp/mode/load.pm | 12 +- .../cisco/standard/snmp/mode/memoryflash.pm | 22 +-- .../cisco/standard/snmp/mode/qosusage.pm | 39 +++--- .../cisco/standard/snmp/mode/sessions.pm | 76 ++++------- .../common/cisco/standard/snmp/mode/stack.pm | 22 +-- .../cisco/standard/snmp/mode/voicecall.pm | 8 +- .../common/cisco/standard/snmp/mode/wan3g.pm | 22 ++- .../common/cps/ups/snmp/mode/batterystatus.pm | 10 +- .../common/cps/ups/snmp/mode/inputlines.pm | 4 +- .../common/cps/ups/snmp/mode/outputlines.pm | 10 +- .../common/emc/navisphere/mode/controller.pm | 23 ++-- centreon/common/emc/navisphere/mode/disk.pm | 28 ++-- centreon/common/force10/snmp/mode/cpu.pm | 12 +- centreon/common/force10/snmp/mode/memory.pm | 4 +- .../fortinet/fortigate/snmp/mode/apusage.pm | 28 ++-- .../fortigate/snmp/mode/clusterstatus.pm | 8 +- .../fortinet/fortigate/snmp/mode/cpu.pm | 6 +- .../fortinet/fortigate/snmp/mode/ipsstats.pm | 36 ++--- .../fortinet/fortigate/snmp/mode/memory.pm | 18 +-- .../fortigate/snmp/mode/signatures.pm | 16 +-- .../fortinet/fortigate/snmp/mode/vdomusage.pm | 33 ++--- .../fortinet/fortigate/snmp/mode/virus.pm | 22 ++- .../fortinet/fortigate/snmp/mode/vpn.pm | 23 ++-- centreon/common/foundry/snmp/mode/cpu.pm | 6 +- centreon/common/foundry/snmp/mode/memory.pm | 16 +-- centreon/common/h3c/snmp/mode/cpu.pm | 4 +- centreon/common/ibm/nos/snmp/mode/cpu.pm | 4 +- centreon/common/ibm/nos/snmp/mode/memory.pm | 16 +-- .../common/ingrian/snmp/mode/connections.pm | 6 +- centreon/common/ingrian/snmp/mode/cpu.pm | 6 +- centreon/common/ingrian/snmp/mode/disk.pm | 4 +- .../common/ingrian/snmp/mode/requeststats.pm | 8 +- centreon/common/jvm/mode/classcount.pm | 6 +- centreon/common/jvm/mode/gcusage.pm | 8 +- centreon/common/jvm/mode/threads.pm | 6 +- .../skype/mssql/mode/appsharingqoe.pm | 8 +- .../microsoft/skype/mssql/mode/audioqoe.pm | 14 +- .../microsoft/skype/mssql/mode/poorcalls.pm | 2 +- .../skype/mssql/mode/sessionstypes.pm | 14 +- .../microsoft/skype/mssql/mode/videoqoe.pm | 14 +- .../endpoint/snmp/mode/videoconferencing.pm | 2 +- centreon/common/radlan/snmp/mode/cpu.pm | 6 +- .../steelhead/snmp/mode/bwoptimization.pm | 28 ++-- .../steelhead/snmp/mode/bwpassthrough.pm | 14 +- .../steelhead/snmp/mode/connections.pm | 14 +- .../steelhead/snmp/mode/diskutilization.pm | 16 +-- .../steelhead/snmp/mode/loadaverage.pm | 8 +- .../riverbed/steelhead/snmp/mode/status.pm | 4 +- .../steelhead/snmp/mode/temperature.pm | 2 +- .../common/xppc/snmp/mode/batterystatus.pm | 8 +- centreon/common/xppc/snmp/mode/environment.pm | 8 +- centreon/common/xppc/snmp/mode/inputlines.pm | 4 +- centreon/common/xppc/snmp/mode/outputlines.pm | 6 +- centreon/plugins/templates/counter.pm | 16 ++- centreon/plugins/values.pm | 106 +++++++-------- changelog | 3 + cloud/aws/apigateway/mode/latency.pm | 2 +- cloud/aws/apigateway/mode/requests.pm | 2 +- cloud/aws/billing/mode/estimatedcharges.pm | 2 +- cloud/aws/cloudfront/mode/errors.pm | 2 +- cloud/aws/cloudwatch/mode/getmetrics.pm | 4 +- cloud/aws/ec2/mode/cpu.pm | 2 +- cloud/aws/ec2/mode/instancesstatus.pm | 12 +- cloud/aws/ec2/mode/instancestypes.pm | 2 +- cloud/aws/ec2/mode/spotactiveinstances.pm | 6 +- cloud/aws/elasticache/mode/connections.pm | 4 +- cloud/aws/elasticache/mode/cpu.pm | 4 +- cloud/aws/elasticache/mode/items.pm | 4 +- cloud/aws/elasticache/mode/replication.pm | 4 +- cloud/aws/elasticache/mode/usagememcached.pm | 4 +- cloud/aws/elasticache/mode/usageredis.pm | 4 +- cloud/aws/elb/application/mode/connections.pm | 2 +- cloud/aws/elb/application/mode/httpcodes.pm | 2 +- .../aws/elb/application/mode/targetshealth.pm | 2 +- cloud/aws/elb/classic/mode/httpcodes.pm | 2 +- cloud/aws/elb/classic/mode/performances.pm | 2 +- cloud/aws/elb/classic/mode/queues.pm | 2 +- cloud/aws/elb/classic/mode/targetshealth.pm | 2 +- cloud/aws/elb/network/mode/targetshealth.pm | 2 +- cloud/aws/kinesis/mode/recordsstats.pm | 2 +- cloud/aws/kinesis/mode/streams.pm | 2 +- cloud/aws/lambda/mode/invocations.pm | 2 +- cloud/aws/rds/mode/connections.pm | 4 +- cloud/aws/rds/mode/cpu.pm | 8 +- cloud/aws/rds/mode/diskio.pm | 16 +-- cloud/aws/rds/mode/instancestatus.pm | 12 +- cloud/aws/rds/mode/network.pm | 4 +- cloud/aws/rds/mode/queries.pm | 8 +- cloud/aws/rds/mode/transactions.pm | 8 +- cloud/aws/rds/mode/volume.pm | 4 +- cloud/aws/s3/mode/bucketsize.pm | 4 +- cloud/aws/s3/mode/objects.pm | 4 +- cloud/aws/s3/mode/requests.pm | 4 +- .../azure/compute/virtualmachine/mode/cpu.pm | 8 +- .../compute/virtualmachine/mode/vmsizes.pm | 2 +- .../compute/virtualmachine/mode/vmsstate.pm | 4 +- .../database/sqldatabase/mode/databasesize.pm | 4 +- cloud/azure/management/monitor/mode/alert.pm | 10 +- cloud/azure/management/monitor/mode/logs.pm | 2 +- .../recovery/mode/backupitemsstatus.pm | 4 +- .../recovery/mode/backupjobsstatus.pm | 6 +- .../resource/mode/deploymentsstatus.pm | 4 +- cloud/azure/management/resource/mode/items.pm | 16 +-- .../network/vpngateway/mode/sitetraffic.pm | 4 +- .../mode/accountusedcapacity.pm | 4 +- .../storageaccount/mode/blobcapacity.pm | 4 +- .../storageaccount/mode/blobcontainercount.pm | 4 +- .../storage/storageaccount/mode/blobcount.pm | 4 +- .../storageaccount/mode/filecapacity.pm | 4 +- .../storage/storageaccount/mode/filecount.pm | 4 +- .../storageaccount/mode/filesharecount.pm | 4 +- .../storageaccount/mode/queuecapacity.pm | 4 +- .../storage/storageaccount/mode/queuecount.pm | 4 +- .../storageaccount/mode/queuemessagecount.pm | 4 +- .../storageaccount/mode/tablecapacity.pm | 4 +- .../storage/storageaccount/mode/tablecount.pm | 4 +- .../storageaccount/mode/tableentitycount.pm | 4 +- .../mode/transactionsavailability.pm | 4 +- .../mode/transactionslatency.pm | 4 +- cloud/cadvisor/restapi/mode/containerusage.pm | 46 +++---- cloud/cadvisor/restapi/mode/diskio.pm | 8 +- cloud/cadvisor/restapi/mode/nodestatus.pm | 16 +-- cloud/cadvisor/restapi/mode/traffic.pm | 8 +- cloud/cloudfoundry/restapi/mode/appsstate.pm | 4 +- .../restapi/mode/instancesstate.pm | 6 +- cloud/docker/restapi/mode/containerusage.pm | 47 +++---- cloud/docker/restapi/mode/nodestatus.pm | 12 +- cloud/ibm/softlayer/mode/events.pm | 6 +- cloud/ibm/softlayer/mode/opentickets.pm | 2 +- cloud/kubernetes/mode/podstatus.pm | 8 +- .../office365/exchange/mode/emailactivity.pm | 18 +-- .../office365/exchange/mode/mailboxusage.pm | 6 +- .../office365/onedrive/mode/usage.pm | 16 +-- .../office365/sharepoint/mode/siteusage.pm | 28 ++-- .../sharepoint/mode/usersactivity.pm | 30 ++-- .../office365/skype/mode/devicesusage.pm | 10 +- .../office365/skype/mode/usersactivity.pm | 18 +-- .../office365/teams/mode/devicesusage.pm | 12 +- .../office365/teams/mode/usersactivity.pm | 24 ++-- cloud/nutanix/snmp/mode/clusterusage.pm | 4 +- cloud/nutanix/snmp/mode/containerusage.pm | 8 +- cloud/nutanix/snmp/mode/diskusage.pm | 12 +- cloud/nutanix/snmp/mode/hypervisorusage.pm | 20 +-- cloud/nutanix/snmp/mode/storagepoolusage.pm | 8 +- cloud/nutanix/snmp/mode/vmusage.pm | 32 ++--- cloud/ovh/restapi/mode/sms.pm | 4 +- .../direct/kubernetes/mode/containerstatus.pm | 4 +- .../direct/kubernetes/mode/namespacestatus.pm | 4 +- .../mode/connections.pm | 28 ++-- .../nginxingresscontroller/mode/requests.pm | 35 ++--- .../prometheus/exporters/cadvisor/mode/cpu.pm | 8 +- .../exporters/cadvisor/mode/load.pm | 4 +- .../exporters/cadvisor/mode/memory.pm | 12 +- .../exporters/cadvisor/mode/taskstate.pm | 20 +-- .../exporters/nodeexporter/mode/cpu.pm | 4 +- .../nodeexporter/mode/cpudetailed.pm | 32 ++--- .../exporters/nodeexporter/mode/load.pm | 12 +- .../exporters/nodeexporter/mode/memory.pm | 8 +- cloud/prometheus/restapi/mode/targetstatus.pm | 10 +- .../restapi/mode/applicationusage.pm | 8 +- .../velocloud/restapi/mode/categoryusage.pm | 8 +- .../vmware/velocloud/restapi/mode/edgeqoe.pm | 12 +- .../velocloud/restapi/mode/linkusage.pm | 20 +-- .../cassandra/jmx/mode/clientrequestsusage.pm | 16 +-- .../cassandra/jmx/mode/threadpoolsusage.pm | 20 +-- database/couchdb/restapi/mode/server.pm | 16 +-- .../restapi/mode/clusterstatistics.pm | 46 +++---- .../restapi/mode/indicestatistics.pm | 20 +-- .../restapi/mode/nodestatistics.pm | 24 ++-- database/firebird/mode/pages.pm | 24 ++-- database/firebird/mode/queries.pm | 48 +++---- database/influxdb/mode/connectiontime.pm | 2 +- database/influxdb/mode/databasestatistics.pm | 8 +- .../influxdb/mode/httpserverstatistics.pm | 46 +++---- database/influxdb/mode/writestatistics.pm | 25 ++-- database/informix/snmp/mode/archivelevel0.pm | 6 +- database/informix/snmp/mode/dbspaceusage.pm | 4 +- database/informix/snmp/mode/globalcache.pm | 4 +- database/informix/snmp/mode/lockstats.pm | 16 +-- database/informix/snmp/mode/logfileusage.pm | 4 +- database/informix/snmp/mode/sessions.pm | 4 +- database/mongodb/mode/collectionstatistics.pm | 8 +- database/mongodb/mode/connections.pm | 11 +- database/mongodb/mode/connectiontime.pm | 2 +- database/mongodb/mode/databasestatistics.pm | 28 ++-- database/mongodb/mode/queries.pm | 16 +-- database/mongodb/mode/replicationstatus.pm | 4 +- database/mssql/mode/blockedprocesses.pm | 2 +- database/mssql/mode/pagelifeexpectancy.pm | 2 +- database/mysql/mode/databasessize.pm | 14 +- database/mysql/mode/queries.pm | 19 +-- database/mysql/mode/threadsconnected.pm | 14 +- database/oracle/mode/datafilesstatus.pm | 20 +-- database/oracle/mode/dataguard.pm | 2 +- database/oracle/mode/eventwaitsusage.pm | 16 +-- database/oracle/mode/frausage.pm | 8 +- database/oracle/mode/invalidobject.pm | 10 +- database/oracle/mode/librarycacheusage.pm | 12 +- database/oracle/mode/redologusage.pm | 16 +-- database/oracle/mode/rollbacksegmentusage.pm | 12 +- database/postgres/mode/databasesize.pm | 4 +- database/postgres/mode/statistics.pm | 30 ++-- database/sap/hana/mode/blockedtransactions.pm | 2 +- database/sap/hana/mode/connectedusers.pm | 4 +- database/sap/hana/mode/hostcpu.pm | 8 +- .../warp10/sensision/mode/fetchstatistics.pm | 42 +++--- .../warp10/sensision/mode/scriptstatistics.pm | 56 +++----- docs/en/developer/guide.rst | 64 +++++---- hardware/ats/apc/snmp/mode/inputlines.pm | 12 +- hardware/ats/apc/snmp/mode/outputlines.pm | 20 +-- hardware/ats/eaton/snmp/mode/inputlines.pm | 6 +- hardware/ats/eaton/snmp/mode/outputline.pm | 4 +- hardware/ats/eaton/snmp/mode/system.pm | 4 +- .../abb/cms700/snmp/mode/mainsmeasurements.pm | 54 ++++---- .../cms700/snmp/mode/sensorsmeasurements.pm | 24 ++-- .../aeg/acm/snmp/mode/batterystatus.pm | 16 +-- .../devices/aeg/acm/snmp/mode/loadstatus.pm | 6 +- .../aeg/acm/snmp/mode/rectifierstatus.pm | 6 +- .../devices/camera/hikvision/snmp/mode/cpu.pm | 2 +- .../camera/hikvision/snmp/mode/disk.pm | 16 +-- .../camera/hikvision/snmp/mode/memory.pm | 16 +-- .../camera/mobotix/snmp/mode/system.pm | 14 +- .../devices/cisco/ces/restapi/mode/callsrt.pm | 2 +- .../cisco/ces/restapi/mode/callssummary.pm | 14 +- .../cisco/ces/restapi/mode/certificates.pm | 4 +- .../cisco/ces/restapi/mode/peripherals.pm | 2 +- .../cisco/ces/restapi/mode/sessions.pm | 2 +- .../devices/eltek/enexus/snmp/mode/alarms.pm | 2 +- .../devices/eltek/enexus/snmp/mode/battery.pm | 30 ++-- .../devices/eltek/enexus/snmp/mode/load.pm | 6 +- .../devices/eltek/enexus/snmp/mode/outputs.pm | 4 +- .../gorgy/ntpserver/snmp/mode/globalstatus.pm | 2 +- .../ntp100gps/snmp/mode/ntpperformance.pm | 6 +- .../polycom/trio/restapi/mode/callsrt.pm | 29 ++-- .../polycom/trio/restapi/mode/callssummary.pm | 8 +- .../polycom/trio/restapi/mode/device.pm | 18 +-- .../polycom/trio/restapi/mode/network.pm | 12 +- .../timelinkmicro/tms6001/snmp/mode/alarms.pm | 2 +- .../tms6001/snmp/mode/frequency.pm | 2 +- .../tms6001/snmp/mode/satellites.pm | 2 +- .../timelinkmicro/tms6001/snmp/mode/time.pm | 2 +- .../kvm/adder/aim/snmp/mode/deviceusage.pm | 4 +- .../kvm/adder/aim/snmp/mode/serverusage.pm | 12 +- .../avocent/acs/8000/snmp/mode/serialports.pm | 14 +- hardware/pdu/apc/snmp/mode/load.pm | 16 +-- hardware/pdu/apc/snmp/mode/outlet.pm | 4 +- hardware/pdu/clever/snmp/mode/psusage.pm | 6 +- hardware/pdu/eaton/snmp/mode/environment.pm | 4 +- hardware/pdu/eaton/snmp/mode/group.pm | 12 +- hardware/pdu/eaton/snmp/mode/outlet.pm | 12 +- hardware/pdu/emerson/snmp/mode/psusage.pm | 10 +- hardware/pdu/emerson/snmp/mode/receptacles.pm | 10 +- .../sensors/comet/p8000/snmp/mode/sensors.pm | 28 ++-- hardware/sensors/geist/snmp/mode/sensors.pm | 18 +-- .../temperhum/local/mode/environment.pm | 16 +-- .../hp/oneview/restapi/mode/storagepools.pm | 22 +-- .../telephony/avaya/aes/snmp/mode/services.pm | 4 +- .../telephony/avaya/cm/snmp/mode/calls.pm | 2 +- .../telephony/avaya/cm/snmp/mode/licenses.pm | 16 +-- hardware/ups/alpha/snmp/mode/batterystatus.pm | 8 +- hardware/ups/apc/snmp/mode/batterystatus.pm | 12 +- hardware/ups/apc/snmp/mode/inputlines.pm | 4 +- hardware/ups/apc/snmp/mode/outputlines.pm | 8 +- hardware/ups/hp/snmp/mode/batterystatus.pm | 8 +- hardware/ups/hp/snmp/mode/environment.pm | 8 +- hardware/ups/hp/snmp/mode/inputlines.pm | 8 +- hardware/ups/hp/snmp/mode/outputlines.pm | 10 +- hardware/ups/mge/snmp/mode/environment.pm | 4 +- hardware/ups/mge/snmp/mode/inputlines.pm | 6 +- hardware/ups/mge/snmp/mode/outputlines.pm | 10 +- .../ups/powerware/snmp/mode/batterystatus.pm | 8 +- .../ups/powerware/snmp/mode/environment.pm | 8 +- .../ups/powerware/snmp/mode/inputlines.pm | 8 +- .../ups/powerware/snmp/mode/outputlines.pm | 10 +- .../rfc1628/snmp/mode/batterystatus.pm | 14 +- .../standard/rfc1628/snmp/mode/inputlines.pm | 16 +-- .../standard/rfc1628/snmp/mode/outputlines.pm | 10 +- network/3com/snmp/mode/cpu.pm | 12 +- network/a10/ax/snmp/mode/cpu.pm | 8 +- network/a10/ax/snmp/mode/globalstats.pm | 6 +- network/a10/ax/snmp/mode/vserverusage.pm | 37 +++-- network/acmepacket/snmp/mode/realmusage.pm | 32 ++--- network/acmepacket/snmp/mode/sipusage.pm | 35 +++-- network/acmepacket/snmp/mode/systemusage.pm | 12 +- network/adva/fsp150/snmp/mode/systems.pm | 16 +-- network/adva/fsp3000/snmp/mode/interfaces.pm | 20 ++- network/aerohive/snmp/mode/connectedusers.pm | 6 +- network/alcatel/isam/snmp/mode/cpu.pm | 4 +- network/alcatel/isam/snmp/mode/hubsapusage.pm | 36 +++-- .../alcatel/pss/1830/snmp/mode/sapqosstats.pm | 47 +++---- network/allied/snmp/mode/cpu.pm | 4 +- network/allied/snmp/mode/memory.pm | 2 +- .../breezeaccess/snmp/mode/radiostatus.pm | 4 +- network/arista/snmp/mode/memory.pm | 20 +-- network/aruba/instant/snmp/mode/apusage.pm | 32 ++--- network/atrica/snmp/mode/connections.pm | 10 +- .../atto/fibrebridge/snmp/mode/fcportusage.pm | 32 ++--- network/audiocodes/snmp/mode/cpu.pm | 4 +- network/audiocodes/snmp/mode/memory.pm | 4 +- network/audiocodes/snmp/mode/trunkstatus.pm | 12 +- .../beeware/snmp/mode/reverseproxyusage.pm | 12 +- network/checkpoint/snmp/mode/memory.pm | 31 ++--- network/checkpoint/snmp/mode/vpnstatus.pm | 2 +- network/checkpoint/snmp/mode/vsx.pm | 33 ++--- network/cisco/aci/apic/restapi/mode/node.pm | 12 +- network/cisco/asa/snmp/mode/failover.pm | 2 +- .../cisco/callmanager/snmp/mode/ccmusage.pm | 2 +- .../cisco/callmanager/snmp/mode/ctiusage.pm | 2 +- .../callmanager/snmp/mode/gatewayusage.pm | 2 +- .../callmanager/snmp/mode/mediadeviceusage.pm | 2 +- .../cisco/callmanager/snmp/mode/phoneusage.pm | 2 +- .../callmanager/snmp/mode/voicemailusage.pm | 2 +- .../restapi/mode/apirequests.pm | 12 +- .../cloudcontroller/restapi/mode/devices.pm | 35 ++--- .../cloudcontroller/restapi/mode/networks.pm | 29 ++-- .../cloudcontroller/snmp/mode/deviceusage.pm | 8 +- network/cisco/prime/restapi/mode/apusage.pm | 20 +-- network/cisco/standard/ssh/mode/cpu.pm | 6 +- .../cisco/standard/ssh/mode/voicedialpeer.pm | 4 +- network/cisco/vcs/restapi/mode/calls.pm | 12 +- .../cisco/vcs/restapi/mode/httpproxystats.pm | 76 ++++------- network/cisco/vcs/restapi/mode/zones.pm | 53 +++----- .../citrix/appacceleration/snmp/mode/cpu.pm | 4 +- .../snmp/mode/serviceclassusage.pm | 53 ++++---- .../citrix/netscaler/snmp/mode/connections.pm | 6 +- .../netscaler/snmp/mode/vserverstatus.pm | 34 ++--- network/citrix/sdx/snmp/mode/diskusage.pm | 20 ++- network/citrix/sdx/snmp/mode/xenusage.pm | 4 +- network/colubris/snmp/mode/apusage.pm | 8 +- network/colubris/snmp/mode/cpu.pm | 8 +- network/colubris/snmp/mode/load.pm | 6 +- network/colubris/snmp/mode/storage.pm | 4 +- network/cyberoam/snmp/mode/requests.pm | 12 +- network/digi/sarian/snmp/mode/gprs.pm | 2 +- network/digi/sarian/snmp/mode/temperature.pm | 6 +- network/efficientip/snmp/mode/dhcpusage.pm | 16 +-- network/efficientip/snmp/mode/dnsusage.pm | 2 +- network/extreme/snmp/mode/cpu.pm | 22 +-- network/f5/bigip/snmp/mode/apm.pm | 12 +- network/f5/bigip/snmp/mode/connections.pm | 13 +- network/f5/bigip/snmp/mode/nodestatus.pm | 4 +- network/f5/bigip/snmp/mode/poolstatus.pm | 12 +- network/f5/bigip/snmp/mode/tmmusage.pm | 24 ++-- network/f5/bigip/snmp/mode/trunks.pm | 20 +-- network/freebox/restapi/mode/dslusage.pm | 8 +- network/freebox/restapi/mode/netusage.pm | 12 +- network/freebox/restapi/mode/system.pm | 8 +- network/fritzbox/mode/traffic.pm | 20 +-- .../hp/procurve/snmp/mode/virtualchassis.pm | 20 +-- network/huawei/snmp/mode/cpu.pm | 4 +- network/infoblox/snmp/mode/cpu.pm | 2 +- network/infoblox/snmp/mode/dhcpusage.pm | 6 +- network/infoblox/snmp/mode/dnsusage.pm | 20 +-- network/infoblox/snmp/mode/memory.pm | 4 +- network/juniper/common/ive/mode/users.pm | 26 ++-- .../junos/mode/bgppeerprefixstatistics.pm | 10 +- network/juniper/common/junos/mode/cpu.pm | 16 +-- .../juniper/common/junos/mode/interfaces.pm | 16 +-- .../juniper/common/junos/mode/ipsectunnel.pm | 14 +- .../common/junos/mode/ldpsessionstatus.pm | 4 +- .../juniper/common/junos/mode/lspstatus.pm | 8 +- network/juniper/common/junos/mode/memory.pm | 22 +-- .../juniper/common/screenos/snmp/mode/nsrp.pm | 2 +- .../common/screenos/snmp/mode/sessions.pm | 43 +++--- .../common/screenos/snmp/mode/vpnstatus.pm | 6 +- .../common/screenos/snmp/mode/vpnusage.pm | 27 ++-- network/juniper/ggsn/mode/apnstats.pm | 60 ++++---- network/juniper/ggsn/mode/globalstats.pm | 58 ++++---- network/juniper/trapeze/snmp/mode/apstatus.pm | 2 +- network/juniper/trapeze/snmp/mode/apusers.pm | 10 +- network/juniper/trapeze/snmp/mode/cpu.pm | 8 +- network/juniper/trapeze/snmp/mode/memory.pm | 22 +-- network/kemp/snmp/mode/rsstatus.pm | 30 ++-- network/kemp/snmp/mode/vsstatus.pm | 34 ++--- network/lenovo/flexsystem/snmp/mode/cpu.pm | 4 +- network/lenovo/flexsystem/snmp/mode/memory.pm | 16 +-- network/libraesva/snmp/mode/system.pm | 16 +-- network/mikrotik/snmp/mode/signal.pm | 12 +- network/mitel/3300icp/snmp/mode/zapcalls.pm | 12 +- network/moxa/switch/snmp/mode/cpu.pm | 6 +- network/moxa/switch/snmp/mode/memory.pm | 18 +-- .../mrv/optiswitch/snmp/mode/interfaces.pm | 12 +- network/netgear/mseries/snmp/mode/cpu.pm | 6 +- network/nokia/timos/snmp/mode/bgpusage.pm | 12 +- network/nokia/timos/snmp/mode/cpu.pm | 2 +- network/nokia/timos/snmp/mode/isisusage.pm | 8 +- network/nokia/timos/snmp/mode/l2tpusage.pm | 20 +-- network/nokia/timos/snmp/mode/ldpusage.pm | 16 +-- network/nokia/timos/snmp/mode/sapusage.pm | 41 +++--- network/nortel/standard/snmp/mode/cpu.pm | 10 +- network/nortel/standard/snmp/mode/memory.pm | 16 +-- .../infiniband/snmp/mode/infinibandusage.pm | 39 +++--- network/oracle/otd/snmp/mode/vserverusage.pm | 28 ++-- network/paloalto/snmp/mode/cpu.pm | 4 +- network/paloalto/snmp/mode/gpusage.pm | 16 +-- network/paloalto/snmp/mode/sessions.pm | 30 ++-- network/paloalto/ssh/mode/interfaces.pm | 2 +- network/paloalto/ssh/mode/ipsec.pm | 2 +- network/paloalto/ssh/mode/system.pm | 16 +-- network/peplink/pepwave/snmp/mode/cpu.pm | 2 +- network/peplink/pepwave/snmp/mode/wanusage.pm | 29 ++-- network/perle/ids/snmp/mode/systemusage.pm | 6 +- .../rmx/snmp/mode/videoconferencingusage.pm | 8 +- network/rad/airmux/snmp/mode/radiostatus.pm | 4 +- network/radware/alteon/snmp/mode/cpu.pm | 24 ++-- .../radware/alteon/snmp/mode/vserverstatus.pm | 34 ++--- network/raisecom/snmp/mode/cpu.pm | 8 +- .../snmp/mode/neighborconnections.pm | 4 +- network/ruckus/ap/snmp/mode/cpu.pm | 2 +- network/ruckus/ap/snmp/mode/users.pm | 4 +- network/ruckus/scg/snmp/mode/apusage.pm | 27 ++-- network/ruckus/scg/snmp/mode/ssidusage.pm | 27 ++-- network/ruckus/scg/snmp/mode/systemstats.pm | 61 +++------ .../smartzone/snmp/mode/accesspoints.pm | 16 +-- network/ruckus/smartzone/snmp/mode/system.pm | 18 ++- .../zonedirector/snmp/mode/accesspoints.pm | 42 +++--- .../ruckus/zonedirector/snmp/mode/system.pm | 40 +++--- network/sonicwall/snmp/mode/connections.pm | 10 +- network/sonicwall/snmp/mode/cpu.pm | 2 +- network/sonicwall/snmp/mode/memory.pm | 2 +- network/sonicwall/snmp/mode/vpn.pm | 24 ++-- network/sonus/sbc/snmp/mode/callstats.pm | 45 +++--- network/sonus/sbc/snmp/mode/channels.pm | 40 +++--- network/sonus/sbc/snmp/mode/dspstats.pm | 8 +- network/sophos/es/snmp/mode/message.pm | 44 +++--- network/stonesoft/snmp/mode/connections.pm | 13 +- network/stonesoft/snmp/mode/droppedpackets.pm | 10 +- .../stonesoft/snmp/mode/rejectedpackets.pm | 10 +- network/stormshield/local/mode/qosusage.pm | 8 +- network/stormshield/snmp/mode/connections.pm | 24 ++-- network/stormshield/snmp/mode/hanodes.pm | 4 +- network/stormshield/snmp/mode/vpnstatus.pm | 17 ++- network/teltonika/snmp/mode/system.pm | 24 ++-- network/ucopia/wlc/snmp/mode/system.pm | 12 +- network/watchguard/snmp/mode/cpu.pm | 6 +- network/watchguard/snmp/mode/ipsectunnel.pm | 24 ++-- network/watchguard/snmp/mode/policyusage.pm | 31 ++--- network/watchguard/snmp/mode/system.pm | 26 ++-- network/zyxel/snmp/mode/cpu.pm | 6 +- network/zyxel/snmp/mode/memory.pm | 4 +- network/zyxel/snmp/mode/sessions.pm | 2 +- network/zyxel/snmp/mode/vpnstatus.pm | 25 ++-- os/aix/local/mode/inodes.pm | 4 +- os/aix/local/mode/process.pm | 2 +- os/aix/snmp/mode/swap.pm | 2 +- os/hpux/local/mode/inodes.pm | 4 +- os/linux/local/mode/directlvmusage.pm | 8 +- os/linux/local/mode/diskio.pm | 17 ++- os/linux/local/mode/inodes.pm | 4 +- os/linux/local/mode/ntp.pm | 24 ++-- os/linux/local/mode/openfiles.pm | 2 +- os/linux/local/mode/paging.pm | 68 +++++----- os/linux/local/mode/pendingupdates.pm | 2 +- os/linux/local/mode/swap.pm | 16 +-- os/linux/local/mode/systemdscstatus.pm | 16 +-- os/linux/local/mode/traffic.pm | 2 - os/windows/local/mode/sessions.pm | 10 +- snmp_standard/mode/arp.pm | 6 +- snmp_standard/mode/cpu.pm | 6 +- snmp_standard/mode/diskio.pm | 64 ++++----- snmp_standard/mode/diskusage.pm | 28 ++-- snmp_standard/mode/inodes.pm | 4 +- snmp_standard/mode/interfaces.pm | 48 ++++--- snmp_standard/mode/isdnusage.pm | 12 +- snmp_standard/mode/memory.pm | 38 +++--- snmp_standard/mode/mtausage.pm | 52 +++---- snmp_standard/mode/ntp.pm | 6 +- snmp_standard/mode/storage.pm | 8 +- snmp_standard/mode/swap.pm | 16 +-- storage/avid/isis/snmp/mode/performance.pm | 8 +- storage/avid/isis/snmp/mode/status.pm | 2 +- storage/avid/isis/snmp/mode/usage.pm | 6 +- .../dell/compellent/local/mode/hbausage.pm | 24 ++-- .../dell/compellent/local/mode/volumeusage.pm | 8 +- .../dell/equallogic/snmp/mode/arrayusage.pm | 64 +++++---- .../dell/equallogic/snmp/mode/diskusage.pm | 28 ++-- .../me4/restapi/mode/controllerstatistics.pm | 90 ++++-------- storage/dell/me4/restapi/mode/interfaces.pm | 37 ++--- .../dell/me4/restapi/mode/volumestatistics.pm | 78 ++++------- storage/emc/DataDomain/mode/replication.pm | 4 +- storage/emc/isilon/snmp/mode/clusterusage.pm | 2 +- storage/emc/unisphere/restapi/mode/pools.pm | 44 +++--- .../restapi/mode/storageresources.pm | 44 +++--- storage/emc/xtremio/restapi/mode/ssdiops.pm | 18 +-- storage/fujitsu/eternus/dx/ssh/mode/cpu.pm | 4 +- .../fujitsu/eternus/dx/ssh/mode/portstats.pm | 16 +-- .../eternus/dx/ssh/mode/volumestats.pm | 40 +++--- storage/hp/3par/ssh/mode/diskusage.pm | 22 +-- storage/hp/3par/ssh/mode/volumeusage.pm | 22 +-- storage/hp/lefthand/snmp/mode/volumeusage.pm | 52 ++++--- storage/hp/p2000/xmlapi/mode/vdisks.pm | 22 +-- storage/hp/p2000/xmlapi/mode/volumesstats.pm | 23 ++-- .../hp/storeonce/restapi/mode/clusterusage.pm | 4 +- storage/hp/storeonce/restapi/mode/fcsusage.pm | 12 +- .../storeonce/restapi/mode/servicesetusage.pm | 4 +- storage/ibm/fs900/snmp/mode/arraysstatus.pm | 4 +- storage/ibm/fs900/snmp/mode/fcusage.pm | 16 +-- storage/kaminario/restapi/mode/systemusage.pm | 24 ++-- storage/kaminario/restapi/mode/volumeusage.pm | 16 +-- storage/lenovo/iomega/snmp/mode/memory.pm | 20 +-- .../ontap/oncommandapi/mode/clusterio.pm | 8 +- .../ontap/oncommandapi/mode/clusterusage.pm | 8 +- .../ontap/oncommandapi/mode/diskfailed.pm | 4 +- .../ontap/oncommandapi/mode/diskspare.pm | 6 +- .../ontap/oncommandapi/mode/lunalignment.pm | 12 +- .../ontap/oncommandapi/mode/lunonline.pm | 8 +- .../oncommandapi/mode/nodehardwarestatus.pm | 8 +- .../oncommandapi/mode/snapmirrorusage.pm | 12 +- .../ontap/oncommandapi/mode/volumeio.pm | 28 ++-- .../netapp/ontap/snmp/mode/cpstatistics.pm | 22 +-- storage/netapp/ontap/snmp/mode/filesys.pm | 12 +- .../netapp/ontap/snmp/mode/globalstatus.pm | 18 +-- storage/netapp/ontap/snmp/mode/sharecalls.pm | 16 +-- .../netapp/ontap/snmp/mode/snapmirrorlag.pm | 4 +- .../netapp/ontap/snmp/mode/snapvaultusage.pm | 20 +-- .../netapp/ontap/snmp/mode/volumeoptions.pm | 2 +- .../restapi/mode/storagecontrollers.pm | 32 ++--- .../santricity/restapi/mode/storagesystems.pm | 16 +-- .../santricity/restapi/mode/storagevolumes.pm | 28 ++-- storage/nimble/snmp/mode/globalstats.pm | 30 ++-- storage/oracle/zs/restapi/mode/pools.pm | 22 +-- storage/panzura/snmp/mode/ratios.pm | 6 +- .../restapi/mode/pgroupreplication.pm | 24 ++-- .../purestorage/restapi/mode/volumeusage.pm | 12 +- storage/purestorage/snmp/mode/stats.pm | 12 +- storage/quantum/dxi/ssh/mode/compaction.pm | 2 +- storage/quantum/dxi/ssh/mode/dedupnas.pm | 8 +- storage/quantum/dxi/ssh/mode/dedupvtl.pm | 8 +- storage/quantum/dxi/ssh/mode/reclamation.pm | 4 +- storage/quantum/dxi/ssh/mode/reduction.pm | 6 +- storage/synology/snmp/mode/ha.pm | 2 +- storage/synology/snmp/mode/temperature.pm | 2 +- storage/synology/snmp/mode/ups.pm | 6 +- 753 files changed, 4993 insertions(+), 5599 deletions(-) diff --git a/apps/activedirectory/local/mode/dfsrbacklog.pm b/apps/activedirectory/local/mode/dfsrbacklog.pm index 8440d4645..d81c421bd 100644 --- a/apps/activedirectory/local/mode/dfsrbacklog.pm +++ b/apps/activedirectory/local/mode/dfsrbacklog.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'backlog' } ], output_template => 'Backlog File Count : %s', perfdatas => [ - { label => 'backlog', value => 'backlog_absolute', template => '%s', min => 0 }, + { label => 'backlog', value => 'backlog', template => '%s', min => 0 }, ], } }, diff --git a/apps/antivirus/kaspersky/snmp/mode/deployment.pm b/apps/antivirus/kaspersky/snmp/mode/deployment.pm index 29e28796e..a9569f8b6 100644 --- a/apps/antivirus/kaspersky/snmp/mode/deployment.pm +++ b/apps/antivirus/kaspersky/snmp/mode/deployment.pm @@ -178,7 +178,7 @@ sub set_counters { key_values => [ { name => 'hostsRemoteInstallFailed' } ], output_template => '%d failed remote installation(s)', perfdatas => [ - { label => 'failed', value => 'hostsRemoteInstallFailed_absolute', template => '%d', min => 0 }, + { label => 'failed', value => 'hostsRemoteInstallFailed', template => '%d', min => 0 }, ], } }, diff --git a/apps/antivirus/kaspersky/snmp/mode/events.pm b/apps/antivirus/kaspersky/snmp/mode/events.pm index 9e230a585..ed45e8c49 100644 --- a/apps/antivirus/kaspersky/snmp/mode/events.pm +++ b/apps/antivirus/kaspersky/snmp/mode/events.pm @@ -60,7 +60,7 @@ sub set_counters { key_values => [ { name => 'criticalEventsCount' } ], output_template => '%d critical event(s)', perfdatas => [ - { label => 'events', value => 'criticalEventsCount_absolute', template => '%d', min => 0 }, + { label => 'events', value => 'criticalEventsCount', template => '%d', min => 0 }, ], } }, diff --git a/apps/antivirus/kaspersky/snmp/mode/fullscan.pm b/apps/antivirus/kaspersky/snmp/mode/fullscan.pm index 516bac8ec..82e2e8ed4 100644 --- a/apps/antivirus/kaspersky/snmp/mode/fullscan.pm +++ b/apps/antivirus/kaspersky/snmp/mode/fullscan.pm @@ -60,7 +60,7 @@ sub set_counters { key_values => [ { name => 'hostsNotScannedLately' } ], output_template => '%d hosts(s) has not been scanned lately', perfdatas => [ - { label => 'not_scanned', value => 'hostsNotScannedLately_absolute', template => '%d', min => 0 }, + { label => 'not_scanned', value => 'hostsNotScannedLately', template => '%d', min => 0 }, ], } }, diff --git a/apps/antivirus/kaspersky/snmp/mode/logicalnetwork.pm b/apps/antivirus/kaspersky/snmp/mode/logicalnetwork.pm index 9f2c2e56b..f15834ba5 100644 --- a/apps/antivirus/kaspersky/snmp/mode/logicalnetwork.pm +++ b/apps/antivirus/kaspersky/snmp/mode/logicalnetwork.pm @@ -60,7 +60,7 @@ sub set_counters { key_values => [ { name => 'hostsFound' } ], output_template => '%d new host(s) found', perfdatas => [ - { label => 'new_hosts', value => 'hostsFound_absolute', template => '%d', min => 0 }, + { label => 'new_hosts', value => 'hostsFound', template => '%d', min => 0 }, ], } }, @@ -68,7 +68,7 @@ sub set_counters { key_values => [ { name => 'groupsCount' } ], output_template => '%d group(s) on the server', perfdatas => [ - { label => 'groups', value => 'groupsCount_absolute', template => '%d', min => 0 }, + { label => 'groups', value => 'groupsCount', template => '%d', min => 0 }, ], } }, @@ -76,7 +76,7 @@ sub set_counters { key_values => [ { name => 'hostsNotConnectedLongTime' } ], output_template => '%d host(s) has not connected for a long time', perfdatas => [ - { label => 'not_connected_long_time', value => 'hostsNotConnectedLongTime_absolute', template => '%d', min => 0 }, + { label => 'not_connected_long_time', value => 'hostsNotConnectedLongTime', template => '%d', min => 0 }, ], } }, @@ -84,7 +84,7 @@ sub set_counters { key_values => [ { name => 'hostsControlLost' } ], output_template => '%d host(s) are not controlled', perfdatas => [ - { label => 'not_controlled', value => 'hostsControlLost_absolute', template => '%d', min => 0 }, + { label => 'not_controlled', value => 'hostsControlLost', template => '%d', min => 0 }, ], } }, diff --git a/apps/antivirus/kaspersky/snmp/mode/protection.pm b/apps/antivirus/kaspersky/snmp/mode/protection.pm index e3fcdda29..85ca7ca95 100644 --- a/apps/antivirus/kaspersky/snmp/mode/protection.pm +++ b/apps/antivirus/kaspersky/snmp/mode/protection.pm @@ -60,7 +60,7 @@ sub set_counters { key_values => [ { name => 'hostsAntivirusNotRunning' } ], output_template => '%d host(s) without running antivirus', perfdatas => [ - { label => 'no_antivirus', value => 'hostsAntivirusNotRunning_absolute', template => '%d', min => 0 }, + { label => 'no_antivirus', value => 'hostsAntivirusNotRunning', template => '%d', min => 0 }, ], } }, @@ -68,7 +68,7 @@ sub set_counters { key_values => [ { name => 'hostsRealtimeNotRunning' } ], output_template => '%d hosts(s) without running real time protection', perfdatas => [ - { label => 'no_real_time', value => 'hostsRealtimeNotRunning_absolute', template => '%d', min => 0 }, + { label => 'no_real_time', value => 'hostsRealtimeNotRunning', template => '%d', min => 0 }, ], } }, @@ -76,7 +76,7 @@ sub set_counters { key_values => [ { name => 'hostsRealtimeLevelChanged' } ], output_template => '%d host(s) with not acceptable level of real time protection', perfdatas => [ - { label => 'not_acceptable_level', value => 'hostsRealtimeLevelChanged_absolute', template => '%d', min => 0 }, + { label => 'not_acceptable_level', value => 'hostsRealtimeLevelChanged', template => '%d', min => 0 }, ], } }, @@ -84,7 +84,7 @@ sub set_counters { key_values => [ { name => 'hostsNotCuredObject' } ], output_template => '%d host(s) with not cured objects', perfdatas => [ - { label => 'not_cured_objects', value => 'hostsNotCuredObject_absolute', template => '%d', min => 0 }, + { label => 'not_cured_objects', value => 'hostsNotCuredObject', template => '%d', min => 0 }, ], } }, @@ -92,7 +92,7 @@ sub set_counters { key_values => [ { name => 'hostsTooManyThreats' } ], output_template => '%d host(s) with too many threats', perfdatas => [ - { label => 'too_many_threats', value => 'hostsTooManyThreats_absolute', template => '%d', min => 0 }, + { label => 'too_many_threats', value => 'hostsTooManyThreats', template => '%d', min => 0 }, ], } }, diff --git a/apps/antivirus/kaspersky/snmp/mode/updates.pm b/apps/antivirus/kaspersky/snmp/mode/updates.pm index a05aa5a1e..740cbba6b 100644 --- a/apps/antivirus/kaspersky/snmp/mode/updates.pm +++ b/apps/antivirus/kaspersky/snmp/mode/updates.pm @@ -124,7 +124,7 @@ sub set_counters { key_values => [ { name => 'hostsNotUpdated' } ], output_template => '%d host(s) not up to date', perfdatas => [ - { label => 'not_updated', value => 'hostsNotUpdated_absolute', template => '%d', min => 0 } + { label => 'not_updated', value => 'hostsNotUpdated', template => '%d', min => 0 } ] } } diff --git a/apps/antivirus/mcafee/webgateway/snmp/mode/clients.pm b/apps/antivirus/mcafee/webgateway/snmp/mode/clients.pm index 10642d275..e85e53471 100644 --- a/apps/antivirus/mcafee/webgateway/snmp/mode/clients.pm +++ b/apps/antivirus/mcafee/webgateway/snmp/mode/clients.pm @@ -38,7 +38,7 @@ sub set_counters { key_values => [ { name => 'stClientCount' } ], output_template => 'Connected clients: %d', perfdatas => [ - { label => 'connected_clients', value => 'stClientCount_absolute', template => '%d', + { label => 'connected_clients', value => 'stClientCount', template => '%d', min => 0, unit => 'clients' }, ], } @@ -47,7 +47,7 @@ sub set_counters { key_values => [ { name => 'stConnectedSockets' } ], output_template => 'Open network sockets: %d', perfdatas => [ - { label => 'open_sockets', value => 'stConnectedSockets_absolute', template => '%d', + { label => 'open_sockets', value => 'stConnectedSockets', template => '%d', min => 0, unit => 'sockets' }, ], } diff --git a/apps/antivirus/mcafee/webgateway/snmp/mode/connections.pm b/apps/antivirus/mcafee/webgateway/snmp/mode/connections.pm index 613419d13..b41160c3a 100644 --- a/apps/antivirus/mcafee/webgateway/snmp/mode/connections.pm +++ b/apps/antivirus/mcafee/webgateway/snmp/mode/connections.pm @@ -35,52 +35,42 @@ sub set_counters { $self->{maps_counters}->{global} = [ { label => 'legitimate', set => { - key_values => [ { name => 'stConnectionsLegitimate', diff => 1 } ], + key_values => [ { name => 'stConnectionsLegitimate', per_second => 1 } ], output_template => 'Legitimate: %d', - per_second => 1, perfdatas => [ - { label => 'legitimate_connections', value => 'stConnectionsLegitimate_per_second', template => '%d', - min => 0, unit => 'connections/s' }, + { label => 'legitimate_connections', template => '%d', min => 0, unit => 'connections/s' }, ], } }, { label => 'blocked', set => { - key_values => [ { name => 'stConnectionsBlocked', diff => 1 } ], + key_values => [ { name => 'stConnectionsBlocked', per_second => 1 } ], output_template => 'Blocked: %d', - per_second => 1, perfdatas => [ - { label => 'blocked_connections', value => 'stConnectionsBlocked_per_second', template => '%d', - min => 0, unit => 'connections/s' }, + { label => 'blocked_connections', template => '%d', min => 0, unit => 'connections/s' }, ], } }, { label => 'blocked-by-am', set => { - key_values => [ { name => 'stBlockedByAntiMalware', diff => 1 } ], + key_values => [ { name => 'stBlockedByAntiMalware', per_second => 1 } ], output_template => 'Blocked by Anti Malware: %d', - per_second => 1, perfdatas => [ - { label => 'blocked_by_am', value => 'stBlockedByAntiMalware_per_second', template => '%d', - min => 0, unit => 'connections/s' }, + { label => 'blocked_by_am', template => '%d', min => 0, unit => 'connections/s' }, ], } }, { label => 'blocked-by-mf', set => { - key_values => [ { name => 'stBlockedByMediaFilter', diff => 1 } ], + key_values => [ { name => 'stBlockedByMediaFilter', per_second => 1 } ], output_template => 'Blocked by Media Filter: %d', - per_second => 1, perfdatas => [ - { label => 'blocked_by_mf', value => 'stBlockedByMediaFilter_per_second', template => '%d', - min => 0, unit => 'connections/s' }, + { label => 'blocked_by_mf', template => '%d', min => 0, unit => 'connections/s' }, ], } }, { label => 'blocked-by-uf', set => { - key_values => [ { name => 'stBlockedByURLFilter', diff => 1 } ], + key_values => [ { name => 'stBlockedByURLFilter', per_second => 1 } ], output_template => 'Blocked by URL Filter: %d', - per_second => 1, perfdatas => [ - { label => 'blocked_by_uf', value => 'stBlockedByURLFilter_per_second', template => '%d', - min => 0, unit => 'connections/s' }, + { label => 'blocked_by_uf', template => '%d', min => 0, unit => 'connections/s' }, ], } }, @@ -98,16 +88,10 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-counters:s" => { name => 'filter_counters', default => '' }, - }); - return $self; -} + $options{options}->add_options(arguments => { + }); -sub check_options { - my ($self, %options) = @_; - $self->SUPER::check_options(%options); + return $self; } my $oid_stConnectionsLegitimate = '.1.3.6.1.4.1.1230.2.7.2.1.3.0'; diff --git a/apps/antivirus/mcafee/webgateway/snmp/mode/detections.pm b/apps/antivirus/mcafee/webgateway/snmp/mode/detections.pm index fe98f1f89..c0ee3d4fc 100644 --- a/apps/antivirus/mcafee/webgateway/snmp/mode/detections.pm +++ b/apps/antivirus/mcafee/webgateway/snmp/mode/detections.pm @@ -37,28 +37,25 @@ sub set_counters { $self->{maps_counters}->{global} = [ { label => 'malware-detected', set => { - key_values => [ { name => 'stMalwareDetected', diff => 1 } ], + key_values => [ { name => 'stMalwareDetected', per_second => 1 } ], output_template => 'Malware detected (per sec): %d', - per_second => 1, perfdatas => [ - { label => 'malware_detected', value => 'stMalwareDetected_per_second', template => '%d', - min => 0, unit => 'detections/s' }, - ], + { label => 'malware_detected', template => '%d', min => 0, unit => 'detections/s' } + ] } - }, + } ]; $self->{maps_counters}->{categories} = [ { label => 'category', set => { - key_values => [ { name => 'stCategoryCount', diff => 1 }, { name => 'stCategoryName' } ], + key_values => [ { name => 'stCategoryCount', per_second => 1 }, { name => 'stCategoryName' } ], output_template => 'detections (per sec): %d', - per_second => 1, perfdatas => [ - { label => 'category', value => 'stCategoryCount_per_second', template => '%d', + { label => 'category', template => '%d', min => 0, unit => 'detections/s', label_extra_instance => 1, - instance_use => 'stCategoryName_absolute' }, - ], + instance_use => 'stCategoryName' } + ] } - }, + } ]; } @@ -73,17 +70,11 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - "filter-counters:s" => { name => 'filter_counters', default => '' }, - }); - return $self; -} + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' } + }); -sub check_options { - my ($self, %options) = @_; - $self->SUPER::check_options(%options); + return $self; } my $oid_stMalwareDetected = '.1.3.6.1.4.1.1230.2.7.2.1.2.0'; diff --git a/apps/antivirus/mcafee/webgateway/snmp/mode/ftpstatistics.pm b/apps/antivirus/mcafee/webgateway/snmp/mode/ftpstatistics.pm index 2a908517e..472846878 100644 --- a/apps/antivirus/mcafee/webgateway/snmp/mode/ftpstatistics.pm +++ b/apps/antivirus/mcafee/webgateway/snmp/mode/ftpstatistics.pm @@ -35,46 +35,38 @@ sub set_counters { $self->{maps_counters}->{traffics} = [ { label => 'client-to-proxy', set => { - key_values => [ { name => 'stFtpBytesFromClient', diff => 1 } ], + key_values => [ { name => 'stFtpBytesFromClient', per_second => 1 } ], output_template => 'from client to proxy: %s %s/s', output_change_bytes => 2, - per_second => 1, perfdatas => [ - { label => 'ftp_traffic_client_to_proxy', value => 'stFtpBytesFromClient_per_second', template => '%d', - min => 0, unit => 'b/s' }, + { label => 'ftp_traffic_client_to_proxy', template => '%d', min => 0, unit => 'b/s' }, ], } }, { label => 'server-to-proxy', set => { - key_values => [ { name => 'stFtpBytesFromServer', diff => 1 } ], + key_values => [ { name => 'stFtpBytesFromServer', per_second => 1 } ], output_template => 'from server to proxy: %s %s/s', output_change_bytes => 2, - per_second => 1, perfdatas => [ - { label => 'ftp_traffic_server_to_proxy', value => 'stFtpBytesFromServer_per_second', template => '%d', - min => 0, unit => 'b/s' }, + { label => 'ftp_traffic_server_to_proxy', template => '%d', min => 0, unit => 'b/s' }, ], } }, { label => 'proxy-to-client', set => { - key_values => [ { name => 'stFtpBytesToClient', diff => 1 } ], + key_values => [ { name => 'stFtpBytesToClient', per_second => 1 } ], output_template => 'from proxy to client: %s %s/s', output_change_bytes => 2, - per_second => 1, perfdatas => [ - { label => 'ftp_traffic_proxy_to_client', value => 'stFtpBytesToClient_per_second', template => '%d', - min => 0, unit => 'b/s' }, + { label => 'ftp_traffic_proxy_to_client', template => '%d', min => 0, unit => 'b/s' }, ], } }, { label => 'proxy-to-server', set => { - key_values => [ { name => 'stFtpBytesToServer', diff => 1 } ], + key_values => [ { name => 'stFtpBytesToServer', per_second => 1 } ], output_template => 'from proxy to server: %s %s/s', output_change_bytes => 2, - per_second => 1, perfdatas => [ - { label => 'ftp_traffic_proxy_to_server', value => 'stFtpBytesToServer_per_second', template => '%d', - min => 0, unit => 'b/s' }, + { label => 'ftp_traffic_proxy_to_server', template => '%d', min => 0, unit => 'b/s' }, ], } }, @@ -92,16 +84,10 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-counters:s" => { name => 'filter_counters', default => '' }, - }); - return $self; -} + $options{options}->add_options(arguments => { + }); -sub check_options { - my ($self, %options) = @_; - $self->SUPER::check_options(%options); + return $self; } my $oid_stFtpBytesFromClient = '.1.3.6.1.4.1.1230.2.7.2.4.2.0'; diff --git a/apps/antivirus/mcafee/webgateway/snmp/mode/httpsstatistics.pm b/apps/antivirus/mcafee/webgateway/snmp/mode/httpsstatistics.pm index b461a9285..c1faf9c57 100644 --- a/apps/antivirus/mcafee/webgateway/snmp/mode/httpsstatistics.pm +++ b/apps/antivirus/mcafee/webgateway/snmp/mode/httpsstatistics.pm @@ -36,58 +36,48 @@ sub set_counters { $self->{maps_counters}->{global} = [ { label => 'requests', set => { - key_values => [ { name => 'stHttpsRequests', diff => 1 } ], + key_values => [ { name => 'stHttpsRequests', per_second => 1 } ], output_template => 'HTTPS Requests (per sec): %d', - per_second => 1, perfdatas => [ - { label => 'https_requests', value => 'stHttpsRequests_per_second', template => '%d', - min => 0, unit => 'requests/s' }, + { label => 'https_requests', template => '%d', min => 0, unit => 'requests/s' }, ], } }, ]; $self->{maps_counters}->{traffics} = [ { label => 'client-to-proxy', set => { - key_values => [ { name => 'stHttpsBytesFromClient', diff => 1 } ], + key_values => [ { name => 'stHttpsBytesFromClient', per_second => 1 } ], output_template => 'from client to proxy: %s %s/s', output_change_bytes => 2, - per_second => 1, perfdatas => [ - { label => 'https_traffic_client_to_proxy', value => 'stHttpsBytesFromClient_per_second', template => '%d', - min => 0, unit => 'b/s' }, + { label => 'https_traffic_client_to_proxy', template => '%d', min => 0, unit => 'b/s' }, ], } }, { label => 'server-to-proxy', set => { - key_values => [ { name => 'stHttpsBytesFromServer', diff => 1 } ], + key_values => [ { name => 'stHttpsBytesFromServer', per_second => 1 } ], output_template => 'from server to proxy: %s %s/s', output_change_bytes => 2, - per_second => 1, perfdatas => [ - { label => 'https_traffic_server_to_proxy', value => 'stHttpsBytesFromServer_per_second', template => '%d', - min => 0, unit => 'b/s' }, + { label => 'https_traffic_server_to_proxy', template => '%d', min => 0, unit => 'b/s' }, ], } }, { label => 'proxy-to-client', set => { - key_values => [ { name => 'stHttpsBytesToClient', diff => 1 } ], + key_values => [ { name => 'stHttpsBytesToClient', per_second => 1 } ], output_template => 'from proxy to client: %s %s/s', output_change_bytes => 2, - per_second => 1, perfdatas => [ - { label => 'https_traffic_proxy_to_client', value => 'stHttpsBytesToClient_per_second', template => '%d', - min => 0, unit => 'b/s' }, + { label => 'https_traffic_proxy_to_client', template => '%d', min => 0, unit => 'b/s' }, ], } }, { label => 'proxy-to-server', set => { - key_values => [ { name => 'stHttpsBytesToServer', diff => 1 } ], + key_values => [ { name => 'stHttpsBytesToServer', per_second => 1 } ], output_template => 'from proxy to server: %s %s/s', output_change_bytes => 2, - per_second => 1, perfdatas => [ - { label => 'https_traffic_proxy_to_server', value => 'stHttpsBytesToServer_per_second', template => '%d', - min => 0, unit => 'b/s' }, + { label => 'https_traffic_proxy_to_server', template => '%d', min => 0, unit => 'b/s' }, ], } }, @@ -105,16 +95,10 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-counters:s" => { name => 'filter_counters', default => '' }, - }); - return $self; -} + $options{options}->add_options(arguments => { + }); -sub check_options { - my ($self, %options) = @_; - $self->SUPER::check_options(%options); + return $self; } my $oid_stHttpsRequests = '.1.3.6.1.4.1.1230.2.7.2.3.1.0'; diff --git a/apps/antivirus/mcafee/webgateway/snmp/mode/httpstatistics.pm b/apps/antivirus/mcafee/webgateway/snmp/mode/httpstatistics.pm index 8c6fbdf5e..9804c6a1c 100644 --- a/apps/antivirus/mcafee/webgateway/snmp/mode/httpstatistics.pm +++ b/apps/antivirus/mcafee/webgateway/snmp/mode/httpstatistics.pm @@ -36,61 +36,52 @@ sub set_counters { $self->{maps_counters}->{global} = [ { label => 'requests', set => { - key_values => [ { name => 'stHttpRequests', diff => 1 } ], + key_values => [ { name => 'stHttpRequests', per_second => 1 } ], output_template => 'HTTP Requests (per sec): %d', - per_second => 1, perfdatas => [ - { label => 'http_requests', value => 'stHttpRequests_per_second', template => '%d', - min => 0, unit => 'requests/s' }, - ], + { label => 'http_requests', template => '%d', min => 0, unit => 'requests/s' } + ] } - }, + } ]; + $self->{maps_counters}->{traffics} = [ { label => 'client-to-proxy', set => { - key_values => [ { name => 'stHttpBytesFromClient', diff => 1 } ], + key_values => [ { name => 'stHttpBytesFromClient', per_second => 1 } ], output_template => 'from client to proxy: %s %s/s', output_change_bytes => 2, - per_second => 1, perfdatas => [ - { label => 'http_traffic_client_to_proxy', value => 'stHttpBytesFromClient_per_second', template => '%d', - min => 0, unit => 'b/s' }, - ], + { label => 'http_traffic_client_to_proxy', template => '%d', min => 0, unit => 'b/s' } + ] } }, { label => 'server-to-proxy', set => { - key_values => [ { name => 'stHttpBytesFromServer', diff => 1 } ], + key_values => [ { name => 'stHttpBytesFromServer', per_second => 1 } ], output_template => 'from server to proxy: %s %s/s', output_change_bytes => 2, - per_second => 1, perfdatas => [ - { label => 'http_traffic_server_to_proxy', value => 'stHttpBytesFromServer_per_second', template => '%d', - min => 0, unit => 'b/s' }, - ], + { label => 'http_traffic_server_to_proxy', template => '%d', min => 0, unit => 'b/s' } + ] } }, { label => 'proxy-to-client', set => { - key_values => [ { name => 'stHttpBytesToClient', diff => 1 } ], + key_values => [ { name => 'stHttpBytesToClient', per_second => 1 } ], output_template => 'from proxy to client: %s %s/s', output_change_bytes => 2, - per_second => 1, perfdatas => [ - { label => 'http_traffic_proxy_to_client', value => 'stHttpBytesToClient_per_second', template => '%d', - min => 0, unit => 'b/s' }, - ], + { label => 'http_traffic_proxy_to_client', template => '%d', min => 0, unit => 'b/s' } + ] } }, { label => 'proxy-to-server', set => { - key_values => [ { name => 'stHttpBytesToServer', diff => 1 } ], + key_values => [ { name => 'stHttpBytesToServer', per_second => 1 } ], output_template => 'from proxy to server: %s %s/s', output_change_bytes => 2, - per_second => 1, perfdatas => [ - { label => 'http_traffic_proxy_to_server', value => 'stHttpBytesToServer_per_second', template => '%d', - min => 0, unit => 'b/s' }, - ], + { label => 'http_traffic_proxy_to_server', template => '%d', min => 0, unit => 'b/s' } + ] } - }, + } ]; } @@ -105,16 +96,10 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-counters:s" => { name => 'filter_counters', default => '' }, - }); - return $self; -} + $options{options}->add_options(arguments => { + }); -sub check_options { - my ($self, %options) = @_; - $self->SUPER::check_options(%options); + return $self; } my $oid_stHttpRequests = '.1.3.6.1.4.1.1230.2.7.2.2.1.0'; diff --git a/apps/automation/ansible/tower/mode/dashboard.pm b/apps/automation/ansible/tower/mode/dashboard.pm index 37f1d3a22..1d6f10c6b 100644 --- a/apps/automation/ansible/tower/mode/dashboard.pm +++ b/apps/automation/ansible/tower/mode/dashboard.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'hosts_total' } ], output_template => 'Hosts Total: %d', perfdatas => [ - { value => 'hosts_total_absolute', template => '%d', min => 0 }, + { value => 'hosts_total', template => '%d', min => 0 }, ], } }, @@ -45,8 +45,8 @@ sub set_counters { key_values => [ { name => 'hosts_failed' },{ name => 'hosts_total' } ], output_template => 'Hosts Failed: %d', perfdatas => [ - { value => 'hosts_failed_absolute', template => '%d', min => 0, - max => 'hosts_total_absolute' }, + { value => 'hosts_failed', template => '%d', min => 0, + max => 'hosts_total' }, ], } }, @@ -54,7 +54,7 @@ sub set_counters { key_values => [ { name => 'inventories_total' } ], output_template => 'Inventories Total: %d', perfdatas => [ - { value => 'inventories_total_absolute', template => '%d', min => 0 }, + { value => 'inventories_total', template => '%d', min => 0 }, ], } }, @@ -62,8 +62,8 @@ sub set_counters { key_values => [ { name => 'inventories_sync_failed' }, { name => 'inventories_total' } ], output_template => 'Inventories Sync Failed: %d', perfdatas => [ - { value => 'inventories_sync_failed_absolute', template => '%d', min => 0, - max => 'inventories_total_absolute' }, + { value => 'inventories_sync_failed', template => '%d', min => 0, + max => 'inventories_total' }, ], } }, @@ -71,7 +71,7 @@ sub set_counters { key_values => [ { name => 'projects_total' } ], output_template => 'Projects Total: %d', perfdatas => [ - { value => 'projects_total_absolute', template => '%d', min => 0 }, + { value => 'projects_total', template => '%d', min => 0 }, ], } }, @@ -79,8 +79,8 @@ sub set_counters { key_values => [ { name => 'projects_sync_failed' }, { name => 'projects_total' } ], output_template => 'Projects Sync Failed: %d', perfdatas => [ - { value => 'projects_sync_failed_absolute', template => '%d', min => 0, - max => 'projects_total_absolute' }, + { value => 'projects_sync_failed', template => '%d', min => 0, + max => 'projects_total' }, ], } }, diff --git a/apps/automation/ansible/tower/mode/inventorystatistics.pm b/apps/automation/ansible/tower/mode/inventorystatistics.pm index 3926e71ce..87416e821 100644 --- a/apps/automation/ansible/tower/mode/inventorystatistics.pm +++ b/apps/automation/ansible/tower/mode/inventorystatistics.pm @@ -39,7 +39,7 @@ sub set_counters { key_values => [ { name => 'total' } ], output_template => 'Total: %d', perfdatas => [ - { value => 'total_absolute', template => '%d', min => 0 }, + { value => 'total', template => '%d', min => 0 }, ], } }, @@ -47,8 +47,8 @@ sub set_counters { key_values => [ { name => 'failed' }, { name => 'total' } ], output_template => 'Failed: %d', perfdatas => [ - { value => 'failed_absolute', template => '%d', min => 0, - max => 'total_absolute' }, + { value => 'failed', template => '%d', min => 0, + max => 'total' }, ], } }, @@ -58,8 +58,8 @@ sub set_counters { key_values => [ { name => 'total_hosts' }, { name => 'display' } ], output_template => 'Hosts total: %d', perfdatas => [ - { value => 'total_hosts_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'total_hosts', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -68,9 +68,9 @@ sub set_counters { { name => 'display' } ], output_template => 'Hosts failed: %d', perfdatas => [ - { value => 'hosts_with_active_failures_absolute', template => '%d', - min => 0, max => 'total_hosts_absolute', label_extra_instance => 1, - instance_use => 'display_absolute' }, + { value => 'hosts_with_active_failures', template => '%d', + min => 0, max => 'total_hosts', label_extra_instance => 1, + instance_use => 'display' }, ], } }, @@ -78,8 +78,8 @@ sub set_counters { key_values => [ { name => 'total_inventory_sources' }, { name => 'display' } ], output_template => 'Sources total: %d', perfdatas => [ - { value => 'total_inventory_sources_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'total_inventory_sources', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -88,9 +88,9 @@ sub set_counters { { name => 'display' } ], output_template => 'Sources failed: %d', perfdatas => [ - { value => 'inventory_sources_with_failures_absolute', template => '%d', - min => 0, max => 'total_inventory_sources_absolute', label_extra_instance => 1, - instance_use => 'display_absolute' }, + { value => 'inventory_sources_with_failures', template => '%d', + min => 0, max => 'total_inventory_sources', label_extra_instance => 1, + instance_use => 'display' }, ], } }, @@ -98,8 +98,8 @@ sub set_counters { key_values => [ { name => 'total_groups' }, { name => 'display' } ], output_template => 'Groups total: %d', perfdatas => [ - { value => 'total_groups_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'total_groups', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -108,9 +108,9 @@ sub set_counters { { name => 'display' } ], output_template => 'Groups failed: %d', perfdatas => [ - { value => 'groups_with_active_failures_absolute', template => '%d', - min => 0, max => 'total_groups_absolute', label_extra_instance => 1, - instance_use => 'display_absolute' }, + { value => 'groups_with_active_failures', template => '%d', + min => 0, max => 'total_groups', label_extra_instance => 1, + instance_use => 'display' }, ], } }, diff --git a/apps/backup/arcserve/udp/mssql/mode/jobstatus.pm b/apps/backup/arcserve/udp/mssql/mode/jobstatus.pm index a4b77db17..e9345c2ff 100644 --- a/apps/backup/arcserve/udp/mssql/mode/jobstatus.pm +++ b/apps/backup/arcserve/udp/mssql/mode/jobstatus.pm @@ -82,7 +82,7 @@ sub set_counters { key_values => [ { name => 'total' } ], output_template => 'total jobs : %s', perfdatas => [ - { label => 'total', value => 'total_absolute', template => '%s', min => 0 }, + { label => 'total', value => 'total', template => '%s', min => 0 }, ], } }, diff --git a/apps/backup/netapp/snapcenter/restapi/mode/jobs.pm b/apps/backup/netapp/snapcenter/restapi/mode/jobs.pm index 75e49c9dd..f1505e119 100644 --- a/apps/backup/netapp/snapcenter/restapi/mode/jobs.pm +++ b/apps/backup/netapp/snapcenter/restapi/mode/jobs.pm @@ -53,7 +53,7 @@ sub set_counters { key_values => [ { name => 'total' } ], output_template => 'total jobs : %s', perfdatas => [ - { label => 'total', value => 'total_absolute', template => '%s', min => 0 }, + { label => 'total', value => 'total', template => '%s', min => 0 }, ], } }, diff --git a/apps/backup/netbackup/local/mode/dedupstatus.pm b/apps/backup/netbackup/local/mode/dedupstatus.pm index 9b1a0d5ea..a95ba12e2 100644 --- a/apps/backup/netbackup/local/mode/dedupstatus.pm +++ b/apps/backup/netbackup/local/mode/dedupstatus.pm @@ -46,9 +46,9 @@ sub custom_usage_threshold { my ($self, %options) = @_; if (!defined($self->{instance_mode}->{option_results}->{'critical-usage'}) || $self->{instance_mode}->{option_results}->{'critical-usage'} eq '') { - $self->{perfdata}->threshold_validate(label => 'critical-usage', value => $self->{result_values}->{watermark_absolute}); + $self->{perfdata}->threshold_validate(label => 'critical-usage', value => $self->{result_values}->{watermark}); } - return $self->{perfdata}->threshold_check(value => $self->{result_values}->{usage_absolute}, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-'. $self->{label}, exit_litteral => 'warning' } ]); + return $self->{perfdata}->threshold_check(value => $self->{result_values}->{usage}, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-'. $self->{label}, exit_litteral => 'warning' } ]); } sub set_counters { @@ -72,8 +72,8 @@ sub set_counters { output_template => 'Use: %s %%', closure_custom_threshold_check => $self->can('custom_usage_threshold'), perfdatas => [ - { label => 'used', value => 'usage_absolute', template => '%s', - unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'used', value => 'usage', template => '%s', + unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/apps/backup/netbackup/local/mode/drivecleaning.pm b/apps/backup/netbackup/local/mode/drivecleaning.pm index 7aa29453b..cb917f03e 100644 --- a/apps/backup/netbackup/local/mode/drivecleaning.pm +++ b/apps/backup/netbackup/local/mode/drivecleaning.pm @@ -38,8 +38,8 @@ sub set_counters { key_values => [ { name => 'num_cleaning' }, { name => 'total' } ], output_template => '%d drives needs a reset mount time', perfdatas => [ - { label => 'cleaning', value => 'num_cleaning_absolute', template => '%s', - min => 0, max => 'total_absolute' }, + { label => 'cleaning', value => 'num_cleaning', template => '%s', + min => 0, max => 'total' }, ], } }, diff --git a/apps/backup/netbackup/local/mode/jobstatus.pm b/apps/backup/netbackup/local/mode/jobstatus.pm index 1a8c86967..68ee9144e 100644 --- a/apps/backup/netbackup/local/mode/jobstatus.pm +++ b/apps/backup/netbackup/local/mode/jobstatus.pm @@ -159,7 +159,7 @@ sub set_counters { key_values => [ { name => 'total' } ], output_template => 'Total Jobs : %s', perfdatas => [ - { label => 'total', value => 'total_absolute', template => '%s', min => 0 }, + { label => 'total', value => 'total', template => '%s', min => 0 }, ], } }, diff --git a/apps/backup/quadstor/local/mode/vtltapeusage.pm b/apps/backup/quadstor/local/mode/vtltapeusage.pm index 94fc6a32a..ea5fdcd46 100644 --- a/apps/backup/quadstor/local/mode/vtltapeusage.pm +++ b/apps/backup/quadstor/local/mode/vtltapeusage.pm @@ -122,7 +122,7 @@ sub set_counters { key_values => [ { name => 'count' } ], output_template => 'Number of tapes : %s', perfdatas => [ - { label => 'count', value => 'count_absolute', template => '%s', + { label => 'count', value => 'count', template => '%s', unit => 'tapes', min => 0 }, ], } diff --git a/apps/backup/rapidrecovery/snmp/mode/agent.pm b/apps/backup/rapidrecovery/snmp/mode/agent.pm index c34ddd689..c62762a41 100644 --- a/apps/backup/rapidrecovery/snmp/mode/agent.pm +++ b/apps/backup/rapidrecovery/snmp/mode/agent.pm @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'total' } ], output_template => 'total agents: %d', perfdatas => [ - { value => 'total_absolute', template => '%d', min => 0 }, + { value => 'total', template => '%d', min => 0 }, ], } }, @@ -65,8 +65,8 @@ sub set_counters { key_values => [ { name => 'recovery_points' }, { name => 'display' } ], output_template => 'recovery points: %s', perfdatas => [ - { value => 'recovery_points_absolute', template => '%s', min => 0, - label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'recovery_points', template => '%s', min => 0, + label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/apps/backup/rapidrecovery/snmp/mode/repository.pm b/apps/backup/rapidrecovery/snmp/mode/repository.pm index 845070516..292c11f20 100644 --- a/apps/backup/rapidrecovery/snmp/mode/repository.pm +++ b/apps/backup/rapidrecovery/snmp/mode/repository.pm @@ -38,11 +38,11 @@ sub custom_space_output { my $msg = sprintf( "space total: %s %s used: %s %s (%.2f%%) free: %s %s (%.2f%%)", - $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_absolute}), - $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_absolute}), - $self->{result_values}->{prct_used_absolute}, - $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute}), - $self->{result_values}->{prct_free_absolute} + $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}), + $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}), + $self->{result_values}->{prct_used}, + $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}), + $self->{result_values}->{prct_free} ); return $msg; } @@ -67,8 +67,8 @@ sub set_counters { key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'display' } ], closure_custom_output => $self->can('custom_space_output'), perfdatas => [ - { value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute', - unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'used', template => '%d', min => 0, max => 'total', + unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -76,8 +76,8 @@ sub set_counters { key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'display' } ], closure_custom_output => $self->can('custom_space_output'), perfdatas => [ - { value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute', - unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'free', template => '%d', min => 0, max => 'total', + unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -85,8 +85,8 @@ sub set_counters { key_values => [ { name => 'prct_used' }, { name => 'display' } ], output_template => 'space used: %.2f %%', perfdatas => [ - { value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, unit => '%', - label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'prct_used', template => '%.2f', min => 0, max => 100, unit => '%', + label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/apps/backup/tsm/local/mode/drives.pm b/apps/backup/tsm/local/mode/drives.pm index c32ddeecf..ffc5e64b2 100644 --- a/apps/backup/tsm/local/mode/drives.pm +++ b/apps/backup/tsm/local/mode/drives.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'online' } ], output_template => 'online : %s', perfdatas => [ - { label => 'online', value => 'online_absolute', template => '%s', min => 0 }, + { label => 'online', value => 'online', template => '%s', min => 0 }, ], } }, @@ -45,7 +45,7 @@ sub set_counters { key_values => [ { name => 'offline' } ], output_template => 'offline : %s', perfdatas => [ - { label => 'offline', value => 'offline_absolute', template => '%s', min => 0 }, + { label => 'offline', value => 'offline', template => '%s', min => 0 }, ], } }, @@ -53,7 +53,7 @@ sub set_counters { key_values => [ { name => 'unavailable' } ], output_template => 'unavailable : %s', perfdatas => [ - { label => 'unavailable', value => 'unavailable_absolute', template => '%s', min => 0 }, + { label => 'unavailable', value => 'unavailable', template => '%s', min => 0 }, ], } }, @@ -61,7 +61,7 @@ sub set_counters { key_values => [ { name => 'empty' } ], output_template => 'empty : %s', perfdatas => [ - { label => 'empty', value => 'empty_absolute', template => '%s', min => 0 }, + { label => 'empty', value => 'empty', template => '%s', min => 0 }, ], } }, @@ -69,7 +69,7 @@ sub set_counters { key_values => [ { name => 'loaded' } ], output_template => 'loaded : %s', perfdatas => [ - { label => 'loaded', value => 'loaded_absolute', template => '%s', min => 0 }, + { label => 'loaded', value => 'loaded', template => '%s', min => 0 }, ], } }, @@ -77,7 +77,7 @@ sub set_counters { key_values => [ { name => 'unloaded' } ], output_template => 'unloaded : %s', perfdatas => [ - { label => 'unloaded', value => 'unloaded_absolute', template => '%s', min => 0 }, + { label => 'unloaded', value => 'unloaded', template => '%s', min => 0 }, ], } }, @@ -85,7 +85,7 @@ sub set_counters { key_values => [ { name => 'reserved' } ], output_template => 'reserved : %s', perfdatas => [ - { label => 'reserved', value => 'reserved_absolute', template => '%s', min => 0 }, + { label => 'reserved', value => 'reserved', template => '%s', min => 0 }, ], } }, @@ -93,7 +93,7 @@ sub set_counters { key_values => [ { name => 'unknown' } ], output_template => 'unknown : %s', perfdatas => [ - { label => 'unknown', value => 'unknown_absolute', template => '%s', min => 0 }, + { label => 'unknown', value => 'unknown', template => '%s', min => 0 }, ], } }, diff --git a/apps/backup/tsm/local/mode/nodes.pm b/apps/backup/tsm/local/mode/nodes.pm index b31b82dd7..e12367adc 100644 --- a/apps/backup/tsm/local/mode/nodes.pm +++ b/apps/backup/tsm/local/mode/nodes.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'associated' } ], output_template => 'Total Associated Nodes : %s', perfdatas => [ - { label => 'associated', value => 'associated_absolute', template => '%s', min => 0 }, + { label => 'associated', value => 'associated', template => '%s', min => 0 }, ], } }, @@ -45,7 +45,7 @@ sub set_counters { key_values => [ { name => 'non_associated' } ], output_template => 'Total Non Associated Nodes : %s', perfdatas => [ - { label => 'non_associated', value => 'non_associated_absolute', template => '%s', min => 0 }, + { label => 'non_associated', value => 'non_associated', template => '%s', min => 0 }, ], } }, @@ -53,7 +53,7 @@ sub set_counters { key_values => [ { name => 'locked' } ], output_template => 'Total Locked Nodes : %s', perfdatas => [ - { label => 'locked', value => 'locked_absolute', template => '%s', min => 0 }, + { label => 'locked', value => 'locked', template => '%s', min => 0 }, ], } }, diff --git a/apps/backup/tsm/local/mode/sessions.pm b/apps/backup/tsm/local/mode/sessions.pm index 8d05cbc95..ed5136fbe 100644 --- a/apps/backup/tsm/local/mode/sessions.pm +++ b/apps/backup/tsm/local/mode/sessions.pm @@ -61,7 +61,7 @@ sub set_counters { key_values => [ { name => 'total' } ], output_template => 'Total Sessions : %s', perfdatas => [ - { label => 'total', value => 'total_absolute', template => '%s', min => 0 }, + { label => 'total', value => 'total', template => '%s', min => 0 }, ], } }, diff --git a/apps/backup/tsm/local/mode/volumes.pm b/apps/backup/tsm/local/mode/volumes.pm index d29d8bb3c..0625c9713 100644 --- a/apps/backup/tsm/local/mode/volumes.pm +++ b/apps/backup/tsm/local/mode/volumes.pm @@ -38,7 +38,7 @@ sub set_counters { key_values => [ { name => 'total' } ], output_template => 'Volumes Total : %s', perfdatas => [ - { label => 'total', value => 'total_absolute', template => '%s', min => 0 }, + { label => 'total', value => 'total', template => '%s', min => 0 }, ], } }, @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'online' } ], output_template => 'Online : %s', perfdatas => [ - { label => 'online', value => 'online_absolute', template => '%s', min => 0 }, + { label => 'online', value => 'online', template => '%s', min => 0 }, ], } }, @@ -54,7 +54,7 @@ sub set_counters { key_values => [ { name => 'offline' } ], output_template => 'Offline : %s', perfdatas => [ - { label => 'offline', value => 'offline_absolute', template => '%s', min => 0 }, + { label => 'offline', value => 'offline', template => '%s', min => 0 }, ], } }, @@ -62,7 +62,7 @@ sub set_counters { key_values => [ { name => 'empty' } ], output_template => 'Empty : %s', perfdatas => [ - { label => 'empty', value => 'empty_absolute', template => '%s', min => 0 }, + { label => 'empty', value => 'empty', template => '%s', min => 0 }, ], } }, @@ -70,7 +70,7 @@ sub set_counters { key_values => [ { name => 'pending' } ], output_template => 'Pending : %s', perfdatas => [ - { label => 'pending', value => 'pending_absolute', template => '%s', min => 0 }, + { label => 'pending', value => 'pending', template => '%s', min => 0 }, ], } }, @@ -78,7 +78,7 @@ sub set_counters { key_values => [ { name => 'filling' } ], output_template => 'Filling : %s', perfdatas => [ - { label => 'filling', value => 'filling_absolute', template => '%s', min => 0 }, + { label => 'filling', value => 'filling', template => '%s', min => 0 }, ], } }, @@ -86,7 +86,7 @@ sub set_counters { key_values => [ { name => 'full' } ], output_template => 'Full : %s', perfdatas => [ - { label => 'full', value => 'full_absolute', template => '%s', min => 0 }, + { label => 'full', value => 'full', template => '%s', min => 0 }, ], } }, @@ -97,8 +97,8 @@ sub set_counters { key_values => [ { name => 'prct_utilized' }, { name => 'display' } ], output_template => 'Usage : %s %%', perfdatas => [ - { label => 'used', value => 'prct_utilized_absolute', template => '%s', min => 0, max => 100, - unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'used', value => 'prct_utilized', template => '%s', min => 0, max => 100, + unit => '%', label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/apps/backup/veeam/local/mode/jobstatus.pm b/apps/backup/veeam/local/mode/jobstatus.pm index aa034ffb0..fde71fa4b 100644 --- a/apps/backup/veeam/local/mode/jobstatus.pm +++ b/apps/backup/veeam/local/mode/jobstatus.pm @@ -69,7 +69,7 @@ sub set_counters { key_values => [ { name => 'total' } ], output_template => 'Total Jobs : %s', perfdatas => [ - { label => 'total', value => 'total_absolute', template => '%s', min => 0 } + { label => 'total', value => 'total', template => '%s', min => 0 } ] } } diff --git a/apps/backup/veeam/local/mode/tapejobs.pm b/apps/backup/veeam/local/mode/tapejobs.pm index 0c02c1bc6..ac7d8c372 100644 --- a/apps/backup/veeam/local/mode/tapejobs.pm +++ b/apps/backup/veeam/local/mode/tapejobs.pm @@ -54,7 +54,7 @@ sub set_counters { key_values => [ { name => 'total' } ], output_template => 'total jobs: %s', perfdatas => [ - { value => 'total_absolute', template => '%s', min => 0 }, + { value => 'total', template => '%s', min => 0 }, ], } }, diff --git a/apps/bind9/web/mode/serverusage.pm b/apps/bind9/web/mode/serverusage.pm index 1c46d7f74..1595ea10f 100644 --- a/apps/bind9/web/mode/serverusage.pm +++ b/apps/bind9/web/mode/serverusage.pm @@ -59,7 +59,7 @@ sub set_counters { key_values => [ { name => $map[$i]->[0], diff => 1 } ], output_template => $map[$i]->[1], perfdatas => [ - { label => $perf_label, value => $map[$i]->[0] . '_absolute', template => '%s', min => 0 }, + { label => $perf_label, value => $map[$i]->[0] , template => '%s', min => 0 }, ], } }; diff --git a/apps/bind9/web/mode/zoneusage.pm b/apps/bind9/web/mode/zoneusage.pm index fb5ffa02b..4325d6b50 100644 --- a/apps/bind9/web/mode/zoneusage.pm +++ b/apps/bind9/web/mode/zoneusage.pm @@ -63,8 +63,8 @@ sub set_counters { key_values => [ { name => $map[$i]->[0], diff => 1 }, { name => 'display' } ], output_template => $map[$i]->[1], perfdatas => [ - { label => $perf_label, value => $map[$i]->[0] . '_absolute', template => '%s', min => 0, - label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => $perf_label, value => $map[$i]->[0] , template => '%s', min => 0, + label_extra_instance => 1, instance_use => 'display' }, ], } }; diff --git a/apps/bluemind/local/mode/core.pm b/apps/bluemind/local/mode/core.pm index a266e1a23..3a59239f5 100644 --- a/apps/bluemind/local/mode/core.pm +++ b/apps/bluemind/local/mode/core.pm @@ -45,7 +45,7 @@ sub set_counters { key_values => [ { name => 'calls_success', diff => 1 } ], output_template => 'success calls received: %s', perfdatas => [ - { value => 'calls_success_absolute', template => '%s', min => 0 } + { value => 'calls_success', template => '%s', min => 0 } ] } }, @@ -53,7 +53,7 @@ sub set_counters { key_values => [ { name => 'calls_failure', diff => 1 } ], output_template => 'failure calls received: %s', perfdatas => [ - { value => 'calls_failure_absolute', template => '%s', min => 0 } + { value => 'calls_failure', template => '%s', min => 0 } ] } }, @@ -61,7 +61,7 @@ sub set_counters { key_values => [ { name => 'heartbeat_broadcast', diff => 1 } ], output_template => 'broadcast heartbeat running: %s', perfdatas => [ - { value => 'heartbeat_broadcast_absolute', template => '%s', min => 0 } + { value => 'heartbeat_broadcast', template => '%s', min => 0 } ] } }, @@ -69,7 +69,7 @@ sub set_counters { key_values => [ { name => 'cluster_events', diff => 1 } ], output_template => 'directory cluster events: %s', perfdatas => [ - { value => 'cluster_events_absolute', template => '%s', min => 0 } + { value => 'cluster_events', template => '%s', min => 0 } ] } }, @@ -77,7 +77,7 @@ sub set_counters { key_values => [ { name => 'request_handling_time_total', diff => 1 } ], output_template => 'total request handling: %s ms', perfdatas => [ - { value => 'request_handling_time_total_absolute', template => '%s', min => 0, unit => 'ms' } + { value => 'request_handling_time_total', template => '%s', min => 0, unit => 'ms' } ] } }, @@ -85,7 +85,7 @@ sub set_counters { key_values => [ { name => 'request_handling_time_mean' } ], output_template => 'mean request handling: %s ms', perfdatas => [ - { value => 'request_handling_time_mean_absolute', template => '%s', min => 0, unit => 'ms' } + { value => 'request_handling_time_mean', template => '%s', min => 0, unit => 'ms' } ] } } diff --git a/apps/bluemind/local/mode/eas.pm b/apps/bluemind/local/mode/eas.pm index fec8f7651..8ae1a0ea3 100644 --- a/apps/bluemind/local/mode/eas.pm +++ b/apps/bluemind/local/mode/eas.pm @@ -46,7 +46,7 @@ sub set_counters { output_template => 'total responses size: %s %s', output_change_bytes => 1, perfdatas => [ - { value => 'response_size_absolute', template => '%s', min => 0, unit => 'B' } + { value => 'response_size', template => '%s', min => 0, unit => 'B' } ] } }, @@ -54,7 +54,7 @@ sub set_counters { key_values => [ { name => 'execution_total', diff => 1 } ], output_template => 'total execution: %s ms', perfdatas => [ - { value => 'execution_total_absolute', template => '%s', min => 0, unit => 'ms' } + { value => 'execution_total', template => '%s', min => 0, unit => 'ms' } ] } }, @@ -62,7 +62,7 @@ sub set_counters { key_values => [ { name => 'execution_mean' } ], output_template => 'mean execution: %s ms', perfdatas => [ - { value => 'execution_mean_absolute', template => '%s', min => 0, unit => 'ms' } + { value => 'execution_mean', template => '%s', min => 0, unit => 'ms' } ] } } diff --git a/apps/bluemind/local/mode/hps.pm b/apps/bluemind/local/mode/hps.pm index 235191345..4eb1edfff 100644 --- a/apps/bluemind/local/mode/hps.pm +++ b/apps/bluemind/local/mode/hps.pm @@ -51,7 +51,7 @@ sub set_counters { key_values => [ { name => 'auth_success', diff => 1 } ], output_template => 'success authentication: %s', perfdatas => [ - { value => 'auth_success_absolute', template => '%s', min => 0 } + { value => 'auth_success', template => '%s', min => 0 } ] } }, @@ -59,7 +59,7 @@ sub set_counters { key_values => [ { name => 'auth_failure', diff => 1 } ], output_template => 'failure authentication: %s', perfdatas => [ - { value => 'auth_failure_absolute', template => '%s', min => 0 } + { value => 'auth_failure', template => '%s', min => 0 } ] } }, @@ -67,7 +67,7 @@ sub set_counters { key_values => [ { name => 'requests_protected', diff => 1 } ], output_template => 'protected requests: %s', perfdatas => [ - { value => 'requests_protected_absolute', template => '%s', min => 0 } + { value => 'requests_protected', template => '%s', min => 0 } ] } }, @@ -75,7 +75,7 @@ sub set_counters { key_values => [ { name => 'requests_maintenance', diff => 1 } ], output_template => 'maintenance requests: %s', perfdatas => [ - { value => 'requests_maintenance_absolute', template => '%s', min => 0 } + { value => 'requests_maintenance', template => '%s', min => 0 } ] } } @@ -86,7 +86,7 @@ sub set_counters { key_values => [ { name => 'requests_time_total', diff => 1 }, { name => 'display' } ], output_template => 'total requests time: %s ms', perfdatas => [ - { value => 'requests_time_total_absolute', template => '%s', min => 0, unit => 'ms', label_extra_instance => 1 } + { value => 'requests_time_total', template => '%s', min => 0, unit => 'ms', label_extra_instance => 1 } ] } }, @@ -94,7 +94,7 @@ sub set_counters { key_values => [ { name => 'requests_time_mean' }, { name => 'display' } ], output_template => 'mean requests time: %s ms', perfdatas => [ - { value => 'requests_time_mean_absolute', template => '%s', min => 0, unit => 'ms', label_extra_instance => 1 } + { value => 'requests_time_mean', template => '%s', min => 0, unit => 'ms', label_extra_instance => 1 } ] } }, @@ -103,7 +103,7 @@ sub set_counters { output_template => 'total requests size: %s %s', output_change_bytes => 1, perfdatas => [ - { value => 'requests_size_absolute', template => '%s', min => 0, unit => 'B' } + { value => 'requests_size', template => '%s', min => 0, unit => 'B' } ] } }, @@ -111,7 +111,7 @@ sub set_counters { key_values => [ { name => 'requests', diff => 1 } ], output_template => 'total requests: %s', perfdatas => [ - { value => 'requests_absolute', template => '%s', min => 0 } + { value => 'requests', template => '%s', min => 0 } ] } } diff --git a/apps/bluemind/local/mode/ips.pm b/apps/bluemind/local/mode/ips.pm index 8b7b58c66..52f2454d8 100644 --- a/apps/bluemind/local/mode/ips.pm +++ b/apps/bluemind/local/mode/ips.pm @@ -43,7 +43,7 @@ sub set_counters { key_values => [ { name => 'active_connections' } ], output_template => 'active connections: %s', perfdatas => [ - { value => 'active_connections_absolute', template => '%s', min => 0 } + { value => 'active_connections', template => '%s', min => 0 } ] } } diff --git a/apps/bluemind/local/mode/lmtpd.pm b/apps/bluemind/local/mode/lmtpd.pm index 0a985bc71..c3d478bc8 100644 --- a/apps/bluemind/local/mode/lmtpd.pm +++ b/apps/bluemind/local/mode/lmtpd.pm @@ -45,7 +45,7 @@ sub set_counters { key_values => [ { name => 'active_connections' } ], output_template => 'active connections: %s', perfdatas => [ - { value => 'active_connections_absolute', template => '%s', min => 0 } + { value => 'active_connections', template => '%s', min => 0 } ] } }, @@ -53,7 +53,7 @@ sub set_counters { key_values => [ { name => 'connections', diff => 1 } ], output_template => 'total connections: %s', perfdatas => [ - { value => 'connections_absolute', template => '%s', min => 0 } + { value => 'connections', template => '%s', min => 0 } ] } }, @@ -61,7 +61,7 @@ sub set_counters { key_values => [ { name => 'deliveries_ok', diff => 1 } ], output_template => 'success deliveries: %s', perfdatas => [ - { value => 'deliveries_ok_absolute', template => '%s', min => 0 } + { value => 'deliveries_ok', template => '%s', min => 0 } ] } }, @@ -69,7 +69,7 @@ sub set_counters { key_values => [ { name => 'deliveries_ko', diff => 1 } ], output_template => 'failure deliveries: %s', perfdatas => [ - { value => 'deliveries_ko_absolute', template => '%s', min => 0 } + { value => 'deliveries_ko', template => '%s', min => 0 } ] } }, @@ -78,7 +78,7 @@ sub set_counters { output_template => 'total emails size: %s %s', output_change_bytes => 1, perfdatas => [ - { value => 'email_size_absolute', template => '%s', min => 0, unit => 'B' } + { value => 'email_size', template => '%s', min => 0, unit => 'B' } ] } }, @@ -86,7 +86,7 @@ sub set_counters { key_values => [ { name => 'session_duration_total', diff => 1 } ], output_template => 'total sessions duration: %s ms', perfdatas => [ - { value => 'session_duration_total_absolute', template => '%s', min => 0, unit => 'ms' } + { value => 'session_duration_total', template => '%s', min => 0, unit => 'ms' } ] } }, @@ -94,7 +94,7 @@ sub set_counters { key_values => [ { name => 'session_duration_mean' } ], output_template => 'mean sessions duration: %s ms', perfdatas => [ - { value => 'session_duration_mean_absolute', template => '%s', min => 0, unit => 'ms' } + { value => 'session_duration_mean', template => '%s', min => 0, unit => 'ms' } ] } }, @@ -102,7 +102,7 @@ sub set_counters { key_values => [ { name => 'traffic_latency_total', diff => 1 } ], output_template => 'total traffic transport latency: %s ms', perfdatas => [ - { value => 'traffic_latency_total_absolute', template => '%s', min => 0, unit => 'ms' } + { value => 'traffic_latency_total', template => '%s', min => 0, unit => 'ms' } ] } }, @@ -110,7 +110,7 @@ sub set_counters { key_values => [ { name => 'traffic_latency_mean' } ], output_template => 'mean traffic transport latency: %s ms', perfdatas => [ - { value => 'traffic_latency_mean_absolute', template => '%s', min => 0, unit => 'ms' } + { value => 'traffic_latency_mean', template => '%s', min => 0, unit => 'ms' } ] } } diff --git a/apps/bluemind/local/mode/milter.pm b/apps/bluemind/local/mode/milter.pm index a762467f5..48db93d3a 100644 --- a/apps/bluemind/local/mode/milter.pm +++ b/apps/bluemind/local/mode/milter.pm @@ -45,7 +45,7 @@ sub set_counters { key_values => [ { name => 'connections', diff => 1 } ], output_template => 'total connections: %s', perfdatas => [ - { value => 'connections_absolute', template => '%s', min => 0 } + { value => 'connections', template => '%s', min => 0 } ] } }, @@ -53,7 +53,7 @@ sub set_counters { key_values => [ { name => 'traffic_class_inbound', diff => 1 } ], output_template => 'traffic class inbound: %s', perfdatas => [ - { value => 'traffic_class_inbound_absolute', template => '%s', min => 0 } + { value => 'traffic_class_inbound', template => '%s', min => 0 } ] } }, @@ -61,7 +61,7 @@ sub set_counters { key_values => [ { name => 'traffic_class_outbound', diff => 1 } ], output_template => 'traffic class outbound: %s', perfdatas => [ - { value => 'traffic_class_outbound_absolute', template => '%s', min => 0 } + { value => 'traffic_class_outbound', template => '%s', min => 0 } ] } }, @@ -70,7 +70,7 @@ sub set_counters { output_template => 'traffic size inbound: %s %s', output_change_bytes => 1, perfdatas => [ - { value => 'traffic_size_inbound_absolute', template => '%s', min => 0, unit => 'B' } + { value => 'traffic_size_inbound', template => '%s', min => 0, unit => 'B' } ] } }, @@ -79,7 +79,7 @@ sub set_counters { output_template => 'traffic size outbound: %s %s', output_change_bytes => 1, perfdatas => [ - { value => 'traffic_size_outbound_absolute', template => '%s', min => 0, unit => 'B' } + { value => 'traffic_size_outbound', template => '%s', min => 0, unit => 'B' } ] } }, @@ -87,7 +87,7 @@ sub set_counters { key_values => [ { name => 'session_duration_total', diff => 1 } ], output_template => 'total sessions duration: %s ms', perfdatas => [ - { value => 'session_duration_total_absolute', template => '%s', min => 0, unit => 'ms' } + { value => 'session_duration_total', template => '%s', min => 0, unit => 'ms' } ] } }, @@ -95,7 +95,7 @@ sub set_counters { key_values => [ { name => 'session_duration_mean' } ], output_template => 'mean sessions duration: %s ms', perfdatas => [ - { value => 'session_duration_mean_absolute', template => '%s', min => 0, unit => 'ms' } + { value => 'session_duration_mean', template => '%s', min => 0, unit => 'ms' } ] } } diff --git a/apps/bluemind/local/mode/webserver.pm b/apps/bluemind/local/mode/webserver.pm index 3e2aede4a..5a8c46cde 100644 --- a/apps/bluemind/local/mode/webserver.pm +++ b/apps/bluemind/local/mode/webserver.pm @@ -45,7 +45,7 @@ sub set_counters { key_values => [ { name => 'requests_time_total', diff => 1 } ], output_template => 'total requests time: %s ms', perfdatas => [ - { value => 'requests_time_total_absolute', template => '%s', min => 0, unit => 'ms' } + { value => 'requests_time_total', template => '%s', min => 0, unit => 'ms' } ] } }, @@ -53,7 +53,7 @@ sub set_counters { key_values => [ { name => 'requests_time_mean' } ], output_template => 'mean requests time: %s ms', perfdatas => [ - { value => 'requests_time_mean_absolute', template => '%s', min => 0, unit => 'ms' } + { value => 'requests_time_mean', template => '%s', min => 0, unit => 'ms' } ] } }, @@ -61,7 +61,7 @@ sub set_counters { key_values => [ { name => 'requests', diff => 1 } ], output_template => 'total requests: %s', perfdatas => [ - { value => 'requests_absolute', template => '%s', min => 0 } + { value => 'requests', template => '%s', min => 0 } ] } }, @@ -69,7 +69,7 @@ sub set_counters { key_values => [ { name => 'requests_200', diff => 1 } ], output_template => 'total 200 requests: %s', perfdatas => [ - { value => 'requests_200_absolute', template => '%s', min => 0 } + { value => 'requests_200', template => '%s', min => 0 } ] } }, @@ -77,7 +77,7 @@ sub set_counters { key_values => [ { name => 'requests_304', diff => 1 } ], output_template => 'total 304 requests: %s', perfdatas => [ - { value => 'requests_304_absolute', template => '%s', min => 0 } + { value => 'requests_304', template => '%s', min => 0 } ] } } diff --git a/apps/bluemind/local/mode/xmpp.pm b/apps/bluemind/local/mode/xmpp.pm index 859d394ce..94f936112 100644 --- a/apps/bluemind/local/mode/xmpp.pm +++ b/apps/bluemind/local/mode/xmpp.pm @@ -45,7 +45,7 @@ sub set_counters { key_values => [ { name => 'packets_all', diff => 1 } ], output_template => 'all packets sent: %s', perfdatas => [ - { value => 'packets_all_absolute', template => '%s', min => 0 } + { value => 'packets_all', template => '%s', min => 0 } ] } }, @@ -53,7 +53,7 @@ sub set_counters { key_values => [ { name => 'packets_chat', diff => 1 } ], output_template => 'chat packets sent: %s', perfdatas => [ - { value => 'packets_chat_absolute', template => '%s', min => 0 } + { value => 'packets_chat', template => '%s', min => 0 } ] } } diff --git a/apps/centreon/local/mode/brokerstats.pm b/apps/centreon/local/mode/brokerstats.pm index 78f1b220b..788a18f1a 100644 --- a/apps/centreon/local/mode/brokerstats.pm +++ b/apps/centreon/local/mode/brokerstats.pm @@ -72,8 +72,8 @@ sub set_counters { key_values => [ { name => 'speed_events' }, { name => 'display' } ], output_template => 'Speed Events: %s/s', perfdatas => [ - { label => 'speed_events', value => 'speed_events_absolute', template => '%s', - unit => 'events/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'speed_events', value => 'speed_events', template => '%s', + unit => 'events/s', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -81,8 +81,8 @@ sub set_counters { key_values => [ { name => 'queued_events' }, { name => 'display' } ], output_template => 'Queued Events: %s', perfdatas => [ - { label => 'queued_events', value => 'queued_events_absolute', template => '%s', - unit => 'events', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'queued_events', value => 'queued_events', template => '%s', + unit => 'events', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -90,8 +90,8 @@ sub set_counters { key_values => [ { name => 'unacknowledged_events' }, { name => 'display' } ], output_template => 'Unacknowledged Events: %s', perfdatas => [ - { label => 'unacknowledged_events', value => 'unacknowledged_events_absolute', template => '%s', - unit => 'events', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'unacknowledged_events', value => 'unacknowledged_events', template => '%s', + unit => 'events', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/apps/centreon/local/mode/centenginestats.pm b/apps/centreon/local/mode/centenginestats.pm index 644b9457a..73cc83791 100644 --- a/apps/centreon/local/mode/centenginestats.pm +++ b/apps/centreon/local/mode/centenginestats.pm @@ -31,9 +31,9 @@ sub custom_hosts_execution_time_output { return sprintf( 'hosts active execution time (avg/min/max): %.3f/%.3f/%.3f sec', - $self->{result_values}->{avg_absolute}, - $self->{result_values}->{min_absolute}, - $self->{result_values}->{max_absolute} + $self->{result_values}->{avg}, + $self->{result_values}->{min}, + $self->{result_values}->{max} ); } @@ -42,9 +42,9 @@ sub custom_services_execution_time_output { return sprintf( 'services active execution time (avg/min/max): %.3f/%.3f/%.3f sec', - $self->{result_values}->{avg_absolute}, - $self->{result_values}->{min_absolute}, - $self->{result_values}->{max_absolute} + $self->{result_values}->{avg}, + $self->{result_values}->{min}, + $self->{result_values}->{max} ); } @@ -53,10 +53,10 @@ sub custom_hosts_checked_output { return sprintf( 'hosts active checked last 1/5/15/60 min: %d/%d/%d/%d', - $self->{result_values}->{last1min_absolute}, - $self->{result_values}->{last5min_absolute}, - $self->{result_values}->{last15min_absolute}, - $self->{result_values}->{last60min_absolute}, + $self->{result_values}->{last1min}, + $self->{result_values}->{last5min}, + $self->{result_values}->{last15min}, + $self->{result_values}->{last60min}, ); } @@ -65,10 +65,10 @@ sub custom_services_checked_output { return sprintf( 'services active checked last 1/5/15/60 min: %d/%d/%d/%d', - $self->{result_values}->{last1min_absolute}, - $self->{result_values}->{last5min_absolute}, - $self->{result_values}->{last15min_absolute}, - $self->{result_values}->{last60min_absolute}, + $self->{result_values}->{last1min}, + $self->{result_values}->{last5min}, + $self->{result_values}->{last15min}, + $self->{result_values}->{last60min}, ); } @@ -77,9 +77,9 @@ sub custom_hosts_latency_output { return sprintf( 'hosts active latency (avg/min/max): %.3f/%.3f/%.3f sec', - $self->{result_values}->{avg_absolute}, - $self->{result_values}->{min_absolute}, - $self->{result_values}->{max_absolute} + $self->{result_values}->{avg}, + $self->{result_values}->{min}, + $self->{result_values}->{max} ); } @@ -88,9 +88,9 @@ sub custom_services_latency_output { return sprintf( 'services active latency (avg/min/max): %.3f/%.3f/%.3f sec', - $self->{result_values}->{avg_absolute}, - $self->{result_values}->{min_absolute}, - $self->{result_values}->{max_absolute} + $self->{result_values}->{avg}, + $self->{result_values}->{min}, + $self->{result_values}->{max} ); } @@ -99,9 +99,9 @@ sub custom_hosts_status_output { return sprintf( 'hosts status up/down/unreach: %d/%d/%d', - $self->{result_values}->{up_absolute}, - $self->{result_values}->{down_absolute}, - $self->{result_values}->{unreach_absolute} + $self->{result_values}->{up}, + $self->{result_values}->{down}, + $self->{result_values}->{unreach} ); } @@ -110,10 +110,10 @@ sub custom_services_status_output { return sprintf( 'services status ok/warn/unk/crit: %d/%d/%d/%d', - $self->{result_values}->{ok_absolute}, - $self->{result_values}->{warn_absolute}, - $self->{result_values}->{unk_absolute}, - $self->{result_values}->{crit_absolute} + $self->{result_values}->{ok}, + $self->{result_values}->{warn}, + $self->{result_values}->{unk}, + $self->{result_values}->{crit} ); } @@ -122,8 +122,8 @@ sub custom_commands_buffer_output { return sprintf( 'commands buffer current/max: %d/%d', - $self->{result_values}->{current_absolute}, - $self->{result_values}->{max_absolute} + $self->{result_values}->{current}, + $self->{result_values}->{max} ); } @@ -159,10 +159,10 @@ sub set_counters { key_values => [ { name => 'avg' }, { name => 'max' }, { name => 'min' } ], - threshold_use => $_->[0] . '_absolute', + threshold_use => $_->[0] , closure_custom_output => $self->can('custom_' . $type . '_execution_time_output'), perfdatas => [ - { value => $_->[0] . '_absolute', template => '%.3f', min => 0, unit => 's' }, + { value => $_->[0] , template => '%.3f', min => 0, unit => 's' }, ], } } @@ -180,10 +180,10 @@ sub set_counters { key_values => [ { name => 'last1min' }, { name => 'last5min' }, { name => 'last15min' }, { name => 'last60min' } ], - threshold_use => $_->[0] . '_absolute', + threshold_use => $_->[0] , closure_custom_output => $self->can('custom_' . $type . '_checked_output'), perfdatas => [ - { value => $_->[0] . '_absolute', template => '%d', min => 0 }, + { value => $_->[0] , template => '%d', min => 0 }, ], } } @@ -201,10 +201,10 @@ sub set_counters { key_values => [ { name => 'avg' }, { name => 'max' }, { name => 'min' } ], - threshold_use => $_->[0] . '_absolute', + threshold_use => $_->[0] , closure_custom_output => $self->can('custom_' . $type . '_latency_output'), perfdatas => [ - { value => $_->[0] . '_absolute', template => '%.3f', min => 0, unit => 's' }, + { value => $_->[0] , template => '%.3f', min => 0, unit => 's' }, ], } } @@ -223,10 +223,10 @@ sub set_counters { key_values => [ { name => 'up' }, { name => 'down' }, { name => 'unreach' } ], - threshold_use => $_->[0] . '_absolute', + threshold_use => $_->[0] , closure_custom_output => $self->can('custom_hosts_status_output'), perfdatas => [ - { value => $_->[0] . '_absolute', template => '%s', min => 0, max => 'total_absolute' }, + { value => $_->[0] , template => '%s', min => 0, max => 'total' }, ], } } @@ -244,10 +244,10 @@ sub set_counters { key_values => [ { name => 'ok' }, { name => 'warn' }, { name => 'unk' }, { name => 'crit' }, { name => 'total' } ], - threshold_use => $_->[0] . '_absolute', + threshold_use => $_->[0] , closure_custom_output => $self->can('custom_services_status_output'), perfdatas => [ - { value => $_->[0] . '_absolute', template => '%s', min => 0, max => 'total_absolute' }, + { value => $_->[0] , template => '%s', min => 0, max => 'total' }, ], } } @@ -265,10 +265,10 @@ sub set_counters { key_values => [ { name => 'current' }, { name => 'max' }, { name => 'total' } ], - threshold_use => $_->[0] . '_absolute', + threshold_use => $_->[0] , closure_custom_output => $self->can('custom_commands_buffer_output'), perfdatas => [ - { value => $_->[0] . '_absolute', template => '%s', min => 0, max => 'total_absolute' }, + { value => $_->[0] , template => '%s', min => 0, max => 'total' }, ], } } diff --git a/apps/centreon/map/jmx/mode/brokerstats.pm b/apps/centreon/map/jmx/mode/brokerstats.pm index 5ac20646e..5e8281e41 100644 --- a/apps/centreon/map/jmx/mode/brokerstats.pm +++ b/apps/centreon/map/jmx/mode/brokerstats.pm @@ -58,29 +58,27 @@ sub set_counters { closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => \&catalog_status_threshold, + closure_custom_threshold_check => \&catalog_status_threshold } }, { label => 'received-packets-rate', set => { - key_values => [ { name => 'ReceivedPackets', diff => 1 } ], + key_values => [ { name => 'ReceivedPackets', per_second => 1 } ], output_template => 'Received Packets: %.2f/s', - per_second => 1, perfdatas => [ - { label => 'received_packets_rate', value => 'ReceivedPackets_per_second', template => '%.2f', - min => 0, unit => 'packets/s' }, - ], + { label => 'received_packets_rate', template => '%.2f', + min => 0, unit => 'packets/s' } + ] } }, { label => 'processed-packets-rate', set => { - key_values => [ { name => 'ProcessedPackets', diff => 1 } ], + key_values => [ { name => 'ProcessedPackets', per_second => 1 } ], output_template => 'Processed Packets: %.2f/s', - per_second => 1, perfdatas => [ - { label => 'processed_packets_rate', value => 'ProcessedPackets_per_second', template => '%.2f', + { label => 'processed_packets_rate', template => '%.2f', min => 0, unit => 'packets/s' }, - ], + ] } - }, + } ]; } @@ -89,12 +87,11 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-counters:s" => { name => 'filter_counters', default => '' }, - "warning-status:s" => { name => 'warning_status', default => '' }, - "critical-status:s" => { name => 'critical_status', default => '%{processed_packets} < %{received_packets}' }, - }); + $options{options}->add_options(arguments => { + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '%{processed_packets} < %{received_packets}' } + }); + return $self; } diff --git a/apps/centreon/map/jmx/mode/enginestats.pm b/apps/centreon/map/jmx/mode/enginestats.pm index 968a7ed08..8408cb6a8 100644 --- a/apps/centreon/map/jmx/mode/enginestats.pm +++ b/apps/centreon/map/jmx/mode/enginestats.pm @@ -37,37 +37,34 @@ sub set_counters { key_values => [ { name => 'DrilldownCandidatesQueue' } ], output_template => 'Drilldown Canditates Queue: %d', perfdatas => [ - { label => 'drilldown_candidates_queue', value => 'DrilldownCandidatesQueue_absolute', template => '%d', + { label => 'drilldown_candidates_queue', template => '%d', min => 0 }, ], } }, { label => 'cutback-computation-rate', set => { - key_values => [ { name => 'Cutbackcomputation', diff => 1 } ], + key_values => [ { name => 'Cutbackcomputation', per_second => 1 } ], output_template => 'Cutback Computation: %.2f/s', - per_second => 1, perfdatas => [ - { label => 'cutback_computation_rate', value => 'Cutbackcomputation_per_second', template => '%.2f', + { label => 'cutback_computation_rate', template => '%.2f', min => 0 }, ], } }, { label => 'minimal-computation-rate', set => { - key_values => [ { name => 'Minimalcomputation', diff => 1 } ], + key_values => [ { name => 'Minimalcomputation', per_second => 1 } ], output_template => 'Minimal Computation: %.2f/s', - per_second => 1, perfdatas => [ - { label => 'minimal_computation_rate', value => 'Minimalcomputation_per_second', template => '%.2f', + { label => 'minimal_computation_rate', template => '%.2f', min => 0 }, ], } }, { label => 'recursive-computation-rate', set => { - key_values => [ { name => 'Recursivecomputation', diff => 1 } ], + key_values => [ { name => 'Recursivecomputation', per_second => 1 } ], output_template => 'Recursive Computation: %.2f/s', - per_second => 1, perfdatas => [ - { label => 'recursive_computation_rate', value => 'Recursivecomputation_per_second', template => '%.2f', + { label => 'recursive_computation_rate', template => '%.2f', min => 0 }, ], } @@ -80,10 +77,9 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-counters:s" => { name => 'filter_counters', default => '' }, - }); + $options{options}->add_options(arguments => { + }); + return $self; } diff --git a/apps/centreon/map/jmx/mode/events.pm b/apps/centreon/map/jmx/mode/events.pm index 9dd3657d5..b293910b9 100644 --- a/apps/centreon/map/jmx/mode/events.pm +++ b/apps/centreon/map/jmx/mode/events.pm @@ -47,15 +47,14 @@ sub set_counters { $label =~ s/_/-/g; $output =~ s/_/ /g; my $entry = { label => $label . '-rate', set => { - key_values => [ { name => $counter, diff => 1 } ], - output_template => ucfirst($output) . ': %.2f/s', - per_second => 1, - perfdatas => [ - { label => $label_perf . '_rate', value => $counter . '_per_second', template => '%.2f', - min => 0, unit => '/s' }, - ], - } - }; + key_values => [ { name => $counter, per_second => 1 } ], + output_template => ucfirst($output) . ': %.2f/s', + perfdatas => [ + { label => $label_perf . '_rate', template => '%.2f', + min => 0, unit => '/s' } + ] + } + }; push @{$self->{maps_counters}->{global}}, $entry; } } @@ -65,10 +64,9 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-counters:s" => { name => 'filter_counters', default => '' }, - }); + $options{options}->add_options(arguments => { + }); + return $self; } diff --git a/apps/centreon/map/jmx/mode/openviews.pm b/apps/centreon/map/jmx/mode/openviews.pm index b6d6134be..69978a5eb 100644 --- a/apps/centreon/map/jmx/mode/openviews.pm +++ b/apps/centreon/map/jmx/mode/openviews.pm @@ -36,7 +36,7 @@ sub set_counters { key_values => [ { name => 'OpenContextCount' } ], output_template => 'Open Views: %d', perfdatas => [ - { label => 'open_views', value => 'OpenContextCount_absolute', template => '%d', + { label => 'open_views', value => 'OpenContextCount', template => '%d', min => 0, unit => 'views' }, ], } diff --git a/apps/centreon/map/jmx/mode/sessions.pm b/apps/centreon/map/jmx/mode/sessions.pm index 5595d0f2b..6560e7ae2 100644 --- a/apps/centreon/map/jmx/mode/sessions.pm +++ b/apps/centreon/map/jmx/mode/sessions.pm @@ -36,7 +36,7 @@ sub set_counters { key_values => [ { name => 'SessionCount' } ], output_template => 'Active Sessions: %d', perfdatas => [ - { label => 'active_sessions', value => 'SessionCount_absolute', template => '%d', + { label => 'active_sessions', value => 'SessionCount', template => '%d', min => 0, unit => 'sessions' }, ], } @@ -45,7 +45,7 @@ sub set_counters { key_values => [ { name => 'AverageEventQueueSize' } ], output_template => 'Average Event Queue Size: %d', perfdatas => [ - { label => 'queue_size', value => 'AverageEventQueueSize_absolute', template => '%d', + { label => 'queue_size', value => 'AverageEventQueueSize', template => '%d', min => 0 }, ], } diff --git a/apps/centreon/map/jmx/mode/syncstats.pm b/apps/centreon/map/jmx/mode/syncstats.pm index ff067b518..d43031366 100644 --- a/apps/centreon/map/jmx/mode/syncstats.pm +++ b/apps/centreon/map/jmx/mode/syncstats.pm @@ -43,7 +43,7 @@ sub set_counters { key_values => [ { name => 'count' } ], output_template => 'Count: %d', perfdatas => [ - { label => 'map.synchronization.centreon.count', value => 'count_absolute', template => '%d', + { label => 'map.synchronization.centreon.count', value => 'count', template => '%d', min => 0 }, ], } @@ -53,7 +53,7 @@ sub set_counters { key_values => [ { name => 'average' } ], output_template => 'Average Duration: %.2f ms', perfdatas => [ - { label => 'map.synchronization.centreon.duration.average.milliseconds', value => 'average_absolute', + { label => 'map.synchronization.centreon.duration.average.milliseconds', value => 'average', template => '%.2f', min => 0, unit => 'ms' }, ], } @@ -63,7 +63,7 @@ sub set_counters { key_values => [ { name => 'max' } ], output_template => 'Max Duration: %.2f ms', perfdatas => [ - { label => 'map.synchronization.centreon.duration.max.milliseconds', value => 'max_absolute', + { label => 'map.synchronization.centreon.duration.max.milliseconds', value => 'max', template => '%.2f', min => 0, unit => 'ms' }, ], } @@ -75,8 +75,8 @@ sub set_counters { key_values => [ { name => 'count' }, { name => 'name' } ], output_template => 'Count: %d', perfdatas => [ - { label => 'map.synchronization.acl.count', value => 'count_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'name_absolute' }, + { label => 'map.synchronization.acl.count', value => 'count', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'name' }, ], } }, @@ -85,8 +85,8 @@ sub set_counters { key_values => [ { name => 'average' }, { name => 'name' } ], output_template => 'Average Duration: %.2f ms', perfdatas => [ - { label => 'map.synchronization.acl.duration.average.milliseconds', value => 'average_absolute', - template => '%.2f', min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'name_absolute' }, + { label => 'map.synchronization.acl.duration.average.milliseconds', value => 'average', + template => '%.2f', min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'name' }, ], } }, @@ -95,8 +95,8 @@ sub set_counters { key_values => [ { name => 'max' }, { name => 'name' } ], output_template => 'Max Duration: %.2f ms', perfdatas => [ - { label => 'map.synchronization.acl.duration.max.milliseconds', value => 'max_absolute', - template => '%.2f', min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'name_absolute' }, + { label => 'map.synchronization.acl.duration.max.milliseconds', value => 'max', + template => '%.2f', min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'name' }, ], } }, @@ -107,8 +107,8 @@ sub set_counters { key_values => [ { name => 'count' }, { name => 'name' } ], output_template => 'Count: %d', perfdatas => [ - { label => 'map.synchronization.resource.count', value => 'count_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'name_absolute' }, + { label => 'map.synchronization.resource.count', value => 'count', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'name' }, ], } }, @@ -117,8 +117,8 @@ sub set_counters { key_values => [ { name => 'average' }, { name => 'name' } ], output_template => 'Average Duration: %.2f ms', perfdatas => [ - { label => 'map.synchronization.resource.duration.average.milliseconds', value => 'average_absolute', - template => '%.2f', min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'name_absolute' }, + { label => 'map.synchronization.resource.duration.average.milliseconds', value => 'average', + template => '%.2f', min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'name' }, ], } }, @@ -127,8 +127,8 @@ sub set_counters { key_values => [ { name => 'max' }, { name => 'name' } ], output_template => 'Max Duration: %.2f ms', perfdatas => [ - { label => 'map.synchronization.resource.duration.max.milliseconds', value => 'max_absolute', - template => '%.2f', min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'name_absolute' }, + { label => 'map.synchronization.resource.duration.max.milliseconds', value => 'max', + template => '%.2f', min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'name' }, ], } }, diff --git a/apps/centreon/restapi/mode/submitresult.pm b/apps/centreon/restapi/mode/submitresult.pm index 0aa2e0ddf..1360da61c 100644 --- a/apps/centreon/restapi/mode/submitresult.pm +++ b/apps/centreon/restapi/mode/submitresult.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => '202' } ], output_template => '202: %d', perfdatas => [ - { value => '202_absolute', template => '%d', min => 0 }, + { value => '202', template => '%d', min => 0 }, ], } }, @@ -45,7 +45,7 @@ sub set_counters { key_values => [ { name => '400' } ], output_template => '400: %d', perfdatas => [ - { value => '400_absolute', template => '%d', min => 0 }, + { value => '400', template => '%d', min => 0 }, ], } }, @@ -53,7 +53,7 @@ sub set_counters { key_values => [ { name => '404' } ], output_template => '404: %d', perfdatas => [ - { value => '404_absolute', template => '%d', min => 0 }, + { value => '404', template => '%d', min => 0 }, ], } }, diff --git a/apps/centreon/sql/mode/countservices.pm b/apps/centreon/sql/mode/countservices.pm index 241d5f857..db037c81c 100644 --- a/apps/centreon/sql/mode/countservices.pm +++ b/apps/centreon/sql/mode/countservices.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'hosts' }, { name => 'display' } ], output_template => 'Number of hosts : %s', perfdatas => [ - { label => 'total_hosts', value => 'hosts_absolute', template => '%s', + { label => 'total_hosts', value => 'hosts', template => '%s', min => 0, label_extra_instance => 1 }, ], } @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'services' }, { name => 'display' } ], output_template => 'Number of services : %s', perfdatas => [ - { label => 'total_services', value => 'services_absolute', template => '%s', + { label => 'total_services', value => 'services', template => '%s', min => 0, label_extra_instance => 1 }, ], } diff --git a/apps/centreon/sql/mode/dsmqueue.pm b/apps/centreon/sql/mode/dsmqueue.pm index 73b0553ed..473733d31 100644 --- a/apps/centreon/sql/mode/dsmqueue.pm +++ b/apps/centreon/sql/mode/dsmqueue.pm @@ -38,7 +38,7 @@ sub set_counters { key_values => [ { name => 'total_queue_cache' } ], output_template => 'Total current cache queue : %s', perfdatas => [ - { label => 'total_queue_cache', value => 'total_queue_cache_absolute', template => '%s', min => 0 }, + { label => 'total_queue_cache', value => 'total_queue_cache', template => '%s', min => 0 }, ], } }, @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'total_queue_lock' } ], output_template => 'Total current lock queue : %s', perfdatas => [ - { label => 'total_queue_lock', value => 'total_queue_lock_absolute', template => '%s', min => 0 }, + { label => 'total_queue_lock', value => 'total_queue_lock', template => '%s', min => 0 }, ], } }, @@ -56,7 +56,7 @@ sub set_counters { key_values => [ { name => 'num' }, { name => 'display' } ], output_template => 'current cache queue : %s', perfdatas => [ - { label => 'host_queue_cache', value => 'num_absolute', template => '%s', + { label => 'host_queue_cache', value => 'num', template => '%s', min => 0, label_extra_instance => 1 }, ], } diff --git a/apps/centreon/sql/mode/pollerdelay.pm b/apps/centreon/sql/mode/pollerdelay.pm index 8d90ddff9..ce30e22b9 100644 --- a/apps/centreon/sql/mode/pollerdelay.pm +++ b/apps/centreon/sql/mode/pollerdelay.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'delay' }, { name => 'display' } ], output_template => 'delay for last update is %d seconds', perfdatas => [ - { label => 'delay', value => 'delay_absolute', template => '%s', + { label => 'delay', value => 'delay', template => '%s', unit => 's', label_extra_instance => 1 }, ], } diff --git a/apps/cisco/cms/restapi/mode/calls.pm b/apps/cisco/cms/restapi/mode/calls.pm index c2b3e6901..406f0735d 100644 --- a/apps/cisco/cms/restapi/mode/calls.pm +++ b/apps/cisco/cms/restapi/mode/calls.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'calls' } ], output_template => 'Active calls: %d', perfdatas => [ - { label => 'active_calls', value => 'calls_absolute', template => '%d', + { label => 'active_calls', value => 'calls', template => '%d', min => 0, unit => 'calls' }, ], } @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'numParticipantsLocal' } ], output_template => 'Local participants: %d', perfdatas => [ - { label => 'local_participants', value => 'numParticipantsLocal_absolute', template => '%d', + { label => 'local_participants', value => 'numParticipantsLocal', template => '%d', min => 0, unit => 'participants' }, ], } @@ -55,7 +55,7 @@ sub set_counters { key_values => [ { name => 'numParticipantsRemote' } ], output_template => 'Remote participants: %d', perfdatas => [ - { label => 'remote_participants', value => 'numParticipantsRemote_absolute', template => '%d', + { label => 'remote_participants', value => 'numParticipantsRemote', template => '%d', min => 0, unit => 'participants' }, ], } @@ -64,7 +64,7 @@ sub set_counters { key_values => [ { name => 'numCallLegs' } ], output_template => 'Call legs: %d', perfdatas => [ - { label => 'call_legs', value => 'numCallLegs_absolute', template => '%d', + { label => 'call_legs', value => 'numCallLegs', template => '%d', min => 0, unit => 'legs' }, ], } diff --git a/apps/cisco/cms/restapi/mode/systemstatus.pm b/apps/cisco/cms/restapi/mode/systemstatus.pm index cf2f0bb84..980f476a8 100644 --- a/apps/cisco/cms/restapi/mode/systemstatus.pm +++ b/apps/cisco/cms/restapi/mode/systemstatus.pm @@ -66,7 +66,7 @@ sub set_counters { key_values => [ { name => 'callLegsActive' } ], output_template => 'Active: %d', perfdatas => [ - { label => 'active_legs', value => 'callLegsActive_absolute', template => '%d', + { label => 'active_legs', value => 'callLegsActive', template => '%d', min => 0, unit => 'legs' }, ], } @@ -75,7 +75,7 @@ sub set_counters { key_values => [ { name => 'callLegsCompleted' } ], output_template => 'Completed: %d', perfdatas => [ - { label => 'completed_legs', value => 'callLegsCompleted_absolute', template => '%d', + { label => 'completed_legs', value => 'callLegsCompleted', template => '%d', min => 0, unit => 'legs' }, ], } @@ -87,7 +87,7 @@ sub set_counters { output_template => 'outgoing audio streams: %s %s/s', output_change_bytes => 2, perfdatas => [ - { label => 'audio_outgoing_rate', value => 'audioBitRateOutgoing_absolute', template => '%d', + { label => 'audio_outgoing_rate', value => 'audioBitRateOutgoing', template => '%d', min => 0, unit => 'b/s' }, ], } @@ -97,7 +97,7 @@ sub set_counters { output_template => 'incoming audio streams: %s %s/s', output_change_bytes => 2, perfdatas => [ - { label => 'audio_incoming_rate', value => 'audioBitRateIncoming_absolute', template => '%d', + { label => 'audio_incoming_rate', value => 'audioBitRateIncoming', template => '%d', min => 0, unit => 'b/s' }, ], } @@ -107,7 +107,7 @@ sub set_counters { output_template => 'outgoing video streams: %s %s/s', output_change_bytes => 2, perfdatas => [ - { label => 'video_outgoing_rate', value => 'videoBitRateOutgoing_absolute', template => '%d', + { label => 'video_outgoing_rate', value => 'videoBitRateOutgoing', template => '%d', min => 0, unit => 'b/s' }, ], } @@ -117,7 +117,7 @@ sub set_counters { output_template => 'incoming video streams: %s %s/s', output_change_bytes => 2, perfdatas => [ - { label => 'video_incoming_rate', value => 'videoBitRateIncoming_absolute', template => '%d', + { label => 'video_incoming_rate', value => 'videoBitRateIncoming', template => '%d', min => 0, unit => 'b/s' }, ], } diff --git a/apps/cisco/ise/restapi/mode/session.pm b/apps/cisco/ise/restapi/mode/session.pm index 2e11c9622..1334706ed 100644 --- a/apps/cisco/ise/restapi/mode/session.pm +++ b/apps/cisco/ise/restapi/mode/session.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'active' } ], output_template => 'Active sessions: %d', perfdatas => [ - { label => 'active_sessions', value => 'active_absolute', template => '%d', + { label => 'active_sessions', value => 'active', template => '%d', min => 0 }, ], } @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'postured' } ], output_template => 'Postured endpoints: %d', perfdatas => [ - { label => 'postured_endpoints', value => 'postured_absolute', template => '%d', + { label => 'postured_endpoints', value => 'postured', template => '%d', min => 0 }, ], } @@ -55,7 +55,7 @@ sub set_counters { key_values => [ { name => 'profiler' } ], output_template => 'Profiler service sessions: %d', perfdatas => [ - { label => 'profiler_service_sessions', value => 'profiler_absolute', template => '%d', + { label => 'profiler_service_sessions', value => 'profiler', template => '%d', min => 0 }, ], } diff --git a/apps/citrix/local/mode/license.pm b/apps/citrix/local/mode/license.pm index bc6f84d0c..3db8f64d8 100644 --- a/apps/citrix/local/mode/license.pm +++ b/apps/citrix/local/mode/license.pm @@ -30,11 +30,11 @@ sub custom_license_output { my ($self, %options) = @_; my $msg = sprintf("Licenses Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", - $self->{result_values}->{total_absolute}, - $self->{result_values}->{used_absolute}, - $self->{result_values}->{prct_used_absolute}, - $self->{result_values}->{free_absolute}, - $self->{result_values}->{prct_free_absolute} + $self->{result_values}->{total}, + $self->{result_values}->{used}, + $self->{result_values}->{prct_used}, + $self->{result_values}->{free}, + $self->{result_values}->{prct_free} ); return $msg; } @@ -51,7 +51,7 @@ sub set_counters { key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], closure_custom_output => $self->can('custom_license_output'), perfdatas => [ - { value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute' }, + { value => 'used', template => '%d', min => 0, max => 'total' }, ], } }, @@ -59,7 +59,7 @@ sub set_counters { key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], closure_custom_output => $self->can('custom_license_output'), perfdatas => [ - { value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute' }, + { value => 'free', template => '%d', min => 0, max => 'total' }, ], } }, @@ -67,7 +67,7 @@ sub set_counters { key_values => [ { name => 'prct_used' } ], output_template => 'Licenses Used : %.2f %%', perfdatas => [ - { value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, unit => '%' }, + { value => 'prct_used', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } }, diff --git a/apps/haproxy/snmp/mode/backendusage.pm b/apps/haproxy/snmp/mode/backendusage.pm index 8aabf6d51..470134b97 100644 --- a/apps/haproxy/snmp/mode/backendusage.pm +++ b/apps/haproxy/snmp/mode/backendusage.pm @@ -62,8 +62,8 @@ sub set_counters { key_values => [ { name => 'alBackendQueueCur' }, { name => 'display' } ], output_template => 'Current queue : %s', perfdatas => [ - { label => 'current_queue', value => 'alBackendQueueCur_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'current_queue', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -71,8 +71,8 @@ sub set_counters { key_values => [ { name => 'alBackendSessionCur' }, { name => 'display' } ], output_template => 'Current sessions : %s', perfdatas => [ - { label => 'current_sessions', value => 'alBackendSessionCur_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'current_sessions', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -80,28 +80,28 @@ sub set_counters { key_values => [ { name => 'alBackendSessionTotal', diff => 1 }, { name => 'display' } ], output_template => 'Total sessions : %s', perfdatas => [ - { label => 'total_connections', value => 'alBackendSessionTotal_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'total_connections', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'traffic-in', set => { - key_values => [ { name => 'alBackendBytesIN', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'alBackendBytesIN', per_second => 1 }, { name => 'display' } ], output_template => 'Traffic In : %s %s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_in', value => 'alBackendBytesIN_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_in', template => '%.2f', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'traffic-out', set => { - key_values => [ { name => 'alBackendBytesOUT', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'alBackendBytesOUT', per_second => 1 }, { name => 'display' } ], output_template => 'Traffic Out : %s %s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_out', value => 'alBackendBytesOUT_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_out', template => '%.2f', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -114,9 +114,9 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - 'filter-name:s' => { name => 'filter_name' }, - 'warning-status:s' => { name => 'warning_status', default => '' }, - 'critical-status:s' => { name => 'critical_status', default => '%{status} !~ /UP/i' }, + 'filter-name:s' => { name => 'filter_name' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '%{status} !~ /UP/i' } }); return $self; diff --git a/apps/haproxy/snmp/mode/frontendusage.pm b/apps/haproxy/snmp/mode/frontendusage.pm index a4d361b25..5412372ea 100644 --- a/apps/haproxy/snmp/mode/frontendusage.pm +++ b/apps/haproxy/snmp/mode/frontendusage.pm @@ -46,7 +46,7 @@ sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ - { name => 'frontend', type => 1, cb_prefix_output => 'prefix_frontend_output', message_multiple => 'All frontends are ok' }, + { name => 'frontend', type => 1, cb_prefix_output => 'prefix_frontend_output', message_multiple => 'All frontends are ok' } ]; $self->{maps_counters}->{frontend} = [ @@ -55,47 +55,47 @@ sub set_counters { closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => \&catalog_status_threshold, + closure_custom_threshold_check => \&catalog_status_threshold } }, { label => 'current-sessions', set => { key_values => [ { name => 'alFrontendSessionCur' }, { name => 'display' } ], output_template => 'Current sessions : %s', perfdatas => [ - { label => 'current_sessions', value => 'alFrontendSessionCur_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, - ], + { label => 'current_sessions', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' } + ] } }, { label => 'total-sessions', set => { key_values => [ { name => 'alFrontendSessionTotal', diff => 1 }, { name => 'display' } ], output_template => 'Total sessions : %s', perfdatas => [ - { label => 'total_connections', value => 'alFrontendSessionTotal_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, - ], + { label => 'total_connections', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' } + ] } }, { label => 'traffic-in', set => { - key_values => [ { name => 'alFrontendBytesIN', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'alFrontendBytesIN', per_second => 1 }, { name => 'display' } ], output_template => 'Traffic In : %s %s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_in', value => 'alFrontendBytesIN_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, - ], + { label => 'traffic_in', template => '%.2f', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' } + ] } }, { label => 'traffic-out', set => { - key_values => [ { name => 'alFrontendBytesOUT', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'alFrontendBytesOUT', per_second => 1 }, { name => 'display' } ], output_template => 'Traffic Out : %s %s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_out', value => 'alFrontendBytesOUT_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, - ], + { label => 'traffic_out', template => '%.2f', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, + ] } - }, + } ]; } @@ -105,9 +105,9 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - "filter-name:s" => { name => 'filter_name' }, - "warning-status:s" => { name => 'warning_status', default => '' }, - "critical-status:s" => { name => 'critical_status', default => '%{status} !~ /OPEN/i' }, + 'filter-name:s' => { name => 'filter_name' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '%{status} !~ /OPEN/i' } }); return $self; diff --git a/apps/hddtemp/mode/temperatures.pm b/apps/hddtemp/mode/temperatures.pm index 61f2e2d77..88adfceb7 100644 --- a/apps/hddtemp/mode/temperatures.pm +++ b/apps/hddtemp/mode/temperatures.pm @@ -39,8 +39,8 @@ sub custom_temperature_output { my ($self, %options) = @_; return sprintf('temperature: %s %s', - $self->{result_values}->{temperature_absolute}, - $self->{result_values}->{temperature_unit_absolute} + $self->{result_values}->{temperature}, + $self->{result_values}->{temperature_unit} ); } @@ -48,10 +48,10 @@ sub custom_temperature_perfdata { my ($self, %options) = @_; $self->{output}->perfdata_add( - nlabel => 'drive.temperature.' . ($self->{result_values}->{temperature_unit_absolute} eq 'C' ? 'celsius' : 'fahrenheit'), - instances => $self->{result_values}->{display_absolute}, - unit => $self->{result_values}->{temperature_unit_absolute}, - value => $self->{result_values}->{temperature_absolute}, + nlabel => 'drive.temperature.' . ($self->{result_values}->{temperature_unit} eq 'C' ? 'celsius' : 'fahrenheit'), + instances => $self->{result_values}->{display}, + unit => $self->{result_values}->{temperature_unit}, + value => $self->{result_values}->{temperature}, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}), ); diff --git a/apps/hyperv/2012/local/mode/nodesnapshot.pm b/apps/hyperv/2012/local/mode/nodesnapshot.pm index bb55bcdc7..0ddde6896 100644 --- a/apps/hyperv/2012/local/mode/nodesnapshot.pm +++ b/apps/hyperv/2012/local/mode/nodesnapshot.pm @@ -52,13 +52,13 @@ sub set_counters { sub custom_snapshot_output { my ($self, %options) = @_; - return "[status = " . $self->{result_values}->{status_absolute} . "] checkpoint started '" . centreon::plugins::misc::change_seconds(value => $self->{result_values}->{snapshot_absolute}) . "' ago"; + return "[status = " . $self->{result_values}->{status} . "] checkpoint started '" . centreon::plugins::misc::change_seconds(value => $self->{result_values}->{snapshot}) . "' ago"; } sub custom_backing_output { my ($self, %options) = @_; - return "[status = " . $self->{result_values}->{status_absolute} . "] backing started '" . centreon::plugins::misc::change_seconds(value => $self->{result_values}->{backing_absolute}) . "' ago"; + return "[status = " . $self->{result_values}->{status} . "] backing started '" . centreon::plugins::misc::change_seconds(value => $self->{result_values}->{backing}) . "' ago"; } sub prefix_vm_output { diff --git a/apps/hyperv/2012/local/mode/scvmmsnapshot.pm b/apps/hyperv/2012/local/mode/scvmmsnapshot.pm index eee3c8e57..cd575a184 100644 --- a/apps/hyperv/2012/local/mode/scvmmsnapshot.pm +++ b/apps/hyperv/2012/local/mode/scvmmsnapshot.pm @@ -46,7 +46,7 @@ sub set_counters { sub custom_vm_output { my ($self, %options) = @_; - return 'checkpoint started since : ' . centreon::plugins::misc::change_seconds(value => $self->{result_values}->{snapshot_absolute}); + return 'checkpoint started since : ' . centreon::plugins::misc::change_seconds(value => $self->{result_values}->{snapshot}); } sub prefix_vm_output { diff --git a/apps/inin/ig/snmp/mode/spanusage.pm b/apps/inin/ig/snmp/mode/spanusage.pm index 6dadbe115..c0d107650 100644 --- a/apps/inin/ig/snmp/mode/spanusage.pm +++ b/apps/inin/ig/snmp/mode/spanusage.pm @@ -61,8 +61,8 @@ sub set_counters { key_values => [ { name => 'i3IgSpanInfoActiveChannels' }, { name => 'display' } ], output_template => 'Current Active Channels : %s', perfdatas => [ - { label => 'active_channels', value => 'i3IgSpanInfoActiveChannels_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'active_channels', value => 'i3IgSpanInfoActiveChannels', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/apps/inin/ig/snmp/mode/stats.pm b/apps/inin/ig/snmp/mode/stats.pm index 4d7d05d1b..ef8df8cc4 100644 --- a/apps/inin/ig/snmp/mode/stats.pm +++ b/apps/inin/ig/snmp/mode/stats.pm @@ -38,7 +38,7 @@ sub set_counters { key_values => [ { name => 'SipActiveCallsCount' } ], output_template => 'SIP Current Active Calls : %s', perfdatas => [ - { label => 'sip_active_calls', value => 'SipActiveCallsCount_absolute', template => '%d', + { label => 'sip_active_calls', value => 'SipActiveCallsCount', template => '%d', min => 0 }, ], } @@ -47,7 +47,7 @@ sub set_counters { key_values => [ { name => 'TdmActiveCallsCount' } ], output_template => 'TDM Current Active Calls : %s', perfdatas => [ - { label => 'tdm_active_calls', value => 'TdmActiveCallsCount_absolute', template => '%d', + { label => 'tdm_active_calls', value => 'TdmActiveCallsCount', template => '%d', min => 0 }, ], } @@ -58,8 +58,8 @@ sub set_counters { key_values => [ { name => 'i3IgChannelGroupActiveCallsCount' }, { name => 'display' } ], output_template => 'Current Active Calls : %s', perfdatas => [ - { label => 'channel_group_active_calls', value => 'i3IgChannelGroupActiveCallsCount_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'channel_group_active_calls', value => 'i3IgChannelGroupActiveCallsCount', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/apps/inin/mediaserver/snmp/mode/audioengineusage.pm b/apps/inin/mediaserver/snmp/mode/audioengineusage.pm index d03755f46..2a1d209a9 100644 --- a/apps/inin/mediaserver/snmp/mode/audioengineusage.pm +++ b/apps/inin/mediaserver/snmp/mode/audioengineusage.pm @@ -37,8 +37,8 @@ sub set_counters { key_values => [ { name => 'i3MsAudioEngineAverageLoad' }, { name => 'display' } ], output_template => 'Average Load : %s', perfdatas => [ - { label => 'load_avg', value => 'i3MsAudioEngineAverageLoad_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'load_avg', value => 'i3MsAudioEngineAverageLoad', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -46,8 +46,8 @@ sub set_counters { key_values => [ { name => 'i3MsAudioEngineElementCount' }, { name => 'display' } ], output_template => 'Total active graph elements : %s', perfdatas => [ - { label => 'elem_count', value => 'i3MsAudioEngineElementCount_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'elem_count', value => 'i3MsAudioEngineElementCount', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/apps/inin/mediaserver/snmp/mode/cmdsrvusage.pm b/apps/inin/mediaserver/snmp/mode/cmdsrvusage.pm index 78b465fb1..d11d97198 100644 --- a/apps/inin/mediaserver/snmp/mode/cmdsrvusage.pm +++ b/apps/inin/mediaserver/snmp/mode/cmdsrvusage.pm @@ -136,8 +136,8 @@ sub set_counters { key_values => [ { name => 'i3MsCmdSrvResourceCount' }, { name => 'display' } ], output_template => 'Resource Count : %s', perfdatas => [ - { label => 'resource_count', value => 'i3MsCmdSrvResourceCount_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'resource_count', value => 'i3MsCmdSrvResourceCount', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/apps/inin/mediaserver/snmp/mode/memoryusage.pm b/apps/inin/mediaserver/snmp/mode/memoryusage.pm index d127f9758..9c6f87c6b 100644 --- a/apps/inin/mediaserver/snmp/mode/memoryusage.pm +++ b/apps/inin/mediaserver/snmp/mode/memoryusage.pm @@ -38,7 +38,7 @@ sub set_counters { output_template => 'Memory Used : %s %s', output_change_bytes => 1, perfdatas => [ - { label => 'used', value => 'used_absolute', template => '%s', + { label => 'used', value => 'used', template => '%s', unit => 'B', min => 0 }, ], } diff --git a/apps/java/hibernate/jmx/mode/stats.pm b/apps/java/hibernate/jmx/mode/stats.pm index 5f2089d49..3b28a8886 100644 --- a/apps/java/hibernate/jmx/mode/stats.pm +++ b/apps/java/hibernate/jmx/mode/stats.pm @@ -39,8 +39,8 @@ sub set_counters { key_values => [ { name => 'connect', diff => 1 }, { name => 'display' } ], output_template => 'Connect Count : %s', perfdatas => [ - { label => 'connect_count', value => 'connect_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'connect_count', value => 'connect', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -48,8 +48,8 @@ sub set_counters { key_values => [ { name => 'close', diff => 1 }, { name => 'display' } ], output_template => 'Close Count : %s', perfdatas => [ - { label => 'close_count', value => 'close_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'close_count', value => 'close', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -57,8 +57,8 @@ sub set_counters { key_values => [ { name => 'query', diff => 1 }, { name => 'display' } ], output_template => 'Query Count : %s', perfdatas => [ - { label => 'query_count', value => 'query_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'query_count', value => 'query', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -66,8 +66,8 @@ sub set_counters { key_values => [ { name => 'insert', diff => 1 }, { name => 'display' } ], output_template => 'Insert Count : %s', perfdatas => [ - { label => 'insert_count', value => 'insert_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'insert_count', value => 'insert', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -75,8 +75,8 @@ sub set_counters { key_values => [ { name => 'update', diff => 1 }, { name => 'display' } ], output_template => 'Update Count : %s', perfdatas => [ - { label => 'update_count', value => 'update_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'update_count', value => 'update', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/apps/java/jboss/jmx/mode/datasourceusage.pm b/apps/java/jboss/jmx/mode/datasourceusage.pm index b143da831..5ff352517 100644 --- a/apps/java/jboss/jmx/mode/datasourceusage.pm +++ b/apps/java/jboss/jmx/mode/datasourceusage.pm @@ -38,8 +38,8 @@ sub set_counters { key_values => [ { name => 'ActiveCount' }, { name => 'display' } ], output_template => 'Current Active Connections : %s', perfdatas => [ - { label => 'active_con', value => 'ActiveCount_absolute', template => '%s', min => 0, - label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'active_con', value => 'ActiveCount', template => '%s', min => 0, + label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -47,8 +47,8 @@ sub set_counters { key_values => [ { name => 'AvailableCount' }, { name => 'display' } ], output_template => 'Current Available Connections : %s', perfdatas => [ - { label => 'available_con', value => 'AvailableCount_absolute', template => '%s', min => 0, - label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'available_con', value => 'AvailableCount', template => '%s', min => 0, + label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -56,8 +56,8 @@ sub set_counters { key_values => [ { name => 'InUseCount' }, { name => 'display' } ], output_template => 'Current In Use Connections : %s', perfdatas => [ - { label => 'in_use_con', value => 'InUseCount_absolute', template => '%s', min => 0, - label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'in_use_con', value => 'InUseCount', template => '%s', min => 0, + label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -65,8 +65,8 @@ sub set_counters { key_values => [ { name => 'CreatedCount', diff => 1 }, { name => 'display' } ], output_template => 'Created Connections : %s', perfdatas => [ - { label => 'created_con', value => 'CreatedCount_absolute', template => '%s', min => 0, - label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'created_con', value => 'CreatedCount', template => '%s', min => 0, + label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/apps/java/kafka/jmx/mode/globalstats.pm b/apps/java/kafka/jmx/mode/globalstats.pm index ab7f7ce28..36d76430f 100644 --- a/apps/java/kafka/jmx/mode/globalstats.pm +++ b/apps/java/kafka/jmx/mode/globalstats.pm @@ -38,7 +38,7 @@ sub set_counters { key_values => [ { name => 'leader_count' } ], output_template => 'Leaders : %s', perfdatas => [ - { label => 'leader_count', value => 'leader_count_absolute', template => '%s', min => 0 }, + { label => 'leader_count', template => '%s', min => 0 }, ], } }, @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'active_controller_count' } ], output_template => 'Active Controllers : %s', perfdatas => [ - { label => 'active_controller_count', value => 'active_controller_count_absolute', template => '%s', min => 0 }, + { label => 'active_controller_count', template => '%s', min => 0 }, ], } }, @@ -54,7 +54,7 @@ sub set_counters { key_values => [ { name => 'partition_count' } ], output_template => 'Partitions : %s', perfdatas => [ - { label => 'partition_count', value => 'partition_count_absolute', template => '%s', min => 0 }, + { label => 'partition_count', template => '%s', min => 0 }, ], } }, @@ -62,7 +62,7 @@ sub set_counters { key_values => [ { name => 'offline_partitions_count' } ], output_template => 'Offline partitions : %s', perfdatas => [ - { label => 'offline_partitions_count', value => 'offline_partitions_count_absolute', template => '%s', + { label => 'offline_partitions_count', template => '%s', min => 0 }, ], } @@ -71,7 +71,7 @@ sub set_counters { key_values => [ { name => 'under_replicated_partitions' } ], output_template => 'Under replicated partitions : %s', perfdatas => [ - { label => 'under_replicated_partitions', value => 'under_replicated_partitions_absolute', template => '%s', + { label => 'under_replicated_partitions', template => '%s', min => 0 }, ], } @@ -80,26 +80,26 @@ sub set_counters { key_values => [ { name => 'unclean_leader_elections', diff => 1 } ], output_template => 'Number of unclean leader elections : %s', perfdatas => [ - { label => 'unclean_leader_elections', value => 'unclean_leader_elections_absolute', template => '%s', min => 0 }, + { label => 'unclean_leader_elections', template => '%s', min => 0 }, ], } }, { label => 'traffic-in', set => { - key_values => [ { name => 'traffic_in', diff => 1 } ], + key_values => [ { name => 'traffic_in', per_second => 1 } ], output_template => 'Traffic In : %s %s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_in', value => 'traffic_in_per_second', template => '%.2f', + { label => 'traffic_in', template => '%.2f', min => 0, unit => 'b/s' }, ], } }, { label => 'traffic-out', set => { - key_values => [ { name => 'traffic_out', diff => 1 } ], + key_values => [ { name => 'traffic_out', per_second => 1 } ], output_template => 'Traffic Out : %s %s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_out', value => 'traffic_out_per_second', template => '%.2f', + { label => 'traffic_out', template => '%.2f', min => 0, unit => 'b/s' }, ], } @@ -108,7 +108,7 @@ sub set_counters { key_values => [ { name => 'total_fetch_requests', diff => 1 } ], output_template => 'Number of total fetch requests : %s', perfdatas => [ - { label => 'total_fetch_requests', value => 'total_fetch_requests_absolute', template => '%s', min => 0 }, + { label => 'total_fetch_requests', template => '%s', min => 0 }, ], } }, @@ -119,11 +119,10 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; - - $options{options}->add_options(arguments => - { - }); - + + $options{options}->add_options(arguments => { + }); + return $self; } diff --git a/apps/java/solr/jmx/mode/cacheusage.pm b/apps/java/solr/jmx/mode/cacheusage.pm index 683fb3d1f..541421214 100644 --- a/apps/java/solr/jmx/mode/cacheusage.pm +++ b/apps/java/solr/jmx/mode/cacheusage.pm @@ -38,8 +38,8 @@ sub set_counters { key_values => [ { name => 'cumulative_evictions', diff => 1 }, { name => 'display' } ], output_template => 'Evictions Count : %s', perfdatas => [ - { label => 'evictions_count', value => 'cumulative_evictions_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'evictions_count', value => 'cumulative_evictions', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -47,8 +47,8 @@ sub set_counters { key_values => [ { name => 'cumulative_lookups', diff => 1 }, { name => 'display' } ], output_template => 'Lookups Count : %s', perfdatas => [ - { label => 'lookups_count', value => 'cumulative_lookups_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'lookups_count', value => 'cumulative_lookups', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -56,8 +56,8 @@ sub set_counters { key_values => [ { name => 'cumulative_inserts', diff => 1 }, { name => 'display' } ], output_template => 'Inserts Count : %s', perfdatas => [ - { label => 'inserts_count', value => 'cumulative_inserts_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'inserts_count', value => 'cumulative_inserts', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -65,8 +65,8 @@ sub set_counters { key_values => [ { name => 'cumulative_hits', diff => 1 }, { name => 'display' } ], output_template => 'Hits Count : %s', perfdatas => [ - { label => 'hits_count', value => 'cumulative_hits_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'hits_count', value => 'cumulative_hits', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/apps/java/solr/jmx/mode/requesthandlerusage.pm b/apps/java/solr/jmx/mode/requesthandlerusage.pm index 244f703de..0ac5d4cd5 100644 --- a/apps/java/solr/jmx/mode/requesthandlerusage.pm +++ b/apps/java/solr/jmx/mode/requesthandlerusage.pm @@ -38,8 +38,8 @@ sub set_counters { key_values => [ { name => '15minRateRequestsPerSecond' }, { name => 'display' } ], output_template => '15min Rate Requests : %.7f/s', perfdatas => [ - { label => '15min_rate_requests', value => '15minRateRequestsPerSecond_absolute', template => '%.7f', - min => 0, unit => '/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => '15min_rate_requests', value => '15minRateRequestsPerSecond', template => '%.7f', + min => 0, unit => '/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -47,8 +47,8 @@ sub set_counters { key_values => [ { name => 'avgRequestsPerSecond' }, { name => 'display' } ], output_template => 'Average Requests : %.7f/s', perfdatas => [ - { label => 'avg_requests', value => 'avgRequestsPerSecond_absolute', template => '%.7f', - min => 0, unit => '/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'avg_requests', value => 'avgRequestsPerSecond', template => '%.7f', + min => 0, unit => '/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -56,8 +56,8 @@ sub set_counters { key_values => [ { name => 'avgTimePerRequest' }, { name => 'display' } ], output_template => 'Average Time Per Request : %.3f ms', perfdatas => [ - { label => 'avg_time', value => 'avgTimePerRequest_absolute', template => '%.3f', - min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'avg_time', value => 'avgTimePerRequest', template => '%.3f', + min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -65,8 +65,8 @@ sub set_counters { key_values => [ { name => 'requests', diff => 1 }, { name => 'display' } ], output_template => 'Requests Count : %s', perfdatas => [ - { label => 'requests_count', value => 'requests_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'requests_count', value => 'requests', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/apps/java/weblogic/jmx/mode/workmanager.pm b/apps/java/weblogic/jmx/mode/workmanager.pm index c5f577331..a79238a87 100644 --- a/apps/java/weblogic/jmx/mode/workmanager.pm +++ b/apps/java/weblogic/jmx/mode/workmanager.pm @@ -60,8 +60,8 @@ sub set_counters { key_values => [ { name => 'completed', diff => 1 }, { name => 'display' } ], output_template => 'Requests completed : %s', perfdatas => [ - { label => 'request_completed', value => 'completed_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'request_completed', value => 'completed', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -69,8 +69,8 @@ sub set_counters { key_values => [ { name => 'pending' }, { name => 'display' } ], output_template => 'Requests pending : %s', perfdatas => [ - { label => 'request_pending', value => 'pending_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'request_pending', value => 'pending', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -78,8 +78,8 @@ sub set_counters { key_values => [ { name => 'stuck' }, { name => 'display' } ], output_template => 'Threads stuck : %s', perfdatas => [ - { label => 'thread_stuck', value => 'stuck_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'thread_stuck', value => 'stuck', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/apps/java/zookeeper/jmx/mode/stats.pm b/apps/java/zookeeper/jmx/mode/stats.pm index 72f2f8470..a19d512c5 100644 --- a/apps/java/zookeeper/jmx/mode/stats.pm +++ b/apps/java/zookeeper/jmx/mode/stats.pm @@ -38,7 +38,7 @@ sub set_counters { key_values => [ { name => 'AvgRequestLatency' } ], output_template => 'Avg Request Latency : %s ms', perfdatas => [ - { label => 'avg_request_latency', value => 'AvgRequestLatency_absolute', template => '%s', + { label => 'avg_request_latency', value => 'AvgRequestLatency', template => '%s', min => 0, unit => 'ms' }, ], } @@ -47,7 +47,7 @@ sub set_counters { key_values => [ { name => 'MaxRequestLatency' } ], output_template => 'Max Request Latency : %s ms', perfdatas => [ - { label => 'max_request_latency', value => 'MaxRequestLatency_absolute', template => '%s', + { label => 'max_request_latency', value => 'MaxRequestLatency', template => '%s', min => 0, unit => 'ms' }, ], } @@ -56,7 +56,7 @@ sub set_counters { key_values => [ { name => 'OutstandingRequests' } ], output_template => 'Outstanding Requests : %s', perfdatas => [ - { label => 'outstanding_requests', value => 'OutstandingRequests_absolute', template => '%s', + { label => 'outstanding_requests', value => 'OutstandingRequests', template => '%s', min => 0 }, ], } @@ -65,7 +65,7 @@ sub set_counters { key_values => [ { name => 'PacketsReceived', diff => 1 } ], output_template => 'Packets Received : %s', perfdatas => [ - { label => 'packets_received', value => 'PacketsReceived_absolute', template => '%s', + { label => 'packets_received', value => 'PacketsReceived', template => '%s', min => 0 }, ], } @@ -74,7 +74,7 @@ sub set_counters { key_values => [ { name => 'PacketsSent', diff => 1 } ], output_template => 'Packets Sent : %s', perfdatas => [ - { label => 'packets_sent', value => 'PacketsSent_absolute', template => '%s', + { label => 'packets_sent', value => 'PacketsSent', template => '%s', min => 0 }, ], } @@ -83,7 +83,7 @@ sub set_counters { key_values => [ { name => 'NumAliveConnections' } ], output_template => 'Num Alive Connections : %s', perfdatas => [ - { label => 'num_connections', value => 'NumAliveConnections_absolute', template => '%s', + { label => 'num_connections', value => 'NumAliveConnections', template => '%s', min => 0 }, ], } diff --git a/apps/kingdee/eas/mode/activeusers.pm b/apps/kingdee/eas/mode/activeusers.pm index fa8a4cc39..697587658 100644 --- a/apps/kingdee/eas/mode/activeusers.pm +++ b/apps/kingdee/eas/mode/activeusers.pm @@ -39,7 +39,7 @@ sub set_counters { key_values => [ { name => 'total' } ], output_template => 'total users active: %s', perfdatas => [ - { value => 'total_absolute', template => '%s', min => 0 }, + { value => 'total', template => '%s', min => 0 }, ], } } @@ -52,7 +52,7 @@ sub set_counters { key_values => [ { name => 'users_' . $_ } ], output_template => '%s (' . $_ . ')', perfdatas => [ - { value => 'users_' . $_ . '_absolute', template => '%s', min => 0 }, + { value => 'users_' . $_ , template => '%s', min => 0 }, ], } }; diff --git a/apps/kingdee/eas/mode/classloading.pm b/apps/kingdee/eas/mode/classloading.pm index e63671476..d8bfcb356 100644 --- a/apps/kingdee/eas/mode/classloading.pm +++ b/apps/kingdee/eas/mode/classloading.pm @@ -39,7 +39,7 @@ sub set_counters { key_values => [ { name => 'loadedclass' } ], output_template => 'class loaded: %s', perfdatas => [ - { value => 'loadedclass_absolute', template => '%s', min => 0 }, + { value => 'loadedclass', template => '%s', min => 0 }, ], } }, @@ -47,7 +47,7 @@ sub set_counters { key_values => [ { name => 'unloadedclass', diff => 1 } ], output_template => 'class unloaded: %s', perfdatas => [ - { value => 'unloadedclass_absolute', template => '%s', min => 0 }, + { value => 'unloadedclass', template => '%s', min => 0 }, ], } }, diff --git a/apps/kingdee/eas/mode/datasource.pm b/apps/kingdee/eas/mode/datasource.pm index 69dd3f0d8..9e2f51f25 100644 --- a/apps/kingdee/eas/mode/datasource.pm +++ b/apps/kingdee/eas/mode/datasource.pm @@ -39,7 +39,7 @@ sub set_counters { key_values => [ { name => 'init_pool_size' } ], output_template => 'pool initial size: %s', perfdatas => [ - { value => 'init_pool_size_absolute', template => '%s', min => 0, label_extra_instance => 1 }, + { value => 'init_pool_size', template => '%s', min => 0, label_extra_instance => 1 }, ], } }, @@ -47,7 +47,7 @@ sub set_counters { key_values => [ { name => 'max_pool_size' } ], output_template => 'pool max size: %s', perfdatas => [ - { value => 'max_pool_size_absolute', template => '%s', min => 0, label_extra_instance => 1 }, + { value => 'max_pool_size', template => '%s', min => 0, label_extra_instance => 1 }, ], } }, @@ -55,7 +55,7 @@ sub set_counters { key_values => [ { name => 'idle_timeout' } ], output_template => 'idle timeout: %s', perfdatas => [ - { value => 'idle_timeout_absolute', template => '%s', min => 0, label_extra_instance => 1 }, + { value => 'idle_timeout', template => '%s', min => 0, label_extra_instance => 1 }, ], } }, @@ -63,7 +63,7 @@ sub set_counters { key_values => [ { name => 'active_conn_count' } ], output_template => 'connections active: %s', perfdatas => [ - { value => 'active_conn_count_absolute', template => '%s', min => 0, label_extra_instance => 1 }, + { value => 'active_conn_count', template => '%s', min => 0, label_extra_instance => 1 }, ], } }, @@ -71,7 +71,7 @@ sub set_counters { key_values => [ { name => 'cur_conn_count' } ], output_template => 'connections current: %s', perfdatas => [ - { value => 'cur_conn_count_absolute', template => '%s', min => 0, label_extra_instance => 1 }, + { value => 'cur_conn_count', template => '%s', min => 0, label_extra_instance => 1 }, ], } }, @@ -79,7 +79,7 @@ sub set_counters { key_values => [ { name => 'max_conn_count' } ], output_template => 'connections max: %s', perfdatas => [ - { value => 'max_conn_count_absolute', template => '%s', min => 0, label_extra_instance => 1 }, + { value => 'max_conn_count', template => '%s', min => 0, label_extra_instance => 1 }, ], } }, @@ -87,7 +87,7 @@ sub set_counters { key_values => [ { name => 'create_count', diff => 1 } ], output_template => 'connections created: %s', perfdatas => [ - { value => 'create_count_absolute', template => '%s', min => 0, label_extra_instance => 1 }, + { value => 'create_count', template => '%s', min => 0, label_extra_instance => 1 }, ], } }, @@ -95,7 +95,7 @@ sub set_counters { key_values => [ { name => 'close_count', diff => 1 } ], output_template => 'connections closed: %s', perfdatas => [ - { value => 'close_count_absolute', template => '%s', min => 0, label_extra_instance => 1 }, + { value => 'close_count', template => '%s', min => 0, label_extra_instance => 1 }, ], } }, diff --git a/apps/kingdee/eas/mode/handlers.pm b/apps/kingdee/eas/mode/handlers.pm index bd28cbf10..103c2170d 100644 --- a/apps/kingdee/eas/mode/handlers.pm +++ b/apps/kingdee/eas/mode/handlers.pm @@ -39,7 +39,7 @@ sub set_counters { key_values => [ { name => 'maxthreads' } ], output_template => 'threads max: %s', perfdatas => [ - { value => 'maxthreads_absolute', template => '%s', min => 0, label_extra_instance => 1 }, + { value => 'maxthreads', template => '%s', min => 0, label_extra_instance => 1 }, ], } }, @@ -47,7 +47,7 @@ sub set_counters { key_values => [ { name => 'minsparethreads' } ], output_template => 'threads spare min: %s', perfdatas => [ - { value => 'minsparethreads_absolute', template => '%s', min => 0, label_extra_instance => 1 }, + { value => 'minsparethreads', template => '%s', min => 0, label_extra_instance => 1 }, ], } }, @@ -55,7 +55,7 @@ sub set_counters { key_values => [ { name => 'maxsparethreads' } ], output_template => 'threads spare max: %s', perfdatas => [ - { value => 'maxsparethreads_absolute', template => '%s', min => 0, label_extra_instance => 1 }, + { value => 'maxsparethreads', template => '%s', min => 0, label_extra_instance => 1 }, ], } }, @@ -63,7 +63,7 @@ sub set_counters { key_values => [ { name => 'maxqueuesize' } ], output_template => 'max queue size: %s', perfdatas => [ - { value => 'maxqueuesize_absolute', template => '%s', min => 0, label_extra_instance => 1 }, + { value => 'maxqueuesize', template => '%s', min => 0, label_extra_instance => 1 }, ], } }, @@ -71,7 +71,7 @@ sub set_counters { key_values => [ { name => 'idle_timeout' } ], output_template => 'idle timeout: %s', perfdatas => [ - { value => 'idle_timeout_absolute', template => '%s', min => 0, label_extra_instance => 1 }, + { value => 'idle_timeout', template => '%s', min => 0, label_extra_instance => 1 }, ], } }, @@ -79,7 +79,7 @@ sub set_counters { key_values => [ { name => 'processedcount', diff => 1 } ], output_template => 'threads processed: %s', perfdatas => [ - { value => 'processedcount_absolute', template => '%s', min => 0, label_extra_instance => 1 }, + { value => 'processedcount', template => '%s', min => 0, label_extra_instance => 1 }, ], } }, @@ -87,7 +87,7 @@ sub set_counters { key_values => [ { name => 'currentthreadcount' } ], output_template => 'threads current: %s', perfdatas => [ - { value => 'currentthreadcount_absolute', template => '%s', min => 0, label_extra_instance => 1 }, + { value => 'currentthreadcount', template => '%s', min => 0, label_extra_instance => 1 }, ], } }, @@ -95,7 +95,7 @@ sub set_counters { key_values => [ { name => 'currentthreadcount' } ], output_template => 'threads current: %s', perfdatas => [ - { value => 'currentthreadcount_absolute', template => '%s', min => 0, label_extra_instance => 1 }, + { value => 'currentthreadcount', template => '%s', min => 0, label_extra_instance => 1 }, ], } }, @@ -103,7 +103,7 @@ sub set_counters { key_values => [ { name => 'availablethreadcount' } ], output_template => 'threads available: %s', perfdatas => [ - { value => 'availablethreadcount_absolute', template => '%s', min => 0, label_extra_instance => 1 }, + { value => 'availablethreadcount', template => '%s', min => 0, label_extra_instance => 1 }, ], } }, @@ -111,7 +111,7 @@ sub set_counters { key_values => [ { name => 'busythreadcount' } ], output_template => 'threads busy: %s', perfdatas => [ - { value => 'busythreadcount_absolute', template => '%s', min => 0, label_extra_instance => 1 }, + { value => 'busythreadcount', template => '%s', min => 0, label_extra_instance => 1 }, ], } }, @@ -119,7 +119,7 @@ sub set_counters { key_values => [ { name => 'maxavailablethreadcount' } ], output_template => 'threads available max: %s', perfdatas => [ - { value => 'maxavailablethreadcount_absolute', template => '%s', min => 0, label_extra_instance => 1 }, + { value => 'maxavailablethreadcount', template => '%s', min => 0, label_extra_instance => 1 }, ], } }, @@ -127,7 +127,7 @@ sub set_counters { key_values => [ { name => 'maxbusythreadcount' } ], output_template => 'threads busy max: %s', perfdatas => [ - { value => 'maxbusythreadcount_absolute', template => '%s', min => 0, label_extra_instance => 1 }, + { value => 'maxbusythreadcount', template => '%s', min => 0, label_extra_instance => 1 }, ], } }, @@ -135,7 +135,7 @@ sub set_counters { key_values => [ { name => 'maxprocessedtime' } ], output_template => 'threads processed time max: %s ms', perfdatas => [ - { value => 'maxprocessedtime_absolute', template => '%s', min => 0, unit => 'ms', label_extra_instance => 1 }, + { value => 'maxprocessedtime', template => '%s', min => 0, unit => 'ms', label_extra_instance => 1 }, ], } }, @@ -143,7 +143,7 @@ sub set_counters { key_values => [ { name => 'createcount' } ], output_template => 'threads created: %s', perfdatas => [ - { value => 'createcount_absolute', template => '%s', min => 0, label_extra_instance => 1 }, + { value => 'createcount', template => '%s', min => 0, label_extra_instance => 1 }, ], } }, @@ -151,7 +151,7 @@ sub set_counters { key_values => [ { name => 'destroycount' } ], output_template => 'threads destroyed: %s', perfdatas => [ - { value => 'destroycount_absolute', template => '%s', min => 0, label_extra_instance => 1 }, + { value => 'destroycount', template => '%s', min => 0, label_extra_instance => 1 }, ], } }, diff --git a/apps/kingdee/eas/mode/ibmjvmgc.pm b/apps/kingdee/eas/mode/ibmjvmgc.pm index c2a6bdc4e..e4ed125e9 100644 --- a/apps/kingdee/eas/mode/ibmjvmgc.pm +++ b/apps/kingdee/eas/mode/ibmjvmgc.pm @@ -38,7 +38,7 @@ sub set_counters { key_values => [ { name => 'collection_count', diff => 1 } ], output_template => 'gc collection count: %s', perfdatas => [ - { value => 'collection_count_absolute', template => '%s', min => 0 }, + { value => 'collection_count', template => '%s', min => 0 }, ], } }, @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'collection_time', diff => 1 } ], output_template => 'gc collection time: %s ms', perfdatas => [ - { value => 'collection_time_absolute', template => '%s', min => 0, unit => 'ms' }, + { value => 'collection_time', template => '%s', min => 0, unit => 'ms' }, ], } }, diff --git a/apps/kingdee/eas/mode/javaruntime.pm b/apps/kingdee/eas/mode/javaruntime.pm index 89d5f97af..d2153a8be 100644 --- a/apps/kingdee/eas/mode/javaruntime.pm +++ b/apps/kingdee/eas/mode/javaruntime.pm @@ -39,9 +39,9 @@ sub set_counters { { label => 'uptime', nlabel => 'java.uptime.milliseconds', set => { key_values => [ { name => 'uptime' }, { name => 'uptime_date' } ], output_template => 'java uptime: %s', - output_use => 'uptime_date_absolute', + output_use => 'uptime_date', perfdatas => [ - { value => 'uptime_absolute', template => '%s', + { value => 'uptime', template => '%s', unit => 'ms' }, ], } diff --git a/apps/kingdee/eas/mode/memory.pm b/apps/kingdee/eas/mode/memory.pm index bf88fec2e..cdd47c53d 100644 --- a/apps/kingdee/eas/mode/memory.pm +++ b/apps/kingdee/eas/mode/memory.pm @@ -42,7 +42,7 @@ sub set_counters { key_values => [ { name => $def->[0] } ], output_template => $def->[0] . ': %s', perfdatas => [ - { value => $def->[0] . '_absolute', template => '%s', min => 0 }, + { value => $def->[0] , template => '%s', min => 0 }, ], } }; diff --git a/apps/kingdee/eas/mode/oraclejvmgc.pm b/apps/kingdee/eas/mode/oraclejvmgc.pm index 5280ec003..89063553f 100644 --- a/apps/kingdee/eas/mode/oraclejvmgc.pm +++ b/apps/kingdee/eas/mode/oraclejvmgc.pm @@ -39,7 +39,7 @@ sub set_counters { key_values => [ { name => 'minor_gc_count', diff => 1 } ], output_template => 'minor count: %s', perfdatas => [ - { value => 'minor_gc_count_absolute', template => '%s', min => 0 }, + { value => 'minor_gc_count', template => '%s', min => 0 }, ], } }, @@ -47,7 +47,7 @@ sub set_counters { key_values => [ { name => 'minor_gc_time', diff => 1 } ], output_template => 'minor time: %s ms', perfdatas => [ - { value => 'minor_gc_time_absolute', template => '%s', min => 0, unit => 'ms' }, + { value => 'minor_gc_time', template => '%s', min => 0, unit => 'ms' }, ], } }, @@ -55,7 +55,7 @@ sub set_counters { key_values => [ { name => 'full_gc_count', diff => 1 } ], output_template => 'full count: %s', perfdatas => [ - { value => 'full_gc_count_absolute', template => '%s', min => 0 }, + { value => 'full_gc_count', template => '%s', min => 0 }, ], } }, @@ -63,7 +63,7 @@ sub set_counters { key_values => [ { name => 'full_gc_time', diff => 1 } ], output_template => 'full time: %s ms', perfdatas => [ - { value => 'full_gc_time_absolute', template => '%s', min => 0, unit => 'ms' }, + { value => 'full_gc_time', template => '%s', min => 0, unit => 'ms' }, ], } }, diff --git a/apps/kingdee/eas/mode/oracleksqltemptable.pm b/apps/kingdee/eas/mode/oracleksqltemptable.pm index 0411e646d..eb8c3fb4c 100644 --- a/apps/kingdee/eas/mode/oracleksqltemptable.pm +++ b/apps/kingdee/eas/mode/oracleksqltemptable.pm @@ -38,7 +38,7 @@ sub set_counters { key_values => [ { name => 'ksqltemp_count' } ], output_template => 'ksqltemp table: %s', perfdatas => [ - { value => 'ksqltemp_count_absolute', template => '%s', min => 0, label_extra_instance => 1 }, + { value => 'ksqltemp_count', template => '%s', min => 0, label_extra_instance => 1 }, ], } } diff --git a/apps/kingdee/eas/mode/oraclerecyclebin.pm b/apps/kingdee/eas/mode/oraclerecyclebin.pm index b8adcf29b..5b4e6108b 100644 --- a/apps/kingdee/eas/mode/oraclerecyclebin.pm +++ b/apps/kingdee/eas/mode/oraclerecyclebin.pm @@ -38,7 +38,7 @@ sub set_counters { key_values => [ { name => 'recyclebin_count' } ], output_template => 'recyclebin table: %s', perfdatas => [ - { value => 'recyclebin_count_absolute', template => '%s', min => 0, label_extra_instance => 1 }, + { value => 'recyclebin_count', template => '%s', min => 0, label_extra_instance => 1 }, ], } } diff --git a/apps/kingdee/eas/mode/oracleredolog.pm b/apps/kingdee/eas/mode/oracleredolog.pm index a5f37cdc6..019837ccb 100644 --- a/apps/kingdee/eas/mode/oracleredolog.pm +++ b/apps/kingdee/eas/mode/oracleredolog.pm @@ -38,7 +38,7 @@ sub set_counters { key_values => [ { name => 'inactive' } ], output_template => 'inactive: %s', perfdatas => [ - { value => 'inactive_absolute', template => '%s', min => 0, label_extra_instance => 1 }, + { value => 'inactive', template => '%s', min => 0, label_extra_instance => 1 }, ], } }, @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'active' } ], output_template => 'active: %s', perfdatas => [ - { value => 'active_absolute', template => '%s', min => 0, label_extra_instance => 1 }, + { value => 'active', template => '%s', min => 0, label_extra_instance => 1 }, ], } }, @@ -54,7 +54,7 @@ sub set_counters { key_values => [ { name => 'current' } ], output_template => 'current: %s', perfdatas => [ - { value => 'current_absolute', template => '%s', min => 0, label_extra_instance => 1 }, + { value => 'current', template => '%s', min => 0, label_extra_instance => 1 }, ], } }, diff --git a/apps/kingdee/eas/mode/oraclesession.pm b/apps/kingdee/eas/mode/oraclesession.pm index d85c28c9b..f115bf3fd 100644 --- a/apps/kingdee/eas/mode/oraclesession.pm +++ b/apps/kingdee/eas/mode/oraclesession.pm @@ -38,7 +38,7 @@ sub set_counters { key_values => [ { name => 'active' } ], output_template => 'sessions active: %s', perfdatas => [ - { value => 'active_absolute', template => '%s', min => 0, max => 'total_absolute', label_extra_instance => 1 }, + { value => 'active', template => '%s', min => 0, max => 'total', label_extra_instance => 1 }, ], } }, @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'inactive' } ], output_template => 'sessions inactive: %s', perfdatas => [ - { value => 'inactive_absolute', template => '%s', min => 0, max => 'total_absolute', label_extra_instance => 1 }, + { value => 'inactive', template => '%s', min => 0, max => 'total', label_extra_instance => 1 }, ], } }, @@ -62,7 +62,7 @@ sub set_counters { key_values => [ { name => $_ } ], output_template => 'wait class ' . $_ . ': %s', perfdatas => [ - { value => $_ . '_absolute', template => '%s', min => 0, label_extra_instance => 1 }, + { value => $_ , template => '%s', min => 0, label_extra_instance => 1 }, ], } }; diff --git a/apps/kingdee/eas/mode/oracletable.pm b/apps/kingdee/eas/mode/oracletable.pm index b2b96a6e6..64b70a07e 100644 --- a/apps/kingdee/eas/mode/oracletable.pm +++ b/apps/kingdee/eas/mode/oracletable.pm @@ -38,7 +38,7 @@ sub set_counters { key_values => [ { name => 'num_rows' } ], output_template => 'number of rows: %s', perfdatas => [ - { value => 'num_rows_absolute', template => '%s', min => 0, label_extra_instance => 1 }, + { value => 'num_rows', template => '%s', min => 0, label_extra_instance => 1 }, ], } }, @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'actual_num_rows' } ], output_template => 'number of actual rows: %s', perfdatas => [ - { value => 'actual_num_rows_absolute', template => '%s', min => 0, label_extra_instance => 1 }, + { value => 'actual_num_rows', template => '%s', min => 0, label_extra_instance => 1 }, ], } } diff --git a/apps/kingdee/eas/mode/ormrpc.pm b/apps/kingdee/eas/mode/ormrpc.pm index e0d0c6396..724bd0446 100644 --- a/apps/kingdee/eas/mode/ormrpc.pm +++ b/apps/kingdee/eas/mode/ormrpc.pm @@ -39,7 +39,7 @@ sub set_counters { key_values => [ { name => 'active_thread_count' } ], output_template => 'threads active: %s', perfdatas => [ - { value => 'active_thread_count_absolute', template => '%s', min => 0 }, + { value => 'active_thread_count', template => '%s', min => 0 }, ], } }, @@ -47,7 +47,7 @@ sub set_counters { key_values => [ { name => 'stub_count' } ], output_template => 'stubs: %s', perfdatas => [ - { value => 'stub_count_absolute', template => '%s', min => 0 }, + { value => 'stub_count', template => '%s', min => 0 }, ], } }, @@ -55,7 +55,7 @@ sub set_counters { key_values => [ { name => 'proxy_count' } ], output_template => 'proxies: %s', perfdatas => [ - { value => 'proxy_count_absolute', template => '%s', min => 0 }, + { value => 'proxy_count', template => '%s', min => 0 }, ], } }, @@ -63,7 +63,7 @@ sub set_counters { key_values => [ { name => 'client_session_count' } ], output_template => 'sessions client: %s', perfdatas => [ - { value => 'client_session_count_absolute', template => '%s', min => 0 }, + { value => 'client_session_count', template => '%s', min => 0 }, ], } }, @@ -71,7 +71,7 @@ sub set_counters { key_values => [ { name => 'server_session_count' } ], output_template => 'sessions server: %s', perfdatas => [ - { value => 'server_session_count_absolute', template => '%s', min => 0 }, + { value => 'server_session_count', template => '%s', min => 0 }, ], } }, @@ -79,7 +79,7 @@ sub set_counters { key_values => [ { name => 'client_invoke_count_per_minute' } ], output_template => 'clients invoke: %s/m', perfdatas => [ - { value => 'client_invoke_count_per_minute_absolute', template => '%s', min => 0, unit => '/m' }, + { value => 'client_invoke_count_per_minute', template => '%s', min => 0, unit => '/m' }, ], } }, @@ -87,7 +87,7 @@ sub set_counters { key_values => [ { name => 'processed_service_count_per_minute' } ], output_template => 'processed service: %s/m', perfdatas => [ - { value => 'processed_service_count_per_minute_absolute', template => '%s', min => 0, unit => '/m' }, + { value => 'processed_service_count_per_minute', template => '%s', min => 0, unit => '/m' }, ], } }, @@ -95,7 +95,7 @@ sub set_counters { key_values => [ { name => 'client_invoke_count', diff => 1 } ], output_template => 'clients invoked: %s', perfdatas => [ - { value => 'client_invoke_count_absolute', template => '%s', min => 0 }, + { value => 'client_invoke_count', template => '%s', min => 0 }, ], } }, @@ -103,7 +103,7 @@ sub set_counters { key_values => [ { name => 'processed_service_count', diff => 1 } ], output_template => 'processed service: %s', perfdatas => [ - { value => 'processed_service_count_absolute', template => '%s', min => 0 }, + { value => 'processed_service_count', template => '%s', min => 0 }, ], } }, diff --git a/apps/kingdee/eas/mode/transaction.pm b/apps/kingdee/eas/mode/transaction.pm index ebe57c101..4239367a3 100644 --- a/apps/kingdee/eas/mode/transaction.pm +++ b/apps/kingdee/eas/mode/transaction.pm @@ -39,7 +39,7 @@ sub set_counters { key_values => [ { name => 'active_count' } ], output_template => 'active: %s', perfdatas => [ - { value => 'active_count_absolute', template => '%s', min => 0 }, + { value => 'active_count', template => '%s', min => 0 }, ], } }, @@ -47,7 +47,7 @@ sub set_counters { key_values => [ { name => 'timedout_count' } ], output_template => 'timed out: %s', perfdatas => [ - { value => 'timedout_count_absolute', template => '%s', min => 0 }, + { value => 'timedout_count', template => '%s', min => 0 }, ], } }, @@ -55,7 +55,7 @@ sub set_counters { key_values => [ { name => 'committed_count', diff => 1 } ], output_template => 'committed: %s', perfdatas => [ - { value => 'committed_count_absolute', template => '%s', min => 0 }, + { value => 'committed_count', template => '%s', min => 0 }, ], } }, @@ -63,7 +63,7 @@ sub set_counters { key_values => [ { name => 'rolledback_count', diff => 1 } ], output_template => 'rolledback: %s', perfdatas => [ - { value => 'rolledback_count_absolute', template => '%s', min => 0 }, + { value => 'rolledback_count', template => '%s', min => 0 }, ], } }, @@ -71,7 +71,7 @@ sub set_counters { key_values => [ { name => 'transaction_count', diff => 1 } ], output_template => 'created: %s', perfdatas => [ - { value => 'transaction_count_absolute', template => '%s', min => 0 }, + { value => 'transaction_count', template => '%s', min => 0 }, ], } }, @@ -79,7 +79,7 @@ sub set_counters { key_values => [ { name => 'total_transaction_time', diff => 1 } ], output_template => 'total time: %s ms', perfdatas => [ - { value => 'total_transaction_time_absolute', template => '%s', min => 0, unit => 'ms' }, + { value => 'total_transaction_time', template => '%s', min => 0, unit => 'ms' }, ], } }, @@ -87,7 +87,7 @@ sub set_counters { key_values => [ { name => 'max_transaction_time', diff => 1 } ], output_template => 'max time: %s ms', perfdatas => [ - { value => 'max_transaction_time_absolute', template => '%s', min => 0, unit => 'ms' }, + { value => 'max_transaction_time', template => '%s', min => 0, unit => 'ms' }, ], } }, @@ -95,7 +95,7 @@ sub set_counters { key_values => [ { name => 'default_timeout' } ], output_template => 'default timeout: %s', perfdatas => [ - { value => 'default_timeout_absolute', template => '%s', min => 0 }, + { value => 'default_timeout', template => '%s', min => 0 }, ], } }, diff --git a/apps/lync/2013/mssql/mode/lyncusers.pm b/apps/lync/2013/mssql/mode/lyncusers.pm index 13c1c3eef..63f0ea6e0 100644 --- a/apps/lync/2013/mssql/mode/lyncusers.pm +++ b/apps/lync/2013/mssql/mode/lyncusers.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'total' } ], output_template => '%d Total users', perfdatas => [ - { label => 'total_users', value => 'total_absolute', template => '%d', + { label => 'total_users', value => 'total', template => '%d', unit => 'users', min => 0, label_extra_instance => 0 }, ], } @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'unique' } ], output_template => '%d Unique users', perfdatas => [ - { label => 'unique_users', value => 'unique_absolute', template => '%d', + { label => 'unique_users', value => 'unique', template => '%d', unit => 'users', min => 0, label_extra_instance => 0 }, ], } diff --git a/apps/monitoring/dynatrace/restapi/mode/problems.pm b/apps/monitoring/dynatrace/restapi/mode/problems.pm index de71f4f2d..ff275b0f6 100644 --- a/apps/monitoring/dynatrace/restapi/mode/problems.pm +++ b/apps/monitoring/dynatrace/restapi/mode/problems.pm @@ -55,7 +55,7 @@ sub set_counters { key_values => [ { name => 'problems_open' } ], output_template => 'number of open problems : %s', perfdatas => [ - { value => 'problems_open_absolute', template => '%s', value => 'problems_open_absolute', min => 0 }, + { value => 'problems_open', template => '%s', value => 'problems_open', min => 0 }, ], } }, diff --git a/apps/monitoring/mip/restapi/mode/scenarios.pm b/apps/monitoring/mip/restapi/mode/scenarios.pm index b0994a27b..d46bc0eb8 100644 --- a/apps/monitoring/mip/restapi/mode/scenarios.pm +++ b/apps/monitoring/mip/restapi/mode/scenarios.pm @@ -47,20 +47,20 @@ sub custom_metric_output { my ($self, %options) = @_; my $msg; - if (defined($mapping_units->{ $self->{result_values}->{unit_absolute} }->{scale})) { + if (defined($mapping_units->{ $self->{result_values}->{unit} }->{scale})) { $msg = sprintf( 'value: %s %s%s', $self->{perfdata}->change_bytes( - value => $self->{result_values}->{value_absolute}, - network => $mapping_units->{ $self->{result_values}->{unit_absolute} }->{network} + value => $self->{result_values}->{value}, + network => $mapping_units->{ $self->{result_values}->{unit} }->{network} ), - $mapping_units->{ $self->{result_values}->{unit_absolute} }->{extra_unit} + $mapping_units->{ $self->{result_values}->{unit} }->{extra_unit} ); } else { $msg = sprintf( 'value: %s %s', - $self->{result_values}->{value_absolute}, - $self->{result_values}->{unit_absolute} + $self->{result_values}->{value}, + $self->{result_values}->{unit} ); } return $msg; @@ -70,10 +70,10 @@ sub custom_metric_perfdata { my ($self, %options) = @_; $self->{output}->perfdata_add( - unit => $self->{result_values}->{unit_absolute}, - nlabel => 'scenario.metric.usage.' . $mapping_units->{ $self->{result_values}->{unit_absolute} }->{label}, + unit => $self->{result_values}->{unit}, + nlabel => 'scenario.metric.usage.' . $mapping_units->{ $self->{result_values}->{unit} }->{label}, instances => $self->{instance}, - value => $self->{result_values}->{value_absolute}, + value => $self->{result_values}->{value}, ); } diff --git a/apps/monitoring/quanta/restapi/mode/webscenariosavailability.pm b/apps/monitoring/quanta/restapi/mode/webscenariosavailability.pm index a64be278b..f2561b50a 100644 --- a/apps/monitoring/quanta/restapi/mode/webscenariosavailability.pm +++ b/apps/monitoring/quanta/restapi/mode/webscenariosavailability.pm @@ -37,8 +37,8 @@ sub set_counters { key_values => [ { name => 'response_time' }, { name => 'display' } ], output_template => 'Total Response Time: %.3fs', perfdatas => [ - { value => 'response_time_absolute', template => '%.3f', - min => 0, unit => 's', label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'response_time', template => '%.3f', + min => 0, unit => 's', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -46,8 +46,8 @@ sub set_counters { key_values => [ { name => 'availability' }, { name => 'display' } ], output_template => 'Availability: %.2f%%', perfdatas => [ - { value => 'availability_absolute', template => '%s', - min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'availability', template => '%s', + min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -55,8 +55,8 @@ sub set_counters { key_values => [ { name => 'avg_step_response_time' }, { name => 'display' } ], output_template => 'Step Average Response Time: %.3fs', perfdatas => [ - { value => 'avg_step_response_time_absolute', template => '%.3f', - min => 0, unit => 's', label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'avg_step_response_time', template => '%.3f', + min => 0, unit => 's', label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/apps/monitoring/scom/restapi/mode/alerts.pm b/apps/monitoring/scom/restapi/mode/alerts.pm index d7f697bec..20ed9f801 100644 --- a/apps/monitoring/scom/restapi/mode/alerts.pm +++ b/apps/monitoring/scom/restapi/mode/alerts.pm @@ -54,7 +54,7 @@ sub set_counters { key_values => [ { name => $_ } ], output_template => $_ . ': %s', perfdatas => [ - { value => $_ . '_absolute', template => '%s', min => 0 }, + { value => $_ , template => '%s', min => 0 }, ], } }; diff --git a/apps/mq/activemq/jmx/mode/brokers.pm b/apps/mq/activemq/jmx/mode/brokers.pm index 7072d4500..714209643 100644 --- a/apps/mq/activemq/jmx/mode/brokers.pm +++ b/apps/mq/activemq/jmx/mode/brokers.pm @@ -44,7 +44,7 @@ sub set_counters { key_values => [ { name => 'StorePercentUsage' }, { name => 'display' } ], output_template => 'store usage: %.2f %%', perfdatas => [ - { value => 'StorePercentUsage_absolute', template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1 } + { value => 'StorePercentUsage', template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1 } ] } }, @@ -52,7 +52,7 @@ sub set_counters { key_values => [ { name => 'TempPercentUsage' }, { name => 'display' } ], output_template => 'temporary usage: %.2f %%', perfdatas => [ - { value => 'TempPercentUsage_absolute', template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1 } + { value => 'TempPercentUsage', template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1 } ] } }, @@ -60,7 +60,7 @@ sub set_counters { key_values => [ { name => 'MemoryPercentUsage' }, { name => 'display' } ], output_template => 'memory usage: %.2f %%', perfdatas => [ - { value => 'MemoryPercentUsage_absolute', template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1 } + { value => 'MemoryPercentUsage', template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1 } ] } } @@ -72,7 +72,7 @@ sub set_counters { key_values => [ { name => 'AverageEnqueueTime' }, { name => 'display' } ], output_template => 'average time messages remained enqueued: %.3f ms', perfdatas => [ - { value => 'AverageEnqueueTime_absolute', + { value => 'AverageEnqueueTime', template => '%.3f', unit => 'ms', min => 0, label_extra_instance => 1 } ] } @@ -81,7 +81,7 @@ sub set_counters { key_values => [ { name => 'ConsumerCount' }, { name => 'display' } ], output_template => 'consumers connected: %s', perfdatas => [ - { value => 'ConsumerCount_absolute', + { value => 'ConsumerCount', template => '%s', min => 0, label_extra_instance => 1 } ] } @@ -90,7 +90,7 @@ sub set_counters { key_values => [ { name => 'ProducerCount' }, { name => 'display' } ], output_template => 'producers connected: %s', perfdatas => [ - { value => 'ProducerCount_absolute', + { value => 'ProducerCount', template => '%s', min => 0, label_extra_instance => 1 } ] } @@ -99,7 +99,7 @@ sub set_counters { key_values => [ { name => 'MemoryPercentUsage' }, { name => 'display' } ], output_template => 'memory usage: %.2f %%', perfdatas => [ - { value => 'MemoryPercentUsage_absolute', + { value => 'MemoryPercentUsage', template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1 } ] } @@ -108,7 +108,7 @@ sub set_counters { key_values => [ { name => 'QueueSize' }, { name => 'display' } ], output_template => 'queue size: %s', perfdatas => [ - { value => 'QueueSize_absolute', + { value => 'QueueSize', template => '%s', min => 0, label_extra_instance => 1 } ] } @@ -117,7 +117,7 @@ sub set_counters { key_values => [ { name => 'EnqueueCount', diff => 1 }, { name => 'display' } ], output_template => 'messages enqueued: %s', perfdatas => [ - { value => 'EnqueueCount_absolute', + { value => 'EnqueueCount', template => '%s', min => 0, label_extra_instance => 1 } ] } @@ -126,7 +126,7 @@ sub set_counters { key_values => [ { name => 'DequeueCount', diff => 1 }, { name => 'display' } ], output_template => 'messages dequeued: %s', perfdatas => [ - { value => 'DequeueCount_absolute', + { value => 'DequeueCount', template => '%s', min => 0, label_extra_instance => 1 } ] } @@ -135,7 +135,7 @@ sub set_counters { key_values => [ { name => 'ExpiredCount', diff => 1 }, { name => 'display' } ], output_template => 'messages expired: %s', perfdatas => [ - { value => 'ExpiredCount_absolute', + { value => 'ExpiredCount', template => '%s', min => 0, label_extra_instance => 1 } ] } @@ -144,7 +144,7 @@ sub set_counters { key_values => [ { name => 'InFlightCount', diff => 1 }, { name => 'display' } ], output_template => 'messages in-flighted: %s', perfdatas => [ - { value => 'InFlightCount_absolute', + { value => 'InFlightCount', template => '%s', min => 0, label_extra_instance => 1 } ] } @@ -154,7 +154,7 @@ sub set_counters { output_template => 'average messages size: %s %s', output_change_bytes => 1, perfdatas => [ - { value => 'AverageMessageSize_absolute', + { value => 'AverageMessageSize', template => '%s', unit => 'B', min => 0, label_extra_instance => 1 } ] } diff --git a/apps/mq/ibmmq/mqi/mode/channels.pm b/apps/mq/ibmmq/mqi/mode/channels.pm index a0b9c5ed6..9fbd788d3 100644 --- a/apps/mq/ibmmq/mqi/mode/channels.pm +++ b/apps/mq/ibmmq/mqi/mode/channels.pm @@ -42,8 +42,8 @@ sub custom_traffic_in_perfdata { $self->{output}->perfdata_add( nlabel => $self->{nlabel}, unit => 'b/s', - instances => [$self->{result_values}->{qmgr_name_absolute}, $self->{result_values}->{channel_name_absolute}], - value => $self->{result_values}->{traffic_in_per_second}, + instances => [$self->{result_values}->{qmgr_name}, $self->{result_values}->{channel_name}], + value => $self->{result_values}->{traffic_in}, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}), min => 0 @@ -55,8 +55,8 @@ sub custom_traffic_out_perfdata { $self->{output}->perfdata_add( nlabel => $self->{nlabel}, unit => 'b/s', - instances => [$self->{result_values}->{qmgr_name_absolute}, $self->{result_values}->{channel_name_absolute}], - value => $self->{result_values}->{traffic_out_per_second}, + instances => [$self->{result_values}->{qmgr_name}, $self->{result_values}->{channel_name}], + value => $self->{result_values}->{traffic_out}, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}), min => 0 @@ -89,16 +89,16 @@ sub set_counters { } }, { label => 'traffic-in', nlabel => 'channel.traffic.in.bitspersecond', set => { - key_values => [ { name => 'traffic_in', diff => 1 }, { name => 'qmgr_name' }, { name => 'channel_name' } ], + key_values => [ { name => 'traffic_in', per_second => 1 }, { name => 'qmgr_name' }, { name => 'channel_name' } ], output_template => 'traffic in: %s %s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, closure_custom_perfdata => $self->can('custom_traffic_in_perfdata') } }, { label => 'traffic-out', nlabel => 'channel.traffic.out.bitspersecond', set => { - key_values => [ { name => 'traffic_out', diff => 1 }, { name => 'qmgr_name' }, { name => 'channel_name' } ], + key_values => [ { name => 'traffic_out', per_second => 1 }, { name => 'qmgr_name' }, { name => 'channel_name' } ], output_template => 'traffic out: %s %s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, closure_custom_perfdata => $self->can('custom_traffic_out_perfdata') } } @@ -115,8 +115,9 @@ sub new { 'filter-type:s' => { name => 'filter_type' }, 'unknown-status:s' => { name => 'unknown_status', default => '' }, 'warning-status:s' => { name => 'warning_status', default => '' }, - 'critical-status:s' => { name => 'critical_status', default => '%{channel_status} !~ /running|idle/i' }, + 'critical-status:s' => { name => 'critical_status', default => '%{channel_status} !~ /running|idle/i' } }); + return $self; } @@ -174,7 +175,7 @@ sub manage_selection { } } - $self->{cache_name} = "ibmmq_" . $self->{mode} . '_' . $options{custom}->get_hostname() . '_' . $options{custom}->get_port() . '_' . + $self->{cache_name} = 'ibmmq_' . $self->{mode} . '_' . $options{custom}->get_hostname() . '_' . $options{custom}->get_port() . '_' . (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); } diff --git a/apps/mq/ibmmq/mqi/mode/queuemanager.pm b/apps/mq/ibmmq/mqi/mode/queuemanager.pm index debadbdf5..23381b20e 100644 --- a/apps/mq/ibmmq/mqi/mode/queuemanager.pm +++ b/apps/mq/ibmmq/mqi/mode/queuemanager.pm @@ -42,8 +42,8 @@ sub custom_connections_perfdata { $self->{output}->perfdata_add( nlabel => $self->{nlabel}, - instances => $self->{result_values}->{display_absolute}, - value => $self->{result_values}->{connection_count_absolute}, + instances => $self->{result_values}->{display}, + value => $self->{result_values}->{connection_count}, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}), min => 0 diff --git a/apps/mq/ibmmq/mqi/mode/queues.pm b/apps/mq/ibmmq/mqi/mode/queues.pm index c566d99d1..11384b2b6 100644 --- a/apps/mq/ibmmq/mqi/mode/queues.pm +++ b/apps/mq/ibmmq/mqi/mode/queues.pm @@ -31,7 +31,7 @@ sub custom_oldest_output { return sprintf( 'oldest message: %s', - centreon::plugins::misc::change_seconds(value => $self->{result_values}->{oldest_msg_age_absolute}) + centreon::plugins::misc::change_seconds(value => $self->{result_values}->{oldest_msg_age}) ); } @@ -40,8 +40,8 @@ sub custom_connections_perfdata { $self->{output}->perfdata_add( nlabel => $self->{nlabel}, - instances => [$self->{result_values}->{qmgr_name_absolute}, $self->{result_values}->{queue_name_absolute}], - value => $self->{result_values}->{open_input_count_absolute}, + instances => [$self->{result_values}->{qmgr_name}, $self->{result_values}->{queue_name}], + value => $self->{result_values}->{open_input_count}, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}), min => 0 @@ -53,8 +53,8 @@ sub custom_qdepth_perfdata { $self->{output}->perfdata_add( nlabel => $self->{nlabel}, - instances => [$self->{result_values}->{qmgr_name_absolute}, $self->{result_values}->{queue_name_absolute}], - value => $self->{result_values}->{current_qdepth_absolute}, + instances => [$self->{result_values}->{qmgr_name}, $self->{result_values}->{queue_name}], + value => $self->{result_values}->{current_qdepth}, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}), min => 0 @@ -66,8 +66,8 @@ sub custom_oldest_perfdata { $self->{output}->perfdata_add( nlabel => $self->{nlabel}, - instances => [$self->{result_values}->{qmgr_name_absolute}, $self->{result_values}->{queue_name_absolute}], - value => $self->{result_values}->{oldest_msg_age_absolute}, + instances => [$self->{result_values}->{qmgr_name}, $self->{result_values}->{queue_name}], + value => $self->{result_values}->{oldest_msg_age}, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}), min => 0 diff --git a/apps/mq/rabbitmq/restapi/mode/nodeusage.pm b/apps/mq/rabbitmq/restapi/mode/nodeusage.pm index ff2c46849..901988ba0 100644 --- a/apps/mq/rabbitmq/restapi/mode/nodeusage.pm +++ b/apps/mq/rabbitmq/restapi/mode/nodeusage.pm @@ -51,25 +51,23 @@ sub set_counters { } }, { label => 'read', nlabel => 'node.io.read.usage.bytespersecond', set => { - key_values => [ { name => 'io_read_bytes', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'io_read_bytes', per_second => 1 }, { name => 'display' } ], output_template => 'read i/o : %s %s/s', - per_second => 1, output_change_bytes => 1, + output_change_bytes => 1, perfdatas => [ - { value => 'io_read_bytes_per_second', template => '%d', - unit => 'B/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, - ], + { template => '%d', unit => 'B/s', min => 0, label_extra_instance => 1, instance_use => 'display' } + ] } }, { label => 'write', nlabel => 'node.io.write.usage.bytespersecond', set => { - key_values => [ { name => 'io_write_bytes', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'io_write_bytes', per_second => 1 }, { name => 'display' } ], output_template => 'write i/o : %s %s/s', - per_second => 1, output_change_bytes => 1, + output_change_bytes => 1, perfdatas => [ - { value => 'io_write_bytes_per_second', template => '%d', - unit => 'B/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, - ], + { template => '%d', unit => 'B/s', min => 0, label_extra_instance => 1, instance_use => 'display' } + ] } - }, + } ]; } diff --git a/apps/mq/rabbitmq/restapi/mode/queueusage.pm b/apps/mq/rabbitmq/restapi/mode/queueusage.pm index 798cf49db..bc67e3f3c 100644 --- a/apps/mq/rabbitmq/restapi/mode/queueusage.pm +++ b/apps/mq/rabbitmq/restapi/mode/queueusage.pm @@ -54,8 +54,8 @@ sub set_counters { key_values => [ { name => 'queue_messages' }, { name => 'display' } ], output_template => 'current queue messages : %s', perfdatas => [ - { label => 'queue_msg', value => 'queue_messages_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'queue_msg', value => 'queue_messages', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -63,8 +63,8 @@ sub set_counters { key_values => [ { name => 'queue_messages_ready' }, { name => 'display' } ], output_template => 'current queue messages ready : %s', perfdatas => [ - { label => 'queue_msg_ready', value => 'queue_messages_ready_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'queue_msg_ready', value => 'queue_messages_ready', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/apps/mq/rabbitmq/restapi/mode/systemusage.pm b/apps/mq/rabbitmq/restapi/mode/systemusage.pm index 2b611a9f3..67f7a08ea 100644 --- a/apps/mq/rabbitmq/restapi/mode/systemusage.pm +++ b/apps/mq/rabbitmq/restapi/mode/systemusage.pm @@ -38,49 +38,42 @@ sub set_counters { key_values => [ { name => 'queue_messages' } ], output_template => 'current queue messages : %s', perfdatas => [ - { label => 'queue_msg', value => 'queue_messages_absolute', template => '%d', - min => 0 }, - ], + { template => '%d', min => 0 } + ] } }, { label => 'queue-msg-ready', nlabel => 'system.queue.messages.ready.count', set => { key_values => [ { name => 'queue_messages_ready' } ], output_template => 'current queue messages ready : %s', perfdatas => [ - { label => 'queue_msg_ready', value => 'queue_messages_ready_absolute', template => '%d', - min => 0 }, - ], + { template => '%d', min => 0 } + ] } }, { label => 'db-event-queue', nlabel => 'system.db.event.queue.count', set => { key_values => [ { name => 'db_event_queue' } ], output_template => 'db event queue : %s', perfdatas => [ - { label => 'db_event_queue', value => 'db_event_queue_absolute', template => '%d', - min => 0 }, - ], + { template => '%d', min => 0 } + ] } }, { label => 'disk-read-iops', nlabel => 'system.disk.read.usage.iops', set => { - key_values => [ { name => 'disk_reads', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'disk_reads', per_second => 1 } ], output_template => 'disk reads iops : %s', perfdatas => [ - { label => 'disk_reads', value => 'disk_reads_per_second', template => '%d', - unit => 'iops', min => 0, }, - ], + { template => '%d', unit => 'iops', min => 0 } + ] } }, { label => 'disk-write-iops', nlabel => 'system.disk.write.usage.iops', set => { - key_values => [ { name => 'disk_writes', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'disk_writes', per_second => 1 } ], output_template => 'disk writes iops : %s', perfdatas => [ - { label => 'disk_writes', value => 'disk_writes_per_second', template => '%d', - unit => 'iops', min => 0, }, - ], + { template => '%d', unit => 'iops', min => 0 } + ] } - }, + } ]; } @@ -91,6 +84,7 @@ sub new { $options{options}->add_options(arguments => { }); + return $self; } diff --git a/apps/mq/rabbitmq/restapi/mode/vhostusage.pm b/apps/mq/rabbitmq/restapi/mode/vhostusage.pm index f00d5ea0f..8877cfbd5 100644 --- a/apps/mq/rabbitmq/restapi/mode/vhostusage.pm +++ b/apps/mq/rabbitmq/restapi/mode/vhostusage.pm @@ -55,8 +55,8 @@ sub set_counters { key_values => [ { name => 'queue_messages' }, { name => 'display' } ], output_template => 'current queue messages : %s', perfdatas => [ - { label => 'queue_msg', value => 'queue_messages_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'queue_msg', value => 'queue_messages', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -64,8 +64,8 @@ sub set_counters { key_values => [ { name => 'queue_messages_ready' }, { name => 'display' } ], output_template => 'current queue messages ready : %s', perfdatas => [ - { label => 'queue_msg_ready', value => 'queue_messages_ready_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'queue_msg_ready', value => 'queue_messages_ready', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/apps/mq/vernemq/restapi/mode/clusters.pm b/apps/mq/vernemq/restapi/mode/clusters.pm index 0dc8c8618..06b70aa84 100644 --- a/apps/mq/vernemq/restapi/mode/clusters.pm +++ b/apps/mq/vernemq/restapi/mode/clusters.pm @@ -51,7 +51,7 @@ sub set_counters { key_values => [ { name => 'running' } ], output_template => 'current clusters running: %s', perfdatas => [ - { value => 'running_absolute', template => '%s', min => 0 } + { value => 'running', template => '%s', min => 0 } ] } }, @@ -59,7 +59,7 @@ sub set_counters { key_values => [ { name => 'notrunning' } ], output_template => 'current clusters not running: %s', perfdatas => [ - { value => 'notrunning_absolute', template => '%s', min => 0 } + { value => 'notrunning', template => '%s', min => 0 } ] } } diff --git a/apps/mq/vernemq/restapi/mode/listeners.pm b/apps/mq/vernemq/restapi/mode/listeners.pm index 8da916ebe..136647c8d 100644 --- a/apps/mq/vernemq/restapi/mode/listeners.pm +++ b/apps/mq/vernemq/restapi/mode/listeners.pm @@ -51,7 +51,7 @@ sub set_counters { key_values => [ { name => 'running' } ], output_template => 'current listeners running: %s', perfdatas => [ - { value => 'running_absolute', template => '%s', min => 0 } + { value => 'running', template => '%s', min => 0 } ] } }, @@ -59,7 +59,7 @@ sub set_counters { key_values => [ { name => 'notrunning' } ], output_template => 'current listeners not running: %s', perfdatas => [ - { value => 'notrunning_absolute', template => '%s', min => 0 } + { value => 'notrunning', template => '%s', min => 0 } ] } } diff --git a/apps/mq/vernemq/restapi/mode/plugins.pm b/apps/mq/vernemq/restapi/mode/plugins.pm index ad1919677..6a5515f14 100644 --- a/apps/mq/vernemq/restapi/mode/plugins.pm +++ b/apps/mq/vernemq/restapi/mode/plugins.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'total' } ], output_template => 'current total plugins: %s', perfdatas => [ - { value => 'total_absolute', template => '%s', min => 0 } + { value => 'total', template => '%s', min => 0 } ] } } diff --git a/apps/mq/vernemq/restapi/mode/sessions.pm b/apps/mq/vernemq/restapi/mode/sessions.pm index d3f2cdde7..e0572bc4a 100644 --- a/apps/mq/vernemq/restapi/mode/sessions.pm +++ b/apps/mq/vernemq/restapi/mode/sessions.pm @@ -43,7 +43,7 @@ sub set_counters { key_values => [ { name => 'online' } ], output_template => 'current online: %s', perfdatas => [ - { value => 'online_absolute', template => '%s', min => 0 } + { value => 'online', template => '%s', min => 0 } ] } }, @@ -51,7 +51,7 @@ sub set_counters { key_values => [ { name => 'total' } ], output_template => 'current total: %s', perfdatas => [ - { value => 'total_absolute', template => '%s', min => 0 } + { value => 'total', template => '%s', min => 0 } ] } } diff --git a/apps/mulesoft/restapi/mode/applications.pm b/apps/mulesoft/restapi/mode/applications.pm index e12a8d173..58e1bb98a 100644 --- a/apps/mulesoft/restapi/mode/applications.pm +++ b/apps/mulesoft/restapi/mode/applications.pm @@ -44,25 +44,25 @@ sub set_counters { { label => 'total', nlabel => 'mulesoft.applications.total.count', set => { key_values => [ { name => 'total' } ], output_template => "Total : %s", - perfdatas => [ { value => 'total_absolute', template => '%d', min => 0 } ] + perfdatas => [ { value => 'total', template => '%d', min => 0 } ] } }, { label => 'started', nlabel => 'mulesoft.applications.status.started.count', set => { key_values => [ { name => 'started' } ], output_template => "Started : %s", - perfdatas => [ { value => 'started_absolute', template => '%d', min => 0 } ] + perfdatas => [ { value => 'started', template => '%d', min => 0 } ] } }, { label => 'stopped', nlabel => 'mulesoft.applications.status.stopped.count', set => { key_values => [ { name => 'stopped' } ], output_template => "Stopped : %s", - perfdatas => [ { value => 'stopped_absolute', template => '%d', min => 0 } ] + perfdatas => [ { value => 'stopped', template => '%d', min => 0 } ] } }, { label => 'failed', nlabel => 'mulesoft.applications.status.failed.count', set => { key_values => [ { name => 'failed' } ], output_template => "Failed : %s", - perfdatas => [ { value => 'failed_absolute', template => '%d', min => 0 } ] + perfdatas => [ { value => 'failed', template => '%d', min => 0 } ] } } ]; diff --git a/apps/mulesoft/restapi/mode/clusters.pm b/apps/mulesoft/restapi/mode/clusters.pm index 5f1cfef53..e5c955b2e 100644 --- a/apps/mulesoft/restapi/mode/clusters.pm +++ b/apps/mulesoft/restapi/mode/clusters.pm @@ -50,19 +50,19 @@ sub set_counters { { label => 'total', nlabel => 'mulesoft.clusters.total.count', set => { key_values => [ { name => 'total' } ], output_template => "Total : %s", - perfdatas => [ { value => 'total_absolute', template => '%d', min => 0 } ], + perfdatas => [ { value => 'total', template => '%d', min => 0 } ], } }, { label => 'running', nlabel => 'mulesoft.clusters.status.running.count', set => { key_values => [ { name => 'running' } ], output_template => "Running : %s", - perfdatas => [ { value => 'running_absolute', template => '%d', min => 0 } ] + perfdatas => [ { value => 'running', template => '%d', min => 0 } ] } }, { label => 'disconnected', nlabel => 'mulesoft.clusters.status.disconnected.count', set => { key_values => [ { name => 'disconnected' } ], output_template => "Disconnected : %s", - perfdatas => [ { value => 'disconnected_absolute', template => '%d', min => 0 } ] + perfdatas => [ { value => 'disconnected', template => '%d', min => 0 } ] } } ]; diff --git a/apps/mulesoft/restapi/mode/servers.pm b/apps/mulesoft/restapi/mode/servers.pm index a3db2385d..f6ead952b 100644 --- a/apps/mulesoft/restapi/mode/servers.pm +++ b/apps/mulesoft/restapi/mode/servers.pm @@ -43,19 +43,19 @@ sub set_counters { { label => 'total', nlabel => 'mulesoft.servers.total.count', set => { key_values => [ { name => 'total' } ], output_template => 'Total : %s', - perfdatas => [ { value => 'total_absolute', template => '%d', min => 0 } ] + perfdatas => [ { value => 'total', template => '%d', min => 0 } ] } }, { label => 'running', nlabel => 'mulesoft.servers.status.running.count', set => { key_values => [ { name => 'running' } ], output_template => 'Running : %s', - perfdatas => [ { value => 'running_absolute', template => '%d', min => 0 } ] + perfdatas => [ { value => 'running', template => '%d', min => 0 } ] } }, { label => 'disconnected', nlabel => 'mulesoft.servers.status.disconnected.count', set => { key_values => [ { name => 'disconnected' } ], output_template => 'Disconnected : %s', - perfdatas => [ { value => 'disconnected_absolute', template => '%d', min => 0 } ] + perfdatas => [ { value => 'disconnected', template => '%d', min => 0 } ] } } ]; diff --git a/apps/openldap/ldap/mode/systemusage.pm b/apps/openldap/ldap/mode/systemusage.pm index 430864a30..78e1bd0cd 100644 --- a/apps/openldap/ldap/mode/systemusage.pm +++ b/apps/openldap/ldap/mode/systemusage.pm @@ -42,9 +42,8 @@ sub set_counters { key_values => [ { name => 'operations_completed_' . $_, diff => 1 } ], output_template => $_ . ' %s', perfdatas => [ - { label => 'operations_' . $_, value => 'operations_completed_' . $_ . '_absolute', template => '%.2f', - min => 0 }, - ], + { label => 'operations_' . $_, template => '%.2f', min => 0 } + ] } }; } @@ -55,8 +54,7 @@ sub set_counters { key_values => [ { name => 'connections_current' } ], output_template => 'Current connections %s', perfdatas => [ - { label => 'connections_current', value => 'connections_current_absolute', template => '%s', - min => 0 }, + { label => 'connections_current', template => '%s', min => 0 }, ], } }, @@ -64,8 +62,7 @@ sub set_counters { key_values => [ { name => 'connections_total', diff => 1 } ], output_template => 'Total connections %s', perfdatas => [ - { label => 'connections_total', value => 'connections_total_absolute', template => '%s', - min => 0 }, + { label => 'connections_total', template => '%s', min => 0 }, ], } }, @@ -73,21 +70,19 @@ sub set_counters { key_values => [ { name => 'threads_active_prct' } ], output_template => 'Current active threads %.2f %%', perfdatas => [ - { label => 'threads_active', value => 'threads_active_prct_absolute', template => '%.2f', - min => 0, max => 100, unit => '%' }, + { label => 'threads_active', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } }, { label => 'traffic', nlabel => 'system.traffic.bytespersecond', set => { - key_values => [ { name => 'traffic', diff => 1 } ], - output_change_bytes => 1, per_second => 1, + key_values => [ { name => 'traffic', per_second => 1 } ], output_template => 'traffic %s %s/s', + output_change_bytes => 1, perfdatas => [ - { label => 'traffic', value => 'traffic_per_second', template => '%s', - min => 0, unit => 'B/s', cast_int => 1 }, - ], + { label => 'traffic', template => '%s', min => 0, unit => 'B/s', cast_int => 1 }, + ] } - }, + } ]; } @@ -109,11 +104,11 @@ sub new { 'ldap-starttls-options:s@' => { name => 'ldap_starttls_options' }, 'ldap-bind-options:s@' => { name => 'ldap_bind_options' }, 'tls' => { name => 'use_tls' }, - 'username:s' => { name => 'username' }, - 'password:s' => { name => 'password' }, - 'timeout:s' => { name => 'timeout', default => '30' }, + 'username:s' => { name => 'username' }, + 'password:s' => { name => 'password' }, + 'timeout:s' => { name => 'timeout', default => '30' }, }); - + return $self; } diff --git a/apps/openvpn/omi/mode/serverusage.pm b/apps/openvpn/omi/mode/serverusage.pm index 134b2654e..a9e314be4 100644 --- a/apps/openvpn/omi/mode/serverusage.pm +++ b/apps/openvpn/omi/mode/serverusage.pm @@ -38,26 +38,26 @@ sub set_counters { key_values => [ { name => 'num_clients' } ], output_template => 'Current Clients: %s', perfdatas => [ - { label => 'num_clients', value => 'num_clients_absolute', template => '%s', min => 0 }, + { label => 'num_clients', template => '%s', min => 0 }, ], } }, { label => 'traffic-in', set => { - key_values => [ { name => 'traffic_in', diff => 1 } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'traffic_in', per_second => 1 } ], + output_change_bytes => 2, output_template => 'Traffic In: %s %s/s', perfdatas => [ - { label => 'traffic_in', value => 'traffic_in_per_second', template => '%.2f', + { label => 'traffic_in', template => '%.2f', min => 0, unit => 'b/s' }, ], } }, { label => 'traffic-out', set => { - key_values => [ { name => 'traffic_out', diff => 1 } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'traffic_out', per_second => 1 } ], + output_change_bytes => 2, output_template => 'Traffic Out: %s %s/s', perfdatas => [ - { label => 'traffic_out', value => 'traffic_out_per_second', template => '%.2f', + { label => 'traffic_out', template => '%.2f', min => 0, unit => 'b/s' }, ], } @@ -69,11 +69,10 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; - - $options{options}->add_options(arguments => - { - }); - + + $options{options}->add_options(arguments => { + }); + return $self; } diff --git a/apps/openweathermap/restapi/mode/cityweather.pm b/apps/openweathermap/restapi/mode/cityweather.pm index d4dbcf067..d83fdebb1 100644 --- a/apps/openweathermap/restapi/mode/cityweather.pm +++ b/apps/openweathermap/restapi/mode/cityweather.pm @@ -60,7 +60,7 @@ sub set_counters { key_values => [ { name => 'temperature' } ], output_template => 'Temperature: %d C', perfdatas => [ - { label => 'temperature', value => 'temperature_absolute', template => '%d', + { label => 'temperature', value => 'temperature', template => '%d', unit => 'C' } ], } @@ -69,7 +69,7 @@ sub set_counters { key_values => [ { name => 'humidity' } ], output_template => 'Humidity: %.2f%%', perfdatas => [ - { label => 'humidity', value => 'humidity_absolute', template => '%.1f', + { label => 'humidity', value => 'humidity', template => '%.1f', min => 0, max => 100, unit => '%' } ], } @@ -78,7 +78,7 @@ sub set_counters { key_values => [ { name => 'clouds' } ], output_template => 'Clouds: %.2f%%', perfdatas => [ - { label => 'clouds', value => 'clouds_absolute', template => '%.1f', + { label => 'clouds', value => 'clouds', template => '%.1f', min => 0, max => 100, unit => '%' } ], } @@ -87,7 +87,7 @@ sub set_counters { key_values => [ { name => 'wind' } ], output_template => 'Wind: %.2f m/s', perfdatas => [ - { label => 'wind', value => 'wind_absolute', template => '%.1f', + { label => 'wind', value => 'wind', template => '%.1f', min => 0, unit => 'm/s' } ], } diff --git a/apps/pfsense/snmp/mode/packetstats.pm b/apps/pfsense/snmp/mode/packetstats.pm index 021be0117..8f3e932fc 100644 --- a/apps/pfsense/snmp/mode/packetstats.pm +++ b/apps/pfsense/snmp/mode/packetstats.pm @@ -35,62 +35,50 @@ sub set_counters { $self->{maps_counters}->{global} = [ { label => 'match', set => { - key_values => [ { name => 'pfCounterMatch', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'pfCounterMatch', per_second => 1 } ], output_template => 'Packets Matched Filter Rule : %.2f/s', perfdatas => [ - { label => 'match', value => 'pfCounterMatch_per_second', template => '%.2f', unit => '/s', - min => 0 }, + { label => 'match', template => '%.2f', unit => '/s', min => 0 }, ], } }, { label => 'badoffset', set => { - key_values => [ { name => 'pfCounterBadOffset', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'pfCounterBadOffset', per_second => 1 } ], output_template => 'Bad Offset Packets : %.2f/s', perfdatas => [ - { label => 'bad_offset', value => 'pfCounterBadOffset_per_second', template => '%.2f', unit => '/s', - min => 0 }, + { label => 'bad_offset', template => '%.2f', unit => '/s', min => 0 }, ], } }, { label => 'fragment', set => { - key_values => [ { name => 'pfCounterFragment', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'pfCounterFragment', per_second => 1 } ], output_template => 'Fragmented Packets : %.2f/s', perfdatas => [ - { label => 'fragment', value => 'pfCounterFragment_per_second', template => '%.2f', unit => '/s', - min => 0 }, + { label => 'fragment', template => '%.2f', unit => '/s', min => 0 }, ], } }, { label => 'short', set => { - key_values => [ { name => 'pfCounterShort', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'pfCounterShort', per_second => 1 } ], output_template => 'Short Packets : %.2f/s', perfdatas => [ - { label => 'short', value => 'pfCounterShort_per_second', template => '%.2f', unit => '/s', - min => 0 }, + { label => 'short', template => '%.2f', unit => '/s', min => 0 }, ], } }, { label => 'normalize', set => { - key_values => [ { name => 'pfCounterNormalize', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'pfCounterNormalize', per_second => 1 } ], output_template => 'Normalized Packets : %.2f/s', perfdatas => [ - { label => 'normalize', value => 'pfCounterNormalize_per_second', template => '%.2f', unit => '/s', - min => 0 }, + { label => 'normalize', template => '%.2f', unit => '/s', min => 0 }, ], } }, { label => 'memdrop', set => { - key_values => [ { name => 'pfCounterMemDrop', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'pfCounterMemDrop', per_second => 1 } ], output_template => 'Dropped Packets Due To Memory : %.2f/s', perfdatas => [ - { label => 'memdrop', value => 'pfCounterMemDrop_per_second', template => '%.2f', unit => '/s', - min => 0 }, + { label => 'memdrop', template => '%.2f', unit => '/s', min => 0 }, ], } }, @@ -101,11 +89,10 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; - - $options{options}->add_options(arguments => - { - }); - + + $options{options}->add_options(arguments => { + }); + return $self; } diff --git a/apps/pfsense/snmp/mode/pfinterfaces.pm b/apps/pfsense/snmp/mode/pfinterfaces.pm index 477822e47..3f35fafea 100644 --- a/apps/pfsense/snmp/mode/pfinterfaces.pm +++ b/apps/pfsense/snmp/mode/pfinterfaces.pm @@ -35,42 +35,42 @@ sub set_counters { $self->{maps_counters}->{pfint} = [ { label => 'traffic-in-pass', set => { - key_values => [ { name => 'pfInterfacesIf4BytesInPass', diff => 1 }, { name => 'display' } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'pfInterfacesIf4BytesInPass', per_second => 1 }, { name => 'display' } ], + output_change_bytes => 2, output_template => 'Traffic In Pass : %s %s/s', perfdatas => [ - { label => 'traffic_in_pass', value => 'pfInterfacesIf4BytesInPass_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_in_pass', template => '%.2f', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'traffic-out-pass', set => { - key_values => [ { name => 'pfInterfacesIf4BytesOutPass', diff => 1 }, { name => 'display' } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'pfInterfacesIf4BytesOutPass', per_second => 1 }, { name => 'display' } ], + output_change_bytes => 2, output_template => 'Traffic Out Pass : %s %s/s', perfdatas => [ - { label => 'traffic_out_pass', value => 'pfInterfacesIf4BytesOutPass_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_out_pass', template => '%.2f', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'traffic-in-block', set => { - key_values => [ { name => 'pfInterfacesIf4BytesInBlock', diff => 1 }, { name => 'display' } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'pfInterfacesIf4BytesInBlock', per_second => 1 }, { name => 'display' } ], + output_change_bytes => 2, output_template => 'Traffic In Block : %s %s/s', perfdatas => [ - { label => 'traffic_in_block', value => 'pfInterfacesIf4BytesInBlock_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_in_block', template => '%.2f', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'traffic-out-block', set => { - key_values => [ { name => 'pfInterfacesIf4BytesOutBlock', diff => 1 }, { name => 'display' } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'pfInterfacesIf4BytesOutBlock', per_second => 1 }, { name => 'display' } ], + output_change_bytes => 2, output_template => 'Traffic Out Block : %s %s/s', perfdatas => [ - { label => 'traffic_out_block', value => 'pfInterfacesIf4BytesOutBlock_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_out_block', template => '%.2f', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -87,12 +87,11 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; - - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - }); - + + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' } + }); + return $self; } @@ -126,7 +125,7 @@ sub manage_selection { $self->{pfint}->{$instance} = { display => $name }; } - + $options{snmp}->load(oids => [$mapping->{pfInterfacesIf4BytesInPass}->{oid}, $mapping->{pfInterfacesIf4BytesOutPass}->{oid}, $mapping->{pfInterfacesIf4BytesInBlock}->{oid}, $mapping->{pfInterfacesIf4BytesOutBlock}->{oid}, ], diff --git a/apps/php/apc/web/mode/filecache.pm b/apps/php/apc/web/mode/filecache.pm index 1f94c02d9..2752aa332 100644 --- a/apps/php/apc/web/mode/filecache.pm +++ b/apps/php/apc/web/mode/filecache.pm @@ -39,18 +39,18 @@ sub set_counters { key_values => [ { name => 'rr' } ], output_template => 'Request Rate (global): %.2f', perfdatas => [ - { value => 'rr_absolute', label => 'request_rate',template => '%.2f', + { label => 'request_rate', template => '%.2f', unit => 'r/s', min => 0 }, ], } }, { label => 'request-rate-now', set => { key_values => [ { name => 'hits', diff => 1 }, { name => 'misses', diff => 1 } ], - closure_custom_calc => $self->can('custom_rr_calc'), per_second => 1, + closure_custom_calc => $self->can('custom_rr_calc'), output_template => 'Request Rate : %.2f', output_error_template => 'Request Rate : %s', output_use => 'rr_now', threshold_use => 'rr_now', perfdatas => [ - { value => 'rr_now', label => 'request_rate_now', template => '%.2f', + { label => 'request_rate_now', value => 'rr_now', template => '%.2f', unit => 'r/s', min => 0 }, ], } @@ -59,18 +59,18 @@ sub set_counters { key_values => [ { name => 'hr' } ], output_template => 'Hit Rate (global): %.2f', perfdatas => [ - { value => 'hr_absolute', label => 'hit_rate',template => '%.2f', + { label => 'hit_rate',template => '%.2f', unit => 'r/s', min => 0 }, ], } }, { label => 'hit-rate-now', set => { key_values => [ { name => 'hits', diff => 1 } ], - closure_custom_calc => $self->can('custom_hr_calc'), per_second => 1, + closure_custom_calc => $self->can('custom_hr_calc'), output_template => 'Hit Rate : %.2f', output_error_template => 'Hit Rate : %s', output_use => 'hr_now', threshold_use => 'hr_now', perfdatas => [ - { value => 'hr_now', label => 'hit_rate_now', template => '%.2f', + { label => 'hit_rate_now', value => 'hr_now', template => '%.2f', unit => 'r/s', min => 0 }, ], } @@ -79,18 +79,18 @@ sub set_counters { key_values => [ { name => 'mr' } ], output_template => 'Miss Rate (global): %.2f', perfdatas => [ - { value => 'mr_absolute', label => 'miss_rate',template => '%.2f', + { label => 'miss_rate',template => '%.2f', unit => 'r/s', min => 0 }, ], } }, { label => 'miss-rate-now', set => { key_values => [ { name => 'misses', diff => 1 } ], - closure_custom_calc => $self->can('custom_mr_calc'), per_second => 1, + closure_custom_calc => $self->can('custom_mr_calc'), output_template => 'Miss Rate : %.2f', output_error_template => 'Miss Rate : %s', output_use => 'mr_now', threshold_use => 'mr_now', perfdatas => [ - { value => 'mr_now', label => 'miss_rate_now', template => '%.2f', + { label => 'miss_rate_now', value => 'mr_now', template => '%.2f', unit => 'r/s', min => 0 }, ], } @@ -101,7 +101,7 @@ sub set_counters { output_template => 'Hit Ratio (global) : %.2f %%', output_error_template => 'Hit Ratio (global): %s', output_use => 'hit_ratio', threshold_use => 'hit_ratio', perfdatas => [ - { value => 'hit_ratio', label => 'hit_ratio', template => '%.2f', + { label => 'hit_ratio', value => 'hit_ratio', template => '%.2f', unit => '%', min => 0, max => 100 }, ], } @@ -112,7 +112,7 @@ sub set_counters { output_template => 'Hit Ratio : %.2f %%', output_error_template => 'Hit Ratio : %s', output_use => 'hit_ratio_now', threshold_use => 'hit_ratio_now', perfdatas => [ - { value => 'hit_ratio_now', label => 'hit_ratio_now', template => '%.2f', + { label => 'hit_ratio_now', value => 'hit_ratio_now', template => '%.2f', unit => '%', min => 0, max => 100 }, ], } diff --git a/apps/php/apc/web/mode/memory.pm b/apps/php/apc/web/mode/memory.pm index 97e607035..b49baf8ea 100644 --- a/apps/php/apc/web/mode/memory.pm +++ b/apps/php/apc/web/mode/memory.pm @@ -50,9 +50,9 @@ sub set_counters { { label => 'fragmentation', set => { key_values => [ { name => 'fragmentation' } ], output_template => 'Memory Fragmentation: %.2f %%', output_error_template => 'Memory Fragmentation: %s', - output_use => 'fragmentation_absolute', threshold_use => 'fragmentation_absolute', + output_use => 'fragmentation', threshold_use => 'fragmentation', perfdatas => [ - { value => 'fragmentation_absolute', label => 'fragmentation', template => '%.2f', + { value => 'fragmentation', label => 'fragmentation', template => '%.2f', unit => '%', min => 0, max => 100 }, ], } diff --git a/apps/php/fpm/web/mode/usage.pm b/apps/php/fpm/web/mode/usage.pm index 155c772c8..1d46d823b 100644 --- a/apps/php/fpm/web/mode/usage.pm +++ b/apps/php/fpm/web/mode/usage.pm @@ -40,7 +40,7 @@ sub set_counters { closure_custom_calc => $self->can('custom_active_calc'), closure_custom_output => $self->can('custom_active_output'), threshold_use => 'active_prct', - closure_custom_perfdata => => $self->can('custom_active_perfdata'), + closure_custom_perfdata => => $self->can('custom_active_perfdata') } }, { label => 'idle-processes', set => { @@ -48,29 +48,27 @@ sub set_counters { closure_custom_calc => $self->can('custom_idle_calc'), closure_custom_output => $self->can('custom_idle_output'), threshold_use => 'idle_prct', - closure_custom_perfdata => => $self->can('custom_idle_perfdata'), + closure_custom_perfdata => => $self->can('custom_idle_perfdata') } }, { label => 'listen-queue', set => { key_values => [ { name => 'listen_queue' }, { name => 'max_listen_queue' } ], output_template => 'Listen queue : %s', - output_use => 'listen_queue_absolute', threshold_use => 'listen_queue_absolute', + output_use => 'listen_queue', threshold_use => 'listen_queue', perfdatas => [ - { label => 'listen_queue', template => '%s', value => 'listen_queue_absolute', - min => 0, max => 'max_listen_queue_absolute' }, - ], + { label => 'listen_queue', template => '%s', + min => 0, max => 'max_listen_queue' } + ] } }, { label => 'requests', set => { - key_values => [ { name => 'request', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'request', per_second => 1 } ], output_template => 'Requests : %.2f/s', perfdatas => [ - { label => 'requests', template => '%.2f', value => 'request_per_second', - unit => '/s', min => 0 }, - ], + { label => 'requests', template => '%.2f', unit => '/s', min => 0 } + ] } - }, + } ]; } @@ -140,19 +138,19 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - "hostname:s" => { name => 'hostname' }, - "port:s" => { name => 'port', }, - "proto:s" => { name => 'proto' }, - "urlpath:s" => { name => 'url_path', default => "/fpm-status" }, - "credentials" => { name => 'credentials' }, - "basic" => { name => 'basic' }, - "username:s" => { name => 'username' }, - "password:s" => { name => 'password' }, - "timeout:s" => { name => 'timeout', default => 5 }, + 'hostname:s' => { name => 'hostname' }, + 'port:s' => { name => 'port', }, + 'proto:s' => { name => 'proto' }, + 'urlpath:s' => { name => 'url_path', default => "/fpm-status" }, + 'credentials' => { name => 'credentials' }, + 'basic' => { name => 'basic' }, + 'username:s' => { name => 'username' }, + 'password:s' => { name => 'password' }, + 'timeout:s' => { name => 'timeout', default => 5 }, }); - + $self->{http} = centreon::plugins::http->new(%options); - + return $self; } diff --git a/apps/pineapp/securemail/snmp/mode/system.pm b/apps/pineapp/securemail/snmp/mode/system.pm index 6ca1e2b11..f06331f1d 100644 --- a/apps/pineapp/securemail/snmp/mode/system.pm +++ b/apps/pineapp/securemail/snmp/mode/system.pm @@ -57,7 +57,7 @@ sub set_counters { key_values => [ { name => 'cpuload' . $_ . 'minavg' } ], output_template => '%s (' . $_ . 'm)', perfdatas => [ - { value => 'cpuload' . $_ . 'minavg_absolute', template => '%s', min => 0 }, + { value => 'cpuload' . $_ . 'minavg', template => '%s', min => 0 }, ], } }; @@ -76,7 +76,7 @@ sub set_counters { key_values => [ { name => 'mailsysteminboundqueue' } ], output_template => 'messages inbound queue: %s', perfdatas => [ - { value => 'mailsysteminboundqueue_absolute', template => '%s', min => 0 }, + { value => 'mailsysteminboundqueue', template => '%s', min => 0 }, ], } }, @@ -84,7 +84,7 @@ sub set_counters { key_values => [ { name => 'mailsystemoutboundqueue' } ], output_template => 'messages outbound queue: %s', perfdatas => [ - { value => 'mailsystemoutboundqueue_absolute', template => '%s', min => 0 }, + { value => 'mailsystemoutboundqueue', template => '%s', min => 0 }, ], } }, @@ -92,7 +92,7 @@ sub set_counters { key_values => [ { name => 'mailQueueHigh' } ], output_template => 'messages high priority: %s', perfdatas => [ - { value => 'mailQueueHigh_absolute', template => '%s', min => 0 }, + { value => 'mailQueueHigh', template => '%s', min => 0 }, ], } }, @@ -100,7 +100,7 @@ sub set_counters { key_values => [ { name => 'mailQueueNormal' } ], output_template => 'messages normal priority: %s', perfdatas => [ - { value => 'mailQueueNormal_absolute', template => '%s', min => 0 }, + { value => 'mailQueueNormal', template => '%s', min => 0 }, ], } }, @@ -108,7 +108,7 @@ sub set_counters { key_values => [ { name => 'mailQueueLow' } ], output_template => 'messages low priority: %s', perfdatas => [ - { value => 'mailQueueLow_absolute', template => '%s', min => 0 }, + { value => 'mailQueueLow', template => '%s', min => 0 }, ], } }, @@ -116,7 +116,7 @@ sub set_counters { key_values => [ { name => 'mailQueueTotal' } ], output_template => 'messages queue total: %s', perfdatas => [ - { value => 'mailQueueTotal_absolute', template => '%s', min => 0 }, + { value => 'mailQueueTotal', template => '%s', min => 0 }, ], } }, diff --git a/apps/protocols/bgp/4/mode/bgppeerstate.pm b/apps/protocols/bgp/4/mode/bgppeerstate.pm index c520bff21..41553d643 100644 --- a/apps/protocols/bgp/4/mode/bgppeerstate.pm +++ b/apps/protocols/bgp/4/mode/bgppeerstate.pm @@ -71,8 +71,8 @@ sub set_counters { key_values => [ { name => 'seconds' }, { name => 'display' } ], output_template => 'Last update : %ss', perfdatas => [ - { label => 'seconds', value => 'seconds_absolute', template => '%s', - unit => 's', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'seconds', value => 'seconds', template => '%s', + unit => 's', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/apps/protocols/http/mode/expectedcontent.pm b/apps/protocols/http/mode/expectedcontent.pm index 3a11046c4..d0c4f09ae 100644 --- a/apps/protocols/http/mode/expectedcontent.pm +++ b/apps/protocols/http/mode/expectedcontent.pm @@ -78,7 +78,7 @@ sub set_counters { key_values => [ { name => 'size' } ], output_template => 'Content size : %s', perfdatas => [ - { label => 'size', value => 'size_absolute', template => '%s', min => 0, unit => 'B' }, + { label => 'size', value => 'size', template => '%s', min => 0, unit => 'B' }, ], } }, @@ -86,7 +86,7 @@ sub set_counters { key_values => [ { name => 'time' } ], output_template => 'Response time : %.3fs', perfdatas => [ - { label => 'time', value => 'time_absolute', template => '%.3f', min => 0, unit => 's' }, + { label => 'time', value => 'time', template => '%.3f', min => 0, unit => 's' }, ], } }, @@ -94,7 +94,7 @@ sub set_counters { key_values => [ { name => 'extracted' } ], output_template => 'Extracted value : %s', perfdatas => [ - { label => 'value', value => 'extracted_absolute', template => '%s' }, + { label => 'value', value => 'extracted', template => '%s' }, ], } }, diff --git a/apps/protocols/http/mode/response.pm b/apps/protocols/http/mode/response.pm index 34505851c..99a291f83 100644 --- a/apps/protocols/http/mode/response.pm +++ b/apps/protocols/http/mode/response.pm @@ -56,7 +56,7 @@ sub set_counters { key_values => [ { name => 'time' } ], output_template => 'Response time %.3fs', perfdatas => [ - { label => 'time', value => 'time_absolute', template => '%.3f', min => 0, unit => 's' } + { label => 'time', value => 'time', template => '%.3f', min => 0, unit => 's' } ] } }, @@ -64,7 +64,7 @@ sub set_counters { key_values => [ { name => 'size' } ], output_template => 'Content size : %s', perfdatas => [ - { label => 'size', value => 'size_absolute', template => '%s', min => 0, unit => 'B' } + { label => 'size', value => 'size', template => '%s', min => 0, unit => 'B' } ] } } diff --git a/apps/protocols/ldap/mode/search.pm b/apps/protocols/ldap/mode/search.pm index a46d42d70..15cc31869 100644 --- a/apps/protocols/ldap/mode/search.pm +++ b/apps/protocols/ldap/mode/search.pm @@ -39,7 +39,7 @@ sub set_counters { key_values => [ { name => 'entries' } ], output_template => 'Number of results returned: %s', perfdatas => [ - { value => 'entries_absolute', template => '%s', min => 0 }, + { value => 'entries', template => '%s', min => 0 }, ], } }, @@ -47,7 +47,7 @@ sub set_counters { key_values => [ { name => 'time' } ], output_template => 'Response time : %.3fs', perfdatas => [ - { label => 'time', value => 'time_absolute', template => '%.3f', min => 0, unit => 's' }, + { label => 'time', value => 'time', template => '%.3f', min => 0, unit => 's' }, ], } }, diff --git a/apps/protocols/ospf/snmp/mode/neighbor.pm b/apps/protocols/ospf/snmp/mode/neighbor.pm index 28f5f626b..b93d12ced 100644 --- a/apps/protocols/ospf/snmp/mode/neighbor.pm +++ b/apps/protocols/ospf/snmp/mode/neighbor.pm @@ -71,7 +71,7 @@ sub set_counters { key_values => [ { name => 'total' } ], output_template => 'Total neighbors : %s', perfdatas => [ - { label => 'total', value => 'total_absolute', template => '%s', + { label => 'total', value => 'total', template => '%s', min => 0 }, ], } diff --git a/apps/protocols/radius/mode/login.pm b/apps/protocols/radius/mode/login.pm index 7b5cc3134..6fdd95c8d 100644 --- a/apps/protocols/radius/mode/login.pm +++ b/apps/protocols/radius/mode/login.pm @@ -65,7 +65,7 @@ sub set_counters { key_values => [ { name => 'elapsed' } ], output_template => 'Response time : %.3f second(s)', perfdatas => [ - { label => 'time', value => 'elapsed_absolute', template => '%.3f', + { label => 'time', value => 'elapsed', template => '%.3f', min => 0, unit => 's' }, ], } diff --git a/apps/protocols/snmp/mode/responsetime.pm b/apps/protocols/snmp/mode/responsetime.pm index 851394377..8b5f81e67 100644 --- a/apps/protocols/snmp/mode/responsetime.pm +++ b/apps/protocols/snmp/mode/responsetime.pm @@ -38,21 +38,21 @@ sub set_counters { key_values => [ { name => 'rta' } ], output_template => 'rta %.3fms', perfdatas => [ - { label => 'rta', value => 'rta_absolute', template => '%.3f', min => 0, unit => 'ms' }, + { label => 'rta', value => 'rta', template => '%.3f', min => 0, unit => 'ms' }, ], } }, { label => 'rtmax', display_ok => 0, set => { key_values => [ { name => 'rtmax' } ], perfdatas => [ - { label => 'rtmax', value => 'rtmax_absolute', template => '%.3f', min => 0, unit => 'ms' }, + { label => 'rtmax', value => 'rtmax', template => '%.3f', min => 0, unit => 'ms' }, ], } }, { label => 'rtmin', display_ok => 0, set => { key_values => [ { name => 'rtmin' } ], perfdatas => [ - { label => 'rtmin', value => 'rtmin_absolute', template => '%.3f', min => 0, unit => 'ms' }, + { label => 'rtmin', value => 'rtmin', template => '%.3f', min => 0, unit => 'ms' }, ], } }, @@ -60,7 +60,7 @@ sub set_counters { key_values => [ { name => 'pl' } ], output_template => 'lost %s%%', perfdatas => [ - { label => 'pl', value => 'pl_absolute', template => '%s', min => 0, max => 100, unit => '%' }, + { label => 'pl', value => 'pl', template => '%s', min => 0, max => 100, unit => '%' }, ], } }, diff --git a/apps/protocols/ssh/mode/login.pm b/apps/protocols/ssh/mode/login.pm index 8a8170f11..44694e161 100644 --- a/apps/protocols/ssh/mode/login.pm +++ b/apps/protocols/ssh/mode/login.pm @@ -61,7 +61,7 @@ sub set_counters { key_values => [ { name => 'time_elapsed' } ], output_template => 'Response time %.3fs', perfdatas => [ - { label => 'time', value => 'time_elapsed_absolute', template => '%.3f', unit => 's', min => 0 }, + { label => 'time', value => 'time_elapsed', template => '%.3f', unit => 's', min => 0 }, ], } }, diff --git a/apps/protocols/tftp/mode/commands.pm b/apps/protocols/tftp/mode/commands.pm index 015c0df81..18dee0d58 100644 --- a/apps/protocols/tftp/mode/commands.pm +++ b/apps/protocols/tftp/mode/commands.pm @@ -63,8 +63,8 @@ sub set_counters { key_values => [ { name => 'timeelapsed' }, { name => 'display' } ], output_template => 'response time %.3fs', perfdatas => [ - { label => 'time', value => 'timeelapsed_absolute', template => '%.3f', - min => 0, unit => 's', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'time', value => 'timeelapsed', template => '%.3f', + min => 0, unit => 's', label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/apps/proxmox/ve/restapi/mode/vmusage.pm b/apps/proxmox/ve/restapi/mode/vmusage.pm index 763ca117c..7d7577a15 100644 --- a/apps/proxmox/ve/restapi/mode/vmusage.pm +++ b/apps/proxmox/ve/restapi/mode/vmusage.pm @@ -185,22 +185,20 @@ sub set_counters { } }, { label => 'read-iops', set => { - key_values => [ { name => 'read_io', diff => 1 }, { name => 'display' } ], - per_second => 1, + key_values => [ { name => 'read_io', per_second => 1 }, { name => 'display' } ], output_template => 'Read IOPs : %.2f', output_error_template => "Read IOPs : %s", perfdatas => [ - { label => 'read_iops', value => 'read_io_per_second', template => '%.2f', - unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' } + { label => 'read_iops', template => '%.2f', + unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display' } ] } }, { label => 'write-iops', set => { - key_values => [ { name => 'write_io', diff => 1 }, { name => 'display' } ], - per_second => 1, + key_values => [ { name => 'write_io', per_second => 1 }, { name => 'display' } ], output_template => 'Write IOPs : %.2f', output_error_template => "Write IOPs : %s", perfdatas => [ - { label => 'write_iops', value => 'write_io_per_second', template => '%.2f', - unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' } + { label => 'write_iops', template => '%.2f', + unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display' } ] } }, @@ -216,22 +214,22 @@ sub set_counters { $self->{maps_counters}->{vms_traffic} = [ { label => 'traffic-in', set => { - key_values => [ { name => 'traffic_in', diff => 1 }, { name => 'display' } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'traffic_in', per_second => 1 }, { name => 'display' } ], + output_change_bytes => 2, output_template => 'Traffic In : %s %s/s', perfdatas => [ - { label => 'traffic_in', value => 'traffic_in_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' } + { label => 'traffic_in', template => '%.2f', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' } ] } }, { label => 'traffic-out', set => { - key_values => [ { name => 'traffic_out', diff => 1 }, { name => 'display' } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'traffic_out', per_second => 1 }, { name => 'display' } ], + output_change_bytes => 2, output_template => 'Traffic Out : %s %s/s', perfdatas => [ - { label => 'traffic_out', value => 'traffic_out_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' } + { label => 'traffic_out', template => '%.2f', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' } ] } } @@ -251,6 +249,7 @@ sub new { 'warning-vm-status:s' => { name => 'warning_vm_status', default => '' }, 'critical-vm-status:s' => { name => 'critical_vm_status', default => '' } }); + $self->{statefile_cache_vms} = centreon::plugins::statefile->new(%options); return $self; } diff --git a/apps/pvx/restapi/mode/httphits.pm b/apps/pvx/restapi/mode/httphits.pm index 0b3b1807c..8b62c0c6c 100644 --- a/apps/pvx/restapi/mode/httphits.pm +++ b/apps/pvx/restapi/mode/httphits.pm @@ -37,8 +37,8 @@ sub set_counters { key_values => [ { name => 'ratio' }, { name => 'key' }, { name => 'instance_label' } ], output_template => 'Ratio: %.2f', perfdatas => [ - { label => 'ratio', value => 'ratio_absolute', template => '%.2f', - min => 0, label_extra_instance => 1, instance_use => 'key_absolute' }, + { label => 'ratio', value => 'ratio', template => '%.2f', + min => 0, label_extra_instance => 1, instance_use => 'key' }, ], } }, @@ -46,8 +46,8 @@ sub set_counters { key_values => [ { name => 'error_hits' }, { name => 'key' }, { name => 'instance_label' } ], output_template => 'Hits Error: %.3f hits/s', perfdatas => [ - { label => 'hits_error', value => 'error_hits_absolute', template => '%.3f', - min => 0, unit => 'hits/s', label_extra_instance => 1, instance_use => 'key_absolute' }, + { label => 'hits_error', value => 'error_hits', template => '%.3f', + min => 0, unit => 'hits/s', label_extra_instance => 1, instance_use => 'key' }, ], } }, @@ -55,8 +55,8 @@ sub set_counters { key_values => [ { name => 'hits' }, { name => 'key' }, { name => 'instance_label' } ], output_template => 'Hits: %.3f hits/s', perfdatas => [ - { label => 'hits', value => 'hits_absolute', template => '%.3f', - min => 0, unit => 'hits/s', label_extra_instance => 1, instance_use => 'key_absolute' }, + { label => 'hits', value => 'hits', template => '%.3f', + min => 0, unit => 'hits/s', label_extra_instance => 1, instance_use => 'key' }, ], } }, diff --git a/apps/pvx/restapi/mode/networkconnection.pm b/apps/pvx/restapi/mode/networkconnection.pm index 347284370..4c8da8f69 100644 --- a/apps/pvx/restapi/mode/networkconnection.pm +++ b/apps/pvx/restapi/mode/networkconnection.pm @@ -37,8 +37,8 @@ sub set_counters { key_values => [ { name => 'syns_ratio' }, { name => 'key' }, { name => 'instance_label' } ], output_template => 'Ratio: %.2f', perfdatas => [ - { label => 'ratio', value => 'syns_ratio_absolute', template => '%.2f', - min => 0, label_extra_instance => 1, instance_use => 'key_absolute' }, + { label => 'ratio', value => 'syns_ratio', template => '%.2f', + min => 0, label_extra_instance => 1, instance_use => 'key' }, ], } }, @@ -46,8 +46,8 @@ sub set_counters { key_values => [ { name => 'syns' }, { name => 'key' }, { name => 'instance_label' } ], output_template => 'Connections Attempts: %.2f conn/s', perfdatas => [ - { label => 'attempt', value => 'syns_absolute', template => '%.2f', - min => 0, unit => 'connections/s', label_extra_instance => 1, instance_use => 'key_absolute' }, + { label => 'attempt', value => 'syns', template => '%.2f', + min => 0, unit => 'connections/s', label_extra_instance => 1, instance_use => 'key' }, ], } }, @@ -55,8 +55,8 @@ sub set_counters { key_values => [ { name => 'ct_count' }, { name => 'key' }, { name => 'instance_label' } ], output_template => 'Successful Connections: %.2f conn/s', perfdatas => [ - { label => 'successful', value => 'ct_count_absolute', template => '%.2f', - min => 0, unit => 'connections/s', label_extra_instance => 1, instance_use => 'key_absolute' }, + { label => 'successful', value => 'ct_count', template => '%.2f', + min => 0, unit => 'connections/s', label_extra_instance => 1, instance_use => 'key' }, ], } }, @@ -64,8 +64,8 @@ sub set_counters { key_values => [ { name => 'ct' }, { name => 'key' }, { name => 'instance_label' } ], output_template => 'Average Connection Time: %.3f ms', perfdatas => [ - { label => 'connection_time', value => 'ct_absolute', template => '%.3f', - min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'key_absolute' }, + { label => 'connection_time', value => 'ct', template => '%.3f', + min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'key' }, ], } }, diff --git a/apps/pvx/restapi/mode/networktraffic.pm b/apps/pvx/restapi/mode/networktraffic.pm index 9802f8dea..26b045e12 100644 --- a/apps/pvx/restapi/mode/networktraffic.pm +++ b/apps/pvx/restapi/mode/networktraffic.pm @@ -39,7 +39,7 @@ sub set_counters { output_template => 'Total Traffic: %.2f %s/s', output_change_bytes => 2, perfdatas => [ - { label => 'total_traffic', value => 'total_traffic_absolute', template => '%d', + { label => 'total_traffic', value => 'total_traffic', template => '%d', min => 0, unit => 'b/s' }, ], } @@ -49,7 +49,7 @@ sub set_counters { output_template => 'Total Server Traffic: %.2f %s/s', output_change_bytes => 2, perfdatas => [ - { label => 'total_server_traffic', value => 'total_server_traffic_absolute', template => '%d', + { label => 'total_server_traffic', value => 'total_server_traffic', template => '%d', min => 0, unit => 'b/s' }, ], } @@ -59,7 +59,7 @@ sub set_counters { output_template => 'Total Client Traffic: %.2f %s/s', output_change_bytes => 2, perfdatas => [ - { label => 'total_client_traffic', value => 'total_client_traffic_absolute', template => '%d', + { label => 'total_client_traffic', value => 'total_client_traffic', template => '%d', min => 0, unit => 'b/s' }, ], } @@ -72,8 +72,8 @@ sub set_counters { output_template => 'Traffic: %.2f %s/s', output_change_bytes => 2, perfdatas => [ - { label => 'traffic', value => 'traffic_absolute', template => '%d', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'key_absolute' }, + { label => 'traffic', value => 'traffic', template => '%d', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'key' }, ], } }, @@ -82,8 +82,8 @@ sub set_counters { output_template => 'Server Traffic: %.2f %s/s', output_change_bytes => 2, perfdatas => [ - { label => 'server_traffic', value => 'server_traffic_absolute', template => '%d', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'key_absolute' }, + { label => 'server_traffic', value => 'server_traffic', template => '%d', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'key' }, ], } }, @@ -92,8 +92,8 @@ sub set_counters { output_template => 'Client Traffic: %.2f %s/s', output_change_bytes => 2, perfdatas => [ - { label => 'client_traffic', value => 'client_traffic_absolute', template => '%d', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'key_absolute' }, + { label => 'client_traffic', value => 'client_traffic', template => '%d', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'key' }, ], } }, diff --git a/apps/pvx/restapi/mode/networkuserexperience.pm b/apps/pvx/restapi/mode/networkuserexperience.pm index 37ea9586d..6bad42c0b 100644 --- a/apps/pvx/restapi/mode/networkuserexperience.pm +++ b/apps/pvx/restapi/mode/networkuserexperience.pm @@ -37,8 +37,8 @@ sub set_counters { key_values => [ { name => 'user_experience' }, { name => 'key' }, { name => 'instance_label' } ], output_template => 'End-User Experience: %.3f s', perfdatas => [ - { label => 'time', value => 'user_experience_absolute', template => '%.3f', - min => 0, unit => 's', label_extra_instance => 1, instance_use => 'key_absolute' }, + { label => 'time', value => 'user_experience', template => '%.3f', + min => 0, unit => 's', label_extra_instance => 1, instance_use => 'key' }, ], } }, diff --git a/apps/redis/cli/mode/clients.pm b/apps/redis/cli/mode/clients.pm index 22209c26d..43241d0e5 100644 --- a/apps/redis/cli/mode/clients.pm +++ b/apps/redis/cli/mode/clients.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'connected_clients' } ], output_template => 'Connected clients: %s', perfdatas => [ - { label => 'connected_clients', value => 'connected_clients_absolute', template => '%s', min => 0 }, + { label => 'connected_clients', value => 'connected_clients', template => '%s', min => 0 }, ], }, }, @@ -45,7 +45,7 @@ sub set_counters { key_values => [ { name => 'blocked_clients' } ], output_template => 'Blocked clients: %s', perfdatas => [ - { label => 'blocked_clients', value => 'blocked_clients_absolute', template => '%s', min => 0 }, + { label => 'blocked_clients', value => 'blocked_clients', template => '%s', min => 0 }, ], }, }, @@ -53,7 +53,7 @@ sub set_counters { 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_longest_output_list', value => 'client_longest_output_list', template => '%s', min => 0 }, ], }, }, @@ -61,7 +61,7 @@ sub set_counters { 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 }, + { label => 'client_biggest_input_buf', value => 'client_biggest_input_buf', template => '%s', min => 0 }, ], }, } diff --git a/apps/redis/cli/mode/commands.pm b/apps/redis/cli/mode/commands.pm index 1d39b7b9d..3c1fbf497 100644 --- a/apps/redis/cli/mode/commands.pm +++ b/apps/redis/cli/mode/commands.pm @@ -38,7 +38,7 @@ sub set_counters { 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 => 'processed_commands', value => 'total_commands_processed', template => '%s', min => 0 }, ], }, }, @@ -46,7 +46,7 @@ sub set_counters { 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' }, + { label => 'ops_per_sec', value => 'instantaneous_ops_per_sec', template => '%s', min => 0, unit => 'ops/s' }, ], }, }, diff --git a/apps/redis/cli/mode/connections.pm b/apps/redis/cli/mode/connections.pm index ef475b688..fa986fb4d 100644 --- a/apps/redis/cli/mode/connections.pm +++ b/apps/redis/cli/mode/connections.pm @@ -39,7 +39,7 @@ sub set_counters { 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 => 'received_connections', template => '%s', min => 0 }, ], }, }, @@ -47,7 +47,7 @@ sub set_counters { key_values => [ { name => 'rejected_connections', diff => 1 } ], output_template => 'Rejected: %s', perfdatas => [ - { label => 'rejected_connections', value => 'rejected_connections_absolute', template => '%s', min => 0 }, + { label => 'rejected_connections', template => '%s', min => 0 }, ], }, }, @@ -55,20 +55,20 @@ sub set_counters { $self->{maps_counters}->{traffic} = [ { label => 'traffic-in', set => { - key_values => [ { name => 'total_net_input_bytes', diff => 1 } ], + key_values => [ { name => 'total_net_input_bytes', per_second => 1 } ], output_template => 'Traffic In: %s %s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_in', value => 'total_net_input_bytes_per_second', template => '%d', min => 0, unit => 'b/s' }, + { label => 'traffic_in', template => '%d', min => 0, unit => 'b/s' }, ], }, }, { label => 'traffic-out', set => { - key_values => [ { name => 'total_net_output_bytes', diff => 1 } ], + key_values => [ { name => 'total_net_output_bytes', per_second => 1 } ], output_template => 'Traffic Out: %s %s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_out', value => 'total_net_output_bytes_per_second', template => '%d', min => 0, unit => 'b/s' }, + { label => 'traffic_out', template => '%d', min => 0, unit => 'b/s' }, ], }, }, @@ -92,10 +92,8 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; - - $options{options}->add_options(arguments => - { - }); + $options{options}->add_options(arguments => { + }); return $self; } diff --git a/apps/redis/cli/mode/cpu.pm b/apps/redis/cli/mode/cpu.pm index 74d1719b7..6191590bf 100644 --- a/apps/redis/cli/mode/cpu.pm +++ b/apps/redis/cli/mode/cpu.pm @@ -38,7 +38,6 @@ sub set_counters { key_values => [ { name => 'used_cpu_sys', diff => 1 } ], closure_custom_calc => $self->can('custom_usage_calc'), closure_custom_calc_extra_options => { label_ref => 'used_cpu_sys' }, output_template => 'System: %.2f %%', output_use => 'used_delta', threshold_use => 'used_delta', - per_second => 1, perfdatas => [ { label => 'sys', value => 'used_delta', template => '%.2f', min => 0, max => 100, unit => '%' }, ], @@ -48,7 +47,6 @@ sub set_counters { key_values => [ { name => 'used_cpu_user', diff => 1 } ], closure_custom_calc => $self->can('custom_usage_calc'), closure_custom_calc_extra_options => { label_ref => 'used_cpu_user' }, output_template => 'User: %.2f %%', output_use => 'used_delta', threshold_use => 'used_delta', - per_second => 1, perfdatas => [ { label => 'user', value => 'used_delta', template => '%.2f', min => 0, max => 100, unit => '%' }, ], @@ -58,7 +56,6 @@ sub set_counters { key_values => [ { name => 'used_cpu_sys_children', diff => 1 } ], closure_custom_calc => $self->can('custom_usage_calc'), closure_custom_calc_extra_options => { label_ref => 'used_cpu_sys_children' }, output_template => 'System children: %.2f %%', output_use => 'used_delta', threshold_use => 'used_delta', - per_second => 1, perfdatas => [ { label => 'sys_children', value => 'used_delta', template => '%.2f', min => 0, max => 100, unit => '%' }, ], @@ -68,12 +65,11 @@ sub set_counters { key_values => [ { name => 'used_cpu_user_children', diff => 1 } ], closure_custom_calc => $self->can('custom_usage_calc'), closure_custom_calc_extra_options => { label_ref => 'used_cpu_user_children' }, output_template => 'User children: %.2f %%', output_use => 'used_delta', threshold_use => 'used_delta', - per_second => 1, perfdatas => [ { label => 'user_children', value => 'used_delta', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } - }, + } ]; } @@ -97,10 +93,8 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; - - $options{options}->add_options(arguments => - { - }); + $options{options}->add_options(arguments => { + }); return $self; } diff --git a/apps/redis/cli/mode/memory.pm b/apps/redis/cli/mode/memory.pm index 484c3665c..e92c96aa6 100644 --- a/apps/redis/cli/mode/memory.pm +++ b/apps/redis/cli/mode/memory.pm @@ -169,7 +169,7 @@ sub set_counters { 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 => 'fragmentation_ratio', value => 'mem_fragmentation_ratio', template => '%s', min => 0 }, ], }, }, @@ -177,7 +177,7 @@ sub set_counters { 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 => 'defrag_running', value => 'active_defrag_running', template => '%s', min => 0 }, ], }, }, @@ -185,7 +185,7 @@ sub set_counters { 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 }, + { label => 'lazyfree_pending_objects', value => 'lazyfree_pending_objects', template => '%s', min => 0 }, ], }, }, diff --git a/apps/redis/cli/mode/persistence.pm b/apps/redis/cli/mode/persistence.pm index b5d8b4dd9..e8f247f86 100644 --- a/apps/redis/cli/mode/persistence.pm +++ b/apps/redis/cli/mode/persistence.pm @@ -46,7 +46,7 @@ sub set_counters { 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 => 'changes', value => 'rdb_changes_since_last_save', template => '%s', min => 0 }, ], }, }, @@ -54,7 +54,7 @@ sub set_counters { 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 => 'last_save', value => 'rdb_last_save_time_sec', template => '%s', min => 0, unit => 's' }, ], }, }, @@ -63,7 +63,7 @@ sub set_counters { 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 => 'save_size', value => 'rdb_last_cow_size', template => '%s', min => 0, unit => 'B' }, ], }, }, @@ -71,7 +71,7 @@ sub set_counters { 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 => 'last_save_duration', value => 'rdb_last_bgsave_time', template => '%s', min => 0, unit => 's' }, ], }, }, @@ -79,7 +79,7 @@ sub set_counters { 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' }, + { label => 'current_save_duration', value => 'rdb_current_bgsave_time', template => '%s', min => 0, unit => 's' }, ], }, }, diff --git a/apps/redis/cli/mode/replication.pm b/apps/redis/cli/mode/replication.pm index 2329efb61..5de24964c 100644 --- a/apps/redis/cli/mode/replication.pm +++ b/apps/redis/cli/mode/replication.pm @@ -48,7 +48,7 @@ sub set_counters { key_values => [ { name => 'connected_slaves' } ], output_template => 'Number of connected slaves: %s', perfdatas => [ - { label => 'connected_slaves', value => 'connected_slaves_absolute', template => '%s', min => 0 }, + { label => 'connected_slaves', value => 'connected_slaves', template => '%s', min => 0 }, ], }, }, @@ -59,7 +59,7 @@ sub set_counters { 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' }, + { label => 'master_repl_offset', value => 'master_repl_offset', template => '%s', min => 0, unit => 's' }, ], }, }, @@ -70,7 +70,7 @@ sub set_counters { 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 => 'master_last_io', value => 'master_last_io_seconds_ago', template => '%s', min => 0, unit => 's' }, ], }, }, @@ -78,7 +78,7 @@ sub set_counters { 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_repl_offset', value => 'slave_repl_offset', template => '%s', min => 0, unit => 's' }, ], }, }, @@ -86,7 +86,7 @@ sub set_counters { key_values => [ { name => 'slave_priority' } ], output_template => 'Slave replication offset: %s s', perfdatas => [ - { label => 'slave_priority', value => 'slave_priority_absolute', template => '%s' }, + { label => 'slave_priority', value => 'slave_priority', template => '%s' }, ], }, }, @@ -94,7 +94,7 @@ sub set_counters { 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' }, + { label => 'slave_read_only', value => 'slave_read_only', template => '%s' }, ], }, }, diff --git a/apps/redis/restapi/mode/clusterstats.pm b/apps/redis/restapi/mode/clusterstats.pm index eece4047e..a759a2725 100644 --- a/apps/redis/restapi/mode/clusterstats.pm +++ b/apps/redis/restapi/mode/clusterstats.pm @@ -104,7 +104,7 @@ sub set_counters { key_values => [ { name => 'cpu_system' } ], output_template => 'Cpu system: %.2f %%', perfdatas => [ - { label => 'cpu_system', value => 'cpu_system_absolute', template => '%.2f', + { label => 'cpu_system', value => 'cpu_system', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } @@ -113,7 +113,7 @@ sub set_counters { key_values => [ { name => 'cpu_user' } ], output_template => 'Cpu user: %.2f %%', perfdatas => [ - { label => 'cpu_user', value => 'cpu_user_absolute', template => '%.2f', + { label => 'cpu_user', value => 'cpu_user', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } @@ -162,7 +162,7 @@ sub set_counters { key_values => [ { name => 'bigstore_iops' } ], output_template => 'Flash IOPS: %s ops/s', perfdatas => [ - { label => 'flash_iops', value => 'bigstore_iops_absolute', template => '%s', + { label => 'flash_iops', value => 'bigstore_iops', template => '%s', min => 0, unit => 'ops/s' }, ], } @@ -172,7 +172,7 @@ sub set_counters { output_template => 'Flash throughput: %s %s/s', output_change_bytes => 1, perfdatas => [ - { label => 'flash_throughput', value => 'bigstore_throughput_absolute', template => '%s', + { label => 'flash_throughput', value => 'bigstore_throughput', template => '%s', min => 0, unit => 'B/s' }, ], } @@ -181,7 +181,7 @@ sub set_counters { key_values => [ { name => 'conns' } ], output_template => 'Connections: %s', perfdatas => [ - { label => 'connections', value => 'conns_absolute', template => '%s', + { label => 'connections', value => 'conns', template => '%s', min => 0 }, ], } @@ -190,7 +190,7 @@ sub set_counters { key_values => [ { name => 'total_req' } ], output_template => 'Requests rate: %s ops/s', perfdatas => [ - { label => 'requests', value => 'total_req_absolute', template => '%s', + { label => 'requests', value => 'total_req', template => '%s', min => 0, unit => 'ops/s' }, ], } @@ -200,7 +200,7 @@ sub set_counters { output_template => 'Traffic In: %s %s/s', output_change_bytes => 2, perfdatas => [ - { label => 'traffic_in', value => 'ingress_absolute', template => '%d', min => 0, unit => 'b/s' }, + { label => 'traffic_in', value => 'ingress', template => '%d', min => 0, unit => 'b/s' }, ], }, }, @@ -209,7 +209,7 @@ sub set_counters { output_template => 'Traffic Out: %s %s/s', output_change_bytes => 2, perfdatas => [ - { label => 'traffic_out', value => 'egress_absolute', template => '%d', min => 0, unit => 'b/s' }, + { label => 'traffic_out', value => 'egress', template => '%d', min => 0, unit => 'b/s' }, ], }, }, diff --git a/apps/redis/restapi/mode/databasesstats.pm b/apps/redis/restapi/mode/databasesstats.pm index c98a3306c..997783930 100644 --- a/apps/redis/restapi/mode/databasesstats.pm +++ b/apps/redis/restapi/mode/databasesstats.pm @@ -236,8 +236,8 @@ sub set_counters { key_values => [ { name => 'mem_frag_ratio' }, { name => 'display' } ], output_template => 'Memory fragmentation ratio: %s', perfdatas => [ - { label => 'mem_frag_ratio', value => 'mem_frag_ratio_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'mem_frag_ratio', value => 'mem_frag_ratio', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -245,8 +245,8 @@ sub set_counters { key_values => [ { name => 'conns' }, { name => 'display' } ], output_template => 'Connections: %s', perfdatas => [ - { label => 'connections', value => 'conns_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'connections', value => 'conns', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -273,8 +273,8 @@ sub set_counters { key_values => [ { name => 'avg_latency' }, { name => 'display' } ], output_template => 'Average latency: %.2f ms', perfdatas => [ - { label => 'latency', value => 'avg_latency_absolute', template => '%.2f', - min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'latency', value => 'avg_latency', template => '%.2f', + min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -297,8 +297,8 @@ sub set_counters { key_values => [ { name => 'avg_other_latency' }, { name => 'display' } ], output_template => 'Other latency: %.2f ms', perfdatas => [ - { label => 'other_latency', value => 'avg_other_latency_absolute', template => '%.2f', - min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'other_latency', value => 'avg_other_latency', template => '%.2f', + min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -306,8 +306,8 @@ sub set_counters { key_values => [ { name => 'no_of_keys' }, { name => 'display' } ], output_template => 'Total keys: %s', perfdatas => [ - { label => 'keys', value => 'no_of_keys_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'keys', value => 'no_of_keys', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -315,8 +315,8 @@ sub set_counters { key_values => [ { name => 'evicted_objects' }, { name => 'display' } ], output_template => 'Evicted objects rate: %s evictions/sec', perfdatas => [ - { label => 'evicted_objects', value => 'evicted_objects_absolute', template => '%s', - min => 0, unit => 'evictions/sec', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'evicted_objects', value => 'evicted_objects', template => '%s', + min => 0, unit => 'evictions/sec', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -324,8 +324,8 @@ sub set_counters { key_values => [ { name => 'expired_objects' }, { name => 'display' } ], output_template => 'Expired objects rate: %s expirations/sec', perfdatas => [ - { label => 'expired_objects', value => 'expired_objects_absolute', template => '%s', - min => 0, unit => 'expirations/sec', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'expired_objects', value => 'expired_objects', template => '%s', + min => 0, unit => 'expirations/sec', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -352,8 +352,8 @@ sub set_counters { key_values => [ { name => 'avg_read_latency' }, { name => 'display' } ], output_template => 'Read latency: %.2f ms', perfdatas => [ - { label => 'read_latency', value => 'avg_read_latency_absolute', template => '%.2f', - min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'read_latency', value => 'avg_read_latency', template => '%.2f', + min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -380,8 +380,8 @@ sub set_counters { key_values => [ { name => 'avg_write_latency' }, { name => 'display' } ], output_template => 'Write latency: %.2f ms', perfdatas => [ - { label => 'write_latency', value => 'avg_write_latency_absolute', template => '%.2f', - min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'write_latency', value => 'avg_write_latency', template => '%.2f', + min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -390,8 +390,8 @@ sub set_counters { output_template => 'Traffic In: %s %s/s', output_change_bytes => 2, perfdatas => [ - { label => 'traffic_in', value => 'ingress_absolute', template => '%d', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_in', value => 'ingress', template => '%d', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], }, }, @@ -400,8 +400,8 @@ sub set_counters { output_template => 'Traffic Out: %s %s/s', output_change_bytes => 2, perfdatas => [ - { label => 'traffic_out', value => 'egress_absolute', template => '%d', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_out', value => 'egress', template => '%d', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], }, }, diff --git a/apps/redis/restapi/mode/nodesstats.pm b/apps/redis/restapi/mode/nodesstats.pm index 338896e9e..be1dcc4d5 100644 --- a/apps/redis/restapi/mode/nodesstats.pm +++ b/apps/redis/restapi/mode/nodesstats.pm @@ -134,8 +134,8 @@ sub set_counters { key_values => [ { name => 'shard_count' }, { name => 'display' } ], output_template => 'Shard count: %d', perfdatas => [ - { label => 'shard_count', value => 'shard_count_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'shard_count', value => 'shard_count', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], }, }, @@ -143,8 +143,8 @@ sub set_counters { key_values => [ { name => 'uptime' }, { name => 'uptime_sec' }, { name => 'display' } ], output_template => 'Uptime: %s', perfdatas => [ - { label => 'uptime', value => 'uptime_sec_absolute', template => '%d', - min => 0, unit => 's', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'uptime', value => 'uptime_sec', template => '%d', + min => 0, unit => 's', label_extra_instance => 1, instance_use => 'display' }, ], }, }, @@ -152,8 +152,8 @@ sub set_counters { key_values => [ { name => 'cpu_system' }, { name => 'display' } ], output_template => 'Cpu system: %.2f %%', perfdatas => [ - { label => 'cpu_system', value => 'cpu_system_absolute', template => '%.2f', - min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'cpu_system', value => 'cpu_system', template => '%.2f', + min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -161,8 +161,8 @@ sub set_counters { key_values => [ { name => 'cpu_user' }, { name => 'display' } ], output_template => 'Cpu user: %.2f %%', perfdatas => [ - { label => 'cpu_user', value => 'cpu_user_absolute', template => '%.2f', - min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'cpu_user', value => 'cpu_user', template => '%.2f', + min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -210,8 +210,8 @@ sub set_counters { key_values => [ { name => 'bigstore_iops' }, { name => 'display' } ], output_template => 'Flash IOPS: %s ops/s', perfdatas => [ - { label => 'flash_iops', value => 'bigstore_iops_absolute', template => '%s', - min => 0, unit => 'ops/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'flash_iops', value => 'bigstore_iops', template => '%s', + min => 0, unit => 'ops/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -220,8 +220,8 @@ sub set_counters { output_template => 'Flash throughput: %s %s/s', output_change_bytes => 1, perfdatas => [ - { label => 'flash_throughput', value => 'bigstore_throughput_absolute', template => '%s', - min => 0, unit => 'B/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'flash_throughput', value => 'bigstore_throughput', template => '%s', + min => 0, unit => 'B/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -229,8 +229,8 @@ sub set_counters { key_values => [ { name => 'conns' }, { name => 'display' } ], output_template => 'Connections: %s', perfdatas => [ - { label => 'connections', value => 'conns_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'connections', value => 'conns', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -238,7 +238,7 @@ sub set_counters { key_values => [ { name => 'total_req' } ], output_template => 'Requests rate: %s ops/s', perfdatas => [ - { label => 'requests', value => 'total_req_absolute', template => '%s', + { label => 'requests', value => 'total_req', template => '%s', min => 0, unit => 'ops/s' }, ], } @@ -248,8 +248,8 @@ sub set_counters { output_template => 'Traffic In: %s %s/s', output_change_bytes => 2, perfdatas => [ - { label => 'traffic_in', value => 'ingress_absolute', template => '%d', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_in', value => 'ingress', template => '%d', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], }, }, @@ -258,8 +258,8 @@ sub set_counters { output_template => 'Traffic Out: %s %s/s', output_change_bytes => 2, perfdatas => [ - { label => 'traffic_out', value => 'egress_absolute', template => '%d', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_out', value => 'egress', template => '%d', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], }, }, diff --git a/apps/redis/restapi/mode/shardsstats.pm b/apps/redis/restapi/mode/shardsstats.pm index 4f405c1c8..6f63885b1 100644 --- a/apps/redis/restapi/mode/shardsstats.pm +++ b/apps/redis/restapi/mode/shardsstats.pm @@ -165,8 +165,8 @@ sub set_counters { output_template => 'Memory used: %s %s', output_change_bytes => 1, perfdatas => [ - { label => 'memory', value => 'used_memory_absolute', template => '%s', - min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'memory', value => 'used_memory', template => '%s', + min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -174,8 +174,8 @@ sub set_counters { key_values => [ { name => 'mem_frag_ratio' }, { name => 'display' } ], output_template => 'Memory fragmentation ratio: %s', perfdatas => [ - { label => 'mem_frag_ratio', value => 'mem_frag_ratio_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'mem_frag_ratio', value => 'mem_frag_ratio', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -183,8 +183,8 @@ sub set_counters { key_values => [ { name => 'connected_clients' }, { name => 'display' } ], output_template => 'Connected clients: %s', perfdatas => [ - { label => 'connected_clients', value => 'connected_clients_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'connected_clients', value => 'connected_clients', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -192,8 +192,8 @@ sub set_counters { key_values => [ { name => 'blocked_clients' }, { name => 'display' } ], output_template => 'Blocked clients: %s', perfdatas => [ - { label => 'blocked_clients', value => 'blocked_clients_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'blocked_clients', value => 'blocked_clients', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -201,8 +201,8 @@ sub set_counters { key_values => [ { name => 'total_req'}, { name => 'display' }], output_template => 'Requests rate: %s ops/s', perfdatas => [ - { label => 'requests', value => 'total_req_absolute', template => '%s', - min => 0, unit => 'ops/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'requests', value => 'total_req', template => '%s', + min => 0, unit => 'ops/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -210,8 +210,8 @@ sub set_counters { key_values => [ { name => 'no_of_keys' }, { name => 'display' } ], output_template => 'Total keys: %s', perfdatas => [ - { label => 'keys', value => 'no_of_keys_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'keys', value => 'no_of_keys', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -219,8 +219,8 @@ sub set_counters { key_values => [ { name => 'no_of_expires' }, { name => 'display' } ], output_template => 'Volatile keys: %s', perfdatas => [ - { label => 'volatile_keys', value => 'no_of_expires_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'volatile_keys', value => 'no_of_expires', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -228,8 +228,8 @@ sub set_counters { key_values => [ { name => 'evicted_objects' }, { name => 'display' } ], output_template => 'Evicted objects rate: %s evictions/sec', perfdatas => [ - { label => 'evicted_objects', value => 'evicted_objects_absolute', template => '%s', - min => 0, unit => 'evictions/sec', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'evicted_objects', value => 'evicted_objects', template => '%s', + min => 0, unit => 'evictions/sec', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -237,8 +237,8 @@ sub set_counters { key_values => [ { name => 'expired_objects' }, { name => 'display' } ], output_template => 'Expired objects rate: %s expirations/sec', perfdatas => [ - { label => 'expired_objects', value => 'expired_objects_absolute', template => '%s', - min => 0, unit => 'expirations/sec', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'expired_objects', value => 'expired_objects', template => '%s', + min => 0, unit => 'expirations/sec', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -274,8 +274,8 @@ sub set_counters { key_values => [ { name => 'rdb_changes_since_last_save' }, { name => 'display' } ], output_template => 'Rdb changes since last save: %s', perfdatas => [ - { label => 'rdb_changes_since_last_save', value => 'rdb_changes_since_last_save_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'rdb_changes_since_last_save', value => 'rdb_changes_since_last_save', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -283,8 +283,8 @@ sub set_counters { key_values => [ { name => 'last_save_time' }, { name => 'last_save_time_sec' }, { name => 'display' } ], output_template => 'Last same time: %s', perfdatas => [ - { label => 'last_save_time', value => 'last_save_time_sec_absolute', template => '%s', - min => 0, unit => 's', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'last_save_time', value => 'last_save_time_sec', template => '%s', + min => 0, unit => 's', label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/apps/rudder/restapi/mode/globalcompliance.pm b/apps/rudder/restapi/mode/globalcompliance.pm index 87fe115bd..eb229b590 100644 --- a/apps/rudder/restapi/mode/globalcompliance.pm +++ b/apps/rudder/restapi/mode/globalcompliance.pm @@ -66,7 +66,7 @@ sub set_counters { key_values => [ { name => 'compliance' } ], output_template => 'Global Compliance: %.2f%%', perfdatas => [ - { label => 'global_compliance', value => 'compliance_absolute', template => '%.2f', + { label => 'global_compliance', value => 'compliance', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } diff --git a/apps/rudder/restapi/mode/nodecompliance.pm b/apps/rudder/restapi/mode/nodecompliance.pm index 7c22c0967..908018b82 100644 --- a/apps/rudder/restapi/mode/nodecompliance.pm +++ b/apps/rudder/restapi/mode/nodecompliance.pm @@ -61,8 +61,8 @@ sub set_counters { key_values => [ { name => 'compliance' }, { name => 'display' } ], output_template => 'Compliance: %.2f%%', perfdatas => [ - { label => 'node_compliance', value => 'compliance_absolute', template => '%.2f', - min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'node_compliance', value => 'compliance', template => '%.2f', + min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/apps/rudder/restapi/mode/rulecompliance.pm b/apps/rudder/restapi/mode/rulecompliance.pm index 2bc4c8c78..6c9c76123 100644 --- a/apps/rudder/restapi/mode/rulecompliance.pm +++ b/apps/rudder/restapi/mode/rulecompliance.pm @@ -61,7 +61,7 @@ sub set_counters { key_values => [ { name => 'compliance' } ], output_template => 'Compliance: %.2f%%', perfdatas => [ - { label => 'rule_compliance', value => 'compliance_absolute', template => '%.2f', + { label => 'rule_compliance', value => 'compliance', template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 }, ], } diff --git a/apps/rudder/restapi/mode/statistics.pm b/apps/rudder/restapi/mode/statistics.pm index 34d2fff9f..a171745c2 100644 --- a/apps/rudder/restapi/mode/statistics.pm +++ b/apps/rudder/restapi/mode/statistics.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'nodes' } ], output_template => 'Nodes: %d', perfdatas => [ - { label => 'nodes', value => 'nodes_absolute', template => '%d', + { label => 'nodes', value => 'nodes', template => '%d', min => 0 }, ], } @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'pending_nodes' } ], output_template => 'Pending Nodes: %d', perfdatas => [ - { label => 'pending_nodes', value => 'pending_nodes_absolute', template => '%d', + { label => 'pending_nodes', value => 'pending_nodes', template => '%d', min => 0 }, ], } @@ -55,7 +55,7 @@ sub set_counters { key_values => [ { name => 'rules' } ], output_template => 'Rules: %d', perfdatas => [ - { label => 'rules', value => 'rules_absolute', template => '%d', + { label => 'rules', value => 'rules', template => '%d', min => 0 }, ], } @@ -64,7 +64,7 @@ sub set_counters { key_values => [ { name => 'directives' } ], output_template => 'Directives: %d', perfdatas => [ - { label => 'directives', value => 'directives_absolute', template => '%d', + { label => 'directives', value => 'directives', template => '%d', min => 0 }, ], } @@ -73,7 +73,7 @@ sub set_counters { key_values => [ { name => 'groups' } ], output_template => 'Groups: %d', perfdatas => [ - { label => 'groups', value => 'groups_absolute', template => '%d', + { label => 'groups', value => 'groups', template => '%d', min => 0 }, ], } @@ -82,7 +82,7 @@ sub set_counters { key_values => [ { name => 'techniques' } ], output_template => 'Techniques: %d', perfdatas => [ - { label => 'techniques', value => 'techniques_absolute', template => '%d', + { label => 'techniques', value => 'techniques', template => '%d', min => 0 }, ], } diff --git a/apps/sahipro/restapi/mode/scenario.pm b/apps/sahipro/restapi/mode/scenario.pm index b751c1dc0..14adc9dc8 100644 --- a/apps/sahipro/restapi/mode/scenario.pm +++ b/apps/sahipro/restapi/mode/scenario.pm @@ -75,7 +75,7 @@ sub set_counters { key_values => [ { name => 'time_taken' } ], output_template => 'execution time : %s ms', perfdatas => [ - { label => 'total_time', value => 'time_taken_absolute', template => '%s', min => 0, unit => 'ms' }, + { label => 'total_time', value => 'time_taken', template => '%s', min => 0, unit => 'ms' }, ], } }, @@ -83,7 +83,7 @@ sub set_counters { key_values => [ { name => 'total_steps' } ], output_template => 'total steps : %s', perfdatas => [ - { label => 'total_steps', value => 'total_steps_absolute', template => '%s', min => 0 }, + { label => 'total_steps', value => 'total_steps', template => '%s', min => 0 }, ], } }, @@ -91,7 +91,7 @@ sub set_counters { key_values => [ { name => 'failures' } ], output_template => 'failures : %s', perfdatas => [ - { label => 'failures', value => 'failures_absolute', template => '%s', min => 0 }, + { label => 'failures', value => 'failures', template => '%s', min => 0 }, ], } }, @@ -99,7 +99,7 @@ sub set_counters { key_values => [ { name => 'errors' } ], output_template => 'errors : %s', perfdatas => [ - { label => 'errors', value => 'errors_absolute', template => '%s', min => 0 }, + { label => 'errors', value => 'errors', template => '%s', min => 0 }, ], } }, @@ -110,8 +110,8 @@ sub set_counters { key_values => [ { name => 'time_taken' }, { name => 'step' } ], output_template => 'execution time : %s ms', perfdatas => [ - { label => 'step_time', value => 'time_taken_absolute', template => '%s', - min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'step_absolute' }, + { label => 'step_time', value => 'time_taken', template => '%s', + min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'step' }, ], } }, diff --git a/apps/salesforce/restapi/mode/sfdcinstance.pm b/apps/salesforce/restapi/mode/sfdcinstance.pm index aea61d55c..73bd954b4 100644 --- a/apps/salesforce/restapi/mode/sfdcinstance.pm +++ b/apps/salesforce/restapi/mode/sfdcinstance.pm @@ -62,7 +62,7 @@ sub set_counters { key_values => [ { name => 'incident' } ], output_template => '%s incidents currently', perfdatas => [ - { label => 'incident', value => 'incident_absolute', template => '%s', + { label => 'incident', value => 'incident', template => '%s', min => 0, label_extra_instance => 1 }, ], } diff --git a/apps/selenium/mode/scenariokatalon.pm b/apps/selenium/mode/scenariokatalon.pm index 754f303fd..e178b3405 100644 --- a/apps/selenium/mode/scenariokatalon.pm +++ b/apps/selenium/mode/scenariokatalon.pm @@ -147,7 +147,7 @@ sub set_counters { key_values => [ { name => 'time_scenario' } ], output_template => 'Total execution time : %.2f ms', perfdatas => [ - { label => 'time_scenario', value => 'time_scenario_absolute', template => '%.2f', + { label => 'time_scenario', value => 'time_scenario', template => '%.2f', min => 0, unit => 'ms' }, ], } @@ -168,8 +168,8 @@ sub set_counters { key_values => [ { name => 'time_step' }, { name => 'display' } ], output_template => 'Execution time : %.2f ms', perfdatas => [ - { label => 'time_step', value => 'time_step_absolute', template => '%.2f', - min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'time_step', value => 'time_step', template => '%.2f', + min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/apps/slack/restapi/mode/countchannels.pm b/apps/slack/restapi/mode/countchannels.pm index 4bb935bbb..f11fca915 100644 --- a/apps/slack/restapi/mode/countchannels.pm +++ b/apps/slack/restapi/mode/countchannels.pm @@ -44,7 +44,7 @@ sub set_counters { key_values => [ { name => 'count' } ], output_template => 'Number of channels : %d', perfdatas => [ - { label => 'count', value => 'count_absolute', template => '%d', + { label => 'count', value => 'count', template => '%d', min => 0 }, ], } diff --git a/apps/slack/restapi/mode/countmembers.pm b/apps/slack/restapi/mode/countmembers.pm index 334c23610..20dd271b4 100644 --- a/apps/slack/restapi/mode/countmembers.pm +++ b/apps/slack/restapi/mode/countmembers.pm @@ -44,7 +44,7 @@ sub set_counters { key_values => [ { name => 'count' } ], output_template => 'Number of members : %d', perfdatas => [ - { label => 'count', value => 'count_absolute', template => '%d', + { label => 'count', value => 'count', template => '%d', min => 0 }, ], } diff --git a/apps/squid/snmp/mode/cacheusage.pm b/apps/squid/snmp/mode/cacheusage.pm index 84ffa9496..98df69c33 100644 --- a/apps/squid/snmp/mode/cacheusage.pm +++ b/apps/squid/snmp/mode/cacheusage.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'cacheCpuUsage' } ], output_template => 'Cpu usage : %s %%', perfdatas => [ - { label => 'cpu', value => 'cacheCpuUsage_absolute', template => '%s', + { label => 'cpu', value => 'cacheCpuUsage', template => '%s', min => 0, max => 100, unit => '%' }, ], } @@ -47,7 +47,7 @@ sub set_counters { output_template => 'Memory usage : %s %s', output_change_bytes => 1, perfdatas => [ - { label => 'memory', value => 'cacheMemUsage_absolute', template => '%s', + { label => 'memory', value => 'cacheMemUsage', template => '%s', min => 0, unit => 'B' }, ], } @@ -56,7 +56,7 @@ sub set_counters { key_values => [ { name => 'cacheCurrentFileDescrCnt' } ], output_template => 'Number of file descriptors : %s', perfdatas => [ - { label => 'fd', value => 'cacheCurrentFileDescrCnt_absolute', template => '%s', + { label => 'fd', value => 'cacheCurrentFileDescrCnt', template => '%s', min => 0 }, ], } @@ -65,7 +65,7 @@ sub set_counters { key_values => [ { name => 'cacheNumObjCount' } ], output_template => 'Number of object stored : %s', perfdatas => [ - { label => 'objects', value => 'cacheNumObjCount_absolute', template => '%s', + { label => 'objects', value => 'cacheNumObjCount', template => '%s', min => 0 }, ], } diff --git a/apps/squid/snmp/mode/protocolstats.pm b/apps/squid/snmp/mode/protocolstats.pm index 9ec1fe0cb..26709a4d9 100644 --- a/apps/squid/snmp/mode/protocolstats.pm +++ b/apps/squid/snmp/mode/protocolstats.pm @@ -63,27 +63,27 @@ sub set_counters { key_values => [ { name => 'cacheHttpErrors', diff => 1 } ], output_template => 'errors : %s', perfdatas => [ - { label => 'http_errors', value => 'cacheHttpErrors_absolute', template => '%s', + { label => 'http_errors', template => '%s', min => 0 }, ], } }, { label => 'http-traffic-in', set => { - key_values => [ { name => 'cacheHttpInKb', diff => 1 } ], + key_values => [ { name => 'cacheHttpInKb', per_second => 1 } ], output_template => 'traffic in : %s %s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { label => 'http_traffic_in', value => 'cacheHttpInKb_per_second', template => '%s', + { label => 'http_traffic_in', template => '%s', min => 0, unit => 'b/s' }, ], } }, { label => 'http-traffic-out', set => { - key_values => [ { name => 'cacheHttpOutKb', diff => 1 } ], + key_values => [ { name => 'cacheHttpOutKb', per_second => 1 } ], output_template => 'traffic Out : %s %s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { label => 'http_traffic_out', value => 'cacheHttpOutKb_per_second', template => '%s', + { label => 'http_traffic_out', template => '%s', min => 0, unit => 'b/s' }, ], } @@ -92,21 +92,21 @@ sub set_counters { $self->{maps_counters}->{global_icp} = [ { label => 'icp-traffic-in', set => { - key_values => [ { name => 'cacheIcpKbRecv', diff => 1 } ], + key_values => [ { name => 'cacheIcpKbRecv', per_second => 1 } ], output_template => 'traffic in : %s %s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { label => 'icp_traffic_in', value => 'cacheIcpKbRecv_per_second', template => '%s', + { label => 'icp_traffic_in', template => '%s', min => 0, unit => 'b/s' }, ], } }, { label => 'icp-traffic-out', set => { - key_values => [ { name => 'cacheIcpKbSent', diff => 1 } ], + key_values => [ { name => 'cacheIcpKbSent', per_second => 1 } ], output_template => 'traffic Out : %s %s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { label => 'icp_traffic_out', value => 'cacheIcpKbSent_per_second', template => '%s', + { label => 'icp_traffic_out', template => '%s', min => 0, unit => 'b/s' }, ], } @@ -115,21 +115,21 @@ sub set_counters { $self->{maps_counters}->{global} = [ { label => 'server-traffic-in', set => { - key_values => [ { name => 'cacheServerInKb', diff => 1 } ], + key_values => [ { name => 'cacheServerInKb', per_second => 1 } ], output_template => 'traffic in : %s %s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { label => 'server_traffic_in', value => 'cacheServerInKb_per_second', template => '%s', + { label => 'server_traffic_in', template => '%s', min => 0, unit => 'b/s' }, ], } }, { label => 'server-traffic-out', set => { - key_values => [ { name => 'cacheServerOutKb', diff => 1 } ], + key_values => [ { name => 'cacheServerOutKb', per_second => 1 } ], output_template => 'traffic Out : %s %s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { label => 'server_traffic_out', value => 'cacheServerOutKb_per_second', template => '%s', + { label => 'server_traffic_out', template => '%s', min => 0, unit => 'b/s' }, ], } @@ -138,11 +138,10 @@ sub set_counters { key_values => [ { name => 'cacheClients' } ], output_template => 'current number of clients : %s', perfdatas => [ - { label => 'clients', value => 'cacheClients_absolute', template => '%s', - min => 0 }, - ], + { label => 'clients', template => '%s', min => 0 }, + ] } - }, + } ]; } @@ -171,7 +170,7 @@ sub new { $options{options}->add_options(arguments => { }); - + return $self; } diff --git a/apps/tomcat/jmx/mode/connectorusage.pm b/apps/tomcat/jmx/mode/connectorusage.pm index b04963209..412140f34 100644 --- a/apps/tomcat/jmx/mode/connectorusage.pm +++ b/apps/tomcat/jmx/mode/connectorusage.pm @@ -56,32 +56,31 @@ sub set_counters { key_values => [ { name => 'requestCount', diff => 1 }, { name => 'display' } ], output_template => 'Request Count : %s', perfdatas => [ - { label => 'request_count', value => 'requestCount_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'request_count', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'traffic-in', set => { - key_values => [ { name => 'bytesReceived', diff => 1 }, { name => 'display' } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'bytesReceived', per_second => 1 }, { name => 'display' } ], + output_change_bytes => 2, output_template => 'Traffic In : %s %s/s', perfdatas => [ - { label => 'traffic_in', value => 'bytesReceived_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_in', template => '%.2f', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'traffic-out', set => { - key_values => [ { name => 'bytesSent', diff => 1 }, { name => 'display' } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'bytesSent', per_second => 1 }, { name => 'display' } ], + output_change_bytes => 2, output_template => 'Traffic Out : %s %s/s', perfdatas => [ - { label => 'traffic_out', value => 'bytesSent_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_out', template => '%.2f', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } - }, - + } ]; } @@ -165,8 +164,8 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - "filter-name:s" => { name => 'filter_name' }, - "units:s" => { name => 'units', default => '%' }, + 'filter-name:s' => { name => 'filter_name' }, + 'units:s' => { name => 'units', default => '%' }, }); return $self; diff --git a/apps/tomcat/jmx/mode/webappssessions.pm b/apps/tomcat/jmx/mode/webappssessions.pm index 4f8f83d59..30659ec4b 100644 --- a/apps/tomcat/jmx/mode/webappssessions.pm +++ b/apps/tomcat/jmx/mode/webappssessions.pm @@ -47,8 +47,8 @@ sub set_counters { key_values => [ { name => 'sessionCounter', diff => 1 }, { name => 'display' } ], output_template => 'Sessions Count : %s', perfdatas => [ - { label => 'sessions_count', value => 'sessionCounter_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'sessions_count', value => 'sessionCounter', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/apps/tomcat/web/mode/applications.pm b/apps/tomcat/web/mode/applications.pm index 07db0afd2..c23cde3a9 100644 --- a/apps/tomcat/web/mode/applications.pm +++ b/apps/tomcat/web/mode/applications.pm @@ -54,8 +54,8 @@ sub set_counters { key_values => [ { name => 'sessions' }, { name => 'display' } ], output_template => 'active sessions: %s', perfdatas => [ - { value => 'sessions_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'sessions', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/apps/tomcat/web/mode/connectors.pm b/apps/tomcat/web/mode/connectors.pm index 578215cc9..0ae52cd92 100644 --- a/apps/tomcat/web/mode/connectors.pm +++ b/apps/tomcat/web/mode/connectors.pm @@ -38,10 +38,12 @@ sub custom_traffic_output { ($total_value, $total_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{speed}, network => 1); } - my $msg = sprintf("Traffic %s : %s/s (%s on %s)", - ucfirst($self->{result_values}->{label}), $traffic_value . $traffic_unit, - defined($self->{result_values}->{traffic_prct}) ? sprintf("%.2f%%", $self->{result_values}->{traffic_prct}) : '-', - defined($total_value) ? $total_value . $total_unit : '-'); + my $msg = sprintf( + "Traffic %s : %s/s (%s on %s)", + ucfirst($self->{result_values}->{label}), $traffic_value . $traffic_unit, + defined($self->{result_values}->{traffic_prct}) ? sprintf("%.2f%%", $self->{result_values}->{traffic_prct}) : '-', + defined($total_value) ? $total_value . $total_unit : '-' + ); return $msg; } @@ -73,7 +75,7 @@ sub set_counters { key_values => [ { name => 'currentThreadCount' }, { name => 'maxThreads' }, { name => 'display' } ], output_template => 'Threads Current : %s', perfdatas => [ - { label => 'threads_current', value => 'currentThreadCount_absolute', template => '%.2f', min => 0, max => 'maxThreads_absolute', + { label => 'threads_current', template => '%.2f', min => 0, max => 'maxThreads', label_extra_instance => 1 }, ], } @@ -82,14 +84,13 @@ sub set_counters { key_values => [ { name => 'currentThreadsBusy' }, { name => 'maxThreads' }, { name => 'display' } ], output_template => 'Threads Busy : %s', perfdatas => [ - { label => 'threads_busy', value => 'currentThreadsBusy_absolute', template => '%.2f', min => 0, max => 'maxThreads_absolute', + { label => 'threads_busy', template => '%.2f', min => 0, max => 'maxThreads', label_extra_instance => 1 }, ], } }, { label => 'traffic-in', nlabel => 'connector.traffic.in.bitspersecond', set => { key_values => [ { name => 'in', diff => 1 }, { name => 'display' } ], - per_second => 1, closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'in' }, closure_custom_output => $self->can('custom_traffic_output'), threshold_use => 'traffic', @@ -101,7 +102,6 @@ sub set_counters { }, { label => 'traffic-in-prct', display_ok => 0, nlabel => 'connector.traffic.in.percent', set => { key_values => [ { name => 'in', diff => 1 }, { name => 'display' } ], - per_second => 1, closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'in', type => 'prct' }, output_template => 'Traffic In Used : %.2f %%', output_use => 'traffic_prct', threshold_use => 'traffic_prct', @@ -113,7 +113,6 @@ sub set_counters { }, { label => 'traffic-out', nlabel => 'connector.traffic.out.bitspersecond', set => { key_values => [ { name => 'out', diff => 1 }, { name => 'display' } ], - per_second => 1, closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'out' }, closure_custom_output => $self->can('custom_traffic_output'), threshold_use => 'traffic', @@ -125,7 +124,6 @@ sub set_counters { }, { label => 'traffic-out-prct', display_ok => 0, nlabel => 'connector.traffic.out.percent', set => { key_values => [ { name => 'out', diff => 1 }, { name => 'display' } ], - per_second => 1, closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'out', type => 'prct' }, output_template => 'Traffic Out Used : %.2f %%', output_use => 'traffic_prct', threshold_use => 'traffic_prct', @@ -139,7 +137,7 @@ sub set_counters { key_values => [ { name => 'requestInfo_processingTime', diff => 1 }, { name => 'display' } ], output_template => 'Requests Total Processing Time : %s ms', perfdatas => [ - { label => 'requests_processingtime_total', value => 'requestInfo_processingTime_absolute', template => '%s', min => 0, + { label => 'requests_processingtime_total', template => '%s', min => 0, unit => 'ms', label_extra_instance => 1 }, ], } @@ -148,7 +146,7 @@ sub set_counters { key_values => [ { name => 'requestInfo_errorCount', diff => 1 }, { name => 'display' } ], output_template => 'Requests Errors : %s', perfdatas => [ - { label => 'requests_errors', value => 'requestInfo_errorCount_absolute', template => '%s', min => 0, + { label => 'requests_errors', template => '%s', min => 0, label_extra_instance => 1 }, ], } @@ -157,7 +155,7 @@ sub set_counters { key_values => [ { name => 'requestInfo_requestCount', diff => 1 }, { name => 'display' } ], output_template => 'Requests Total : %s', perfdatas => [ - { label => 'requests_total', value => 'requestInfo_requestCount_absolute', template => '%s', min => 0, + { label => 'requests_total', template => '%s', min => 0, label_extra_instance => 1 }, ], } diff --git a/apps/tomcat/web/mode/memory.pm b/apps/tomcat/web/mode/memory.pm index a6e112c14..edaf048cd 100644 --- a/apps/tomcat/web/mode/memory.pm +++ b/apps/tomcat/web/mode/memory.pm @@ -31,11 +31,11 @@ sub custom_memory_output { my ($self, %options) = @_; my $msg = sprintf("Memory Total: %s %s Used: %s %s (%.2f%%) Free: %s %s (%.2f%%)", - $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_absolute}), - $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_absolute}), - $self->{result_values}->{prct_used_absolute}, - $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute}), - $self->{result_values}->{prct_free_absolute}); + $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}), + $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}), + $self->{result_values}->{prct_used}, + $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}), + $self->{result_values}->{prct_free}); return $msg; } @@ -51,7 +51,7 @@ sub set_counters { key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], closure_custom_output => $self->can('custom_memory_output'), perfdatas => [ - { value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute', + { value => 'used', template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1 }, ], } @@ -60,7 +60,7 @@ sub set_counters { key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], closure_custom_output => $self->can('custom_memory_output'), perfdatas => [ - { value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute', + { value => 'free', template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1 }, ], } @@ -69,7 +69,7 @@ sub set_counters { key_values => [ { name => 'prct_used' } ], output_template => 'Memory Used : %.2f %%', perfdatas => [ - { value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, unit => '%' }, + { value => 'prct_used', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } }, diff --git a/apps/toshiba/storemate/sql/mode/posstatus.pm b/apps/toshiba/storemate/sql/mode/posstatus.pm index 5fc0c3511..43cf06b99 100644 --- a/apps/toshiba/storemate/sql/mode/posstatus.pm +++ b/apps/toshiba/storemate/sql/mode/posstatus.pm @@ -40,7 +40,7 @@ sub set_counters { key_values => [ { name => 'total' } ], output_template => 'total : %s', perfdatas => [ - { label => 'total', value => 'total_absolute', template => '%s', + { label => 'total', value => 'total', template => '%s', min => 0 }, ], } @@ -49,7 +49,7 @@ sub set_counters { key_values => [ { name => 'online' } ], output_template => 'online : %s', perfdatas => [ - { label => 'online', value => 'online_absolute', template => '%s', + { label => 'online', value => 'online', template => '%s', min => 0 }, ], } @@ -58,7 +58,7 @@ sub set_counters { key_values => [ { name => 'offline' } ], output_template => 'offline : %s', perfdatas => [ - { label => 'offline', value => 'offline_absolute', template => '%s', + { label => 'offline', value => 'offline', template => '%s', min => 0 }, ], } @@ -70,7 +70,7 @@ sub set_counters { key_values => [ { name => 'unknown' } ], output_template => 'unknown : %s', perfdatas => [ - { label => 'state_unknown', value => 'unknown_absolute', template => '%s', + { label => 'state_unknown', value => 'unknown', template => '%s', min => 0 }, ], } @@ -79,7 +79,7 @@ sub set_counters { key_values => [ { name => 'signoff' } ], output_template => 'signed off : %s', perfdatas => [ - { label => 'state_signoff', value => 'signoff_absolute', template => '%s', + { label => 'state_signoff', value => 'signoff', template => '%s', min => 0 }, ], } @@ -88,7 +88,7 @@ sub set_counters { key_values => [ { name => 'signon' } ], output_template => 'signed on : %s', perfdatas => [ - { label => 'state_signon', value => 'signon_absolute', template => '%s', + { label => 'state_signon', value => 'signon', template => '%s', min => 0 }, ], } @@ -97,7 +97,7 @@ sub set_counters { key_values => [ { name => 'closed' } ], output_template => 'closed : %s', perfdatas => [ - { label => 'state_closed', value => 'closed_absolute', template => '%s', + { label => 'state_closed', value => 'closed', template => '%s', min => 0 }, ], } @@ -106,7 +106,7 @@ sub set_counters { key_values => [ { name => 'paused' } ], output_template => 'paused : %s', perfdatas => [ - { label => 'state_paused', value => 'paused_absolute', template => '%s', + { label => 'state_paused', value => 'paused', template => '%s', min => 0 }, ], } @@ -118,7 +118,7 @@ sub set_counters { key_values => [ { name => 'unknown' } ], output_template => 'unknown : %s', perfdatas => [ - { label => 'merchandise_rep_unknown', value => 'unknown_absolute', template => '%s', + { label => 'merchandise_rep_unknown', value => 'unknown', template => '%s', min => 0 }, ], } @@ -127,7 +127,7 @@ sub set_counters { key_values => [ { name => 'ok' } ], output_template => 'ok : %s', perfdatas => [ - { label => 'merchandise_rep_ok', value => 'ok_absolute', template => '%s', + { label => 'merchandise_rep_ok', value => 'ok', template => '%s', min => 0 }, ], } @@ -136,7 +136,7 @@ sub set_counters { key_values => [ { name => 'suspended' } ], output_template => 'suspended : %s', perfdatas => [ - { label => 'merchandise_rep_suspended', value => 'suspended_absolute', template => '%s', + { label => 'merchandise_rep_suspended', value => 'suspended', template => '%s', min => 0 }, ], } @@ -145,7 +145,7 @@ sub set_counters { key_values => [ { name => 'error' } ], output_template => 'error : %s', perfdatas => [ - { label => 'merchandise_rep_error', value => 'error_absolute', template => '%s', + { label => 'merchandise_rep_error', value => 'error', template => '%s', min => 0 }, ], } @@ -157,7 +157,7 @@ sub set_counters { key_values => [ { name => 'unknown' } ], output_template => 'unknown : %s', perfdatas => [ - { label => 'transaction_rep_unknown', value => 'unknown_absolute', template => '%s', + { label => 'transaction_rep_unknown', value => 'unknown', template => '%s', min => 0 }, ], } @@ -166,7 +166,7 @@ sub set_counters { key_values => [ { name => 'ok' } ], output_template => 'ok : %s', perfdatas => [ - { label => 'transaction_rep_ok', value => 'ok_absolute', template => '%s', + { label => 'transaction_rep_ok', value => 'ok', template => '%s', min => 0 }, ], } @@ -175,7 +175,7 @@ sub set_counters { key_values => [ { name => 'suspended' } ], output_template => 'suspended : %s', perfdatas => [ - { label => 'transaction_rep_suspended', value => 'suspended_absolute', template => '%s', + { label => 'transaction_rep_suspended', value => 'suspended', template => '%s', min => 0 }, ], } @@ -184,7 +184,7 @@ sub set_counters { key_values => [ { name => 'error' } ], output_template => 'error : %s', perfdatas => [ - { label => 'transaction_rep_error', value => 'error_absolute', template => '%s', + { label => 'transaction_rep_error', value => 'error', template => '%s', min => 0 }, ], } diff --git a/apps/varnish/local/mode/stats.pm b/apps/varnish/local/mode/stats.pm index 2d6ebd296..b635c400f 100644 --- a/apps/varnish/local/mode/stats.pm +++ b/apps/varnish/local/mode/stats.pm @@ -30,27 +30,27 @@ sub configure_varnish_stats { my ($self, %options) = @_; $self->{varnish_stats} = [ - { entry => 'client_conn', nlabel => 'connections.client.accepted.persecond', display_ok => 1, diff => 1, per_second => 1 }, - { entry => 'client_drop', nlabel => 'connections.client.dropped.persecond', display_ok => 1, diff => 1, per_second => 1 }, - { entry => 'client_req', nlabel => 'connections.client.request.received.persecond', display_ok => 1, diff => 1, per_second => 1 }, - { entry => 'client_drop_late', nlabel => 'connections.client.dropped.late.persecond', display_ok => 0, diff => 1, per_second => 1 }, - { entry => 'client_req_400', nlabel => 'connections.client.request400.received.persecond', display_ok => 0, diff => 1, per_second => 1 }, - { entry => 'client_req_411', nlabel => 'connections.client.request411.received.persecond', display_ok => 0, diff => 1, per_second => 1 }, - { entry => 'client_req_413', nlabel => 'connections.client.request413.received.persecond', display_ok => 0, diff => 1, per_second => 1 }, - { entry => 'client_req_417', nlabel => 'connections.client.request417.received.persecond', display_ok => 0, diff => 1, per_second => 1 }, + { entry => 'client_conn', nlabel => 'connections.client.accepted.persecond', display_ok => 1, per_second => 1 }, + { entry => 'client_drop', nlabel => 'connections.client.dropped.persecond', display_ok => 1, per_second => 1 }, + { entry => 'client_req', nlabel => 'connections.client.request.received.persecond', display_ok => 1, per_second => 1 }, + { entry => 'client_drop_late', nlabel => 'connections.client.dropped.late.persecond', display_ok => 0, per_second => 1 }, + { entry => 'client_req_400', nlabel => 'connections.client.request400.received.persecond', display_ok => 0, per_second => 1 }, + { entry => 'client_req_411', nlabel => 'connections.client.request411.received.persecond', display_ok => 0, per_second => 1 }, + { entry => 'client_req_413', nlabel => 'connections.client.request413.received.persecond', display_ok => 0, per_second => 1 }, + { entry => 'client_req_417', nlabel => 'connections.client.request417.received.persecond', display_ok => 0, per_second => 1 }, - { entry => 'backend_conn', nlabel => 'backends.connections.success.persecond', display_ok => 0, diff => 1, per_second => 1 }, - { entry => 'backend_unhealthy', nlabel => 'backends.connections.unhealthy.persecond', display_ok => 0, diff => 1, per_second => 1 }, - { entry => 'backend_busy', nlabel => 'backends.connections.busy.persecond', display_ok => 0, diff => 1, per_second => 1 }, - { entry => 'backend_fail', nlabel => 'backends.connections.fail.persecond', display_ok => 0, diff => 1, per_second => 1 }, - { entry => 'backend_reuse', nlabel => 'backends.connections.reuse.persecond', display_ok => 0, diff => 1, per_second => 1 }, - { entry => 'backend_recycle', nlabel => 'backends.connections.recycle.persecond', display_ok => 0, diff => 1, per_second => 1 }, - { entry => 'backend_retry', nlabel => 'backends.connections.retry.persecond', display_ok => 0, diff => 1, per_second => 1 }, - { entry => 'backend_req', nlabel => 'backends.requests.persecond', display_ok => 0, diff => 1, per_second => 1 }, + { entry => 'backend_conn', nlabel => 'backends.connections.success.persecond', display_ok => 0, per_second => 1 }, + { entry => 'backend_unhealthy', nlabel => 'backends.connections.unhealthy.persecond', display_ok => 0, per_second => 1 }, + { entry => 'backend_busy', nlabel => 'backends.connections.busy.persecond', display_ok => 0, per_second => 1 }, + { entry => 'backend_fail', nlabel => 'backends.connections.fail.persecond', display_ok => 0, per_second => 1 }, + { entry => 'backend_reuse', nlabel => 'backends.connections.reuse.persecond', display_ok => 0, per_second => 1 }, + { entry => 'backend_recycle', nlabel => 'backends.connections.recycle.persecond', display_ok => 0, per_second => 1 }, + { entry => 'backend_retry', nlabel => 'backends.connections.retry.persecond', display_ok => 0, per_second => 1 }, + { entry => 'backend_req', nlabel => 'backends.requests.persecond', display_ok => 0, per_second => 1 }, - { entry => 'cache_hit', nlabel => 'cache.hit.persecond', display_ok => 0, diff => 1, per_second => 1 }, - { entry => 'cache_hitpass', nlabel => 'cache.hitpass.persecond', display_ok => 0, diff => 1, per_second => 1 }, - { entry => 'cache_miss', nlabel => 'cache.miss.persecond', display_ok => 0, diff => 1, per_second => 1 }, + { entry => 'cache_hit', nlabel => 'cache.hit.persecond', display_ok => 0, per_second => 1 }, + { entry => 'cache_hitpass', nlabel => 'cache.hitpass.persecond', display_ok => 0, per_second => 1 }, + { entry => 'cache_miss', nlabel => 'cache.miss.persecond', display_ok => 0, per_second => 1 }, { entry => 'n_sess_mem', nlabel => 'structure.session.memory.count', display_ok => 0 }, { entry => 'n_sess', nlabel => 'structure.session.count', display_ok => 0 }, @@ -66,53 +66,53 @@ sub configure_varnish_stats { { entry => 'n_lru_nuked', nlabel => 'object.lru.nuked.count', display_ok => 0 }, { entry => 'n_lru_moved', nlabel => 'object.lru.moved.count', display_ok => 0 }, - { entry => 'n_objsendfile', nlabel => 'object.sent.file.persecond', display_ok => 0, diff => 1, per_second => 1 }, - { entry => 'n_objwrite', nlabel => 'object.sent.write.persecond', display_ok => 0, diff => 1, per_second => 1 }, - { entry => 'n_objoverflow', nlabel => 'object.overflow.workspace.persecond', display_ok => 0, diff => 1, per_second => 1 }, + { entry => 'n_objsendfile', nlabel => 'object.sent.file.persecond', display_ok => 0, per_second => 1 }, + { entry => 'n_objwrite', nlabel => 'object.sent.write.persecond', display_ok => 0, per_second => 1 }, + { entry => 'n_objoverflow', nlabel => 'object.overflow.workspace.persecond', display_ok => 0, per_second => 1 }, - { entry => 'shm_records', nlabel => 'shm.records.persecond', display_ok => 0, diff => 1, per_second => 1 }, - { entry => 'shm_writes', nlabel => 'shm.writes.persecond', display_ok => 0, diff => 1, per_second => 1 }, - { entry => 'shm_flushes', nlabel => 'shm.flushes.persecond', display_ok => 0, diff => 1, per_second => 1 }, - { entry => 'shm_cont', nlabel => 'shm.contentions.persecond', display_ok => 0, diff => 1, per_second => 1 }, - { entry => 'shm_cycles', nlabel => 'shm.cycles.persecond', display_ok => 0, diff => 1, per_second => 1 }, + { entry => 'shm_records', nlabel => 'shm.records.persecond', display_ok => 0, per_second => 1 }, + { entry => 'shm_writes', nlabel => 'shm.writes.persecond', display_ok => 0, per_second => 1 }, + { entry => 'shm_flushes', nlabel => 'shm.flushes.persecond', display_ok => 0, per_second => 1 }, + { entry => 'shm_cont', nlabel => 'shm.contentions.persecond', display_ok => 0, per_second => 1 }, + { entry => 'shm_cycles', nlabel => 'shm.cycles.persecond', display_ok => 0, per_second => 1 }, - { entry => 'sms_nreq', nlabel => 'sms.allocator.requests.persecond', display_ok => 0, diff => 1, per_second => 1 }, + { entry => 'sms_nreq', nlabel => 'sms.allocator.requests.persecond', display_ok => 0, per_second => 1 }, { entry => 'sms_nobj', nlabel => 'sms.outstanding.allocations.count', display_ok => 0 }, { entry => 'sms_nbytes', nlabel => 'sms.outstanding.bytes', display_ok => 0, custom_output => $self->can('custom_output_scale_bytes') }, { entry => 'sms_balloc', nlabel => 'sms.outstanding.allocated.bytes', display_ok => 0, custom_output => $self->can('custom_output_scale_bytes') }, { entry => 'sms_bfree', nlabel => 'sms.outstanding.freed.bytes', display_ok => 0, custom_output => $self->can('custom_output_scale_bytes') }, - { entry => 'fetch_head', nlabel => 'fetch.head.persecond', display_ok => 0, diff => 1, per_second => 1 }, - { entry => 'fetch_length', nlabel => 'fetch.length.persecond', display_ok => 0, diff => 1, per_second => 1 }, - { entry => 'fetch_chunked', nlabel => 'fetch.chunked.persecond', display_ok => 0, diff => 1, per_second => 1 }, - { entry => 'fetch_eof', nlabel => 'fetch.eof.persecond', display_ok => 0, diff => 1, per_second => 1 }, - { entry => 'fetch_bad', nlabel => 'fetch.badheaders.persecond', display_ok => 0, diff => 1, per_second => 1 }, - { entry => 'fetch_close', nlabel => 'fetch.close.persecond', display_ok => 0, diff => 1, per_second => 1 }, - { entry => 'fetch_oldhttp', nlabel => 'fetch.oldhttp.persecond', display_ok => 0, diff => 1, per_second => 1 }, - { entry => 'fetch_zero', nlabel => 'fetch.zero.persecond', display_ok => 0, diff => 1, per_second => 1 }, - { entry => 'fetch_failed', nlabel => 'fetch.failed.persecond', display_ok => 0, diff => 1, per_second => 1 }, - { entry => 'fetch_1xx', nlabel => 'fetch.1xx.persecond', display_ok => 0, diff => 1, per_second => 1 }, - { entry => 'fetch_204', nlabel => 'fetch.204.persecond', display_ok => 0, diff => 1, per_second => 1 }, - { entry => 'fetch_304', nlabel => 'fetch.304.persecond', display_ok => 0, diff => 1, per_second => 1 }, + { entry => 'fetch_head', nlabel => 'fetch.head.persecond', display_ok => 0, per_second => 1 }, + { entry => 'fetch_length', nlabel => 'fetch.length.persecond', display_ok => 0, per_second => 1 }, + { entry => 'fetch_chunked', nlabel => 'fetch.chunked.persecond', display_ok => 0, per_second => 1 }, + { entry => 'fetch_eof', nlabel => 'fetch.eof.persecond', display_ok => 0, per_second => 1 }, + { entry => 'fetch_bad', nlabel => 'fetch.badheaders.persecond', display_ok => 0, per_second => 1 }, + { entry => 'fetch_close', nlabel => 'fetch.close.persecond', display_ok => 0, per_second => 1 }, + { entry => 'fetch_oldhttp', nlabel => 'fetch.oldhttp.persecond', display_ok => 0, per_second => 1 }, + { entry => 'fetch_zero', nlabel => 'fetch.zero.persecond', display_ok => 0, per_second => 1 }, + { entry => 'fetch_failed', nlabel => 'fetch.failed.persecond', display_ok => 0, per_second => 1 }, + { entry => 'fetch_1xx', nlabel => 'fetch.1xx.persecond', display_ok => 0, per_second => 1 }, + { entry => 'fetch_204', nlabel => 'fetch.204.persecond', display_ok => 0, per_second => 1 }, + { entry => 'fetch_304', nlabel => 'fetch.304.persecond', display_ok => 0, per_second => 1 }, { entry => 'n_ban', nlabel => 'ban.total.active.count', display_ok => 0 }, - { entry => 'n_ban_add', nlabel => 'ban.new.added.persecond', display_ok => 0, diff => 1, per_second => 1 }, - { entry => 'n_ban_retire', nlabel => 'ban.old.deleted.persecond', display_ok => 0, diff => 1, per_second => 1 }, - { entry => 'n_ban_obj_test', nlabel => 'ban.object.tested.persecond', display_ok => 0, diff => 1, per_second => 1 }, - { entry => 'n_ban_re_test', nlabel => 'ban.object.tested.regexp.persecond', display_ok => 0, diff => 1, per_second => 1 }, - { entry => 'n_ban_dups', nlabel => 'ban.duplicate.removed.persecond', display_ok => 0, diff => 1, per_second => 1 }, + { entry => 'n_ban_add', nlabel => 'ban.new.added.persecond', display_ok => 0, per_second => 1 }, + { entry => 'n_ban_retire', nlabel => 'ban.old.deleted.persecond', display_ok => 0, per_second => 1 }, + { entry => 'n_ban_obj_test', nlabel => 'ban.object.tested.persecond', display_ok => 0, per_second => 1 }, + { entry => 'n_ban_re_test', nlabel => 'ban.object.tested.regexp.persecond', display_ok => 0, per_second => 1 }, + { entry => 'n_ban_dups', nlabel => 'ban.duplicate.removed.persecond', display_ok => 0, per_second => 1 }, - { entry => 'dir_dns_lookups', nlabel => 'dns.director.lookups.persecond', display_ok => 0, diff => 1, per_second => 1 }, - { entry => 'dir_dns_failed', nlabel => 'dns.director.lookups.failed.persecond', display_ok => 0, diff => 1, per_second => 1 }, - { entry => 'dir_dns_hit', nlabel => 'dns.director.lookups.cachehit.persecond', display_ok => 0, diff => 1, per_second => 1 }, - { entry => 'dir_dns_cache_full', nlabel => 'dns.director.cache.full.persecond', display_ok => 0, diff => 1, per_second => 1 }, + { entry => 'dir_dns_lookups', nlabel => 'dns.director.lookups.persecond', display_ok => 0, per_second => 1 }, + { entry => 'dir_dns_failed', nlabel => 'dns.director.lookups.failed.persecond', display_ok => 0, per_second => 1 }, + { entry => 'dir_dns_hit', nlabel => 'dns.director.lookups.cachehit.persecond', display_ok => 0, per_second => 1 }, + { entry => 'dir_dns_cache_full', nlabel => 'dns.director.cache.full.persecond', display_ok => 0, per_second => 1 }, - { entry => 'esi_errors', nlabel => 'esi.parse.errors.persecond', display_ok => 0, diff => 1, per_second => 1 }, - { entry => 'esi_warnings', nlabel => 'esi.parse.warnings.persecond', display_ok => 0, diff => 1, per_second => 1 }, + { entry => 'esi_errors', nlabel => 'esi.parse.errors.persecond', display_ok => 0, per_second => 1 }, + { entry => 'esi_warnings', nlabel => 'esi.parse.warnings.persecond', display_ok => 0, per_second => 1 }, - { entry => 'hcb_nolock', nlabel => 'hck.lookups.nolock.persecond', display_ok => 0, diff => 1, per_second => 1 }, - { entry => 'hcb_lock', nlabel => 'hck.lookups.lock.persecond', display_ok => 0, diff => 1, per_second => 1 }, - { entry => 'hcb_insert', nlabel => 'hck.inserts.persecond', display_ok => 0, diff => 1, per_second => 1 }, + { entry => 'hcb_nolock', nlabel => 'hck.lookups.nolock.persecond', display_ok => 0, per_second => 1 }, + { entry => 'hcb_lock', nlabel => 'hck.lookups.lock.persecond', display_ok => 0, per_second => 1 }, + { entry => 'hcb_insert', nlabel => 'hck.inserts.persecond', display_ok => 0, per_second => 1 }, { entry => 'n_vcl', nlabel => 'vlc.total.count', display_ok => 0, diff => 1 }, { entry => 'n_vcl_avail', nlabel => 'vlc.available.count', display_ok => 0, diff => 1 }, @@ -147,7 +147,7 @@ sub configure_varnish_stats { { entry => 'n_wrk_max', nlabel => 'workers.threads.limited.count', display_ok => 0, diff => 1 }, { entry => 'n_wrk_lqueue', nlabel => 'workers.requests.queue.length.count', display_ok => 0, diff => 1 }, { entry => 'n_wrk_queued', nlabel => 'workers.requests.queued.count', display_ok => 0, diff => 1 }, - { entry => 'n_wrk_drop', nlabel => 'workers.requests.dropped.count', display_ok => 0, diff => 1 }, + { entry => 'n_wrk_drop', nlabel => 'workers.requests.dropped.count', display_ok => 0, diff => 1 } ]; } @@ -156,9 +156,8 @@ sub custom_output_scale_bytes { my $label = $self->{label}; $label =~ s/-/_/g; - my ($value, $unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{$label . '_absolute'}); - my $msg = sprintf('%s: %.2f %s', $self->{result_values}->{$label . '_description_absolute'}, $value, $unit); - return $msg; + my ($value, $unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{$label }); + return sprintf('%s: %.2f %s', $self->{result_values}->{$label . '_description'}, $value, $unit); } sub custom_output_second { @@ -166,7 +165,7 @@ sub custom_output_second { my $label = $self->{label}; $label =~ s/-/_/g; - my $msg = sprintf('%s: %.2f/s', $self->{result_values}->{$label . '_description_absolute'}, $self->{result_values}->{$label . '_per_second'}); + my $msg = sprintf('%s: %.2f/s', $self->{result_values}->{$label . '_description'}, $self->{result_values}->{$label}); return $msg; } @@ -175,7 +174,7 @@ sub custom_output { my $label = $self->{label}; $label =~ s/-/_/g; - my $msg = sprintf('%s: %s', $self->{result_values}->{$label . '_description_absolute'}, $self->{result_values}->{$label . '_absolute'}); + my $msg = sprintf('%s: %s', $self->{result_values}->{$label . '_description'}, $self->{result_values}->{$label }); return $msg; } @@ -185,7 +184,7 @@ sub set_counters { $self->configure_varnish_stats(); $self->{maps_counters_type} = [ - { name => 'global', type => 0, skipped_code => { -10 => 1 } }, + { name => 'global', type => 0, skipped_code => { -10 => 1 } } ]; $self->{maps_counters}->{global} = []; @@ -194,12 +193,11 @@ sub set_counters { $label =~ s/_/-/g; push @{$self->{maps_counters}->{global}}, { label => $label, nlabel => $_->{nlabel}, display_ok => $_->{display_ok}, set => { - key_values => [ { name => $_->{entry}, diff => $_->{diff} }, { name => $_->{entry}. '_description' } ], + key_values => [ { name => $_->{entry}, diff => $_->{diff}, per_second => $_->{per_second} }, { name => $_->{entry}. '_description' } ], closure_custom_output => defined($_->{custom_output}) ? $_->{custom_output} : (defined($_->{per_second}) ? $self->can('custom_output_second') : $self->can('custom_output')), - per_second => $_->{per_second}, perfdatas => [ - { label => $_->{entry}, value => $_->{entry} . (defined($_->{per_second}) ? '_per_second' : '_absolute'), + { label => $_->{entry}, template => defined($_->{per_second}) ? '%.2f' : '%s', min => 0 }, ], @@ -224,7 +222,7 @@ sub new { 'sudo' => { name => 'sudo' }, 'command:s' => { name => 'command', default => 'varnishstat' }, 'command-path:s' => { name => 'command_path', default => '/usr/bin' }, - 'command-options:s' => { name => 'command_options', default => ' -1 -j 2>&1' }, + 'command-options:s' => { name => 'command_options', default => ' -1 -j 2>&1' } }); return $self; diff --git a/apps/video/openheadend/snmp/mode/nodeusage.pm b/apps/video/openheadend/snmp/mode/nodeusage.pm index 801ac4e45..3a7e3aaed 100644 --- a/apps/video/openheadend/snmp/mode/nodeusage.pm +++ b/apps/video/openheadend/snmp/mode/nodeusage.pm @@ -62,8 +62,8 @@ sub set_counters { output_template => 'bitRate : %s %s/s', output_change_bytes => 2, perfdatas => [ - { label => 'bitrate', value => 'nodeBitrate_absolute', template => '%d', - unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'bitrate', value => 'nodeBitrate', template => '%d', + unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/apps/video/zixi/restapi/mode/broadcasterinputusage.pm b/apps/video/zixi/restapi/mode/broadcasterinputusage.pm index f62ba7ce7..061b9f7ab 100644 --- a/apps/video/zixi/restapi/mode/broadcasterinputusage.pm +++ b/apps/video/zixi/restapi/mode/broadcasterinputusage.pm @@ -61,25 +61,25 @@ sub set_counters { } }, { label => 'traffic-in', set => { - key_values => [ { name => 'traffic_in', diff => 1 }, { name => 'source' } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'traffic_in', per_second => 1 }, { name => 'source' } ], + output_change_bytes => 2, output_template => 'Traffic In : %s %s/s', perfdatas => [ - { label => 'traffic_in', value => 'traffic_in_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'source_absolute' }, + { label => 'traffic_in', template => '%.2f', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'source' }, ], } }, { label => 'traffic-out', set => { - key_values => [ { name => 'traffic_out', diff => 1 }, { name => 'source' } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'traffic_out', per_second => 1 }, { name => 'source' } ], + output_change_bytes => 2, output_template => 'Traffic Out : %s %s/s', perfdatas => [ - { label => 'traffic_out', value => 'traffic_out_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'source_absolute' }, - ], + { label => 'traffic_out', template => '%.2f', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'source' }, + ] } - }, + } ]; } @@ -88,13 +88,12 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-source:s" => { name => 'filter_source' }, - "warning-status:s" => { name => 'warning_status' }, - "critical-status:s" => { name => 'critical_status', default => '%{status} !~ /Connecting|Connected/i || %{error} !~ /none/i' }, - }); - + $options{options}->add_options(arguments => { + 'filter-source:s' => { name => 'filter_source' }, + 'warning-status:s' => { name => 'warning_status' }, + 'critical-status:s' => { name => 'critical_status', default => '%{status} !~ /Connecting|Connected/i || %{error} !~ /none/i' }, + }); + return $self; } diff --git a/apps/video/zixi/restapi/mode/broadcasteroutputusage.pm b/apps/video/zixi/restapi/mode/broadcasteroutputusage.pm index 10d74f706..35fd76a5e 100644 --- a/apps/video/zixi/restapi/mode/broadcasteroutputusage.pm +++ b/apps/video/zixi/restapi/mode/broadcasteroutputusage.pm @@ -57,38 +57,38 @@ sub set_counters { closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => \&catalog_status_threshold, + closure_custom_threshold_check => \&catalog_status_threshold } }, { label => 'traffic-in', set => { - key_values => [ { name => 'traffic_in', diff => 1 }, { name => 'name' } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'traffic_in', per_second => 1 }, { name => 'name' } ], + output_change_bytes => 2, output_template => 'Traffic In : %s %s/s', perfdatas => [ - { label => 'traffic_in', value => 'traffic_in_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'name_absolute' }, - ], + { label => 'traffic_in', template => '%.2f', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'name' } + ] } }, { label => 'traffic-out', set => { - key_values => [ { name => 'traffic_out', diff => 1 }, { name => 'name' } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'traffic_out', per_second => 1 }, { name => 'name' } ], + output_change_bytes => 2, output_template => 'Traffic Out : %s %s/s', perfdatas => [ - { label => 'traffic_out', value => 'traffic_out_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'name_absolute' }, - ], + { label => 'traffic_out', template => '%.2f', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'name' } + ] } }, { label => 'dropped-in', set => { key_values => [ { name => 'dropped_in', diff => 1 }, { name => 'name' } ], output_template => 'Packets Dropped In : %s', perfdatas => [ - { label => 'dropped_in', value => 'dropped_in_absolute', template => '%.2f', - min => 0, label_extra_instance => 1, instance_use => 'name_absolute' }, - ], + { label => 'dropped_in', template => '%.2f', + min => 0, label_extra_instance => 1, instance_use => 'name' } + ] } - }, + } ]; } @@ -97,13 +97,12 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - "warning-status:s" => { name => 'warning_status' }, - "critical-status:s" => { name => 'critical_status', default => '%{status} !~ /Connecting|Connected/i || %{error} !~ /none/i' }, - }); - + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' }, + 'warning-status:s' => { name => 'warning_status' }, + 'critical-status:s' => { name => 'critical_status', default => '%{status} !~ /Connecting|Connected/i || %{error} !~ /none/i' }, + }); + return $self; } diff --git a/apps/video/zixi/restapi/mode/broadcastersystemusage.pm b/apps/video/zixi/restapi/mode/broadcastersystemusage.pm index d02ebc931..31fcecfb8 100644 --- a/apps/video/zixi/restapi/mode/broadcastersystemusage.pm +++ b/apps/video/zixi/restapi/mode/broadcastersystemusage.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'cpu_load' } ], output_template => 'Cpu Load : %.2f %%', perfdatas => [ - { label => 'cpu_load', value => 'cpu_load_absolute', template => '%.2f', + { label => 'cpu_load', value => 'cpu_load', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'memory_used' } ], output_template => 'Memory Used : %.2f %%', perfdatas => [ - { label => 'memory_used', value => 'memory_used_absolute', template => '%.2f', + { label => 'memory_used', value => 'memory_used', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } @@ -55,7 +55,7 @@ sub set_counters { key_values => [ { name => 'disk_used' } ], output_template => 'Disk Used : %.2f %%', perfdatas => [ - { label => 'disk_used', value => 'disk_used_absolute', template => '%.2f', + { label => 'disk_used', value => 'disk_used', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } diff --git a/apps/video/zixi/restapi/mode/feederinputusage.pm b/apps/video/zixi/restapi/mode/feederinputusage.pm index 9fb0441e5..4ca0fa7d9 100644 --- a/apps/video/zixi/restapi/mode/feederinputusage.pm +++ b/apps/video/zixi/restapi/mode/feederinputusage.pm @@ -57,19 +57,19 @@ sub set_counters { closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => $self->can('custom_status_threshold'), + closure_custom_threshold_check => $self->can('custom_status_threshold') } }, - { label => 'traffic-in', set => { - key_values => [ { name => 'traffic_in', diff => 1 }, { name => 'name' } ], - per_second => 1, output_change_bytes => 2, + { label => 'traffic-in', set => { + key_values => [ { name => 'traffic_in', per_second => 1 }, { name => 'name' } ], + output_change_bytes => 2, output_template => 'Traffic In : %s %s/s', perfdatas => [ - { label => 'traffic_in', value => 'traffic_in_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'name_absolute' }, - ], + { label => 'traffic_in', template => '%.2f', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'name' } + ] } - }, + } ]; } @@ -78,13 +78,12 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - "warning-status:s" => { name => 'warning_status' }, - "critical-status:s" => { name => 'critical_status' }, - }); - + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' }, + 'warning-status:s' => { name => 'warning_status' }, + 'critical-status:s' => { name => 'critical_status' } + }); + return $self; } diff --git a/apps/video/zixi/restapi/mode/feederoutputusage.pm b/apps/video/zixi/restapi/mode/feederoutputusage.pm index 846b3ea83..239cff2b8 100644 --- a/apps/video/zixi/restapi/mode/feederoutputusage.pm +++ b/apps/video/zixi/restapi/mode/feederoutputusage.pm @@ -66,8 +66,8 @@ sub set_counters { output_change_bytes => 2, output_template => 'Current Bitrate : %s %s/s', perfdatas => [ - { label => 'current_bitrate', value => 'bitrate_absolute', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'name_absolute' }, + { label => 'current_bitrate', value => 'bitrate', template => '%.2f', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'name' }, ], } }, diff --git a/apps/virtualization/ovirt/mode/cpuhost.pm b/apps/virtualization/ovirt/mode/cpuhost.pm index 29a2cbddd..8bdc2b6fa 100644 --- a/apps/virtualization/ovirt/mode/cpuhost.pm +++ b/apps/virtualization/ovirt/mode/cpuhost.pm @@ -37,8 +37,8 @@ sub set_counters { key_values => [ { name => 'user' }, { name => 'display' } ], output_template => 'user: %.2f %%', perfdatas => [ - { value => 'user_absolute', template => '%.2f', unit => '%', - min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'user', template => '%.2f', unit => '%', + min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -46,8 +46,8 @@ sub set_counters { key_values => [ { name => 'system' }, { name => 'display' } ], output_template => 'system: %.2f %%', perfdatas => [ - { value => 'system_absolute', template => '%.2f', unit => '%', - min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'system', template => '%.2f', unit => '%', + min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/apps/vmware/connector/mode/alarmdatacenter.pm b/apps/vmware/connector/mode/alarmdatacenter.pm index 2201ad77d..5dc2b828c 100644 --- a/apps/vmware/connector/mode/alarmdatacenter.pm +++ b/apps/vmware/connector/mode/alarmdatacenter.pm @@ -128,7 +128,7 @@ sub set_counters { key_values => [ { name => 'yellow' } ], output_template => '%s warning alarm(s) found(s)', perfdatas => [ - { label => 'total_alarm_warning', value => 'yellow_absolute', template => '%s', min => 0 }, + { label => 'total_alarm_warning', value => 'yellow', template => '%s', min => 0 }, ], } }, @@ -136,7 +136,7 @@ sub set_counters { key_values => [ { name => 'red' } ], output_template => '%s critical alarm(s) found(s)', perfdatas => [ - { label => 'total_alarm_critical', value => 'red_absolute', template => '%s', min => 0 }, + { label => 'total_alarm_critical', value => 'red', template => '%s', min => 0 }, ], } }, diff --git a/apps/vmware/connector/mode/alarmhost.pm b/apps/vmware/connector/mode/alarmhost.pm index deaf33907..708524b5e 100644 --- a/apps/vmware/connector/mode/alarmhost.pm +++ b/apps/vmware/connector/mode/alarmhost.pm @@ -127,7 +127,7 @@ sub set_counters { key_values => [ { name => 'yellow' } ], output_template => '%s warning alarm(s) found(s)', perfdatas => [ - { label => 'total_alarm_warning', value => 'yellow_absolute', template => '%s', min => 0 }, + { label => 'total_alarm_warning', value => 'yellow', template => '%s', min => 0 }, ], } }, @@ -135,7 +135,7 @@ sub set_counters { key_values => [ { name => 'red' } ], output_template => '%s critical alarm(s) found(s)', perfdatas => [ - { label => 'total_alarm_critical', value => 'red_absolute', template => '%s', min => 0 }, + { label => 'total_alarm_critical', value => 'red', template => '%s', min => 0 }, ], } }, diff --git a/apps/vmware/connector/mode/countvmhost.pm b/apps/vmware/connector/mode/countvmhost.pm index 9b2878e27..645042ed4 100644 --- a/apps/vmware/connector/mode/countvmhost.pm +++ b/apps/vmware/connector/mode/countvmhost.pm @@ -52,8 +52,8 @@ sub set_counters { key_values => [ { name => 'poweredon' }, { name => 'total' } ], output_template => '%s VM(s) poweredon', perfdatas => [ - { label => 'poweredon', value => 'poweredon_absolute', template => '%s', - min => 0, max => 'total_absolute' } + { label => 'poweredon', value => 'poweredon', template => '%s', + min => 0, max => 'total' } ] } }, @@ -61,8 +61,8 @@ sub set_counters { key_values => [ { name => 'poweredoff' }, { name => 'total' } ], output_template => '%s VM(s) poweredoff', perfdatas => [ - { label => 'poweredoff', value => 'poweredoff_absolute', template => '%s', - min => 0, max => 'total_absolute' } + { label => 'poweredoff', value => 'poweredoff', template => '%s', + min => 0, max => 'total' } ] } }, @@ -70,8 +70,8 @@ sub set_counters { key_values => [ { name => 'suspended' }, { name => 'total' } ], output_template => '%s VM(s) suspended', perfdatas => [ - { label => 'suspended', value => 'suspended_absolute', template => '%s', - min => 0, max => 'total_absolute' } + { label => 'suspended', value => 'suspended', template => '%s', + min => 0, max => 'total' } ] } }, @@ -90,8 +90,8 @@ sub set_counters { key_values => [ { name => 'poweredon' }, { name => 'total' } ], output_template => '%s VM(s) poweredon', perfdatas => [ - { label => 'poweredon', value => 'poweredon_absolute', template => '%s', - min => 0, max => 'total_absolute', label_extra_instance => 1 } + { label => 'poweredon', value => 'poweredon', template => '%s', + min => 0, max => 'total', label_extra_instance => 1 } ] } }, @@ -99,8 +99,8 @@ sub set_counters { key_values => [ { name => 'poweredoff' }, { name => 'total' } ], output_template => '%s VM(s) poweredoff', perfdatas => [ - { label => 'poweredoff', value => 'poweredoff_absolute', template => '%s', - min => 0, max => 'total_absolute', label_extra_instance => 1 } + { label => 'poweredoff', value => 'poweredoff', template => '%s', + min => 0, max => 'total', label_extra_instance => 1 } ] } }, @@ -108,8 +108,8 @@ sub set_counters { key_values => [ { name => 'suspended' }, { name => 'total' } ], output_template => '%s VM(s) suspended', perfdatas => [ - { label => 'suspended', value => 'suspended_absolute', template => '%s', - min => 0, max => 'total_absolute', label_extra_instance => 1 } + { label => 'suspended', value => 'suspended', template => '%s', + min => 0, max => 'total', label_extra_instance => 1 } ] } } diff --git a/apps/vmware/connector/mode/cpuhost.pm b/apps/vmware/connector/mode/cpuhost.pm index adcc66c51..08f9efa19 100644 --- a/apps/vmware/connector/mode/cpuhost.pm +++ b/apps/vmware/connector/mode/cpuhost.pm @@ -69,7 +69,7 @@ sub set_counters { key_values => [ { name => 'cpu_average' } ], output_template => '%s %%', perfdatas => [ - { label => 'cpu_total', value => 'cpu_average_absolute', template => '%s', unit => '%', + { label => 'cpu_total', value => 'cpu_average', template => '%s', unit => '%', min => 0, max => 100, label_extra_instance => 1 }, ], } @@ -78,8 +78,8 @@ sub set_counters { key_values => [ { name => 'cpu_average_mhz' }, { name => 'cpu_average_mhz_max' } ], output_template => '%s MHz', perfdatas => [ - { label => 'cpu_total_MHz', value => 'cpu_average_mhz_absolute', template => '%s', unit => 'MHz', - min => 0, max => 'cpu_average_mhz_max_absolute', label_extra_instance => 1 }, + { label => 'cpu_total_MHz', value => 'cpu_average_mhz', template => '%s', unit => 'MHz', + min => 0, max => 'cpu_average_mhz_max', label_extra_instance => 1 }, ], } }, @@ -90,7 +90,7 @@ sub set_counters { key_values => [ { name => 'cpu_usage' }, { name => 'display' } ], output_template => 'usage : %s', perfdatas => [ - { label => 'cpu', value => 'cpu_usage_absolute', template => '%s', unit => '%', + { label => 'cpu', value => 'cpu_usage', template => '%s', unit => '%', min => 0, max => 100, label_extra_instance => 1 }, ], } diff --git a/apps/vmware/connector/mode/cpuvm.pm b/apps/vmware/connector/mode/cpuvm.pm index fdfb7ab6e..6c7712633 100644 --- a/apps/vmware/connector/mode/cpuvm.pm +++ b/apps/vmware/connector/mode/cpuvm.pm @@ -70,7 +70,7 @@ sub set_counters { key_values => [ { name => 'cpu_average' } ], output_template => '%s %%', perfdatas => [ - { label => 'cpu_total', value => 'cpu_average_absolute', template => '%s', unit => '%', + { label => 'cpu_total', value => 'cpu_average', template => '%s', unit => '%', min => 0, max => 100, label_extra_instance => 1 }, ], } @@ -79,7 +79,7 @@ sub set_counters { key_values => [ { name => 'cpu_average_mhz' } ], output_template => '%s MHz', perfdatas => [ - { label => 'cpu_total_MHz', value => 'cpu_average_mhz_absolute', template => '%s', unit => 'MHz', + { label => 'cpu_total_MHz', value => 'cpu_average_mhz', template => '%s', unit => 'MHz', min => 0, label_extra_instance => 1 }, ], } @@ -88,7 +88,7 @@ sub set_counters { key_values => [ { name => 'cpu_ready' } ], output_template => 'ready %s %%', perfdatas => [ - { label => 'cpu_ready', value => 'cpu_ready_absolute', template => '%s', unit => '%', + { label => 'cpu_ready', value => 'cpu_ready', template => '%s', unit => '%', min => 0, max => 100, label_extra_instance => 1 }, ], } @@ -100,7 +100,7 @@ sub set_counters { key_values => [ { name => 'cpu_usage' }, { name => 'display' } ], output_template => 'usage : %s MHz', perfdatas => [ - { label => 'cpu', value => 'cpu_usage_absolute', template => '%s', unit => 'MHz', + { label => 'cpu', value => 'cpu_usage', template => '%s', unit => 'MHz', min => 0, label_extra_instance => 1 }, ], } diff --git a/apps/vmware/connector/mode/datastorecountvm.pm b/apps/vmware/connector/mode/datastorecountvm.pm index 0381b115a..72a95d4f3 100644 --- a/apps/vmware/connector/mode/datastorecountvm.pm +++ b/apps/vmware/connector/mode/datastorecountvm.pm @@ -54,8 +54,8 @@ sub set_counters { key_values => [ { name => 'poweredon' }, { name => 'total' } ], output_template => '%s VM(s) poweredon', perfdatas => [ - { label => 'poweredon', value => 'poweredon_absolute', template => '%s', - min => 0, max => 'total_absolute' }, + { label => 'poweredon', value => 'poweredon', template => '%s', + min => 0, max => 'total' }, ], } }, @@ -63,8 +63,8 @@ sub set_counters { key_values => [ { name => 'poweredoff' }, { name => 'total' } ], output_template => '%s VM(s) poweredoff', perfdatas => [ - { label => 'poweredoff', value => 'poweredoff_absolute', template => '%s', - min => 0, max => 'total_absolute' }, + { label => 'poweredoff', value => 'poweredoff', template => '%s', + min => 0, max => 'total' }, ], } }, @@ -72,8 +72,8 @@ sub set_counters { key_values => [ { name => 'suspended' }, { name => 'total' } ], output_template => '%s VM(s) suspended', perfdatas => [ - { label => 'suspended', value => 'suspended_absolute', template => '%s', - min => 0, max => 'total_absolute' }, + { label => 'suspended', value => 'suspended', template => '%s', + min => 0, max => 'total' }, ], } }, @@ -92,8 +92,8 @@ sub set_counters { key_values => [ { name => 'poweredon' }, { name => 'total' } ], output_template => '%s VM(s) poweredon', perfdatas => [ - { label => 'poweredon', value => 'poweredon_absolute', template => '%s', - min => 0, max => 'total_absolute', label_extra_instance => 1 }, + { label => 'poweredon', value => 'poweredon', template => '%s', + min => 0, max => 'total', label_extra_instance => 1 }, ], } }, @@ -101,8 +101,8 @@ sub set_counters { key_values => [ { name => 'poweredoff' }, { name => 'total' } ], output_template => '%s VM(s) poweredoff', perfdatas => [ - { label => 'poweredoff', value => 'poweredoff_absolute', template => '%s', - min => 0, max => 'total_absolute', label_extra_instance => 1 }, + { label => 'poweredoff', value => 'poweredoff', template => '%s', + min => 0, max => 'total', label_extra_instance => 1 }, ], } }, @@ -110,8 +110,8 @@ sub set_counters { key_values => [ { name => 'suspended' }, { name => 'total' } ], output_template => '%s VM(s) suspended', perfdatas => [ - { label => 'suspended', value => 'suspended_absolute', template => '%s', - min => 0, max => 'total_absolute', label_extra_instance => 1 }, + { label => 'suspended', value => 'suspended', template => '%s', + min => 0, max => 'total', label_extra_instance => 1 }, ], } }, diff --git a/apps/vmware/connector/mode/datastorehost.pm b/apps/vmware/connector/mode/datastorehost.pm index 214cdc7fa..0e25fdd74 100644 --- a/apps/vmware/connector/mode/datastorehost.pm +++ b/apps/vmware/connector/mode/datastorehost.pm @@ -69,7 +69,7 @@ sub set_counters { key_values => [ { name => 'read_latency' }, { name => 'display' } ], output_template => 'read : %s ms', perfdatas => [ - { label => 'trl', value => 'read_latency_absolute', template => '%s', unit => 'ms', + { label => 'trl', value => 'read_latency', template => '%s', unit => 'ms', min => 0, label_extra_instance => 1 }, ], } @@ -78,7 +78,7 @@ sub set_counters { key_values => [ { name => 'write_latency' }, { name => 'display' } ], output_template => 'write : %s ms', perfdatas => [ - { label => 'twl', value => 'write_latency_absolute', template => '%s', unit => 'ms', + { label => 'twl', value => 'write_latency', template => '%s', unit => 'ms', min => 0, label_extra_instance => 1 }, ], } diff --git a/apps/vmware/connector/mode/datastoreio.pm b/apps/vmware/connector/mode/datastoreio.pm index edeb13e31..b8db9e28a 100644 --- a/apps/vmware/connector/mode/datastoreio.pm +++ b/apps/vmware/connector/mode/datastoreio.pm @@ -54,7 +54,7 @@ sub set_counters { output_template => 'Total rate of reading data: %s %s/s', output_change_bytes => 1, perfdatas => [ - { label => 'total_read_rate', value => 'read_absolute', template => '%s', + { label => 'total_read_rate', value => 'read', template => '%s', unit => 'B/s', min => 0 }, ], } @@ -64,7 +64,7 @@ sub set_counters { output_template => 'Total rate of writing data: %s %s/s', output_change_bytes => 1, perfdatas => [ - { label => 'total_write_rate', value => 'write_absolute', template => '%s', + { label => 'total_write_rate', value => 'write', template => '%s', unit => 'B/s', min => 0 }, ], } @@ -85,7 +85,7 @@ sub set_counters { output_template => 'rate of reading data: %s %s/s', output_change_bytes => 1, perfdatas => [ - { label => 'read_rate', value => 'read_absolute', template => '%s', + { label => 'read_rate', value => 'read', template => '%s', unit => 'B/s', min => 0, label_extra_instance => 1 }, ], } @@ -95,7 +95,7 @@ sub set_counters { output_template => 'rate of writing data: %s %s/s', output_change_bytes => 1, perfdatas => [ - { label => 'write_rate', value => 'write_absolute', template => '%s', + { label => 'write_rate', value => 'write', template => '%s', unit => 'B/s', min => 0, label_extra_instance => 1 }, ], } diff --git a/apps/vmware/connector/mode/datastoreiops.pm b/apps/vmware/connector/mode/datastoreiops.pm index 1a0b2c3b7..776cfae85 100644 --- a/apps/vmware/connector/mode/datastoreiops.pm +++ b/apps/vmware/connector/mode/datastoreiops.pm @@ -70,7 +70,7 @@ sub set_counters { key_values => [ { name => 'read' } ], output_template => '%s read iops', perfdatas => [ - { label => 'riops', value => 'read_absolute', template => '%s', unit => 'iops', + { label => 'riops', value => 'read', template => '%s', unit => 'iops', min => 0, label_extra_instance => 1 }, ], } @@ -79,8 +79,8 @@ sub set_counters { key_values => [ { name => 'write' } ], output_template => '%s write iops', perfdatas => [ - { label => 'wiops', value => 'write_absolute', template => '%s', unit => 'iops', - min => 0, max => 'write_absolute', label_extra_instance => 1 }, + { label => 'wiops', value => 'write', template => '%s', unit => 'iops', + min => 0, max => 'write', label_extra_instance => 1 }, ], } }, @@ -91,7 +91,7 @@ sub set_counters { key_values => [ { name => 'read' } ], output_template => '%s read iops', perfdatas => [ - { label => 'vm_riops', value => 'read_absolute', template => '%s', unit => 'iops', + { label => 'vm_riops', value => 'read', template => '%s', unit => 'iops', min => 0, label_extra_instance => 1 }, ], } @@ -100,8 +100,8 @@ sub set_counters { key_values => [ { name => 'write' } ], output_template => '%s write iops', perfdatas => [ - { label => 'vm_wiops', value => 'write_absolute', template => '%s', unit => 'iops', - min => 0, max => 'write_absolute', label_extra_instance => 1 }, + { label => 'vm_wiops', value => 'write', template => '%s', unit => 'iops', + min => 0, max => 'write', label_extra_instance => 1 }, ], } }, diff --git a/apps/vmware/connector/mode/datastoresnapshot.pm b/apps/vmware/connector/mode/datastoresnapshot.pm index 0f1e38b02..0055afb9f 100644 --- a/apps/vmware/connector/mode/datastoresnapshot.pm +++ b/apps/vmware/connector/mode/datastoresnapshot.pm @@ -71,7 +71,7 @@ sub set_counters { output_template => 'total snapshots [size = %s %s]', output_change_bytes => 1, perfdatas => [ - { label => 'total_size', value => 'total_absolute', template => '%s', unit => 'B', + { label => 'total_size', value => 'total', template => '%s', unit => 'B', min => 0, label_extra_instance => 1 }, ], } diff --git a/apps/vmware/connector/mode/datastoreusage.pm b/apps/vmware/connector/mode/datastoreusage.pm index a5edae08b..d60959c89 100644 --- a/apps/vmware/connector/mode/datastoreusage.pm +++ b/apps/vmware/connector/mode/datastoreusage.pm @@ -43,14 +43,14 @@ sub custom_status_calc { sub custom_usage_output { my ($self, %options) = @_; - my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_space_absolute}); - my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_space_absolute}); - my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_space_absolute}); + my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_space}); + my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_space}); + my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_space}); my $msg = sprintf( 'Usage Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)', $total_size_value . " " . $total_size_unit, - $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used_space_absolute}, - $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free_space_absolute} + $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used_space}, + $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free_space} ); return $msg; } @@ -104,8 +104,8 @@ sub set_counters { key_values => [ { name => 'used_space' }, { name => 'free_space' }, { name => 'prct_used_space' }, { name => 'prct_free_space' }, { name => 'total_space' }, { name => 'display' }, ], closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ - { label => 'used', value => 'used_space_absolute', template => '%d', min => 0, max => 'total_space_absolute', - unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'used', value => 'used_space', template => '%d', min => 0, max => 'total_space', + unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -113,8 +113,8 @@ sub set_counters { key_values => [ { name => 'free_space' }, { name => 'used_space' }, { name => 'prct_used_space' }, { name => 'prct_free_space' }, { name => 'total_space' }, { name => 'display' }, ], closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ - { label => 'free', value => 'free_space_absolute', template => '%d', min => 0, max => 'total_space_absolute', - unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'free', value => 'free_space', template => '%d', min => 0, max => 'total_space', + unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -122,8 +122,8 @@ sub set_counters { key_values => [ { name => 'prct_used_space' }, { name => 'display' } ], output_template => 'used : %.2f %%', perfdatas => [ - { label => 'used_prct', value => 'prct_used_space_absolute', template => '%.2f', min => 0, max => 100, - unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'used_prct', value => 'prct_used_space', template => '%.2f', min => 0, max => 100, + unit => '%', label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/apps/vmware/connector/mode/datastorevm.pm b/apps/vmware/connector/mode/datastorevm.pm index 23657ea95..abcb4a60f 100644 --- a/apps/vmware/connector/mode/datastorevm.pm +++ b/apps/vmware/connector/mode/datastorevm.pm @@ -71,7 +71,7 @@ sub set_counters { key_values => [ { name => 'total_latency' } ], output_template => 'max total latency is %s ms', perfdatas => [ - { label => 'max_total_latency', value => 'total_latency_absolute', template => '%s', unit => 'ms', + { label => 'max_total_latency', value => 'total_latency', template => '%s', unit => 'ms', min => 0, label_extra_instance => 1 }, ], } @@ -83,7 +83,7 @@ sub set_counters { key_values => [ { name => 'read' } ], output_template => '%s read iops', perfdatas => [ - { label => 'riops', value => 'read_absolute', template => '%s', unit => 'iops', + { label => 'riops', value => 'read', template => '%s', unit => 'iops', min => 0, label_extra_instance => 1 }, ], } @@ -92,8 +92,8 @@ sub set_counters { key_values => [ { name => 'write' } ], output_template => '%s write iops', perfdatas => [ - { label => 'wiops', value => 'write_absolute', template => '%s', unit => 'iops', - min => 0, max => 'write_absolute', label_extra_instance => 1 }, + { label => 'wiops', value => 'write', template => '%s', unit => 'iops', + min => 0, max => 'write', label_extra_instance => 1 }, ], } }, diff --git a/apps/vmware/connector/mode/devicevm.pm b/apps/vmware/connector/mode/devicevm.pm index ea95a4f24..f8ba791eb 100644 --- a/apps/vmware/connector/mode/devicevm.pm +++ b/apps/vmware/connector/mode/devicevm.pm @@ -44,7 +44,7 @@ sub custom_status_calc { sub custom_device_output { my ($self, %options) = @_; - my $msg = sprintf("%s %s device connected", $self->{result_values}->{device_connected_absolute}, $self->{instance_mode}->{option_results}->{device}); + my $msg = sprintf("%s %s device connected", $self->{result_values}->{device_connected}, $self->{instance_mode}->{option_results}->{device}); return $msg; } @@ -61,7 +61,7 @@ sub set_counters { key_values => [ { name => 'device_connected' } ], closure_custom_output => $self->can('custom_device_output'), perfdatas => [ - { label => 'total_device_connected', value => 'device_connected_absolute', template => '%s', + { label => 'total_device_connected', value => 'device_connected', template => '%s', min => 0 }, ], } @@ -81,7 +81,7 @@ sub set_counters { key_values => [ { name => 'device_connected' }, { name => 'display' } ], oclosure_custom_output => $self->can('custom_device_output'), perfdatas => [ - { label => 'device_connected', value => 'device_connected_absolute', template => '%s', + { label => 'device_connected', value => 'device_connected', template => '%s', min => 0, label_extra_instance => 1 }, ], } diff --git a/apps/vmware/connector/mode/healthhost.pm b/apps/vmware/connector/mode/healthhost.pm index edb0848fa..ad7254413 100644 --- a/apps/vmware/connector/mode/healthhost.pm +++ b/apps/vmware/connector/mode/healthhost.pm @@ -44,10 +44,10 @@ sub custom_summary_output { my ($self, %options) = @_; my $msg; - if ($self->{result_values}->{type_absolute} ne '') { - $msg = $self->{result_values}->{type_absolute} . " sensor " . $self->{result_values}->{name_absolute} . ": ". $self->{result_values}->{summary_absolute}; + if ($self->{result_values}->{type} ne '') { + $msg = $self->{result_values}->{type} . " sensor " . $self->{result_values}->{name} . ": ". $self->{result_values}->{summary}; } else { - $msg = $self->{result_values}->{name_absolute} . ": ". $self->{result_values}->{summary_absolute}; + $msg = $self->{result_values}->{name} . ": ". $self->{result_values}->{summary}; } return $msg; } @@ -71,8 +71,8 @@ sub set_counters { key_values => [ { name => 'total_problems' }, { name => 'total' } ], output_template => '%s total health issue(s) found', perfdatas => [ - { label => 'total_problems', value => 'total_problems_absolute', template => '%s', - min => 0, max => 'total_absolute' }, + { label => 'total_problems', value => 'total_problems', template => '%s', + min => 0, max => 'total' }, ], } }, @@ -100,8 +100,8 @@ sub set_counters { key_values => [ { name => 'total_problems' }, { name => 'total' } ], output_template => '%s total health issue(s) found', perfdatas => [ - { label => 'problems', value => 'total_problems_absolute', template => '%s', - min => 0, max => 'total_absolute', label_extra_instance => 1 }, + { label => 'problems', value => 'total_problems', template => '%s', + min => 0, max => 'total', label_extra_instance => 1 }, ], } }, @@ -109,8 +109,8 @@ sub set_counters { key_values => [ { name => 'yellow' }, { name => 'total' } ], output_template => '%s yellow health issue(s) found', perfdatas => [ - { label => 'problems_yellow', value => 'yellow_absolute', template => '%s', - min => 0, max => 'total_absolute', label_extra_instance => 1 }, + { label => 'problems_yellow', value => 'yellow', template => '%s', + min => 0, max => 'total', label_extra_instance => 1 }, ], } }, @@ -118,8 +118,8 @@ sub set_counters { key_values => [ { name => 'red' }, { name => 'total' } ], output_template => '%s red health issue(s) found', perfdatas => [ - { label => 'problems_red', value => 'red_absolute', template => '%s', - min => 0, max => 'total_absolute', label_extra_instance => 1 }, + { label => 'problems_red', value => 'red', template => '%s', + min => 0, max => 'total', label_extra_instance => 1 }, ], } }, diff --git a/apps/vmware/connector/mode/memoryhost.pm b/apps/vmware/connector/mode/memoryhost.pm index 0915e35da..1ad760d86 100644 --- a/apps/vmware/connector/mode/memoryhost.pm +++ b/apps/vmware/connector/mode/memoryhost.pm @@ -116,7 +116,7 @@ sub custom_usage_calc { sub custom_overhead_output { my ($self, %options) = @_; - my ($overhead_value, $overhead_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{overhead_absolute}); + my ($overhead_value, $overhead_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{overhead}); my $msg = sprintf("Memory Overhead: %s", $overhead_value . " " . $overhead_unit); return $msg; @@ -125,7 +125,7 @@ sub custom_overhead_output { sub custom_memstate_output { my ($self, %options) = @_; - my $msg = 'Memory state is ' . $self->{result_values}->{mem_state_str_absolute}; + my $msg = 'Memory state is ' . $self->{result_values}->{mem_state_str}; return $msg; } @@ -157,7 +157,7 @@ sub set_counters { key_values => [ { name => 'overhead' }, { name => 'display' } ], closure_custom_output => $self->can('custom_overhead_output'), perfdatas => [ - { label => 'overhead', value => 'overhead_absolute', template => '%s', unit => 'B', + { label => 'overhead', value => 'overhead', template => '%s', unit => 'B', min => 0, label_extra_instance => 1 }, ], } @@ -166,7 +166,7 @@ sub set_counters { key_values => [ { name => 'mem_state' }, { name => 'mem_state_str' }, { name => 'display' } ], closure_custom_output => $self->can('custom_memstate_output'), perfdatas => [ - { label => 'state', value => 'mem_state_absolute', template => '%s', + { label => 'state', value => 'mem_state', template => '%s', min => 0, max => 3, label_extra_instance => 1 }, ], } diff --git a/apps/vmware/connector/mode/memoryvm.pm b/apps/vmware/connector/mode/memoryvm.pm index 617b1736a..3d337967c 100644 --- a/apps/vmware/connector/mode/memoryvm.pm +++ b/apps/vmware/connector/mode/memoryvm.pm @@ -120,21 +120,21 @@ sub custom_usage_calc { sub custom_overhead_output { my ($self, %options) = @_; - my ($value, $unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{overhead_absolute}); + my ($value, $unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{overhead}); return sprintf('Memory overhead: %s %s', $value, $unit); } sub custom_ballooning_output { my ($self, %options) = @_; - my ($value, $unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{vmmemctl_absolute}); + my ($value, $unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{vmmemctl}); return sprintf('Memory ballooning: %s %s', $value, $unit); } sub custom_shared_output { my ($self, %options) = @_; - my ($value, $unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{shared_absolute}); + my ($value, $unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{shared}); return sprintf('Memory shared: %s %s', $value, $unit); } @@ -190,7 +190,7 @@ sub set_counters { key_values => [ { name => 'overhead' } ], closure_custom_output => $self->can('custom_overhead_output'), perfdatas => [ - { label => 'overhead', value => 'overhead_absolute', template => '%s', unit => 'B', + { label => 'overhead', value => 'overhead', template => '%s', unit => 'B', min => 0, label_extra_instance => 1 } ] } @@ -201,7 +201,7 @@ sub set_counters { key_values => [ { name => 'vmmemctl' } ], closure_custom_output => $self->can('custom_ballooning_output'), perfdatas => [ - { label => 'ballooning', value => 'vmmemctl_absolute', template => '%s', unit => 'B', + { label => 'ballooning', value => 'vmmemctl', template => '%s', unit => 'B', min => 0, label_extra_instance => 1 } ] } @@ -212,7 +212,7 @@ sub set_counters { key_values => [ { name => 'shared' } ], closure_custom_output => $self->can('custom_shared_output'), perfdatas => [ - { label => 'shared', value => 'shared_absolute', template => '%s', unit => 'B', + { label => 'shared', value => 'shared', template => '%s', unit => 'B', min => 0, label_extra_instance => 1 } ] } diff --git a/apps/vmware/connector/mode/nethost.pm b/apps/vmware/connector/mode/nethost.pm index dc2da0c98..8569339ed 100644 --- a/apps/vmware/connector/mode/nethost.pm +++ b/apps/vmware/connector/mode/nethost.pm @@ -132,7 +132,7 @@ sub set_counters { output_template => 'host traffic in : %s %s/s', output_change_bytes => 2, perfdatas => [ - { label => 'host_traffic_in', value => 'traffic_in_absolute', template => '%s', + { label => 'host_traffic_in', value => 'traffic_in', template => '%s', unit => 'b/s', min => 0, label_extra_instance => 1 } ] } @@ -142,7 +142,7 @@ sub set_counters { output_template => 'host traffic out : %s %s/s', output_change_bytes => 2, perfdatas => [ - { label => 'host_traffic_out', value => 'traffic_out_absolute', template => '%s', + { label => 'host_traffic_out', value => 'traffic_out', template => '%s', unit => 'b/s', min => 0, label_extra_instance => 1 } ] } @@ -155,7 +155,7 @@ sub set_counters { output_template => 'traffic in : %s %s/s', output_change_bytes => 2, perfdatas => [ - { label => 'vswitch_traffic_in', value => 'traffic_in_absolute', template => '%s', + { label => 'vswitch_traffic_in', value => 'traffic_in', template => '%s', unit => 'b/s', min => 0, label_extra_instance => 1 }, ], } @@ -165,7 +165,7 @@ sub set_counters { output_template => 'traffic out : %s %s/s', output_change_bytes => 2, perfdatas => [ - { label => 'vswitch_traffic_out', value => 'traffic_out_absolute', template => '%s', + { label => 'vswitch_traffic_out', value => 'traffic_out', template => '%s', unit => 'b/s', min => 0, label_extra_instance => 1 } ] } diff --git a/apps/vmware/connector/mode/statconnectors.pm b/apps/vmware/connector/mode/statconnectors.pm index eeb322085..efd1f3b30 100644 --- a/apps/vmware/connector/mode/statconnectors.pm +++ b/apps/vmware/connector/mode/statconnectors.pm @@ -39,7 +39,7 @@ sub set_counters { key_values => [ { name => 'requests', diff => 1 } ], output_template => 'Total %s requests', perfdatas => [ - { label => 'requests', value => 'requests_absolute', template => '%s', + { label => 'requests', value => 'requests', template => '%s', min => 0, label_extra_instance => 1 }, ], } @@ -51,7 +51,7 @@ sub set_counters { key_values => [ { name => 'requests', diff => 1 } ], output_template => '%s requests', perfdatas => [ - { label => 'requests', value => 'requests_absolute', template => '%s', + { label => 'requests', value => 'requests', template => '%s', min => 0, label_extra_instance => 1 }, ], } diff --git a/apps/vmware/connector/mode/swaphost.pm b/apps/vmware/connector/mode/swaphost.pm index aab266d6c..21b540c25 100644 --- a/apps/vmware/connector/mode/swaphost.pm +++ b/apps/vmware/connector/mode/swaphost.pm @@ -61,7 +61,7 @@ sub set_counters { output_template => 'Swap In: %s %s/s', output_change_bytes => 1, perfdatas => [ - { label => 'swap_in', value => 'swap_in_absolute', template => '%s', + { label => 'swap_in', value => 'swap_in', template => '%s', unit => 'B/s', min => 0, label_extra_instance => 1 }, ], } @@ -71,7 +71,7 @@ sub set_counters { output_template => 'Swap Out: %s %s/s', output_change_bytes => 1, perfdatas => [ - { label => 'swap_out', value => 'swap_out_absolute', template => '%s', + { label => 'swap_out', value => 'swap_out', template => '%s', unit => 'B/s', min => 0, label_extra_instance => 1 }, ], } diff --git a/apps/vmware/connector/mode/swapvm.pm b/apps/vmware/connector/mode/swapvm.pm index f6ab8e229..84b007cf8 100644 --- a/apps/vmware/connector/mode/swapvm.pm +++ b/apps/vmware/connector/mode/swapvm.pm @@ -62,7 +62,7 @@ sub set_counters { output_template => 'Swap In: %s %s/s', output_change_bytes => 1, perfdatas => [ - { label => 'swap_in', value => 'swap_in_absolute', template => '%s', + { label => 'swap_in', value => 'swap_in', template => '%s', unit => 'B/s', min => 0, label_extra_instance => 1 }, ], } @@ -72,7 +72,7 @@ sub set_counters { output_template => 'Swap Out: %s %s/s', output_change_bytes => 1, perfdatas => [ - { label => 'swap_out', value => 'swap_out_absolute', template => '%s', + { label => 'swap_out', value => 'swap_out', template => '%s', unit => 'B/s', min => 0, label_extra_instance => 1 }, ], } diff --git a/apps/vmware/connector/mode/timehost.pm b/apps/vmware/connector/mode/timehost.pm index e30153b8c..1fa2d2de9 100644 --- a/apps/vmware/connector/mode/timehost.pm +++ b/apps/vmware/connector/mode/timehost.pm @@ -45,7 +45,7 @@ sub custom_time_output { my ($self, %options) = @_; my $msg = sprintf("time offset %d second(s) : %s", - $self->{result_values}->{offset_absolute}, $self->{result_values}->{date_absolute}); + $self->{result_values}->{offset}, $self->{result_values}->{date}); return $msg; } @@ -69,7 +69,7 @@ sub set_counters { key_values => [ { name => 'offset' }, { name => 'date' }, { name => 'display' } ], closure_custom_output => $self->can('custom_time_output'), perfdatas => [ - { label => 'offset', value => 'offset_absolute', template => '%.2f', + { label => 'offset', value => 'offset', template => '%.2f', unit => 's', label_extra_instance => 1 }, ], } diff --git a/apps/vmware/connector/mode/uptimehost.pm b/apps/vmware/connector/mode/uptimehost.pm index dee66f450..e36edebee 100644 --- a/apps/vmware/connector/mode/uptimehost.pm +++ b/apps/vmware/connector/mode/uptimehost.pm @@ -45,7 +45,7 @@ sub custom_time_output { my ($self, %options) = @_; my $msg = sprintf("Uptime: %s day(s)", - int($self->{result_values}->{offset_absolute} / 60 / 60 / 24)); + int($self->{result_values}->{offset} / 60 / 60 / 24)); return $msg; } @@ -69,7 +69,7 @@ sub set_counters { key_values => [ { name => 'offset' }, { name => 'date' }, { name => 'display' } ], closure_custom_output => $self->can('custom_time_output'), perfdatas => [ - { label => 'uptime', value => 'offset_absolute', template => '%.2f', + { label => 'uptime', value => 'offset', template => '%.2f', unit => 's', label_extra_instance => 1 }, ], } diff --git a/apps/vmware/connector/mode/vmoperationcluster.pm b/apps/vmware/connector/mode/vmoperationcluster.pm index f8f4a5b4b..e0a95b6ad 100644 --- a/apps/vmware/connector/mode/vmoperationcluster.pm +++ b/apps/vmware/connector/mode/vmoperationcluster.pm @@ -38,7 +38,7 @@ sub set_counters { key_values => [ { name => 'numSVMotion', diff => 1 }, { name => 'display' } ], output_template => 'SVMotion %s', perfdatas => [ - { label => 'svmotion', value => 'numSVMotion_absolute', template => '%s', + { label => 'svmotion', value => 'numSVMotion', template => '%s', label_extra_instance => 1 }, ], } @@ -47,7 +47,7 @@ sub set_counters { key_values => [ { name => 'numVMotion', diff => 1 }, { name => 'display' } ], output_template => 'VMotion %s', perfdatas => [ - { label => 'vmotion', value => 'numVMotion_absolute', template => '%s', + { label => 'vmotion', value => 'numVMotion', template => '%s', label_extra_instance => 1 }, ], } @@ -56,7 +56,7 @@ sub set_counters { key_values => [ { name => 'numClone', diff => 1 }, { name => 'display' } ], output_template => 'Clone %s', perfdatas => [ - { label => 'clone', value => 'numClone_absolute', template => '%s', + { label => 'clone', value => 'numClone', template => '%s', label_extra_instance => 1 }, ], } diff --git a/apps/vmware/connector/mode/vsanclusterusage.pm b/apps/vmware/connector/mode/vsanclusterusage.pm index a2459810a..3783afd81 100644 --- a/apps/vmware/connector/mode/vsanclusterusage.pm +++ b/apps/vmware/connector/mode/vsanclusterusage.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'iopsRead' } ], output_template => 'read IOPS: %s', perfdatas => [ - { value => 'iopsRead_absolute', template => '%s', unit => 'iops', min => 0 }, + { value => 'iopsRead', template => '%s', unit => 'iops', min => 0 }, ], } }, @@ -45,7 +45,7 @@ sub set_counters { key_values => [ { name => 'iopsWrite' } ], output_template => 'write IOPS: %s', perfdatas => [ - { value => 'iopsWrite_absolute', template => '%s', unit => 'iops', min => 0 }, + { value => 'iopsWrite', template => '%s', unit => 'iops', min => 0 }, ], } }, @@ -53,7 +53,7 @@ sub set_counters { key_values => [ { name => 'congestion' } ], output_template => 'congestions: %s', perfdatas => [ - { value => 'congestion_absolute', template => '%s', min => 0 }, + { value => 'congestion', template => '%s', min => 0 }, ], } }, @@ -61,7 +61,7 @@ sub set_counters { key_values => [ { name => 'oio' } ], output_template => 'outstanding IO: %s', perfdatas => [ - { value => 'oio_absolute', template => '%s', min => 0 }, + { value => 'oio', template => '%s', min => 0 }, ], } }, @@ -70,7 +70,7 @@ sub set_counters { output_template => 'read throughput: %s %s/s', output_change_bytes => 1, perfdatas => [ - { value => 'throughputRead_absolute', template => '%s', unit => 'B/s', min => 0 }, + { value => 'throughputRead', template => '%s', unit => 'B/s', min => 0 }, ], } }, @@ -79,7 +79,7 @@ sub set_counters { output_template => 'write throughput: %s %s/s', output_change_bytes => 1, perfdatas => [ - { value => 'throughputWrite_absolute', template => '%s', unit => 'B/s', min => 0 }, + { value => 'throughputWrite', template => '%s', unit => 'B/s', min => 0 }, ], } }, @@ -87,7 +87,7 @@ sub set_counters { key_values => [ { name => 'latencyAvgRead' } ], output_template => 'read latency: %s ms', perfdatas => [ - { value => 'latencyAvgRead_absolute', template => '%s', unit => 'ms', min => 0 }, + { value => 'latencyAvgRead', template => '%s', unit => 'ms', min => 0 }, ], } }, @@ -95,7 +95,7 @@ sub set_counters { key_values => [ { name => 'latencyAvgWrite' } ], output_template => 'write latency: %s ms', perfdatas => [ - { value => 'latencyAvgWrite_absolute', template => '%s', unit => 'ms', min => 0 }, + { value => 'latencyAvgWrite', template => '%s', unit => 'ms', min => 0 }, ], } }, diff --git a/apps/voip/3cx/restapi/mode/system.pm b/apps/voip/3cx/restapi/mode/system.pm index 72c82d761..6f784e7d7 100644 --- a/apps/voip/3cx/restapi/mode/system.pm +++ b/apps/voip/3cx/restapi/mode/system.pm @@ -50,7 +50,7 @@ sub set_counters { key_values => [ { name => 'calls_active' } ], output_template => 'calls active : %s', perfdatas => [ - { label => 'calls_active', template => '%s', value => 'calls_active_absolute', + { label => 'calls_active', template => '%s', value => 'calls_active', min => 0 }, ], } @@ -59,7 +59,7 @@ sub set_counters { key_values => [ { name => 'extensions_registered' } ], output_template => 'extensions registered : %s', perfdatas => [ - { label => 'extensions_registered', template => '%s', value => 'extensions_registered_absolute', + { label => 'extensions_registered', template => '%s', value => 'extensions_registered', min => 0 }, ], } diff --git a/apps/voip/asterisk/ami/mode/channelusage.pm b/apps/voip/asterisk/ami/mode/channelusage.pm index de3341bd2..019fcad10 100644 --- a/apps/voip/asterisk/ami/mode/channelusage.pm +++ b/apps/voip/asterisk/ami/mode/channelusage.pm @@ -38,7 +38,7 @@ sub set_counters { key_values => [ { name => 'channels_active' } ], output_template => 'Channels Active: %s', perfdatas => [ - { label => 'channels_active', value => 'channels_active_absolute', template => '%s', min => 0 }, + { label => 'channels_active', value => 'channels_active', template => '%s', min => 0 }, ], } }, @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'calls_active' } ], output_template => 'Calls Active: %s', perfdatas => [ - { label => 'calls_active', value => 'calls_active_absolute', template => '%s', min => 0 }, + { label => 'calls_active', value => 'calls_active', template => '%s', min => 0 }, ], } }, @@ -54,7 +54,7 @@ sub set_counters { key_values => [ { name => 'extcalls_active' } ], output_template => 'External Calls Active: %s', perfdatas => [ - { label => 'extcalls_active', value => 'extcalls_active_absolute', template => '%s', min => 0 }, + { label => 'extcalls_active', value => 'extcalls_active', template => '%s', min => 0 }, ], } }, @@ -62,7 +62,7 @@ sub set_counters { key_values => [ { name => 'calls_count', diff => 1 } ], output_template => 'Calls Count: %s', perfdatas => [ - { label => 'calls_count', value => 'calls_count_absolute', template => '%s', min => 0 }, + { label => 'calls_count', value => 'calls_count', template => '%s', min => 0 }, ], } }, diff --git a/apps/voip/asterisk/ami/mode/sippeersusage.pm b/apps/voip/asterisk/ami/mode/sippeersusage.pm index bd2cc7120..63cdd3bd8 100644 --- a/apps/voip/asterisk/ami/mode/sippeersusage.pm +++ b/apps/voip/asterisk/ami/mode/sippeersusage.pm @@ -54,7 +54,7 @@ sub set_counters { key_values => [ { name => 'total_peers' } ], output_template => 'Total Peers: %s', perfdatas => [ - { label => 'total_peers', value => 'total_peers_absolute', template => '%s', min => 0 }, + { label => 'total_peers', value => 'total_peers', template => '%s', min => 0 }, ], } }, @@ -62,7 +62,7 @@ sub set_counters { key_values => [ { name => 'monitor_online_peers' } ], output_template => 'Monitor Online Peers: %s', perfdatas => [ - { label => 'monitor_online_peers', value => 'monitor_online_peers_absolute', template => '%s', min => 0 }, + { label => 'monitor_online_peers', value => 'monitor_online_peers', template => '%s', min => 0 }, ], } }, @@ -70,7 +70,7 @@ sub set_counters { key_values => [ { name => 'monitor_offline_peers' } ], output_template => 'Monitor Offline Peers: %s', perfdatas => [ - { label => 'monitor_offline_peers', value => 'monitor_offline_peers_absolute', template => '%s', min => 0 }, + { label => 'monitor_offline_peers', value => 'monitor_offline_peers', template => '%s', min => 0 }, ], } }, @@ -78,7 +78,7 @@ sub set_counters { key_values => [ { name => 'unmonitor_online_peers' } ], output_template => 'Unmonitor Online Peers: %s', perfdatas => [ - { label => 'unmonitor_online_peers', value => 'unmonitor_online_peers_absolute', template => '%s', min => 0 }, + { label => 'unmonitor_online_peers', value => 'unmonitor_online_peers', template => '%s', min => 0 }, ], } }, @@ -86,7 +86,7 @@ sub set_counters { key_values => [ { name => 'unmonitor_offline_peers' } ], output_template => 'Unmonitor Offline Peers: %s', perfdatas => [ - { label => 'unmonitor_offline_peers', value => 'unmonitor_offline_peers_absolute', template => '%s', min => 0 }, + { label => 'unmonitor_offline_peers', value => 'unmonitor_offline_peers', template => '%s', min => 0 }, ], } }, diff --git a/apps/voip/asterisk/snmp/mode/channelusage.pm b/apps/voip/asterisk/snmp/mode/channelusage.pm index 4f5743ba6..dd67d92e1 100644 --- a/apps/voip/asterisk/snmp/mode/channelusage.pm +++ b/apps/voip/asterisk/snmp/mode/channelusage.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'channels_active' } ], output_template => 'Channels Active: %s', perfdatas => [ - { label => 'channels_active', value => 'channels_active_absolute', template => '%s', min => 0 }, + { label => 'channels_active', value => 'channels_active', template => '%s', min => 0 }, ], } }, @@ -45,7 +45,7 @@ sub set_counters { key_values => [ { name => 'calls_active' } ], output_template => 'Calls Active: %s', perfdatas => [ - { label => 'calls_active', value => 'calls_active_absolute', template => '%s', min => 0 }, + { label => 'calls_active', value => 'calls_active', template => '%s', min => 0 }, ], } }, @@ -53,7 +53,7 @@ sub set_counters { key_values => [ { name => 'calls_count', diff => 1 } ], output_template => 'Calls Count: %s', perfdatas => [ - { label => 'calls_count', value => 'calls_count_absolute', template => '%s', min => 0 }, + { label => 'calls_count', value => 'calls_count', template => '%s', min => 0 }, ], } }, diff --git a/apps/vtom/restapi/mode/jobstatus.pm b/apps/vtom/restapi/mode/jobstatus.pm index dc01b29d8..0a5658780 100644 --- a/apps/vtom/restapi/mode/jobstatus.pm +++ b/apps/vtom/restapi/mode/jobstatus.pm @@ -108,8 +108,8 @@ sub set_counters { key_values => [ { name => 'error' }, { name => 'total' } ], output_template => 'Error : %s', perfdatas => [ - { label => 'total_error', value => 'error_absolute', template => '%s', - min => 0, max => 'total_absolute' }, + { label => 'total_error', value => 'error', template => '%s', + min => 0, max => 'total' }, ], } }, @@ -117,8 +117,8 @@ sub set_counters { key_values => [ { name => 'running' }, { name => 'total' } ], output_template => 'Running : %s', perfdatas => [ - { label => 'total_running', value => 'running_absolute', template => '%s', - min => 0, max => 'total_absolute' }, + { label => 'total_running', value => 'running', template => '%s', + min => 0, max => 'total' }, ], } }, @@ -126,8 +126,8 @@ sub set_counters { key_values => [ { name => 'unplanned' }, { name => 'total' } ], output_template => 'Unplanned : %s', perfdatas => [ - { label => 'total_unplanned', value => 'unplanned_absolute', template => '%s', - min => 0, max => 'total_absolute' }, + { label => 'total_unplanned', value => 'unplanned', template => '%s', + min => 0, max => 'total' }, ], } }, @@ -135,8 +135,8 @@ sub set_counters { key_values => [ { name => 'finished' }, { name => 'total' } ], output_template => 'Finished : %s', perfdatas => [ - { label => 'total_finished', value => 'finished_absolute', template => '%s', - min => 0, max => 'total_absolute' }, + { label => 'total_finished', value => 'finished', template => '%s', + min => 0, max => 'total' }, ], } }, @@ -144,8 +144,8 @@ sub set_counters { key_values => [ { name => 'coming' }, { name => 'total' } ], output_template => 'Coming : %s', perfdatas => [ - { label => 'total_coming', value => 'coming_absolute', template => '%s', - min => 0, max => 'total_absolute' }, + { label => 'total_coming', value => 'coming', template => '%s', + min => 0, max => 'total' }, ], } }, diff --git a/apps/wazuh/restapi/mode/agents.pm b/apps/wazuh/restapi/mode/agents.pm index 26860ab51..f483e286b 100644 --- a/apps/wazuh/restapi/mode/agents.pm +++ b/apps/wazuh/restapi/mode/agents.pm @@ -51,7 +51,7 @@ sub set_counters { key_values => [ { name => $_ } ], output_template => $_ . ': %s', perfdatas => [ - { value => $_ . '_absolute', template => '%s', min => 0 }, + { value => $_ , template => '%s', min => 0 }, ], } }; diff --git a/apps/wazuh/restapi/mode/manager.pm b/apps/wazuh/restapi/mode/manager.pm index 62c0fd97f..b2da0d896 100644 --- a/apps/wazuh/restapi/mode/manager.pm +++ b/apps/wazuh/restapi/mode/manager.pm @@ -52,7 +52,7 @@ sub set_counters { key_values => [ { name => $_ } ], output_template => $_ . ': %s', perfdatas => [ - { value => $_ . '_absolute', template => '%s', min => 0 }, + { value => $_ , template => '%s', min => 0 }, ], } }; @@ -76,7 +76,7 @@ sub set_counters { key_values => [ { name => $_, diff => 1 } ], output_template => $_ . ': %s', perfdatas => [ - { value => $_ . '_absolute', template => '%s', min => 0 }, + { value => $_ , template => '%s', min => 0 }, ], } }; diff --git a/apps/wsus/local/mode/computersstatus.pm b/apps/wsus/local/mode/computersstatus.pm index 52d88f9ad..a02edd2f2 100644 --- a/apps/wsus/local/mode/computersstatus.pm +++ b/apps/wsus/local/mode/computersstatus.pm @@ -40,7 +40,7 @@ sub set_counters { key_values => [ { name => 'ComputersUpToDateCount' } ], output_template => 'Up-to-date: %d', perfdatas => [ - { label => 'computers_up_to_date', value => 'ComputersUpToDateCount_absolute', + { label => 'computers_up_to_date', value => 'ComputersUpToDateCount', template => '%d', min => 0 }, ], } @@ -49,7 +49,7 @@ sub set_counters { key_values => [ { name => 'ComputerTargetsNeedingUpdatesCount' } ], output_template => 'Needing Updates: %d', perfdatas => [ - { label => 'computers_needing_updates', value => 'ComputerTargetsNeedingUpdatesCount_absolute', + { label => 'computers_needing_updates', value => 'ComputerTargetsNeedingUpdatesCount', template => '%d', min => 0 }, ], } @@ -58,7 +58,7 @@ sub set_counters { key_values => [ { name => 'ComputerTargetsWithUpdateErrorsCount' } ], output_template => 'With Update Errors: %d', perfdatas => [ - { label => 'computers_with_update_errors', value => 'ComputerTargetsWithUpdateErrorsCount_absolute', + { label => 'computers_with_update_errors', value => 'ComputerTargetsWithUpdateErrorsCount', template => '%d', min => 0 }, ], } @@ -67,7 +67,7 @@ sub set_counters { key_values => [ { name => 'ComputersNotContactedSinceCount' } ], output_template => 'Not Contacted: %d', perfdatas => [ - { label => 'computers_not_contacted', value => 'ComputersNotContactedSinceCount_absolute', + { label => 'computers_not_contacted', value => 'ComputersNotContactedSinceCount', template => '%d', min => 0 }, ], } @@ -76,7 +76,7 @@ sub set_counters { key_values => [ { name => 'UnassignedComputersCount' } ], output_template => 'Unassigned: %s', perfdatas => [ - { label => 'computers_unassigned', value => 'UnassignedComputersCount_absolute', + { label => 'computers_unassigned', value => 'UnassignedComputersCount', template => '%d', min => 0 }, ], } diff --git a/apps/wsus/local/mode/serverstatistics.pm b/apps/wsus/local/mode/serverstatistics.pm index 927930f58..d0c604395 100644 --- a/apps/wsus/local/mode/serverstatistics.pm +++ b/apps/wsus/local/mode/serverstatistics.pm @@ -40,7 +40,7 @@ sub set_counters { key_values => [ { name => 'ComputerTargetCount' } ], output_template => 'Computers: %d', perfdatas => [ - { label => 'computers', value => 'ComputerTargetCount_absolute', + { label => 'computers', value => 'ComputerTargetCount', template => '%d', min => 0 }, ], } @@ -49,7 +49,7 @@ sub set_counters { key_values => [ { name => 'CustomComputerTargetGroupCount' } ], output_template => 'Computer Groups: %d', perfdatas => [ - { label => 'computer_groups', value => 'CustomComputerTargetGroupCount_absolute', + { label => 'computer_groups', value => 'CustomComputerTargetGroupCount', template => '%d', min => 0 }, ], } @@ -58,7 +58,7 @@ sub set_counters { key_values => [ { name => 'UpdateCount' } ], output_template => 'Updates: %d', perfdatas => [ - { label => 'updates', value => 'UpdateCount_absolute', + { label => 'updates', value => 'UpdateCount', template => '%d', min => 0 }, ], } @@ -67,7 +67,7 @@ sub set_counters { key_values => [ { name => 'ApprovedUpdateCount' } ], output_template => 'Approved Updates: %d', perfdatas => [ - { label => 'approved_updates', value => 'ApprovedUpdateCount_absolute', + { label => 'approved_updates', value => 'ApprovedUpdateCount', template => '%d', min => 0 }, ], } @@ -76,7 +76,7 @@ sub set_counters { key_values => [ { name => 'DeclinedUpdateCount' } ], output_template => 'Declined Updates: %d', perfdatas => [ - { label => 'declined_updates', value => 'DeclinedUpdateCount_absolute', + { label => 'declined_updates', value => 'DeclinedUpdateCount', template => '%d', min => 0 }, ], } @@ -85,7 +85,7 @@ sub set_counters { key_values => [ { name => 'NotApprovedUpdateCount' } ], output_template => 'Not Approved Updates: %d', perfdatas => [ - { label => 'not_approved_updates', value => 'NotApprovedUpdateCount_absolute', + { label => 'not_approved_updates', value => 'NotApprovedUpdateCount', template => '%d', min => 0 }, ], } @@ -94,7 +94,7 @@ sub set_counters { key_values => [ { name => 'UpdatesWithStaleUpdateApprovalsCount' } ], output_template => 'Stale Updates: %d', perfdatas => [ - { label => 'stale_updates', value => 'UpdatesWithStaleUpdateApprovalsCount_absolute', + { label => 'stale_updates', value => 'UpdatesWithStaleUpdateApprovalsCount', template => '%d', min => 0 }, ], } @@ -103,7 +103,7 @@ sub set_counters { key_values => [ { name => 'ExpiredUpdateCount' } ], output_template => 'Expired Updates: %d', perfdatas => [ - { label => 'expired_updates', value => 'ExpiredUpdateCount_absolute', + { label => 'expired_updates', value => 'ExpiredUpdateCount', template => '%d', min => 0 }, ], } diff --git a/apps/wsus/local/mode/updatesstatus.pm b/apps/wsus/local/mode/updatesstatus.pm index 390a16170..52ebb502f 100644 --- a/apps/wsus/local/mode/updatesstatus.pm +++ b/apps/wsus/local/mode/updatesstatus.pm @@ -40,7 +40,7 @@ sub set_counters { key_values => [ { name => 'UpdatesWithClientErrorsCount' } ], output_template => 'With Client Errors: %d', perfdatas => [ - { label => 'updates_with_client_errors', value => 'UpdatesWithClientErrorsCount_absolute', + { label => 'updates_with_client_errors', value => 'UpdatesWithClientErrorsCount', template => '%d', min => 0 }, ], } @@ -49,7 +49,7 @@ sub set_counters { key_values => [ { name => 'UpdatesWithServerErrorsCount' } ], output_template => 'With Server Errors: %d', perfdatas => [ - { label => 'updates_with_server_errors', value => 'UpdatesWithServerErrorsCount_absolute', + { label => 'updates_with_server_errors', value => 'UpdatesWithServerErrorsCount', template => '%d', min => 0 }, ], } @@ -58,7 +58,7 @@ sub set_counters { key_values => [ { name => 'UpdatesNeedingFilesCount' } ], output_template => 'Needing Files: %d', perfdatas => [ - { label => 'updates_needing_files_count', value => 'UpdatesNeedingFilesCount_absolute', + { label => 'updates_needing_files_count', value => 'UpdatesNeedingFilesCount', template => '%d', min => 0 }, ], } @@ -67,7 +67,7 @@ sub set_counters { key_values => [ { name => 'UpdatesNeededByComputersCount' } ], output_template => 'Needed By Computers: %d', perfdatas => [ - { label => 'updates_needed_by_computers', value => 'UpdatesNeededByComputersCount_absolute', + { label => 'updates_needed_by_computers', value => 'UpdatesNeededByComputersCount', template => '%d', min => 0 }, ], } @@ -76,7 +76,7 @@ sub set_counters { key_values => [ { name => 'UpdatesUpToDateCount' } ], output_template => 'Up-to-date: %s', perfdatas => [ - { label => 'updates_up_to_date', value => 'UpdatesUpToDateCount_absolute', + { label => 'updates_up_to_date', value => 'UpdatesUpToDateCount', template => '%d', min => 0 }, ], } diff --git a/blockchain/hyperledger/exporter/mode/channels.pm b/blockchain/hyperledger/exporter/mode/channels.pm index c14c4678b..da153a85e 100644 --- a/blockchain/hyperledger/exporter/mode/channels.pm +++ b/blockchain/hyperledger/exporter/mode/channels.pm @@ -50,7 +50,7 @@ sub set_counters { key_values => [ { name => $_->[2] . '_count', diff => 1 } ], output_template => '%s (total)', perfdatas => [ - { value => $_->[2] . '_count_absolute', template => '%s', min => 0, + { value => $_->[2] . '_count', template => '%s', min => 0, label_extra_instance => 1 }, ], } @@ -66,7 +66,7 @@ sub set_counters { key_values => [ { name => $_->[2] . '_bucket_' . $label, diff => 1 } ], output_template => '%s (<= ' . $perf_label . ' sec)', perfdatas => [ - { value => $_->[2] . '_bucket_' . $label . '_absolute', template => '%s', min => 0, + { value => $_->[2] . '_bucket_' . $label , template => '%s', min => 0, label_extra_instance => 1 }, ], } @@ -79,7 +79,7 @@ sub set_counters { key_values => [ { name => 'ledger_transaction_count', diff => 1 } ], output_template => 'number of transactions processed: %s', perfdatas => [ - { value => 'ledger_transaction_count_absolute', template => '%s', min => 0, + { value => 'ledger_transaction_count', template => '%s', min => 0, label_extra_instance => 1 }, ], } @@ -88,7 +88,7 @@ sub set_counters { key_values => [ { name => 'gossip_membership_total_peers_known' } ], output_template => 'total known peers: %s', perfdatas => [ - { value => 'gossip_membership_total_peers_known_absolute', template => '%s', min => 0, + { value => 'gossip_membership_total_peers_known', template => '%s', min => 0, label_extra_instance => 1 }, ], } @@ -97,7 +97,7 @@ sub set_counters { key_values => [ { name => 'gossip_state_height' } ], output_template => 'current ledger height: %s', perfdatas => [ - { value => 'gossip_state_height_absolute', template => '%s', min => 0, + { value => 'gossip_state_height', template => '%s', min => 0, label_extra_instance => 1 }, ], } @@ -106,7 +106,7 @@ sub set_counters { key_values => [ { name => 'ledger_blockchain_height' } ], output_template => 'height of the chain in blocks: %s', perfdatas => [ - { value => 'ledger_blockchain_height_absolute', template => '%s', min => 0, + { value => 'ledger_blockchain_height', template => '%s', min => 0, label_extra_instance => 1 }, ], } diff --git a/centreon/common/airespace/snmp/mode/apchannelinterference.pm b/centreon/common/airespace/snmp/mode/apchannelinterference.pm index 76a3abe9a..5229a275a 100644 --- a/centreon/common/airespace/snmp/mode/apchannelinterference.pm +++ b/centreon/common/airespace/snmp/mode/apchannelinterference.pm @@ -36,8 +36,8 @@ sub set_counters { key_values => [ { name => 'interference_power' }, { name => 'label_perfdata' } ], output_template => 'Interference Power : %s', perfdatas => [ - { label => 'interference_power', value => 'interference_power_absolute', template => '%s', - label_extra_instance => 1, instance_use => 'label_perfdata_absolute' }, + { label => 'interference_power', value => 'interference_power', template => '%s', + label_extra_instance => 1, instance_use => 'label_perfdata' }, ], } }, @@ -45,8 +45,8 @@ sub set_counters { key_values => [ { name => 'interference_util' }, { name => 'label_perfdata' } ], output_template => 'Interference Utilization : %s %%', perfdatas => [ - { label => 'interference_util', value => 'interference_util_absolute', template => '%s', - unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'label_perfdata_absolute' }, + { label => 'interference_util', value => 'interference_util', template => '%s', + unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'label_perfdata' }, ], } }, diff --git a/centreon/common/airespace/snmp/mode/apchannelnoise.pm b/centreon/common/airespace/snmp/mode/apchannelnoise.pm index 14b34299a..0f81c193d 100644 --- a/centreon/common/airespace/snmp/mode/apchannelnoise.pm +++ b/centreon/common/airespace/snmp/mode/apchannelnoise.pm @@ -36,8 +36,8 @@ sub set_counters { key_values => [ { name => 'noise_power' }, { name => 'label_perfdata' } ], output_template => 'Noise Power : %s dBm', perfdatas => [ - { label => 'noise_power', value => 'noise_power_absolute', template => '%s', - unit => 'dBm', label_extra_instance => 1, instance_use => 'label_perfdata_absolute' }, + { label => 'noise_power', value => 'noise_power', template => '%s', + unit => 'dBm', label_extra_instance => 1, instance_use => 'label_perfdata' }, ], } }, diff --git a/centreon/common/airespace/snmp/mode/apstatus.pm b/centreon/common/airespace/snmp/mode/apstatus.pm index fda788f52..a0b9bed86 100644 --- a/centreon/common/airespace/snmp/mode/apstatus.pm +++ b/centreon/common/airespace/snmp/mode/apstatus.pm @@ -60,7 +60,7 @@ sub set_counters { key_values => [ { name => 'total' } ], output_template => 'Total ap : %s', perfdatas => [ - { label => 'total', value => 'total_absolute', template => '%s', + { label => 'total', value => 'total', template => '%s', min => 0 }, ], } @@ -69,7 +69,7 @@ sub set_counters { key_values => [ { name => 'associated' } ], output_template => 'Total ap associated : %s', perfdatas => [ - { label => 'total_associated', value => 'associated_absolute', template => '%s', + { label => 'total_associated', value => 'associated', template => '%s', min => 0 }, ], } @@ -78,7 +78,7 @@ sub set_counters { key_values => [ { name => 'disassociating' } ], output_template => 'Total ap disassociating : %s', perfdatas => [ - { label => 'total_disassociating', value => 'disassociating_absolute', template => '%s', + { label => 'total_disassociating', value => 'disassociating', template => '%s', min => 0 }, ], } @@ -87,7 +87,7 @@ sub set_counters { key_values => [ { name => 'enable' } ], output_template => 'Total ap enabled : %s', perfdatas => [ - { label => 'total_enabled', value => 'enable_absolute', template => '%s', + { label => 'total_enabled', value => 'enable', template => '%s', min => 0 }, ], } @@ -96,7 +96,7 @@ sub set_counters { key_values => [ { name => 'disable' } ], output_template => 'Total ap disabled : %s', perfdatas => [ - { label => 'total_disabled', value => 'disable_absolute', template => '%s', + { label => 'total_disabled', value => 'disable', template => '%s', min => 0 }, ], } diff --git a/centreon/common/airespace/snmp/mode/apusers.pm b/centreon/common/airespace/snmp/mode/apusers.pm index f16600743..58cf67188 100644 --- a/centreon/common/airespace/snmp/mode/apusers.pm +++ b/centreon/common/airespace/snmp/mode/apusers.pm @@ -38,7 +38,7 @@ sub set_counters { key_values => [ { name => 'total' } ], output_template => 'Total Users : %s', perfdatas => [ - { label => 'total', value => 'total_absolute', template => '%s', + { label => 'total', value => 'total', template => '%s', unit => 'users', min => 0 }, ], } @@ -47,7 +47,7 @@ sub set_counters { key_values => [ { name => 'total_idle' } ], output_template => 'Total Idle Users : %s', perfdatas => [ - { label => 'total_idle', value => 'total_idle_absolute', template => '%s', + { label => 'total_idle', value => 'total_idle', template => '%s', unit => 'users', min => 0 }, ], } @@ -56,7 +56,7 @@ sub set_counters { key_values => [ { name => 'total_aaapending' } ], output_template => 'Total AaaPending Users : %s', perfdatas => [ - { label => 'total_aaapending', value => 'total_aaapending_absolute', template => '%s', + { label => 'total_aaapending', value => 'total_aaapending', template => '%s', unit => 'users', min => 0 }, ], } @@ -65,7 +65,7 @@ sub set_counters { key_values => [ { name => 'total_authenticated' } ], output_template => 'Total Authenticated Users : %s', perfdatas => [ - { label => 'total_authenticated', value => 'total_authenticated_absolute', template => '%s', + { label => 'total_authenticated', value => 'total_authenticated', template => '%s', unit => 'users', min => 0 }, ], } @@ -74,7 +74,7 @@ sub set_counters { key_values => [ { name => 'total_associated' } ], output_template => 'Total Associated Users : %s', perfdatas => [ - { label => 'total_associated', value => 'total_associated_absolute', template => '%s', + { label => 'total_associated', value => 'total_associated', template => '%s', unit => 'users', min => 0 }, ], } @@ -83,7 +83,7 @@ sub set_counters { key_values => [ { name => 'total_powersave' } ], output_template => 'Total Powersave Users : %s', perfdatas => [ - { label => 'total_powersave', value => 'total_powersave_absolute', template => '%s', + { label => 'total_powersave', value => 'total_powersave', template => '%s', unit => 'users', min => 0 }, ], } @@ -92,7 +92,7 @@ sub set_counters { key_values => [ { name => 'total_disassociated' } ], output_template => 'Total Disassociated Users : %s', perfdatas => [ - { label => 'total_disassociated', value => 'total_disassociated_absolute', template => '%s', + { label => 'total_disassociated', value => 'total_disassociated', template => '%s', unit => 'users', min => 0 }, ], } @@ -101,7 +101,7 @@ sub set_counters { key_values => [ { name => 'total_tobedeleted' } ], output_template => 'Total ToBeDeleted Users : %s', perfdatas => [ - { label => 'total_tobedeleted', value => 'total_tobedeleted_absolute', template => '%s', + { label => 'total_tobedeleted', value => 'total_tobedeleted', template => '%s', unit => 'users', min => 0 }, ], } @@ -110,7 +110,7 @@ sub set_counters { key_values => [ { name => 'total_probing' } ], output_template => 'Total Probing Users : %s', perfdatas => [ - { label => 'total_probing', value => 'total_probing_absolute', template => '%s', + { label => 'total_probing', value => 'total_probing', template => '%s', unit => 'users', min => 0 }, ], } @@ -119,7 +119,7 @@ sub set_counters { key_values => [ { name => 'total_blacklisted' } ], output_template => 'Total Blacklisted Users : %s', perfdatas => [ - { label => 'total_blacklisted', value => 'total_blacklisted_absolute', template => '%s', + { label => 'total_blacklisted', value => 'total_blacklisted', template => '%s', unit => 'users', min => 0 }, ], } @@ -131,8 +131,8 @@ sub set_counters { key_values => [ { name => 'total' }, { name => 'display' } ], output_template => 'users : %s', perfdatas => [ - { label => 'ssid', value => 'total_absolute', template => '%s', - unit => 'users', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'ssid', value => 'total', template => '%s', + unit => 'users', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -143,8 +143,8 @@ sub set_counters { key_values => [ { name => 'total' }, { name => 'display' } ], output_template => 'users : %s', perfdatas => [ - { label => 'ap', value => 'total_absolute', template => '%s', - unit => 'users', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'ap', value => 'total', template => '%s', + unit => 'users', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/centreon/common/aruba/snmp/mode/apconnections.pm b/centreon/common/aruba/snmp/mode/apconnections.pm index d8d540461..3e59a90b9 100644 --- a/centreon/common/aruba/snmp/mode/apconnections.pm +++ b/centreon/common/aruba/snmp/mode/apconnections.pm @@ -38,7 +38,7 @@ sub set_counters { key_values => [ { name => 'total' } ], output_template => 'Total access points connected : %d', perfdatas => [ - { label => 'total', value => 'total_absolute', template => '%d', min => 0 }, + { label => 'total', value => 'total', template => '%d', min => 0 }, ], } }, @@ -49,8 +49,8 @@ sub set_counters { key_values => [ { name => 'apTotalTime' }, { name => 'bssid' }, ], output_template => 'Current total connection time : %.3f s', perfdatas => [ - { label => 'total_time', value => 'apTotalTime_absolute', template => '%.3f', - min => 0, unit => 's', label_extra_instance => 1, instance_use => 'bssid_absolute' }, + { label => 'total_time', value => 'apTotalTime', template => '%.3f', + min => 0, unit => 's', label_extra_instance => 1, instance_use => 'bssid' }, ], } }, @@ -58,8 +58,8 @@ sub set_counters { key_values => [ { name => 'apInactiveTime' }, { name => 'bssid' }, ], output_template => 'Current inactive time : %.3f s', perfdatas => [ - { label => 'inactive_time', value => 'apInactiveTime_absolute', template => '%.3f', - min => 0, unit => 's', label_extra_instance => 1, instance_use => 'bssid_absolute' }, + { label => 'inactive_time', value => 'apInactiveTime', template => '%.3f', + min => 0, unit => 's', label_extra_instance => 1, instance_use => 'bssid' }, ], } }, @@ -67,8 +67,8 @@ sub set_counters { key_values => [ { name => 'apChannelNoise' }, { name => 'bssid' }, ], output_template => 'Channel noise : %d', perfdatas => [ - { label => 'channel_noise', value => 'apChannelNoise_absolute', template => '%d', - label_extra_instance => 1, instance_use => 'bssid_absolute' }, + { label => 'channel_noise', value => 'apChannelNoise', template => '%d', + label_extra_instance => 1, instance_use => 'bssid' }, ], } }, @@ -76,8 +76,8 @@ sub set_counters { key_values => [ { name => 'apSignalToNoiseRatio' }, { name => 'bssid' }, ], output_template => 'Signal to noise ratio : %d', perfdatas => [ - { label => 'snr', value => 'apSignalToNoiseRatio_absolute', template => '%d', - label_extra_instance => 1, instance_use => 'bssid_absolute' }, + { label => 'snr', value => 'apSignalToNoiseRatio', template => '%d', + label_extra_instance => 1, instance_use => 'bssid' }, ], } }, diff --git a/centreon/common/aruba/snmp/mode/apssidstatistics.pm b/centreon/common/aruba/snmp/mode/apssidstatistics.pm index cc605fd66..f218e0d1e 100644 --- a/centreon/common/aruba/snmp/mode/apssidstatistics.pm +++ b/centreon/common/aruba/snmp/mode/apssidstatistics.pm @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'total' } ], output_template => 'Stations Associated: %d', perfdatas => [ - { value => 'total_absolute', template => '%d', min => 0 }, + { value => 'total', template => '%d', min => 0 }, ], } }, @@ -57,7 +57,7 @@ sub set_counters { key_values => [ { name => 'wlanAPEssidNumAssociatedStations' }, { name => 'wlanAPESSID' } ], output_template => 'Associated Stations: %d', perfdatas => [ - { value => 'wlanAPEssidNumAssociatedStations_absolute', template => '%d', + { value => 'wlanAPEssidNumAssociatedStations', template => '%d', label_extra_instance => 1 }, ], } @@ -70,7 +70,7 @@ sub set_counters { { name => 'wlanAPESSID' } ], output_template => 'Associated Stations: %d', perfdatas => [ - { value => 'wlanAPBssidNumAssociatedStations_absolute', template => '%d', + { value => 'wlanAPBssidNumAssociatedStations', template => '%d', label_extra_instance => 1 }, ], } @@ -80,7 +80,7 @@ sub set_counters { { name => 'wlanAPESSID' } ], output_template => 'Channel Noise: %d', perfdatas => [ - { value => 'apChannelNoise_absolute', template => '%d', + { value => 'apChannelNoise', template => '%d', label_extra_instance => 1 }, ], } @@ -90,7 +90,7 @@ sub set_counters { { name => 'wlanAPESSID' } ], output_template => 'Signal To Noise Ratio: %d', perfdatas => [ - { value => 'apSignalToNoiseRatio_absolute', template => '%d', + { value => 'apSignalToNoiseRatio', template => '%d', label_extra_instance => 1 }, ], } diff --git a/centreon/common/aruba/snmp/mode/apstatus.pm b/centreon/common/aruba/snmp/mode/apstatus.pm index 932207977..d585e3893 100644 --- a/centreon/common/aruba/snmp/mode/apstatus.pm +++ b/centreon/common/aruba/snmp/mode/apstatus.pm @@ -63,7 +63,7 @@ sub set_counters { key_values => [ { name => 'connected' } ], output_template => 'Total connected AP: %d', perfdatas => [ - { value => 'connected_absolute', template => '%d', min => 0 }, + { value => 'connected', template => '%d', min => 0 }, ], } }, @@ -83,8 +83,8 @@ sub set_counters { key_values => [ { name => 'wlanAPUpTime' }, { name => 'wlanAPName' } ], output_template => 'Uptime: %ss', perfdatas => [ - { value => 'wlanAPUpTime_absolute', template => '%s', - unit => 's', label_extra_instance => 1, instance_use => 'wlanAPName_absolute' }, + { value => 'wlanAPUpTime', template => '%s', + unit => 's', label_extra_instance => 1, instance_use => 'wlanAPName' }, ], } }, @@ -92,8 +92,8 @@ sub set_counters { key_values => [ { name => 'wlanAPNumBootstraps' }, { name => 'wlanAPName' } ], output_template => 'Controller Bootstrap Count: %d', perfdatas => [ - { value => 'wlanAPNumBootstraps_absolute', template => '%d', - label_extra_instance => 1, instance_use => 'wlanAPName_absolute' }, + { value => 'wlanAPNumBootstraps', template => '%d', + label_extra_instance => 1, instance_use => 'wlanAPName' }, ], } }, @@ -101,8 +101,8 @@ sub set_counters { key_values => [ { name => 'wlanAPNumReboots' }, { name => 'wlanAPName' } ], output_template => 'Reboot Count: %d', perfdatas => [ - { value => 'wlanAPNumReboots_absolute', template => '%d', - label_extra_instance => 1, instance_use => 'wlanAPName_absolute' }, + { value => 'wlanAPNumReboots', template => '%d', + label_extra_instance => 1, instance_use => 'wlanAPName' }, ], } }, diff --git a/centreon/common/aruba/snmp/mode/apusers.pm b/centreon/common/aruba/snmp/mode/apusers.pm index d0f547554..5df8571ce 100644 --- a/centreon/common/aruba/snmp/mode/apusers.pm +++ b/centreon/common/aruba/snmp/mode/apusers.pm @@ -38,7 +38,7 @@ sub set_counters { key_values => [ { name => 'total' } ], output_template => 'Total Users : %s', perfdatas => [ - { label => 'total', value => 'total_absolute', template => '%s', + { label => 'total', value => 'total', template => '%s', unit => 'users', min => 0 }, ], } @@ -47,7 +47,7 @@ sub set_counters { key_values => [ { name => 'total_none' } ], output_template => 'Total Auth None : %s', perfdatas => [ - { label => 'total_none', value => 'total_none_absolute', template => '%s', + { label => 'total_none', value => 'total_none', template => '%s', unit => 'users', min => 0 }, ], } @@ -56,7 +56,7 @@ sub set_counters { key_values => [ { name => 'total_other' } ], output_template => 'Total Auth Other : %s', perfdatas => [ - { label => 'total_other', value => 'total_other_absolute', template => '%s', + { label => 'total_other', value => 'total_other', template => '%s', unit => 'users', min => 0 }, ], } @@ -65,7 +65,7 @@ sub set_counters { key_values => [ { name => 'total_web' } ], output_template => 'Total Auth Web : %s', perfdatas => [ - { label => 'total_web', value => 'total_web_absolute', template => '%s', + { label => 'total_web', value => 'total_web', template => '%s', unit => 'users', min => 0 }, ], } @@ -74,7 +74,7 @@ sub set_counters { key_values => [ { name => 'total_dot1x' } ], output_template => 'Total Auth Dot1x : %s', perfdatas => [ - { label => 'total_dot1x', value => 'total_dot1x_absolute', template => '%s', + { label => 'total_dot1x', value => 'total_dot1x', template => '%s', unit => 'users', min => 0 }, ], } @@ -83,7 +83,7 @@ sub set_counters { key_values => [ { name => 'total_vpn' } ], output_template => 'Total Auth Vpn : %s', perfdatas => [ - { label => 'total_vpn', value => 'total_vpn_absolute', template => '%s', + { label => 'total_vpn', value => 'total_vpn', template => '%s', unit => 'users', min => 0 }, ], } @@ -92,7 +92,7 @@ sub set_counters { key_values => [ { name => 'total_mac' } ], output_template => 'Total Auth Mac : %s', perfdatas => [ - { label => 'total_mac', value => 'total_mac_absolute', template => '%s', + { label => 'total_mac', value => 'total_mac', template => '%s', unit => 'users', min => 0 }, ], } @@ -101,7 +101,7 @@ sub set_counters { key_values => [ { name => 'avg_connection_time' } ], output_template => 'Users average connection time : %.3f seconds', perfdatas => [ - { label => 'avg_connection_time', value => 'avg_connection_time_absolute', template => '%.3f', + { label => 'avg_connection_time', value => 'avg_connection_time', template => '%.3f', unit => 's', min => 0 }, ], } @@ -113,8 +113,8 @@ sub set_counters { key_values => [ { name => 'users' }, { name => 'essid' } ], output_template => 'users : %s', perfdatas => [ - { label => 'essid', value => 'users_absolute', template => '%s', - unit => 'users', min => 0, label_extra_instance => 1, instance_use => 'essid_absolute' }, + { label => 'essid', value => 'users', template => '%s', + unit => 'users', min => 0, label_extra_instance => 1, instance_use => 'essid' }, ], } }, @@ -125,8 +125,8 @@ sub set_counters { key_values => [ { name => 'users' }, { name => 'ap_id' } ], output_template => 'users : %s', perfdatas => [ - { label => 'ap', value => 'users_absolute', template => '%s', - unit => 'users', min => 0, label_extra_instance => 1, instance_use => 'ap_id_absolute' }, + { label => 'ap', value => 'users', template => '%s', + unit => 'users', min => 0, label_extra_instance => 1, instance_use => 'ap_id' }, ], } }, diff --git a/centreon/common/aruba/snmp/mode/controllerstatus.pm b/centreon/common/aruba/snmp/mode/controllerstatus.pm index 58032b9d6..08346a6c9 100644 --- a/centreon/common/aruba/snmp/mode/controllerstatus.pm +++ b/centreon/common/aruba/snmp/mode/controllerstatus.pm @@ -64,7 +64,7 @@ sub set_counters { key_values => [ { name => 'current' } ], output_template => 'Total controllers: %d', perfdatas => [ - { value => 'current_absolute', template => '%d', min => 0 }, + { value => 'current', template => '%d', min => 0 }, ], } }, diff --git a/centreon/common/aruba/snmp/mode/cpu.pm b/centreon/common/aruba/snmp/mode/cpu.pm index fc90abc14..4b8bec6f6 100644 --- a/centreon/common/aruba/snmp/mode/cpu.pm +++ b/centreon/common/aruba/snmp/mode/cpu.pm @@ -38,8 +38,8 @@ sub set_counters { key_values => [ { name => 'sysExtProcessorLoad' }, { name => 'sysExtProcessorDescr' } ], output_template => 'Utilization %.2f%%', perfdatas => [ - { label => 'utilization', value => 'sysExtProcessorLoad_absolute', template => '%.2f', min => 0, max => 100, - unit => '%', label_extra_instance => 1, instance_use => 'sysExtProcessorDescr_absolute' }, + { label => 'utilization', value => 'sysExtProcessorLoad', template => '%.2f', min => 0, max => 100, + unit => '%', label_extra_instance => 1, instance_use => 'sysExtProcessorDescr' }, ], } }, diff --git a/centreon/common/avaya/snmp/mode/cpu.pm b/centreon/common/avaya/snmp/mode/cpu.pm index 3652a7747..052a46e23 100644 --- a/centreon/common/avaya/snmp/mode/cpu.pm +++ b/centreon/common/avaya/snmp/mode/cpu.pm @@ -37,8 +37,8 @@ sub set_counters { key_values => [ { name => 'cpu' }, { name => 'display' } ], output_template => 'usage : %s %%', perfdatas => [ - { label => 'cpu_usage', value => 'cpu_absolute', template => '%s', - unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'cpu_usage', value => 'cpu', template => '%s', + unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/centreon/common/broadcom/fastpath/snmp/mode/cpu.pm b/centreon/common/broadcom/fastpath/snmp/mode/cpu.pm index cfa18018d..871b6e876 100644 --- a/centreon/common/broadcom/fastpath/snmp/mode/cpu.pm +++ b/centreon/common/broadcom/fastpath/snmp/mode/cpu.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'usage_5s' } ], output_template => '%.2f %% (5sec)', output_error_template => "%s (5sec)", perfdatas => [ - { label => 'cpu_5s', value => 'usage_5s_absolute', template => '%.2f', + { label => 'cpu_5s', value => 'usage_5s', template => '%.2f', unit => '%', min => 0, max => 100 }, ], } @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'usage_1m' } ], output_template => '%.2f %% (1m)', output_error_template => "%s (1min)", perfdatas => [ - { label => 'cpu_1m', value => 'usage_1m_absolute', template => '%.2f', + { label => 'cpu_1m', value => 'usage_1m', template => '%.2f', unit => '%', min => 0, max => 100 }, ], } @@ -55,7 +55,7 @@ sub set_counters { key_values => [ { name => 'usage_5m' } ], output_template => '%.2f %% (5min)', output_error_template => "%s (5min)", perfdatas => [ - { label => 'cpu_5m', value => 'usage_5m_absolute', template => '%.2f', + { label => 'cpu_5m', value => 'usage_5m', template => '%.2f', unit => '%', min => 0, max => 100 }, ], } diff --git a/centreon/common/cisco/ironport/snmp/mode/cpu.pm b/centreon/common/cisco/ironport/snmp/mode/cpu.pm index 014ec5145..48bc32396 100644 --- a/centreon/common/cisco/ironport/snmp/mode/cpu.pm +++ b/centreon/common/cisco/ironport/snmp/mode/cpu.pm @@ -36,7 +36,7 @@ sub set_counters { key_values => [ { name => 'perCentCPUUtilization' } ], output_template => 'cpu global usage is: %.2f%%', perfdatas => [ - { value => 'perCentCPUUtilization_absolute', template => '%.2f', + { value => 'perCentCPUUtilization', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } @@ -45,7 +45,7 @@ sub set_counters { key_values => [ { name => 'cacheCpuUsage' } ], output_template => 'cpu proxy usage is: %.2f%%', perfdatas => [ - { value => 'cacheCpuUsage_absolute', template => '%.2f', + { value => 'cacheCpuUsage', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } diff --git a/centreon/common/cisco/ironport/snmp/mode/mailusage.pm b/centreon/common/cisco/ironport/snmp/mode/mailusage.pm index 20e923c2a..4244bbe4a 100644 --- a/centreon/common/cisco/ironport/snmp/mode/mailusage.pm +++ b/centreon/common/cisco/ironport/snmp/mode/mailusage.pm @@ -56,7 +56,7 @@ sub set_counters { key_values => [ { name => 'msgs_in_work_queue' } ], output_template => 'messages in work queue: %s', perfdatas => [ - { value => 'msgs_in_work_queue_absolute', template => '%s', min => 0 }, + { value => 'msgs_in_work_queue', template => '%s', min => 0 }, ], } }, @@ -64,7 +64,7 @@ sub set_counters { key_values => [ { name => 'outstandingDNSRequests' } ], output_template => 'dns requests with no reply: %s', perfdatas => [ - { value => 'outstandingDNSRequests_absolute', template => '%s', min => 0 }, + { value => 'outstandingDNSRequests', template => '%s', min => 0 }, ], } }, @@ -72,7 +72,7 @@ sub set_counters { key_values => [ { name => 'pendingDNSRequests' } ], output_template => 'dns requests pending: %s', perfdatas => [ - { value => 'pendingDNSRequests_absolute', template => '%s', min => 0 }, + { value => 'pendingDNSRequests', template => '%s', min => 0 }, ], } }, @@ -80,7 +80,7 @@ sub set_counters { key_values => [ { name => 'openFilesOrSockets' } ], output_template => 'fd opened: %s', perfdatas => [ - { value => 'openFilesOrSockets_absolute', template => '%s', min => 0 }, + { value => 'openFilesOrSockets', template => '%s', min => 0 }, ], } }, @@ -88,7 +88,7 @@ sub set_counters { key_values => [ { name => 'mailTransferThreads' } ], output_template => 'threads mail: %s', perfdatas => [ - { value => 'mailTransferThreads_absolute', template => '%s', min => 0 }, + { value => 'mailTransferThreads', template => '%s', min => 0 }, ], } }, @@ -99,8 +99,8 @@ sub set_counters { key_values => [ { name => 'updateFailures', diff => 1 }, { name => 'updateServiceName' } ], output_template => 'update failures: %s', perfdatas => [ - { value => 'updateFailures_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'updateServiceName_absolute' }, + { value => 'updateFailures', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'updateServiceName' }, ], } }, @@ -110,10 +110,10 @@ sub set_counters { { label => 'time-expiration', nlabel => 'key.time.expiration.seconds', set => { key_values => [ { name => 'seconds' }, { name => 'msg' }, { name => 'display' } ], output_template => '%s remaining before expiration', - output_use => 'msg_absolute', + output_use => 'msg', perfdatas => [ - { value => 'seconds_absolute', template => '%s', - unit => 's', label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'seconds', template => '%s', + unit => 's', label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/centreon/common/cisco/ironport/snmp/mode/proxyusage.pm b/centreon/common/cisco/ironport/snmp/mode/proxyusage.pm index 8a3c3b4fc..85b5b5b81 100644 --- a/centreon/common/cisco/ironport/snmp/mode/proxyusage.pm +++ b/centreon/common/cisco/ironport/snmp/mode/proxyusage.pm @@ -64,28 +64,25 @@ sub set_counters { key_values => [ { name => 'cacheClientErrors', diff => 1 } ], output_template => 'client errors: %s', perfdatas => [ - { value => 'cacheClientErrors_absolute', template => '%s', - min => 0 }, + { template => '%s', min => 0 }, ], } }, { label => 'client-http-traffic-in', display_ok => 0, nlabel => 'client.http.traffic.in.bitspersecond', set => { - key_values => [ { name => 'cacheClientInKb', diff => 1 } ], + key_values => [ { name => 'cacheClientInKb', per_second => 1 } ], output_template => 'client traffic in: %s %s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { value => 'cacheClientInKb_per_second', template => '%s', - min => 0, unit => 'b/s' }, + { template => '%s', min => 0, unit => 'b/s' }, ], } }, { label => 'client-http-traffic-out', display_ok => 0, nlabel => 'client.http.traffic.out.bitspersecond', set => { - key_values => [ { name => 'cacheClientOutKb', diff => 1 } ], + key_values => [ { name => 'cacheClientOutKb', per_second => 1 } ], output_template => 'client traffic out: %s %s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { value => 'cacheClientOutKb_per_second', template => '%s', - min => 0, unit => 'b/s' }, + { template => '%s', min => 0, unit => 'b/s' }, ], } }, @@ -93,18 +90,15 @@ sub set_counters { key_values => [ { name => 'cacheClientTotalConns' } ], output_template => 'total number of clients: %s', perfdatas => [ - { value => 'cacheClientTotalConns_absolute', template => '%s', - min => 0 }, + { template => '%s', min => 0 }, ], } }, { label => 'client-http-requests', display_ok => 0, nlabel => 'client.http.requests.persecond', set => { - key_values => [ { name => 'cacheClientRequests', diff => 1 } ], + key_values => [ { name => 'cacheClientRequests', per_second => 1 } ], output_template => 'client requests: %.2f/s', - per_second => 1, perfdatas => [ - { value => 'cacheClientRequests_per_second', template => '%.2f', - min => 0, unit => '/s' }, + { template => '%.2f', min => 0, unit => '/s' }, ], } }, @@ -128,28 +122,25 @@ sub set_counters { key_values => [ { name => 'cacheMeanRespTime' } ], output_template => 'http mean response time: %s ms', perfdatas => [ - { value => 'cacheMeanRespTime_absolute', template => '%s', - min => 0, unit => 'ms' }, + { template => '%s', min => 0, unit => 'ms' }, ], } }, { label => 'server-traffic-in', display_ok => 0, nlabel => 'server.traffic.in.bitspersecond', set => { - key_values => [ { name => 'cacheServerInKb', diff => 1 } ], + key_values => [ { name => 'cacheServerInKb', per_second => 1 } ], output_template => 'server traffic in: %s %s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { value => 'cacheServerInKb_per_second', template => '%s', - min => 0, unit => 'b/s' }, + { template => '%s', min => 0, unit => 'b/s' }, ], } }, { label => 'server-traffic-out', display_ok => 0, nlabel => 'server.traffic.out.bitspersecond', set => { - key_values => [ { name => 'cacheServerOutKb', diff => 1 } ], + key_values => [ { name => 'cacheServerOutKb', per_second => 1 } ], output_template => 'server traffic out: %s %s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { value => 'cacheServerOutKb_per_second', template => '%s', - min => 0, unit => 'b/s' }, + { template => '%s', min => 0, unit => 'b/s' }, ], } }, diff --git a/centreon/common/cisco/ironport/xmlapi/mode/systemusage.pm b/centreon/common/cisco/ironport/xmlapi/mode/systemusage.pm index cdf288484..645188db9 100644 --- a/centreon/common/cisco/ironport/xmlapi/mode/systemusage.pm +++ b/centreon/common/cisco/ironport/xmlapi/mode/systemusage.pm @@ -63,8 +63,7 @@ sub set_counters { key_values => [ { name => 'ram_utilization' } ], output_template => 'memory usage: %.2f %%', perfdatas => [ - { value => 'ram_utilization_absolute', template => '%.2f', - unit => '%', min => 0, max => 100 }, + { template => '%.2f', unit => '%', min => 0, max => 100 }, ], } }, @@ -72,8 +71,7 @@ sub set_counters { key_values => [ { name => 'total_utilization' } ], output_template => 'total cpu usage: %.2f %%', perfdatas => [ - { value => 'total_utilization_absolute', template => '%.2f', - unit => '%', min => 0, max => 100 }, + { template => '%.2f', unit => '%', min => 0, max => 100 }, ], } }, @@ -81,8 +79,7 @@ sub set_counters { key_values => [ { name => 'disk_utilization' } ], output_template => 'disk i/o usage: %.2f %%', perfdatas => [ - { value => 'disk_utilization_absolute', template => '%.2f', - unit => '%', min => 0, max => 100 }, + { template => '%.2f', unit => '%', min => 0, max => 100 }, ], } }, @@ -90,8 +87,7 @@ sub set_counters { key_values => [ { name => 'log_used' } ], output_template => 'logging disk usage: %.2f %%', perfdatas => [ - { value => 'log_used_absolute', template => '%.2f', - unit => '%', min => 0, max => 100 }, + { template => '%.2f', unit => '%', min => 0, max => 100 }, ], } }, @@ -99,7 +95,7 @@ sub set_counters { key_values => [ { name => 'resource_conservation' } ], output_template => 'resource conservation mode: %s', perfdatas => [ - { value => 'resource_conservation_absolute', template => '%s', min => 0 }, + { template => '%s', min => 0 }, ], } }, @@ -107,7 +103,7 @@ sub set_counters { key_values => [ { name => 'conn_in' } ], output_template => 'current inbound connections: %s', perfdatas => [ - { value => 'conn_in_absolute', template => '%s', min => 0 }, + { template => '%s', min => 0 }, ], } }, @@ -115,7 +111,7 @@ sub set_counters { key_values => [ { name => 'conn_out' } ], output_template => 'current outbound connections: %s', perfdatas => [ - { value => 'conn_out_absolute', template => '%s', min => 0 }, + { template => '%s', min => 0 }, ], } }, @@ -123,7 +119,7 @@ sub set_counters { key_values => [ { name => 'active_recips' } ], output_template => 'queue active recipients: %s', perfdatas => [ - { value => 'active_recips_absolute', template => '%s', min => 0 }, + { value => 'active_recips', template => '%s', min => 0 }, ], } }, @@ -131,7 +127,7 @@ sub set_counters { key_values => [ { name => 'msgs_in_quarantine' } ], output_template => 'messages in quarantine: %s', perfdatas => [ - { value => 'msgs_in_quarantine_absolute', template => '%s', min => 0 }, + { template => '%s', min => 0 }, ], } }, @@ -139,17 +135,15 @@ sub set_counters { key_values => [ { name => 'msgs_in_work_queue' } ], output_template => 'messages in work queue: %s', perfdatas => [ - { value => 'msgs_in_work_queue_absolute', template => '%s', min => 0 }, + { template => '%s', min => 0 }, ], } }, { label => 'messages-received', nlabel => 'system.queue.messages.received.persecond', set => { - key_values => [ { name => 'msgs_received_lifetime', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'msgs_received_lifetime', per_second => 1 } ], output_template => 'messages received: %.2f/s', perfdatas => [ - { value => 'msgs_received_lifetime_per_second', template => '%.2f', - unit => '/s', min => 0 }, + { template => '%.2f', unit => '/s', min => 0 }, ], } }, @@ -157,8 +151,7 @@ sub set_counters { key_values => [ { name => 'queuedisk' } ], output_template => 'queue disk usage: %.2f %%', perfdatas => [ - { value => 'queuedisk_absolute', template => '%.2f', - unit => '%', min => 0, max => 100 }, + { template => '%.2f', unit => '%', min => 0, max => 100 }, ], } }, @@ -184,7 +177,7 @@ sub new { 'warning-system-status:s' => { name => 'warning_system_status', default => '' }, 'critical-system-status:s' => { name => 'critical_system_status', default => '%{system_status} !~ /online/i' }, }); - + $self->{http} = centreon::plugins::http->new(%options); return $self; } diff --git a/centreon/common/cisco/standard/snmp/mode/cpu.pm b/centreon/common/cisco/standard/snmp/mode/cpu.pm index 592451965..d7861c5f3 100644 --- a/centreon/common/cisco/standard/snmp/mode/cpu.pm +++ b/centreon/common/cisco/standard/snmp/mode/cpu.pm @@ -38,7 +38,7 @@ sub set_counters { key_values => [ { name => 'average_5s' } ], output_template => '%.2f %% (5s)', perfdatas => [ - { label => 'total_cpu_5s_avg', value => 'average_5s_absolute', template => '%.2f', + { label => 'total_cpu_5s_avg', value => 'average_5s', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } @@ -47,7 +47,7 @@ sub set_counters { key_values => [ { name => 'average_1m' } ], output_template => '%.2f %% (1m)', perfdatas => [ - { label => 'total_cpu_1m_avg', value => 'average_1m_absolute', template => '%.2f', + { label => 'total_cpu_1m_avg', value => 'average_1m', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } @@ -56,7 +56,7 @@ sub set_counters { key_values => [ { name => 'average_5m' } ], output_template => '%.2f %% (5m)', perfdatas => [ - { label => 'total_cpu_5m_avg', value => 'average_5m_absolute', template => '%.2f', + { label => 'total_cpu_5m_avg', value => 'average_5m', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } @@ -68,8 +68,8 @@ sub set_counters { key_values => [ { name => 'cpu_5s' }, { name => 'display' } ], output_template => '%.2f %% (5s)', perfdatas => [ - { label => 'cpu_5s', value => 'cpu_5s_absolute', template => '%.2f', - min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'cpu_5s', value => 'cpu_5s', template => '%.2f', + min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -77,8 +77,8 @@ sub set_counters { key_values => [ { name => 'cpu_1m' }, { name => 'display' } ], output_template => '%.2f %% (1m)', perfdatas => [ - { label => 'cpu_1m', value => 'cpu_1m_absolute', template => '%.2f', - min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'cpu_1m', value => 'cpu_1m', template => '%.2f', + min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -86,8 +86,8 @@ sub set_counters { key_values => [ { name => 'cpu_5m' }, { name => 'display' } ], output_template => '%.2f %% (5m)', perfdatas => [ - { label => 'cpu_5m', value => 'cpu_5m_absolute', template => '%.2f', - min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'cpu_5m', value => 'cpu_5m', template => '%.2f', + min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/centreon/common/cisco/standard/snmp/mode/ipsectunnel.pm b/centreon/common/cisco/standard/snmp/mode/ipsectunnel.pm index 979d30190..cabad8c65 100644 --- a/centreon/common/cisco/standard/snmp/mode/ipsectunnel.pm +++ b/centreon/common/cisco/standard/snmp/mode/ipsectunnel.pm @@ -40,16 +40,16 @@ sub set_counters { key_values => [ { name => 'total' } ], output_template => 'Total Tunnels : %s', perfdatas => [ - { label => 'total_tunnels', value => 'total_absolute', template => '%s', - min => 0 }, - ], + { label => 'total_tunnels', template => '%s', min => 0 } + ] } - }, + } ]; + $self->{maps_counters}->{tunnel} = [ { label => 'traffic-in', set => { key_values => [], - per_second => 1, manual_keys => 1, + manual_keys => 1, closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'In' }, closure_custom_output => $self->can('custom_traffic_output'), closure_custom_perfdata => $self->can('custom_traffic_perfdata'), @@ -58,7 +58,7 @@ sub set_counters { }, { label => 'traffic-out', set => { key_values => [], - per_second => 1, manual_keys => 1, + manual_keys => 1, closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'Out' }, closure_custom_output => $self->can('custom_traffic_output'), closure_custom_perfdata => $self->can('custom_traffic_perfdata'), @@ -67,7 +67,7 @@ sub set_counters { }, { label => 'drop-in', set => { key_values => [], - per_second => 1, manual_keys => 1, + manual_keys => 1, closure_custom_calc => $self->can('custom_drop_calc'), closure_custom_calc_extra_options => { label_ref => 'In' }, closure_custom_output => $self->can('custom_drop_output'), closure_custom_perfdata => $self->can('custom_drop_perfdata'), @@ -76,7 +76,7 @@ sub set_counters { }, { label => 'drop-out', set => { key_values => [], - per_second => 1, manual_keys => 1, + manual_keys => 1, closure_custom_calc => $self->can('custom_drop_calc'), closure_custom_calc_extra_options => { label_ref => 'Out' }, closure_custom_output => $self->can('custom_drop_output'), closure_custom_perfdata => $self->can('custom_drop_perfdata'), @@ -87,11 +87,10 @@ sub set_counters { key_values => [ { name => 'sa' }, { name => 'display' } ], output_template => 'Total SA : %s', perfdatas => [ - { label => 'total_sa', value => 'sa_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, - ], + { label => 'total_sa', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' } + ] } - }, + } ]; } @@ -184,9 +183,10 @@ sub custom_drop_threshold { sub custom_drop_output { my ($self, %options) = @_; - my $msg = sprintf("Drop %s : %s pkts/s", - $self->{result_values}->{label}, $self->{result_values}->{pkts_per_seconds}); - return $msg; + return sprintf( + "Drop %s : %s pkts/s", + $self->{result_values}->{label}, $self->{result_values}->{pkts_per_seconds} + ); } sub custom_drop_calc { @@ -223,8 +223,8 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - "filter-name:s" => { name => 'filter_name' }, - "filter-sa:s" => { name => 'filter_sa' }, + 'filter-name:s' => { name => 'filter_name' }, + 'filter-sa:s' => { name => 'filter_sa' }, }); return $self; diff --git a/centreon/common/cisco/standard/snmp/mode/ipsla.pm b/centreon/common/cisco/standard/snmp/mode/ipsla.pm index 1623c0717..30b4464ec 100644 --- a/centreon/common/cisco/standard/snmp/mode/ipsla.pm +++ b/centreon/common/cisco/standard/snmp/mode/ipsla.pm @@ -58,7 +58,7 @@ sub set_counters { ], output_template => 'Completion Time : %s', perfdatas => [ - { label => 'completion_time', value => 'rttMonLatestRttOperCompletionTime_absolute', template => '%s', + { label => 'completion_time', value => 'rttMonLatestRttOperCompletionTime', template => '%s', min => 0, label_extra_instance => 1 }, ], } diff --git a/centreon/common/cisco/standard/snmp/mode/load.pm b/centreon/common/cisco/standard/snmp/mode/load.pm index 14e21df19..3a80c6130 100644 --- a/centreon/common/cisco/standard/snmp/mode/load.pm +++ b/centreon/common/cisco/standard/snmp/mode/load.pm @@ -37,8 +37,8 @@ sub set_counters { key_values => [ { name => 'cpmCPULoadAvg1min' }, { name => 'display' } ], output_template => '%.2f (1m)', perfdatas => [ - { value => 'cpmCPULoadAvg1min_absolute', template => '%.2f', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'cpmCPULoadAvg1min', template => '%.2f', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -46,8 +46,8 @@ sub set_counters { key_values => [ { name => 'cpmCPULoadAvg5min' }, { name => 'display' } ], output_template => '%.2f (5m)', perfdatas => [ - { value => 'cpmCPULoadAvg5min_absolute', template => '%.2f', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'cpmCPULoadAvg5min', template => '%.2f', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -55,8 +55,8 @@ sub set_counters { key_values => [ { name => 'cpmCPULoadAvg15min' }, { name => 'display' } ], output_template => '%.2f (15m)', perfdatas => [ - { value => 'cpmCPULoadAvg15min_absolute', template => '%.2f', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'cpmCPULoadAvg15min', template => '%.2f', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/centreon/common/cisco/standard/snmp/mode/memoryflash.pm b/centreon/common/cisco/standard/snmp/mode/memoryflash.pm index bf31fcf72..f2ac0776b 100644 --- a/centreon/common/cisco/standard/snmp/mode/memoryflash.pm +++ b/centreon/common/cisco/standard/snmp/mode/memoryflash.pm @@ -37,11 +37,11 @@ sub custom_mem_output { my ($self, %options) = @_; my $msg = sprintf("Total: %s %s Used: %s %s (%.2f%%) Free: %s %s (%.2f%%)", - $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_absolute}), - $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_absolute}), - $self->{result_values}->{prct_used_absolute}, - $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute}), - $self->{result_values}->{prct_free_absolute}); + $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}), + $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}), + $self->{result_values}->{prct_used}, + $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}), + $self->{result_values}->{prct_free}); return $msg; } @@ -65,8 +65,8 @@ sub set_counters { key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'display' } ], closure_custom_output => $self->can('custom_mem_output'), perfdatas => [ - { value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute', - unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'used', template => '%d', min => 0, max => 'total', + unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -74,8 +74,8 @@ sub set_counters { key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'display' } ], closure_custom_output => $self->can('custom_mem_output'), perfdatas => [ - { value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute', - unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'free', template => '%d', min => 0, max => 'total', + unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -83,8 +83,8 @@ sub set_counters { key_values => [ { name => 'prct_used' }, { name => 'display' } ], output_template => 'Used : %.2f %%', perfdatas => [ - { value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, unit => '%', - label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'prct_used', template => '%.2f', min => 0, max => 100, unit => '%', + label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/centreon/common/cisco/standard/snmp/mode/qosusage.pm b/centreon/common/cisco/standard/snmp/mode/qosusage.pm index 79708b47f..77a88387f 100644 --- a/centreon/common/cisco/standard/snmp/mode/qosusage.pm +++ b/centreon/common/cisco/standard/snmp/mode/qosusage.pm @@ -39,7 +39,6 @@ sub set_counters { $self->{maps_counters}->{interface_classmap} = [ { label => 'int-cmap-traffic', set => { key_values => [ { name => 'traffic_usage', diff => 1 }, { name => 'total' }, { name => 'display' } ], - per_second => 1, closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_output => $self->can('custom_traffic_output'), closure_custom_perfdata => $self->can('custom_traffic_perfdata'), @@ -47,34 +46,34 @@ sub set_counters { } }, { label => 'int-cmap-drop', set => { - key_values => [ { name => 'drop_usage', diff => 1 }, { name => 'display' } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'drop_usage', per_second => 1 }, { name => 'display' } ], + output_change_bytes => 2, output_template => 'Drop : %s %s/s', perfdatas => [ - { label => 'icmap_drop', value => 'drop_usage_per_second', template => '%d', - unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' } + { label => 'icmap_drop', template => '%d', + unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display' } ] } } ]; $self->{maps_counters}->{classmap} = [ { label => 'cmap-traffic', set => { - key_values => [ { name => 'traffic_usage', diff => 1 }, { name => 'display' } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'traffic_usage', per_second => 1 }, { name => 'display' } ], + output_change_bytes => 2, output_template => 'Traffic : %s %s/s', perfdatas => [ - { label => 'cmap_traffic', value => 'traffic_usage_per_second', template => '%d', - unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' } + { label => 'cmap_traffic', template => '%d', + unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display' } ] } }, { label => 'cmap-drop', set => { - key_values => [ { name => 'drop_usage', diff => 1 }, { name => 'display' } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'drop_usage', per_second => 1 }, { name => 'display' } ], + output_change_bytes => 2, output_template => 'Drop : %s %s/s', perfdatas => [ - { label => 'cmap_drop', value => 'drop_usage_per_second', template => '%d', - unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' } + { label => 'cmap_drop', template => '%d', + unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display' } ] } } @@ -82,22 +81,20 @@ sub set_counters { $self->{maps_counters}->{total} = [ { label => 'total-traffic', set => { - key_values => [ { name => 'traffic_usage', diff => 1 } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'traffic_usage', per_second => 1 } ], + output_change_bytes => 2, output_template => 'Total Traffic : %s %s/s', perfdatas => [ - { label => 'total_traffic', value => 'traffic_usage_per_second', template => '%d', - unit => 'b/s', min => 0 } + { label => 'total_traffic', template => '%d', unit => 'b/s', min => 0 } ] } }, { label => 'total-drop', set => { - key_values => [ { name => 'drop_usage', diff => 1 } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'drop_usage', per_second => 1 } ], + output_change_bytes => 2, output_template => 'Total Drop : %s %s/s', perfdatas => [ - { label => 'total_drop', value => 'drop_usage_per_second', template => '%d', - unit => 'b/s', min => 0 } + { label => 'total_drop', template => '%d', unit => 'b/s', min => 0 } ] } } diff --git a/centreon/common/cisco/standard/snmp/mode/sessions.pm b/centreon/common/cisco/standard/snmp/mode/sessions.pm index 72eee68d2..48b81a6c0 100644 --- a/centreon/common/cisco/standard/snmp/mode/sessions.pm +++ b/centreon/common/cisco/standard/snmp/mode/sessions.pm @@ -38,8 +38,7 @@ sub set_counters { key_values => [ { name => 'cufwConnGlobalNumActive' } ], output_template => 'current : %s', output_error_template => "current : %s", perfdatas => [ - { label => 'connections_current', value => 'cufwConnGlobalNumActive_absolute', template => '%d', - min => 0 }, + { label => 'connections_current', template => '%d', min => 0 }, ], } }, @@ -47,8 +46,7 @@ sub set_counters { key_values => [ { name => 'cufwConnGlobalConnSetupRate1' } ], output_template => 'average last 1min : %s', output_error_template => "average last 1min : %s", perfdatas => [ - { label => 'connections_1m', value => 'cufwConnGlobalConnSetupRate1_absolute', template => '%d', - min => 0 }, + { label => 'connections_1m', template => '%d', min => 0 }, ], } }, @@ -56,19 +54,18 @@ sub set_counters { key_values => [ { name => 'cufwConnGlobalConnSetupRate5' } ], output_template => 'average last 5min : %s', output_error_template => "average last 5min : %s", perfdatas => [ - { label => 'connections_5m', value => 'cufwConnGlobalConnSetupRate5_absolute', template => '%d', - min => 0 }, + { label => 'connections_5m', template => '%d', min => 0 }, ], } }, ]; + $self->{maps_counters}->{sessions} = [ { label => 'sessions-total', set => { key_values => [ { name => 'crasNumSessions' } ], output_template => 'total : %s', output_error_template => "total : %s", perfdatas => [ - { label => 'sessions_total', value => 'crasNumSessions_absolute', template => '%d', - min => 0 }, + { label => 'sessions_total', template => '%d', min => 0 }, ], } }, @@ -76,18 +73,15 @@ sub set_counters { key_values => [ { name => 'crasEmailNumSessions' } ], output_template => 'current email proxy : %s', output_error_template => "current email proxy : %s", perfdatas => [ - { label => 'sessions_email_current', value => 'crasEmailNumSessions_absolute', template => '%d', - min => 0 }, + { label => 'sessions_email_current', template => '%d', min => 0 }, ], } }, { label => 'sessions-email-psec', set => { - key_values => [ { name => 'crasEmailCumulateSessions', diff => 1 } ], + key_values => [ { name => 'crasEmailCumulateSessions', per_second => 1 } ], output_template => 'email proxy : %.2f/s', output_error_template => "email proxy : %s", - per_second => 1, perfdatas => [ - { label => 'sessions_email_psec', value => 'crasEmailCumulateSessions_per_second', template => '%.2f', - min => 0 }, + { label => 'sessions_email_psec', template => '%.2f', min => 0 }, ], } }, @@ -95,18 +89,15 @@ sub set_counters { key_values => [ { name => 'crasIPSecNumSessions' } ], output_template => 'current ipsec : %s', output_error_template => "current ipsec : %s", perfdatas => [ - { label => 'sessions_ipsec_current', value => 'crasIPSecNumSessions_absolute', template => '%d', - min => 0 }, + { label => 'sessions_ipsec_current', template => '%d', min => 0 }, ], } }, { label => 'sessions-ipsec-psec', set => { - key_values => [ { name => 'crasIPSecCumulateSessions', diff => 1 } ], + key_values => [ { name => 'crasIPSecCumulateSessions', per_second => 1 } ], output_template => 'ipsec : %.2f/s', output_error_template => "ipsec : %s", - per_second => 1, perfdatas => [ - { label => 'sessions_ipsec_psec', value => 'crasIPSecCumulateSessions_per_second', template => '%.2f', - min => 0 }, + { label => 'sessions_ipsec_psec', template => '%.2f', min => 0 }, ], } }, @@ -114,18 +105,15 @@ sub set_counters { key_values => [ { name => 'crasL2LNumSessions' } ], output_template => 'current LAN to LAN : %s', output_error_template => "current LAN to LAN : %s", perfdatas => [ - { label => 'sessions_l2l_current', value => 'crasL2LNumSessions_absolute', template => '%d', - min => 0 }, + { label => 'sessions_l2l_current', template => '%d', min => 0 }, ], } }, { label => 'sessions-l2l-psec', set => { - key_values => [ { name => 'crasL2LCumulateSessions', diff => 1 } ], + key_values => [ { name => 'crasL2LCumulateSessions', per_second => 1 } ], output_template => 'LAN to LAN : %.2f/s', output_error_template => "LAN to LAN : %s", - per_second => 1, perfdatas => [ - { label => 'sessions_l2l_psec', value => 'crasL2LCumulateSessions_per_second', template => '%.2f', - min => 0 }, + { label => 'sessions_l2l_psec', template => '%.2f', min => 0 }, ], } }, @@ -133,18 +121,15 @@ sub set_counters { key_values => [ { name => 'crasLBNumSessions' } ], output_template => 'current load balancing : %s', output_error_template => "current load balancing : %s", perfdatas => [ - { label => 'sessions_lb_current', value => 'crasLBNumSessions_absolute', template => '%d', - min => 0 }, + { label => 'sessions_lb_current', template => '%d', min => 0 }, ], } }, { label => 'sessions-lb-psec', set => { - key_values => [ { name => 'crasLBCumulateSessions', diff => 1 } ], + key_values => [ { name => 'crasLBCumulateSessions', per_second => 1 } ], output_template => 'load balancing : %.2f/s', output_error_template => "load balancing : %s", - per_second => 1, perfdatas => [ - { label => 'sessions_lb_psec', value => 'crasLBCumulateSessions_per_second', template => '%.2f', - min => 0 }, + { label => 'sessions_lb_psec', template => '%.2f', min => 0 }, ], } }, @@ -152,18 +137,15 @@ sub set_counters { key_values => [ { name => 'crasSVCNumSessions' } ], output_template => 'current SVC : %s', output_error_template => "current SVC : %s", perfdatas => [ - { label => 'sessions_svc_current', value => 'crasSVCNumSessions_absolute', template => '%d', - min => 0 }, + { label => 'sessions_svc_current', template => '%d', min => 0 }, ], } }, { label => 'sessions-svc-psec', set => { - key_values => [ { name => 'crasSVCCumulateSessions', diff => 1 } ], + key_values => [ { name => 'crasSVCCumulateSessions', per_second => 1 } ], output_template => 'SVC : %.2f/s', output_error_template => "SVC : %s", - per_second => 1, perfdatas => [ - { label => 'sessions_svc_psec', value => 'crasSVCCumulateSessions_per_second', template => '%.2f', - min => 0 }, + { label => 'sessions_svc_psec', template => '%.2f', min => 0 }, ], } }, @@ -171,18 +153,15 @@ sub set_counters { key_values => [ { name => 'crasWebvpnNumSessions' } ], output_template => 'current webvpn : %s', output_error_template => "current webvpn : %s", perfdatas => [ - { label => 'sessions_webvpn_current', value => 'crasWebvpnNumSessions_absolute', template => '%d', - min => 0 }, + { label => 'sessions_webvpn_current', template => '%d', min => 0 }, ], } }, { label => 'sessions-webvpn-psec', set => { - key_values => [ { name => 'crasWebvpnCumulateSessions', diff => 1 } ], + key_values => [ { name => 'crasWebvpnCumulateSessions', per_second => 1 } ], output_template => 'webvpn : %.2f/s', output_error_template => "webvpn : %s", - per_second => 1, perfdatas => [ - { label => 'sessions_webvpn_psec', value => 'crasWebvpnCumulateSessions_per_second', template => '%.2f', - min => 0 }, + { label => 'sessions_webvpn_psec',template => '%.2f', min => 0 }, ], } }, @@ -205,11 +184,10 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; - - $options{options}->add_options(arguments => - { - }); - + + $options{options}->add_options(arguments => { + }); + return $self; } diff --git a/centreon/common/cisco/standard/snmp/mode/stack.pm b/centreon/common/cisco/standard/snmp/mode/stack.pm index 88ba6792e..35c923df6 100644 --- a/centreon/common/cisco/standard/snmp/mode/stack.pm +++ b/centreon/common/cisco/standard/snmp/mode/stack.pm @@ -77,7 +77,7 @@ sub set_counters { key_values => [ { name => 'waiting' } ], output_template => 'Waiting: %d', perfdatas => [ - { label => 'waiting', value => 'waiting_absolute', template => '%d', + { label => 'waiting', value => 'waiting', template => '%d', min => 0 }, ], } @@ -86,7 +86,7 @@ sub set_counters { key_values => [ { name => 'progressing' } ], output_template => 'Progressing: %d', perfdatas => [ - { label => 'progressing', value => 'progressing_absolute', template => '%d', + { label => 'progressing', value => 'progressing', template => '%d', min => 0 }, ], } @@ -95,7 +95,7 @@ sub set_counters { key_values => [ { name => 'added' } ], output_template => 'Added: %d', perfdatas => [ - { label => 'added', value => 'added_absolute', template => '%d', + { label => 'added', value => 'added', template => '%d', min => 0 }, ], } @@ -104,7 +104,7 @@ sub set_counters { key_values => [ { name => 'ready' } ], output_template => 'Ready: %d', perfdatas => [ - { label => 'ready', value => 'ready_absolute', template => '%d', + { label => 'ready', value => 'ready', template => '%d', min => 0 }, ], } @@ -113,7 +113,7 @@ sub set_counters { key_values => [ { name => 'sdmMismatch' } ], output_template => 'SDM Mismatch: %d', perfdatas => [ - { label => 'sdm_mismatch', value => 'sdmMismatch_absolute', template => '%d', + { label => 'sdm_mismatch', value => 'sdmMismatch', template => '%d', min => 0 }, ], } @@ -122,7 +122,7 @@ sub set_counters { key_values => [ { name => 'verMismatch' } ], output_template => 'Version Mismatch: %d', perfdatas => [ - { label => 'version_mismatch', value => 'verMismatch_absolute', template => '%d', + { label => 'version_mismatch', value => 'verMismatch', template => '%d', min => 0 }, ], } @@ -131,7 +131,7 @@ sub set_counters { key_values => [ { name => 'featureMismatch' } ], output_template => 'Feature Mismatch: %d', perfdatas => [ - { label => 'feature_mismatch', value => 'featureMismatch_absolute', template => '%d', + { label => 'feature_mismatch', value => 'featureMismatch', template => '%d', min => 0 }, ], } @@ -140,7 +140,7 @@ sub set_counters { key_values => [ { name => 'newMasterInit' } ], output_template => 'New Master Init: %d', perfdatas => [ - { label => 'new_master_init', value => 'newMasterInit_absolute', template => '%d', + { label => 'new_master_init', value => 'newMasterInit', template => '%d', min => 0 }, ], } @@ -149,7 +149,7 @@ sub set_counters { key_values => [ { name => 'provisioned' } ], output_template => 'Provisioned: %d', perfdatas => [ - { label => 'provisioned', value => 'provisioned_absolute', template => '%d', + { label => 'provisioned', value => 'provisioned', template => '%d', min => 0 }, ], } @@ -158,7 +158,7 @@ sub set_counters { key_values => [ { name => 'invalid' } ], output_template => 'Invalid: %d', perfdatas => [ - { label => 'invalid', value => 'invalid_absolute', template => '%d', + { label => 'invalid', value => 'invalid', template => '%d', min => 0 }, ], } @@ -167,7 +167,7 @@ sub set_counters { key_values => [ { name => 'removed' } ], output_template => 'Removed: %d', perfdatas => [ - { label => 'removed', value => 'removed_absolute', template => '%d', + { label => 'removed', value => 'removed', template => '%d', min => 0 }, ], } diff --git a/centreon/common/cisco/standard/snmp/mode/voicecall.pm b/centreon/common/cisco/standard/snmp/mode/voicecall.pm index 8db776d07..694541e22 100644 --- a/centreon/common/cisco/standard/snmp/mode/voicecall.pm +++ b/centreon/common/cisco/standard/snmp/mode/voicecall.pm @@ -38,7 +38,7 @@ sub set_counters { key_values => [ { name => 'active_1m_average' } ], output_template => '%.2f (1m)', perfdatas => [ - { value => 'active_1m_average_absolute', template => '%.2f', min => 0 }, + { value => 'active_1m_average', template => '%.2f', min => 0 }, ], } }, @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'active_5m_average' } ], output_template => '%.2f (5m)', perfdatas => [ - { value => 'active_5m_average_absolute', template => '%.2f', min => 0 }, + { value => 'active_5m_average', template => '%.2f', min => 0 }, ], } }, @@ -54,7 +54,7 @@ sub set_counters { key_values => [ { name => 'active_15m_average' } ], output_template => '%.2f (15m)', perfdatas => [ - { value => 'active_15m_average_absolute', template => '%.2f', min => 0 }, + { value => 'active_15m_average', template => '%.2f', min => 0 }, ], } }, @@ -65,7 +65,7 @@ sub set_counters { key_values => [ { name => 'active_calls' }, { name => 'display' } ], output_template => 'active calls %s', perfdatas => [ - { value => 'active_calls_absolute', template => '%s', + { value => 'active_calls', template => '%s', min => 0, label_extra_instance => 1 }, ], } diff --git a/centreon/common/cisco/standard/snmp/mode/wan3g.pm b/centreon/common/cisco/standard/snmp/mode/wan3g.pm index da72efd56..8722adb2e 100644 --- a/centreon/common/cisco/standard/snmp/mode/wan3g.pm +++ b/centreon/common/cisco/standard/snmp/mode/wan3g.pm @@ -130,8 +130,8 @@ sub set_counters { output_template => 'memory used: %s%s', output_change_bytes => 1, perfdatas => [ - { value => 'temperature_absolute', template => '%s', min => 0, - unit => 'C', label_extra_instance => 1, instance_use => 'display_absolute' } + { template => '%s', min => 0, + unit => 'C', label_extra_instance => 1, instance_use => 'display' } ] } } @@ -151,8 +151,8 @@ sub set_counters { output_template => 'received signal strength: %s dBm', output_change_bytes => 1, perfdatas => [ - { value => 'rssi_absolute', template => '%s', min => 0, - unit => 'dBm', label_extra_instance => 1, instance_use => 'display_absolute' } + { template => '%s', min => 0, + unit => 'dBm', label_extra_instance => 1, instance_use => 'display' } ] } } @@ -168,22 +168,20 @@ sub set_counters { } }, { label => 'traffic-in', nlabel => 'modem.traffic.in.bitspersecond', set => { - key_values => [ { name => 'traffic_in', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'traffic_in', per_second => 1 }, { name => 'display' } ], output_template => 'traffic in: %s%s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { value => 'traffic_in_per_second', template => '%s', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' } + { template => '%s', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' } ] } }, { label => 'traffic-out', nlabel => 'modem.traffic.out.bitspersecond', set => { - key_values => [ { name => 'traffic_out', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'traffic_out', per_second => 1 }, { name => 'display' } ], output_template => 'traffic out: %s%s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { value => 'traffic_out_per_second', template => '%s', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' } + { template => '%s', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' } ] } } diff --git a/centreon/common/cps/ups/snmp/mode/batterystatus.pm b/centreon/common/cps/ups/snmp/mode/batterystatus.pm index f768e980a..5b4d63b14 100644 --- a/centreon/common/cps/ups/snmp/mode/batterystatus.pm +++ b/centreon/common/cps/ups/snmp/mode/batterystatus.pm @@ -36,8 +36,8 @@ sub custom_load_output { my ($self, %options) = @_; return sprintf("charge remaining: %s%% (%s minutes remaining)", - $self->{result_values}->{charge_remain_absolute}, - $self->{result_values}->{minute_remain_absolute} + $self->{result_values}->{charge_remain}, + $self->{result_values}->{minute_remain} ); } @@ -61,7 +61,7 @@ sub set_counters { key_values => [ { name => 'charge_remain' }, { name => 'minute_remain' } ], closure_custom_output => $self->can('custom_load_output'), perfdatas => [ - { value => 'charge_remain_absolute', template => '%s', min => 0, max => 100, unit => '%' }, + { value => 'charge_remain', template => '%s', min => 0, max => 100, unit => '%' }, ], } }, @@ -69,7 +69,7 @@ sub set_counters { key_values => [ { name => 'voltage', no_value => 0 } ], output_template => 'voltage: %s V', perfdatas => [ - { value => 'voltage_absolute', template => '%s', unit => 'V' }, + { value => 'voltage', template => '%s', unit => 'V' }, ], } }, @@ -77,7 +77,7 @@ sub set_counters { key_values => [ { name => 'temperature', no_value => 0 } ], output_template => 'temperature: %s C', perfdatas => [ - { value => 'temperature_absolute', template => '%s', unit => 'C' }, + { value => 'temperature', template => '%s', unit => 'C' }, ], } }, diff --git a/centreon/common/cps/ups/snmp/mode/inputlines.pm b/centreon/common/cps/ups/snmp/mode/inputlines.pm index 9a01cc2da..7c7b310d9 100644 --- a/centreon/common/cps/ups/snmp/mode/inputlines.pm +++ b/centreon/common/cps/ups/snmp/mode/inputlines.pm @@ -52,7 +52,7 @@ sub set_counters { key_values => [ { name => 'voltage' } ], output_template => 'Voltage : %.2f V', perfdatas => [ - { value => 'voltage_absolute', template => '%.2f', unit => 'V' }, + { value => 'voltage', template => '%.2f', unit => 'V' }, ], } }, @@ -60,7 +60,7 @@ sub set_counters { key_values => [ { name => 'frequence' } ], output_template => 'Frequence : %.2f Hz', perfdatas => [ - { value => 'frequence_absolute', template => '%.2f', min => 0, unit => 'Hz' }, + { value => 'frequence', template => '%.2f', min => 0, unit => 'Hz' }, ], } }, diff --git a/centreon/common/cps/ups/snmp/mode/outputlines.pm b/centreon/common/cps/ups/snmp/mode/outputlines.pm index f798b6634..3c12a2eba 100644 --- a/centreon/common/cps/ups/snmp/mode/outputlines.pm +++ b/centreon/common/cps/ups/snmp/mode/outputlines.pm @@ -52,7 +52,7 @@ sub set_counters { key_values => [ { name => 'load' } ], output_template => 'Load : %.2f %%', perfdatas => [ - { value => 'load_absolute', template => '%.2f', min => 0, max => 100, unit => '%' }, + { value => 'load', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } }, @@ -60,7 +60,7 @@ sub set_counters { key_values => [ { name => 'current' } ], output_template => 'Current : %.2f A', perfdatas => [ - { value => 'current_absolute', template => '%.2f', min => 0, unit => 'A' }, + { value => 'current', template => '%.2f', min => 0, unit => 'A' }, ], } }, @@ -68,7 +68,7 @@ sub set_counters { key_values => [ { name => 'voltage' } ], output_template => 'Voltage : %.2f V', perfdatas => [ - { value => 'voltage_absolute', template => '%.2f', unit => 'V' }, + { value => 'voltage', template => '%.2f', unit => 'V' }, ], } }, @@ -76,7 +76,7 @@ sub set_counters { key_values => [ { name => 'power' } ], output_template => 'Power : %.2f W', perfdatas => [ - { value => 'power_absolute', template => '%.2f', min => 0, unit => 'W' }, + { value => 'power', template => '%.2f', min => 0, unit => 'W' }, ], } }, @@ -84,7 +84,7 @@ sub set_counters { key_values => [ { name => 'frequence' } ], output_template => 'Frequence : %.2f Hz', perfdatas => [ - { value => 'frequence_absolute', template => '%.2f', min => 0, unit => 'Hz' }, + { value => 'frequence', template => '%.2f', min => 0, unit => 'Hz' }, ], } }, diff --git a/centreon/common/emc/navisphere/mode/controller.pm b/centreon/common/emc/navisphere/mode/controller.pm index 3cd39ff25..96b85c043 100644 --- a/centreon/common/emc/navisphere/mode/controller.pm +++ b/centreon/common/emc/navisphere/mode/controller.pm @@ -50,23 +50,19 @@ sub set_counters { $self->{maps_counters}->{global} = [ { label => 'read-iops', nlabel => 'controller.io.read.usage.iops', set => { - key_values => [ { name => 'read', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'read', per_second => 1 } ], output_template => 'Read IOPs : %.2f', perfdatas => [ - { value => 'read_per_second', template => '%.2f', - unit => 'iops', min => 0 }, - ], + { template => '%.2f', unit => 'iops', min => 0 } + ] } }, { label => 'write-iops', nlabel => 'controller.io.write.usage.iops', set => { - key_values => [ { name => 'write', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'write', per_second => 1 } ], output_template => 'Write IOPs : %.2f', perfdatas => [ - { value => 'write_per_second', template => '%.2f', - unit => 'iops', min => 0 }, - ], + { template => '%.2f', unit => 'iops', min => 0 } + ] } }, { label => 'busy', nlabel => 'controller.busy.usage.percentage', set => { @@ -75,11 +71,10 @@ sub set_counters { output_template => 'Busy : %.2f %%', output_use => 'busy_prct', threshold_use => 'busy_prct', perfdatas => [ - { value => 'busy_prct', template => '%.2f', - unit => '%', min => 0, max => 100 }, - ], + { value => 'busy_prct', template => '%.2f', unit => '%', min => 0, max => 100 } + ] } - }, + } ]; } diff --git a/centreon/common/emc/navisphere/mode/disk.pm b/centreon/common/emc/navisphere/mode/disk.pm index 6adce83f0..31150f09a 100644 --- a/centreon/common/emc/navisphere/mode/disk.pm +++ b/centreon/common/emc/navisphere/mode/disk.pm @@ -109,8 +109,8 @@ sub set_counters { key_values => [ { name => 'hard_read_errors', diff => 1 }, { name => 'display' } ], output_template => 'Hard Read Errors : %d', perfdatas => [ - { label => 'hard_read_errors', value => 'hard_read_errors_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'hard_read_errors', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -118,28 +118,28 @@ sub set_counters { key_values => [ { name => 'hard_write_errors', diff => 1 }, { name => 'display' } ], output_template => 'Hard Write Errors : %d', perfdatas => [ - { label => 'hard_write_errors', value => 'hard_write_errors_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'hard_write_errors', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'read-io', set => { - key_values => [ { name => 'read_io', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'read_io', per_second => 1 }, { name => 'display' } ], output_template => 'Read I/O : %s %s/s', - per_second => 1, output_change_bytes => 1, + output_change_bytes => 1, perfdatas => [ - { label => 'read_io', value => 'read_io_absolute', template => '%s', - min => 0, unit => 'B/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'read_io', template => '%s', + min => 0, unit => 'B/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'write-io', set => { - key_values => [ { name => 'write_io', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'write_io', per_second => 1 }, { name => 'display' } ], output_template => 'Write I/O : %s %s/s', - per_second => 1, output_change_bytes => 1, + output_change_bytes => 1, perfdatas => [ - { label => 'write_io', value => 'write_io_absolute', template => '%s', - min => 0, unit => 'B/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'write_io', template => '%s', + min => 0, unit => 'B/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -168,8 +168,8 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - "filter-raidgroupid:s" => { name => 'filter_raidgroupid', }, - "filter-disk:s" => { name => 'filter_disk', }, + 'filter-raidgroupid:s' => { name => 'filter_raidgroupid', }, + 'filter-disk:s' => { name => 'filter_disk', }, }); return $self; diff --git a/centreon/common/force10/snmp/mode/cpu.pm b/centreon/common/force10/snmp/mode/cpu.pm index 170448c71..d847213a6 100644 --- a/centreon/common/force10/snmp/mode/cpu.pm +++ b/centreon/common/force10/snmp/mode/cpu.pm @@ -37,8 +37,8 @@ sub set_counters { key_values => [ { name => 'usage_5s' }, { name => 'display' } ], output_template => '%s %% (5sec)', output_error_template => "%s (5sec)", perfdatas => [ - { label => 'cpu_5s', value => 'usage_5s_absolute', template => '%d', - unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'cpu_5s', value => 'usage_5s', template => '%d', + unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -46,8 +46,8 @@ sub set_counters { key_values => [ { name => 'usage_1m' }, { name => 'display' } ], output_template => '%s %% (1m)', output_error_template => "%s (1min)", perfdatas => [ - { label => 'cpu_1m', value => 'usage_1m_absolute', template => '%d', - unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'cpu_1m', value => 'usage_1m', template => '%d', + unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -55,8 +55,8 @@ sub set_counters { key_values => [ { name => 'usage_5m' }, { name => 'display' } ], output_template => '%s %% (5min)', output_error_template => "%s (5min)", perfdatas => [ - { label => 'cpu_5m', value => 'usage_5m_absolute', template => '%d', - unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'cpu_5m', value => 'usage_5m', template => '%d', + unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/centreon/common/force10/snmp/mode/memory.pm b/centreon/common/force10/snmp/mode/memory.pm index a8ca4514f..ffb3ad286 100644 --- a/centreon/common/force10/snmp/mode/memory.pm +++ b/centreon/common/force10/snmp/mode/memory.pm @@ -37,8 +37,8 @@ sub set_counters { key_values => [ { name => 'usage' }, { name => 'display' } ], output_template => '%s %%', output_error_template => "%s", perfdatas => [ - { label => 'used', value => 'usage_absolute', template => '%d', - unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'used', value => 'usage', template => '%d', + unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/centreon/common/fortinet/fortigate/snmp/mode/apusage.pm b/centreon/common/fortinet/fortigate/snmp/mode/apusage.pm index cc73dfa16..e6319f0d8 100644 --- a/centreon/common/fortinet/fortigate/snmp/mode/apusage.pm +++ b/centreon/common/fortinet/fortigate/snmp/mode/apusage.pm @@ -59,22 +59,22 @@ sub set_counters { } }, { label => 'in-traffic', set => { - key_values => [ { name => 'in', diff => 1 }, { name => 'display' } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'in', per_second => 1 }, { name => 'display' } ], + output_change_bytes => 2, output_template => 'traffic in : %s %s/s', perfdatas => [ - { label => 'traffic_in', value => 'in_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_in', template => '%.2f', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'out-traffic', set => { - key_values => [ { name => 'out', diff => 1 }, { name => 'display' } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'out', per_second => 1 }, { name => 'display' } ], + output_change_bytes => 2, output_template => 'traffic out : %s %s/s', perfdatas => [ - { label => 'traffic_out', value => 'out_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_out', template => '%.2f', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -82,8 +82,8 @@ sub set_counters { key_values => [ { name => 'clients' }, { name => 'display' } ], output_template => 'current client connections : %s', perfdatas => [ - { label => 'clients', value => 'clients_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'clients', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -91,8 +91,8 @@ sub set_counters { key_values => [ { name => 'cpu' }, { name => 'display' } ], output_template => 'cpu usage : %.2f %%', perfdatas => [ - { label => 'cpu', value => 'cpu_absolute', template => '%.2f', - unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'cpu', template => '%.2f', + unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -100,8 +100,8 @@ sub set_counters { key_values => [ { name => 'memory' }, { name => 'display' } ], output_template => 'memory usage : %.2f %%', perfdatas => [ - { label => 'memory', value => 'memory_absolute', template => '%.2f', - unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'memory', template => '%.2f', + unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/centreon/common/fortinet/fortigate/snmp/mode/clusterstatus.pm b/centreon/common/fortinet/fortigate/snmp/mode/clusterstatus.pm index c767da49b..fa4927cc8 100644 --- a/centreon/common/fortinet/fortigate/snmp/mode/clusterstatus.pm +++ b/centreon/common/fortinet/fortigate/snmp/mode/clusterstatus.pm @@ -63,7 +63,7 @@ sub set_counters { key_values => [ { name => 'total_nodes' } ], output_template => 'Total nodes: %d', perfdatas => [ - { label => 'total_nodes', value => 'total_nodes_absolute', template => '%d', + { label => 'total_nodes', value => 'total_nodes', template => '%d', min => 0 }, ], } @@ -72,7 +72,7 @@ sub set_counters { key_values => [ { name => 'synchronized' } ], output_template => 'Synchronized: %d', perfdatas => [ - { label => 'synchronized_nodes', value => 'synchronized_absolute', template => '%d', + { label => 'synchronized_nodes', value => 'synchronized', template => '%d', min => 0 }, ], } @@ -81,7 +81,7 @@ sub set_counters { key_values => [ { name => 'not_synchronized' } ], output_template => 'Not Synchronized: %d', perfdatas => [ - { label => 'not_synchronized_nodes', value => 'not_synchronized_absolute', template => '%d', + { label => 'not_synchronized_nodes', value => 'not_synchronized', template => '%d', min => 0 }, ], } @@ -90,7 +90,7 @@ sub set_counters { key_values => [ { name => 'total_checksums' } ], output_template => 'Total Checksums: %d', perfdatas => [ - { label => 'total_checksums', value => 'total_checksums_absolute', template => '%d', min => 0 }, + { label => 'total_checksums', value => 'total_checksums', template => '%d', min => 0 }, ], } }, diff --git a/centreon/common/fortinet/fortigate/snmp/mode/cpu.pm b/centreon/common/fortinet/fortigate/snmp/mode/cpu.pm index 245ce76e6..5ec2209d9 100644 --- a/centreon/common/fortinet/fortigate/snmp/mode/cpu.pm +++ b/centreon/common/fortinet/fortigate/snmp/mode/cpu.pm @@ -39,7 +39,7 @@ sub set_counters { key_values => [ { name => 'average' } ], output_template => 'CPU(s) average usage is: %.2f %%', perfdatas => [ - { label => 'total_cpu_avg', value => 'average_absolute', template => '%.2f', + { label => 'total_cpu_avg', value => 'average', template => '%.2f', min => 0, max => 100, unit => '%' }, ] } @@ -51,7 +51,7 @@ sub set_counters { key_values => [ { name => 'cpu' } ], output_template => 'usage: %.2f %%', perfdatas => [ - { value => 'cpu_absolute', template => '%.2f', + { value => 'cpu', template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 }, ] } @@ -63,7 +63,7 @@ sub set_counters { key_values => [ { name => 'cpu' } ], output_template => 'CPU usage: %.2f %%', perfdatas => [ - { value => 'cpu_absolute', template => '%.2f', + { value => 'cpu', template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 }, ] } diff --git a/centreon/common/fortinet/fortigate/snmp/mode/ipsstats.pm b/centreon/common/fortinet/fortigate/snmp/mode/ipsstats.pm index ae03d8b81..8221f1577 100644 --- a/centreon/common/fortinet/fortigate/snmp/mode/ipsstats.pm +++ b/centreon/common/fortinet/fortigate/snmp/mode/ipsstats.pm @@ -38,8 +38,8 @@ sub set_counters { key_values => [ { name => 'fgIpsIntrusionsDetected', diff => 1 }, { name => 'display' } ], output_template => 'Intrusions detected : %s', perfdatas => [ - { label => 'intrusions_detected', value => 'fgIpsIntrusionsDetected_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'intrusions_detected', value => 'fgIpsIntrusionsDetected', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -47,8 +47,8 @@ sub set_counters { key_values => [ { name => 'fgIpsIntrusionsBlocked', diff => 1 }, { name => 'display' } ], output_template => 'Intrusions blocked : %s', perfdatas => [ - { label => 'intrusions_blocked', value => 'fgIpsIntrusionsBlocked_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'intrusions_blocked', value => 'fgIpsIntrusionsBlocked', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -56,8 +56,8 @@ sub set_counters { key_values => [ { name => 'fgIpsCritSevDetections', diff => 1 }, { name => 'display' } ], output_template => 'Critical severity intrusions detected : %s', perfdatas => [ - { label => 'crit_sev_detections', value => 'fgIpsCritSevDetections_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'crit_sev_detections', value => 'fgIpsCritSevDetections', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -65,8 +65,8 @@ sub set_counters { key_values => [ { name => 'fgIpsHighSevDetections', diff => 1 }, { name => 'display' } ], output_template => 'High severity intrusions detected : %s', perfdatas => [ - { label => 'high_sev_detections', value => 'fgIpsHighSevDetections_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'high_sev_detections', value => 'fgIpsHighSevDetections', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -74,8 +74,8 @@ sub set_counters { key_values => [ { name => 'fgIpsMedSevDetections', diff => 1 }, { name => 'display' } ], output_template => 'Medium severity intrusions detected : %s', perfdatas => [ - { label => 'med_sev_detections', value => 'fgIpsMedSevDetections_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'med_sev_detections', value => 'fgIpsMedSevDetections', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -83,8 +83,8 @@ sub set_counters { key_values => [ { name => 'fgIpsLowSevDetections', diff => 1 }, { name => 'display' } ], output_template => 'Low severity intrusions detected : %s', perfdatas => [ - { label => 'low_sev_detections', value => 'fgIpsLowSevDetections_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'low_sev_detections', value => 'fgIpsLowSevDetections', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -92,8 +92,8 @@ sub set_counters { key_values => [ { name => 'fgIpsInfoSevDetections', diff => 1 }, { name => 'display' } ], output_template => 'Informational severity intrusions detected : %s', perfdatas => [ - { label => 'info_sev_detections', value => 'fgIpsInfoSevDetections_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'info_sev_detections', value => 'fgIpsInfoSevDetections', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -101,8 +101,8 @@ sub set_counters { key_values => [ { name => 'fgIpsSignatureDetections', diff => 1 }, { name => 'display' } ], output_template => 'Signature intrusions detected : %s', perfdatas => [ - { label => 'signature_detection', value => 'fgIpsSignatureDetections_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'signature_detection', value => 'fgIpsSignatureDetections', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -110,8 +110,8 @@ sub set_counters { key_values => [ { name => 'fgIpsAnomalyDetections', diff => 1 }, { name => 'display' } ], output_template => 'Anomaly intrusions detected : %s', perfdatas => [ - { label => 'anomaly_detections', value => 'fgIpsAnomalyDetections_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'anomaly_detections', value => 'fgIpsAnomalyDetections', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/centreon/common/fortinet/fortigate/snmp/mode/memory.pm b/centreon/common/fortinet/fortigate/snmp/mode/memory.pm index 1b6fff7fa..2e018ba2d 100644 --- a/centreon/common/fortinet/fortigate/snmp/mode/memory.pm +++ b/centreon/common/fortinet/fortigate/snmp/mode/memory.pm @@ -29,11 +29,11 @@ sub custom_usage_output { my ($self, %options) = @_; return sprintf("memory total: %s %s used: %s %s (%.2f%%) free: %s %s (%.2f%%)", - $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_absolute}), - $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_absolute}), - $self->{result_values}->{prct_used_absolute}, - $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute}), - $self->{result_values}->{prct_free_absolute} + $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}), + $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}), + $self->{result_values}->{prct_used}, + $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}), + $self->{result_values}->{prct_free} ); } @@ -56,7 +56,7 @@ sub set_counters { key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ - { value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute', + { value => 'used', template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1 }, ] } @@ -65,7 +65,7 @@ sub set_counters { key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ - { value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute', + { value => 'free', template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1 }, ] } @@ -74,7 +74,7 @@ sub set_counters { key_values => [ { name => 'prct_used' } ], output_template => 'memory used : %.2f %%', perfdatas => [ - { label => 'used_prct', value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, + { label => 'used_prct', value => 'prct_used', template => '%.2f', min => 0, max => 100, unit => '%' } ] } @@ -86,7 +86,7 @@ sub set_counters { key_values => [ { name => 'memory' } ], output_template => 'memory used: %.2f %%', perfdatas => [ - { value => 'memory_absolute', template => '%.2f', + { value => 'memory', template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 }, ] } diff --git a/centreon/common/fortinet/fortigate/snmp/mode/signatures.pm b/centreon/common/fortinet/fortigate/snmp/mode/signatures.pm index 83ce6cbe0..851592aa7 100644 --- a/centreon/common/fortinet/fortigate/snmp/mode/signatures.pm +++ b/centreon/common/fortinet/fortigate/snmp/mode/signatures.pm @@ -39,10 +39,10 @@ sub set_counters { $self->{maps_counters}->{av} = [ { label => 'av', set => { key_values => [ { name => 'human' }, { name => 'value' } ], - threshold_use => 'value_absolute', + threshold_use => 'value', output_template => "last refresh is: '%s'", perfdatas => [ - { label => 'av_update', value => 'value_absolute', + { label => 'av_update', value => 'value', template => '%d', min => 0, unit => 's' }, ], } @@ -51,10 +51,10 @@ sub set_counters { $self->{maps_counters}->{avet} = [ { label => 'avet', set => { key_values => [ { name => 'human' }, { name => 'value' } ], - threshold_use => 'value_absolute', + threshold_use => 'value', output_template => "last refresh is: '%s'", perfdatas => [ - { label => 'avet_update', value => 'value_absolute', + { label => 'avet_update', value => 'value', template => '%d', min => 0, unit => 's' }, ], } @@ -63,10 +63,10 @@ sub set_counters { $self->{maps_counters}->{ips} = [ { label => 'ips', set => { key_values => [ { name => 'human' }, { name => 'value' } ], - threshold_use => 'value_absolute', + threshold_use => 'value', output_template => "last refresh is: '%s'", perfdatas => [ - { label => 'ips_update', value => 'value_absolute', + { label => 'ips_update', value => 'value', template => '%d', min => 0, unit => 's' }, ], } @@ -75,10 +75,10 @@ sub set_counters { $self->{maps_counters}->{ipset} = [ { label => 'ipset', set => { key_values => [ { name => 'human' }, { name => 'value' } ], - threshold_use => 'value_absolute', + threshold_use => 'value', output_template => "last refresh is: '%s'", perfdatas => [ - { label => 'ipset_update', value => 'value_absolute', + { label => 'ipset_update', value => 'value', template => '%d', min => 0, unit => 's' }, ], } diff --git a/centreon/common/fortinet/fortigate/snmp/mode/vdomusage.pm b/centreon/common/fortinet/fortigate/snmp/mode/vdomusage.pm index c2842db05..81449e3db 100644 --- a/centreon/common/fortinet/fortigate/snmp/mode/vdomusage.pm +++ b/centreon/common/fortinet/fortigate/snmp/mode/vdomusage.pm @@ -42,9 +42,9 @@ sub custom_license_output { return sprintf( 'number of virtual domains used: %s/%s (%.2f%%)', - $self->{result_values}->{used_absolute}, - $self->{result_values}->{total_absolute}, - $self->{result_values}->{prct_used_absolute} + $self->{result_values}->{used}, + $self->{result_values}->{total}, + $self->{result_values}->{prct_used} ); } @@ -114,7 +114,7 @@ sub set_counters { key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], closure_custom_output => $self->can('custom_license_output'), perfdatas => [ - { value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute' } + { template => '%d', min => 0, max => 'total' } ] } }, @@ -122,7 +122,7 @@ sub set_counters { key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], closure_custom_output => $self->can('custom_license_output'), perfdatas => [ - { value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute' } + { template => '%d', min => 0, max => 'total' } ] } }, @@ -130,7 +130,7 @@ sub set_counters { key_values => [ { name => 'prct_used' }, { name => 'free' }, { name => 'used' }, { name => 'prct_free' }, { name => 'total' } ], closure_custom_output => $self->can('custom_license_output'), perfdatas => [ - { value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, unit => '%' } + { template => '%.2f', min => 0, max => 100, unit => '%' } ] } } @@ -141,8 +141,8 @@ sub set_counters { key_values => [ { name => 'cpu' }, { name => 'display' } ], output_template => 'cpu usage: %.2f%%', perfdatas => [ - { value => 'cpu_absolute', template => '%.2f', unit => '%', min => 0, max => 100, - label_extra_instance => 1, instance_use => 'display_absolute' } + { template => '%.2f', unit => '%', min => 0, max => 100, + label_extra_instance => 1, instance_use => 'display' } ] } } @@ -153,8 +153,8 @@ sub set_counters { key_values => [ { name => 'prct_used' }, { name => 'display' } ], output_template => 'memory used : %.2f %%', perfdatas => [ - { value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, - unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' } + { template => '%.2f', min => 0, max => 100, + unit => '%', label_extra_instance => 1, instance_use => 'display' } ], } } @@ -165,8 +165,7 @@ sub set_counters { key_values => [ { name => 'active_policies' }, { name => 'display' } ], output_template => 'active policies: %d', perfdatas => [ - { value => 'active_policies_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display' }, ] } } @@ -177,8 +176,7 @@ sub set_counters { key_values => [ { name => 'active_sessions' }, { name => 'display' } ], output_template => 'active sessions: %d', perfdatas => [ - { value => 'active_sessions_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display' }, ] } }, @@ -186,8 +184,7 @@ sub set_counters { key_values => [ { name => 'session_rate' }, { name => 'display' } ], output_template => 'session setup rate: %d/s', perfdatas => [ - { value => 'session_rate_absolute', template => '%d', - min => 0, unit => '/s', label_extra_instance => 1, instance_use => 'display_absolute' } + { template => '%d', min => 0, unit => '/s', label_extra_instance => 1, instance_use => 'display' } ] } } @@ -207,7 +204,7 @@ sub set_counters { $self->{maps_counters}->{vdom_traffic} = [ { label => 'traffic-in', nlabel => 'virtualdomain.traffic.in.bitspersecond', set => { key_values => [], - per_second => 1, manual_keys => 1, + manual_keys => 1, closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'in' }, output_template => 'traffic in: %s%s/s', output_use => 'traffic_per_second', threshold_use => 'traffic_per_second', @@ -220,7 +217,7 @@ sub set_counters { }, { label => 'traffic-out', nlabel => 'virtualdomain.traffic.out.bitspersecond', set => { key_values => [], - per_second => 1, manual_keys => 1, + manual_keys => 1, closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'out' }, output_template => 'traffic out: %s%s/s', output_use => 'traffic_per_second', threshold_use => 'traffic_per_second', diff --git a/centreon/common/fortinet/fortigate/snmp/mode/virus.pm b/centreon/common/fortinet/fortigate/snmp/mode/virus.pm index 7b9e2d98b..b09426a87 100644 --- a/centreon/common/fortinet/fortigate/snmp/mode/virus.pm +++ b/centreon/common/fortinet/fortigate/snmp/mode/virus.pm @@ -38,18 +38,17 @@ sub set_counters { key_values => [ { name => 'fgAvVirusDetected', diff => 1 }, { name => 'display' } ], output_template => 'virus detected: %s', perfdatas => [ - { label => 'virus_detected', value => 'fgAvVirusDetected_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'virus_detected', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'virus-detected-psec', nlabel => 'domain.virus.detected.persecond', display_ok => 0, set => { - key_values => [ { name => 'fgAvVirusDetected', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'fgAvVirusDetected', per_second => 1 }, { name => 'display' } ], output_template => 'virus detected: %.2f/s', - per_second => 1, perfdatas => [ - { label => 'domain.virus.detected.persecond', value => 'fgAvVirusDetected_per_second', template => '%.2f', - unit => '/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'domain.virus.detected.persecond', template => '%.2f', + unit => '/s', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -57,18 +56,17 @@ sub set_counters { key_values => [ { name => 'fgAvVirusBlocked', diff => 1 }, { name => 'display' } ], output_template => 'virus blocked: %s', perfdatas => [ - { label => 'virus_blocked', value => 'fgAvVirusBlocked_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'virus_blocked', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'virus-blocked-psec', nlabel => 'domain.virus.blocked.persecond', display_ok => 0, set => { - key_values => [ { name => 'fgAvVirusBlocked', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'fgAvVirusBlocked', per_second => 1 }, { name => 'display' } ], output_template => 'virus blocked: %.2f/s', - per_second => 1, perfdatas => [ - { label => 'domain.virus.blocked.persecond', value => 'fgAvVirusBlocked_per_second', template => '%.2f', - unit => '/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'domain.virus.blocked.persecond', template => '%.2f', + unit => '/s', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } } diff --git a/centreon/common/fortinet/fortigate/snmp/mode/vpn.pm b/centreon/common/fortinet/fortigate/snmp/mode/vpn.pm index 62e277480..dc86ee83b 100644 --- a/centreon/common/fortinet/fortigate/snmp/mode/vpn.pm +++ b/centreon/common/fortinet/fortigate/snmp/mode/vpn.pm @@ -58,8 +58,7 @@ sub set_counters { key_values => [ { name => 'users' } ], output_template => 'Logged users: %s', perfdatas => [ - { label => 'users', value => 'users_absolute', template => '%d', - min => 0, unit => 'users', label_extra_instance => 1 }, + { label => 'users', template => '%d', min => 0, unit => 'users', label_extra_instance => 1 }, ], } }, @@ -67,8 +66,7 @@ sub set_counters { key_values => [ { name => 'sessions' }], output_template => 'Active web sessions: %s', perfdatas => [ - { label => 'sessions', value => 'sessions_absolute', template => '%d', - min => 0, unit => 'sessions', label_extra_instance => 1 }, + { label => 'sessions', template => '%d', min => 0, unit => 'sessions', label_extra_instance => 1 }, ], } }, @@ -76,8 +74,7 @@ sub set_counters { key_values => [ { name => 'tunnels' } ], output_template => 'Active Tunnels: %s', perfdatas => [ - { label => 'active_tunnels', value => 'tunnels_absolute', template => '%d', - min => 0, unit => 'tunnels', label_extra_instance => 1 }, + { label => 'active_tunnels', template => '%d', min => 0, unit => 'tunnels', label_extra_instance => 1 }, ], } }, @@ -93,22 +90,20 @@ sub set_counters { } }, { label => 'traffic-in', set => { - key_values => [ { name => 'traffic_in', diff => 1 }, { name => 'display' } ], - per_second => 1, output_change_bytes => 1, + key_values => [ { name => 'traffic_in', per_second => 1 }, { name => 'display' } ], + output_change_bytes => 1, output_template => 'Traffic In: %s %s/s', perfdatas => [ - { label => 'traffic_in', value => 'traffic_in_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1 }, + { label => 'traffic_in', template => '%.2f', min => 0, unit => 'b/s', label_extra_instance => 1 }, ], } }, { label => 'traffic-out', set => { - key_values => [ { name => 'traffic_out', diff => 1 }, { name => 'display' } ], - per_second => 1, output_change_bytes => 1, + key_values => [ { name => 'traffic_out', per_second => 1 }, { name => 'display' } ], + output_change_bytes => 1, output_template => 'Traffic Out: %s %s/s', perfdatas => [ - { label => 'traffic_out', value => 'traffic_out_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1 }, + { label => 'traffic_out', template => '%.2f', min => 0, unit => 'b/s', label_extra_instance => 1 }, ], } } diff --git a/centreon/common/foundry/snmp/mode/cpu.pm b/centreon/common/foundry/snmp/mode/cpu.pm index a778bd133..3c597a1bd 100644 --- a/centreon/common/foundry/snmp/mode/cpu.pm +++ b/centreon/common/foundry/snmp/mode/cpu.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'cpu_5s' }, { name => 'display' } ], output_template => '%.2f %% (5s)', perfdatas => [ - { value => 'cpu_5s_absolute', template => '%.2f', + { value => 'cpu_5s', template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1 } ] } @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'cpu_1m' }, { name => 'display' } ], output_template => '%.2f %% (1m)', perfdatas => [ - { value => 'cpu_1m_absolute', template => '%.2f', + { value => 'cpu_1m', template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1 } ] } @@ -55,7 +55,7 @@ sub set_counters { key_values => [ { name => 'cpu_5m' }, { name => 'display' } ], output_template => '%.2f %% (5m)', perfdatas => [ - { value => 'cpu_5m_absolute', template => '%.2f', + { value => 'cpu_5m', template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1 } ] } diff --git a/centreon/common/foundry/snmp/mode/memory.pm b/centreon/common/foundry/snmp/mode/memory.pm index 5d3c7c38d..c37842d48 100644 --- a/centreon/common/foundry/snmp/mode/memory.pm +++ b/centreon/common/foundry/snmp/mode/memory.pm @@ -30,11 +30,11 @@ sub custom_usage_output { return sprintf( 'Ram total: %s %s used: %s %s (%.2f%%) free: %s %s (%.2f%%)', - $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_absolute}), - $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_absolute}), - $self->{result_values}->{prct_used_absolute}, - $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute}), - $self->{result_values}->{prct_free_absolute} + $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}), + $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}), + $self->{result_values}->{prct_used}, + $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}), + $self->{result_values}->{prct_free} ); } @@ -50,7 +50,7 @@ sub set_counters { key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ - { value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute', + { value => 'used', template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1 } ] } @@ -59,7 +59,7 @@ sub set_counters { key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ - { value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute', + { value => 'free', template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1 } ] } @@ -68,7 +68,7 @@ sub set_counters { key_values => [ { name => 'prct_used' } ], output_template => 'Ram used: %.2f %%', perfdatas => [ - { value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, unit => '%' } + { value => 'prct_used', template => '%.2f', min => 0, max => 100, unit => '%' } ] } } diff --git a/centreon/common/h3c/snmp/mode/cpu.pm b/centreon/common/h3c/snmp/mode/cpu.pm index a29760fb2..27db3c88d 100644 --- a/centreon/common/h3c/snmp/mode/cpu.pm +++ b/centreon/common/h3c/snmp/mode/cpu.pm @@ -38,8 +38,8 @@ sub set_counters { key_values => [ { name => 'EntityExtCpuUsage' }, { name => 'num' }, ], output_template => ' : %.2f %%', perfdatas => [ - { label => 'cpu', value => 'EntityExtCpuUsage_absolute', template => '%.2f', - min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'num_absolute' }, + { label => 'cpu', value => 'EntityExtCpuUsage', template => '%.2f', + min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'num' }, ], } }, diff --git a/centreon/common/ibm/nos/snmp/mode/cpu.pm b/centreon/common/ibm/nos/snmp/mode/cpu.pm index 5260d01e6..6334c9fbb 100644 --- a/centreon/common/ibm/nos/snmp/mode/cpu.pm +++ b/centreon/common/ibm/nos/snmp/mode/cpu.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'average_1m' } ], output_template => '%.2f %% (1m)', perfdatas => [ - { value => 'average_1m_absolute', template => '%.2f', + { value => 'average_1m', template => '%.2f', min => 0, max => 100, unit => '%' } ] } @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'average_5m' } ], output_template => '%.2f %% (5m)', perfdatas => [ - { value => 'average_5m_absolute', template => '%.2f', + { value => 'average_5m', template => '%.2f', min => 0, max => 100, unit => '%' } ] } diff --git a/centreon/common/ibm/nos/snmp/mode/memory.pm b/centreon/common/ibm/nos/snmp/mode/memory.pm index fe9559cbc..5de5cca6e 100644 --- a/centreon/common/ibm/nos/snmp/mode/memory.pm +++ b/centreon/common/ibm/nos/snmp/mode/memory.pm @@ -30,11 +30,11 @@ sub custom_usage_output { return sprintf( 'Ram Total: %s %s Used: %s %s (%.2f%%) Free: %s %s (%.2f%%)', - $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_absolute}), - $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_absolute}), - $self->{result_values}->{prct_used_absolute}, - $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute}), - $self->{result_values}->{prct_free_absolute} + $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}), + $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}), + $self->{result_values}->{prct_used}, + $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}), + $self->{result_values}->{prct_free} ); } @@ -50,7 +50,7 @@ sub set_counters { key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ - { value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute', + { value => 'used', template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1 } ] } @@ -59,7 +59,7 @@ sub set_counters { key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ - { value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute', + { value => 'free', template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1 } ] } @@ -68,7 +68,7 @@ sub set_counters { key_values => [ { name => 'prct_used' } ], output_template => 'Ram Used : %.2f %%', perfdatas => [ - { value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, + { value => 'prct_used', template => '%.2f', min => 0, max => 100, unit => '%' } ] } diff --git a/centreon/common/ingrian/snmp/mode/connections.pm b/centreon/common/ingrian/snmp/mode/connections.pm index 5738bbd17..00ba5ec39 100644 --- a/centreon/common/ingrian/snmp/mode/connections.pm +++ b/centreon/common/ingrian/snmp/mode/connections.pm @@ -38,7 +38,7 @@ sub set_counters { key_values => [ { name => 'naeTotalTotalConnections', diff => 1 } ], output_template => 'Total Connections : %s', perfdatas => [ - { label => 'total', value => 'naeTotalTotalConnections_absolute', template => '%s', min => 0 }, + { label => 'total', value => 'naeTotalTotalConnections', template => '%s', min => 0 }, ], } }, @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'naeTotalSSLConnections', diff => 1 } ], output_template => 'Total SSL Connections : %s', perfdatas => [ - { label => 'total_ssl', value => 'naeTotalSSLConnections_absolute', template => '%s', min => 0 }, + { label => 'total_ssl', value => 'naeTotalSSLConnections', template => '%s', min => 0 }, ], } }, @@ -54,7 +54,7 @@ sub set_counters { key_values => [ { name => 'naeTotalNonSSLConnections', diff => 1 } ], output_template => 'Total non-SSL Connections : %s', perfdatas => [ - { label => 'total_non_ssl', value => 'naeTotalNonSSLConnections_absolute', template => '%s', min => 0 }, + { label => 'total_non_ssl', value => 'naeTotalNonSSLConnections', template => '%s', min => 0 }, ], } }, diff --git a/centreon/common/ingrian/snmp/mode/cpu.pm b/centreon/common/ingrian/snmp/mode/cpu.pm index 83e440ea3..b8339dd71 100644 --- a/centreon/common/ingrian/snmp/mode/cpu.pm +++ b/centreon/common/ingrian/snmp/mode/cpu.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'total' } ], output_template => 'Total CPU Usage : %.2f %%', perfdatas => [ - { label => 'total_cpu_avg', value => 'total_absolute', template => '%.2f', min => 0, max => 100, unit => '%' }, + { label => 'total_cpu_avg', value => 'total', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } }, @@ -48,8 +48,8 @@ sub set_counters { key_values => [ { name => 'usage' }, { name => 'display' }, ], output_template => 'Usage : %.2f %%', perfdatas => [ - { label => 'cpu', value => 'usage_absolute', template => '%.2f', - min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'cpu', value => 'usage', template => '%.2f', + min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/centreon/common/ingrian/snmp/mode/disk.pm b/centreon/common/ingrian/snmp/mode/disk.pm index 21b6b6a87..6bbfb8a5e 100644 --- a/centreon/common/ingrian/snmp/mode/disk.pm +++ b/centreon/common/ingrian/snmp/mode/disk.pm @@ -37,8 +37,8 @@ sub set_counters { key_values => [ { name => 'used' }, { name => 'display' } ], output_template => 'Used : %.2f %%', perfdatas => [ - { label => 'used', value => 'used_absolute', template => '%.2f', min => 0, max => 100, unit => '%', - label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'used', value => 'used', template => '%.2f', min => 0, max => 100, unit => '%', + label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/centreon/common/ingrian/snmp/mode/requeststats.pm b/centreon/common/ingrian/snmp/mode/requeststats.pm index 0d26f4ab2..d31fa51fc 100644 --- a/centreon/common/ingrian/snmp/mode/requeststats.pm +++ b/centreon/common/ingrian/snmp/mode/requeststats.pm @@ -38,8 +38,8 @@ sub set_counters { key_values => [ { name => 'success', diff => 1 }, { name => 'display' } ], output_template => 'Success : %s', perfdatas => [ - { label => 'success', value => 'success_absolute', template => '%s', min => 0, - label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'success', value => 'success', template => '%s', min => 0, + label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -47,8 +47,8 @@ sub set_counters { key_values => [ { name => 'fail', diff => 1 }, { name => 'display' } ], output_template => 'Fail : %s', perfdatas => [ - { label => 'fail', value => 'fail_absolute', template => '%s', min => 0, - label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'fail', value => 'fail', template => '%s', min => 0, + label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/centreon/common/jvm/mode/classcount.pm b/centreon/common/jvm/mode/classcount.pm index 8a7b9e2c8..94db98b53 100644 --- a/centreon/common/jvm/mode/classcount.pm +++ b/centreon/common/jvm/mode/classcount.pm @@ -38,7 +38,7 @@ sub set_counters { key_values => [ { name => 'LoadedClassCount' } ], output_template => 'Current : %s', perfdatas => [ - { label => 'current', value => 'LoadedClassCount_absolute', template => '%s', min => 0 }, + { label => 'current', value => 'LoadedClassCount', template => '%s', min => 0 }, ], } }, @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'TotalLoadedClassCount', diff => 1 } ], output_template => 'Loaded : %s', perfdatas => [ - { label => 'loaded', value => 'TotalLoadedClassCount_absolute', template => '%s', min => 0 }, + { label => 'loaded', value => 'TotalLoadedClassCount', template => '%s', min => 0 }, ], } }, @@ -54,7 +54,7 @@ sub set_counters { key_values => [ { name => 'UnloadedClassCount', diff => 1 } ], output_template => 'Unloaded : %s', perfdatas => [ - { label => 'unloaded', value => 'UnloadedClassCount_absolute', template => '%s', min => 0 }, + { label => 'unloaded', value => 'UnloadedClassCount', template => '%s', min => 0 }, ], } }, diff --git a/centreon/common/jvm/mode/gcusage.pm b/centreon/common/jvm/mode/gcusage.pm index 439a698c2..1c60aa1db 100644 --- a/centreon/common/jvm/mode/gcusage.pm +++ b/centreon/common/jvm/mode/gcusage.pm @@ -38,8 +38,8 @@ sub set_counters { key_values => [ { name => 'time', diff => 1 }, { name => 'display' } ], output_template => 'Collection Time : %s ms', perfdatas => [ - { label => 'time', value => 'time_absolute', template => '%s', - unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'time', value => 'time', template => '%s', + unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -47,8 +47,8 @@ sub set_counters { key_values => [ { name => 'count', diff => 1 }, { name => 'display' } ], output_template => 'Collection Count : %s', perfdatas => [ - { label => 'count', value => 'count_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'count', value => 'count', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/centreon/common/jvm/mode/threads.pm b/centreon/common/jvm/mode/threads.pm index 0ab3d741d..fa71c5588 100644 --- a/centreon/common/jvm/mode/threads.pm +++ b/centreon/common/jvm/mode/threads.pm @@ -38,7 +38,7 @@ sub set_counters { key_values => [ { name => 'ThreadCount' } ], output_template => 'Active : %s', perfdatas => [ - { label => 'active', value => 'ThreadCount_absolute', template => '%s', min => 0 }, + { label => 'active', value => 'ThreadCount', template => '%s', min => 0 }, ], } }, @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'TotalStartedThreadCount', diff => 1 } ], output_template => 'Started : %s', perfdatas => [ - { label => 'started', value => 'TotalStartedThreadCount_absolute', template => '%s', min => 0 }, + { label => 'started', value => 'TotalStartedThreadCount', template => '%s', min => 0 }, ], } }, @@ -54,7 +54,7 @@ sub set_counters { key_values => [ { name => 'DaemonThreadCount' } ], output_template => 'Daemon : %s', perfdatas => [ - { label => 'daemon', value => 'DaemonThreadCount_absolute', template => '%s', min => 0 }, + { label => 'daemon', value => 'DaemonThreadCount', template => '%s', min => 0 }, ], } }, diff --git a/centreon/common/microsoft/skype/mssql/mode/appsharingqoe.pm b/centreon/common/microsoft/skype/mssql/mode/appsharingqoe.pm index 319db514c..d1931c907 100644 --- a/centreon/common/microsoft/skype/mssql/mode/appsharingqoe.pm +++ b/centreon/common/microsoft/skype/mssql/mode/appsharingqoe.pm @@ -38,7 +38,7 @@ sub set_counters { key_values => [ { name => 'SpoiledTilePercentTotal' } ], output_template => 'Average Spoiled Tiles: %.2f%%', perfdatas => [ - { label => 'spoiled_tile_prct_total_avg', value => 'SpoiledTilePercentTotal_absolute', + { label => 'spoiled_tile_prct_total_avg', value => 'SpoiledTilePercentTotal', template => '%.2f', unit => '%', min => 0, max => 100 }, ], } @@ -47,7 +47,7 @@ sub set_counters { key_values => [ { name => 'RDPTileProcessingLatencyAverage' } ], output_template => 'Average RDP Tiles Processing Latency: %.2f ms', perfdatas => [ - { label => 'rdp_tile_processing_latency_avg', value => 'RDPTileProcessingLatencyAverage_absolute', + { label => 'rdp_tile_processing_latency_avg', value => 'RDPTileProcessingLatencyAverage', template => '%.2f', unit => 'ms', min => 0 }, ], } @@ -56,7 +56,7 @@ sub set_counters { key_values => [ { name => 'RelativeOneWayAverage' } ], output_template => 'Average Amount of One-way Latency: %.2f ms', perfdatas => [ - { label => 'relative_one_way_average', value => 'RelativeOneWayAverage_absolute', + { label => 'relative_one_way_average', value => 'RelativeOneWayAverage', template => '%.2f', unit => 'ms', min => 0 }, ], } @@ -67,7 +67,7 @@ sub set_counters { key_values => [ { name => 'TotalStreams' } ], output_template => 'Streams Count: %.2f/s', perfdatas => [ - { label => 'stream_count', value => 'TotalStreams_absolute', template => '%.2f', + { label => 'stream_count', value => 'TotalStreams', template => '%.2f', unit => 'streams/s', min => 0 }, ], } diff --git a/centreon/common/microsoft/skype/mssql/mode/audioqoe.pm b/centreon/common/microsoft/skype/mssql/mode/audioqoe.pm index e95143910..05e8217df 100644 --- a/centreon/common/microsoft/skype/mssql/mode/audioqoe.pm +++ b/centreon/common/microsoft/skype/mssql/mode/audioqoe.pm @@ -39,7 +39,7 @@ sub set_counters { key_values => [ { name => 'JitterAvg' } ], output_template => 'Average: %d ms', perfdatas => [ - { label => 'jitter_avg', value => 'JitterAvg_absolute', template => '%d', + { label => 'jitter_avg', value => 'JitterAvg', template => '%d', unit => 'ms', min => 0 }, ], } @@ -48,7 +48,7 @@ sub set_counters { key_values => [ { name => 'JitterMin' } ], output_template => 'Min: %d ms', perfdatas => [ - { label => 'jitter_min', value => 'JitterMin_absolute', template => '%d', + { label => 'jitter_min', value => 'JitterMin', template => '%d', unit => 'ms', min => 0 }, ], } @@ -57,7 +57,7 @@ sub set_counters { key_values => [ { name => 'JitterMax' } ], output_template => 'Max: %d ms', perfdatas => [ - { label => 'jitter_max', value => 'JitterMax_absolute', template => '%d', + { label => 'jitter_max', value => 'JitterMax', template => '%d', unit => 'ms', min => 0 }, ], } @@ -68,7 +68,7 @@ sub set_counters { key_values => [ { name => 'PacketLossAvg' } ], output_template => 'Average: %.2f%%', perfdatas => [ - { label => 'pckt_loss_avg', value => 'PacketLossAvg_absolute', template => '%.2f', + { label => 'pckt_loss_avg', value => 'PacketLossAvg', template => '%.2f', unit => '%', min => 0, max => 100 }, ], } @@ -77,7 +77,7 @@ sub set_counters { key_values => [ { name => 'PacketLossMin' } ], output_template => 'Min: %.2f%%', perfdatas => [ - { label => 'pckt_loss_min', value => 'PacketLossMin_absolute', template => '%.2f', + { label => 'pckt_loss_min', value => 'PacketLossMin', template => '%.2f', unit => '%', min => 0, max => 100 }, ], } @@ -86,7 +86,7 @@ sub set_counters { key_values => [ { name => 'PacketLossMax' } ], output_template => 'Max: %.2f%%', perfdatas => [ - { label => 'pckt_loss_max', value => 'PacketLossMax_absolute', template => '%.2f', + { label => 'pckt_loss_max', value => 'PacketLossMax', template => '%.2f', unit => '%', min => 0, max => 100 }, ], } @@ -97,7 +97,7 @@ sub set_counters { key_values => [ { name => 'TotalStreams' } ], output_template => 'Streams Count: %.2f/s', perfdatas => [ - { label => 'stream_count', value => 'TotalStreams_absolute', template => '%.2f', + { label => 'stream_count', value => 'TotalStreams', template => '%.2f', unit => 'streams/s', min => 0 }, ], } diff --git a/centreon/common/microsoft/skype/mssql/mode/poorcalls.pm b/centreon/common/microsoft/skype/mssql/mode/poorcalls.pm index 030e81043..620e49104 100644 --- a/centreon/common/microsoft/skype/mssql/mode/poorcalls.pm +++ b/centreon/common/microsoft/skype/mssql/mode/poorcalls.pm @@ -39,7 +39,7 @@ sub set_counters { key_values => [ { name => 'count' } ], output_template => 'Poor Calls: %d', perfdatas => [ - { label => 'poor_calls', value => 'count_absolute', template => '%d', + { label => 'poor_calls', value => 'count', template => '%d', unit => 'calls', min => 0 }, ], } diff --git a/centreon/common/microsoft/skype/mssql/mode/sessionstypes.pm b/centreon/common/microsoft/skype/mssql/mode/sessionstypes.pm index 94626c5ea..5fc7dc4f2 100644 --- a/centreon/common/microsoft/skype/mssql/mode/sessionstypes.pm +++ b/centreon/common/microsoft/skype/mssql/mode/sessionstypes.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'instant_messaging' } ], output_template => 'Instant Messaging: %d', perfdatas => [ - { label => 'instant_messaging', value => 'instant_messaging_absolute', template => '%d', + { label => 'instant_messaging', value => 'instant_messaging', template => '%d', unit => 'sessions', min => 0 }, ], } @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'audio' } ], output_template => 'Audio: %d', perfdatas => [ - { label => 'audio', value => 'audio_absolute', template => '%d', + { label => 'audio', value => 'audio', template => '%d', unit => 'sessions', min => 0 }, ], } @@ -55,7 +55,7 @@ sub set_counters { key_values => [ { name => 'video' } ], output_template => 'Video: %d', perfdatas => [ - { label => 'video', value => 'video_absolute', template => '%d', + { label => 'video', value => 'video', template => '%d', unit => 'sessions', min => 0 }, ], } @@ -64,7 +64,7 @@ sub set_counters { key_values => [ { name => 'file_transfer' } ], output_template => 'File Transfer: %d', perfdatas => [ - { label => 'file_transfer', value => 'file_transfer_absolute', template => '%d', + { label => 'file_transfer', value => 'file_transfer', template => '%d', unit => 'sessions', min => 0 }, ], } @@ -73,7 +73,7 @@ sub set_counters { key_values => [ { name => 'remote_assistance' } ], output_template => 'Remote Assistance: %d', perfdatas => [ - { label => 'remote_assistance', value => 'remote_assistance_absolute', template => '%d', + { label => 'remote_assistance', value => 'remote_assistance', template => '%d', unit => 'sessions', min => 0 }, ], } @@ -82,7 +82,7 @@ sub set_counters { key_values => [ { name => 'app_sharing' } ], output_template => 'App Sharing: %d', perfdatas => [ - { label => 'app_sharing', value => 'app_sharing_absolute', template => '%d', + { label => 'app_sharing', value => 'app_sharing', template => '%d', unit => 'sessions', min => 0 }, ], } @@ -91,7 +91,7 @@ sub set_counters { key_values => [ { name => 'app_invite' } ], output_template => 'App Invite: %d', perfdatas => [ - { label => 'app_invite', value => 'app_invite_absolute', template => '%d', + { label => 'app_invite', value => 'app_invite', template => '%d', unit => 'sessions', min => 0 }, ], } diff --git a/centreon/common/microsoft/skype/mssql/mode/videoqoe.pm b/centreon/common/microsoft/skype/mssql/mode/videoqoe.pm index ced1a2bbd..3c1b35dee 100644 --- a/centreon/common/microsoft/skype/mssql/mode/videoqoe.pm +++ b/centreon/common/microsoft/skype/mssql/mode/videoqoe.pm @@ -18,7 +18,7 @@ sub set_counters { key_values => [ { name => 'VideoPacketLossRate' } ], output_template => 'Packet Loss Rate: %.2f%%', perfdatas => [ - { label => 'video_pckt_loss_rate', value => 'VideoPacketLossRate_absolute', + { label => 'video_pckt_loss_rate', value => 'VideoPacketLossRate', template => '%.2f', unit => '%', min => 0, max => 100 }, ], } @@ -27,7 +27,7 @@ sub set_counters { key_values => [ { name => 'VideoPostFECPLR' } ], output_template => 'Packet Loss Rate After Correction: %.2f%%', perfdatas => [ - { label => 'video_post_fecplr', value => 'VideoPostFECPLR_absolute', + { label => 'video_post_fecplr', value => 'VideoPostFECPLR', template => '%.2f', unit => '%', min => 0, max => 100 }, ], } @@ -36,7 +36,7 @@ sub set_counters { key_values => [ { name => 'VideoLocalFrameLossPercentageAvg' } ], output_template => 'Video Frame Loss: %.2f%%', perfdatas => [ - { label => 'video_frame_loss_prct_avg', value => 'VideoLocalFrameLossPercentageAvg_absolute', + { label => 'video_frame_loss_prct_avg', value => 'VideoLocalFrameLossPercentageAvg', template => '%.2f', unit => '%', min => 0, max => 100 }, ], } @@ -45,7 +45,7 @@ sub set_counters { key_values => [ { name => 'RecvFrameRateAverage' } ], output_template => 'Receiver Frame Rate: %.2f/s', perfdatas => [ - { label => 'rcv_frame_rate_avg', value => 'RecvFrameRateAverage_absolute', + { label => 'rcv_frame_rate_avg', value => 'RecvFrameRateAverage', template => '%.2f', unit => 'frames/s', min => 0 }, ], } @@ -54,7 +54,7 @@ sub set_counters { key_values => [ { name => 'InboundVideoFrameRateAvg' } ], output_template => 'Inbound Video Frame Rate: %.2f%%', perfdatas => [ - { label => 'inbound_video_frame_rate_avg', value => 'InboundVideoFrameRateAvg_absolute', + { label => 'inbound_video_frame_rate_avg', value => 'InboundVideoFrameRateAvg', template => '%.2f', unit => '%', min => 0, max => 100 }, ], } @@ -63,7 +63,7 @@ sub set_counters { key_values => [ { name => 'OutboundVideoFrameRateAvg' } ], output_template => 'Outbound Video Frame Rate: %.2f%%', perfdatas => [ - { label => 'outbound_video_frame_rate_avg', value => 'OutboundVideoFrameRateAvg_absolute', + { label => 'outbound_video_frame_rate_avg', value => 'OutboundVideoFrameRateAvg', template => '%.2f', unit => '%', min => 0, max => 100 }, ], } @@ -74,7 +74,7 @@ sub set_counters { key_values => [ { name => 'TotalStreams' } ], output_template => 'Streams Count: %.2f/s', perfdatas => [ - { label => 'stream_count', value => 'TotalStreams_absolute', template => '%.2f', + { label => 'stream_count', value => 'TotalStreams', template => '%.2f', unit => 'streams/s', min => 0 }, ], } diff --git a/centreon/common/polycom/endpoint/snmp/mode/videoconferencing.pm b/centreon/common/polycom/endpoint/snmp/mode/videoconferencing.pm index 92eeb6298..06af0c25c 100644 --- a/centreon/common/polycom/endpoint/snmp/mode/videoconferencing.pm +++ b/centreon/common/polycom/endpoint/snmp/mode/videoconferencing.pm @@ -36,7 +36,7 @@ sub set_counters { key_values => [ { name => 'NumberActiveConferences' } ], output_template => 'Current Conferences : %s', perfdatas => [ - { label => 'conferences_active', value => 'NumberActiveConferences_absolute', template => '%d', min => 0 }, + { label => 'conferences_active', value => 'NumberActiveConferences', template => '%d', min => 0 }, ], } }, diff --git a/centreon/common/radlan/snmp/mode/cpu.pm b/centreon/common/radlan/snmp/mode/cpu.pm index b30a23b0f..6865682d7 100644 --- a/centreon/common/radlan/snmp/mode/cpu.pm +++ b/centreon/common/radlan/snmp/mode/cpu.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'average_1s' } ], output_template => '%.2f %% (1s)', perfdatas => [ - { value => 'average_1s_absolute', template => '%.2f', + { value => 'average_1s', template => '%.2f', min => 0, max => 100, unit => '%' } ] } @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'average_1m' } ], output_template => '%.2f %% (1m)', perfdatas => [ - { value => 'average_1m_absolute', template => '%.2f', + { value => 'average_1m', template => '%.2f', min => 0, max => 100, unit => '%' } ] } @@ -55,7 +55,7 @@ sub set_counters { key_values => [ { name => 'average_5m' } ], output_template => '%.2f %% (5m)', perfdatas => [ - { value => 'average_5m_absolute', template => '%.2f', + { value => 'average_5m', template => '%.2f', min => 0, max => 100, unit => '%' } ] } diff --git a/centreon/common/riverbed/steelhead/snmp/mode/bwoptimization.pm b/centreon/common/riverbed/steelhead/snmp/mode/bwoptimization.pm index 194d27d56..ff87dc10d 100644 --- a/centreon/common/riverbed/steelhead/snmp/mode/bwoptimization.pm +++ b/centreon/common/riverbed/steelhead/snmp/mode/bwoptimization.pm @@ -35,42 +35,38 @@ sub set_counters { $self->{maps_counters}->{global} = [ { label => 'wan2lan-lan', set => { - key_values => [ { name => 'bwHCAggInLan', diff => 1 } ], + key_values => [ { name => 'bwHCAggInLan', per_second => 1 } ], output_template => 'Wan2Lan on Lan: %s %s/s', - output_change_bytes => 1, per_second => 1, + output_change_bytes => 1, perfdatas => [ - { label => 'wan2lan_lan', value => 'bwHCAggInLan_per_second', - template => '%s', min => 0, unit => 'B/s' }, + { label => 'wan2lan_lan', template => '%s', min => 0, unit => 'B/s' }, ], } }, { label => 'wan2lan-wan', set => { - key_values => [ { name => 'bwHCAggInWan', diff => 1 } ], + key_values => [ { name => 'bwHCAggInWan', per_second => 1 } ], output_template => 'Wan2Lan on Wan: %s %s/s', - output_change_bytes => 1, per_second => 1, + output_change_bytes => 1, perfdatas => [ - { label => 'wan2lan_wan', value => 'bwHCAggInWan_per_second', - template => '%s', min => 0, unit => 'B/s' }, + { label => 'wan2lan_wan', template => '%s', min => 0, unit => 'B/s' }, ], } }, { label => 'lan2wan-lan', set => { - key_values => [ { name => 'bwHCAggOutLan', diff => 1 } ], + key_values => [ { name => 'bwHCAggOutLan', per_second => 1 } ], output_template => 'Lan2Wan on Lan: %s %s/s', - output_change_bytes => 1, per_second => 1, + output_change_bytes => 1, perfdatas => [ - { label => 'lan2wan_lan', value => 'bwHCAggOutLan_per_second', - template => '%s', min => 0, unit => 'B/s' }, + { label => 'lan2wan_lan', template => '%s', min => 0, unit => 'B/s' }, ], } }, { label => 'lan2wan-wan', set => { - key_values => [ { name => 'bwHCAggOutWan', diff => 1 } ], + key_values => [ { name => 'bwHCAggOutWan', per_second => 1 } ], output_template => 'Lan2Wan on Wan: %s %s/s', - output_change_bytes => 1, per_second => 1, + output_change_bytes => 1, perfdatas => [ - { label => 'lan2wan_wan', value => 'bwHCAggOutWan_per_second', - template => '%s', min => 0, unit => 'B/s' }, + { label => 'lan2wan_wan', template => '%s', min => 0, unit => 'B/s' }, ], } }, diff --git a/centreon/common/riverbed/steelhead/snmp/mode/bwpassthrough.pm b/centreon/common/riverbed/steelhead/snmp/mode/bwpassthrough.pm index 4ff04e356..424ed7a8c 100644 --- a/centreon/common/riverbed/steelhead/snmp/mode/bwpassthrough.pm +++ b/centreon/common/riverbed/steelhead/snmp/mode/bwpassthrough.pm @@ -35,22 +35,20 @@ sub set_counters { $self->{maps_counters}->{global} = [ { label => 'traffic-in', set => { - key_values => [ { name => 'bwPassThroughIn', diff => 1 } ], + key_values => [ { name => 'bwPassThroughIn', per_second => 1 } ], output_template => 'Traffic In (Wan2Lan): %s %s/s', - output_change_bytes => 1, per_second => 1, + output_change_bytes => 1, perfdatas => [ - { label => 'traffic_in', value => 'bwPassThroughIn_per_second', - template => '%s', min => 0, unit => 'B/s' }, + { label => 'traffic_in', template => '%s', min => 0, unit => 'B/s' }, ], } }, { label => 'traffic-out', set => { - key_values => [ { name => 'bwPassThroughOut', diff => 1 } ], + key_values => [ { name => 'bwPassThroughOut', per_second => 1 } ], output_template => 'Traffic Out (Lan2Wan): %s %s/s', - output_change_bytes => 1, per_second => 1, + output_change_bytes => 1, perfdatas => [ - { label => 'traffic_out', value => 'bwPassThroughOut_per_second', - template => '%s', min => 0, unit => 'B/s' }, + { label => 'traffic_out', template => '%s', min => 0, unit => 'B/s' }, ], } }, diff --git a/centreon/common/riverbed/steelhead/snmp/mode/connections.pm b/centreon/common/riverbed/steelhead/snmp/mode/connections.pm index 3237c52c4..cfb892b4f 100644 --- a/centreon/common/riverbed/steelhead/snmp/mode/connections.pm +++ b/centreon/common/riverbed/steelhead/snmp/mode/connections.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'totalConnections' } ], output_template => 'total %s', perfdatas => [ - { label => 'total', value => 'totalConnections_absolute', template => '%s', min => 0 }, + { label => 'total', value => 'totalConnections', template => '%s', min => 0 }, ], } }, @@ -45,7 +45,7 @@ sub set_counters { key_values => [ { name => 'establishedConnections' } ], output_template => 'established %s', perfdatas => [ - { label => 'established', value => 'establishedConnections_absolute', template => '%s', min => 0 }, + { label => 'established', value => 'establishedConnections', template => '%s', min => 0 }, ], } }, @@ -53,7 +53,7 @@ sub set_counters { key_values => [ { name => 'activeConnections' } ], output_template => 'active %s', perfdatas => [ - { label => 'active', value => 'activeConnections_absolute', template => '%s', min => 0 }, + { label => 'active', value => 'activeConnections', template => '%s', min => 0 }, ], } }, @@ -61,7 +61,7 @@ sub set_counters { key_values => [ { name => 'optimizedConnections' } ], output_template => 'optimized %s', perfdatas => [ - { label => 'optimized', value => 'optimizedConnections_absolute', template => '%s', min => 0 }, + { label => 'optimized', value => 'optimizedConnections', template => '%s', min => 0 }, ], } }, @@ -69,7 +69,7 @@ sub set_counters { key_values => [ { name => 'passthroughConnections' } ], output_template => 'passthrough %s', perfdatas => [ - { label => 'passthrough', value => 'passthroughConnections_absolute', template => '%s', min => 0 }, + { label => 'passthrough', value => 'passthroughConnections', template => '%s', min => 0 }, ], } }, @@ -77,7 +77,7 @@ sub set_counters { key_values => [ { name => 'halfOpenedConnections' } ], output_template => 'half opened %s', perfdatas => [ - { label => 'half_opened', value => 'halfOpenedConnections_absolute', template => '%s', min => 0 }, + { label => 'half_opened', value => 'halfOpenedConnections', template => '%s', min => 0 }, ], } }, @@ -85,7 +85,7 @@ sub set_counters { key_values => [ { name => 'halfClosedConnections' } ], output_template => 'half closed %s', perfdatas => [ - { label => 'half_closed', value => 'halfClosedConnections_absolute', template => '%s', min => 0 }, + { label => 'half_closed', value => 'halfClosedConnections', template => '%s', min => 0 }, ], } }, diff --git a/centreon/common/riverbed/steelhead/snmp/mode/diskutilization.pm b/centreon/common/riverbed/steelhead/snmp/mode/diskutilization.pm index 0d5255ea4..3a32b4b1b 100644 --- a/centreon/common/riverbed/steelhead/snmp/mode/diskutilization.pm +++ b/centreon/common/riverbed/steelhead/snmp/mode/diskutilization.pm @@ -38,28 +38,23 @@ sub set_counters { key_values => [ { name => 'dsAveDiskUtilization' } ], output_template => 'Datastore Usage: %.2f%%', perfdatas => [ - { label => 'used', value => 'dsAveDiskUtilization_absolute', template => '%.2f', - min => 0, max => 100, unit => '%' }, + { label => 'used', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } }, { label => 'hits', set => { - key_values => [ { name => 'dsHitsTotal', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'dsHitsTotal', per_second => 1 } ], output_template => 'Hits: %s/s', perfdatas => [ - { label => 'hits', value => 'dsHitsTotal_per_second', template => '%.2f', - min => 0, unit => 'hits/s' }, + { label => 'hits', template => '%.2f', min => 0, unit => 'hits/s' }, ], } }, { label => 'misses', set => { - key_values => [ { name => 'dsMissTotal', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'dsMissTotal', per_second => 1 } ], output_template => 'Misses: %s/s', perfdatas => [ - { label => 'misses', value => 'dsMissTotal_per_second', template => '%.2f', - min => 0, unit => 'misses/s' }, + { label => 'misses', template => '%.2f', min => 0, unit => 'misses/s' }, ], } }, @@ -73,6 +68,7 @@ sub new { $options{options}->add_options(arguments =>{ }); + return $self; } diff --git a/centreon/common/riverbed/steelhead/snmp/mode/loadaverage.pm b/centreon/common/riverbed/steelhead/snmp/mode/loadaverage.pm index d51d9b5c1..29705ac3c 100644 --- a/centreon/common/riverbed/steelhead/snmp/mode/loadaverage.pm +++ b/centreon/common/riverbed/steelhead/snmp/mode/loadaverage.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'cpuUtil1' } ], output_template => 'CPU Average: %.2f%%', perfdatas => [ - { label => 'total_cpu_avg', value => 'cpuUtil1_absolute', template => '%.2f', + { label => 'total_cpu_avg', value => 'cpuUtil1', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'cpuLoad1' } ], output_template => 'Load 1 min: %.2f', perfdatas => [ - { label => 'load1', value => 'cpuLoad1_absolute', template => '%.2f', + { label => 'load1', value => 'cpuLoad1', template => '%.2f', min => 0 }, ], } @@ -55,7 +55,7 @@ sub set_counters { key_values => [ { name => 'cpuLoad5' } ], output_template => 'Load 5 min: %.2f', perfdatas => [ - { label => 'load5', value => 'cpuLoad5_absolute', template => '%.2f', + { label => 'load5', value => 'cpuLoad5', template => '%.2f', min => 0 }, ], } @@ -64,7 +64,7 @@ sub set_counters { key_values => [ { name => 'cpuLoad15' } ], output_template => 'Load 15 min: %.2f', perfdatas => [ - { label => 'load15', value => 'cpuLoad15_absolute', template => '%.2f', + { label => 'load15', value => 'cpuLoad15', template => '%.2f', min => 0 }, ], } diff --git a/centreon/common/riverbed/steelhead/snmp/mode/status.pm b/centreon/common/riverbed/steelhead/snmp/mode/status.pm index b1d814566..737b1abe5 100644 --- a/centreon/common/riverbed/steelhead/snmp/mode/status.pm +++ b/centreon/common/riverbed/steelhead/snmp/mode/status.pm @@ -60,9 +60,9 @@ sub set_counters { }, { label => 'uptime', set => { key_values => [ { name => 'serviceUptime' }, { name => 'serviceUptime_human' } ], - output_template => 'Uptime: %s', output_use => 'serviceUptime_human_absolute', + output_template => 'Uptime: %s', output_use => 'serviceUptime_human', perfdatas => [ - { label => 'uptime', value => 'serviceUptime_absolute', template => '%d', + { label => 'uptime', value => 'serviceUptime', template => '%d', min => 0, unit => 's' }, ], } diff --git a/centreon/common/riverbed/steelhead/snmp/mode/temperature.pm b/centreon/common/riverbed/steelhead/snmp/mode/temperature.pm index 8f74b4366..59a53a0b5 100644 --- a/centreon/common/riverbed/steelhead/snmp/mode/temperature.pm +++ b/centreon/common/riverbed/steelhead/snmp/mode/temperature.pm @@ -38,7 +38,7 @@ sub set_counters { key_values => [ { name => 'systemTemperature' } ], output_template => 'Temperature: %.2f C', perfdatas => [ - { label => 'temperature', value => 'systemTemperature_absolute', template => '%.2f', + { label => 'temperature', value => 'systemTemperature', template => '%.2f', min => 0, unit => 'C' }, ], } diff --git a/centreon/common/xppc/snmp/mode/batterystatus.pm b/centreon/common/xppc/snmp/mode/batterystatus.pm index 056a9a33d..3b3c25e53 100644 --- a/centreon/common/xppc/snmp/mode/batterystatus.pm +++ b/centreon/common/xppc/snmp/mode/batterystatus.pm @@ -53,7 +53,7 @@ sub set_counters { key_values => [ { name => 'upsSmartBatteryCapacity' } ], output_template => 'remaining capacity: %s %%', perfdatas => [ - { value => 'upsSmartBatteryCapacity_absolute', template => '%s', min => 0, max => 100, unit => '%' }, + { value => 'upsSmartBatteryCapacity', template => '%s', min => 0, max => 100, unit => '%' }, ], } }, @@ -61,7 +61,7 @@ sub set_counters { key_values => [ { name => 'upsSmartBatteryRunTimeRemaining' } ], output_template => 'remaining time: %s minutes', perfdatas => [ - { value => 'upsSmartBatteryRunTimeRemaining_absolute', template => '%s', min => 0, unit => 'm' }, + { value => 'upsSmartBatteryRunTimeRemaining', template => '%s', min => 0, unit => 'm' }, ], } }, @@ -69,7 +69,7 @@ sub set_counters { key_values => [ { name => 'upsSmartBatteryVoltage', no_value => 0 } ], output_template => 'voltage: %s V', perfdatas => [ - { value => 'upsSmartBatteryVoltage_absolute', template => '%s', unit => 'V' }, + { value => 'upsSmartBatteryVoltage', template => '%s', unit => 'V' }, ], } }, @@ -77,7 +77,7 @@ sub set_counters { key_values => [ { name => 'upsSmartBatteryTemperature', no_value => 0 } ], output_template => 'temperature: %s C', perfdatas => [ - { value => 'upsSmartBatteryTemperature_absolute', template => '%s', unit => 'C' }, + { value => 'upsSmartBatteryTemperature', template => '%s', unit => 'C' }, ], } }, diff --git a/centreon/common/xppc/snmp/mode/environment.pm b/centreon/common/xppc/snmp/mode/environment.pm index ec41ff317..ec5a969dc 100644 --- a/centreon/common/xppc/snmp/mode/environment.pm +++ b/centreon/common/xppc/snmp/mode/environment.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'internal_temperature' } ], output_template => 'internal temperature: %.2f C', perfdatas => [ - { value => 'internal_temperature_absolute', template => '%.2f', + { value => 'internal_temperature', template => '%.2f', min => 0, unit => 'C' }, ], } @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'internal_humidity' } ], output_template => 'internal humidity: %.2f %%', perfdatas => [ - { value => 'internal_humidity_absolute', template => '%.2f', + { value => 'internal_humidity', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } @@ -55,7 +55,7 @@ sub set_counters { key_values => [ { name => 'remote_temperature' } ], output_template => 'remote temperature: %.2f C', perfdatas => [ - { value => 'remote_temperature_absolute', template => '%.2f', + { value => 'remote_temperature', template => '%.2f', min => 0, unit => 'C' }, ], } @@ -64,7 +64,7 @@ sub set_counters { key_values => [ { name => 'remote_humidity' } ], output_template => 'remote humidity: %.2f %%', perfdatas => [ - { value => 'remote_humidity_absolute', template => '%.2f', + { value => 'remote_humidity', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } diff --git a/centreon/common/xppc/snmp/mode/inputlines.pm b/centreon/common/xppc/snmp/mode/inputlines.pm index b8e8dbeb7..16c190f22 100644 --- a/centreon/common/xppc/snmp/mode/inputlines.pm +++ b/centreon/common/xppc/snmp/mode/inputlines.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'upsSmartInputFrequency', no_value => 0 } ], output_template => 'frequence: %.2f Hz', perfdatas => [ - { value => 'upsSmartInputFrequency_absolute', template => '%.2f', + { value => 'upsSmartInputFrequency', template => '%.2f', unit => 'Hz' }, ], } @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'upsSmartInputLineVoltage', no_value => 0 } ], output_template => 'voltage: %s V', perfdatas => [ - { value => 'upsSmartInputLineVoltage_absolute', template => '%s', + { value => 'upsSmartInputLineVoltage', template => '%s', unit => 'V' }, ], } diff --git a/centreon/common/xppc/snmp/mode/outputlines.pm b/centreon/common/xppc/snmp/mode/outputlines.pm index cea42be3b..df2f3d321 100644 --- a/centreon/common/xppc/snmp/mode/outputlines.pm +++ b/centreon/common/xppc/snmp/mode/outputlines.pm @@ -52,7 +52,7 @@ sub set_counters { key_values => [ { name => 'upsSmartOutputLoad', no_value => -1 } ], output_template => 'load: %.2f %%', perfdatas => [ - { value => 'upsSmartOutputLoad_absolute', template => '%.2f', min => 0, max => 100 }, + { value => 'upsSmartOutputLoad', template => '%.2f', min => 0, max => 100 }, ], } }, @@ -60,7 +60,7 @@ sub set_counters { key_values => [ { name => 'upsSmartOutputFrequency', no_value => 0 } ], output_template => 'frequence: %.2f Hz', perfdatas => [ - { value => 'upsSmartOutputFrequency_absolute', template => '%.2f', unit => 'Hz' }, + { value => 'upsSmartOutputFrequency', template => '%.2f', unit => 'Hz' }, ], } }, @@ -68,7 +68,7 @@ sub set_counters { key_values => [ { name => 'upsSmartOutputVoltage', no_value => 0 } ], output_template => 'voltage: %s V', perfdatas => [ - { value => 'upsSmartOutputVoltage_absolute', template => '%s', + { value => 'upsSmartOutputVoltage', template => '%s', unit => 'V' }, ], } diff --git a/centreon/plugins/templates/counter.pm b/centreon/plugins/templates/counter.pm index 4ab923489..e0951f33d 100644 --- a/centreon/plugins/templates/counter.pm +++ b/centreon/plugins/templates/counter.pm @@ -52,7 +52,7 @@ sub set_counters { # key_values => [ { name => 'client' } ], # output_template => 'Current client connections : %s', # perfdatas => [ - # { label => 'Client', value => 'client_absolute', template => '%s', + # { label => 'Client', value => 'client', template => '%s', # min => 0, unit => 'con' }, # ], # } @@ -332,8 +332,10 @@ sub run_instances { $no_message_multiple = 0; $obj->set(instance => $id); - my ($value_check) = $obj->execute(new_datas => $self->{new_datas}, - values => $self->{$options{config}->{name}}->{$id}); + my ($value_check) = $obj->execute( + new_datas => $self->{new_datas}, + values => $self->{$options{config}->{name}}->{$id} + ); next if (defined($options{config}->{skipped_code}) && defined($options{config}->{skipped_code}->{$value_check})); if ($value_check != 0) { $long_msg .= $long_msg_append . $obj->output_error(); @@ -382,8 +384,10 @@ sub run_instances { } if (!$self->{output}->is_status(litteral => 1, value => $exit, compare => 'ok')) { - $self->{output}->output_add(severity => $exit, - short_msg => $prefix_output . $short_msg . $suffix_output); + $self->{output}->output_add( + severity => $exit, + short_msg => $prefix_output . $short_msg . $suffix_output + ); } if ($self->{multiple} == 0) { @@ -648,7 +652,7 @@ sub run { $self->{statefile_value}->read(statefile => $self->{cache_name}) if (defined($self->{cache_name})); $self->{new_datas}->{last_timestamp} = time(); } - + foreach my $entry (@{$self->{maps_counters_type}}) { if ($entry->{type} == 0) { $self->run_global(config => $entry); diff --git a/centreon/plugins/values.pm b/centreon/plugins/values.pm index 33d9c7826..5e9794725 100644 --- a/centreon/plugins/values.pm +++ b/centreon/plugins/values.pm @@ -43,8 +43,6 @@ sub new { $self->{output_template} = $self->{label} . ' : %s'; $self->{output_use} = undef; $self->{output_change_bytes} = 0; - $self->{output_absolute_unit} = ''; - $self->{output_per_second_unit} = ''; $self->{output_error_template} = $self->{label} . ' : %s'; @@ -89,14 +87,12 @@ sub calc { # manage only one value ;) foreach my $value (@{$self->{key_values}}) { - if (defined($value->{diff}) && $value->{diff} == 1) { - if (defined($self->{per_second}) && $self->{per_second} == 1) { - $self->{result_values}->{$value->{name} . '_per_second'} = ($options{new_datas}->{$self->{instance} . '_' . $value->{name}} - $options{old_datas}->{$self->{instance} . '_' . $value->{name}}) / $options{delta_time}; - } - $self->{result_values}->{$value->{name} . '_absolute'} = $options{new_datas}->{$self->{instance} . '_' . $value->{name}} - $options{old_datas}->{$self->{instance} . '_' . $value->{name}}; + if (defined($value->{per_second}) && $value->{per_second} == 1) { + $self->{result_values}->{$value->{name}} = ($options{new_datas}->{$self->{instance} . '_' . $value->{name}} - $options{old_datas}->{$self->{instance} . '_' . $value->{name}}) / $options{delta_time}; + } elsif (defined($value->{diff}) && $value->{diff} == 1) { + $self->{result_values}->{$value->{name}} = $options{new_datas}->{$self->{instance} . '_' . $value->{name}} - $options{old_datas}->{$self->{instance} . '_' . $value->{name}}; } else { - # absolute one. nothing to do. Can be used for values. - $self->{result_values}->{$value->{name} . '_absolute'} = $options{new_datas}->{$self->{instance} . '_' . $value->{name}}; + $self->{result_values}->{$value->{name}} = $options{new_datas}->{$self->{instance} . '_' . $value->{name}}; } } @@ -113,25 +109,24 @@ sub threshold_check { my $warn = defined($self->{threshold_warn}) ? $self->{threshold_warn} : 'warning-' . $self->{thlabel}; my $crit = defined($self->{threshold_crit}) ? $self->{threshold_crit} : 'critical-' . $self->{thlabel}; - my $first = defined($self->{key_values}->[0]) ? $self->{key_values}->[0]->{name} : ''; - my $value; - - if (!defined($self->{threshold_use})) { - $value = $self->{result_values}->{$first . '_absolute'}; - if (defined($self->{per_second}) && $self->{per_second} == 1) { - $value = $self->{result_values}->{$first . '_per_second'}; - } + my $value = ''; + if (defined($self->{threshold_use})) { + $value = $self->{result_values}->{ $self->{threshold_use} }; } else { - $value = $self->{result_values}->{$self->{threshold_use}}; + $value = defined($self->{key_values}->[0]) ? $self->{key_values}->[0]->{name} : ''; } - return $self->{perfdata}->threshold_check(value => $value, threshold => [ { label => $crit, 'exit_litteral' => 'critical' }, - { label => $warn, 'exit_litteral' => 'warning' }]); + return $self->{perfdata}->threshold_check( + value => $value, threshold => [ + { label => $crit, exit_litteral => 'critical' }, + { label => $warn, exit_litteral => 'warning' } + ] + ); } sub output_error { my ($self, %options) = @_; - + return sprintf($self->{output_error_template}, $self->{error_msg}); } @@ -141,24 +136,23 @@ sub output { if (defined($self->{closure_custom_output})) { return $self->{closure_custom_output}->($self); } - my $first = defined($self->{key_values}->[0]) ? $self->{key_values}->[0]->{name} : undef; - my ($value, $unit) = (defined($first) ? $self->{result_values}->{$first . '_absolute'} : '', $self->{output_absolute_unit}); - - if (!defined($self->{output_use})) { - if ($self->{per_second} == 1) { - $value = $self->{result_values}->{$first . '_per_second'}; - $unit = $self->{output_per_second_unit}; - } + + my ($value, $unit, $name) = ('', ''); + if (defined($self->{output_use})) { + $name = $self->{output_use}; } else { - $value = $self->{result_values}->{$self->{output_use}}; + $name = defined($self->{key_values}->[0]) ? $self->{key_values}->[0]->{name} : undef; } - if ($self->{output_change_bytes} == 1) { - ($value, $unit) = $self->{perfdata}->change_bytes(value => $value); - } elsif ($self->{output_change_bytes} == 2) { - ($value, $unit) = $self->{perfdata}->change_bytes(value => $value, network => 1); + if (defined($name)) { + $value = $self->{result_values}->{$name}; + if ($self->{output_change_bytes} == 1) { + ($value, $unit) = $self->{perfdata}->change_bytes(value => $value); + } elsif ($self->{output_change_bytes} == 2) { + ($value, $unit) = $self->{perfdata}->change_bytes(value => $value, network => 1); + } } - + return sprintf($self->{output_template}, $value, $unit); } @@ -213,15 +207,17 @@ sub perfdata { } } + my $value = defined($perf->{value}) ? $perf->{value} : $self->{key_values}->[0]->{name}; $self->{output}->perfdata_add( label => $label, instances => $instances, nlabel => $self->{nlabel}, unit => $perf->{unit}, - value => $cast_int == 1 ? int($self->{result_values}->{$perf->{value}}) : sprintf($template, $self->{result_values}->{$perf->{value}}), + value => $cast_int == 1 ? int($self->{result_values}->{$value}) : sprintf($template, $self->{result_values}->{$value}), warning => $self->{perfdata}->get_perfdata_for_output(label => $warn, total => $th_total, cast_int => $cast_int), critical => $self->{perfdata}->get_perfdata_for_output(label => $crit, total => $th_total, cast_int => $cast_int), - min => $min, max => $max + min => $min, + max => $max ); } } @@ -233,7 +229,6 @@ sub execute { $self->{result_values} = {}, $self->{error_msg} = undef; my $quit = 0; - my $per_second = 0; $options{new_datas} = {} if (!defined($options{new_datas})); foreach my $value (@{$self->{key_values}}) { @@ -243,7 +238,8 @@ sub execute { last; } - if (defined($value->{diff}) && $value->{diff} == 1) { + if ((defined($value->{diff}) && $value->{diff} == 1) || + (defined($value->{per_second}) && $value->{per_second} == 1)) { $options{new_datas}->{$self->{instance} . '_' . $value->{name}} = $options{values}->{$value->{name}}; $old_datas->{$self->{instance} . '_' . $value->{name}} = $self->{statefile}->get(name => $self->{instance} . '_' . $value->{name}); if (!defined($old_datas->{$self->{instance} . '_' . $value->{name}})) { @@ -272,27 +268,21 @@ sub execute { } if ($quit == 2) { - $self->{error_msg} = "skipped (no value(s))"; + $self->{error_msg} = 'skipped (no value(s))'; return -10; } - + + if (defined($self->{statefile})) { + $self->{last_timestamp} = $self->{statefile}->get(name => 'last_timestamp'); + } + if ($quit == 1) { - $self->{error_msg} = "Buffer creation"; + $self->{error_msg} = 'Buffer creation'; return -1; } - - if (defined($self->{per_second}) && $self->{per_second} == 1) { - if (!defined($self->{last_timestamp})) { - $self->{last_timestamp} = $self->{statefile}->get(name => 'last_timestamp'); - } - if (!defined($self->{last_timestamp})) { - $self->{error_msg} = "Buffer creation"; - return -1; - } - } - + my $delta_time; - if (defined($self->{per_second}) && $self->{per_second} == 1) { + if (defined($self->{statefile}) && defined($self->{last_timestamp})) { $delta_time = $options{new_datas}->{last_timestamp} - $self->{last_timestamp}; if ($delta_time <= 0) { $delta_time = 1; @@ -300,7 +290,13 @@ sub execute { } if (defined($self->{closure_custom_calc})) { - return $self->{closure_custom_calc}->($self, old_datas => $old_datas, new_datas => $options{new_datas}, delta_time => $delta_time, extra_options => $self->{closure_custom_calc_extra_options}); + return $self->{closure_custom_calc}->( + $self, + old_datas => $old_datas, + new_datas => $options{new_datas}, + delta_time => $delta_time, + extra_options => $self->{closure_custom_calc_extra_options} + ); } return $self->calc(old_datas => $old_datas, new_datas => $options{new_datas}, delta_time => $delta_time); } diff --git a/changelog b/changelog index 4b477357f..3da1cd2e2 100644 --- a/changelog +++ b/changelog @@ -1,4 +1,6 @@ 2020-XX-XX Quentin Garnier + * Plugin added: ActiveMQ JMX + * Plugin added: VerneMQ Rest API * Plugin added: Ruckus SmartZone SNMP * Plugin added: Ruckus ZoneDirector SNMP * Plugin added: Ruckus ICX SNMP @@ -6,6 +8,7 @@ * Plugin added: Adva FSP150 SNMP * Plugin added: Lenovo Iomega SNMP * Plugin added: Netapp Santricity Rest API + * Plugin added: Timelinkmicro tms6001 SNMP * Plugin added: Bluemind * Plugin added: Mulesoft Rest API * Plugin added: Salesforce Rest API diff --git a/cloud/aws/apigateway/mode/latency.pm b/cloud/aws/apigateway/mode/latency.pm index 57bcc04b0..cd03b83ef 100644 --- a/cloud/aws/apigateway/mode/latency.pm +++ b/cloud/aws/apigateway/mode/latency.pm @@ -81,7 +81,7 @@ sub set_counters { key_values => [ { name => $metric }, { name => 'display' } ], output_template => $metrics_mapping{$metric}->{output} . ': %.2f ' . $metrics_mapping{$metric}->{output_unit}, perfdatas => [ - { value => $metric . '_absolute', template => '%.2f', label_extra_instance => 1, + { value => $metric , template => '%.2f', label_extra_instance => 1, perfdata_unit => $metrics_mapping{$metric}->{perfdata_unit} } ], } diff --git a/cloud/aws/apigateway/mode/requests.pm b/cloud/aws/apigateway/mode/requests.pm index 0dd38bfa6..b95cd685b 100644 --- a/cloud/aws/apigateway/mode/requests.pm +++ b/cloud/aws/apigateway/mode/requests.pm @@ -82,7 +82,7 @@ sub set_counters { key_values => [ { name => $metric }, { name => 'display' } ], output_template => $metrics_mapping{$metric}->{output} . ': %.2f', perfdatas => [ - { value => $metric . '_absolute', template => '%.2f', label_extra_instance => 1 } + { value => $metric , template => '%.2f', label_extra_instance => 1 } ], } }; diff --git a/cloud/aws/billing/mode/estimatedcharges.pm b/cloud/aws/billing/mode/estimatedcharges.pm index 70438cb99..1e7c1cf5b 100644 --- a/cloud/aws/billing/mode/estimatedcharges.pm +++ b/cloud/aws/billing/mode/estimatedcharges.pm @@ -44,7 +44,7 @@ sub set_counters { key_values => [ { name => 'estimated_charges' }, { name => 'display' } ], output_template => 'Estimated Charges: %.2f USD', perfdatas => [ - { value => 'estimated_charges_absolute', template => '%.2f', unit => 'USD', + { value => 'estimated_charges', template => '%.2f', unit => 'USD', label_extra_instance => 1 }, ], } diff --git a/cloud/aws/cloudfront/mode/errors.pm b/cloud/aws/cloudfront/mode/errors.pm index d6d337211..319a35e1a 100644 --- a/cloud/aws/cloudfront/mode/errors.pm +++ b/cloud/aws/cloudfront/mode/errors.pm @@ -82,7 +82,7 @@ sub set_counters { key_values => [ { name => $metric }, { name => 'display' } ], output_template => $metrics_mapping{$metric}->{output} . ': %.2f', perfdatas => [ - { value => $metric . '_absolute', template => '%.2f', label_extra_instance => 1 } + { value => $metric , template => '%.2f', label_extra_instance => 1 } ], } }; diff --git a/cloud/aws/cloudwatch/mode/getmetrics.pm b/cloud/aws/cloudwatch/mode/getmetrics.pm index a0d19a1a0..7af2ec2e9 100644 --- a/cloud/aws/cloudwatch/mode/getmetrics.pm +++ b/cloud/aws/cloudwatch/mode/getmetrics.pm @@ -152,8 +152,8 @@ sub check_options { key_values => [ { name => $metric_name . '_' . $statistic }, { name => 'display' } ], output_template => $metric_name . ' ' . ucfirst($statistic) . ' : %s', perfdatas => [ - { label => lc($metric_name) . '_' . $statistic, value => $metric_name . '_' . $statistic . '_absolute', template => '%s', - label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => lc($metric_name) . '_' . $statistic, value => $metric_name . '_' . $statistic , template => '%s', + label_extra_instance => 1, instance_use => 'display' }, ], } }; diff --git a/cloud/aws/ec2/mode/cpu.pm b/cloud/aws/ec2/mode/cpu.pm index 08946c33f..09e44c44b 100644 --- a/cloud/aws/ec2/mode/cpu.pm +++ b/cloud/aws/ec2/mode/cpu.pm @@ -97,7 +97,7 @@ sub set_counters { key_values => [ { name => $metric }, { name => 'display' } ], output_template => $metrics_mapping{$metric}->{output} . ': %.2f', perfdatas => [ - { value => $metric . '_absolute', template => '%.2f', label_extra_instance => 1 } + { value => $metric , template => '%.2f', label_extra_instance => 1 } ], } }; diff --git a/cloud/aws/ec2/mode/instancesstatus.pm b/cloud/aws/ec2/mode/instancesstatus.pm index ef689b0fb..ad595f569 100644 --- a/cloud/aws/ec2/mode/instancesstatus.pm +++ b/cloud/aws/ec2/mode/instancesstatus.pm @@ -56,7 +56,7 @@ sub set_counters { key_values => [ { name => 'pending' } ], output_template => "Pending : %s", perfdatas => [ - { value => 'pending_absolute', template => '%d', min => 0 }, + { value => 'pending', template => '%d', min => 0 }, ], } }, @@ -64,7 +64,7 @@ sub set_counters { key_values => [ { name => 'running' } ], output_template => "Running : %s", perfdatas => [ - { value => 'running_absolute', template => '%d', min => 0 }, + { value => 'running', template => '%d', min => 0 }, ], } }, @@ -72,7 +72,7 @@ sub set_counters { key_values => [ { name => 'shutting-down' } ], output_template => "Shutting Down : %s", perfdatas => [ - { value => 'shutting-down_absolute', template => '%d', min => 0 }, + { value => 'shutting-down', template => '%d', min => 0 }, ], } }, @@ -80,7 +80,7 @@ sub set_counters { key_values => [ { name => 'terminated' } ], output_template => "Terminated : %s", perfdatas => [ - { value => 'terminated_absolute', template => '%d', min => 0 }, + { value => 'terminated', template => '%d', min => 0 }, ], } }, @@ -88,7 +88,7 @@ sub set_counters { key_values => [ { name => 'stopping' } ], output_template => "Stopping : %s", perfdatas => [ - { value => 'stopping_absolute', template => '%d', min => 0 }, + { value => 'stopping', template => '%d', min => 0 }, ], } }, @@ -96,7 +96,7 @@ sub set_counters { key_values => [ { name => 'stopped' } ], output_template => "Stopped : %s", perfdatas => [ - { value => 'stopped_absolute', template => '%d', min => 0 }, + { value => 'stopped', template => '%d', min => 0 }, ], } }, diff --git a/cloud/aws/ec2/mode/instancestypes.pm b/cloud/aws/ec2/mode/instancestypes.pm index 3da9abe5c..bf01ce51e 100644 --- a/cloud/aws/ec2/mode/instancestypes.pm +++ b/cloud/aws/ec2/mode/instancestypes.pm @@ -136,7 +136,7 @@ sub set_counters { key_values => [ { name => $type } ], output_template => $type . ": %s", perfdatas => [ - { value => $type . '_absolute', template => '%d', min => 0 }, + { value => $type , template => '%d', min => 0 }, ], } }; diff --git a/cloud/aws/ec2/mode/spotactiveinstances.pm b/cloud/aws/ec2/mode/spotactiveinstances.pm index e343cec54..f7a626242 100644 --- a/cloud/aws/ec2/mode/spotactiveinstances.pm +++ b/cloud/aws/ec2/mode/spotactiveinstances.pm @@ -36,7 +36,7 @@ sub set_counters { key_values => [ { name => 'active' } ], output_template => 'Active instances : %s', perfdatas => [ - { label => 'active', value => 'active_absolute', template => '%s', + { label => 'active', value => 'active', template => '%s', min => 0 }, ], } @@ -45,7 +45,7 @@ sub set_counters { key_values => [ { name => 'healthy' } ], output_template => 'Healthy instances : %s', perfdatas => [ - { label => 'healthy', value => 'healthy_absolute', template => '%s', + { label => 'healthy', value => 'healthy', template => '%s', min => 0 }, ], } @@ -54,7 +54,7 @@ sub set_counters { key_values => [ { name => 'unhealthy' } ], output_template => 'Unhealty instances : %s', perfdatas => [ - { label => 'unhealthy', value => 'unhealthy_absolute', template => '%s', + { label => 'unhealthy', value => 'unhealthy', template => '%s', min => 0 }, ], } diff --git a/cloud/aws/elasticache/mode/connections.pm b/cloud/aws/elasticache/mode/connections.pm index b0717845a..b26c771b5 100644 --- a/cloud/aws/elasticache/mode/connections.pm +++ b/cloud/aws/elasticache/mode/connections.pm @@ -96,8 +96,8 @@ sub set_counters { key_values => [ { name => $metric . '_' . $statistic }, { name => 'display' }, { name => 'stat' } ], output_template => $metric . ': %d connections', perfdatas => [ - { label => lc($metric) . '_' . lc($statistic), value => $metric . '_' . $statistic . '_absolute', - template => '%d', unit => 'conn', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => lc($metric) . '_' . lc($statistic), value => $metric . '_' . $statistic , + template => '%d', unit => 'conn', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }; diff --git a/cloud/aws/elasticache/mode/cpu.pm b/cloud/aws/elasticache/mode/cpu.pm index 6a1f9f9c7..d011a190b 100644 --- a/cloud/aws/elasticache/mode/cpu.pm +++ b/cloud/aws/elasticache/mode/cpu.pm @@ -49,8 +49,8 @@ sub set_counters { key_values => [ { name => $metric . '_' . $statistic }, { name => 'display' }, { name => 'stat' } ], output_template => $metric . ': %.2f %%', perfdatas => [ - { label => lc($metric) . '_' . lc($statistic), value => $metric . '_' . $statistic . '_absolute', - template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => lc($metric) . '_' . lc($statistic), value => $metric . '_' . $statistic , + template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }, ], } }; diff --git a/cloud/aws/elasticache/mode/items.pm b/cloud/aws/elasticache/mode/items.pm index c8d4b38b5..110b0bdd8 100644 --- a/cloud/aws/elasticache/mode/items.pm +++ b/cloud/aws/elasticache/mode/items.pm @@ -96,8 +96,8 @@ sub set_counters { key_values => [ { name => $metric . '_' . $statistic }, { name => 'display' }, { name => 'stat' }, { name => 'timeframe' } ], output_template => $metric . ': %d items', perfdatas => [ - { label => lc($metric) . '_' . lc($statistic), value => $metric . '_' . $statistic . '_absolute', - template => '%d', unit => 'items', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => lc($metric) . '_' . lc($statistic), value => $metric . '_' . $statistic , + template => '%d', unit => 'items', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }; diff --git a/cloud/aws/elasticache/mode/replication.pm b/cloud/aws/elasticache/mode/replication.pm index 6c2871851..8077dbfec 100644 --- a/cloud/aws/elasticache/mode/replication.pm +++ b/cloud/aws/elasticache/mode/replication.pm @@ -113,8 +113,8 @@ sub set_counters { key_values => [ { name => $metric . '_' . $statistic }, { name => 'display' }, { name => 'stat' }, { name => 'timeframe' } ], output_template => $metric . ': %.2f s', perfdatas => [ - { label => lc($metric) . '_' . lc($statistic), value => $metric . '_' . $statistic . '_absolute', - template => '%.2f', unit => 's', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => lc($metric) . '_' . lc($statistic), value => $metric . '_' . $statistic , + template => '%.2f', unit => 's', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }; diff --git a/cloud/aws/elasticache/mode/usagememcached.pm b/cloud/aws/elasticache/mode/usagememcached.pm index d9c0529fe..5ec41f09f 100644 --- a/cloud/aws/elasticache/mode/usagememcached.pm +++ b/cloud/aws/elasticache/mode/usagememcached.pm @@ -50,8 +50,8 @@ sub set_counters { output_template => $metric . ': %d %s', output_change_bytes => 1, perfdatas => [ - { label => lc($metric) . '_' . lc($statistic), value => $metric . '_' . $statistic . '_absolute', - template => '%d', unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => lc($metric) . '_' . lc($statistic), value => $metric . '_' . $statistic , + template => '%d', unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }; diff --git a/cloud/aws/elasticache/mode/usageredis.pm b/cloud/aws/elasticache/mode/usageredis.pm index d7c2b6240..cb9ba8faa 100644 --- a/cloud/aws/elasticache/mode/usageredis.pm +++ b/cloud/aws/elasticache/mode/usageredis.pm @@ -50,8 +50,8 @@ sub set_counters { output_template => $metric . ': %d %s', output_change_bytes => 1, perfdatas => [ - { label => lc($metric) . '_' . lc($statistic), value => $metric . '_' . $statistic . '_absolute', - template => '%d', unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => lc($metric) . '_' . lc($statistic), value => $metric . '_' . $statistic , + template => '%d', unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }; diff --git a/cloud/aws/elb/application/mode/connections.pm b/cloud/aws/elb/application/mode/connections.pm index 903837b04..0147f4451 100644 --- a/cloud/aws/elb/application/mode/connections.pm +++ b/cloud/aws/elb/application/mode/connections.pm @@ -97,7 +97,7 @@ sub set_counters { key_values => [ { name => $metric }, { name => 'display' } ], output_template => $metrics_mapping{$metric}->{output} . ': %.2f', perfdatas => [ - { value => $metric . '_absolute', template => '%.2f', label_extra_instance => 1 } + { value => $metric , template => '%.2f', label_extra_instance => 1 } ], } }; diff --git a/cloud/aws/elb/application/mode/httpcodes.pm b/cloud/aws/elb/application/mode/httpcodes.pm index 5838b084b..77989d102 100644 --- a/cloud/aws/elb/application/mode/httpcodes.pm +++ b/cloud/aws/elb/application/mode/httpcodes.pm @@ -112,7 +112,7 @@ sub set_counters { key_values => [ { name => $metric }, { name => 'display' } ], output_template => $metrics_mapping{$metric}->{output} . ': %.2f', perfdatas => [ - { value => $metric . '_absolute', template => '%.2f', label_extra_instance => 1 } + { value => $metric , template => '%.2f', label_extra_instance => 1 } ], } }; diff --git a/cloud/aws/elb/application/mode/targetshealth.pm b/cloud/aws/elb/application/mode/targetshealth.pm index 083139090..e2c55ae99 100644 --- a/cloud/aws/elb/application/mode/targetshealth.pm +++ b/cloud/aws/elb/application/mode/targetshealth.pm @@ -87,7 +87,7 @@ sub set_counters { key_values => [ { name => $metric }, { name => 'display' } ], output_template => $metrics_mapping{$metric}->{output} . ': %.2f', perfdatas => [ - { value => $metric . '_absolute', template => '%.2f', label_extra_instance => 1 } + { value => $metric , template => '%.2f', label_extra_instance => 1 } ], } }; diff --git a/cloud/aws/elb/classic/mode/httpcodes.pm b/cloud/aws/elb/classic/mode/httpcodes.pm index db9b99ec1..4b4bda977 100644 --- a/cloud/aws/elb/classic/mode/httpcodes.pm +++ b/cloud/aws/elb/classic/mode/httpcodes.pm @@ -117,7 +117,7 @@ sub set_counters { key_values => [ { name => $metric }, { name => 'display' } ], output_template => $metrics_mapping{$metric}->{output} . ': %.2f', perfdatas => [ - { value => $metric . '_absolute', template => '%.2f', label_extra_instance => 1 } + { value => $metric , template => '%.2f', label_extra_instance => 1 } ], } }; diff --git a/cloud/aws/elb/classic/mode/performances.pm b/cloud/aws/elb/classic/mode/performances.pm index a13980dfc..7d3d3452d 100644 --- a/cloud/aws/elb/classic/mode/performances.pm +++ b/cloud/aws/elb/classic/mode/performances.pm @@ -92,7 +92,7 @@ sub set_counters { key_values => [ { name => $metric }, { name => 'display' } ], output_template => $metrics_mapping{$metric}->{output} . ': %.2f', perfdatas => [ - { value => $metric . '_absolute', template => '%.2f', label_extra_instance => 1 } + { value => $metric , template => '%.2f', label_extra_instance => 1 } ], } }; diff --git a/cloud/aws/elb/classic/mode/queues.pm b/cloud/aws/elb/classic/mode/queues.pm index 82a0f93a5..de6fee464 100644 --- a/cloud/aws/elb/classic/mode/queues.pm +++ b/cloud/aws/elb/classic/mode/queues.pm @@ -92,7 +92,7 @@ sub set_counters { key_values => [ { name => $metric }, { name => 'display' } ], output_template => $metrics_mapping{$metric}->{output} . ': %.2f', perfdatas => [ - { value => $metric . '_absolute', template => '%.2f', label_extra_instance => 1 } + { value => $metric , template => '%.2f', label_extra_instance => 1 } ], } }; diff --git a/cloud/aws/elb/classic/mode/targetshealth.pm b/cloud/aws/elb/classic/mode/targetshealth.pm index 1d45c9b33..4c9b4f5ba 100644 --- a/cloud/aws/elb/classic/mode/targetshealth.pm +++ b/cloud/aws/elb/classic/mode/targetshealth.pm @@ -92,7 +92,7 @@ sub set_counters { key_values => [ { name => $metric }, { name => 'display' } ], output_template => $metrics_mapping{$metric}->{output} . ': %.2f', perfdatas => [ - { value => $metric . '_absolute', template => '%.2f', label_extra_instance => 1 } + { value => $metric , template => '%.2f', label_extra_instance => 1 } ], } }; diff --git a/cloud/aws/elb/network/mode/targetshealth.pm b/cloud/aws/elb/network/mode/targetshealth.pm index dc145d268..8a9734588 100644 --- a/cloud/aws/elb/network/mode/targetshealth.pm +++ b/cloud/aws/elb/network/mode/targetshealth.pm @@ -87,7 +87,7 @@ sub set_counters { key_values => [ { name => $metric }, { name => 'display' } ], output_template => $metrics_mapping{$metric}->{output} . ': %.2f', perfdatas => [ - { value => $metric . '_absolute', template => '%.2f', label_extra_instance => 1 } + { value => $metric , template => '%.2f', label_extra_instance => 1 } ], } }; diff --git a/cloud/aws/kinesis/mode/recordsstats.pm b/cloud/aws/kinesis/mode/recordsstats.pm index c98566e05..7744334eb 100644 --- a/cloud/aws/kinesis/mode/recordsstats.pm +++ b/cloud/aws/kinesis/mode/recordsstats.pm @@ -122,7 +122,7 @@ sub set_counters { output_template => ($metrics_mapping{$metric}->{change_bytes} != 0) ? $metrics_mapping{$metric}->{output} . ': %.2f %s' : $metrics_mapping{$metric}->{output} . ': %.2f', change_bytes => $metrics_mapping{$metric}->{output_change_bytes}, perfdatas => [ - { value => $metric . '_absolute', template => '%.2f', label_extra_instance => 1, unit => $metrics_mapping{$metric}->{perf_unit} } + { value => $metric , template => '%.2f', label_extra_instance => 1, unit => $metrics_mapping{$metric}->{perf_unit} } ], } }; diff --git a/cloud/aws/kinesis/mode/streams.pm b/cloud/aws/kinesis/mode/streams.pm index 198556f0a..8a00ebae2 100644 --- a/cloud/aws/kinesis/mode/streams.pm +++ b/cloud/aws/kinesis/mode/streams.pm @@ -98,7 +98,7 @@ sub set_counters { output_template => ($metrics_mapping{$metric}->{change_bytes} != 0) ? $metrics_mapping{$metric}->{output} . ': %.2f %s' : $metrics_mapping{$metric}->{output} . ': %.2f', change_bytes => $metrics_mapping{$metric}->{output_change_bytes}, perfdatas => [ - { value => $metric . '_absolute', template => '%.2f', label_extra_instance => 1, unit => $metrics_mapping{$metric}->{perf_unit} } + { value => $metric , template => '%.2f', label_extra_instance => 1, unit => $metrics_mapping{$metric}->{perf_unit} } ], } }; diff --git a/cloud/aws/lambda/mode/invocations.pm b/cloud/aws/lambda/mode/invocations.pm index fe3e08bf5..586485997 100644 --- a/cloud/aws/lambda/mode/invocations.pm +++ b/cloud/aws/lambda/mode/invocations.pm @@ -97,7 +97,7 @@ sub set_counters { key_values => [ { name => $metric }, { name => 'display' } ], output_template => $metrics_mapping{$metric}->{output} . ': %.2f', perfdatas => [ - { value => $metric . '_absolute', template => '%.2f', label_extra_instance => 1 } + { value => $metric , template => '%.2f', label_extra_instance => 1 } ], } }; diff --git a/cloud/aws/rds/mode/connections.pm b/cloud/aws/rds/mode/connections.pm index 983fd682e..3a7ed2d4a 100644 --- a/cloud/aws/rds/mode/connections.pm +++ b/cloud/aws/rds/mode/connections.pm @@ -49,8 +49,8 @@ sub set_counters { key_values => [ { name => $metric . '_' . $statistic }, { name => 'display' }, { name => 'type' }, { name => 'stat' } ], output_template => $metric . ': %d', perfdatas => [ - { label => lc($metric) . '_' . lc($statistic), value => $metric . '_' . $statistic . '_absolute', - template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => lc($metric) . '_' . lc($statistic), value => $metric . '_' . $statistic , + template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }; diff --git a/cloud/aws/rds/mode/cpu.pm b/cloud/aws/rds/mode/cpu.pm index 22fc2f1b1..a4681964f 100644 --- a/cloud/aws/rds/mode/cpu.pm +++ b/cloud/aws/rds/mode/cpu.pm @@ -49,8 +49,8 @@ sub set_counters { key_values => [ { name => $metric . '_' . $statistic }, { name => 'display' }, { name => 'type' }, { name => 'stat' } ], output_template => $metric . ': %.2f', perfdatas => [ - { label => lc($metric) . '_' . lc($statistic), value => $metric . '_' . $statistic . '_absolute', - template => '%.2f', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => lc($metric) . '_' . lc($statistic), value => $metric . '_' . $statistic , + template => '%.2f', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }; @@ -61,8 +61,8 @@ sub set_counters { key_values => [ { name => $metric . '_' . $statistic }, { name => 'display' }, { name => 'type' }, { name => 'stat' } ], output_template => $metric . ': %.2f %%', perfdatas => [ - { label => lc($metric) . '_' . lc($statistic), value => $metric . '_' . $statistic . '_absolute', - template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => lc($metric) . '_' . lc($statistic), value => $metric . '_' . $statistic , + template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }, ], } }; diff --git a/cloud/aws/rds/mode/diskio.pm b/cloud/aws/rds/mode/diskio.pm index 7f498dfaf..86fb0e9af 100644 --- a/cloud/aws/rds/mode/diskio.pm +++ b/cloud/aws/rds/mode/diskio.pm @@ -50,8 +50,8 @@ sub set_counters { output_template => $metric . ': %.2f %s/s', output_change_bytes => 1, perfdatas => [ - { label => lc($metric) . '_' . lc($statistic), value => $metric . '_' . $statistic . '_absolute', - template => '%.2f', unit => 'B/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => lc($metric) . '_' . lc($statistic), value => $metric . '_' . $statistic , + template => '%.2f', unit => 'B/s', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }; @@ -62,8 +62,8 @@ sub set_counters { key_values => [ { name => $metric . '_' . $statistic }, { name => 'display' }, { name => 'type' }, { name => 'stat' } ], output_template => $metric . ': %.2f iops', perfdatas => [ - { label => lc($metric) . '_' . lc($statistic), value => $metric . '_' . $statistic . '_absolute', - template => '%.2f', unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => lc($metric) . '_' . lc($statistic), value => $metric . '_' . $statistic , + template => '%.2f', unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }; @@ -74,8 +74,8 @@ sub set_counters { key_values => [ { name => $metric . '_' . $statistic }, { name => 'display' }, { name => 'type' }, { name => 'stat' } ], output_template => $metric . ': %.2f s', perfdatas => [ - { label => lc($metric) . '_' . lc($statistic), value => $metric . '_' . $statistic . '_absolute', - template => '%.2f', unit => 's', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => lc($metric) . '_' . lc($statistic), value => $metric . '_' . $statistic , + template => '%.2f', unit => 's', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }; @@ -86,8 +86,8 @@ sub set_counters { key_values => [ { name => $metric . '_' . $statistic }, { name => 'display' }, { name => 'type' }, { name => 'stat' } ], output_template => $metric . ': %d', perfdatas => [ - { label => lc($metric) . '_' . lc($statistic), value => $metric . '_' . $statistic . '_absolute', - template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => lc($metric) . '_' . lc($statistic), value => $metric . '_' . $statistic , + template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }; diff --git a/cloud/aws/rds/mode/instancestatus.pm b/cloud/aws/rds/mode/instancestatus.pm index e9bb8ced9..e2fc227a6 100644 --- a/cloud/aws/rds/mode/instancestatus.pm +++ b/cloud/aws/rds/mode/instancestatus.pm @@ -55,7 +55,7 @@ sub set_counters { key_values => [ { name => 'available' } ], output_template => "available : %s", perfdatas => [ - { label => 'total_available', value => 'available_absolute', template => '%d', min => 0 }, + { label => 'total_available', value => 'available', template => '%d', min => 0 }, ], } }, @@ -63,7 +63,7 @@ sub set_counters { key_values => [ { name => 'failed' } ], output_template => "failed : %s", perfdatas => [ - { label => 'total_failed', value => 'failed_absolute', template => '%d', min => 0 }, + { label => 'total_failed', value => 'failed', template => '%d', min => 0 }, ], } }, @@ -71,7 +71,7 @@ sub set_counters { key_values => [ { name => 'backing-up' } ], output_template => "backing-up : %s", perfdatas => [ - { label => 'total_backing_up', value => 'backing-up_absolute', template => '%d', min => 0 }, + { label => 'total_backing_up', value => 'backing-up', template => '%d', min => 0 }, ], } }, @@ -79,7 +79,7 @@ sub set_counters { key_values => [ { name => 'maintenance' } ], output_template => "maintenance : %s", perfdatas => [ - { label => 'total_maintenance', value => 'maintenance_absolute', template => '%d', min => 0 }, + { label => 'total_maintenance', value => 'maintenance', template => '%d', min => 0 }, ], } }, @@ -87,7 +87,7 @@ sub set_counters { key_values => [ { name => 'stopped' } ], output_template => "stopped : %s", perfdatas => [ - { label => 'total_stopped', value => 'stopped_absolute', template => '%d', min => 0 }, + { label => 'total_stopped', value => 'stopped', template => '%d', min => 0 }, ], } }, @@ -95,7 +95,7 @@ sub set_counters { key_values => [ { name => 'storage-full' } ], output_template => "storage-full : %s", perfdatas => [ - { label => 'total_storage_full', value => 'storage-full_absolute', template => '%d', min => 0 }, + { label => 'total_storage_full', value => 'storage-full', template => '%d', min => 0 }, ], } }, diff --git a/cloud/aws/rds/mode/network.pm b/cloud/aws/rds/mode/network.pm index 2c34935ef..0612c7096 100644 --- a/cloud/aws/rds/mode/network.pm +++ b/cloud/aws/rds/mode/network.pm @@ -50,8 +50,8 @@ sub set_counters { output_template => $metric . ': %.2f %s/s', output_change_bytes => 1, perfdatas => [ - { label => lc($metric) . '_' . lc($statistic), value => $metric . '_' . $statistic . '_absolute', - template => '%.2f', unit => 'B/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => lc($metric) . '_' . lc($statistic), value => $metric . '_' . $statistic , + template => '%.2f', unit => 'B/s', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }; diff --git a/cloud/aws/rds/mode/queries.pm b/cloud/aws/rds/mode/queries.pm index 6c8798d8b..dd4e9de2c 100644 --- a/cloud/aws/rds/mode/queries.pm +++ b/cloud/aws/rds/mode/queries.pm @@ -49,8 +49,8 @@ sub set_counters { key_values => [ { name => $metric . '_' . $statistic }, { name => 'display' }, { name => 'type' }, { name => 'stat' } ], output_template => $metric . ': %d queries/s', perfdatas => [ - { label => lc($metric) . '_' . lc($statistic), value => $metric . '_' . $statistic . '_absolute', - template => '%d', unit => 'queries/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => lc($metric) . '_' . lc($statistic), value => $metric . '_' . $statistic , + template => '%d', unit => 'queries/s', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }; @@ -61,8 +61,8 @@ sub set_counters { key_values => [ { name => $metric . '_' . $statistic }, { name => 'display' }, { name => 'type' }, { name => 'stat' } ], output_template => $metric . ': %.2f ms', perfdatas => [ - { label => lc($metric) . '_' . lc($statistic), value => $metric . '_' . $statistic . '_absolute', - template => '%.2f', unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => lc($metric) . '_' . lc($statistic), value => $metric . '_' . $statistic , + template => '%.2f', unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }; diff --git a/cloud/aws/rds/mode/transactions.pm b/cloud/aws/rds/mode/transactions.pm index a8cdd0b9a..d78956dfc 100644 --- a/cloud/aws/rds/mode/transactions.pm +++ b/cloud/aws/rds/mode/transactions.pm @@ -49,8 +49,8 @@ sub set_counters { key_values => [ { name => $metric . '_' . $statistic }, { name => 'display' }, { name => 'type' }, { name => 'stat' } ], output_template => $metric . ': %d ops', perfdatas => [ - { label => lc($metric) . '_' . lc($statistic), value => $metric . '_' . $statistic . '_absolute', - template => '%d', unit => 'ops', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => lc($metric) . '_' . lc($statistic), value => $metric . '_' . $statistic , + template => '%d', unit => 'ops', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }; @@ -61,8 +61,8 @@ sub set_counters { key_values => [ { name => $metric . '_' . $statistic }, { name => 'display' }, { name => 'type' }, { name => 'stat' } ], output_template => $metric . ': %.2f ms', perfdatas => [ - { label => lc($metric) . '_' . lc($statistic), value => $metric . '_' . $statistic . '_absolute', - template => '%.2f', unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => lc($metric) . '_' . lc($statistic), value => $metric . '_' . $statistic , + template => '%.2f', unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }; diff --git a/cloud/aws/rds/mode/volume.pm b/cloud/aws/rds/mode/volume.pm index e539019a0..dfe3e3214 100644 --- a/cloud/aws/rds/mode/volume.pm +++ b/cloud/aws/rds/mode/volume.pm @@ -98,8 +98,8 @@ sub set_counters { output_template => $metric . ': %.2f %s', output_change_bytes => 1, perfdatas => [ - { label => lc($metric) . '_' . lc($statistic), value => $metric . '_' . $statistic . '_absolute', - template => '%.2f', unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => lc($metric) . '_' . lc($statistic), value => $metric . '_' . $statistic , + template => '%.2f', unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }; diff --git a/cloud/aws/s3/mode/bucketsize.pm b/cloud/aws/s3/mode/bucketsize.pm index 2344ce552..ac679e550 100644 --- a/cloud/aws/s3/mode/bucketsize.pm +++ b/cloud/aws/s3/mode/bucketsize.pm @@ -46,8 +46,8 @@ sub set_counters { output_template => $metric . ': %d %s', output_change_bytes => 1, perfdatas => [ - { label => lc($metric) . '_' . lc($storage_type) . '_' . lc($statistic), value => $metric . '_' . $storage_type . '_' . $statistic . '_absolute', - template => '%d', unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => lc($metric) . '_' . lc($storage_type) . '_' . lc($statistic), value => $metric . '_' . $storage_type . '_' . $statistic , + template => '%d', unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }; diff --git a/cloud/aws/s3/mode/objects.pm b/cloud/aws/s3/mode/objects.pm index 46673f4d8..0912e66e5 100644 --- a/cloud/aws/s3/mode/objects.pm +++ b/cloud/aws/s3/mode/objects.pm @@ -44,8 +44,8 @@ sub set_counters { key_values => [ { name => $metric . '_' . $statistic }, { name => 'display' }, { name => 'stat' } ], output_template => $metric . ': %d objects', perfdatas => [ - { label => lc($metric) . '_' . lc($statistic), value => $metric . '_' . $statistic . '_absolute', - template => '%d', unit => 'objects', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => lc($metric) . '_' . lc($statistic), value => $metric . '_' . $statistic , + template => '%d', unit => 'objects', label_extra_instance => 1, instance_use => 'display' }, ], } }; diff --git a/cloud/aws/s3/mode/requests.pm b/cloud/aws/s3/mode/requests.pm index f6cfd7d0a..1c400b798 100644 --- a/cloud/aws/s3/mode/requests.pm +++ b/cloud/aws/s3/mode/requests.pm @@ -44,8 +44,8 @@ sub set_counters { key_values => [ { name => $metric . '_' . $statistic }, { name => 'display' }, { name => 'stat' } ], output_template => $metric . ': %d requests', perfdatas => [ - { label => lc($metric) . '_' . lc($statistic), value => $metric . '_' . $statistic . '_absolute', - template => '%d', unit => 'requests', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => lc($metric) . '_' . lc($statistic), value => $metric . '_' . $statistic , + template => '%d', unit => 'requests', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }; diff --git a/cloud/azure/compute/virtualmachine/mode/cpu.pm b/cloud/azure/compute/virtualmachine/mode/cpu.pm index d068f927e..b037eeadb 100644 --- a/cloud/azure/compute/virtualmachine/mode/cpu.pm +++ b/cloud/azure/compute/virtualmachine/mode/cpu.pm @@ -48,8 +48,8 @@ sub set_counters { key_values => [ { name => $metric_perf . '_' . $aggregation }, { name => 'display' }, { name => 'stat' } ], output_template => $metric . ': %.2f', perfdatas => [ - { label => $metric_perf . '_' . $aggregation, value => $metric_perf . '_' . $aggregation . '_absolute', - template => '%.2f', unit => 'credits', label_extra_instance => 1, instance_use => 'display_absolute', + { label => $metric_perf . '_' . $aggregation, value => $metric_perf . '_' . $aggregation , + template => '%.2f', unit => 'credits', label_extra_instance => 1, instance_use => 'display', min => 0 }, ], } @@ -65,8 +65,8 @@ sub set_counters { key_values => [ { name => $metric_perf . '_' . $aggregation }, { name => 'display' }, { name => 'stat' } ], output_template => $metric . ': %.2f %%', perfdatas => [ - { label => $metric_perf . '_' . $aggregation, value => $metric_perf . '_' . $aggregation . '_absolute', - template => '%.2f', unit => '%', label_extra_instance => 1, instance_use => 'display_absolute', + { label => $metric_perf . '_' . $aggregation, value => $metric_perf . '_' . $aggregation , + template => '%.2f', unit => '%', label_extra_instance => 1, instance_use => 'display', min => 0, max => 100 }, ], } diff --git a/cloud/azure/compute/virtualmachine/mode/vmsizes.pm b/cloud/azure/compute/virtualmachine/mode/vmsizes.pm index 2d4344d0f..afa3dd949 100644 --- a/cloud/azure/compute/virtualmachine/mode/vmsizes.pm +++ b/cloud/azure/compute/virtualmachine/mode/vmsizes.pm @@ -106,7 +106,7 @@ sub set_counters { key_values => [ { name => $size } ], output_template => $size . ": %s", perfdatas => [ - { label => $perf, value => $size . '_absolute', template => '%d', min => 0 }, + { label => $perf, value => $size , template => '%d', min => 0 }, ], } }; diff --git a/cloud/azure/compute/virtualmachine/mode/vmsstate.pm b/cloud/azure/compute/virtualmachine/mode/vmsstate.pm index 082ec453f..6722e2036 100644 --- a/cloud/azure/compute/virtualmachine/mode/vmsstate.pm +++ b/cloud/azure/compute/virtualmachine/mode/vmsstate.pm @@ -66,7 +66,7 @@ sub set_counters { key_values => [ { name => 'running' } ], output_template => "running : %s", perfdatas => [ - { label => 'total_running', value => 'running_absolute', template => '%d', min => 0 }, + { label => 'total_running', value => 'running', template => '%d', min => 0 }, ], } }, @@ -74,7 +74,7 @@ sub set_counters { key_values => [ { name => 'stopped' } ], output_template => "stopped : %s", perfdatas => [ - { label => 'total_stopped', value => 'stopped_absolute', template => '%d', min => 0 }, + { label => 'total_stopped', value => 'stopped', template => '%d', min => 0 }, ], } }, diff --git a/cloud/azure/database/sqldatabase/mode/databasesize.pm b/cloud/azure/database/sqldatabase/mode/databasesize.pm index 5026c67b6..36e0668d0 100644 --- a/cloud/azure/database/sqldatabase/mode/databasesize.pm +++ b/cloud/azure/database/sqldatabase/mode/databasesize.pm @@ -48,8 +48,8 @@ sub set_counters { key_values => [ { name => $metric_perf . '_' . $aggregation }, { name => 'display' }, { name => 'stat' } ], output_template => 'Database size percentage: %.2f %%', perfdatas => [ - { label => $metric_perf . '_' . $aggregation, value => $metric_perf . '_' . $aggregation . '_absolute', - template => '%.2f', unit => '%', label_extra_instance => 1, instance_use => 'display_absolute', + { label => $metric_perf . '_' . $aggregation, value => $metric_perf . '_' . $aggregation , + template => '%.2f', unit => '%', label_extra_instance => 1, instance_use => 'display', min => 0, max => 100 }, ], } diff --git a/cloud/azure/management/monitor/mode/alert.pm b/cloud/azure/management/monitor/mode/alert.pm index 18aeddbfc..addeb7fed 100644 --- a/cloud/azure/management/monitor/mode/alert.pm +++ b/cloud/azure/management/monitor/mode/alert.pm @@ -30,8 +30,8 @@ sub custom_output { return sprintf( "alert severity: '%s', Count: '%d'", - $self->{result_values}->{severity_absolute}, - $self->{result_values}->{count_absolute} + $self->{result_values}->{severity}, + $self->{result_values}->{count} ); } @@ -39,8 +39,8 @@ sub custom_perfdata { my ($self, %options) = @_; $self->{output}->perfdata_add( - nlabel => 'alerts.' . lc($self->{result_values}->{severity_absolute}) . '.count', - value => $self->{result_values}->{count_absolute}, + nlabel => 'alerts.' . lc($self->{result_values}->{severity}) . '.count', + value => $self->{result_values}->{count}, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}) ); @@ -57,7 +57,7 @@ sub set_counters { { label => 'count', set => { key_values => [ { name => 'severity' }, { name => 'count' } ], closure_custom_output => $self->can('custom_output'), - threshold_use => 'count_absolute', + threshold_use => 'count', closure_custom_perfdata => $self->can('custom_perfdata'), } }, diff --git a/cloud/azure/management/monitor/mode/logs.pm b/cloud/azure/management/monitor/mode/logs.pm index f238c4b81..52ab7ef4c 100644 --- a/cloud/azure/management/monitor/mode/logs.pm +++ b/cloud/azure/management/monitor/mode/logs.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'total' } ], output_template => 'total logs: %s', perfdatas => [ - { value => 'total_absolute', template => '%s', min => 0 } + { value => 'total', template => '%s', min => 0 } ] } } diff --git a/cloud/azure/management/recovery/mode/backupitemsstatus.pm b/cloud/azure/management/recovery/mode/backupitemsstatus.pm index c3960b30f..59d896bdd 100644 --- a/cloud/azure/management/recovery/mode/backupitemsstatus.pm +++ b/cloud/azure/management/recovery/mode/backupitemsstatus.pm @@ -70,7 +70,7 @@ sub set_counters { key_values => [ { name => 'completed' } ], output_template => "completed : %s", perfdatas => [ - { label => 'total_completed', value => 'completed_absolute', template => '%d', min => 0 } + { label => 'total_completed', value => 'completed', template => '%d', min => 0 } ] } }, @@ -78,7 +78,7 @@ sub set_counters { key_values => [ { name => 'failed' } ], output_template => "failed : %s", perfdatas => [ - { label => 'total_failed', value => 'failed_absolute', template => '%d', min => 0 } + { label => 'total_failed', value => 'failed', template => '%d', min => 0 } ] } } diff --git a/cloud/azure/management/recovery/mode/backupjobsstatus.pm b/cloud/azure/management/recovery/mode/backupjobsstatus.pm index 5e1d778a1..f80a36518 100644 --- a/cloud/azure/management/recovery/mode/backupjobsstatus.pm +++ b/cloud/azure/management/recovery/mode/backupjobsstatus.pm @@ -68,7 +68,7 @@ sub set_counters { key_values => [ { name => 'completed' } ], output_template => "completed : %s", perfdatas => [ - { label => 'total_completed', value => 'completed_absolute', template => '%d', min => 0 }, + { label => 'total_completed', value => 'completed', template => '%d', min => 0 }, ], } }, @@ -76,7 +76,7 @@ sub set_counters { key_values => [ { name => 'failed' } ], output_template => "failed : %s", perfdatas => [ - { label => 'total_failed', value => 'failed_absolute', template => '%d', min => 0 }, + { label => 'total_failed', value => 'failed', template => '%d', min => 0 }, ], } }, @@ -84,7 +84,7 @@ sub set_counters { key_values => [ { name => 'inprogress' } ], output_template => "in progress : %s", perfdatas => [ - { label => 'total_inprogress', value => 'inprogress_absolute', template => '%d', min => 0 }, + { label => 'total_inprogress', value => 'inprogress', template => '%d', min => 0 }, ], } }, diff --git a/cloud/azure/management/resource/mode/deploymentsstatus.pm b/cloud/azure/management/resource/mode/deploymentsstatus.pm index ae3b4da26..79e0ef70d 100644 --- a/cloud/azure/management/resource/mode/deploymentsstatus.pm +++ b/cloud/azure/management/resource/mode/deploymentsstatus.pm @@ -70,7 +70,7 @@ sub set_counters { key_values => [ { name => 'succeeded' } ], output_template => "succeeded : %s", perfdatas => [ - { label => 'total_succeeded', value => 'succeeded_absolute', template => '%d', min => 0 }, + { label => 'total_succeeded', value => 'succeeded', template => '%d', min => 0 }, ], } }, @@ -78,7 +78,7 @@ sub set_counters { key_values => [ { name => 'failed' } ], output_template => "failed : %s", perfdatas => [ - { label => 'total_failed', value => 'failed_absolute', template => '%d', min => 0 }, + { label => 'total_failed', value => 'failed', template => '%d', min => 0 }, ], } }, diff --git a/cloud/azure/management/resource/mode/items.pm b/cloud/azure/management/resource/mode/items.pm index 68c84bbde..18985917a 100644 --- a/cloud/azure/management/resource/mode/items.pm +++ b/cloud/azure/management/resource/mode/items.pm @@ -43,8 +43,8 @@ sub set_counters { key_values => [ { name => 'total' } , { name => 'display' } ], output_template => "Total number of items : %s", perfdatas => [ - { label => 'total', value => 'total_absolute', template => '%d', - label_extra_instance => 1, instance_use => 'display_absolute', min => 0 }, + { label => 'total', value => 'total', template => '%d', + label_extra_instance => 1, instance_use => 'display', min => 0 }, ], } }, @@ -52,8 +52,8 @@ sub set_counters { key_values => [ { name => 'compute' } , { name => 'display' } ], output_template => "Compute: %s", perfdatas => [ - { label => 'compute', value => 'compute_absolute', template => '%d', - label_extra_instance => 1, instance_use => 'display_absolute', min => 0 }, + { label => 'compute', value => 'compute', template => '%d', + label_extra_instance => 1, instance_use => 'display', min => 0 }, ], } }, @@ -61,8 +61,8 @@ sub set_counters { key_values => [ { name => 'storage' } , { name => 'display' } ], output_template => "Storage: %s", perfdatas => [ - { label => 'storage', value => 'storage_absolute', template => '%d', - label_extra_instance => 1, instance_use => 'display_absolute', min => 0 }, + { label => 'storage', value => 'storage', template => '%d', + label_extra_instance => 1, instance_use => 'display', min => 0 }, ], } }, @@ -70,8 +70,8 @@ sub set_counters { key_values => [ { name => 'network' } , { name => 'display' } ], output_template => "Network: %s", perfdatas => [ - { label => 'network', value => 'network_absolute', template => '%d', - label_extra_instance => 1, instance_use => 'display_absolute', min => 0 }, + { label => 'network', value => 'network', template => '%d', + label_extra_instance => 1, instance_use => 'display', min => 0 }, ], } }, diff --git a/cloud/azure/network/vpngateway/mode/sitetraffic.pm b/cloud/azure/network/vpngateway/mode/sitetraffic.pm index e86d38c71..c706f3fca 100644 --- a/cloud/azure/network/vpngateway/mode/sitetraffic.pm +++ b/cloud/azure/network/vpngateway/mode/sitetraffic.pm @@ -114,8 +114,8 @@ sub set_counters { { name => $metric_perf . '_' . $aggregation . '_name' }, { name => 'stat' } ], output_template => 'P2S Connection Count: %d', perfdatas => [ - { label => $metric_perf . '_' . $aggregation, value => $metric_perf . '_' . $aggregation . '_absolute', - template => '%d', label_extra_instance => 1, instance_use => 'display_absolute', + { label => $metric_perf . '_' . $aggregation, value => $metric_perf . '_' . $aggregation , + template => '%d', label_extra_instance => 1, instance_use => 'display', min => 0 }, ], } diff --git a/cloud/azure/storage/storageaccount/mode/accountusedcapacity.pm b/cloud/azure/storage/storageaccount/mode/accountusedcapacity.pm index bc8f2b9c2..4a130da00 100644 --- a/cloud/azure/storage/storageaccount/mode/accountusedcapacity.pm +++ b/cloud/azure/storage/storageaccount/mode/accountusedcapacity.pm @@ -46,8 +46,8 @@ sub set_counters { output_template => $metric . ': %s %s', output_change_bytes => 1, perfdatas => [ - { label => $metric_label . '_' . $aggregation, value => $metric_label . '_' . $aggregation . '_absolute', - template => '%s', unit => 'B', label_extra_instance => 1, instance_use => 'display_absolute', + { label => $metric_label . '_' . $aggregation, value => $metric_label . '_' . $aggregation , + template => '%s', unit => 'B', label_extra_instance => 1, instance_use => 'display', min => 0 }, ], } diff --git a/cloud/azure/storage/storageaccount/mode/blobcapacity.pm b/cloud/azure/storage/storageaccount/mode/blobcapacity.pm index 607c7f1a3..46c25e2ee 100644 --- a/cloud/azure/storage/storageaccount/mode/blobcapacity.pm +++ b/cloud/azure/storage/storageaccount/mode/blobcapacity.pm @@ -46,8 +46,8 @@ sub set_counters { output_template => $metric . ': %s %s', output_change_bytes => 1, perfdatas => [ - { label => $metric_label . '_' . $aggregation, value => $metric_label . '_' . $aggregation . '_absolute', - template => '%s', unit => 'B', label_extra_instance => 1, instance_use => 'display_absolute', + { label => $metric_label . '_' . $aggregation, value => $metric_label . '_' . $aggregation , + template => '%s', unit => 'B', label_extra_instance => 1, instance_use => 'display', min => 0 }, ], } diff --git a/cloud/azure/storage/storageaccount/mode/blobcontainercount.pm b/cloud/azure/storage/storageaccount/mode/blobcontainercount.pm index 5d2c5f4cd..9050beeec 100644 --- a/cloud/azure/storage/storageaccount/mode/blobcontainercount.pm +++ b/cloud/azure/storage/storageaccount/mode/blobcontainercount.pm @@ -45,8 +45,8 @@ sub set_counters { key_values => [ { name => $metric_label . '_' . $aggregation }, { name => 'display' }, { name => 'stat' } ], output_template => $metric . ': %s', perfdatas => [ - { label => $metric_label . '_' . $aggregation, value => $metric_label . '_' . $aggregation . '_absolute', - template => '%s', label_extra_instance => 1, instance_use => 'display_absolute', + { label => $metric_label . '_' . $aggregation, value => $metric_label . '_' . $aggregation , + template => '%s', label_extra_instance => 1, instance_use => 'display', min => 0 }, ], } diff --git a/cloud/azure/storage/storageaccount/mode/blobcount.pm b/cloud/azure/storage/storageaccount/mode/blobcount.pm index 56a18b1f3..223b94c32 100644 --- a/cloud/azure/storage/storageaccount/mode/blobcount.pm +++ b/cloud/azure/storage/storageaccount/mode/blobcount.pm @@ -45,8 +45,8 @@ sub set_counters { key_values => [ { name => $metric_label . '_' . $aggregation }, { name => 'display' }, { name => 'stat' } ], output_template => $metric . ': %s', perfdatas => [ - { label => $metric_label . '_' . $aggregation, value => $metric_label . '_' . $aggregation . '_absolute', - template => '%s', label_extra_instance => 1, instance_use => 'display_absolute', + { label => $metric_label . '_' . $aggregation, value => $metric_label . '_' . $aggregation , + template => '%s', label_extra_instance => 1, instance_use => 'display', min => 0 }, ], } diff --git a/cloud/azure/storage/storageaccount/mode/filecapacity.pm b/cloud/azure/storage/storageaccount/mode/filecapacity.pm index a47624e6c..d926550ad 100644 --- a/cloud/azure/storage/storageaccount/mode/filecapacity.pm +++ b/cloud/azure/storage/storageaccount/mode/filecapacity.pm @@ -46,8 +46,8 @@ sub set_counters { output_template => $metric . ': %s %s', output_change_bytes => 1, perfdatas => [ - { label => $metric_label . '_' . $aggregation, value => $metric_label . '_' . $aggregation . '_absolute', - template => '%s', unit => 'B', label_extra_instance => 1, instance_use => 'display_absolute', + { label => $metric_label . '_' . $aggregation, value => $metric_label . '_' . $aggregation , + template => '%s', unit => 'B', label_extra_instance => 1, instance_use => 'display', min => 0 }, ], } diff --git a/cloud/azure/storage/storageaccount/mode/filecount.pm b/cloud/azure/storage/storageaccount/mode/filecount.pm index 9094e53ab..bc4461753 100644 --- a/cloud/azure/storage/storageaccount/mode/filecount.pm +++ b/cloud/azure/storage/storageaccount/mode/filecount.pm @@ -45,8 +45,8 @@ sub set_counters { key_values => [ { name => $metric_label . '_' . $aggregation }, { name => 'display' }, { name => 'stat' } ], output_template => $metric . ': %s', perfdatas => [ - { label => $metric_label . '_' . $aggregation, value => $metric_label . '_' . $aggregation . '_absolute', - template => '%s', label_extra_instance => 1, instance_use => 'display_absolute', + { label => $metric_label . '_' . $aggregation, value => $metric_label . '_' . $aggregation , + template => '%s', label_extra_instance => 1, instance_use => 'display', min => 0 }, ], } diff --git a/cloud/azure/storage/storageaccount/mode/filesharecount.pm b/cloud/azure/storage/storageaccount/mode/filesharecount.pm index 13af6a010..069ad7777 100644 --- a/cloud/azure/storage/storageaccount/mode/filesharecount.pm +++ b/cloud/azure/storage/storageaccount/mode/filesharecount.pm @@ -45,8 +45,8 @@ sub set_counters { key_values => [ { name => $metric_label . '_' . $aggregation }, { name => 'display' }, { name => 'stat' } ], output_template => $metric . ': %s', perfdatas => [ - { label => $metric_label . '_' . $aggregation, value => $metric_label . '_' . $aggregation . '_absolute', - template => '%s', label_extra_instance => 1, instance_use => 'display_absolute', + { label => $metric_label . '_' . $aggregation, value => $metric_label . '_' . $aggregation , + template => '%s', label_extra_instance => 1, instance_use => 'display', min => 0 }, ], } diff --git a/cloud/azure/storage/storageaccount/mode/queuecapacity.pm b/cloud/azure/storage/storageaccount/mode/queuecapacity.pm index 080b70ce4..ae484fc81 100644 --- a/cloud/azure/storage/storageaccount/mode/queuecapacity.pm +++ b/cloud/azure/storage/storageaccount/mode/queuecapacity.pm @@ -46,8 +46,8 @@ sub set_counters { output_template => $metric . ': %s %s', output_change_bytes => 1, perfdatas => [ - { label => $metric_label . '_' . $aggregation, value => $metric_label . '_' . $aggregation . '_absolute', - template => '%s', unit => 'B', label_extra_instance => 1, instance_use => 'display_absolute', + { label => $metric_label . '_' . $aggregation, value => $metric_label . '_' . $aggregation , + template => '%s', unit => 'B', label_extra_instance => 1, instance_use => 'display', min => 0 }, ], } diff --git a/cloud/azure/storage/storageaccount/mode/queuecount.pm b/cloud/azure/storage/storageaccount/mode/queuecount.pm index d6424f226..02286d1d1 100644 --- a/cloud/azure/storage/storageaccount/mode/queuecount.pm +++ b/cloud/azure/storage/storageaccount/mode/queuecount.pm @@ -45,8 +45,8 @@ sub set_counters { key_values => [ { name => $metric_label . '_' . $aggregation }, { name => 'display' }, { name => 'stat' } ], output_template => $metric . ': %s', perfdatas => [ - { label => $metric_label . '_' . $aggregation, value => $metric_label . '_' . $aggregation . '_absolute', - template => '%s', label_extra_instance => 1, instance_use => 'display_absolute', + { label => $metric_label . '_' . $aggregation, value => $metric_label . '_' . $aggregation , + template => '%s', label_extra_instance => 1, instance_use => 'display', min => 0 }, ], } diff --git a/cloud/azure/storage/storageaccount/mode/queuemessagecount.pm b/cloud/azure/storage/storageaccount/mode/queuemessagecount.pm index d5ea43dc7..ac17264cd 100644 --- a/cloud/azure/storage/storageaccount/mode/queuemessagecount.pm +++ b/cloud/azure/storage/storageaccount/mode/queuemessagecount.pm @@ -45,8 +45,8 @@ sub set_counters { key_values => [ { name => $metric_label . '_' . $aggregation }, { name => 'display' }, { name => 'stat' } ], output_template => $metric . ': %s', perfdatas => [ - { label => $metric_label . '_' . $aggregation, value => $metric_label . '_' . $aggregation . '_absolute', - template => '%s', label_extra_instance => 1, instance_use => 'display_absolute', + { label => $metric_label . '_' . $aggregation, value => $metric_label . '_' . $aggregation , + template => '%s', label_extra_instance => 1, instance_use => 'display', min => 0 }, ], } diff --git a/cloud/azure/storage/storageaccount/mode/tablecapacity.pm b/cloud/azure/storage/storageaccount/mode/tablecapacity.pm index 7d9ce5b38..5c8309597 100644 --- a/cloud/azure/storage/storageaccount/mode/tablecapacity.pm +++ b/cloud/azure/storage/storageaccount/mode/tablecapacity.pm @@ -46,8 +46,8 @@ sub set_counters { output_template => $metric . ': %s %s', output_change_bytes => 1, perfdatas => [ - { label => $metric_label . '_' . $aggregation, value => $metric_label . '_' . $aggregation . '_absolute', - template => '%s', unit => 'B', label_extra_instance => 1, instance_use => 'display_absolute', + { label => $metric_label . '_' . $aggregation, value => $metric_label . '_' . $aggregation , + template => '%s', unit => 'B', label_extra_instance => 1, instance_use => 'display', min => 0 }, ], } diff --git a/cloud/azure/storage/storageaccount/mode/tablecount.pm b/cloud/azure/storage/storageaccount/mode/tablecount.pm index 7ee41e1c9..5093396c8 100644 --- a/cloud/azure/storage/storageaccount/mode/tablecount.pm +++ b/cloud/azure/storage/storageaccount/mode/tablecount.pm @@ -45,8 +45,8 @@ sub set_counters { key_values => [ { name => $metric_label . '_' . $aggregation }, { name => 'display' }, { name => 'stat' } ], output_template => $metric . ': %s', perfdatas => [ - { label => $metric_label . '_' . $aggregation, value => $metric_label . '_' . $aggregation . '_absolute', - template => '%s', label_extra_instance => 1, instance_use => 'display_absolute', + { label => $metric_label . '_' . $aggregation, value => $metric_label . '_' . $aggregation , + template => '%s', label_extra_instance => 1, instance_use => 'display', min => 0 }, ], } diff --git a/cloud/azure/storage/storageaccount/mode/tableentitycount.pm b/cloud/azure/storage/storageaccount/mode/tableentitycount.pm index b9d62f697..09a87c7ef 100644 --- a/cloud/azure/storage/storageaccount/mode/tableentitycount.pm +++ b/cloud/azure/storage/storageaccount/mode/tableentitycount.pm @@ -45,8 +45,8 @@ sub set_counters { key_values => [ { name => $metric_label . '_' . $aggregation }, { name => 'display' }, { name => 'stat' } ], output_template => $metric . ': %s', perfdatas => [ - { label => $metric_label . '_' . $aggregation, value => $metric_label . '_' . $aggregation . '_absolute', - template => '%s', label_extra_instance => 1, instance_use => 'display_absolute', + { label => $metric_label . '_' . $aggregation, value => $metric_label . '_' . $aggregation , + template => '%s', label_extra_instance => 1, instance_use => 'display', min => 0 }, ], } diff --git a/cloud/azure/storage/storageaccount/mode/transactionsavailability.pm b/cloud/azure/storage/storageaccount/mode/transactionsavailability.pm index 71eb5e517..5fcf230c4 100644 --- a/cloud/azure/storage/storageaccount/mode/transactionsavailability.pm +++ b/cloud/azure/storage/storageaccount/mode/transactionsavailability.pm @@ -49,8 +49,8 @@ sub set_counters { key_values => [ { name => $metric_label . '_' . $aggregation }, { name => 'display' }, { name => 'stat' } ], output_template => $metric . ': %.2f %%', perfdatas => [ - { label => $metric_label . '_' . $aggregation, value => $metric_label . '_' . $aggregation . '_absolute', - template => '%.2f', label_extra_instance => 1, instance_use => 'display_absolute', + { label => $metric_label . '_' . $aggregation, value => $metric_label . '_' . $aggregation , + template => '%.2f', label_extra_instance => 1, instance_use => 'display', unit => '%', min => 0, max => 100 }, ], } diff --git a/cloud/azure/storage/storageaccount/mode/transactionslatency.pm b/cloud/azure/storage/storageaccount/mode/transactionslatency.pm index 11803fa58..d00778878 100644 --- a/cloud/azure/storage/storageaccount/mode/transactionslatency.pm +++ b/cloud/azure/storage/storageaccount/mode/transactionslatency.pm @@ -49,8 +49,8 @@ sub set_counters { key_values => [ { name => $metric_label . '_' . $aggregation }, { name => 'display' }, { name => 'stat' } ], output_template => $metric . ': %.2f ms', perfdatas => [ - { label => $metric_label . '_' . $aggregation, value => $metric_label . '_' . $aggregation . '_absolute', - template => '%.2f', unit => 'ms', label_extra_instance => 1, instance_use => 'display_absolute', + { label => $metric_label . '_' . $aggregation, value => $metric_label . '_' . $aggregation , + template => '%.2f', unit => 'ms', label_extra_instance => 1, instance_use => 'display', min => 0 }, ], } diff --git a/cloud/cadvisor/restapi/mode/containerusage.pm b/cloud/cadvisor/restapi/mode/containerusage.pm index f18382280..eeaf7acb3 100644 --- a/cloud/cadvisor/restapi/mode/containerusage.pm +++ b/cloud/cadvisor/restapi/mode/containerusage.pm @@ -29,10 +29,10 @@ use DateTime; sub custom_memory_output { my ($self, %options) = @_; - my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{memory_total_absolute}); - my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{memory_used_absolute}); + my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{memory_total}); + my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{memory_used}); my $msg = sprintf("Memory Used: %s (%.2f%%) Total: %s" , - $total_used_value . " " . $total_used_unit, 100 * $self->{result_values}->{memory_used_absolute} / $self->{result_values}->{memory_total_absolute}, + $total_used_value . " " . $total_used_unit, 100 * $self->{result_values}->{memory_used} / $self->{result_values}->{memory_total}, $total_size_value . " " . $total_size_unit); return $msg; } @@ -48,40 +48,40 @@ sub set_counters { { label => 'cpu-number', set => { key_values => [ { name => 'cpu_number'}, { name => 'display' } ], output_template => 'CPU: %d core(s)', - output_use => 'cpu_number_absolute', + output_use => 'cpu_number', perfdatas => [ - { label => 'cpu_number', value => 'cpu_number_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'cpu_number', value => 'cpu_number', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'cpu-total', set => { key_values => [ { name => 'cpu_total'}, { name => 'display' } ], output_template => 'CPU Usage: %.2f %%', - output_use => 'cpu_total_absolute', + output_use => 'cpu_total', perfdatas => [ - { label => 'cpu_total', value => 'cpu_total_absolute', template => '%.2f', - unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'cpu_total', value => 'cpu_total', template => '%.2f', + unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'cpu-user', set => { key_values => [ { name => 'cpu_user'}, { name => 'display' } ], output_template => 'CPU User: %.2f %%', - output_use => 'cpu_user_absolute', + output_use => 'cpu_user', perfdatas => [ - { label => 'cpu_user', value => 'cpu_user_absolute', template => '%.2f', - unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'cpu_user', value => 'cpu_user', template => '%.2f', + unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'cpu-system', set => { key_values => [ { name => 'cpu_system' }, { name => 'display' } ], output_template => 'CPU System: %.2f %%', - output_use => 'cpu_system_absolute', + output_use => 'cpu_system', perfdatas => [ - { label => 'cpu_system', value => 'cpu_system_absolute', template => '%.2f', - unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'cpu_system', value => 'cpu_system', template => '%.2f', + unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -90,8 +90,8 @@ sub set_counters { output_change_bytes => 1, closure_custom_output => $self->can('custom_memory_output'), perfdatas => [ - { label => 'memory_used', value => 'memory_used_absolute', template => '%s', - min => 0, max => 'memory_total_absolute',unit => 'B', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'memory_used', value => 'memory_used', template => '%s', + min => 0, max => 'memory_total',unit => 'B', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -100,8 +100,8 @@ sub set_counters { output_change_bytes => 1, output_template => 'Memory Cache: %s %s', perfdatas => [ - { label => 'memory_cache', value => 'memory_cache_absolute', template => '%s', - min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'memory_cache', value => 'memory_cache', template => '%s', + min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -110,8 +110,8 @@ sub set_counters { output_change_bytes => 1, output_template => 'Memory RSS: %s %s', perfdatas => [ - { label => 'memory_rss', value => 'memory_rss_absolute', template => '%s', - min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'memory_rss', value => 'memory_rss', template => '%s', + min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -120,8 +120,8 @@ sub set_counters { output_change_bytes => 1, output_template => 'Swap: %s %s', perfdatas => [ - { label => 'swap', value => 'swap_absolute', template => '%s', - min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'swap', value => 'swap', template => '%s', + min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/cloud/cadvisor/restapi/mode/diskio.pm b/cloud/cadvisor/restapi/mode/diskio.pm index 84085d28f..568a57bf8 100644 --- a/cloud/cadvisor/restapi/mode/diskio.pm +++ b/cloud/cadvisor/restapi/mode/diskio.pm @@ -39,8 +39,8 @@ sub set_counters { output_change_bytes => 1, output_template => 'Disk IO Read: %s %s/s', perfdatas => [ - { label => 'diskio_read', value => 'diskio_read_absolute', template => '%.2f', - min => 0, unit => 'B/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'diskio_read', value => 'diskio_read', template => '%.2f', + min => 0, unit => 'B/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -49,8 +49,8 @@ sub set_counters { output_change_bytes => 1, output_template => 'Disk IO Write: %s %s/s', perfdatas => [ - { label => 'diskio_write', value => 'diskio_write_absolute', template => '%.2f', - min => 0, unit => 'B/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'diskio_write', value => 'diskio_write', template => '%.2f', + min => 0, unit => 'B/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/cloud/cadvisor/restapi/mode/nodestatus.pm b/cloud/cadvisor/restapi/mode/nodestatus.pm index 5ed9d1dc3..12d715bb9 100644 --- a/cloud/cadvisor/restapi/mode/nodestatus.pm +++ b/cloud/cadvisor/restapi/mode/nodestatus.pm @@ -47,8 +47,8 @@ sub set_counters { key_values => [ { name => 'containers_running' }, { name => 'display' } ], output_template => 'Containers Running : %s', perfdatas => [ - { label => 'containers_running', value => 'containers_running_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'containers_running', value => 'containers_running', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -56,8 +56,8 @@ sub set_counters { key_values => [ { name => 'num_cores' }, { name => 'display' } ], output_template => 'CPU cores: %s', perfdatas => [ - { label => 'num_cores', value => 'num_cores_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'num_cores', value => 'num_cores', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -65,8 +65,8 @@ sub set_counters { key_values => [ { name => 'memory_capacity' }, { name => 'display' } ], output_template => 'Mem capacity %s %s', perfdatas => [ - { label => 'memory_capacity', value => 'memory_capacity_absolute', unit => 'B', output_change_bytes => 1, template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'memory_capacity', value => 'memory_capacity', unit => 'B', output_change_bytes => 1, template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -74,8 +74,8 @@ sub set_counters { key_values => [ { name => 'cpu_frequency' }, { name => 'display' } ], output_template => 'CPU frequency %s %s', perfdatas => [ - { label => 'cpu_frequency', value => 'cpu_frequency_absolute', unit => 'Hz', output_change_bytes => 1, template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'cpu_frequency', value => 'cpu_frequency', unit => 'Hz', output_change_bytes => 1, template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/cloud/cadvisor/restapi/mode/traffic.pm b/cloud/cadvisor/restapi/mode/traffic.pm index f303bf84d..603da6967 100644 --- a/cloud/cadvisor/restapi/mode/traffic.pm +++ b/cloud/cadvisor/restapi/mode/traffic.pm @@ -40,8 +40,8 @@ sub set_counters { output_change_bytes => 2, output_template => 'Traffic In: %s %s/s', perfdatas => [ - { label => 'traffic_in', value => 'traffic_in_absolute', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_in', value => 'traffic_in', template => '%.2f', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -50,8 +50,8 @@ sub set_counters { output_change_bytes => 2, output_template => 'Traffic Out: %s %s/s', perfdatas => [ - { label => 'traffic_out', value => 'traffic_out_absolute', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_out', value => 'traffic_out', template => '%.2f', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/cloud/cloudfoundry/restapi/mode/appsstate.pm b/cloud/cloudfoundry/restapi/mode/appsstate.pm index 8ea16b612..3f02fdc0b 100644 --- a/cloud/cloudfoundry/restapi/mode/appsstate.pm +++ b/cloud/cloudfoundry/restapi/mode/appsstate.pm @@ -61,7 +61,7 @@ sub set_counters { key_values => [ { name => 'started' } ], output_template => 'Started : %d', perfdatas => [ - { label => 'started', value => 'started_absolute', template => '%d', + { label => 'started', value => 'started', template => '%d', min => 0 }, ], } @@ -70,7 +70,7 @@ sub set_counters { key_values => [ { name => 'stopped' } ], output_template => 'Stopped : %d', perfdatas => [ - { label => 'stopped', value => 'stopped_absolute', template => '%d', + { label => 'stopped', value => 'stopped', template => '%d', min => 0 }, ], } diff --git a/cloud/cloudfoundry/restapi/mode/instancesstate.pm b/cloud/cloudfoundry/restapi/mode/instancesstate.pm index b5f4bfa8f..5091b6d93 100644 --- a/cloud/cloudfoundry/restapi/mode/instancesstate.pm +++ b/cloud/cloudfoundry/restapi/mode/instancesstate.pm @@ -137,7 +137,7 @@ sub set_counters { key_values => [ { name => 'running' } ], output_template => 'Running : %d', perfdatas => [ - { label => 'running', value => 'running_absolute', template => '%d', + { label => 'running', value => 'running', template => '%d', min => 0 }, ], } @@ -146,7 +146,7 @@ sub set_counters { key_values => [ { name => 'stopped' } ], output_template => 'Stopped : %d', perfdatas => [ - { label => 'stopped', value => 'stopped_absolute', template => '%d', + { label => 'stopped', value => 'stopped', template => '%d', min => 0 }, ], } @@ -155,7 +155,7 @@ sub set_counters { key_values => [ { name => 'crashed' } ], output_template => 'Crashed : %d', perfdatas => [ - { label => 'crashed', value => 'crashed_absolute', template => '%d', + { label => 'crashed', value => 'crashed', template => '%d', min => 0 }, ], } diff --git a/cloud/docker/restapi/mode/containerusage.pm b/cloud/docker/restapi/mode/containerusage.pm index 616d85581..7f4c9260a 100644 --- a/cloud/docker/restapi/mode/containerusage.pm +++ b/cloud/docker/restapi/mode/containerusage.pm @@ -138,22 +138,20 @@ sub set_counters { } }, { label => 'read-iops', set => { - key_values => [ { name => 'read_io', diff => 1 }, { name => 'display' } ], - per_second => 1, + key_values => [ { name => 'read_io', per_second => 1 }, { name => 'display' } ], output_template => 'Read IOPs : %.2f', output_error_template => "Read IOPs : %s", perfdatas => [ - { label => 'read_iops', value => 'read_io_per_second', template => '%.2f', - unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'read_iops', template => '%.2f', + unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'write-iops', set => { - key_values => [ { name => 'write_io', diff => 1 }, { name => 'display' } ], - per_second => 1, + key_values => [ { name => 'write_io', per_second => 1 }, { name => 'display' } ], output_template => 'Write IOPs : %.2f', output_error_template => "Write IOPs : %s", perfdatas => [ - { label => 'write_iops', value => 'write_io_per_second', template => '%.2f', - unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'write_iops', template => '%.2f', + unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -161,22 +159,22 @@ sub set_counters { $self->{maps_counters}->{containers_traffic} = [ { label => 'traffic-in', set => { - key_values => [ { name => 'traffic_in', diff => 1 }, { name => 'display' } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'traffic_in', per_second => 1 }, { name => 'display' } ], + output_change_bytes => 2, output_template => 'Traffic In : %s %s/s', perfdatas => [ - { label => 'traffic_in', value => 'traffic_in_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_in', template => '%.2f', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'traffic-out', set => { - key_values => [ { name => 'traffic_out', diff => 1 }, { name => 'display' } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'traffic_out', per_second => 1 }, { name => 'display' } ], + output_change_bytes => 2, output_template => 'Traffic Out : %s %s/s', perfdatas => [ - { label => 'traffic_out', value => 'traffic_out_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_out', template => '%.2f', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -188,15 +186,14 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; - $options{options}->add_options(arguments => - { - "container-id:s" => { name => 'container_id' }, - "container-name:s" => { name => 'container_name' }, - "filter-name:s" => { name => 'filter_name' }, - "use-name" => { name => 'use_name' }, - "warning-container-status:s" => { name => 'warning_container_status', default => '' }, - "critical-container-status:s" => { name => 'critical_container_status', default => '' }, - }); + $options{options}->add_options(arguments => { + 'container-id:s' => { name => 'container_id' }, + 'container-name:s' => { name => 'container_name' }, + 'filter-name:s' => { name => 'filter_name' }, + 'use-name' => { name => 'use_name' }, + 'warning-container-status:s' => { name => 'warning_container_status', default => '' }, + 'critical-container-status:s' => { name => 'critical_container_status', default => '' }, + }); $self->{statefile_cache_containers} = centreon::plugins::statefile->new(%options); return $self; diff --git a/cloud/docker/restapi/mode/nodestatus.pm b/cloud/docker/restapi/mode/nodestatus.pm index 985ce21f4..0320818da 100644 --- a/cloud/docker/restapi/mode/nodestatus.pm +++ b/cloud/docker/restapi/mode/nodestatus.pm @@ -66,8 +66,8 @@ sub set_counters { key_values => [ { name => 'containers_running' }, { name => 'display' } ], output_template => 'Containers Running : %s', perfdatas => [ - { label => 'containers_running', value => 'containers_running_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'containers_running', value => 'containers_running', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -75,8 +75,8 @@ sub set_counters { key_values => [ { name => 'containers_stopped' }, { name => 'display' } ], output_template => 'Containers Stopped : %s', perfdatas => [ - { label => 'containers_stopped', value => 'containers_stopped_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'containers_stopped', value => 'containers_stopped', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -84,8 +84,8 @@ sub set_counters { key_values => [ { name => 'containers_paused' }, { name => 'display' } ], output_template => 'Containers Paused : %s', perfdatas => [ - { label => 'containers_paused', value => 'containers_paused_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'containers_paused', value => 'containers_paused', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/cloud/ibm/softlayer/mode/events.pm b/cloud/ibm/softlayer/mode/events.pm index 28ac5c07a..4db7b457d 100644 --- a/cloud/ibm/softlayer/mode/events.pm +++ b/cloud/ibm/softlayer/mode/events.pm @@ -77,7 +77,7 @@ sub set_counters { key_values => [ { name => 'active' } ], output_template => 'Active : %d', perfdatas => [ - { label => 'active_events', value => 'active_absolute', template => '%d', + { label => 'active_events', value => 'active', template => '%d', min => 0 }, ], } @@ -86,7 +86,7 @@ sub set_counters { key_values => [ { name => 'completed' } ], output_template => 'Completed : %d', perfdatas => [ - { label => 'completed_events', value => 'completed_absolute', template => '%d', + { label => 'completed_events', value => 'completed', template => '%d', min => 0 }, ], } @@ -95,7 +95,7 @@ sub set_counters { key_values => [ { name => 'published' } ], output_template => 'Published : %d', perfdatas => [ - { label => 'published_events', value => 'published_absolute', template => '%d', + { label => 'published_events', value => 'published', template => '%d', min => 0 }, ], } diff --git a/cloud/ibm/softlayer/mode/opentickets.pm b/cloud/ibm/softlayer/mode/opentickets.pm index fac2cfc2e..0119294b5 100644 --- a/cloud/ibm/softlayer/mode/opentickets.pm +++ b/cloud/ibm/softlayer/mode/opentickets.pm @@ -70,7 +70,7 @@ sub set_counters { key_values => [ { name => 'open' } ], output_template => 'Number of open tickets : %d', perfdatas => [ - { label => 'open_tickets', value => 'open_absolute', template => '%d', + { label => 'open_tickets', value => 'open', template => '%d', min => 0 }, ], } diff --git a/cloud/kubernetes/mode/podstatus.pm b/cloud/kubernetes/mode/podstatus.pm index f05217be8..4f6e0402a 100644 --- a/cloud/kubernetes/mode/podstatus.pm +++ b/cloud/kubernetes/mode/podstatus.pm @@ -155,8 +155,8 @@ sub set_counters { key_values => [ { name => 'restarts_total' }, { name => 'display' } ], output_template => 'Restarts: %d', perfdatas => [ - { label => 'restarts_count', value => 'restarts_total_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'restarts_count', value => 'restarts_total', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -174,8 +174,8 @@ sub set_counters { key_values => [ { name => 'restarts' }, { name => 'perf' } ], output_template => 'Restarts: %d', perfdatas => [ - { label => 'restarts_count', value => 'restarts_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'perf_absolute' }, + { label => 'restarts_count', value => 'restarts', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'perf' }, ], } }, diff --git a/cloud/microsoft/office365/exchange/mode/emailactivity.pm b/cloud/microsoft/office365/exchange/mode/emailactivity.pm index 2aec580b7..7cf50eb44 100644 --- a/cloud/microsoft/office365/exchange/mode/emailactivity.pm +++ b/cloud/microsoft/office365/exchange/mode/emailactivity.pm @@ -113,7 +113,7 @@ sub set_counters { key_values => [ { name => 'send_count' } ], output_template => 'Send Count: %d', perfdatas => [ - { label => 'total_send_count', value => 'send_count_absolute', template => '%d', + { label => 'total_send_count', value => 'send_count', template => '%d', min => 0 }, ], } @@ -122,7 +122,7 @@ sub set_counters { key_values => [ { name => 'receive_count' } ], output_template => 'Receive Count: %d', perfdatas => [ - { label => 'total_receive_count', value => 'receive_count_absolute', template => '%d', + { label => 'total_receive_count', value => 'receive_count', template => '%d', min => 0 }, ], } @@ -131,7 +131,7 @@ sub set_counters { key_values => [ { name => 'read_count' } ], output_template => 'Read Count: %d', perfdatas => [ - { label => 'total_read_count', value => 'read_count_absolute', template => '%d', + { label => 'total_read_count', value => 'read_count', template => '%d', min => 0 }, ], } @@ -142,8 +142,8 @@ sub set_counters { key_values => [ { name => 'send_count' }, { name => 'name' } ], output_template => 'Send Count: %d', perfdatas => [ - { label => 'send_count', value => 'send_count_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'name_absolute' }, + { label => 'send_count', value => 'send_count', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'name' }, ], } }, @@ -151,8 +151,8 @@ sub set_counters { key_values => [ { name => 'receive_count' }, { name => 'name' } ], output_template => 'Receive Count: %d', perfdatas => [ - { label => 'receive_count', value => 'receive_count_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'name_absolute' }, + { label => 'receive_count', value => 'receive_count', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'name' }, ], } }, @@ -160,8 +160,8 @@ sub set_counters { key_values => [ { name => 'read_count' }, { name => 'name' } ], output_template => 'Read Count: %d', perfdatas => [ - { label => 'read_count', value => 'read_count_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'name_absolute' }, + { label => 'read_count', value => 'read_count', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'name' }, ], } }, diff --git a/cloud/microsoft/office365/exchange/mode/mailboxusage.pm b/cloud/microsoft/office365/exchange/mode/mailboxusage.pm index cd13735c4..acca62088 100644 --- a/cloud/microsoft/office365/exchange/mode/mailboxusage.pm +++ b/cloud/microsoft/office365/exchange/mode/mailboxusage.pm @@ -177,7 +177,7 @@ sub set_counters { output_template => 'Usage (active mailboxes): %s %s', output_change_bytes => 1, perfdatas => [ - { label => 'storage_used_active', value => 'storage_used_active_absolute', template => '%d', + { label => 'storage_used_active', value => 'storage_used_active', template => '%d', min => 0, unit => 'B' }, ], } @@ -187,7 +187,7 @@ sub set_counters { output_template => 'Usage (inactive mailboxes): %s %s', output_change_bytes => 1, perfdatas => [ - { label => 'storage_used_inactive', value => 'storage_used_inactive_absolute', template => '%d', + { label => 'storage_used_inactive', value => 'storage_used_inactive', template => '%d', min => 0, unit => 'B' }, ], } @@ -207,7 +207,7 @@ sub set_counters { key_values => [ { name => 'items' } ], output_template => 'Items: %d', perfdatas => [ - { label => 'items', value => 'items_absolute', template => '%d', + { label => 'items', value => 'items', template => '%d', min => 0 }, ], } diff --git a/cloud/microsoft/office365/onedrive/mode/usage.pm b/cloud/microsoft/office365/onedrive/mode/usage.pm index b46017d7f..e22e1fd97 100644 --- a/cloud/microsoft/office365/onedrive/mode/usage.pm +++ b/cloud/microsoft/office365/onedrive/mode/usage.pm @@ -178,7 +178,7 @@ sub set_counters { output_template => 'Usage (active sites): %s %s', output_change_bytes => 1, perfdatas => [ - { label => 'storage_used_active', value => 'storage_used_active_absolute', template => '%d', + { label => 'storage_used_active', value => 'storage_used_active', template => '%d', min => 0, unit => 'B' }, ], } @@ -188,7 +188,7 @@ sub set_counters { output_template => 'Usage (inactive sites): %s %s', output_change_bytes => 1, perfdatas => [ - { label => 'storage_used_inactive', value => 'storage_used_inactive_absolute', template => '%d', + { label => 'storage_used_inactive', value => 'storage_used_inactive', template => '%d', min => 0, unit => 'B' }, ], } @@ -197,7 +197,7 @@ sub set_counters { key_values => [ { name => 'file_count' } ], output_template => 'File Count (active sites): %d', perfdatas => [ - { label => 'total_file_count', value => 'file_count_absolute', template => '%d', + { label => 'total_file_count', value => 'file_count', template => '%d', min => 0 }, ], } @@ -206,7 +206,7 @@ sub set_counters { key_values => [ { name => 'active_file_count' } ], output_template => 'Active File Count (active sites): %d', perfdatas => [ - { label => 'total_active_file_count', value => 'active_file_count_absolute', template => '%d', + { label => 'total_active_file_count', value => 'active_file_count', template => '%d', min => 0 }, ], } @@ -225,8 +225,8 @@ sub set_counters { key_values => [ { name => 'file_count' }, { name => 'url' }, { name => 'owner' } ], output_template => 'File Count: %d', perfdatas => [ - { label => 'file_count', value => 'file_count_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'url_absolute' }, + { label => 'file_count', value => 'file_count', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'url' }, ], } }, @@ -234,8 +234,8 @@ sub set_counters { key_values => [ { name => 'active_file_count' }, { name => 'url' }, { name => 'owner' } ], output_template => 'Active File Count: %d', perfdatas => [ - { label => 'active_file_count', value => 'active_file_count_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'url_absolute' }, + { label => 'active_file_count', value => 'active_file_count', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'url' }, ], } }, diff --git a/cloud/microsoft/office365/sharepoint/mode/siteusage.pm b/cloud/microsoft/office365/sharepoint/mode/siteusage.pm index 7da0645fa..35ddd321a 100644 --- a/cloud/microsoft/office365/sharepoint/mode/siteusage.pm +++ b/cloud/microsoft/office365/sharepoint/mode/siteusage.pm @@ -178,7 +178,7 @@ sub set_counters { output_template => 'Usage (active sites): %s %s', output_change_bytes => 1, perfdatas => [ - { label => 'storage_used_active', value => 'storage_used_active_absolute', template => '%d', + { label => 'storage_used_active', value => 'storage_used_active', template => '%d', min => 0, unit => 'B' }, ], } @@ -188,7 +188,7 @@ sub set_counters { output_template => 'Usage (inactive sites): %s %s', output_change_bytes => 1, perfdatas => [ - { label => 'storage_used_inactive', value => 'storage_used_inactive_absolute', template => '%d', + { label => 'storage_used_inactive', value => 'storage_used_inactive', template => '%d', min => 0, unit => 'B' }, ], } @@ -197,7 +197,7 @@ sub set_counters { key_values => [ { name => 'file_count' } ], output_template => 'File Count (active sites): %d', perfdatas => [ - { label => 'total_file_count', value => 'file_count_absolute', template => '%d', + { label => 'total_file_count', value => 'file_count', template => '%d', min => 0 }, ], } @@ -206,7 +206,7 @@ sub set_counters { key_values => [ { name => 'active_file_count' } ], output_template => 'Active File Count (active sites): %d', perfdatas => [ - { label => 'total_active_file_count', value => 'active_file_count_absolute', template => '%d', + { label => 'total_active_file_count', value => 'active_file_count', template => '%d', min => 0 }, ], } @@ -215,7 +215,7 @@ sub set_counters { key_values => [ { name => 'visited_page_count' } ], output_template => 'Visited Page Count (active sites): %d', perfdatas => [ - { label => 'total_visited_page_count', value => 'visited_page_count_absolute', template => '%d', + { label => 'total_visited_page_count', value => 'visited_page_count', template => '%d', min => 0 }, ], } @@ -224,7 +224,7 @@ sub set_counters { key_values => [ { name => 'page_view_count' } ], output_template => 'Page View Count (active sites): %d', perfdatas => [ - { label => 'total_page_view_count', value => 'page_view_count_absolute', template => '%d', + { label => 'total_page_view_count', value => 'page_view_count', template => '%d', min => 0 }, ], } @@ -243,8 +243,8 @@ sub set_counters { key_values => [ { name => 'file_count' }, { name => 'url' }, { name => 'id' } ], output_template => 'File Count: %d', perfdatas => [ - { label => 'file_count', value => 'file_count_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'id_absolute' }, + { label => 'file_count', value => 'file_count', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'id' }, ], } }, @@ -252,8 +252,8 @@ sub set_counters { key_values => [ { name => 'active_file_count' }, { name => 'url' }, { name => 'id' } ], output_template => 'Active File Count: %d', perfdatas => [ - { label => 'active_file_count', value => 'active_file_count_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'id_absolute' }, + { label => 'active_file_count', value => 'active_file_count', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'id' }, ], } }, @@ -261,8 +261,8 @@ sub set_counters { key_values => [ { name => 'visited_page_count' }, { name => 'url' }, { name => 'id' } ], output_template => 'Visited Page Count: %d', perfdatas => [ - { label => 'visited_page_count', value => 'visited_page_count_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'id_absolute' }, + { label => 'visited_page_count', value => 'visited_page_count', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'id' }, ], } }, @@ -270,8 +270,8 @@ sub set_counters { key_values => [ { name => 'page_view_count' }, { name => 'url' }, { name => 'id' } ], output_template => 'Page View Count: %d', perfdatas => [ - { label => 'page_view_count', value => 'page_view_count_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'id_absolute' }, + { label => 'page_view_count', value => 'page_view_count', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'id' }, ], } }, diff --git a/cloud/microsoft/office365/sharepoint/mode/usersactivity.pm b/cloud/microsoft/office365/sharepoint/mode/usersactivity.pm index d76f56133..f27210261 100644 --- a/cloud/microsoft/office365/sharepoint/mode/usersactivity.pm +++ b/cloud/microsoft/office365/sharepoint/mode/usersactivity.pm @@ -113,7 +113,7 @@ sub set_counters { key_values => [ { name => 'viewed_edited_file_count' } ], output_template => 'Viewed or Edited File Count: %d', perfdatas => [ - { label => 'total_viewed_edited_file_count', value => 'viewed_edited_file_count_absolute', template => '%d', + { label => 'total_viewed_edited_file_count', value => 'viewed_edited_file_count', template => '%d', min => 0 }, ], } @@ -122,7 +122,7 @@ sub set_counters { key_values => [ { name => 'synced_file_count' } ], output_template => 'Synced File Count: %d', perfdatas => [ - { label => 'total_synced_file_count', value => 'synced_file_count_absolute', template => '%d', + { label => 'total_synced_file_count', value => 'synced_file_count', template => '%d', min => 0 }, ], } @@ -131,7 +131,7 @@ sub set_counters { key_values => [ { name => 'shared_int_file_count' } ], output_template => 'Shared Internally File Count: %d', perfdatas => [ - { label => 'total_shared_int_file_count', value => 'shared_int_file_count_absolute', template => '%d', + { label => 'total_shared_int_file_count', value => 'shared_int_file_count', template => '%d', min => 0 }, ], } @@ -140,7 +140,7 @@ sub set_counters { key_values => [ { name => 'shared_ext_file_count' } ], output_template => 'Shared Externally File Count: %d', perfdatas => [ - { label => 'total_shared_ext_file_count', value => 'shared_ext_file_count_absolute', template => '%d', + { label => 'total_shared_ext_file_count', value => 'shared_ext_file_count', template => '%d', min => 0 }, ], } @@ -149,7 +149,7 @@ sub set_counters { key_values => [ { name => 'visited_page_count' } ], output_template => 'Visited Page Count (active sites): %d', perfdatas => [ - { label => 'total_visited_page_count', value => 'visited_page_count_absolute', template => '%d', + { label => 'total_visited_page_count', value => 'visited_page_count', template => '%d', min => 0 }, ], } @@ -160,8 +160,8 @@ sub set_counters { key_values => [ { name => 'viewed_edited_file_count' }, { name => 'name' } ], output_template => 'Viewed or Edited File Count: %d', perfdatas => [ - { label => 'viewed_edited_file_count', value => 'viewed_edited_file_count_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'name_absolute' }, + { label => 'viewed_edited_file_count', value => 'viewed_edited_file_count', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'name' }, ], } }, @@ -169,8 +169,8 @@ sub set_counters { key_values => [ { name => 'synced_file_count' }, { name => 'name' } ], output_template => 'Synced File Count: %d', perfdatas => [ - { label => 'synced_file_count', value => 'synced_file_count_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'name_absolute' }, + { label => 'synced_file_count', value => 'synced_file_count', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'name' }, ], } }, @@ -178,8 +178,8 @@ sub set_counters { key_values => [ { name => 'shared_int_file_count' }, { name => 'name' } ], output_template => 'Shared Internally File Count: %d', perfdatas => [ - { label => 'shared_int_file_count', value => 'shared_int_file_count_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'name_absolute' }, + { label => 'shared_int_file_count', value => 'shared_int_file_count', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'name' }, ], } }, @@ -187,8 +187,8 @@ sub set_counters { key_values => [ { name => 'shared_ext_file_count' }, { name => 'name' } ], output_template => 'Shared Externally File Count: %d', perfdatas => [ - { label => 'shared_ext_file_count', value => 'shared_ext_file_count_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'name_absolute' }, + { label => 'shared_ext_file_count', value => 'shared_ext_file_count', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'name' }, ], } }, @@ -196,8 +196,8 @@ sub set_counters { key_values => [ { name => 'visited_page_count' }, { name => 'name' } ], output_template => 'Visited Page Count: %d', perfdatas => [ - { label => 'visited_page_count', value => 'visited_page_count_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'name_absolute' }, + { label => 'visited_page_count', value => 'visited_page_count', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'name' }, ], } }, diff --git a/cloud/microsoft/office365/skype/mode/devicesusage.pm b/cloud/microsoft/office365/skype/mode/devicesusage.pm index 9763c2395..a32b1ac55 100644 --- a/cloud/microsoft/office365/skype/mode/devicesusage.pm +++ b/cloud/microsoft/office365/skype/mode/devicesusage.pm @@ -106,7 +106,7 @@ sub set_counters { key_values => [ { name => 'windows' } ], output_template => 'Windows: %d', perfdatas => [ - { label => 'windows', value => 'windows_absolute', template => '%d', + { label => 'windows', value => 'windows', template => '%d', min => 0 }, ], } @@ -115,7 +115,7 @@ sub set_counters { key_values => [ { name => 'ipad' } ], output_template => 'iPad: %d', perfdatas => [ - { label => 'ipad', value => 'ipad_absolute', template => '%d', + { label => 'ipad', value => 'ipad', template => '%d', min => 0 }, ], } @@ -124,7 +124,7 @@ sub set_counters { key_values => [ { name => 'iphone' } ], output_template => 'iPhone: %d', perfdatas => [ - { label => 'iphone', value => 'iphone_absolute', template => '%d', + { label => 'iphone', value => 'iphone', template => '%d', min => 0 }, ], } @@ -133,7 +133,7 @@ sub set_counters { key_values => [ { name => 'android_phone' } ], output_template => 'Android Phone: %d', perfdatas => [ - { label => 'android_phone', value => 'android_phone_absolute', template => '%d', + { label => 'android_phone', value => 'android_phone', template => '%d', min => 0 }, ], } @@ -142,7 +142,7 @@ sub set_counters { key_values => [ { name => 'windows_phone' } ], output_template => 'Windows Phone: %d', perfdatas => [ - { label => 'windows_phone', value => 'windows_phone_absolute', template => '%d', + { label => 'windows_phone', value => 'windows_phone', template => '%d', min => 0 }, ], } diff --git a/cloud/microsoft/office365/skype/mode/usersactivity.pm b/cloud/microsoft/office365/skype/mode/usersactivity.pm index 443f2bd32..f7361d085 100644 --- a/cloud/microsoft/office365/skype/mode/usersactivity.pm +++ b/cloud/microsoft/office365/skype/mode/usersactivity.pm @@ -113,7 +113,7 @@ sub set_counters { key_values => [ { name => 'peer_to_peer_sessions' } ], output_template => 'Peer-to-peer Sessions Count: %d', perfdatas => [ - { label => 'total_peer_to_peer_sessions', value => 'peer_to_peer_sessions_absolute', template => '%d', + { label => 'total_peer_to_peer_sessions', value => 'peer_to_peer_sessions', template => '%d', min => 0 }, ], } @@ -122,7 +122,7 @@ sub set_counters { key_values => [ { name => 'organized_conference' } ], output_template => 'Organized Conference Count: %d', perfdatas => [ - { label => 'total_organized_conference', value => 'organized_conference_absolute', template => '%d', + { label => 'total_organized_conference', value => 'organized_conference', template => '%d', min => 0 }, ], } @@ -131,7 +131,7 @@ sub set_counters { key_values => [ { name => 'participated_conference' } ], output_template => 'Participated Conference Count: %d', perfdatas => [ - { label => 'total_participated_conference', value => 'participated_conference_absolute', template => '%d', + { label => 'total_participated_conference', value => 'participated_conference', template => '%d', min => 0 }, ], } @@ -142,8 +142,8 @@ sub set_counters { key_values => [ { name => 'peer_to_peer_sessions' }, { name => 'name' } ], output_template => 'Peer-to-peer Sessions Count: %d', perfdatas => [ - { label => 'peer_to_peer_sessions', value => 'peer_to_peer_sessions_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'name_absolute' }, + { label => 'peer_to_peer_sessions', value => 'peer_to_peer_sessions', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'name' }, ], } }, @@ -151,8 +151,8 @@ sub set_counters { key_values => [ { name => 'organized_conference' }, { name => 'name' } ], output_template => 'Organized Conference Count: %d', perfdatas => [ - { label => 'organized_conference', value => 'organized_conference_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'name_absolute' }, + { label => 'organized_conference', value => 'organized_conference', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'name' }, ], } }, @@ -160,8 +160,8 @@ sub set_counters { key_values => [ { name => 'participated_conference' }, { name => 'name' } ], output_template => 'Participated Conference Count: %d', perfdatas => [ - { label => 'participated_conference', value => 'participated_conference_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'name_absolute' }, + { label => 'participated_conference', value => 'participated_conference', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'name' }, ], } }, diff --git a/cloud/microsoft/office365/teams/mode/devicesusage.pm b/cloud/microsoft/office365/teams/mode/devicesusage.pm index 237069fe2..8edb722b4 100644 --- a/cloud/microsoft/office365/teams/mode/devicesusage.pm +++ b/cloud/microsoft/office365/teams/mode/devicesusage.pm @@ -106,7 +106,7 @@ sub set_counters { key_values => [ { name => 'windows' } ], output_template => 'Windows: %d', perfdatas => [ - { label => 'windows', value => 'windows_absolute', template => '%d', + { label => 'windows', value => 'windows', template => '%d', min => 0 }, ], } @@ -115,7 +115,7 @@ sub set_counters { key_values => [ { name => 'mac' } ], output_template => 'Mac: %d', perfdatas => [ - { label => 'mac', value => 'mac_absolute', template => '%d', + { label => 'mac', value => 'mac', template => '%d', min => 0 }, ], } @@ -124,7 +124,7 @@ sub set_counters { key_values => [ { name => 'web' } ], output_template => 'Web: %d', perfdatas => [ - { label => 'web', value => 'web_absolute', template => '%d', + { label => 'web', value => 'web', template => '%d', min => 0 }, ], } @@ -133,7 +133,7 @@ sub set_counters { key_values => [ { name => 'ios' } ], output_template => 'iOS: %d', perfdatas => [ - { label => 'ios', value => 'ios_absolute', template => '%d', + { label => 'ios', value => 'ios', template => '%d', min => 0 }, ], } @@ -142,7 +142,7 @@ sub set_counters { key_values => [ { name => 'android_phone' } ], output_template => 'Android Phone: %d', perfdatas => [ - { label => 'android_phone', value => 'android_phone_absolute', template => '%d', + { label => 'android_phone', value => 'android_phone', template => '%d', min => 0 }, ], } @@ -151,7 +151,7 @@ sub set_counters { key_values => [ { name => 'windows_phone' } ], output_template => 'Windows Phone: %d', perfdatas => [ - { label => 'windows_phone', value => 'windows_phone_absolute', template => '%d', + { label => 'windows_phone', value => 'windows_phone', template => '%d', min => 0 }, ], } diff --git a/cloud/microsoft/office365/teams/mode/usersactivity.pm b/cloud/microsoft/office365/teams/mode/usersactivity.pm index ebeaa6fcb..0d13a29ff 100644 --- a/cloud/microsoft/office365/teams/mode/usersactivity.pm +++ b/cloud/microsoft/office365/teams/mode/usersactivity.pm @@ -113,7 +113,7 @@ sub set_counters { key_values => [ { name => 'team_chat' } ], output_template => 'Team Chat Message Count: %d', perfdatas => [ - { label => 'total_team_chat', value => 'team_chat_absolute', template => '%d', + { label => 'total_team_chat', value => 'team_chat', template => '%d', min => 0 }, ], } @@ -122,7 +122,7 @@ sub set_counters { key_values => [ { name => 'private_chat' } ], output_template => 'Private Chat Message Count: %d', perfdatas => [ - { label => 'total_private_chat', value => 'private_chat_absolute', template => '%d', + { label => 'total_private_chat', value => 'private_chat', template => '%d', min => 0 }, ], } @@ -131,7 +131,7 @@ sub set_counters { key_values => [ { name => 'call' } ], output_template => 'Call Count: %d', perfdatas => [ - { label => 'total_call', value => 'call_absolute', template => '%d', + { label => 'total_call', value => 'call', template => '%d', min => 0 }, ], } @@ -140,7 +140,7 @@ sub set_counters { key_values => [ { name => 'meeting' } ], output_template => 'Meeting Count: %d', perfdatas => [ - { label => 'total_meeting', value => 'meeting_absolute', template => '%d', + { label => 'total_meeting', value => 'meeting', template => '%d', min => 0 }, ], } @@ -151,8 +151,8 @@ sub set_counters { key_values => [ { name => 'team_chat' }, { name => 'name' } ], output_template => 'Team Chat Message Count: %d', perfdatas => [ - { label => 'team_chat', value => 'team_chat_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'name_absolute' }, + { label => 'team_chat', value => 'team_chat', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'name' }, ], } }, @@ -160,8 +160,8 @@ sub set_counters { key_values => [ { name => 'private_chat' }, { name => 'name' } ], output_template => 'Private Chat Message Count: %d', perfdatas => [ - { label => 'private_chat', value => 'private_chat_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'name_absolute' }, + { label => 'private_chat', value => 'private_chat', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'name' }, ], } }, @@ -169,8 +169,8 @@ sub set_counters { key_values => [ { name => 'call' }, { name => 'name' } ], output_template => 'Call Count: %d', perfdatas => [ - { label => 'call', value => 'call_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'name_absolute' }, + { label => 'call', value => 'call', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'name' }, ], } }, @@ -178,8 +178,8 @@ sub set_counters { key_values => [ { name => 'meeting' }, { name => 'name' } ], output_template => 'Meeting Count: %d', perfdatas => [ - { label => 'meeting', value => 'meeting_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'name_absolute' }, + { label => 'meeting', value => 'meeting', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'name' }, ], } }, diff --git a/cloud/nutanix/snmp/mode/clusterusage.pm b/cloud/nutanix/snmp/mode/clusterusage.pm index 9db7dad4c..b0a2c246a 100644 --- a/cloud/nutanix/snmp/mode/clusterusage.pm +++ b/cloud/nutanix/snmp/mode/clusterusage.pm @@ -135,7 +135,7 @@ sub set_counters { key_values => [ { name => 'clusterLatency' } ], output_template => 'Average Latency : %s µs', perfdatas => [ - { label => 'avg_latency', value => 'clusterLatency_absolute', template => '%s', unit => 'µs', + { label => 'avg_latency', value => 'clusterLatency', template => '%s', unit => 'µs', min => 0 }, ], } @@ -144,7 +144,7 @@ sub set_counters { key_values => [ { name => 'clusterIops' } ], output_template => 'IOPs : %s', perfdatas => [ - { label => 'iops', value => 'clusterIops_absolute', template => '%s', unit => 'iops', + { label => 'iops', value => 'clusterIops', template => '%s', unit => 'iops', min => 0 }, ], } diff --git a/cloud/nutanix/snmp/mode/containerusage.pm b/cloud/nutanix/snmp/mode/containerusage.pm index c52cdacac..2f0d612d6 100644 --- a/cloud/nutanix/snmp/mode/containerusage.pm +++ b/cloud/nutanix/snmp/mode/containerusage.pm @@ -112,8 +112,8 @@ sub set_counters { key_values => [ { name => 'citAvgLatencyUsecs' }, { name => 'display' } ], output_template => 'Average Latency : %s µs', perfdatas => [ - { label => 'avg_latency', value => 'citAvgLatencyUsecs_absolute', template => '%s', unit => 'µs', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'avg_latency', value => 'citAvgLatencyUsecs', template => '%s', unit => 'µs', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -121,8 +121,8 @@ sub set_counters { key_values => [ { name => 'citIOPerSecond' }, { name => 'display' } ], output_template => 'IOPs : %s', perfdatas => [ - { label => 'iops', value => 'citIOPerSecond_absolute', template => '%s', unit => 'iops', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'iops', value => 'citIOPerSecond', template => '%s', unit => 'iops', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/cloud/nutanix/snmp/mode/diskusage.pm b/cloud/nutanix/snmp/mode/diskusage.pm index 2de3b02d2..df991f939 100644 --- a/cloud/nutanix/snmp/mode/diskusage.pm +++ b/cloud/nutanix/snmp/mode/diskusage.pm @@ -135,8 +135,8 @@ sub set_counters { key_values => [ { name => 'inodes_used' }, { name => 'display' } ], output_template => 'Inodes Used : %s %%', perfdatas => [ - { label => 'inodes', value => 'inodes_used_absolute', template => '%s', unit => '%', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'inodes', value => 'inodes_used', template => '%s', unit => '%', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -144,8 +144,8 @@ sub set_counters { key_values => [ { name => 'dstAverageLatency' }, { name => 'display' } ], output_template => 'Average Latency : %s µs', perfdatas => [ - { label => 'avg_latency', value => 'dstAverageLatency_absolute', template => '%s', unit => 'µs', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'avg_latency', value => 'dstAverageLatency', template => '%s', unit => 'µs', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -153,8 +153,8 @@ sub set_counters { key_values => [ { name => 'dstNumberIops' }, { name => 'display' } ], output_template => 'IOPs : %s', perfdatas => [ - { label => 'iops', value => 'dstNumberIops_absolute', template => '%s', unit => 'iops', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'iops', value => 'dstNumberIops', template => '%s', unit => 'iops', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/cloud/nutanix/snmp/mode/hypervisorusage.pm b/cloud/nutanix/snmp/mode/hypervisorusage.pm index 351da7186..94bf109dc 100644 --- a/cloud/nutanix/snmp/mode/hypervisorusage.pm +++ b/cloud/nutanix/snmp/mode/hypervisorusage.pm @@ -82,8 +82,8 @@ sub set_counters { key_values => [ { name => 'hypervisorCpuUsagePercent' }, { name => 'display' } ], output_template => 'CPU Usage : %s %%', perfdatas => [ - { label => 'cpu_usage', value => 'hypervisorCpuUsagePercent_absolute', template => '%s', unit => '%', - min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'cpu_usage', value => 'hypervisorCpuUsagePercent', template => '%s', unit => '%', + min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -99,8 +99,8 @@ sub set_counters { key_values => [ { name => 'hypervisorAverageLatency' }, { name => 'display' } ], output_template => 'Average Latency : %s µs', perfdatas => [ - { label => 'avg_latency', value => 'hypervisorAverageLatency_absolute', template => '%s', unit => 'µs', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'avg_latency', value => 'hypervisorAverageLatency', template => '%s', unit => 'µs', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -108,8 +108,8 @@ sub set_counters { key_values => [ { name => 'hypervisorReadIOPerSecond' }, { name => 'display' } ], output_template => 'Read IOPs : %s', perfdatas => [ - { label => 'read_iops', value => 'hypervisorReadIOPerSecond_absolute', template => '%s', unit => 'iops', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'read_iops', value => 'hypervisorReadIOPerSecond', template => '%s', unit => 'iops', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -117,8 +117,8 @@ sub set_counters { key_values => [ { name => 'hypervisorWriteIOPerSecond' }, { name => 'display' } ], output_template => 'Write IOPs : %s', perfdatas => [ - { label => 'write_iops', value => 'hypervisorWriteIOPerSecond_absolute', template => '%s', unit => 'iops', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'write_iops', value => 'hypervisorWriteIOPerSecond', template => '%s', unit => 'iops', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -126,8 +126,8 @@ sub set_counters { key_values => [ { name => 'hypervisorVmCount' }, { name => 'display' } ], output_template => 'VM Count : %s', perfdatas => [ - { label => 'vm_count', value => 'hypervisorVmCount_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'vm_count', value => 'hypervisorVmCount', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/cloud/nutanix/snmp/mode/storagepoolusage.pm b/cloud/nutanix/snmp/mode/storagepoolusage.pm index 5de35cb0d..fc978de86 100644 --- a/cloud/nutanix/snmp/mode/storagepoolusage.pm +++ b/cloud/nutanix/snmp/mode/storagepoolusage.pm @@ -112,8 +112,8 @@ sub set_counters { key_values => [ { name => 'spitAvgLatencyUsecs' }, { name => 'display' } ], output_template => 'Average Latency : %s µs', perfdatas => [ - { label => 'avg_latency', value => 'spitAvgLatencyUsecs_absolute', template => '%s', unit => 'µs', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'avg_latency', value => 'spitAvgLatencyUsecs', template => '%s', unit => 'µs', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -121,8 +121,8 @@ sub set_counters { key_values => [ { name => 'spitIOPerSecond' }, { name => 'display' } ], output_template => 'IOPs : %s', perfdatas => [ - { label => 'iops', value => 'spitIOPerSecond_absolute', template => '%s', unit => 'iops', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'iops', value => 'spitIOPerSecond', template => '%s', unit => 'iops', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/cloud/nutanix/snmp/mode/vmusage.pm b/cloud/nutanix/snmp/mode/vmusage.pm index 5e0e94724..dc2550060 100644 --- a/cloud/nutanix/snmp/mode/vmusage.pm +++ b/cloud/nutanix/snmp/mode/vmusage.pm @@ -39,8 +39,8 @@ sub set_counters { key_values => [ { name => 'vmCpuUsagePercent' }, { name => 'display' } ], output_template => 'CPU Usage : %s %%', perfdatas => [ - { label => 'cpu_usage', value => 'vmCpuUsagePercent_absolute', template => '%s', unit => '%', - min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'cpu_usage', template => '%s', unit => '%', + min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -48,8 +48,8 @@ sub set_counters { key_values => [ { name => 'vmAverageLatency' }, { name => 'display' } ], output_template => 'Average Latency : %s µs', perfdatas => [ - { label => 'avg_latency', value => 'vmAverageLatency_absolute', template => '%s', unit => 'µs', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'avg_latency', template => '%s', unit => 'µs', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -57,8 +57,8 @@ sub set_counters { key_values => [ { name => 'vmReadIOPerSecond' }, { name => 'display' } ], output_template => 'Read IOPs : %s', perfdatas => [ - { label => 'read_iops', value => 'vmReadIOPerSecond_absolute', template => '%s', unit => 'iops', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'read_iops', template => '%s', unit => 'iops', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -66,28 +66,28 @@ sub set_counters { key_values => [ { name => 'vmWriteIOPerSecond' }, { name => 'display' } ], output_template => 'Write IOPs : %s', perfdatas => [ - { label => 'write_iops', value => 'vmWriteIOPerSecond_absolute', template => '%s', unit => 'iops', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'write_iops', template => '%s', unit => 'iops', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'traffic-in', set => { - key_values => [ { name => 'vmRxBytes', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'vmRxBytes', per_second => 1 }, { name => 'display' } ], output_template => 'Traffic In : %s %s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_in', value => 'vmRxBytes_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_in', template => '%.2f', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'traffic-out', set => { - key_values => [ { name => 'vmTxBytes', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'vmTxBytes', per_second => 1 }, { name => 'display' } ], output_template => 'Traffic Out : %s %s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_out', value => 'vmTxBytes_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_out', template => '%.2f', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/cloud/ovh/restapi/mode/sms.pm b/cloud/ovh/restapi/mode/sms.pm index 1ade427f3..cb451d56d 100644 --- a/cloud/ovh/restapi/mode/sms.pm +++ b/cloud/ovh/restapi/mode/sms.pm @@ -37,8 +37,8 @@ sub set_counters { key_values => [ { name => 'left' }, { name => 'display' } ], output_template => 'SMS left : %s', perfdatas => [ - { label => 'left', value => 'left_absolute', template => '%s', unit => 'sms', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'left', value => 'left', template => '%s', unit => 'sms', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/cloud/prometheus/direct/kubernetes/mode/containerstatus.pm b/cloud/prometheus/direct/kubernetes/mode/containerstatus.pm index 326d4d68f..8c8ff8439 100644 --- a/cloud/prometheus/direct/kubernetes/mode/containerstatus.pm +++ b/cloud/prometheus/direct/kubernetes/mode/containerstatus.pm @@ -72,8 +72,8 @@ sub set_counters { key_values => [ { name => 'restarts' }, { name => 'perf' } ], output_template => 'Restarts count : %d', perfdatas => [ - { label => 'restarts_count', value => 'restarts_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'perf_absolute' }, + { label => 'restarts_count', value => 'restarts', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'perf' }, ], } }, diff --git a/cloud/prometheus/direct/kubernetes/mode/namespacestatus.pm b/cloud/prometheus/direct/kubernetes/mode/namespacestatus.pm index 4bf008352..910d468ef 100644 --- a/cloud/prometheus/direct/kubernetes/mode/namespacestatus.pm +++ b/cloud/prometheus/direct/kubernetes/mode/namespacestatus.pm @@ -55,7 +55,7 @@ sub set_counters { key_values => [ { name => 'active' } ], output_template => 'Active : %d', perfdatas => [ - { label => 'active', value => 'active_absolute', template => '%d', + { label => 'active', value => 'active', template => '%d', min => 0 }, ], } @@ -64,7 +64,7 @@ sub set_counters { key_values => [ { name => 'terminating' } ], output_template => 'Terminating : %d', perfdatas => [ - { label => 'terminating', value => 'terminating_absolute', template => '%d', + { label => 'terminating', value => 'terminating', template => '%d', min => 0 }, ], } diff --git a/cloud/prometheus/direct/nginxingresscontroller/mode/connections.pm b/cloud/prometheus/direct/nginxingresscontroller/mode/connections.pm index 8ce95a583..0463d20c1 100644 --- a/cloud/prometheus/direct/nginxingresscontroller/mode/connections.pm +++ b/cloud/prometheus/direct/nginxingresscontroller/mode/connections.pm @@ -38,8 +38,7 @@ sub set_counters { key_values => [ { name => 'reading' } ], output_template => 'Reading: %d', perfdatas => [ - { label => 'reading', value => 'reading_absolute', template => '%d', - min => 0, unit => 'connections' }, + { label => 'reading',template => '%d', min => 0, unit => 'connections' }, ], } }, @@ -47,8 +46,7 @@ sub set_counters { key_values => [ { name => 'waiting' } ], output_template => 'Waiting: %d', perfdatas => [ - { label => 'waiting', value => 'waiting_absolute', template => '%d', - min => 0, unit => 'connections' }, + { label => 'waiting', template => '%d', min => 0, unit => 'connections' }, ], } }, @@ -56,8 +54,7 @@ sub set_counters { key_values => [ { name => 'writing' } ], output_template => 'Writing: %d', perfdatas => [ - { label => 'writing', value => 'writing_absolute', template => '%d', - min => 0, unit => 'connections' }, + { label => 'writing', template => '%d', min => 0, unit => 'connections' }, ], } }, @@ -65,28 +62,23 @@ sub set_counters { key_values => [ { name => 'active' } ], output_template => 'Active: %d', perfdatas => [ - { label => 'active', value => 'active_absolute', template => '%d', - min => 0, unit => 'connections' }, + { label => 'active', template => '%d', min => 0, unit => 'connections' }, ], } }, { label => 'accepted', nlabel => 'connections.accepted.persecond', set => { - key_values => [ { name => 'accepted', diff => 1 } ], + key_values => [ { name => 'accepted', per_second => 1 } ], output_template => 'Accepted: %.2f/s', - per_second => 1, perfdatas => [ - { label => 'accepted', value => 'accepted_per_second', template => '%.2f', - min => 0, unit => 'connections/s' }, + { label => 'accepted', template => '%.2f', min => 0, unit => 'connections/s' }, ], } }, { label => 'handled', nlabel => 'connections.handled.persecond', set => { - key_values => [ { name => 'handled', diff => 1 } ], + key_values => [ { name => 'handled', per_second => 1 } ], output_template => 'Handled: %.2f/s', - per_second => 1, perfdatas => [ - { label => 'handled', value => 'handled_per_second', template => '%.2f', - min => 0, unit => 'connections/s' }, + { label => 'handled', template => '%.2f', min => 0, unit => 'connections/s' }, ], } }, @@ -105,8 +97,8 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - "extra-filter:s@" => { name => 'extra_filter' }, - "metric-overload:s@" => { name => 'metric_overload' }, + 'extra-filter:s@' => { name => 'extra_filter' }, + 'metric-overload:s@' => { name => 'metric_overload' }, }); return $self; diff --git a/cloud/prometheus/direct/nginxingresscontroller/mode/requests.pm b/cloud/prometheus/direct/nginxingresscontroller/mode/requests.pm index b3de6f6ae..af140d00c 100644 --- a/cloud/prometheus/direct/nginxingresscontroller/mode/requests.pm +++ b/cloud/prometheus/direct/nginxingresscontroller/mode/requests.pm @@ -37,54 +37,45 @@ sub set_counters { $self->{maps_counters}->{global} = [ { label => 'requests', nlabel => 'requests.total.persecond', set => { - key_values => [ { name => 'requests', diff => 1 } ], + key_values => [ { name => 'requests', per_second => 1 } ], output_template => 'Requests: %.2f/s', - per_second => 1, perfdatas => [ - { label => 'requests', value => 'requests_per_second', template => '%.2f', - min => 0, unit => 'requests/s' }, + { label => 'requests', template => '%.2f', min => 0, unit => 'requests/s' }, ], } }, ]; + $self->{maps_counters}->{namespaces} = [ { label => 'requests-2xx', nlabel => 'namespace.requests.2xx.persecond', set => { - key_values => [ { name => 'requests_2xx', diff => 1 } ], + key_values => [ { name => 'requests_2xx', per_second => 1 } ], output_template => 'Requests 2xx: %.2f/s', - per_second => 1, perfdatas => [ - { label => 'requests_2xx', value => 'requests_2xx_per_second', template => '%.2f', unit => 'requests/s', - min => 0, label_extra_instance => 1 }, + { label => 'requests_2xx', template => '%.2f', unit => 'requests/s', min => 0, label_extra_instance => 1 }, ], } }, { label => 'requests-3xx', nlabel => 'namespace.requests.2xx.persecond', set => { - key_values => [ { name => 'requests_3xx', diff => 1 } ], + key_values => [ { name => 'requests_3xx', per_second => 1 } ], output_template => 'Requests 3xx: %.2f/s', - per_second => 1, perfdatas => [ - { label => 'requests_3xx', value => 'requests_3xx_per_second', template => '%.2f', unit => 'requests/s', - min => 0, label_extra_instance => 1 }, + { label => 'requests_3xx', template => '%.2f', unit => 'requests/s', min => 0, label_extra_instance => 1 }, ], } }, { label => 'requests-4xx', nlabel => 'namespace.requests.4xx.persecond', set => { - key_values => [ { name => 'requests_4xx', diff => 1 } ], + key_values => [ { name => 'requests_4xx', per_second => 1 } ], output_template => 'Requests 4xx: %.2f/s', - per_second => 1, perfdatas => [ - { label => 'requests_4xx', value => 'requests_4xx_per_second', template => '%.2f', unit => 'requests/s', - min => 0, label_extra_instance => 1 }, + { label => 'requests_4xx', template => '%.2f', unit => 'requests/s', min => 0, label_extra_instance => 1 }, ], } }, { label => 'requests-5xx', nlabel => 'namespace.requests.5xx.persecond', set => { - key_values => [ { name => 'requests_5xx', diff => 1 } ], + key_values => [ { name => 'requests_5xx', per_second => 1 } ], output_template => 'Requests 5xx: %.2f/s', - per_second => 1, perfdatas => [ - { label => 'requests_5xx', value => 'requests_5xx_per_second', template => '%.2f', unit => 'requests/s', - min => 0, label_extra_instance => 1 }, + { label => 'requests_5xx', template => '%.2f', unit => 'requests/s', min => 0, label_extra_instance => 1 }, ], } }, @@ -103,8 +94,8 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - "extra-filter:s@" => { name => 'extra_filter' }, - "metric-overload:s@" => { name => 'metric_overload' }, + 'extra-filter:s@' => { name => 'extra_filter' }, + 'metric-overload:s@' => { name => 'metric_overload' }, }); return $self; diff --git a/cloud/prometheus/exporters/cadvisor/mode/cpu.pm b/cloud/prometheus/exporters/cadvisor/mode/cpu.pm index 36004dec3..8068d1747 100644 --- a/cloud/prometheus/exporters/cadvisor/mode/cpu.pm +++ b/cloud/prometheus/exporters/cadvisor/mode/cpu.pm @@ -38,9 +38,9 @@ sub set_counters { key_values => [ { name => 'usage' }, { name => 'container' }, { name => 'pod' }, { name => 'perf' } ], output_template => 'Usage: %.2f %%', perfdatas => [ - { label => 'usage', value => 'usage_absolute', template => '%.2f', + { label => 'usage', value => 'usage', template => '%.2f', min => 0, max => 100, unit => '%', - label_extra_instance => 1, instance_use => 'perf_absolute' }, + label_extra_instance => 1, instance_use => 'perf' }, ], } }, @@ -48,9 +48,9 @@ sub set_counters { key_values => [ { name => 'throttled' }, { name => 'container' }, { name => 'pod' }, { name => 'perf' } ], output_template => 'Throttled: %.2f %%', perfdatas => [ - { label => 'throttled', value => 'throttled_absolute', template => '%.2f', + { label => 'throttled', value => 'throttled', template => '%.2f', min => 0, max => 100, unit => '%', - label_extra_instance => 1, instance_use => 'perf_absolute' }, + label_extra_instance => 1, instance_use => 'perf' }, ], } }, diff --git a/cloud/prometheus/exporters/cadvisor/mode/load.pm b/cloud/prometheus/exporters/cadvisor/mode/load.pm index 1a6a3ff8b..459a97f1e 100644 --- a/cloud/prometheus/exporters/cadvisor/mode/load.pm +++ b/cloud/prometheus/exporters/cadvisor/mode/load.pm @@ -39,8 +39,8 @@ sub set_counters { output_template => 'Load: %.2f', output_change_bytes => 1, perfdatas => [ - { label => 'load', value => 'load_absolute', template => '%.2f', - min => 0, label_extra_instance => 1, instance_use => 'perf_absolute' }, + { label => 'load', value => 'load', template => '%.2f', + min => 0, label_extra_instance => 1, instance_use => 'perf' }, ], } }, diff --git a/cloud/prometheus/exporters/cadvisor/mode/memory.pm b/cloud/prometheus/exporters/cadvisor/mode/memory.pm index b163b6cd2..f67613e33 100644 --- a/cloud/prometheus/exporters/cadvisor/mode/memory.pm +++ b/cloud/prometheus/exporters/cadvisor/mode/memory.pm @@ -131,8 +131,8 @@ sub set_counters { output_template => 'Cache: %.2f %s', output_change_bytes => 1, perfdatas => [ - { label => 'cache', value => 'cache_absolute', template => '%s', - min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'perf_absolute' }, + { label => 'cache', value => 'cache', template => '%s', + min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'perf' }, ], } }, @@ -141,8 +141,8 @@ sub set_counters { output_template => 'Rss: %.2f %s', output_change_bytes => 1, perfdatas => [ - { label => 'rss', value => 'rss_absolute', template => '%s', - min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'perf_absolute' }, + { label => 'rss', value => 'rss', template => '%s', + min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'perf' }, ], } }, @@ -151,8 +151,8 @@ sub set_counters { output_template => 'Swap: %.2f %s', output_change_bytes => 1, perfdatas => [ - { label => 'swap', value => 'swap_absolute', template => '%s', - min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'perf_absolute' }, + { label => 'swap', value => 'swap', template => '%s', + min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'perf' }, ], } }, diff --git a/cloud/prometheus/exporters/cadvisor/mode/taskstate.pm b/cloud/prometheus/exporters/cadvisor/mode/taskstate.pm index 7e68d1b86..9225655a8 100644 --- a/cloud/prometheus/exporters/cadvisor/mode/taskstate.pm +++ b/cloud/prometheus/exporters/cadvisor/mode/taskstate.pm @@ -39,8 +39,8 @@ sub set_counters { output_template => 'Sleeping: %d', output_change_bytes => 1, perfdatas => [ - { label => 'tasks_sleeping', value => 'sleeping_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'perf_absolute' }, + { label => 'tasks_sleeping', value => 'sleeping', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'perf' }, ], } }, @@ -49,8 +49,8 @@ sub set_counters { output_template => 'Running: %d', output_change_bytes => 1, perfdatas => [ - { label => 'tasks_running', value => 'running_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'perf_absolute' }, + { label => 'tasks_running', value => 'running', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'perf' }, ], } }, @@ -59,8 +59,8 @@ sub set_counters { output_template => 'Stopped: %d', output_change_bytes => 1, perfdatas => [ - { label => 'tasks_stopped', value => 'stopped_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'perf_absolute' }, + { label => 'tasks_stopped', value => 'stopped', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'perf' }, ], } }, @@ -69,8 +69,8 @@ sub set_counters { output_template => 'Uninterruptible: %d', output_change_bytes => 1, perfdatas => [ - { label => 'tasks_uninterruptible', value => 'uninterruptible_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'perf_absolute' }, + { label => 'tasks_uninterruptible', value => 'uninterruptible', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'perf' }, ], } }, @@ -79,8 +79,8 @@ sub set_counters { output_template => 'Iowaiting: %d', output_change_bytes => 1, perfdatas => [ - { label => 'tasks_iowaiting', value => 'iowaiting_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'perf_absolute' }, + { label => 'tasks_iowaiting', value => 'iowaiting', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'perf' }, ], } }, diff --git a/cloud/prometheus/exporters/nodeexporter/mode/cpu.pm b/cloud/prometheus/exporters/nodeexporter/mode/cpu.pm index 72ca54c35..c6b3d8e52 100644 --- a/cloud/prometheus/exporters/nodeexporter/mode/cpu.pm +++ b/cloud/prometheus/exporters/nodeexporter/mode/cpu.pm @@ -44,7 +44,7 @@ sub set_counters { key_values => [ { name => 'node_average' } ], output_template => '%.2f %%', perfdatas => [ - { label => 'node', value => 'node_average_absolute', template => '%.2f', unit => '%', + { label => 'node', value => 'node_average', template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1 }, ], } @@ -55,7 +55,7 @@ sub set_counters { key_values => [ { name => 'cpu_usage' }, { name => 'display' } ], output_template => 'Usage: %.2f %%', perfdatas => [ - { label => 'cpu', value => 'cpu_usage_absolute', template => '%.2f', unit => '%', + { label => 'cpu', value => 'cpu_usage', template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1 }, ], } diff --git a/cloud/prometheus/exporters/nodeexporter/mode/cpudetailed.pm b/cloud/prometheus/exporters/nodeexporter/mode/cpudetailed.pm index 747c547fb..b3dcbf742 100644 --- a/cloud/prometheus/exporters/nodeexporter/mode/cpudetailed.pm +++ b/cloud/prometheus/exporters/nodeexporter/mode/cpudetailed.pm @@ -44,7 +44,7 @@ sub set_counters { key_values => [ { name => 'iowait' } ], output_template => 'Wait: %.2f %%', perfdatas => [ - { label => 'wait', value => 'iowait_absolute', template => '%.2f', + { label => 'wait', value => 'iowait', template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 }, ], } @@ -53,7 +53,7 @@ sub set_counters { key_values => [ { name => 'user' } ], output_template => 'User: %.2f %%', perfdatas => [ - { label => 'user', value => 'user_absolute', template => '%.2f', + { label => 'user', value => 'user', template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 }, ], } @@ -62,7 +62,7 @@ sub set_counters { key_values => [ { name => 'softirq' } ], output_template => 'Soft Irq: %.2f %%', perfdatas => [ - { label => 'softirq', value => 'softirq_absolute', template => '%.2f', + { label => 'softirq', value => 'softirq', template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 }, ], } @@ -71,7 +71,7 @@ sub set_counters { key_values => [ { name => 'irq' } ], output_template => 'Interrupt: %.2f %%', perfdatas => [ - { label => 'interrupt', value => 'irq_absolute', template => '%.2f', + { label => 'interrupt', value => 'irq', template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 }, ], } @@ -80,7 +80,7 @@ sub set_counters { key_values => [ { name => 'idle' } ], output_template => 'Idle: %.2f %%', perfdatas => [ - { label => 'idle', value => 'idle_absolute', template => '%.2f', + { label => 'idle', value => 'idle', template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 }, ], } @@ -89,7 +89,7 @@ sub set_counters { key_values => [ { name => 'steal' } ], output_template => 'Steal: %.2f %%', perfdatas => [ - { label => 'steal', value => 'steal_absolute', template => '%.2f', + { label => 'steal', value => 'steal', template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 }, ], } @@ -98,7 +98,7 @@ sub set_counters { key_values => [ { name => 'system' } ], output_template => 'System: %.2f %%', perfdatas => [ - { label => 'system', value => 'system_absolute', template => '%.2f', + { label => 'system', value => 'system', template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 }, ], } @@ -107,7 +107,7 @@ sub set_counters { key_values => [ { name => 'nice' } ], output_template => 'Nice: %.2f %%', perfdatas => [ - { label => 'nice', value => 'nice_absolute', template => '%.2f', + { label => 'nice', value => 'nice', template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 }, ], } @@ -118,7 +118,7 @@ sub set_counters { key_values => [ { name => 'iowait' }, { name => 'display' } ], output_template => 'Wait: %.2f %%', perfdatas => [ - { label => 'wait', value => 'iowait_absolute', template => '%.2f', + { label => 'wait', value => 'iowait', template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 }, ], } @@ -127,7 +127,7 @@ sub set_counters { key_values => [ { name => 'user' }, { name => 'display' } ], output_template => 'User: %.2f %%', perfdatas => [ - { label => 'user', value => 'user_absolute', template => '%.2f', + { label => 'user', value => 'user', template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 }, ], } @@ -136,7 +136,7 @@ sub set_counters { key_values => [ { name => 'softirq' }, { name => 'display' } ], output_template => 'Soft Irq: %.2f %%', perfdatas => [ - { label => 'softirq', value => 'softirq_absolute', template => '%.2f', + { label => 'softirq', value => 'softirq', template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 }, ], } @@ -145,7 +145,7 @@ sub set_counters { key_values => [ { name => 'irq' }, { name => 'display' } ], output_template => 'Interrupt: %.2f %%', perfdatas => [ - { label => 'interrupt', value => 'irq_absolute', template => '%.2f', + { label => 'interrupt', value => 'irq', template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 }, ], } @@ -154,7 +154,7 @@ sub set_counters { key_values => [ { name => 'idle' }, { name => 'display' } ], output_template => 'Idle: %.2f %%', perfdatas => [ - { label => 'idle', value => 'idle_absolute', template => '%.2f', + { label => 'idle', value => 'idle', template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 }, ], } @@ -163,7 +163,7 @@ sub set_counters { key_values => [ { name => 'steal' }, { name => 'display' } ], output_template => 'Steal: %.2f %%', perfdatas => [ - { label => 'steal', value => 'steal_absolute', template => '%.2f', + { label => 'steal', value => 'steal', template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 }, ], } @@ -172,7 +172,7 @@ sub set_counters { key_values => [ { name => 'system' }, { name => 'display' } ], output_template => 'System: %.2f %%', perfdatas => [ - { label => 'system', value => 'system_absolute', template => '%.2f', + { label => 'system', value => 'system', template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 }, ], } @@ -181,7 +181,7 @@ sub set_counters { key_values => [ { name => 'nice' }, { name => 'display' } ], output_template => 'Nice: %.2f %%', perfdatas => [ - { label => 'nice', value => 'nice_absolute', template => '%.2f', + { label => 'nice', value => 'nice', template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 }, ], } diff --git a/cloud/prometheus/exporters/nodeexporter/mode/load.pm b/cloud/prometheus/exporters/nodeexporter/mode/load.pm index 2f511c482..cde0cf25c 100644 --- a/cloud/prometheus/exporters/nodeexporter/mode/load.pm +++ b/cloud/prometheus/exporters/nodeexporter/mode/load.pm @@ -38,8 +38,8 @@ sub set_counters { output_template => 'Load 1 minute: %.2f', output_change_bytes => 1, perfdatas => [ - { label => 'load1', value => 'load1_absolute', template => '%.2f', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'load1', value => 'load1', template => '%.2f', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -48,8 +48,8 @@ sub set_counters { output_template => 'Load 5 minutes: %.2f', output_change_bytes => 1, perfdatas => [ - { label => 'load5', value => 'load5_absolute', template => '%.2f', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'load5', value => 'load5', template => '%.2f', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -58,8 +58,8 @@ sub set_counters { output_template => 'Load 15 minutes: %.2f', output_change_bytes => 1, perfdatas => [ - { label => 'load15', value => 'load15_absolute', template => '%.2f', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'load15', value => 'load15', template => '%.2f', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/cloud/prometheus/exporters/nodeexporter/mode/memory.pm b/cloud/prometheus/exporters/nodeexporter/mode/memory.pm index 3a0c4ab2b..6fdacbfae 100644 --- a/cloud/prometheus/exporters/nodeexporter/mode/memory.pm +++ b/cloud/prometheus/exporters/nodeexporter/mode/memory.pm @@ -109,8 +109,8 @@ sub set_counters { output_template => 'Buffer: %.2f %s', output_change_bytes => 1, perfdatas => [ - { label => 'buffer', value => 'buffer_absolute', template => '%s', - min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'buffer', value => 'buffer', template => '%s', + min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -119,8 +119,8 @@ sub set_counters { output_template => 'Cached: %.2f %s', output_change_bytes => 1, perfdatas => [ - { label => 'cached', value => 'cached_absolute', template => '%s', - min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'cached', value => 'cached', template => '%s', + min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/cloud/prometheus/restapi/mode/targetstatus.pm b/cloud/prometheus/restapi/mode/targetstatus.pm index 6f6d83ae8..9e48ddc2c 100644 --- a/cloud/prometheus/restapi/mode/targetstatus.pm +++ b/cloud/prometheus/restapi/mode/targetstatus.pm @@ -71,7 +71,7 @@ sub set_counters { key_values => [ { name => 'active' } ], output_template => 'Active: %s', perfdatas => [ - { label => 'active_targets', value => 'active_absolute', template => '%s', + { label => 'active_targets', value => 'active', template => '%s', min => 0 }, ], } @@ -80,7 +80,7 @@ sub set_counters { key_values => [ { name => 'dropped' } ], output_template => 'Dropped: %s', perfdatas => [ - { label => 'dropped_targets', value => 'dropped_absolute', template => '%s', + { label => 'dropped_targets', value => 'dropped', template => '%s', min => 0 }, ], } @@ -89,7 +89,7 @@ sub set_counters { key_values => [ { name => 'up' } ], output_template => 'Up: %s', perfdatas => [ - { label => 'up_targets', value => 'up_absolute', template => '%s', + { label => 'up_targets', value => 'up', template => '%s', min => 0 }, ], } @@ -98,7 +98,7 @@ sub set_counters { key_values => [ { name => 'down' } ], output_template => 'Down: %s', perfdatas => [ - { label => 'down_targets', value => 'down_absolute', template => '%s', + { label => 'down_targets', value => 'down', template => '%s', min => 0 }, ], } @@ -107,7 +107,7 @@ sub set_counters { key_values => [ { name => 'unknown' } ], output_template => 'Unknown: %s', perfdatas => [ - { label => 'unknown_targets', value => 'unknown_absolute', template => '%s', + { label => 'unknown_targets', value => 'unknown', template => '%s', min => 0 }, ], } diff --git a/cloud/vmware/velocloud/restapi/mode/applicationusage.pm b/cloud/vmware/velocloud/restapi/mode/applicationusage.pm index 22d9c7fb7..6ee4f7d92 100644 --- a/cloud/vmware/velocloud/restapi/mode/applicationusage.pm +++ b/cloud/vmware/velocloud/restapi/mode/applicationusage.pm @@ -44,7 +44,7 @@ sub set_counters { output_change_bytes => 2, output_template => 'Traffic In: %s %s/s', perfdatas => [ - { value => 'traffic_in_absolute', template => '%s', + { value => 'traffic_in', template => '%s', min => 0, unit => 'b/s', label_extra_instance => 1 }, ], } @@ -54,7 +54,7 @@ sub set_counters { output_change_bytes => 2, output_template => 'Traffic Out: %s %s/s', perfdatas => [ - { value => 'traffic_out_absolute', template => '%s', + { value => 'traffic_out', template => '%s', min => 0, unit => 'b/s', label_extra_instance => 1 }, ], } @@ -63,7 +63,7 @@ sub set_counters { key_values => [ { name => 'packets_in' }, { name => 'display' }, { name => 'id' } ], output_template => 'Packets In: %.2f packets/s', perfdatas => [ - { value => 'packets_in_absolute', template => '%.2f', + { value => 'packets_in', template => '%.2f', min => 0, unit => 'packets/s', label_extra_instance => 1 }, ], } @@ -72,7 +72,7 @@ sub set_counters { key_values => [ { name => 'packets_out' }, { name => 'display' }, { name => 'id' } ], output_template => 'Packets Out: %.2f packets/s', perfdatas => [ - { value => 'packets_out_absolute', template => '%.2f', + { value => 'packets_out', template => '%.2f', min => 0, unit => 'packets/s', label_extra_instance => 1 }, ], } diff --git a/cloud/vmware/velocloud/restapi/mode/categoryusage.pm b/cloud/vmware/velocloud/restapi/mode/categoryusage.pm index e1ead2619..6759143d7 100644 --- a/cloud/vmware/velocloud/restapi/mode/categoryusage.pm +++ b/cloud/vmware/velocloud/restapi/mode/categoryusage.pm @@ -44,7 +44,7 @@ sub set_counters { output_change_bytes => 2, output_template => 'Traffic In: %s %s/s', perfdatas => [ - { value => 'traffic_in_absolute', template => '%s', + { value => 'traffic_in', template => '%s', min => 0, unit => 'b/s', label_extra_instance => 1 }, ], } @@ -54,7 +54,7 @@ sub set_counters { output_change_bytes => 2, output_template => 'Traffic Out: %s %s/s', perfdatas => [ - { value => 'traffic_out_absolute', template => '%s', + { value => 'traffic_out', template => '%s', min => 0, unit => 'b/s', label_extra_instance => 1 }, ], } @@ -63,7 +63,7 @@ sub set_counters { key_values => [ { name => 'packets_in' }, { name => 'display' }, { name => 'id' } ], output_template => 'Packets In: %.2f packets/s', perfdatas => [ - { value => 'packets_in_absolute', template => '%.2f', + { value => 'packets_in', template => '%.2f', min => 0, unit => 'packets/s', label_extra_instance => 1 }, ], } @@ -72,7 +72,7 @@ sub set_counters { key_values => [ { name => 'packets_out' }, { name => 'display' }, { name => 'id' } ], output_template => 'Packets Out: %.2f packets/s', perfdatas => [ - { value => 'packets_out_absolute', template => '%.2f', + { value => 'packets_out', template => '%.2f', min => 0, unit => 'packets/s', label_extra_instance => 1 }, ], } diff --git a/cloud/vmware/velocloud/restapi/mode/edgeqoe.pm b/cloud/vmware/velocloud/restapi/mode/edgeqoe.pm index 709f4ec46..485c7023f 100644 --- a/cloud/vmware/velocloud/restapi/mode/edgeqoe.pm +++ b/cloud/vmware/velocloud/restapi/mode/edgeqoe.pm @@ -44,7 +44,7 @@ sub set_counters { key_values => [ { name => 'voice' } ], output_template => 'Voice QOE: %s', perfdatas => [ - { value => 'voice_absolute', template => '%s', + { value => 'voice', template => '%s', min => 0, max => 10, label_extra_instance => 1 }, ], } @@ -53,7 +53,7 @@ sub set_counters { key_values => [ { name => 'video' } ], output_template => 'Video QOE: %s', perfdatas => [ - { value => 'video_absolute', template => '%s', + { value => 'video', template => '%s', min => 0, max => 10, label_extra_instance => 1 }, ], } @@ -62,7 +62,7 @@ sub set_counters { key_values => [ { name => 'transactional' } ], output_template => 'Transactional QOE: %s', perfdatas => [ - { value => 'transactional_absolute', template => '%s', + { value => 'transactional', template => '%s', min => 0, max => 10, label_extra_instance => 1 }, ], } @@ -74,7 +74,7 @@ sub set_counters { key_values => [ { name => 'voice' }, { name => 'display' }, { name => 'id' } ], output_template => 'Voice QOE: %s', perfdatas => [ - { value => 'voice_absolute', template => '%s', + { value => 'voice', template => '%s', min => 0, max => 10, label_extra_instance => 1 }, ], } @@ -83,7 +83,7 @@ sub set_counters { key_values => [ { name => 'video' }, { name => 'display' }, { name => 'id' } ], output_template => 'Video QOE: %s', perfdatas => [ - { value => 'video_absolute', template => '%s', + { value => 'video', template => '%s', min => 0, max => 10, label_extra_instance => 1 }, ], } @@ -92,7 +92,7 @@ sub set_counters { key_values => [ { name => 'transactional' }, { name => 'display' }, { name => 'id' } ], output_template => 'Transactional QOE: %s', perfdatas => [ - { value => 'transactional_absolute', template => '%s', + { value => 'transactional', template => '%s', min => 0, max => 10, label_extra_instance => 1 }, ], } diff --git a/cloud/vmware/velocloud/restapi/mode/linkusage.pm b/cloud/vmware/velocloud/restapi/mode/linkusage.pm index e7274f071..b662014f1 100644 --- a/cloud/vmware/velocloud/restapi/mode/linkusage.pm +++ b/cloud/vmware/velocloud/restapi/mode/linkusage.pm @@ -45,7 +45,7 @@ sub set_counters { output_template => 'Total Traffic In: %s %s/s', output_change_bytes => 2, perfdatas => [ - { value => 'traffic_in_absolute', template => '%s', + { value => 'traffic_in', template => '%s', min => 0, unit => 'b/s', label_extra_instance => 1 }, ], } @@ -55,7 +55,7 @@ sub set_counters { output_template => 'Total Traffic Out: %s %s/s', output_change_bytes => 2, perfdatas => [ - { value => 'traffic_out_absolute', template => '%s', + { value => 'traffic_out', template => '%s', min => 0, unit => 'b/s', label_extra_instance => 1 }, ], } @@ -68,7 +68,7 @@ sub set_counters { output_change_bytes => 2, output_template => 'Traffic In: %s %s/s', perfdatas => [ - { value => 'traffic_in_absolute', template => '%s', + { value => 'traffic_in', template => '%s', min => 0, unit => 'b/s', label_extra_instance => 1 }, ], } @@ -78,7 +78,7 @@ sub set_counters { output_change_bytes => 2, output_template => 'Traffic Out: %s %s/s', perfdatas => [ - { value => 'traffic_out_absolute', template => '%s', + { value => 'traffic_out', template => '%s', min => 0, unit => 'b/s', label_extra_instance => 1 }, ], } @@ -87,7 +87,7 @@ sub set_counters { key_values => [ { name => 'latency_in' }, { name => 'display' }, { name => 'id' } ], output_template => 'Latency In: %.2f ms', perfdatas => [ - { value => 'latency_in_absolute', template => '%.2f', + { value => 'latency_in', template => '%.2f', min => 0, unit => 'ms', label_extra_instance => 1 }, ], } @@ -96,7 +96,7 @@ sub set_counters { key_values => [ { name => 'latency_out' }, { name => 'display' }, { name => 'id' } ], output_template => 'Latency Out: %.2f ms', perfdatas => [ - { value => 'latency_out_absolute', template => '%.2f', + { value => 'latency_out', template => '%.2f', min => 0, unit => 'ms', label_extra_instance => 1 }, ], } @@ -105,7 +105,7 @@ sub set_counters { key_values => [ { name => 'jitter_in' }, { name => 'display' }, { name => 'id' } ], output_template => 'Jitter In: %.2f ms', perfdatas => [ - { value => 'jitter_in_absolute', template => '%.2f', + { value => 'jitter_in', template => '%.2f', min => 0, unit => 'ms', label_extra_instance => 1 }, ], } @@ -114,7 +114,7 @@ sub set_counters { key_values => [ { name => 'jitter_out' }, { name => 'display' }, { name => 'id' } ], output_template => 'Jitter Out: %.2f ms', perfdatas => [ - { value => 'jitter_out_absolute', template => '%.2f', + { value => 'jitter_out', template => '%.2f', min => 0, unit => 'ms', label_extra_instance => 1 }, ], } @@ -123,7 +123,7 @@ sub set_counters { key_values => [ { name => 'packet_loss_in' }, { name => 'display' }, { name => 'id' } ], output_template => 'Packet Loss In: %.2f%%', perfdatas => [ - { value => 'packet_loss_in_absolute', template => '%.2f', + { value => 'packet_loss_in', template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 }, ], } @@ -132,7 +132,7 @@ sub set_counters { key_values => [ { name => 'packet_loss_out' }, { name => 'display' }, { name => 'id' } ], output_template => 'Packet Loss Out: %.2f%%', perfdatas => [ - { value => 'packet_loss_out_absolute', template => '%.2f', + { value => 'packet_loss_out', template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 }, ], } diff --git a/database/cassandra/jmx/mode/clientrequestsusage.pm b/database/cassandra/jmx/mode/clientrequestsusage.pm index 878b0f375..9c9da1374 100644 --- a/database/cassandra/jmx/mode/clientrequestsusage.pm +++ b/database/cassandra/jmx/mode/clientrequestsusage.pm @@ -38,8 +38,8 @@ sub set_counters { key_values => [ { name => 'TotalLatency_Count', diff => 1 }, { name => 'display' } ], output_template => 'Total Latency : %s us', perfdatas => [ - { label => 'total_latency', value => 'TotalLatency_Count_absolute', template => '%s', - min => 0, unit => 'us', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'total_latency', value => 'TotalLatency_Count', template => '%s', + min => 0, unit => 'us', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -47,8 +47,8 @@ sub set_counters { key_values => [ { name => 'Timeouts_Count', diff => 1 }, { name => 'display' } ], output_template => 'Timeouts : %s', perfdatas => [ - { label => 'timeouts', value => 'Timeouts_Count_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'timeouts', value => 'Timeouts_Count', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -56,8 +56,8 @@ sub set_counters { key_values => [ { name => 'Unavailables_Count', diff => 1 }, { name => 'display' } ], output_template => 'Unavailables : %s', perfdatas => [ - { label => 'unavailbles', value => 'Unavailables_Count_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'unavailbles', value => 'Unavailables_Count', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -65,8 +65,8 @@ sub set_counters { key_values => [ { name => 'Failures_Count', diff => 1 }, { name => 'display' } ], output_template => 'Failures : %s', perfdatas => [ - { label => 'failures', value => 'Failures_Count_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'failures', value => 'Failures_Count', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/database/cassandra/jmx/mode/threadpoolsusage.pm b/database/cassandra/jmx/mode/threadpoolsusage.pm index ad5c06cf2..16e2cc225 100644 --- a/database/cassandra/jmx/mode/threadpoolsusage.pm +++ b/database/cassandra/jmx/mode/threadpoolsusage.pm @@ -38,8 +38,8 @@ sub set_counters { key_values => [ { name => 'ActiveTasks_Value' }, { name => 'display' } ], output_template => 'Current Active Tasks : %s', perfdatas => [ - { label => 'active_tasks', value => 'ActiveTasks_Value_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'active_tasks', value => 'ActiveTasks_Value', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -47,8 +47,8 @@ sub set_counters { key_values => [ { name => 'PendingTasks_Value' }, { name => 'display' } ], output_template => 'Current Pending Tasks : %s', perfdatas => [ - { label => 'pending_tasks', value => 'PendingTasks_Value_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'pending_tasks', value => 'PendingTasks_Value', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -56,8 +56,8 @@ sub set_counters { key_values => [ { name => 'CompletedTasks_Value', diff => 1 }, { name => 'display' } ], output_template => 'Total Completed Tasks : %s', perfdatas => [ - { label => 'total_completed_tasks', value => 'CompletedTasks_Value_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'total_completed_tasks', value => 'CompletedTasks_Value', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -65,8 +65,8 @@ sub set_counters { key_values => [ { name => 'TotalBlockedTasks_Count', diff => 1 }, { name => 'display' } ], output_template => 'Total Blocked Tasks : %s', perfdatas => [ - { label => 'total_blocked_tasks', value => 'TotalBlockedTasks_Count_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'total_blocked_tasks', value => 'TotalBlockedTasks_Count', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -74,8 +74,8 @@ sub set_counters { key_values => [ { name => 'CurrentlyBlockedTasks_Count', diff => 1 }, { name => 'display' } ], output_template => 'Currently Blocked Tasks : %s', perfdatas => [ - { label => 'current_blocked_tasks', value => 'CurrentlyBlockedTasks_Count_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'current_blocked_tasks', value => 'CurrentlyBlockedTasks_Count', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/database/couchdb/restapi/mode/server.pm b/database/couchdb/restapi/mode/server.pm index 24159549a..0e58d4836 100644 --- a/database/couchdb/restapi/mode/server.pm +++ b/database/couchdb/restapi/mode/server.pm @@ -74,8 +74,8 @@ sub set_counters { output_template => 'live data size: %s %s', output_change_bytes => 1, perfdatas => [ - { value => 'sizes_active_absolute', template => '%d', min => 0, - unit => 'B', label_extra_instance => 1, instance_use => 'display_absolute' } + { value => 'sizes_active', template => '%d', min => 0, + unit => 'B', label_extra_instance => 1, instance_use => 'display' } ], } }, @@ -84,8 +84,8 @@ sub set_counters { output_template => 'file size: %s %s', output_change_bytes => 1, perfdatas => [ - { value => 'sizes_file_absolute', template => '%d', min => 0, - unit => 'B', label_extra_instance => 1, instance_use => 'display_absolute' } + { value => 'sizes_file', template => '%d', min => 0, + unit => 'B', label_extra_instance => 1, instance_use => 'display' } ], } }, @@ -93,8 +93,8 @@ sub set_counters { key_values => [ { name => 'doc_count' }, { name => 'display' } ], output_template => 'number of documents: %s', perfdatas => [ - { value => 'doc_count_absolute', template => '%d', min => 0, - label_extra_instance => 1, instance_use => 'display_absolute' } + { value => 'doc_count', template => '%d', min => 0, + label_extra_instance => 1, instance_use => 'display' } ], } }, @@ -102,8 +102,8 @@ sub set_counters { key_values => [ { name => 'doc_del_count' }, { name => 'display' } ], output_template => 'number of deleted documents: %s', perfdatas => [ - { value => 'doc_del_count_absolute', template => '%d', min => 0, - label_extra_instance => 1, instance_use => 'display_absolute' } + { value => 'doc_del_count', template => '%d', min => 0, + label_extra_instance => 1, instance_use => 'display' } ], } }, diff --git a/database/elasticsearch/restapi/mode/clusterstatistics.pm b/database/elasticsearch/restapi/mode/clusterstatistics.pm index 1e5215f61..8d5c99c3c 100644 --- a/database/elasticsearch/restapi/mode/clusterstatistics.pm +++ b/database/elasticsearch/restapi/mode/clusterstatistics.pm @@ -61,7 +61,7 @@ sub set_counters { key_values => [ { name => 'nodes_total' } ], output_template => 'Nodes: %d', perfdatas => [ - { value => 'nodes_total_absolute', template => '%d', + { value => 'nodes_total', template => '%d', min => 0 }, ], } @@ -70,8 +70,8 @@ sub set_counters { key_values => [ { name => 'nodes_data' }, { name => 'nodes_total' } ], output_template => 'Nodes Data: %d', perfdatas => [ - { value => 'nodes_data_absolute', template => '%d', - min => 0, max => 'nodes_total_absolute' }, + { value => 'nodes_data', template => '%d', + min => 0, max => 'nodes_total' }, ], } }, @@ -79,8 +79,8 @@ sub set_counters { key_values => [ { name => 'nodes_coordinating' }, { name => 'nodes_total' } ], output_template => 'Nodes Coordinating: %d', perfdatas => [ - { value => 'nodes_coordinating_absolute', template => '%d', - min => 0, max => 'nodes_total_absolute' }, + { value => 'nodes_coordinating', template => '%d', + min => 0, max => 'nodes_total' }, ], } }, @@ -88,8 +88,8 @@ sub set_counters { key_values => [ { name => 'nodes_master' }, { name => 'nodes_total' } ], output_template => 'Nodes Master: %d', perfdatas => [ - { value => 'nodes_master_absolute', template => '%d', - min => 0, max => 'nodes_total_absolute' }, + { value => 'nodes_master', template => '%d', + min => 0, max => 'nodes_total' }, ], } }, @@ -97,8 +97,8 @@ sub set_counters { key_values => [ { name => 'nodes_ingest' }, { name => 'nodes_total' } ], output_template => 'Nodes Ingest: %d', perfdatas => [ - { value => 'nodes_ingest_absolute', template => '%d', - min => 0, max => 'nodes_total_absolute' }, + { value => 'nodes_ingest', template => '%d', + min => 0, max => 'nodes_total' }, ], } }, @@ -106,7 +106,7 @@ sub set_counters { key_values => [ { name => 'indices_count' } ], output_template => 'Indices: %d', perfdatas => [ - { value => 'indices_count_absolute', template => '%d', + { value => 'indices_count', template => '%d', min => 0 }, ], } @@ -115,7 +115,7 @@ sub set_counters { key_values => [ { name => 'shards_total' } ], output_template => 'Shards: %d', perfdatas => [ - { value => 'shards_total_absolute', template => '%d', + { value => 'shards_total', template => '%d', min => 0 }, ], } @@ -124,8 +124,8 @@ sub set_counters { key_values => [ { name => 'shards_active' } ], output_template => 'Shards Active: %d', perfdatas => [ - { value => 'shards_active_absolute', template => '%d', - min => 0, max => 'shards_total_absolute' }, + { value => 'shards_active', template => '%d', + min => 0, max => 'shards_total' }, ], } }, @@ -133,7 +133,7 @@ sub set_counters { key_values => [ { name => 'active_shards_percent' } ], output_template => 'Shards Active: %.2f%%', perfdatas => [ - { value => 'active_shards_percent_absolute', template => '%.2f', + { value => 'active_shards_percent', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } @@ -142,8 +142,8 @@ sub set_counters { key_values => [ { name => 'shards_unassigned' }, { name => 'shards_total' } ], output_template => 'Shards Unassigned: %d', perfdatas => [ - { value => 'shards_unassigned_absolute', template => '%d', - min => 0, max => 'shards_total_absolute' }, + { value => 'shards_unassigned', template => '%d', + min => 0, max => 'shards_total' }, ], } }, @@ -151,8 +151,8 @@ sub set_counters { key_values => [ { name => 'shards_relocating' }, { name => 'shards_total' } ], output_template => 'Shards Relocating: %d', perfdatas => [ - { value => 'shards_relocating_absolute', template => '%d', - min => 0, max => 'shards_total_absolute' }, + { value => 'shards_relocating', template => '%d', + min => 0, max => 'shards_total' }, ], } }, @@ -160,8 +160,8 @@ sub set_counters { key_values => [ { name => 'shards_initializing' }, { name => 'shards_total' } ], output_template => 'Shards Initializing: %d', perfdatas => [ - { value => 'shards_initializing_absolute', template => '%d', - min => 0, max => 'shards_total_absolute' }, + { value => 'shards_initializing', template => '%d', + min => 0, max => 'shards_total' }, ], } }, @@ -169,7 +169,7 @@ sub set_counters { key_values => [ { name => 'tasks_pending' } ], output_template => 'Tasks Pending: %d', perfdatas => [ - { value => 'tasks_pending_absolute', template => '%d', + { value => 'tasks_pending', template => '%d', min => 0 }, ], } @@ -178,7 +178,7 @@ sub set_counters { key_values => [ { name => 'docs_count' } ], output_template => 'Documents: %d', perfdatas => [ - { value => 'docs_count_absolute', template => '%d', + { value => 'docs_count', template => '%d', min => 0 }, ], } @@ -188,7 +188,7 @@ sub set_counters { output_template => 'Data: %s%s', output_change_bytes => 1, perfdatas => [ - { value => 'size_in_bytes_absolute', template => '%s', + { value => 'size_in_bytes', template => '%s', min => 0, unit => 'B' }, ], } diff --git a/database/elasticsearch/restapi/mode/indicestatistics.pm b/database/elasticsearch/restapi/mode/indicestatistics.pm index 34d5690b2..ff60fdb99 100644 --- a/database/elasticsearch/restapi/mode/indicestatistics.pm +++ b/database/elasticsearch/restapi/mode/indicestatistics.pm @@ -60,8 +60,8 @@ sub set_counters { key_values => [ { name => 'docs_count' }, { name => 'display' } ], output_template => 'Documents: %d', perfdatas => [ - { value => 'docs_count_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'docs_count', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -70,8 +70,8 @@ sub set_counters { output_template => 'Data Primaries: %s%s', output_change_bytes => 1, perfdatas => [ - { value => 'size_in_bytes_primaries_absolute', template => '%s', - min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'size_in_bytes_primaries', template => '%s', + min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -80,8 +80,8 @@ sub set_counters { output_template => 'Data Total: %s%s', output_change_bytes => 1, perfdatas => [ - { value => 'size_in_bytes_total_absolute', template => '%s', - min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'size_in_bytes_total', template => '%s', + min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -89,8 +89,8 @@ sub set_counters { key_values => [ { name => 'shards_active' }, { name => 'display' } ], output_template => 'Shards Active: %d', perfdatas => [ - { value => 'shards_active_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'shards_active', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -98,8 +98,8 @@ sub set_counters { key_values => [ { name => 'shards_unassigned' }, { name => 'display' } ], output_template => 'Shards Unassigned: %d', perfdatas => [ - { value => 'shards_unassigned_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'shards_unassigned', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/database/elasticsearch/restapi/mode/nodestatistics.pm b/database/elasticsearch/restapi/mode/nodestatistics.pm index bf404f74b..f040bf4b0 100644 --- a/database/elasticsearch/restapi/mode/nodestatistics.pm +++ b/database/elasticsearch/restapi/mode/nodestatistics.pm @@ -38,8 +38,8 @@ sub set_counters { key_values => [ { name => 'heap_used_percent' }, { name => 'display' } ], output_template => 'JVM Heap: %d%%', perfdatas => [ - { value => 'heap_used_percent_absolute', template => '%d', - min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'heap_used_percent', template => '%d', + min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -48,9 +48,9 @@ sub set_counters { output_template => 'JVM Heap Bytes: %s%s', output_change_bytes => 1, perfdatas => [ - { value => 'heap_used_in_bytes_absolute', template => '%s', - min => 0, max => 'heap_max_in_bytes_absolute', unit => 'B', label_extra_instance => 1, - instance_use => 'display_absolute' }, + { value => 'heap_used_in_bytes', template => '%s', + min => 0, max => 'heap_max_in_bytes', unit => 'B', label_extra_instance => 1, + instance_use => 'display' }, ], } }, @@ -60,9 +60,9 @@ sub set_counters { output_template => 'Free Disk Space: %s%s', output_change_bytes => 1, perfdatas => [ - { value => 'available_in_bytes_absolute', template => '%s', - min => 0, max => 'total_in_bytes_absolute', unit => 'B', - label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'available_in_bytes', template => '%s', + min => 0, max => 'total_in_bytes', unit => 'B', + label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -70,8 +70,8 @@ sub set_counters { key_values => [ { name => 'docs_count' }, { name => 'display' } ], output_template => 'Documents: %d', perfdatas => [ - { value => 'docs_count_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'docs_count', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -80,8 +80,8 @@ sub set_counters { output_template => 'Data: %s%s', output_change_bytes => 1, perfdatas => [ - { value => 'size_in_bytes_absolute', template => '%s', - min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'size_in_bytes', template => '%s', + min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/database/firebird/mode/pages.pm b/database/firebird/mode/pages.pm index 6d1600014..0921d6177 100644 --- a/database/firebird/mode/pages.pm +++ b/database/firebird/mode/pages.pm @@ -35,42 +35,34 @@ sub set_counters { $self->{maps_counters}->{global} = [ { label => 'reads', nlabel => 'pages.reads.persecond', set => { - key_values => [ { name => 'reads', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'reads', per_second => 1 } ], output_template => 'Reads : %.2f', perfdatas => [ - { label => 'reads', template => '%.2f', value => 'reads_per_second', - unit => '/s', min => 0 }, + { label => 'reads', template => '%.2f', unit => '/s', min => 0 }, ], } }, { label => 'writes', nlabel => 'pages.writes.persecond', set => { - key_values => [ { name => 'writes', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'writes', per_second => 1 } ], output_template => 'Writes : %.2f', perfdatas => [ - { label => 'writes', template => '%.2f', value => 'writes_per_second', - unit => '/s', min => 0 }, + { label => 'writes', template => '%.2f', unit => '/s', min => 0 }, ], } }, { label => 'fetches', nlabel => 'pages.fetches.persecond', set => { - key_values => [ { name => 'fetches', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'fetches', per_second => 1 } ], output_template => 'Fetches : %.2f', perfdatas => [ - { label => 'fetches', template => '%.2f', value => 'fetches_per_second', - unit => '/s', min => 0 }, + { label => 'fetches', template => '%.2f', unit => '/s', min => 0 }, ], } }, { label => 'marks', nlabel => 'pages.marks.persecond', set => { - key_values => [ { name => 'marks', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'marks', per_second => 1 } ], output_template => 'Marks : %.2f', perfdatas => [ - { label => 'marks', template => '%.2f', value => 'marks_per_second', - unit => '/s', min => 0 }, + { label => 'marks', template => '%.2f', unit => '/s', min => 0 }, ], } }, diff --git a/database/firebird/mode/queries.pm b/database/firebird/mode/queries.pm index a37a8f550..e582e4e38 100644 --- a/database/firebird/mode/queries.pm +++ b/database/firebird/mode/queries.pm @@ -35,82 +35,66 @@ sub set_counters { $self->{maps_counters}->{global} = [ { label => 'total', nlabel => 'queries.total.persecond', set => { - key_values => [ { name => 'total', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'total', per_second => 1 } ], output_template => 'Total : %d', perfdatas => [ - { label => 'total', template => '%d', value => 'total_per_second', - unit => '/s', min => 0 }, + { label => 'total', template => '%d', unit => '/s', min => 0 }, ], } }, { label => 'seq-reads', nlabel => 'queries.sequentialreads.persecond', set => { - key_values => [ { name => 'seq_reads', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'seq_reads', per_second => 1 } ], output_template => 'Seq Reads : %d', perfdatas => [ - { label => 'seq_reads', template => '%d', value => 'seq_reads_per_second', - unit => '/s', min => 0 }, + { label => 'seq_reads', template => '%d', unit => '/s', min => 0 }, ], } }, { label => 'inserts', nlabel => 'queries.insert.persecond', set => { - key_values => [ { name => 'inserts', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'inserts', per_second => 1 } ], output_template => 'Inserts : %d', perfdatas => [ - { label => 'inserts', template => '%d', value => 'inserts_per_second', - unit => '/s', min => 0 }, + { label => 'inserts', template => '%d', unit => '/s', min => 0 }, ], } }, { label => 'updates', nlabel => 'queries.updates.persecond', set => { - key_values => [ { name => 'updates', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'updates', per_second => 1 } ], output_template => 'Updates : %d', perfdatas => [ - { label => 'updates', template => '%d', value => 'updates_per_second', - unit => '/s', min => 0 }, + { label => 'updates', template => '%d', unit => '/s', min => 0 }, ], } }, { label => 'deletes', nlabel => 'queries.deletes.persecond', set => { - key_values => [ { name => 'deletes', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'deletes', per_second => 1 } ], output_template => 'Deletes : %d', perfdatas => [ - { label => 'deletes', template => '%d', value => 'deletes_per_second', - unit => '/s', min => 0 }, + { label => 'deletes', template => '%d', unit => '/s', min => 0 }, ], } }, { label => 'backouts', nlabel => 'queries.backout.persecond', set => { - key_values => [ { name => 'backouts', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'backouts', per_second => 1 } ], output_template => 'Backouts : %d', perfdatas => [ - { label => 'backouts', template => '%d', value => 'backouts_per_second', - unit => '/s', min => 0 }, + { label => 'backouts', template => '%d', unit => '/s', min => 0 }, ], } }, { label => 'purges', nlabel => 'queries.purges.persecond', set => { - key_values => [ { name => 'purges', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'purges', per_second => 1 } ], output_template => 'Purges : %d', perfdatas => [ - { label => 'purges', template => '%d', value => 'purges_per_second', - unit => '/s', min => 0 }, + { label => 'purges', template => '%d', unit => '/s', min => 0 }, ], } }, { label => 'expunges', nlabel => 'queries.expunges.persecond', set => { - key_values => [ { name => 'expunges', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'expunges', per_second => 1 } ], output_template => 'Expunges : %d', perfdatas => [ - { label => 'expunges', template => '%d', value => 'expunges_per_second', - unit => '/s', min => 0 }, + { label => 'expunges', template => '%d', unit => '/s', min => 0 }, ], } }, diff --git a/database/influxdb/mode/connectiontime.pm b/database/influxdb/mode/connectiontime.pm index 36b291870..6cae9f4a5 100644 --- a/database/influxdb/mode/connectiontime.pm +++ b/database/influxdb/mode/connectiontime.pm @@ -38,7 +38,7 @@ sub set_counters { key_values => [ { name => 'connection_time' } ], output_template => 'Connection established in %d ms', perfdatas => [ - { value => 'connection_time_absolute', template => '%d', unit => 'ms', + { value => 'connection_time', template => '%d', unit => 'ms', min => 0 }, ], } diff --git a/database/influxdb/mode/databasestatistics.pm b/database/influxdb/mode/databasestatistics.pm index 1898e6ca4..9c5ac3d02 100644 --- a/database/influxdb/mode/databasestatistics.pm +++ b/database/influxdb/mode/databasestatistics.pm @@ -38,8 +38,8 @@ sub set_counters { key_values => [ { name => 'numMeasurements' }, { name => 'display' } ], output_template => 'Measurements: %s', perfdatas => [ - { value => 'numMeasurements_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'numMeasurements', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -47,8 +47,8 @@ sub set_counters { key_values => [ { name => 'numSeries' }, { name => 'display' } ], output_template => 'Series: %s', perfdatas => [ - { value => 'numSeries_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'numSeries', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/database/influxdb/mode/httpserverstatistics.pm b/database/influxdb/mode/httpserverstatistics.pm index 855f8d324..261e42170 100644 --- a/database/influxdb/mode/httpserverstatistics.pm +++ b/database/influxdb/mode/httpserverstatistics.pm @@ -35,38 +35,34 @@ sub set_counters { $self->{maps_counters}->{global} = [ { label => 'requests-query-count', nlabel => 'requests.query.count.persecond', set => { - key_values => [ { name => 'queryReq', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'queryReq', per_second => 1 } ], output_template => 'Query Requests: %.2f/s', perfdatas => [ - { value => 'queryReq_per_second', template => '%.2f', min => 0 }, + { template => '%.2f', min => 0 }, ], } }, { label => 'requests-write-count', nlabel => 'requests.write.count.persecond', set => { - key_values => [ { name => 'writeReq', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'writeReq', per_second => 1 } ], output_template => 'Write Requests: %.2f/s', perfdatas => [ - { value => 'writeReq_per_second', template => '%.2f', min => 0 }, + { template => '%.2f', min => 0 }, ], } }, { label => 'requests-ping-count', nlabel => 'requests.ping.count.persecond', set => { - key_values => [ { name => 'pingReq', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'pingReq', per_second => 1 } ], output_template => 'Ping Requests: %.2f/s', perfdatas => [ - { value => 'pingReq_per_second', template => '%.2f', min => 0 }, + { template => '%.2f', min => 0 }, ], } }, { label => 'requests-status-count', nlabel => 'requests.status.count.persecond', set => { - key_values => [ { name => 'statusReq', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'statusReq', per_second => 1 } ], output_template => 'Status Requests: %.2f/s', perfdatas => [ - { value => 'statusReq_per_second', template => '%.2f', min => 0 }, + { template => '%.2f', min => 0 }, ], } }, @@ -74,7 +70,7 @@ sub set_counters { key_values => [ { name => 'reqActive' } ], output_template => 'Active Requests: %d', perfdatas => [ - { value => 'reqActive_absolute', template => '%d', min => 0 }, + { template => '%d', min => 0 }, ], } }, @@ -82,48 +78,44 @@ sub set_counters { key_values => [ { name => 'writeReqActive' } ], output_template => 'Active Write Requests: %d', perfdatas => [ - { value => 'writeReqActive_absolute', template => '%d', min => 0 }, + { template => '%d', min => 0 }, ], } }, { label => 'requests-response-data', nlabel => 'requests.response.data.bytes', set => { - key_values => [ { name => 'queryRespBytes', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'queryRespBytes', per_second => 1 } ], output_change_bytes => 1, output_template => 'Response Data: %s%s/s', perfdatas => [ - { value => 'queryRespBytes_per_second', template => '%s', min => 0, unit => 'B/s' }, + { template => '%s', min => 0, unit => 'B/s' }, ], } }, { label => 'requests-write-data', nlabel => 'requests.write.data.bytes', set => { - key_values => [ { name => 'writeReqBytes', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'writeReqBytes', per_second => 1 } ], output_change_bytes => 1, output_template => 'Write Data: %s%s/s', perfdatas => [ - { value => 'writeReqBytes_per_second', template => '%s', min => 0, unit => 'B/s' }, + { template => '%s', min => 0, unit => 'B/s' }, ], } }, { label => 'errors-server', nlabel => 'errors.server.persecond', set => { - key_values => [ { name => 'serverError', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'serverError', per_second => 1 } ], output_template => 'Server Errors: %.2f/s', perfdatas => [ - { value => 'serverError_per_second', template => '%.2f', min => 0 }, + { template => '%.2f', min => 0 }, ], } }, { label => 'errors-client', nlabel => 'errors.client.persecond', set => { - key_values => [ { name => 'clientError', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'clientError', per_second => 1 } ], output_template => 'Client Errors: %.2f/s', perfdatas => [ - { value => 'clientError_per_second', template => '%.2f', min => 0 }, + { template => '%.2f', min => 0 }, ], } - }, + } ]; } diff --git a/database/influxdb/mode/writestatistics.pm b/database/influxdb/mode/writestatistics.pm index 4f02a9b2a..26370dcf0 100644 --- a/database/influxdb/mode/writestatistics.pm +++ b/database/influxdb/mode/writestatistics.pm @@ -35,47 +35,42 @@ sub set_counters { $self->{maps_counters}->{global} = [ { label => 'points-written', nlabel => 'points.written.persecond', set => { - key_values => [ { name => 'pointReq', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'pointReq', per_second => 1 } ], output_template => 'Points Written: %.2f/s', perfdatas => [ - { value => 'pointReq_per_second', template => '%.2f', min => 0 }, + { template => '%.2f', min => 0 }, ], } }, { label => 'writes-ok', nlabel => 'writes.ok.persecond', set => { - key_values => [ { name => 'writeOk', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'writeOk', per_second => 1 } ], output_template => 'Writes Ok: %.2f/s', perfdatas => [ - { value => 'writeOk_per_second', template => '%.2f', min => 0 }, + { template => '%.2f', min => 0 }, ], } }, { label => 'writes-error', nlabel => 'writes.error.persecond', set => { - key_values => [ { name => 'writeError', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'writeError', per_second => 1 } ], output_template => 'Writes Error: %.2f/s', perfdatas => [ - { value => 'writeError_per_second', template => '%.2f', min => 0 }, + { template => '%.2f', min => 0 }, ], } }, { label => 'writes-drop', nlabel => 'writes.drop.persecond', set => { - key_values => [ { name => 'writeDrop', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'writeDrop', per_second => 1 } ], output_template => 'Writes Drop: %.2f/s', perfdatas => [ - { value => 'writeDrop_per_second', template => '%.2f', min => 0 }, + { template => '%.2f', min => 0 }, ], } }, { label => 'writes-timeout', nlabel => 'writes.timeout.persecond', set => { - key_values => [ { name => 'writeTimeout', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'writeTimeout', per_second => 1 } ], output_template => 'Writes Timeout: %.2f/s', perfdatas => [ - { value => 'writeTimeout_per_second', template => '%.2f', min => 0 }, + { template => '%.2f', min => 0 }, ], } }, diff --git a/database/informix/snmp/mode/archivelevel0.pm b/database/informix/snmp/mode/archivelevel0.pm index 729bb77ad..b335e2973 100644 --- a/database/informix/snmp/mode/archivelevel0.pm +++ b/database/informix/snmp/mode/archivelevel0.pm @@ -38,10 +38,10 @@ sub set_counters { { label => 'time', set => { key_values => [ { name => 'seconds' }, { name => 'date'}, { name => 'display' } ], output_template => "archive level0 last execution date '%s'", - output_use => 'date_absolute', + output_use => 'date', perfdatas => [ - { label => 'seconds', value => 'seconds_absolute', template => '%s', min => 0, unit => 's', - label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'seconds', value => 'seconds', template => '%s', min => 0, unit => 's', + label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/database/informix/snmp/mode/dbspaceusage.pm b/database/informix/snmp/mode/dbspaceusage.pm index 054a43fbb..97f092837 100644 --- a/database/informix/snmp/mode/dbspaceusage.pm +++ b/database/informix/snmp/mode/dbspaceusage.pm @@ -37,8 +37,8 @@ sub set_counters { key_values => [ { name => 'prct_used' }, { name => 'display' } ], output_template => 'Used: %.2f%%', perfdatas => [ - { label => 'used', value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, unit => '%', - label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'used', value => 'prct_used', template => '%.2f', min => 0, max => 100, unit => '%', + label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/database/informix/snmp/mode/globalcache.pm b/database/informix/snmp/mode/globalcache.pm index f3394a735..5d372d352 100644 --- a/database/informix/snmp/mode/globalcache.pm +++ b/database/informix/snmp/mode/globalcache.pm @@ -53,7 +53,7 @@ sub set_counters { threshold_use => 'prct', output_use => 'prct', perfdatas => [ { label => 'read', value => 'prct', template => '%.2f', min => 0, max => 100, unit => '%', - label_extra_instance => 1, instance_use => 'display_absolute' }, + label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -64,7 +64,7 @@ sub set_counters { threshold_use => 'prct', output_use => 'prct', perfdatas => [ { label => 'write', value => 'prct', template => '%.2f', min => 0, max => 100, unit => '%', - label_extra_instance => 1, instance_use => 'display_absolute' }, + label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/database/informix/snmp/mode/lockstats.pm b/database/informix/snmp/mode/lockstats.pm index a302da7ec..46a279e2e 100644 --- a/database/informix/snmp/mode/lockstats.pm +++ b/database/informix/snmp/mode/lockstats.pm @@ -38,8 +38,8 @@ sub set_counters { key_values => [ { name => 'onServerDeadLocks', diff => 1 }, { name => 'display' } ], output_template => 'Deadlocks %d', perfdatas => [ - { label => 'lock_dead', value => 'onServerDeadLocks_absolute', template => '%s', min => 0, - label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'lock_dead', value => 'onServerDeadLocks', template => '%s', min => 0, + label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -47,8 +47,8 @@ sub set_counters { key_values => [ { name => 'onServerLockWaits', diff => 1 }, { name => 'display' } ], output_template => 'Lock Waits %d', perfdatas => [ - { label => 'lock_wait', value => 'onServerLockWaits_absolute', template => '%s', min => 0, - label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'lock_wait', value => 'onServerLockWaits', template => '%s', min => 0, + label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -56,8 +56,8 @@ sub set_counters { key_values => [ { name => 'onServerLockRequests', diff => 1 }, { name => 'display' } ], output_template => 'Lock Requests %d', perfdatas => [ - { label => 'lock_request', value => 'onServerLockRequests_absolute', template => '%s', min => 0, - label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'lock_request', value => 'onServerLockRequests', template => '%s', min => 0, + label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -65,8 +65,8 @@ sub set_counters { key_values => [ { name => 'onServerLockTimeouts', diff => 1 }, { name => 'display' } ], output_template => 'Lock Timeouts %d', perfdatas => [ - { label => 'lock_timeout', value => 'onServerLockTimeouts_absolute', template => '%s', min => 0, - label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'lock_timeout', value => 'onServerLockTimeouts', template => '%s', min => 0, + label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/database/informix/snmp/mode/logfileusage.pm b/database/informix/snmp/mode/logfileusage.pm index 8f86139dd..a56f62319 100644 --- a/database/informix/snmp/mode/logfileusage.pm +++ b/database/informix/snmp/mode/logfileusage.pm @@ -37,8 +37,8 @@ sub set_counters { key_values => [ { name => 'prct_used' }, { name => 'display' } ], output_template => 'Log Files Used: %.2f%%', perfdatas => [ - { label => 'used', value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, unit => '%', - label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'used', value => 'prct_used', template => '%.2f', min => 0, max => 100, unit => '%', + label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/database/informix/snmp/mode/sessions.pm b/database/informix/snmp/mode/sessions.pm index eb0c9e062..b0f3dff24 100644 --- a/database/informix/snmp/mode/sessions.pm +++ b/database/informix/snmp/mode/sessions.pm @@ -37,8 +37,8 @@ sub set_counters { key_values => [ { name => 'sessions' }, { name => 'display' } ], output_template => '%d client sessions', perfdatas => [ - { label => 'sessions', value => 'sessions_absolute', template => '%s', min => 0, - label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'sessions', value => 'sessions', template => '%s', min => 0, + label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/database/mongodb/mode/collectionstatistics.pm b/database/mongodb/mode/collectionstatistics.pm index 7f6e54d7f..61377dca4 100644 --- a/database/mongodb/mode/collectionstatistics.pm +++ b/database/mongodb/mode/collectionstatistics.pm @@ -44,7 +44,7 @@ sub set_counters { output_template => 'Storage Size: %s %s', output_change_bytes => 1, perfdatas => [ - { value => 'storageSize_absolute', template => '%s', + { value => 'storageSize', template => '%s', min => 0, unit => 'B', label_extra_instance => 1 }, ], } @@ -54,7 +54,7 @@ sub set_counters { output_template => 'Index Size: %s %s', output_change_bytes => 1, perfdatas => [ - { value => 'totalIndexSize_absolute', template => '%s', + { value => 'totalIndexSize', template => '%s', min => 0, unit => 'B', label_extra_instance => 1 }, ], } @@ -63,7 +63,7 @@ sub set_counters { key_values => [ { name => 'count' }, { name => 'display' } ], output_template => 'Documents: %s', perfdatas => [ - { value => 'count_absolute', template => '%s', + { value => 'count', template => '%s', min => 0, label_extra_instance => 1 }, ], } @@ -72,7 +72,7 @@ sub set_counters { key_values => [ { name => 'nindexes' }, { name => 'display' } ], output_template => 'Indexes: %s', perfdatas => [ - { value => 'nindexes_absolute', template => '%s', + { value => 'nindexes', template => '%s', min => 0, label_extra_instance => 1 }, ], } diff --git a/database/mongodb/mode/connections.pm b/database/mongodb/mode/connections.pm index 54fd88821..69e63448a 100644 --- a/database/mongodb/mode/connections.pm +++ b/database/mongodb/mode/connections.pm @@ -38,7 +38,7 @@ sub set_counters { key_values => [ { name => 'active' } ], output_template => 'Active: %d', perfdatas => [ - { value => 'active_absolute', template => '%d', min => 0, unit => 'conn' }, + { template => '%d', min => 0, unit => 'conn' }, ], } }, @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'current' } ], output_template => 'Current: %d', perfdatas => [ - { value => 'current_absolute', template => '%d', min => 0, unit => 'conn' }, + { template => '%d', min => 0, unit => 'conn' }, ], } }, @@ -54,16 +54,15 @@ sub set_counters { key_values => [ { name => 'usage' } ], output_template => 'Usage: %.2f %%', perfdatas => [ - { value => 'usage_absolute', template => '%.2f', min => 0, max => 100, unit => '%' }, + { template => '%.2f', min => 0, max => 100, unit => '%' }, ], } }, { label => 'total-created', nlabel => 'connections.created.persecond', set => { - key_values => [ { name => 'totalCreated', diff => 1 } ], + key_values => [ { name => 'totalCreated', per_second => 1 } ], output_template => 'Created: %.2f/s', - per_second => 1, perfdatas => [ - { value => 'totalCreated_per_second', template => '%.2f', min => 0, unit => 'conn/s' }, + { template => '%.2f', min => 0, unit => 'conn/s' }, ], } }, diff --git a/database/mongodb/mode/connectiontime.pm b/database/mongodb/mode/connectiontime.pm index fd3dee309..85bffac65 100644 --- a/database/mongodb/mode/connectiontime.pm +++ b/database/mongodb/mode/connectiontime.pm @@ -38,7 +38,7 @@ sub set_counters { key_values => [ { name => 'connection_time' } ], output_template => 'Connection established in %d ms', perfdatas => [ - { value => 'connection_time_absolute', template => '%d', unit => 'ms', + { value => 'connection_time', template => '%d', unit => 'ms', min => 0 }, ], } diff --git a/database/mongodb/mode/databasestatistics.pm b/database/mongodb/mode/databasestatistics.pm index fd10ea8f7..8c4eda3e5 100644 --- a/database/mongodb/mode/databasestatistics.pm +++ b/database/mongodb/mode/databasestatistics.pm @@ -39,8 +39,8 @@ sub set_counters { output_template => 'Storage Size: %s %s', output_change_bytes => 1, perfdatas => [ - { value => 'storageSize_absolute', template => '%s', - min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'storageSize', template => '%s', + min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -49,8 +49,8 @@ sub set_counters { output_template => 'Data Size: %s %s', output_change_bytes => 1, perfdatas => [ - { value => 'dataSize_absolute', template => '%s', - min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'dataSize', template => '%s', + min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -59,8 +59,8 @@ sub set_counters { output_template => 'Index Size: %s %s', output_change_bytes => 1, perfdatas => [ - { value => 'indexSize_absolute', template => '%s', - min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'indexSize', template => '%s', + min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -68,8 +68,8 @@ sub set_counters { key_values => [ { name => 'collections' }, { name => 'display' } ], output_template => 'Collections: %s', perfdatas => [ - { value => 'collections_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'collections', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -77,8 +77,8 @@ sub set_counters { key_values => [ { name => 'views' }, { name => 'display' } ], output_template => 'Views: %s', perfdatas => [ - { value => 'views_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'views', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -86,8 +86,8 @@ sub set_counters { key_values => [ { name => 'documents' }, { name => 'display' } ], output_template => 'Documents: %s', perfdatas => [ - { value => 'documents_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'documents', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -95,8 +95,8 @@ sub set_counters { key_values => [ { name => 'indexes' }, { name => 'display' } ], output_template => 'Indexes: %s', perfdatas => [ - { value => 'indexes_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'indexes', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/database/mongodb/mode/queries.pm b/database/mongodb/mode/queries.pm index fea4d56c0..3ff9af843 100644 --- a/database/mongodb/mode/queries.pm +++ b/database/mongodb/mode/queries.pm @@ -35,11 +35,10 @@ sub set_counters { $self->{maps_counters}->{global} = [ { label => 'total', nlabel => 'queries.total.persecond', set => { - key_values => [ { name => 'total', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'total', per_second => 1 } ], output_template => 'Total : %d', perfdatas => [ - { value => 'total_per_second', template => '%d', unit => '/s', min => 0 }, + { template => '%d', unit => '/s', min => 0 }, ], } }, @@ -48,12 +47,11 @@ sub set_counters { foreach ('insert', 'query', 'update', 'delete', 'getmore', 'command') { push @{$self->{maps_counters}->{global}}, { label => $_, nlabel => 'queries.' . $_ . '.persecond', display_ok => 0, set => { - key_values => [ { name => $_, diff => 1 } ], - per_second => 1, + key_values => [ { name => $_, per_second => 1 } ], output_template => $_ . ' : %.2f', perfdatas => [ - { value => $_ . '_per_second',template => '%.2f', unit => '/s', min => 0 }, - ], + { template => '%.2f', unit => '/s', min => 0 } + ] } }; push @{$self->{maps_counters}->{global}}, { @@ -61,8 +59,8 @@ sub set_counters { key_values => [ { name => $_, diff => 1 } ], output_template => $_ . ' count : %d', perfdatas => [ - { value => $_ . '_absolute', template => '%d', min => 0 }, - ], + { template => '%d', min => 0 } + ] } }; } diff --git a/database/mongodb/mode/replicationstatus.pm b/database/mongodb/mode/replicationstatus.pm index 03ae69a14..cf6bec9cf 100644 --- a/database/mongodb/mode/replicationstatus.pm +++ b/database/mongodb/mode/replicationstatus.pm @@ -108,8 +108,8 @@ sub set_counters { key_values => [ { name => 'lag' }, { name => 'name' } ], output_template => 'Replication Lag: %s s', perfdatas => [ - { value => 'lag_absolute', template => '%d', unit => 's', - min => 0, label_extra_instance => 1, instance_use => 'name_absolute' }, + { value => 'lag', template => '%d', unit => 's', + min => 0, label_extra_instance => 1, instance_use => 'name' }, ], } }, diff --git a/database/mssql/mode/blockedprocesses.pm b/database/mssql/mode/blockedprocesses.pm index 44c0d5cfb..638409996 100644 --- a/database/mssql/mode/blockedprocesses.pm +++ b/database/mssql/mode/blockedprocesses.pm @@ -40,7 +40,7 @@ sub set_counters { key_values => [ { name => 'blocked_processes' } ], output_template => 'Number of blocked processes : %s', perfdatas => [ - { label => 'blocked_processes', value => 'blocked_processes_absolute', template => '%s', + { label => 'blocked_processes', value => 'blocked_processes', template => '%s', unit => '', min => 0 }, ], } diff --git a/database/mssql/mode/pagelifeexpectancy.pm b/database/mssql/mode/pagelifeexpectancy.pm index e70468ce4..4380ba53d 100644 --- a/database/mssql/mode/pagelifeexpectancy.pm +++ b/database/mssql/mode/pagelifeexpectancy.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'page_life_expectancy'}], output_template => 'Page life expectancy : %d second(s)', perfdatas => [ - { value => 'page_life_expectancy_absolute', template => '%d', unit => 's', min => 0 }, + { value => 'page_life_expectancy', template => '%d', unit => 's', min => 0 }, ] }} ]; diff --git a/database/mysql/mode/databasessize.pm b/database/mysql/mode/databasessize.pm index a9cc517e4..270abd318 100644 --- a/database/mysql/mode/databasessize.pm +++ b/database/mysql/mode/databasessize.pm @@ -47,7 +47,7 @@ sub set_counters { output_template => 'Used Space: %s %s', output_change_bytes => 1, perfdatas => [ - { value => 'used_absolute', template => '%s', unit => 'B', + { value => 'used', template => '%s', unit => 'B', min => 0 }, ], } @@ -57,7 +57,7 @@ sub set_counters { output_template => 'Free Space: %s %s', output_change_bytes => 1, perfdatas => [ - { value => 'free_absolute', template => '%s', unit => 'B', + { value => 'free', template => '%s', unit => 'B', min => 0 }, ], } @@ -70,7 +70,7 @@ sub set_counters { output_template => 'Used: %s %s', output_change_bytes => 1, perfdatas => [ - { value => 'used_absolute', template => '%s', unit => 'B', + { value => 'used', template => '%s', unit => 'B', min => 0, label_extra_instance => 1 }, ], } @@ -80,7 +80,7 @@ sub set_counters { output_template => 'Free: %s %s', output_change_bytes => 1, perfdatas => [ - { value => 'free_absolute', template => '%s', unit => 'B', + { value => 'free', template => '%s', unit => 'B', min => 0, label_extra_instance => 1 }, ], } @@ -93,7 +93,7 @@ sub set_counters { output_template => 'Used: %s %s', output_change_bytes => 1, perfdatas => [ - { value => 'used_absolute', template => '%s', unit => 'B', + { value => 'used', template => '%s', unit => 'B', min => 0, label_extra_instance => 1 }, ], } @@ -103,7 +103,7 @@ sub set_counters { output_template => 'Free: %s %s', output_change_bytes => 1, perfdatas => [ - { value => 'free_absolute', template => '%s', unit => 'B', + { value => 'free', template => '%s', unit => 'B', min => 0, label_extra_instance => 1 }, ], } @@ -112,7 +112,7 @@ sub set_counters { key_values => [ { name => 'frag' }, { name => 'display' } ], output_template => 'Fragmentation: %.2f %%', perfdatas => [ - { value => 'frag_absolute', template => '%.2f', unit => '%', + { value => 'frag', template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1 }, ], } diff --git a/database/mysql/mode/queries.pm b/database/mysql/mode/queries.pm index bc154861d..e4bfcfce3 100644 --- a/database/mysql/mode/queries.pm +++ b/database/mysql/mode/queries.pm @@ -35,12 +35,10 @@ sub set_counters { $self->{maps_counters}->{global} = [ { label => 'total', nlabel => 'queries.total.persecond', set => { - key_values => [ { name => 'Queries', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'Queries', per_second => 1 } ], output_template => 'Total : %d', perfdatas => [ - { label => 'total_requests', template => '%d', value => 'Queries_per_second', - unit => '/s', min => 0 }, + { label => 'total_requests', template => '%d', unit => '/s', min => 0 }, ], } }, @@ -49,13 +47,11 @@ sub set_counters { foreach ('update', 'delete', 'insert', 'truncate', 'select', 'commit', 'begin') { push @{$self->{maps_counters}->{global}}, { label => $_, nlabel => 'queries.' . $_ . '.persecond', display_ok => 0, set => { - key_values => [ { name => 'Com_' . $_, diff => 1 } ], - per_second => 1, + key_values => [ { name => 'Com_' . $_, per_second => 1 } ], output_template => $_ . ' : %d', perfdatas => [ - { label => $_ . '_requests', template => '%d', value => 'Com_' . $_ . '_per_second', - unit => '/s', min => 0 }, - ], + { label => $_ . '_requests', template => '%d', unit => '/s', min => 0 } + ] } }; push @{$self->{maps_counters}->{global}}, { @@ -63,9 +59,8 @@ sub set_counters { key_values => [ { name => 'Com_' . $_, diff => 1 } ], output_template => $_ . ' count : %d', perfdatas => [ - { label => $_ . '_count', template => '%d', value => 'Com_' . $_ . '_absolute', - min => 0 }, - ], + { label => $_ . '_count', template => '%d', min => 0 } + ] } }; } diff --git a/database/mysql/mode/threadsconnected.pm b/database/mysql/mode/threadsconnected.pm index 34858d322..6528a1d61 100644 --- a/database/mysql/mode/threadsconnected.pm +++ b/database/mysql/mode/threadsconnected.pm @@ -29,11 +29,11 @@ sub custom_usage_output { my ($self, %options) = @_; my $msg = sprintf("Client Connection Threads Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", - $self->{result_values}->{total_absolute}, - $self->{result_values}->{used_absolute}, - $self->{result_values}->{prct_used_absolute}, - $self->{result_values}->{free_absolute}, - $self->{result_values}->{prct_free_absolute}); + $self->{result_values}->{total}, + $self->{result_values}->{used}, + $self->{result_values}->{prct_used}, + $self->{result_values}->{free}, + $self->{result_values}->{prct_free}); return $msg; } @@ -49,7 +49,7 @@ sub set_counters { key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ - { label => 'threads_connected', value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute' }, + { label => 'threads_connected', value => 'used', template => '%d', min => 0, max => 'total' }, ], } }, @@ -57,7 +57,7 @@ sub set_counters { key_values => [ { name => 'prct_used' } ], output_template => 'Client Connection Threads Used : %.2f %%', perfdatas => [ - { label => 'threads_connected_prct', value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, + { label => 'threads_connected_prct', value => 'prct_used', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } diff --git a/database/oracle/mode/datafilesstatus.pm b/database/oracle/mode/datafilesstatus.pm index 46b8b8fea..36eac375a 100644 --- a/database/oracle/mode/datafilesstatus.pm +++ b/database/oracle/mode/datafilesstatus.pm @@ -69,8 +69,8 @@ sub set_counters { $self->{maps_counters}->{global} = [ { label => 'total-traffic', nlabel => 'datafiles.traffic.io.usage.iops', set => { key_values => [], + manual_keys => 1, closure_custom_calc => $self->can('custom_traffic_calc'), - per_second => 1, manual_keys => 1, threshold_use => 'traffic', output_use => 'traffic', output_template => 'Total Traffic IOPs %.2f', perfdatas => [ @@ -86,7 +86,7 @@ sub set_counters { closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => \&catalog_status_threshold, + closure_custom_threshold_check => \&catalog_status_threshold } }, { label => 'online-status', threshold => 0, set => { @@ -94,7 +94,7 @@ sub set_counters { closure_custom_calc => $self->can('custom_online_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => \&catalog_status_threshold, + closure_custom_threshold_check => \&catalog_status_threshold } }, ]; @@ -133,14 +133,14 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - "filter-tablespace:s" => { name => 'filter_tablespace' }, - "filter-data-file:s" => { name => 'filter_data_file' }, - "warning-status:s" => { name => 'warning_status', default => '' }, - "critical-status:s" => { name => 'critical_status', default => '%{status} =~ /offline|invalid/i' }, - "warning-online-status:s" => { name => 'warning_online_status', default => '%{online_status} =~ /sysoff/i' }, - "critical-online-status:s" => { name => 'critical_online_status', default => '%{online_status} =~ /offline|recover/i' }, + 'filter-tablespace:s' => { name => 'filter_tablespace' }, + 'filter-data-file:s' => { name => 'filter_data_file' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '%{status} =~ /offline|invalid/i' }, + 'warning-online-status:s' => { name => 'warning_online_status', default => '%{online_status} =~ /sysoff/i' }, + 'critical-online-status:s' => { name => 'critical_online_status', default => '%{online_status} =~ /offline|recover/i' } }); - + return $self; } diff --git a/database/oracle/mode/dataguard.pm b/database/oracle/mode/dataguard.pm index 431622058..7cee5e996 100644 --- a/database/oracle/mode/dataguard.pm +++ b/database/oracle/mode/dataguard.pm @@ -81,7 +81,7 @@ sub set_counters { key_values => [ { name => 'lag_minutes' } ], output_template => 'dataguard standby lag %d minutes: %s', perfdatas => [ - { value => 'lag_minutes_absolute', template => '%s', min => 0, unit => 'm' }, + { value => 'lag_minutes', template => '%s', min => 0, unit => 'm' }, ], } }, diff --git a/database/oracle/mode/eventwaitsusage.pm b/database/oracle/mode/eventwaitsusage.pm index a55a1ceeb..5f56f48cd 100644 --- a/database/oracle/mode/eventwaitsusage.pm +++ b/database/oracle/mode/eventwaitsusage.pm @@ -40,25 +40,23 @@ sub set_counters { key_values => [ { name => 'count' } ], output_template => 'Event Wait Count : %s events', perfdatas => [ - { label => 'event_wait_count', value => 'count_absolute', template => '%s', min => 0 } + { label => 'event_wait_count', template => '%s', min => 0 } ], } }, ]; $self->{maps_counters}->{event} = [ { label => 'total-waits-sec', set => { - key_values => [ { name => 'total_waits', diff => 1 }, { name => 'display' } ], - per_second => 1, + key_values => [ { name => 'total_waits', per_second => 1 }, { name => 'display' } ], output_template => 'Total Waits : %.2f/s', perfdatas => [ - { label => 'total_waits', value => 'total_waits_per_second', template => '%.2f', - unit => '/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'total_waits', template => '%.2f', + unit => '/s', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'total-waits-time', set => { key_values => [ { name => 'time_waited_micro', diff => 1 }, { name => 'display' } ], - per_second => 1, closure_custom_calc => $self->can('custom_usage_calc'), output_template => 'Total Waits Time : %.2f %%', output_use => 'prct_wait', threshold_use => 'prct_wait', perfdatas => [ @@ -86,9 +84,9 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - "filter-name:s" => { name => 'filter_name' }, - "wait-time-min:s" => { name => 'wait_time_min', default => 1000 }, - "show-details" => { name => 'show_details' } + 'filter-name:s' => { name => 'filter_name' }, + 'wait-time-min:s' => { name => 'wait_time_min', default => 1000 }, + 'show-details' => { name => 'show_details' } }); return $self; diff --git a/database/oracle/mode/frausage.pm b/database/oracle/mode/frausage.pm index ad50d37f7..f97fdd29b 100644 --- a/database/oracle/mode/frausage.pm +++ b/database/oracle/mode/frausage.pm @@ -37,8 +37,8 @@ sub set_counters { key_values => [ { name => 'percent_space_usage' }, { name => 'display' } ], output_template => 'used : %.2f %%', perfdatas => [ - { value => 'percent_space_usage_absolute', template => '%.2f', min => 0, max => 100, - unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'percent_space_usage', template => '%.2f', min => 0, max => 100, + unit => '%', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -46,8 +46,8 @@ sub set_counters { key_values => [ { name => 'percent_space_reclaimable' }, { name => 'display' } ], output_template => 'reclaimable : %.2f %%', perfdatas => [ - { value => 'percent_space_reclaimable_absolute', template => '%.2f', min => 0, max => 100, - unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'percent_space_reclaimable', template => '%.2f', min => 0, max => 100, + unit => '%', label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/database/oracle/mode/invalidobject.pm b/database/oracle/mode/invalidobject.pm index 10b3626ff..60cac7bee 100644 --- a/database/oracle/mode/invalidobject.pm +++ b/database/oracle/mode/invalidobject.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'invalid_objects' } ], output_template => 'objects : %s', perfdatas => [ - { label => 'invalid_objects', value => 'invalid_objects_absolute', template => '%d', min => 0 }, + { label => 'invalid_objects', value => 'invalid_objects', template => '%d', min => 0 }, ], } }, @@ -45,7 +45,7 @@ sub set_counters { key_values => [ { name => 'invalid_indexes' } ], output_template => 'indexes : %s', perfdatas => [ - { label => 'invalid_indexes', value => 'invalid_indexes_absolute', template => '%d', min => 0 }, + { label => 'invalid_indexes', value => 'invalid_indexes', template => '%d', min => 0 }, ], } }, @@ -53,7 +53,7 @@ sub set_counters { key_values => [ { name => 'invalid_ind_partitions' } ], output_template => 'index partitions : %s', perfdatas => [ - { label => 'invalid_ind_partitions', value => 'invalid_ind_partitions_absolute', template => '%d', min => 0 }, + { label => 'invalid_ind_partitions', value => 'invalid_ind_partitions', template => '%d', min => 0 }, ], } }, @@ -61,7 +61,7 @@ sub set_counters { key_values => [ { name => 'invalid_ind_subpartitions' } ], output_template => 'index subpartitions : %s', perfdatas => [ - { label => 'invalid_ind_subpartitions', value => 'invalid_ind_subpartitions_absolute', template => '%d', min => 0 }, + { label => 'invalid_ind_subpartitions', value => 'invalid_ind_subpartitions', template => '%d', min => 0 }, ], } }, @@ -69,7 +69,7 @@ sub set_counters { key_values => [ { name => 'invalid_registry_components' } ], output_template => 'registry components : %s', perfdatas => [ - { label => 'invalid_registry_components', value => 'invalid_registry_components_absolute', template => '%d', min => 0 }, + { label => 'invalid_registry_components', value => 'invalid_registry_components', template => '%d', min => 0 }, ], } }, diff --git a/database/oracle/mode/librarycacheusage.pm b/database/oracle/mode/librarycacheusage.pm index 684483845..08cf8db4b 100644 --- a/database/oracle/mode/librarycacheusage.pm +++ b/database/oracle/mode/librarycacheusage.pm @@ -75,23 +75,21 @@ sub set_counters { } }, { label => 'reloads', nlabel => 'library.cache.reloads.persecond', set => { - key_values => [ { name => 'reloads', diff => 1 }, ], - per_second => 1, + key_values => [ { name => 'reloads', per_second => 1 }, ], output_template => 'reloads %.2f/s', perfdatas => [ - { label => 'reloads', value => 'reloads_per_second', template => '%.2f', min => 0, unit => '/s' }, + { label => 'reloads', template => '%.2f', min => 0, unit => '/s' }, ], } }, { label => 'invalids', nlabel => 'library.cache.invalids.persecond', set => { - key_values => [ { name => 'invalids', diff => 1 }, ], - per_second => 1, + key_values => [ { name => 'invalids', per_second => 1 }, ], output_template => 'invalids %.2f/s', perfdatas => [ - { label => 'invalids', value => 'invalids_per_second', template => '%.2f', min => 0, unit => '/s' }, + { label => 'invalids', template => '%.2f', min => 0, unit => '/s' }, ], } - }, + } ]; } diff --git a/database/oracle/mode/redologusage.pm b/database/oracle/mode/redologusage.pm index 12109aa1e..3f9ec3fb6 100644 --- a/database/oracle/mode/redologusage.pm +++ b/database/oracle/mode/redologusage.pm @@ -40,7 +40,7 @@ sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ - { name => 'global', cb_prefix_output => 'prefix_global_output', type => 0 }, + { name => 'global', cb_prefix_output => 'prefix_global_output', type => 0 } ]; $self->{maps_counters}->{global} = [ @@ -50,19 +50,19 @@ sub set_counters { output_template => 'retry ratio %.2f%%', output_use => 'retry_ratio', threshold_use => 'retry_ratio', perfdatas => [ - { label => 'retry_ratio', value => 'retry_ratio', template => '%.2f', min => 0, max => 100, unit => '%' }, - ], + { label => 'retry_ratio', value => 'retry_ratio', template => '%.2f', min => 0, max => 100, unit => '%' } + ] } }, { label => 'traffic-io', nlabel => 'redolog.traffic.io.bytespersecond', set => { - key_values => [ { name => 'redo_size', diff => 1 } ], - output_change_bytes => 1, per_second => 1, + key_values => [ { name => 'redo_size', per_second => 1 } ], + output_change_bytes => 1, output_template => 'traffic io %s %s/s', perfdatas => [ - { label => 'traffic_io', value => 'redo_size_per_second', template => '%s', min => 0, unit => 'B/s' }, - ], + { label => 'traffic_io', template => '%s', min => 0, unit => 'B/s' } + ] } - }, + } ]; } diff --git a/database/oracle/mode/rollbacksegmentusage.pm b/database/oracle/mode/rollbacksegmentusage.pm index 515abb564..fd027b4ca 100644 --- a/database/oracle/mode/rollbacksegmentusage.pm +++ b/database/oracle/mode/rollbacksegmentusage.pm @@ -35,22 +35,18 @@ sub set_counters { $self->{maps_counters}->{segment} = [ { label => 'extends', set => { - key_values => [ { name => 'extends', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'extends', per_second => 1 } ], output_template => 'Extends : %.2f/s', perfdatas => [ - { label => 'extends', value => 'extends_per_second', template => '%.2f', - unit => '/s', min => 0 }, + { label => 'extends', template => '%.2f', unit => '/s', min => 0 }, ], } }, { label => 'wraps', set => { - key_values => [ { name => 'wraps', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'wraps', per_second => 1 } ], output_template => 'Wraps : %.2f/s', perfdatas => [ - { label => 'wraps', value => 'wraps_per_second', template => '%.2f', - unit => '/s', min => 0 }, + { label => 'wraps', template => '%.2f', unit => '/s', min => 0 }, ], } }, diff --git a/database/postgres/mode/databasesize.pm b/database/postgres/mode/databasesize.pm index 39f1f80d1..cb077a36a 100644 --- a/database/postgres/mode/databasesize.pm +++ b/database/postgres/mode/databasesize.pm @@ -38,8 +38,8 @@ sub set_counters { output_template => 'size : %s %s', output_change_bytes => 1, perfdatas => [ - { label => 'size', value => 'size_absolute', template => '%s', - min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'size', value => 'size', template => '%s', + min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/database/postgres/mode/statistics.pm b/database/postgres/mode/statistics.pm index c6abe9518..5eda9a284 100644 --- a/database/postgres/mode/statistics.pm +++ b/database/postgres/mode/statistics.pm @@ -39,7 +39,7 @@ sub set_counters { key_values => [ { name => 'commit', diff => 1 } ], output_template => 'Commit : %s', perfdatas => [ - { label => 'commit', value => 'commit_absolute', template => '%s', min => 0 }, + { label => 'commit', value => 'commit', template => '%s', min => 0 }, ], } }, @@ -47,7 +47,7 @@ sub set_counters { key_values => [ { name => 'rollback', diff => 1 } ], output_template => 'Rollback : %s', perfdatas => [ - { label => 'rollback', value => 'rollback_absolute', template => '%s', min => 0 }, + { label => 'rollback', value => 'rollback', template => '%s', min => 0 }, ], } }, @@ -55,7 +55,7 @@ sub set_counters { key_values => [ { name => 'insert', diff => 1 } ], output_template => 'Insert : %s', perfdatas => [ - { label => 'insert', value => 'insert_absolute', template => '%s', min => 0 }, + { label => 'insert', value => 'insert', template => '%s', min => 0 }, ], } }, @@ -63,7 +63,7 @@ sub set_counters { key_values => [ { name => 'update', diff => 1 } ], output_template => 'Update : %s', perfdatas => [ - { label => 'update', value => 'update_absolute', template => '%s', min => 0 }, + { label => 'update', value => 'update', template => '%s', min => 0 }, ], } }, @@ -71,7 +71,7 @@ sub set_counters { key_values => [ { name => 'delete', diff => 1 } ], output_template => 'Delete : %s', perfdatas => [ - { label => 'delete', value => 'delete_absolute', template => '%s', min => 0 }, + { label => 'delete', value => 'delete', template => '%s', min => 0 }, ], } }, @@ -82,8 +82,8 @@ sub set_counters { key_values => [ { name => 'commit', diff => 1 }, { name => 'name' }, ], output_template => 'Commit : %s', perfdatas => [ - { label => 'commit', value => 'commit_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'name_absolute' }, + { label => 'commit', value => 'commit', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'name' }, ], } }, @@ -91,8 +91,8 @@ sub set_counters { key_values => [ { name => 'rollback', diff => 1 }, { name => 'name' }, ], output_template => 'Rollback : %s', perfdatas => [ - { label => 'rollback', value => 'rollback_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'name_absolute' }, + { label => 'rollback', value => 'rollback', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'name' }, ], } }, @@ -100,8 +100,8 @@ sub set_counters { key_values => [ { name => 'insert', diff => 1 }, { name => 'name' }, ], output_template => 'Insert : %s', perfdatas => [ - { label => 'insert', value => 'insert_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'name_absolute' }, + { label => 'insert', value => 'insert', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'name' }, ], } }, @@ -109,8 +109,8 @@ sub set_counters { key_values => [ { name => 'update', diff => 1 }, { name => 'name' }, ], output_template => 'Update : %s', perfdatas => [ - { label => 'update', value => 'update_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'name_absolute' }, + { label => 'update', value => 'update', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'name' }, ], } }, @@ -118,8 +118,8 @@ sub set_counters { key_values => [ { name => 'delete', diff => 1 }, { name => 'name' }, ], output_template => 'Delete : %s', perfdatas => [ - { label => 'delete', value => 'delete_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'name_absolute' }, + { label => 'delete', value => 'delete', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'name' }, ], } }, diff --git a/database/sap/hana/mode/blockedtransactions.pm b/database/sap/hana/mode/blockedtransactions.pm index bf74f7c25..055464492 100644 --- a/database/sap/hana/mode/blockedtransactions.pm +++ b/database/sap/hana/mode/blockedtransactions.pm @@ -36,7 +36,7 @@ sub set_counters { key_values => [ { name => 'total' } ], output_template => 'Current Total Blocked Transactions : %s', perfdatas => [ - { label => 'total_blocked_transactions', value => 'total_absolute', template => '%s', min => 0 }, + { label => 'total_blocked_transactions', value => 'total', template => '%s', min => 0 }, ], } }, diff --git a/database/sap/hana/mode/connectedusers.pm b/database/sap/hana/mode/connectedusers.pm index f3bcc22e4..55726a002 100644 --- a/database/sap/hana/mode/connectedusers.pm +++ b/database/sap/hana/mode/connectedusers.pm @@ -36,8 +36,8 @@ sub set_counters { key_values => [ { name => 'total' }, { name => 'display' } ], output_template => 'Connected Users : %s', perfdatas => [ - { label => 'users', value => 'total_absolute', template => '%s', min => 0, - label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'users', value => 'total', template => '%s', min => 0, + label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/database/sap/hana/mode/hostcpu.pm b/database/sap/hana/mode/hostcpu.pm index e0d821f9f..978b6a60c 100644 --- a/database/sap/hana/mode/hostcpu.pm +++ b/database/sap/hana/mode/hostcpu.pm @@ -39,7 +39,7 @@ sub set_counters { output_template => 'User %.2f %%', output_use => 'user_prct', threshold_use => 'user_prct', perfdatas => [ { label => 'user', value => 'user_prct', template => '%.2f', min => 0, max => 100, unit => '%', - label_extra_instance => 1, instance_use => 'display_absolute' }, + label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -49,7 +49,7 @@ sub set_counters { output_template => 'System %.2f %%', output_use => 'sys_prct', threshold_use => 'sys_prct', perfdatas => [ { label => 'sys', value => 'sys_prct', template => '%.2f', min => 0, max => 100, unit => '%', - label_extra_instance => 1, instance_use => 'display_absolute' }, + label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -59,7 +59,7 @@ sub set_counters { output_template => 'Wait %.2f %%', output_use => 'wait_prct', threshold_use => 'wait_prct', perfdatas => [ { label => 'wait', value => 'wait_prct', template => '%.2f', min => 0, max => 100, unit => '%', - label_extra_instance => 1, instance_use => 'display_absolute' }, + label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -69,7 +69,7 @@ sub set_counters { output_template => 'Idle %.2f %%', output_use => 'idle_prct', threshold_use => 'idle_prct', perfdatas => [ { label => 'idle', value => 'idle_prct', template => '%.2f', min => 0, max => 100, unit => '%', - label_extra_instance => 1, instance_use => 'display_absolute' }, + label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/database/warp10/sensision/mode/fetchstatistics.pm b/database/warp10/sensision/mode/fetchstatistics.pm index dea0bf039..c4f841404 100644 --- a/database/warp10/sensision/mode/fetchstatistics.pm +++ b/database/warp10/sensision/mode/fetchstatistics.pm @@ -40,18 +40,15 @@ sub set_counters { key_values => [ { name => 'calls', diff => 1 }, { name => 'display' } ], output_template => 'Calls: %d', perfdatas => [ - { value => 'calls_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'calls-persecond', nlabel => 'fetch.calls.persecond', set => { - key_values => [ { name => 'calls', diff => 1 }, { name => 'display' } ], - per_second => 1, + key_values => [ { name => 'calls', per_second => 1 }, { name => 'display' } ], output_template => 'Calls (per second): %.2f', perfdatas => [ - { value => 'calls_per_second', template => '%.2f', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { template => '%.2f', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -60,18 +57,16 @@ sub set_counters { output_template => 'Bytes Values: %s%s', output_change_bytes => 1, perfdatas => [ - { value => 'bytes_values_absolute', template => '%s', - min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'display_absolute' }, + { template => '%s', min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'bytes-values-persecond', nlabel => 'fetch.bytes.values.bytespersecond', set => { - key_values => [ { name => 'bytes_values', diff => 1 }, { name => 'display' } ], - output_change_bytes => 1, per_second => 1, + key_values => [ { name => 'bytes_values', per_second => 1 }, { name => 'display' } ], + output_change_bytes => 1, output_template => 'Bytes Values (per second): %s%s/s', perfdatas => [ - { value => 'bytes_values_per_second', template => '%s', - min => 0, unit => 'B/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { template => '%s', min => 0, unit => 'B/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -80,18 +75,16 @@ sub set_counters { output_template => 'Bytes Keys: %s%s', output_change_bytes => 1, perfdatas => [ - { value => 'bytes_keys_absolute', template => '%s', - min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'display_absolute' }, + { template => '%s', min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'bytes-keys-persecond', nlabel => 'fetch.bytes.keys.bytespersecond', set => { - key_values => [ { name => 'bytes_keys', diff => 1 }, { name => 'display' } ], - output_change_bytes => 1, per_second => 1, + key_values => [ { name => 'bytes_keys', per_second => 1 }, { name => 'display' } ], + output_change_bytes => 1, output_template => 'Bytes Keys (per second): %s%s/s', perfdatas => [ - { value => 'bytes_keys_per_second', template => '%s', - min => 0, unit => 'B/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { template => '%s', min => 0, unit => 'B/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -99,18 +92,15 @@ sub set_counters { key_values => [ { name => 'datapoints', diff => 1 }, { name => 'display' } ], output_template => 'Datapoints: %d', perfdatas => [ - { value => 'datapoints_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'datapoints-persecond', nlabel => 'fetch.datapoints.persecond', set => { - key_values => [ { name => 'datapoints', diff => 1 }, { name => 'display' } ], - per_second => 1, + key_values => [ { name => 'datapoints', per_second => 1 }, { name => 'display' } ], output_template => 'Datapoints (per second): %.2f', perfdatas => [ - { value => 'datapoints_per_second', template => '%.2f', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { template => '%.2f', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -129,9 +119,9 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - "filter-name:s" => { name => 'filter_name' }, + 'filter-name:s' => { name => 'filter_name' } }); - + return $self; } diff --git a/database/warp10/sensision/mode/scriptstatistics.pm b/database/warp10/sensision/mode/scriptstatistics.pm index 3b2e8059c..736f73a0e 100644 --- a/database/warp10/sensision/mode/scriptstatistics.pm +++ b/database/warp10/sensision/mode/scriptstatistics.pm @@ -41,8 +41,7 @@ sub set_counters { key_values => [ { name => 'time', diff => 1 } ], output_template => 'Time Spent: %d us', perfdatas => [ - { value => 'time_absolute', template => '%d', - min => 0, unit => 'us' }, + { template => '%d', min => 0, unit => 'us' }, ], } }, @@ -50,18 +49,15 @@ sub set_counters { key_values => [ { name => 'requests', diff => 1 } ], output_template => 'Requests: %d', perfdatas => [ - { value => 'requests_absolute', template => '%d', - min => 0 }, + { template => '%d', min => 0 }, ], } }, { label => 'requests-persecond', nlabel => 'requests.persecond', set => { - key_values => [ { name => 'requests', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'requests', per_second => 1 } ], output_template => 'Requests (per second): %.2f', perfdatas => [ - { value => 'requests_per_second', template => '%.2f', - min => 0 }, + { template => '%.2f', min => 0 }, ], } }, @@ -69,18 +65,15 @@ sub set_counters { key_values => [ { name => 'ops', diff => 1 } ], output_template => 'Ops: %d', perfdatas => [ - { value => 'ops_absolute', template => '%d', - min => 0 }, + { template => '%d', min => 0 }, ], } }, { label => 'ops-persecond', nlabel => 'ops.persecond', set => { - key_values => [ { name => 'ops', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'ops', per_second => 1 } ], output_template => 'Ops (per second): %.2f', perfdatas => [ - { value => 'ops_per_second', template => '%.2f', - min => 0 }, + { template => '%.2f', min => 0 }, ], } }, @@ -88,18 +81,15 @@ sub set_counters { key_values => [ { name => 'errors', diff => 1 } ], output_template => 'Errors: %d', perfdatas => [ - { value => 'errors_absolute', template => '%d', - min => 0 }, + { template => '%d', min => 0 }, ], } }, { label => 'errors-persecond', nlabel => 'errors.persecond', set => { - key_values => [ { name => 'errors', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'errors', per_second => 1 } ], output_template => 'Errors (per second): %.2f', perfdatas => [ - { value => 'errors_per_second', template => '%.2f', - min => 0 }, + { template => '%.2f', min => 0 }, ], } }, @@ -107,29 +97,26 @@ sub set_counters { key_values => [ { name => 'bootstrap_loads', diff => 1 } ], output_template => 'Bootstrap Loads: %d', perfdatas => [ - { value => 'bootstrap_loads_absolute', template => '%d', - min => 0 }, + { template => '%d', min => 0 }, ], } }, { label => 'bootstrap-loads-persecond', nlabel => 'bootstrap.loads.persecond', set => { - key_values => [ { name => 'bootstrap_loads', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'bootstrap_loads', per_second => 1 } ], output_template => 'Bootstrap Loads (per second): %.2f', perfdatas => [ - { value => 'bootstrap_loads_per_second', template => '%.2f', - min => 0 }, + { template => '%.2f', min => 0 }, ], } }, ]; + $self->{maps_counters}->{functions} = [ { label => 'time', nlabel => 'function.time.microseconds', set => { key_values => [ { name => 'time', diff => 1 }, { name => 'display' } ], output_template => 'Time Spent: %d us', perfdatas => [ - { value => 'time_absolute', template => '%d', - min => 0, unit => 'us', label_extra_instance => 1, instance_use => 'display_absolute' }, + { template => '%d', min => 0, unit => 'us', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -137,21 +124,18 @@ sub set_counters { key_values => [ { name => 'count', diff => 1 }, { name => 'display' } ], output_template => 'Uses: %d', perfdatas => [ - { value => 'count_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'uses-persecond', nlabel => 'function.uses.persecond', set => { - key_values => [ { name => 'count', diff => 1 }, { name => 'display' } ], - per_second => 1, + key_values => [ { name => 'count', per_second => 1 }, { name => 'display' } ], output_template => 'Uses (per second): %.2f', perfdatas => [ - { value => 'count_per_second', template => '%.2f', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { template => '%.2f', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } - }, + } ]; } @@ -167,7 +151,7 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - "filter-name:s" => { name => 'filter_name' }, + 'filter-name:s' => { name => 'filter_name' } }); return $self; diff --git a/docs/en/developer/guide.rst b/docs/en/developer/guide.rst index 9eec3f5e8..aa886a646 100644 --- a/docs/en/developer/guide.rst +++ b/docs/en/developer/guide.rst @@ -108,11 +108,11 @@ Several modes can be declared in the **new** constructor: .. code-block:: perl - %{$self->{modes}} = ( - 'mode1' => '::mode::mode1', - 'mode2' => '::mode::mode2', - ... - ); + $self->{modes} = { + 'mode1' => '::mode::mode1', + 'mode2' => '::mode::mode2', + ... + }; Then, declare the module: @@ -194,12 +194,11 @@ Several options can be declared in the **new** constructor: .. code-block:: perl - $options{options}->add_options(arguments => - { - "option1:s" => { name => 'option1' }, - "option2:s" => { name => 'option2', default => 'value1' }, - "option3" => { name => 'option3' }, - }); + $options{options}->add_options(arguments => { + "option1:s" => { name => 'option1' }, + "option2:s" => { name => 'option2', default => 'value1' }, + "option3" => { name => 'option3' }, + }); Here is the description of arguments used in this example: @@ -1939,8 +1938,7 @@ We want to develop the following SNMP plugin: key_values => [ { name => 'sessions' } ], output_template => 'Current sessions : %s', perfdatas => [ - { label => 'sessions', value => 'sessions_absolute', template => '%s', - min => 0 }, + { label => 'sessions', template => '%s', min => 0 }, ], } }, @@ -1948,8 +1946,7 @@ We want to develop the following SNMP plugin: key_values => [ { name => 'sessions_ssl' } ], output_template => 'Current ssl sessions : %s', perfdatas => [ - { label => 'sessions_ssl', value => 'sessions_ssl_absolute', template => '%s', - min => 0 }, + { label => 'sessions_ssl', template => '%s', min => 0 }, ], } }, @@ -1962,11 +1959,14 @@ We want to develop the following SNMP plugin: # OIDs are fake. Only for the example. my ($oid_sessions, $oid_sessions_ssl) = ('.1.2.3.4.0', '.1.2.3.5.0'); - my $result = $options{snmp}->get_leef(oids => [ $oid_sessions, $oid_sessions_ssl ], - nothing_quit => 1); - $self->{global} = { sessions => $result->{$oid_sessions}, - sessions_ssl => $result->{$oid_sessions_ssl} - }; + my $result = $options{snmp}->get_leef( + oids => [ $oid_sessions, $oid_sessions_ssl ], + nothing_quit => 1 + ); + $self->{global} = { + sessions => $result->{$oid_sessions}, + sessions_ssl => $result->{$oid_sessions_ssl} + }; } @@ -1996,15 +1996,15 @@ As you can see, we create two arrays of hash tables in **set_counters** method. * *name*: attribute name. Need to match with attributes in **manage_selection** method! * *diff*: if we set the value to 1, we'll have the difference between two checks (need a statefile!). + * *per_second*: if we set the value to 1, the *diff* values will be calculated per seconds (need a statefile!). No need to add diff attribute. * *output_template*: string to display. '%s' will be replaced by the first value of *keys_values*. * *output_use*: which value to be used in *output_template* (If not set, we use the first value of *keys_values*). - * *per_second*: if we set the value to 1, the *diff* values will be calculated per seconds. * *output_change_bytes*: if we set the value to 1 or 2, we can use a second '%s' in *output_template* to display the unit. 1 = divide by 1024 (Bytes), 2 = divide by 1000 (bits). * *perfdata*: array of hashes. To configure perfdatas * *label*: name displayed. - * *value*: value to used. It's the name from *keys_values* with a **suffix**: '_absolute' or '_per_second' (depends of other options). + * *value*: value to used. It's the name from *keys_values*. * *template*: value format (could be for example: '%.3f'). * *unit*: unit displayed. * *min*, *max*: min and max displayed. You can use a value from *keys_values*. @@ -2037,8 +2037,7 @@ We want to add the current number of sessions by virtual servers. key_values => [ { name => 'sessions' } ], output_template => 'current sessions : %s', perfdatas => [ - { label => 'total_sessions', value => 'sessions_absolute', template => '%s', - min => 0 }, + { label => 'total_sessions', template => '%s', min => 0 }, ], } }, @@ -2046,8 +2045,7 @@ We want to add the current number of sessions by virtual servers. key_values => [ { name => 'sessions_ssl' } ], output_template => 'current ssl sessions : %s', perfdatas => [ - { label => 'total_sessions_ssl', value => 'sessions_ssl_absolute', template => '%s', - min => 0 }, + { label => 'total_sessions_ssl', template => '%s', min => 0 }, ], } }, @@ -2058,8 +2056,8 @@ We want to add the current number of sessions by virtual servers. key_values => [ { name => 'sessions' }, { name => 'display' } ], output_template => 'current sessions : %s', perfdatas => [ - { label => 'sessions', value => 'sessions_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'sessions', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -2067,8 +2065,8 @@ We want to add the current number of sessions by virtual servers. key_values => [ { name => 'sessions_ssl' }, { name => 'display' } ], output_template => 'current ssl sessions : %s', perfdatas => [ - { label => 'sessions_ssl', value => 'sessions_ssl_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'sessions_ssl', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -2151,9 +2149,9 @@ The model can also be used to check strings (not only counters). So we want to c closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => $self->can('custom_threshold_output'), + closure_custom_threshold_check => $self->can('custom_threshold_output') } - }, + } ]; } @@ -2219,7 +2217,7 @@ The model can also be used to check strings (not only counters). So we want to c The following example show 4 new attributes: -* *closure_custom_calc*: should be used to have a simple name (without '_absolute' or '_per_second'). Or to do some more complex calculation. +* *closure_custom_calc*: should be used to do more complex calculation. * *closure_custom_output*: should be used to have a more complex output (An example: want to display the total, free and used value at the same time). * *closure_custom_perfdata*: should be used to manage yourself the perfdata. * *closure_custom_threshold_check*: should be used to manage yourself the threshold check. diff --git a/hardware/ats/apc/snmp/mode/inputlines.pm b/hardware/ats/apc/snmp/mode/inputlines.pm index e56ec7c4f..de361a56a 100644 --- a/hardware/ats/apc/snmp/mode/inputlines.pm +++ b/hardware/ats/apc/snmp/mode/inputlines.pm @@ -37,8 +37,8 @@ sub set_counters { key_values => [ { name => 'atsInputVoltage' }, { name => 'display' } ], output_template => 'Voltage : %.2f V', perfdatas => [ - { label => 'voltage', value => 'atsInputVoltage_absolute', template => '%s', - unit => 'V', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'voltage', value => 'atsInputVoltage', template => '%s', + unit => 'V', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -46,8 +46,8 @@ sub set_counters { key_values => [ { name => 'atsInputCurrent' }, { name => 'display' } ], output_template => 'Current : %.2f A', perfdatas => [ - { label => 'current', value => 'atsInputCurrent_absolute', template => '%s', - unit => 'A', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'current', value => 'atsInputCurrent', template => '%s', + unit => 'A', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -55,8 +55,8 @@ sub set_counters { key_values => [ { name => 'atsInputPower' }, { name => 'display' } ], output_template => 'Power : %.2f W', perfdatas => [ - { label => 'power', value => 'atsInputPower_absolute', template => '%s', - unit => 'W', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'power', value => 'atsInputPower', template => '%s', + unit => 'W', label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/hardware/ats/apc/snmp/mode/outputlines.pm b/hardware/ats/apc/snmp/mode/outputlines.pm index f14c23c7f..faa9809a2 100644 --- a/hardware/ats/apc/snmp/mode/outputlines.pm +++ b/hardware/ats/apc/snmp/mode/outputlines.pm @@ -46,8 +46,8 @@ sub set_counters { key_values => [ { name => 'atsOutputVoltage' }, { name => 'display' } ], output_template => 'Voltage : %.2f V', perfdatas => [ - { label => 'voltage', value => 'atsOutputVoltage_absolute', template => '%s', - unit => 'V', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'voltage', value => 'atsOutputVoltage', template => '%s', + unit => 'V', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -55,8 +55,8 @@ sub set_counters { key_values => [ { name => 'atsOutputCurrent' }, { name => 'display' } ], output_template => 'Current : %.2f A', perfdatas => [ - { label => 'current', value => 'atsOutputCurrent_absolute', template => '%s', - unit => 'A', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'current', value => 'atsOutputCurrent', template => '%s', + unit => 'A', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -64,8 +64,8 @@ sub set_counters { key_values => [ { name => 'atsOutputPower' }, { name => 'display' } ], output_template => 'Power : %.2f W', perfdatas => [ - { label => 'power', value => 'atsOutputPower_absolute', template => '%s', - unit => 'W', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'power', value => 'atsOutputPower', template => '%s', + unit => 'W', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -73,8 +73,8 @@ sub set_counters { key_values => [ { name => 'atsOutputLoad' }, { name => 'display' } ], output_template => 'Load : %.2f VA', perfdatas => [ - { label => 'load', value => 'atsOutputLoad_absolute', template => '%s', - unit => 'VA', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'load', value => 'atsOutputLoad', template => '%s', + unit => 'VA', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -82,8 +82,8 @@ sub set_counters { key_values => [ { name => 'atsOutputPercentLoad' }, { name => 'display' } ], output_template => 'Load capacity : %.2f %%', perfdatas => [ - { label => 'load_capacity', value => 'atsOutputPercentLoad_absolute', template => '%s', - unit => '%', label_extra_instance => 1, instance_use => 'display_absolute', min => 0, max => 100 }, + { label => 'load_capacity', value => 'atsOutputPercentLoad', template => '%s', + unit => '%', label_extra_instance => 1, instance_use => 'display', min => 0, max => 100 }, ], } }, diff --git a/hardware/ats/eaton/snmp/mode/inputlines.pm b/hardware/ats/eaton/snmp/mode/inputlines.pm index 64f6fd22a..af50035f0 100644 --- a/hardware/ats/eaton/snmp/mode/inputlines.pm +++ b/hardware/ats/eaton/snmp/mode/inputlines.pm @@ -37,8 +37,8 @@ sub set_counters { key_values => [ { name => 'voltage' }, { name => 'display' } ], output_template => 'Voltage : %.2f V', perfdatas => [ - { value => 'voltage_absolute', template => '%s', - unit => 'V', label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'voltage', template => '%s', + unit => 'V', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'frequency', no_value => -1 } ], output_template => 'Frequence : %.2f Hz', perfdatas => [ - { value => 'frequency_absolute', template => '%.2f', + { value => 'frequency', template => '%.2f', unit => 'Hz', label_extra_instance => 1 }, ], } diff --git a/hardware/ats/eaton/snmp/mode/outputline.pm b/hardware/ats/eaton/snmp/mode/outputline.pm index 6ad484216..2d3449afa 100644 --- a/hardware/ats/eaton/snmp/mode/outputline.pm +++ b/hardware/ats/eaton/snmp/mode/outputline.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'voltage' } ], output_template => 'Voltage : %.2f V', perfdatas => [ - { value => 'voltage_absolute', template => '%s', + { value => 'voltage', template => '%s', unit => 'V' }, ], } @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'current' } ], output_template => 'current : %s A', perfdatas => [ - { template => '%s', value => 'current_absolute', + { template => '%s', value => 'current', unit => 'A', min => 0 }, ], } diff --git a/hardware/ats/eaton/snmp/mode/system.pm b/hardware/ats/eaton/snmp/mode/system.pm index 6e0d36422..246aa1b63 100644 --- a/hardware/ats/eaton/snmp/mode/system.pm +++ b/hardware/ats/eaton/snmp/mode/system.pm @@ -60,7 +60,7 @@ sub set_counters { key_values => [ { name => 'temperature' } ], output_template => 'temperature : %s C', perfdatas => [ - { label => 'temperature', value => 'temperature_absolute', template => '%s', + { label => 'temperature', value => 'temperature', template => '%s', unit => 'C' }, ], } @@ -69,7 +69,7 @@ sub set_counters { key_values => [ { name => 'humidity' } ], output_template => 'humidity : %s %%', perfdatas => [ - { label => 'humidity', value => 'humidity_absolute', template => '%s', + { label => 'humidity', value => 'humidity', template => '%s', unit => '%', min => 9, max => 100 }, ], } diff --git a/hardware/devices/abb/cms700/snmp/mode/mainsmeasurements.pm b/hardware/devices/abb/cms700/snmp/mode/mainsmeasurements.pm index ca5ed8aea..f41f00074 100644 --- a/hardware/devices/abb/cms700/snmp/mode/mainsmeasurements.pm +++ b/hardware/devices/abb/cms700/snmp/mode/mainsmeasurements.pm @@ -45,7 +45,7 @@ sub set_counters { key_values => [ { name => 'p3' } ], output_template => 'Active Power: %.2f W', perfdatas => [ - { value => 'p3_absolute', template => '%.2f', unit => 'W', min => 0 }, + { value => 'p3', template => '%.2f', unit => 'W', min => 0 }, ], } }, @@ -53,7 +53,7 @@ sub set_counters { key_values => [ { name => 'q3' } ], output_template => 'Reactive Power: %.2f VAR', perfdatas => [ - { value => 'q3_absolute', template => '%.2f', unit => 'VAR', min => 0 }, + { value => 'q3', template => '%.2f', unit => 'VAR', min => 0 }, ], } }, @@ -61,7 +61,7 @@ sub set_counters { key_values => [ { name => 's3' } ], output_template => 'Apparent Power: %.2f VA', perfdatas => [ - { value => 's3_absolute', template => '%.2f', unit => 'VA', min => 0 }, + { value => 's3', template => '%.2f', unit => 'VA', min => 0 }, ], } }, @@ -72,8 +72,8 @@ sub set_counters { key_values => [ { name => 'uL' }, { name => 'display' } ], output_template => 'Voltage: %.2f V', perfdatas => [ - { value => 'uL_absolute', template => '%.2f', unit => 'V', min => 0, - label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'uL', template => '%.2f', unit => 'V', min => 0, + label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -81,8 +81,8 @@ sub set_counters { key_values => [ { name => 'iL' }, { name => 'display' } ], output_template => 'Current: %.2f A', perfdatas => [ - { value => 'iL_absolute', template => '%.2f', unit => 'A', min => 0, - label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'iL', template => '%.2f', unit => 'A', min => 0, + label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -90,8 +90,8 @@ sub set_counters { key_values => [ { name => 'pfL' }, { name => 'display' } ], output_template => 'Power Factor: %.2f', perfdatas => [ - { value => 'pfL_absolute', template => '%.2f', min => 0, max => 1, - label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'pfL', template => '%.2f', min => 0, max => 1, + label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -99,8 +99,8 @@ sub set_counters { key_values => [ { name => 'cosP' }, { name => 'display' } ], output_template => 'Cos Phi: %.2f', perfdatas => [ - { value => 'cosP_absolute', template => '%.2f', min => 0, max => 1, - label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'cosP', template => '%.2f', min => 0, max => 1, + label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -108,8 +108,8 @@ sub set_counters { key_values => [ { name => 'pL' }, { name => 'display' } ], output_template => 'Active Power: %.2f W', perfdatas => [ - { value => 'pL_absolute', template => '%.2f', unit => 'W', min => 0, - label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'pL', template => '%.2f', unit => 'W', min => 0, + label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -117,8 +117,8 @@ sub set_counters { key_values => [ { name => 'qL' }, { name => 'display' } ], output_template => 'Reactive Power: %.2f VAR', perfdatas => [ - { value => 'qL_absolute', template => '%.2f', unit => 'VAR', min => 0, - label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'qL', template => '%.2f', unit => 'VAR', min => 0, + label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -126,8 +126,8 @@ sub set_counters { key_values => [ { name => 'sL' }, { name => 'display' } ], output_template => 'Apparent Power: %.2f VA', perfdatas => [ - { value => 'sL_absolute', template => '%.2f', unit => 'VA', min => 0, - label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'sL', template => '%.2f', unit => 'VA', min => 0, + label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -135,8 +135,8 @@ sub set_counters { key_values => [ { name => 'whL' }, { name => 'display' } ], output_template => 'Active Energy: %.2f Wh', perfdatas => [ - { value => 'whL_absolute', template => '%.2f', unit => 'Wh', min => 0, - label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'whL', template => '%.2f', unit => 'Wh', min => 0, + label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -144,8 +144,8 @@ sub set_counters { key_values => [ { name => 'qhL' }, { name => 'display' } ], output_template => 'Reactive Energy: %.2f VARh', perfdatas => [ - { value => 'qhL_absolute', template => '%.2f', unit => 'VARh', min => 0, - label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'qhL', template => '%.2f', unit => 'VARh', min => 0, + label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -153,8 +153,8 @@ sub set_counters { key_values => [ { name => 'shL' }, { name => 'display' } ], output_template => 'Apparent Energy: %.2f VAh', perfdatas => [ - { value => 'shL_absolute', template => '%.2f', unit => 'VAh', min => 0, - label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'shL', template => '%.2f', unit => 'VAh', min => 0, + label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -162,8 +162,8 @@ sub set_counters { key_values => [ { name => 'thdUL' }, { name => 'display' } ], output_template => 'Voltage THD: %.2f %%', perfdatas => [ - { value => 'thdUL_absolute', template => '%.2f', unit => '%', min => 0, - label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'thdUL', template => '%.2f', unit => '%', min => 0, + label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -171,8 +171,8 @@ sub set_counters { key_values => [ { name => 'thdIL' }, { name => 'display' } ], output_template => 'Current THD: %.2f %%', perfdatas => [ - { value => 'thdIL_absolute', template => '%.2f', unit => '%', min => 0, - label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'thdIL', template => '%.2f', unit => '%', min => 0, + label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/hardware/devices/abb/cms700/snmp/mode/sensorsmeasurements.pm b/hardware/devices/abb/cms700/snmp/mode/sensorsmeasurements.pm index 820de2f5c..798f988f6 100644 --- a/hardware/devices/abb/cms700/snmp/mode/sensorsmeasurements.pm +++ b/hardware/devices/abb/cms700/snmp/mode/sensorsmeasurements.pm @@ -50,8 +50,8 @@ sub set_counters { key_values => [ { name => 'TRMSsens' }, { name => 'display' } ], output_template => 'Mixte Current: %.2f A', perfdatas => [ - { value => 'TRMSsens_absolute', template => '%.2f', unit => 'A', min => 0, - label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'TRMSsens', template => '%.2f', unit => 'A', min => 0, + label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -59,8 +59,8 @@ sub set_counters { key_values => [ { name => 'ACsens' }, { name => 'display' } ], output_template => 'Alternative Current: %.2f A', perfdatas => [ - { value => 'ACsens_absolute', template => '%.2f', unit => 'A', min => 0, - label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'ACsens', template => '%.2f', unit => 'A', min => 0, + label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -68,8 +68,8 @@ sub set_counters { key_values => [ { name => 'DCsens' }, { name => 'display' } ], output_template => 'Direct Current: %.2f A', perfdatas => [ - { value => 'DCsens_absolute', template => '%.2f', unit => 'A', min => 0, - label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'DCsens', template => '%.2f', unit => 'A', min => 0, + label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -77,8 +77,8 @@ sub set_counters { key_values => [ { name => 'Psens' }, { name => 'display' } ], output_template => 'Active Power: %.2f W', perfdatas => [ - { value => 'Psens_absolute', template => '%.2f', unit => 'W', min => 0, - label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'Psens', template => '%.2f', unit => 'W', min => 0, + label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -86,8 +86,8 @@ sub set_counters { key_values => [ { name => 'Whsens' }, { name => 'display' } ], output_template => 'Active Energy: %.2f Wh', perfdatas => [ - { value => 'Whsens_absolute', template => '%.2f', unit => 'Wh', min => 0, - label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'Whsens', template => '%.2f', unit => 'Wh', min => 0, + label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -95,8 +95,8 @@ sub set_counters { key_values => [ { name => 'PowerFactorsens' }, { name => 'display' } ], output_template => 'Power Factor: %.2f', perfdatas => [ - { value => 'PowerFactorsens_absolute', template => '%.2f', min => 0, max => 1, - label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'PowerFactorsens', template => '%.2f', min => 0, max => 1, + label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/hardware/devices/aeg/acm/snmp/mode/batterystatus.pm b/hardware/devices/aeg/acm/snmp/mode/batterystatus.pm index 848f602a3..e49048277 100644 --- a/hardware/devices/aeg/acm/snmp/mode/batterystatus.pm +++ b/hardware/devices/aeg/acm/snmp/mode/batterystatus.pm @@ -60,7 +60,7 @@ sub set_counters { key_values => [ { name => 'battVoltage' } ], output_template => 'Voltage : %s V', perfdatas => [ - { label => 'voltage', value => 'battVoltage_absolute', template => '%s', + { label => 'voltage', value => 'battVoltage', template => '%s', unit => 'V' }, ], } @@ -69,7 +69,7 @@ sub set_counters { key_values => [ { name => 'battCurrent' } ], output_template => 'Current : %s A', perfdatas => [ - { label => 'current', value => 'battCurrent_absolute', template => '%s', + { label => 'current', value => 'battCurrent', template => '%s', min => 0, unit => 'A' }, ], } @@ -78,7 +78,7 @@ sub set_counters { key_values => [ { name => 'battCurrent1' } ], output_template => 'Current 1 : %s A', perfdatas => [ - { label => 'current1', value => 'battCurrent1_absolute', template => '%s', + { label => 'current1', value => 'battCurrent1', template => '%s', min => 0, unit => 'A' }, ], } @@ -87,7 +87,7 @@ sub set_counters { key_values => [ { name => 'battCurrent2' } ], output_template => 'Current 2 : %s A', perfdatas => [ - { label => 'current2', value => 'battCurrent2_absolute', template => '%s', + { label => 'current2', value => 'battCurrent2', template => '%s', min => 0, unit => 'A' }, ], } @@ -96,7 +96,7 @@ sub set_counters { key_values => [ { name => 'battTemp' } ], output_template => 'Temperature : %s C', perfdatas => [ - { label => 'temperature', value => 'battTemp_absolute', template => '%s', + { label => 'temperature', value => 'battTemp', template => '%s', unit => 'C'}, ], } @@ -105,7 +105,7 @@ sub set_counters { key_values => [ { name => 'battTemp1' } ], output_template => 'Temperature 1 : %s C', perfdatas => [ - { label => 'temperature1', value => 'battTemp1_absolute', template => '%s', + { label => 'temperature1', value => 'battTemp1', template => '%s', unit => 'C'}, ], } @@ -114,7 +114,7 @@ sub set_counters { key_values => [ { name => 'battTemp2' } ], output_template => 'Temperature 2 : %s C', perfdatas => [ - { label => 'temperature2', value => 'battTemp2_absolute', template => '%s', + { label => 'temperature2', value => 'battTemp2', template => '%s', unit => 'C'}, ], } @@ -123,7 +123,7 @@ sub set_counters { key_values => [ { name => 'battAmpHMeter' } ], output_template => 'Amp Hour Meter : %s %%', perfdatas => [ - { label => 'amphourmeter', value => 'battAmpHMeter_absolute', template => '%s', + { label => 'amphourmeter', value => 'battAmpHMeter', template => '%s', unit => '%'}, ], } diff --git a/hardware/devices/aeg/acm/snmp/mode/loadstatus.pm b/hardware/devices/aeg/acm/snmp/mode/loadstatus.pm index 495e6fd06..e8257e78e 100644 --- a/hardware/devices/aeg/acm/snmp/mode/loadstatus.pm +++ b/hardware/devices/aeg/acm/snmp/mode/loadstatus.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'loadVoltage' } ], output_template => 'Voltage : %s V', perfdatas => [ - { label => 'voltage', value => 'loadVoltage_absolute', template => '%s', + { label => 'voltage', value => 'loadVoltage', template => '%s', unit => 'V' }, ], } @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'loadCurrent' } ], output_template => 'Current : %s A', perfdatas => [ - { label => 'current', value => 'loadCurrent_absolute', template => '%s', + { label => 'current', value => 'loadCurrent', template => '%s', min => 0, unit => 'A' }, ], } @@ -55,7 +55,7 @@ sub set_counters { key_values => [ { name => 'loadPower' } ], output_template => 'Power : %s W', perfdatas => [ - { label => 'power', value => 'loadPower_absolute', template => '%s', + { label => 'power', value => 'loadPower', template => '%s', unit => 'w'}, ], } diff --git a/hardware/devices/aeg/acm/snmp/mode/rectifierstatus.pm b/hardware/devices/aeg/acm/snmp/mode/rectifierstatus.pm index 5c16939c7..e13c5542b 100644 --- a/hardware/devices/aeg/acm/snmp/mode/rectifierstatus.pm +++ b/hardware/devices/aeg/acm/snmp/mode/rectifierstatus.pm @@ -59,7 +59,7 @@ sub set_counters { key_values => [ { name => 'rectVoltage' } ], output_template => 'Voltage : %s V', perfdatas => [ - { label => 'voltage', value => 'rectVoltage_absolute', template => '%s', + { label => 'voltage', value => 'rectVoltage', template => '%s', unit => 'V' }, ], } @@ -68,7 +68,7 @@ sub set_counters { key_values => [ { name => 'rectCurrent' } ], output_template => 'Current : %s A', perfdatas => [ - { label => 'current', value => 'rectCurrent_absolute', template => '%s', + { label => 'current', value => 'rectCurrent', template => '%s', min => 0, unit => 'A' }, ], } @@ -77,7 +77,7 @@ sub set_counters { key_values => [ { name => 'nbrOfFaultyRect' } ], output_template => 'Faulty rectifiers : %s', perfdatas => [ - { label => 'faulty_count', value => 'nbrOfFaultyRect_absolute', template => '%s', + { label => 'faulty_count', value => 'nbrOfFaultyRect', template => '%s', min => 0, unit => '' }, ], } diff --git a/hardware/devices/camera/hikvision/snmp/mode/cpu.pm b/hardware/devices/camera/hikvision/snmp/mode/cpu.pm index 6733b0a61..b6cb49bf8 100644 --- a/hardware/devices/camera/hikvision/snmp/mode/cpu.pm +++ b/hardware/devices/camera/hikvision/snmp/mode/cpu.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'used' } ], output_template => 'CPU Usage: %.2f %%', perfdatas => [ - { value => 'used_absolute', template => '%.2f', min => 0, max => 100, unit => '%' }, + { value => 'used', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } }, diff --git a/hardware/devices/camera/hikvision/snmp/mode/disk.pm b/hardware/devices/camera/hikvision/snmp/mode/disk.pm index bd453e7e5..7675658e1 100644 --- a/hardware/devices/camera/hikvision/snmp/mode/disk.pm +++ b/hardware/devices/camera/hikvision/snmp/mode/disk.pm @@ -30,11 +30,11 @@ sub custom_disk_output { my ($self, %options) = @_; my $msg = sprintf("Disk Total: %s %s Used: %s %s (%.2f%%) Free: %s %s (%.2f%%)", - $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_absolute}), - $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_absolute}), - $self->{result_values}->{prct_used_absolute}, - $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute}), - $self->{result_values}->{prct_free_absolute} + $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}), + $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}), + $self->{result_values}->{prct_used}, + $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}), + $self->{result_values}->{prct_free} ); return $msg; } @@ -51,7 +51,7 @@ sub set_counters { key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], closure_custom_output => $self->can('custom_disk_output'), perfdatas => [ - { value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute', + { value => 'used', template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1 }, ], } @@ -60,7 +60,7 @@ sub set_counters { key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], closure_custom_output => $self->can('custom_disk_output'), perfdatas => [ - { value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute', + { value => 'free', template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1 }, ], } @@ -69,7 +69,7 @@ sub set_counters { key_values => [ { name => 'prct_used' } ], output_template => 'Disk Used : %.2f %%', perfdatas => [ - { value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, unit => '%' }, + { value => 'prct_used', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } }, diff --git a/hardware/devices/camera/hikvision/snmp/mode/memory.pm b/hardware/devices/camera/hikvision/snmp/mode/memory.pm index d059f5129..b3aa23a18 100644 --- a/hardware/devices/camera/hikvision/snmp/mode/memory.pm +++ b/hardware/devices/camera/hikvision/snmp/mode/memory.pm @@ -30,11 +30,11 @@ sub custom_mem_output { my ($self, %options) = @_; my $msg = sprintf("Memory Total: %s %s Used: %s %s (%.2f%%) Free: %s %s (%.2f%%)", - $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_absolute}), - $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_absolute}), - $self->{result_values}->{prct_used_absolute}, - $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute}), - $self->{result_values}->{prct_free_absolute} + $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}), + $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}), + $self->{result_values}->{prct_used}, + $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}), + $self->{result_values}->{prct_free} ); return $msg; } @@ -51,7 +51,7 @@ sub set_counters { key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], closure_custom_output => $self->can('custom_mem_output'), perfdatas => [ - { value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute', + { value => 'used', template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1 }, ], } @@ -60,7 +60,7 @@ sub set_counters { key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], closure_custom_output => $self->can('custom_mem_output'), perfdatas => [ - { value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute', + { value => 'free', template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1 }, ], } @@ -69,7 +69,7 @@ sub set_counters { key_values => [ { name => 'prct_used' } ], output_template => 'Memory Used : %.2f %%', perfdatas => [ - { value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, unit => '%' }, + { value => 'prct_used', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } }, diff --git a/hardware/devices/camera/mobotix/snmp/mode/system.pm b/hardware/devices/camera/mobotix/snmp/mode/system.pm index 36078b217..93c17c962 100644 --- a/hardware/devices/camera/mobotix/snmp/mode/system.pm +++ b/hardware/devices/camera/mobotix/snmp/mode/system.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'storageArchiveBufferFillLevel', no_value => -1 } ], output_template => 'sd card usage: %.2f %%', perfdatas => [ - { value => 'storageArchiveBufferFillLevel_absolute', template => '%d', min => 0, max => 100, + { value => 'storageArchiveBufferFillLevel', template => '%d', min => 0, max => 100, unit => '%' }, ], } @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'statusTemperatureCameraC', no_value => -1000 } ], output_template => 'internal temperature: %s C', perfdatas => [ - { value => 'statusTemperatureCameraC_absolute', template => '%s', unit => 'C' }, + { value => 'statusTemperatureCameraC', template => '%s', unit => 'C' }, ], } }, @@ -54,7 +54,7 @@ sub set_counters { key_values => [ { name => 'statusTemperatureOutsideC', no_value => -1000 } ], output_template => 'external temperature: %s C', perfdatas => [ - { value => 'statusTemperatureOutsideC_absolute', template => '%s', unit => 'C' }, + { value => 'statusTemperatureOutsideC', template => '%s', unit => 'C' }, ], } }, @@ -62,7 +62,7 @@ sub set_counters { key_values => [ { name => 'statusTemperatureGpsC', no_value => -1000 } ], output_template => 'gps temperature: %s C', perfdatas => [ - { value => 'statusTemperatureGpsC_absolute', template => '%s', unit => 'C' }, + { value => 'statusTemperatureGpsC', template => '%s', unit => 'C' }, ], } }, @@ -70,7 +70,7 @@ sub set_counters { key_values => [ { name => 'statusSensorIlluminationR', no_value => -1000 } ], output_template => 'illumination right: %s lx', perfdatas => [ - { value => 'statusSensorIlluminationR_absolute', template => '%s', unit => 'lx' }, + { value => 'statusSensorIlluminationR', template => '%s', unit => 'lx' }, ], } }, @@ -78,7 +78,7 @@ sub set_counters { key_values => [ { name => 'statusSensorIlluminationL', no_value => -1000 } ], output_template => 'illumination left: %s lx', perfdatas => [ - { value => 'statusSensorIlluminationL_absolute', template => '%s', unit => 'lx' }, + { value => 'statusSensorIlluminationL', template => '%s', unit => 'lx' }, ], } }, @@ -86,7 +86,7 @@ sub set_counters { key_values => [ { name => 'videoMainCurrentFrameRate', no_value => -1000 } ], output_template => 'video framerate: %s fps', perfdatas => [ - { value => 'videoMainCurrentFrameRate_absolute', template => '%s', unit => 'fps' }, + { value => 'videoMainCurrentFrameRate', template => '%s', unit => 'fps' }, ], } } diff --git a/hardware/devices/cisco/ces/restapi/mode/callsrt.pm b/hardware/devices/cisco/ces/restapi/mode/callsrt.pm index 7ceb4648f..9a477dd3f 100644 --- a/hardware/devices/cisco/ces/restapi/mode/callsrt.pm +++ b/hardware/devices/cisco/ces/restapi/mode/callsrt.pm @@ -118,7 +118,7 @@ sub set_counters { $self->{maps_counters}->{channels} = [ { label => 'channels-traffic', nlabel => 'call.channels.traffic.bytes', set => { key_values => [], - per_second => 1, manual_keys => 1, + manual_keys => 1, closure_custom_calc => $self->can('custom_traffic_calc'), output_template => 'traffic: %s %s/s', output_change_bytes => 1, diff --git a/hardware/devices/cisco/ces/restapi/mode/callssummary.pm b/hardware/devices/cisco/ces/restapi/mode/callssummary.pm index d62400227..d987852c9 100644 --- a/hardware/devices/cisco/ces/restapi/mode/callssummary.pm +++ b/hardware/devices/cisco/ces/restapi/mode/callssummary.pm @@ -32,9 +32,9 @@ sub custom_loss_output { return sprintf( "packets loss: %.2f%% (%s on %s)", - $self->{result_values}->{loss_prct_absolute}, - $self->{result_values}->{loss_absolute}, - $self->{result_values}->{pkts_absolute} + $self->{result_values}->{loss_prct}, + $self->{result_values}->{loss}, + $self->{result_values}->{pkts} ); } @@ -60,7 +60,7 @@ sub set_counters { key_values => [ { name => 'new_calls' } ], output_template => 'total calls finished: %d', perfdatas => [ - { value => 'new_calls_absolute', template => '%d', min => 0 }, + { value => 'new_calls', template => '%d', min => 0 }, ], } } @@ -73,7 +73,7 @@ sub set_counters { key_values => [ { name => 'loss' }, { name => 'pkts' }, { name => 'loss_prct' } ], closure_custom_output => $self->can('custom_loss_output'), perfdatas => [ - { value => 'loss_absolute', template => '%d', min => 0 }, + { value => 'loss', template => '%d', min => 0 }, ], } }, @@ -81,7 +81,7 @@ sub set_counters { key_values => [ { name => 'loss_prct' }, { name => 'loss' }, { name => 'pkts' } ], closure_custom_output => $self->can('custom_loss_output'), perfdatas => [ - { value => 'loss_prct_absolute', template => '%d', unit => '%', min => 0, max => 100 }, + { value => 'loss_prct', template => '%d', unit => '%', min => 0, max => 100 }, ], } }, @@ -89,7 +89,7 @@ sub set_counters { key_values => [ { name => 'maxjitter' } ], output_template => 'max jitter: %s ms', perfdatas => [ - { value => 'maxjitter_absolute', template => '%d', unit => 'ms', min => 0 }, + { value => 'maxjitter', template => '%d', unit => 'ms', min => 0 }, ], } }, diff --git a/hardware/devices/cisco/ces/restapi/mode/certificates.pm b/hardware/devices/cisco/ces/restapi/mode/certificates.pm index be25a55bd..cb73eb87d 100644 --- a/hardware/devices/cisco/ces/restapi/mode/certificates.pm +++ b/hardware/devices/cisco/ces/restapi/mode/certificates.pm @@ -31,7 +31,7 @@ sub custom_validity_output { return sprintf( 'expires in %s', - $self->{result_values}->{generation_time_absolute} + $self->{result_values}->{generation_time} ); } @@ -47,7 +47,7 @@ sub set_counters { key_values => [ { name => 'validity_time' }, { name => 'generation_time' } ], closure_custom_output => $self->can('custom_validity_output'), perfdatas => [ - { value => 'validity_time_absolute', template => '%d', min => 0, unit => 's' }, + { value => 'validity_time', template => '%d', min => 0, unit => 's' }, ], } } diff --git a/hardware/devices/cisco/ces/restapi/mode/peripherals.pm b/hardware/devices/cisco/ces/restapi/mode/peripherals.pm index e468d76c6..5c3e0dc5a 100644 --- a/hardware/devices/cisco/ces/restapi/mode/peripherals.pm +++ b/hardware/devices/cisco/ces/restapi/mode/peripherals.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'connected' } ], output_template => 'peripherals connected: %d', perfdatas => [ - { value => 'connected_absolute', template => '%d', min => 0 }, + { value => 'connected', template => '%d', min => 0 }, ], } } diff --git a/hardware/devices/cisco/ces/restapi/mode/sessions.pm b/hardware/devices/cisco/ces/restapi/mode/sessions.pm index 786e1334c..56351b865 100644 --- a/hardware/devices/cisco/ces/restapi/mode/sessions.pm +++ b/hardware/devices/cisco/ces/restapi/mode/sessions.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'sessions' } ], output_template => 'total current sessions: %d', perfdatas => [ - { value => 'sessions_absolute', template => '%d', min => 0 }, + { value => 'sessions', template => '%d', min => 0 }, ], } } diff --git a/hardware/devices/eltek/enexus/snmp/mode/alarms.pm b/hardware/devices/eltek/enexus/snmp/mode/alarms.pm index dcb1c84a2..0e3a868ba 100644 --- a/hardware/devices/eltek/enexus/snmp/mode/alarms.pm +++ b/hardware/devices/eltek/enexus/snmp/mode/alarms.pm @@ -48,7 +48,7 @@ sub set_counters { key_values => [ { name => 'active' }, { name => 'total' } ], output_template => 'current active alarms: %d', perfdatas => [ - { value => 'active_absolute', template => '%d', min => 0, max => 'total_absolute' } + { value => 'active', template => '%d', min => 0, max => 'total' } ] } } diff --git a/hardware/devices/eltek/enexus/snmp/mode/battery.pm b/hardware/devices/eltek/enexus/snmp/mode/battery.pm index c0582dea4..d73e366d2 100644 --- a/hardware/devices/eltek/enexus/snmp/mode/battery.pm +++ b/hardware/devices/eltek/enexus/snmp/mode/battery.pm @@ -39,8 +39,8 @@ sub custom_temperature_output { my ($self, %options) = @_; return sprintf('temperature: %s %s', - $self->{result_values}->{temperature_absolute}, - $self->{result_values}->{temperature_unit_absolute} + $self->{result_values}->{temperature}, + $self->{result_values}->{temperature_unit} ); } @@ -48,9 +48,9 @@ sub custom_temperature_perfdata { my ($self, %options) = @_; $self->{output}->perfdata_add( - nlabel => 'battery.temperature.' . ($self->{result_values}->{temperature_unit_absolute} eq 'C' ? 'celsius' : 'fahrenheit'), - unit => $self->{result_values}->{temperature_unit_absolute}, - value => $self->{result_values}->{temperature_absolute}, + nlabel => 'battery.temperature.' . ($self->{result_values}->{temperature_unit} eq 'C' ? 'celsius' : 'fahrenheit'), + unit => $self->{result_values}->{temperature_unit}, + value => $self->{result_values}->{temperature}, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}), ); @@ -60,8 +60,8 @@ sub custom_charge_remaining_output { my ($self, %options) = @_; return sprintf('remaining capacity: %s %s', - $self->{result_values}->{charge_remaining_absolute}, - $self->{result_values}->{charge_remaining_unit_absolute} + $self->{result_values}->{charge_remaining}, + $self->{result_values}->{charge_remaining_unit} ); } @@ -69,13 +69,13 @@ sub custom_charge_remaining_perfdata { my ($self, %options) = @_; $self->{output}->perfdata_add( - nlabel => 'battery.charge.remaining.' . ($self->{result_values}->{charge_remaining_unit_absolute} eq '%' ? 'percentage' : 'amperehour'), - unit => $self->{result_values}->{charge_remaining_unit_absolute}, - value => $self->{result_values}->{charge_remaining_absolute}, + nlabel => 'battery.charge.remaining.' . ($self->{result_values}->{charge_remaining_unit} eq '%' ? 'percentage' : 'amperehour'), + unit => $self->{result_values}->{charge_remaining_unit}, + value => $self->{result_values}->{charge_remaining}, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}), min => 0, - max => $self->{result_values}->{charge_remaining_unit_absolute} eq '%' ? 100 : undef + max => $self->{result_values}->{charge_remaining_unit} eq '%' ? 100 : undef ); } @@ -84,7 +84,7 @@ sub custom_charge_time_output { return sprintf( 'remaining time: %s', - centreon::plugins::misc::change_seconds(value => $self->{result_values}->{charge_remaining_time_absolute}) + centreon::plugins::misc::change_seconds(value => $self->{result_values}->{charge_remaining_time}) ); } @@ -120,7 +120,7 @@ sub set_counters { key_values => [ { name => 'charge_remaining_time' } ], closure_custom_output => $self->can('custom_charge_time_output'), perfdatas => [ - { value => 'charge_remaining_time_absolute', template => '%s', min => 0, unit => 's' }, + { value => 'charge_remaining_time', template => '%s', min => 0, unit => 's' }, ], } }, @@ -128,7 +128,7 @@ sub set_counters { key_values => [ { name => 'voltage' } ], output_template => 'voltage: %.2f V', perfdatas => [ - { value => 'voltage_absolute', template => '%.2f', unit => 'V' } + { value => 'voltage', template => '%.2f', unit => 'V' } ] } }, @@ -136,7 +136,7 @@ sub set_counters { key_values => [ { name => 'current' } ], output_template => 'current: %.2f A', perfdatas => [ - { value => 'current_absolute', template => '%.2f', min => 0, unit => 'A' } + { value => 'current', template => '%.2f', min => 0, unit => 'A' } ] } } diff --git a/hardware/devices/eltek/enexus/snmp/mode/load.pm b/hardware/devices/eltek/enexus/snmp/mode/load.pm index 2c55a4048..6019b0702 100644 --- a/hardware/devices/eltek/enexus/snmp/mode/load.pm +++ b/hardware/devices/eltek/enexus/snmp/mode/load.pm @@ -56,7 +56,7 @@ sub set_counters { key_values => [ { name => 'current' } ], output_template => 'current: %s A', perfdatas => [ - { value => 'current_absolute', template => '%s', unit => 'A', min => 0 } + { value => 'current', template => '%s', unit => 'A', min => 0 } ] } }, @@ -64,7 +64,7 @@ sub set_counters { key_values => [ { name => 'power' } ], output_template => 'power: %s W', perfdatas => [ - { value => 'power_absolute', template => '%s', unit => 'W', min => 0 } + { value => 'power', template => '%s', unit => 'W', min => 0 } ] } } @@ -75,7 +75,7 @@ sub set_counters { key_values => [ { name => 'voltage' } ], output_template => 'voltage: %.2f V', perfdatas => [ - { value => 'voltage_absolute', template => '%.2f', unit => 'V', label_extra_instance => 1 } + { value => 'voltage', template => '%.2f', unit => 'V', label_extra_instance => 1 } ] } } diff --git a/hardware/devices/eltek/enexus/snmp/mode/outputs.pm b/hardware/devices/eltek/enexus/snmp/mode/outputs.pm index 37a86ffcb..0d318707a 100644 --- a/hardware/devices/eltek/enexus/snmp/mode/outputs.pm +++ b/hardware/devices/eltek/enexus/snmp/mode/outputs.pm @@ -48,7 +48,7 @@ sub set_counters { key_values => [ { name => 'disconnected' }, { name => 'total_contactors' } ], output_template => 'current disconnected outputs: %d', perfdatas => [ - { value => 'disconnected_absolute', template => '%d', min => 0, max => 'total_contactors_absolute' } + { value => 'disconnected', template => '%d', min => 0, max => 'total_contactors' } ] } }, @@ -56,7 +56,7 @@ sub set_counters { key_values => [ { name => 'notenergized' }, { name => 'total_relay' } ], output_template => 'current not energized outputs: %d', perfdatas => [ - { value => 'notenergized_absolute', template => '%d', min => 0, max => 'total_relay_absolute' } + { value => 'notenergized', template => '%d', min => 0, max => 'total_relay' } ] } } diff --git a/hardware/devices/gorgy/ntpserver/snmp/mode/globalstatus.pm b/hardware/devices/gorgy/ntpserver/snmp/mode/globalstatus.pm index 0f27aabaf..03713e7a4 100644 --- a/hardware/devices/gorgy/ntpserver/snmp/mode/globalstatus.pm +++ b/hardware/devices/gorgy/ntpserver/snmp/mode/globalstatus.pm @@ -77,7 +77,7 @@ sub set_counters { key_values => [ { name => 'ntp_requests', diff => 1 } ], output_template => 'Number of ntp requests : %s', perfdatas => [ - { label => 'ntp_requests', value => 'ntp_requests_absolute', template => '%s', + { label => 'ntp_requests', value => 'ntp_requests', template => '%s', min => 0 }, ], } diff --git a/hardware/devices/masterclock/ntp100gps/snmp/mode/ntpperformance.pm b/hardware/devices/masterclock/ntp100gps/snmp/mode/ntpperformance.pm index b5ba72ad7..06e43d4eb 100644 --- a/hardware/devices/masterclock/ntp100gps/snmp/mode/ntpperformance.pm +++ b/hardware/devices/masterclock/ntp100gps/snmp/mode/ntpperformance.pm @@ -63,7 +63,7 @@ sub set_counters { key_values => [ { name => 'stratum_level' } ], output_template => 'Stratum level : %d', perfdatas => [ - { label => 'stratum_level', value => 'stratum_level_absolute', template => '%d', + { label => 'stratum_level', value => 'stratum_level', template => '%d', min => 0, max => 16 }, ], } @@ -72,7 +72,7 @@ sub set_counters { key_values => [ { name => 'precision' } ], output_template => 'Precision : %s seconds', perfdatas => [ - { label => 'precision', value => 'precision_absolute', template => '%s', + { label => 'precision', value => 'precision', template => '%s', min => 0, unit => "seconds" }, ], } @@ -81,7 +81,7 @@ sub set_counters { key_values => [ { name => 'poll_interval' } ], output_template => 'Poll interval : %d seconds', perfdatas => [ - { label => 'poll_interval', value => 'poll_interval_absolute', template => '%d', + { label => 'poll_interval', value => 'poll_interval', template => '%d', min => 0, unit => "seconds" }, ], } diff --git a/hardware/devices/polycom/trio/restapi/mode/callsrt.pm b/hardware/devices/polycom/trio/restapi/mode/callsrt.pm index 57c411f56..356a548bd 100644 --- a/hardware/devices/polycom/trio/restapi/mode/callsrt.pm +++ b/hardware/devices/polycom/trio/restapi/mode/callsrt.pm @@ -29,7 +29,7 @@ use Digest::MD5 qw(md5_hex); sub custom_loss_calc { my ($self, %options) = @_; - $self->{result_values}->{display_absolute} = $options{new_datas}->{$self->{instance} . '_display'}; + $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; my $diff_pkts = ($options{new_datas}->{$self->{instance} . '_packets'} - $options{old_datas}->{$self->{instance} . '_packets'}); my $diff_loss = ($options{new_datas}->{$self->{instance} . '_loss'} - $options{old_datas}->{$self->{instance} . '_loss'}); @@ -63,22 +63,20 @@ sub set_counters { $self->{maps_counters}->{channels} = [ { label => 'channel-traffic-in', nlabel => 'call.channel.traffic.in.bytes', set => { - key_values => [ { name => 'traffic_in', diff => 1 }, { name => 'display' } ], - per_second => 1, output_change_bytes => 1, + key_values => [ { name => 'traffic_in', per_second => 1 }, { name => 'display' } ], + output_change_bytes => 1, output_template => 'traffic in: %s %s/s', perfdatas => [ - { value => 'traffic_in_per_second', template => '%d', - unit => 'B/s', min => 0, label_extra_instance => 1 }, + { template => '%d', unit => 'B/s', min => 0, label_extra_instance => 1 }, ], } }, { label => 'channel-traffic-out', nlabel => 'call.channel.traffic.out.bytes', set => { - key_values => [ { name => 'traffic_out', diff => 1 }, { name => 'display' } ], - per_second => 1, output_change_bytes => 1, + key_values => [ { name => 'traffic_out', per_second => 1 }, { name => 'display' } ], + output_change_bytes => 1, output_template => 'traffic out: %s %s/s', perfdatas => [ - { value => 'traffic_out_per_second', template => '%d', - unit => 'B/s', min => 0, label_extra_instance => 1 }, + { template => '%d', unit => 'B/s', min => 0, label_extra_instance => 1 }, ], } }, @@ -86,8 +84,7 @@ sub set_counters { key_values => [ { name => 'max_jitter' }, { name => 'display' } ], output_template => 'max jitter: %s ms', perfdatas => [ - { value => 'max_jitter_absolute', template => '%d', - unit => 'ms', min => 0, label_extra_instance => 1 }, + { template => '%d', unit => 'ms', min => 0, label_extra_instance => 1 }, ], } }, @@ -97,8 +94,7 @@ sub set_counters { closure_custom_output => $self->can('custom_loss_output'), threshold_use => 'packets_loss', perfdatas => [ - { value => 'packets_loss', template => '%d', - min => 0, label_extra_instance => 1 }, + { value => 'packets_loss', template => '%d', min => 0, label_extra_instance => 1 } ], } }, @@ -108,11 +104,10 @@ sub set_counters { closure_custom_output => $self->can('custom_loss_output'), threshold_use => 'packets_loss_prct', perfdatas => [ - { value => 'packets_loss_prct', template => '%.2f', - unit => '%', min => 0, max => 100, label_extra_instance => 1 }, - ], + { value => 'packets_loss_prct', template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1 } + ] } - }, + } ]; } diff --git a/hardware/devices/polycom/trio/restapi/mode/callssummary.pm b/hardware/devices/polycom/trio/restapi/mode/callssummary.pm index 1021d580e..bd4e22b1c 100644 --- a/hardware/devices/polycom/trio/restapi/mode/callssummary.pm +++ b/hardware/devices/polycom/trio/restapi/mode/callssummary.pm @@ -45,7 +45,7 @@ sub set_counters { key_values => [ { name => 'total' } ], output_template => 'total: d', perfdatas => [ - { value => 'total_absolute', template => '%d', min => 0 }, + { value => 'total', template => '%d', min => 0 }, ], } }, @@ -53,7 +53,7 @@ sub set_counters { key_values => [ { name => 'placed' } ], output_template => 'placed: %d', perfdatas => [ - { value => 'placed_absolute', template => '%d', min => 0 }, + { value => 'placed', template => '%d', min => 0 }, ], } }, @@ -61,7 +61,7 @@ sub set_counters { key_values => [ { name => 'missed' } ], output_template => 'missed: %d', perfdatas => [ - { value => 'missed_absolute', template => '%d', min => 0 }, + { value => 'missed', template => '%d', min => 0 }, ], } }, @@ -69,7 +69,7 @@ sub set_counters { key_values => [ { name => 'received' } ], output_template => 'received: %d', perfdatas => [ - { value => 'received_absolute', template => '%d', min => 0 }, + { value => 'received', template => '%d', min => 0 }, ], } }, diff --git a/hardware/devices/polycom/trio/restapi/mode/device.pm b/hardware/devices/polycom/trio/restapi/mode/device.pm index f84a23b1e..d661e38c5 100644 --- a/hardware/devices/polycom/trio/restapi/mode/device.pm +++ b/hardware/devices/polycom/trio/restapi/mode/device.pm @@ -37,11 +37,11 @@ sub custom_memory_output { return sprintf( "memory total: %s %s used: %s %s (%.2f%%) free: %s %s (%.2f%%)", - $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_absolute}), - $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_absolute}), - $self->{result_values}->{prct_used_absolute}, - $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute}), - $self->{result_values}->{prct_free_absolute} + $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}), + $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}), + $self->{result_values}->{prct_used}, + $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}), + $self->{result_values}->{prct_free} ); } @@ -65,7 +65,7 @@ sub set_counters { key_values => [ { name => 'cpu_average' } ], output_template => 'cpu average: %.2f%%', perfdatas => [ - { value => 'cpu_average_absolute', template => '%.2f', + { value => 'cpu_average', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } @@ -75,7 +75,7 @@ sub set_counters { { name => 'prct_free' }, { name => 'total' } ], closure_custom_output => $self->can('custom_memory_output'), perfdatas => [ - { value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute', + { value => 'used', template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1 }, ], } @@ -85,7 +85,7 @@ sub set_counters { { name => 'prct_free' }, { name => 'total' } ], closure_custom_output => $self->can('custom_memory_output'), perfdatas => [ - { value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute', + { value => 'free', template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1 }, ], } @@ -94,7 +94,7 @@ sub set_counters { key_values => [ { name => 'prct_used' } ], output_template => 'Memory Used: %.2f %%', perfdatas => [ - { value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, + { value => 'prct_used', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } diff --git a/hardware/devices/polycom/trio/restapi/mode/network.pm b/hardware/devices/polycom/trio/restapi/mode/network.pm index 1b903de93..01ee05be4 100644 --- a/hardware/devices/polycom/trio/restapi/mode/network.pm +++ b/hardware/devices/polycom/trio/restapi/mode/network.pm @@ -35,21 +35,19 @@ sub set_counters { $self->{maps_counters}->{global} = [ { label => 'packets-in', nlabel => 'network.packets.in.persecond', set => { - key_values => [ { name => 'packets_in', diff => 1 } ], + key_values => [ { name => 'packets_in', per_second => 1 } ], output_template => 'packets in: %.2f/s', - per_second => 1, perfdatas => [ - { value => 'packets_in_per_second', template => '%.2f', min => 0, unit => '/s' }, + { template => '%.2f', min => 0, unit => '/s' } ], } }, { label => 'packets-out', nlabel => 'network.packets.out.persecond', set => { - key_values => [ { name => 'packets_out', diff => 1 } ], + key_values => [ { name => 'packets_out', per_second => 1 } ], output_template => 'packets out: %.2f/s', - per_second => 1, perfdatas => [ - { value => 'packets_out_per_second', template => '%.2f', min => 0, unit => '/s' }, - ], + { template => '%.2f', min => 0, unit => '/s' } + ] } } ]; diff --git a/hardware/devices/timelinkmicro/tms6001/snmp/mode/alarms.pm b/hardware/devices/timelinkmicro/tms6001/snmp/mode/alarms.pm index d89a21330..6194fae99 100644 --- a/hardware/devices/timelinkmicro/tms6001/snmp/mode/alarms.pm +++ b/hardware/devices/timelinkmicro/tms6001/snmp/mode/alarms.pm @@ -38,7 +38,7 @@ sub set_counters { key_values => [ { name => 'alarms_count' } ], output_template => 'current number of alarms: %s', perfdatas => [ - { value => 'alarms_count_absolute', template => '%s', min => 0 } + { value => 'alarms_count', template => '%s', min => 0 } ] } } diff --git a/hardware/devices/timelinkmicro/tms6001/snmp/mode/frequency.pm b/hardware/devices/timelinkmicro/tms6001/snmp/mode/frequency.pm index 11072dd37..d09d7f52d 100644 --- a/hardware/devices/timelinkmicro/tms6001/snmp/mode/frequency.pm +++ b/hardware/devices/timelinkmicro/tms6001/snmp/mode/frequency.pm @@ -38,7 +38,7 @@ sub set_counters { key_values => [ { name => 'qual_frequency' } ], output_template => 'quality of frequency generation: %s', perfdatas => [ - { value => 'qual_frequency_absolute', template => '%s' } + { value => 'qual_frequency', template => '%s' } ] } } diff --git a/hardware/devices/timelinkmicro/tms6001/snmp/mode/satellites.pm b/hardware/devices/timelinkmicro/tms6001/snmp/mode/satellites.pm index 533a72e85..f1dd16151 100644 --- a/hardware/devices/timelinkmicro/tms6001/snmp/mode/satellites.pm +++ b/hardware/devices/timelinkmicro/tms6001/snmp/mode/satellites.pm @@ -38,7 +38,7 @@ sub set_counters { key_values => [ { name => 'sat_count' } ], output_template => 'current number of satellites seen: %s', perfdatas => [ - { value => 'sat_count_absolute', template => '%s', min => 0 } + { value => 'sat_count', template => '%s', min => 0 } ] } } diff --git a/hardware/devices/timelinkmicro/tms6001/snmp/mode/time.pm b/hardware/devices/timelinkmicro/tms6001/snmp/mode/time.pm index c9c5b06f8..7eb31f6df 100644 --- a/hardware/devices/timelinkmicro/tms6001/snmp/mode/time.pm +++ b/hardware/devices/timelinkmicro/tms6001/snmp/mode/time.pm @@ -38,7 +38,7 @@ sub set_counters { key_values => [ { name => 'qual_time' } ], output_template => 'quality of time generation: %s', perfdatas => [ - { value => 'qual_time_absolute', template => '%s' } + { value => 'qual_time', template => '%s' } ] } } diff --git a/hardware/kvm/adder/aim/snmp/mode/deviceusage.pm b/hardware/kvm/adder/aim/snmp/mode/deviceusage.pm index 0c6d8e9ed..30415b997 100644 --- a/hardware/kvm/adder/aim/snmp/mode/deviceusage.pm +++ b/hardware/kvm/adder/aim/snmp/mode/deviceusage.pm @@ -54,7 +54,7 @@ sub set_counters { key_values => [ { name => 'total' } ], output_template => 'Total devices : %s', perfdatas => [ - { label => 'devices_total', value => 'total_absolute', template => '%s', min => 0 }, + { label => 'devices_total', value => 'total', template => '%s', min => 0 }, ], } }, @@ -62,7 +62,7 @@ sub set_counters { key_values => [ { name => 'online' }, { name => 'total' } ], output_template => 'Online devices : %s', perfdatas => [ - { label => 'devices_online', value => 'online_absolute', template => '%s', min => 0, max => 'total_absolute' }, + { label => 'devices_online', value => 'online', template => '%s', min => 0, max => 'total' }, ], } }, diff --git a/hardware/kvm/adder/aim/snmp/mode/serverusage.pm b/hardware/kvm/adder/aim/snmp/mode/serverusage.pm index f08b174e2..3036e3b3c 100644 --- a/hardware/kvm/adder/aim/snmp/mode/serverusage.pm +++ b/hardware/kvm/adder/aim/snmp/mode/serverusage.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'cpu_load' } ], output_template => 'CPU Load : %s', perfdatas => [ - { label => 'cpu_load', value => 'cpu_load_absolute', template => '%s', min => 0 }, + { label => 'cpu_load', value => 'cpu_load', template => '%s', min => 0 }, ], } }, @@ -45,7 +45,7 @@ sub set_counters { key_values => [ { name => 'memory_used' } ], output_template => 'Memory Used : %s %%', perfdatas => [ - { label => 'memory_used', value => 'memory_used_absolute', template => '%s', + { label => 'memory_used', value => 'memory_used', template => '%s', unit => '%', min => 0, max => 100 }, ], } @@ -54,7 +54,7 @@ sub set_counters { key_values => [ { name => 'disk_used' } ], output_template => 'Disk Used : %s %%', perfdatas => [ - { label => 'disk_used', value => 'disk_used_absolute', template => '%s', + { label => 'disk_used', value => 'disk_used', template => '%s', unit => '%', min => 0, max => 100 }, ], } @@ -63,7 +63,7 @@ sub set_counters { key_values => [ { name => 'num_active_con' } ], output_template => 'Current Connected Rx : %s', perfdatas => [ - { label => 'num_active_con', value => 'num_active_con_absolute', template => '%s', min => 0}, + { label => 'num_active_con', value => 'num_active_con', template => '%s', min => 0}, ], } }, @@ -71,7 +71,7 @@ sub set_counters { key_values => [ { name => 'num_rx' } ], output_template => 'Number Rx : %s', perfdatas => [ - { label => 'num_rx', value => 'num_rx_absolute', template => '%s', min => 0 }, + { label => 'num_rx', value => 'num_rx', template => '%s', min => 0 }, ], } }, @@ -79,7 +79,7 @@ sub set_counters { key_values => [ { name => 'num_tx' } ], output_template => 'Numbre Tx : %s', perfdatas => [ - { label => 'num_tx', value => 'num_tx_absolute', template => '%s', min => 0 }, + { label => 'num_tx', value => 'num_tx', template => '%s', min => 0 }, ], } }, diff --git a/hardware/kvm/avocent/acs/8000/snmp/mode/serialports.pm b/hardware/kvm/avocent/acs/8000/snmp/mode/serialports.pm index 152a73e9c..61473a751 100644 --- a/hardware/kvm/avocent/acs/8000/snmp/mode/serialports.pm +++ b/hardware/kvm/avocent/acs/8000/snmp/mode/serialports.pm @@ -53,22 +53,20 @@ sub set_counters { } }, { label => 'traffic-in', nlabel => 'serialport.traffic.in.bitspersecond', set => { - key_values => [ { name => 'traffic_in', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'traffic_in', per_second => 1 }, { name => 'display' } ], output_template => 'traffic in: %s%s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { value => 'traffic_in_per_second', template => '%s', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' } + { template => '%s', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' } ] } }, { label => 'traffic-out', nlabel => 'serialport.traffic.out.bitspersecond', set => { - key_values => [ { name => 'traffic_out', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'traffic_out', per_second => 1 }, { name => 'display' } ], output_template => 'traffic out: %s%s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { value => 'traffic_out_per_second', template => '%s', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' } + { template => '%s', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' } ] } } diff --git a/hardware/pdu/apc/snmp/mode/load.pm b/hardware/pdu/apc/snmp/mode/load.pm index ab1bc83a5..26804b839 100644 --- a/hardware/pdu/apc/snmp/mode/load.pm +++ b/hardware/pdu/apc/snmp/mode/load.pm @@ -63,8 +63,8 @@ sub set_counters { key_values => [ { name => 'current' }, { name => 'display' } ], output_template => 'current : %s A', perfdatas => [ - { label => 'current_bank', template => '%s', value => 'current_absolute', - unit => 'A', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'current_bank', template => '%s', value => 'current', + unit => 'A', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -83,8 +83,8 @@ sub set_counters { key_values => [ { name => 'current' }, { name => 'display' } ], output_template => 'current : %s A', perfdatas => [ - { label => 'current_phase', template => '%s', value => 'current_absolute', - unit => 'A', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'current_phase', template => '%s', value => 'current', + unit => 'A', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -92,8 +92,8 @@ sub set_counters { key_values => [ { name => 'power' }, { name => 'display' } ], output_template => 'power : %s W', perfdatas => [ - { label => 'power_phase', template => '%s', value => 'power_absolute', - unit => 'W', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'power_phase', template => '%s', value => 'power', + unit => 'W', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -104,8 +104,8 @@ sub set_counters { key_values => [ { name => 'power' }, { name => 'display' } ], output_template => 'power : %s W', perfdatas => [ - { label => 'power_phase', template => '%s', value => 'power_absolute', - unit => 'W', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'power_phase', template => '%s', value => 'power', + unit => 'W', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/hardware/pdu/apc/snmp/mode/outlet.pm b/hardware/pdu/apc/snmp/mode/outlet.pm index 0739a35e7..34b20dbb0 100644 --- a/hardware/pdu/apc/snmp/mode/outlet.pm +++ b/hardware/pdu/apc/snmp/mode/outlet.pm @@ -68,8 +68,8 @@ sub set_counters { key_values => [ { name => 'current', no_value => 0 }, { name => 'display' } ], output_template => 'current : %s A', perfdatas => [ - { label => 'current', template => '%s', value => 'current_absolute', - unit => 'A', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'current', template => '%s', value => 'current', + unit => 'A', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/hardware/pdu/clever/snmp/mode/psusage.pm b/hardware/pdu/clever/snmp/mode/psusage.pm index a283b9318..93dbcd542 100644 --- a/hardware/pdu/clever/snmp/mode/psusage.pm +++ b/hardware/pdu/clever/snmp/mode/psusage.pm @@ -36,7 +36,7 @@ sub set_counters { key_values => [ { name => 'power' } ], output_template => 'Input power : %s W', perfdatas => [ - { label => 'power', value => 'power_absolute', template => '%s', + { label => 'power', value => 'power', template => '%s', unit => 'W', min => 0 }, ], } @@ -45,7 +45,7 @@ sub set_counters { key_values => [ { name => 'current' } ], output_template => 'Current : %s A', perfdatas => [ - { label => 'current', value => 'current_absolute', template => '%s', + { label => 'current', value => 'current', template => '%s', unit => 'A', min => 0 }, ], } @@ -54,7 +54,7 @@ sub set_counters { key_values => [ { name => 'voltage' } ], output_template => 'Voltage : %s V', perfdatas => [ - { label => 'voltage', value => 'voltage_absolute', template => '%s', + { label => 'voltage', value => 'voltage', template => '%s', unit => 'V', min => 0 }, ], } diff --git a/hardware/pdu/eaton/snmp/mode/environment.pm b/hardware/pdu/eaton/snmp/mode/environment.pm index 928d45fd2..2717decf1 100644 --- a/hardware/pdu/eaton/snmp/mode/environment.pm +++ b/hardware/pdu/eaton/snmp/mode/environment.pm @@ -59,7 +59,7 @@ sub set_counters { key_values => [ { name => 'value' }, { name => 'display' } ], output_template => 'temperature %.1f C', perfdatas => [ - { value => 'value_absolute', template => '%.1f', + { value => 'value', template => '%.1f', unit => 'C', label_extra_instance => 1 }, ], } @@ -79,7 +79,7 @@ sub set_counters { key_values => [ { name => 'value' }, { name => 'display' } ], output_template => 'humidity %.2f %%', perfdatas => [ - { value => 'value_absolute', template => '%.2f', + { value => 'value', template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1 }, ], } diff --git a/hardware/pdu/eaton/snmp/mode/group.pm b/hardware/pdu/eaton/snmp/mode/group.pm index 2a11324eb..e496d5a0b 100644 --- a/hardware/pdu/eaton/snmp/mode/group.pm +++ b/hardware/pdu/eaton/snmp/mode/group.pm @@ -37,8 +37,8 @@ sub set_counters { key_values => [ { name => 'groupCurrent', no_value => 0 }, { name => 'display' } ], output_template => 'Current : %.2f A', perfdatas => [ - { value => 'groupCurrent_absolute', template => '%.2f', - min => 0, unit => 'A', label_extra_instance => 1, instance_use => 'display_absolute' } + { value => 'groupCurrent', template => '%.2f', + min => 0, unit => 'A', label_extra_instance => 1, instance_use => 'display' } ] } }, @@ -46,8 +46,8 @@ sub set_counters { key_values => [ { name => 'groupVoltage', no_value => 0 }, { name => 'display' } ], output_template => 'Voltage : %.2f V', perfdatas => [ - { value => 'groupVoltage_absolute', template => '%.2f', - unit => 'V', label_extra_instance => 1, instance_use => 'display_absolute' } + { value => 'groupVoltage', template => '%.2f', + unit => 'V', label_extra_instance => 1, instance_use => 'display' } ] } }, @@ -55,8 +55,8 @@ sub set_counters { key_values => [ { name => 'groupWatts', no_value => 0 }, { name => 'display' } ], output_template => 'Power : %.2f W', perfdatas => [ - { value => 'groupWatts_absolute', template => '%.2f', - unit => 'W', label_extra_instance => 1, instance_use => 'display_absolute' } + { value => 'groupWatts', template => '%.2f', + unit => 'W', label_extra_instance => 1, instance_use => 'display' } ] } } diff --git a/hardware/pdu/eaton/snmp/mode/outlet.pm b/hardware/pdu/eaton/snmp/mode/outlet.pm index 0583c293e..544ba2b67 100644 --- a/hardware/pdu/eaton/snmp/mode/outlet.pm +++ b/hardware/pdu/eaton/snmp/mode/outlet.pm @@ -37,8 +37,8 @@ sub set_counters { key_values => [ { name => 'outletCurrent', no_value => 0 }, { name => 'display' } ], output_template => 'Current : %.2f A', perfdatas => [ - { value => 'outletCurrent_absolute', template => '%.2f', - min => 0, unit => 'A', label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'outletCurrent', template => '%.2f', + min => 0, unit => 'A', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -46,8 +46,8 @@ sub set_counters { key_values => [ { name => 'outletVoltage', no_value => 0 }, { name => 'display' } ], output_template => 'Voltage : %.2f V', perfdatas => [ - { value => 'outletVoltage_absolute', template => '%.2f', - unit => 'V', label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'outletVoltage', template => '%.2f', + unit => 'V', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -55,8 +55,8 @@ sub set_counters { key_values => [ { name => 'outletWatts', no_value => 0 }, { name => 'display' } ], output_template => 'Power : %.2f W', perfdatas => [ - { value => 'outletWatts_absolute', template => '%.2f', - unit => 'W', label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'outletWatts', template => '%.2f', + unit => 'W', label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/hardware/pdu/emerson/snmp/mode/psusage.pm b/hardware/pdu/emerson/snmp/mode/psusage.pm index f1936a25b..e473c9a32 100644 --- a/hardware/pdu/emerson/snmp/mode/psusage.pm +++ b/hardware/pdu/emerson/snmp/mode/psusage.pm @@ -43,7 +43,7 @@ sub set_counters { key_values => [ { name => 'PwrTotal' } ], output_template => 'Total input power : %s W', output_error_template => "total input power : %s", perfdatas => [ - { label => 'power', value => 'PwrTotal_absolute', template => '%s', + { label => 'power', value => 'PwrTotal', template => '%s', unit => 'W', min => 0, label_extra_instance => 1 }, ], } @@ -52,7 +52,7 @@ sub set_counters { key_values => [ { name => 'EnergyAccum', diff => 1 } ], output_template => 'Total energy : %.3f kWh', output_error_template => "Total energy : %s", perfdatas => [ - { label => 'energy', value => 'EnergyAccum_absolute', template => '%.3f', + { label => 'energy', value => 'EnergyAccum', template => '%.3f', unit => 'kWh', min => 0, label_extra_instance => 1 }, ], } @@ -61,7 +61,7 @@ sub set_counters { key_values => [ { name => 'EcNeutral' } ], output_template => 'Current neutral : %s Amp AC RMS', output_error_template => "Current neutral : %s", perfdatas => [ - { label => 'current_neutral', value => 'EcNeutral_absolute', template => '%s', + { label => 'current_neutral', value => 'EcNeutral', template => '%s', unit => 'AmpAcRMS', min => 0, label_extra_instance => 1 }, ], } @@ -72,7 +72,7 @@ sub set_counters { key_values => [ { name => 'load' } ], output_template => 'Load : %.2f %%', output_error_template => "Load : %s", perfdatas => [ - { label => 'line_load', value => 'load_absolute', template => '%.2f', + { label => 'line_load', value => 'load', template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1 }, ], } @@ -81,7 +81,7 @@ sub set_counters { key_values => [ { name => 'current' }], output_template => 'Current : %.2f A', output_error_template => "Current : %s", perfdatas => [ - { label => 'line_current', value => 'current_absolute', template => '%.2f', + { label => 'line_current', value => 'current', template => '%.2f', unit => 'A', min => 0, label_extra_instance => 1 }, ], } diff --git a/hardware/pdu/emerson/snmp/mode/receptacles.pm b/hardware/pdu/emerson/snmp/mode/receptacles.pm index b47ce0196..685424d9c 100644 --- a/hardware/pdu/emerson/snmp/mode/receptacles.pm +++ b/hardware/pdu/emerson/snmp/mode/receptacles.pm @@ -55,7 +55,7 @@ sub set_counters { key_values => [ { name => 'lgpPduRbEntryEnergyAccum', diff => 1 } ], output_template => 'total input power : %s kWh', perfdatas => [ - { template => '%s', value => 'lgpPduRbEntryEnergyAccum_absolute', + { template => '%s', value => 'lgpPduRbEntryEnergyAccum', unit => 'kWh', min => 0, label_extra_instance => 1 }, ], } @@ -64,7 +64,7 @@ sub set_counters { key_values => [ { name => 'lgpPduRbEntryPwr' } ], output_template => 'line-to-neutral real power : %s W', perfdatas => [ - { template => '%s', value => 'lgpPduRbEntryPwr_absolute', + { template => '%s', value => 'lgpPduRbEntryPwr', unit => 'W', min => 0, label_extra_instance => 1 }, ], } @@ -73,7 +73,7 @@ sub set_counters { key_values => [ { name => 'lgpPduRbEntryAp' } ], output_template => 'line-to-neutral apparent power : %s VA', perfdatas => [ - { template => '%s', value => 'lgpPduRbEntryAp_absolute', + { template => '%s', value => 'lgpPduRbEntryAp', unit => 'VA', min => 0, label_extra_instance => 1 }, ], } @@ -82,7 +82,7 @@ sub set_counters { key_values => [ { name => 'lgpPduRbEntryEcHundredths' } ], output_template => 'line-to-neutral current : %s Amp AC RMS', perfdatas => [ - { value => 'lgpPduRbEntryEcHundredths_absolute', template => '%s', + { value => 'lgpPduRbEntryEcHundredths', template => '%s', unit => 'AmpAcRMS', min => 0, label_extra_instance => 1 }, ], } @@ -91,7 +91,7 @@ sub set_counters { key_values => [ { name => 'lgpPduRbEntryEpLNTenths' } ], output_template => 'line-to-neutral potential : %s VoltRMS', perfdatas => [ - { value => 'lgpPduRbEntryEpLNTenths_absolute', template => '%s', + { value => 'lgpPduRbEntryEpLNTenths', template => '%s', unit => 'VoltRMS', min => 0, label_extra_instance => 1 }, ], } diff --git a/hardware/sensors/comet/p8000/snmp/mode/sensors.pm b/hardware/sensors/comet/p8000/snmp/mode/sensors.pm index de43b1399..6ac912565 100644 --- a/hardware/sensors/comet/p8000/snmp/mode/sensors.pm +++ b/hardware/sensors/comet/p8000/snmp/mode/sensors.pm @@ -30,13 +30,13 @@ sub custom_temperature_perfdata { my ($extra_label, $unit) = ('', 'C'); if (!defined($options{extra_instance}) || $options{extra_instance} != 0) { - $extra_label .= '_' . $self->{result_values}->{display_absolute}; + $extra_label .= '_' . $self->{result_values}->{display}; } $self->{output}->perfdata_add( label => $self->{label} . $extra_label, unit => $unit, - value => $self->{result_values}->{$self->{label} . '_absolute'}, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label} . '_' . $self->{result_values}->{display_absolute}), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label} . '_' . $self->{result_values}->{display_absolute}), + value => $self->{result_values}->{$self->{label} }, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label} . '_' . $self->{result_values}->{display}), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label} . '_' . $self->{result_values}->{display}), ); } @@ -45,13 +45,13 @@ sub custom_humidity_perfdata { my ($extra_label, $unit) = ('', '%'); if (!defined($options{extra_instance}) || $options{extra_instance} != 0) { - $extra_label .= '_' . $self->{result_values}->{display_absolute}; + $extra_label .= '_' . $self->{result_values}->{display}; } $self->{output}->perfdata_add( label => $self->{label} . $extra_label, unit => $unit, - value => $self->{result_values}->{$self->{label} . '_absolute'}, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label} . '_' . $self->{result_values}->{display_absolute}), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label} . '_' . $self->{result_values}->{display_absolute}), + value => $self->{result_values}->{$self->{label} }, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label} . '_' . $self->{result_values}->{display}), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label} . '_' . $self->{result_values}->{display}), min => 0, max => 100, ); } @@ -63,17 +63,17 @@ sub custom_sensor_threshold { if (defined($self->{instance_mode}->{option_results}->{'warning-' . $self->{label}}) && $self->{instance_mode}->{option_results}->{'warning-' . $self->{label}} ne '') { $warn_limit = $self->{instance_mode}->{option_results}->{'warning-' . $self->{label}}; } - $self->{perfdata}->threshold_validate(label => 'warning-' . $self->{label} . '_' . $self->{result_values}->{display_absolute}, value => $warn_limit); + $self->{perfdata}->threshold_validate(label => 'warning-' . $self->{label} . '_' . $self->{result_values}->{display}, value => $warn_limit); - my $crit_limit = $self->{result_values}->{limit_lo_absolute} . ':' . $self->{result_values}->{limit_hi_absolute}; + my $crit_limit = $self->{result_values}->{limit_lo} . ':' . $self->{result_values}->{limit_hi}; if (defined($self->{instance_mode}->{option_results}->{'critical-' . $self->{label}}) && $self->{instance_mode}->{option_results}->{'critical-' . $self->{label}} ne '') { $crit_limit = $self->{instance_mode}->{option_results}->{'critical-' . $self->{label}}; } - $self->{perfdata}->threshold_validate(label => 'critical-' . $self->{label} . '_' . $self->{result_values}->{display_absolute}, value => $crit_limit); + $self->{perfdata}->threshold_validate(label => 'critical-' . $self->{label} . '_' . $self->{result_values}->{display}, value => $crit_limit); - my $exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{$self->{label} . '_absolute'}, - threshold => [ { label => 'critical-' . $self->{label} . '_' . $self->{result_values}->{display_absolute}, exit_litteral => 'critical' }, - { label => 'warning-' . $self->{label} . '_' . $self->{result_values}->{display_absolute}, exit_litteral => 'warning' } ]); + my $exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{$self->{label} }, + threshold => [ { label => 'critical-' . $self->{label} . '_' . $self->{result_values}->{display}, exit_litteral => 'critical' }, + { label => 'warning-' . $self->{label} . '_' . $self->{result_values}->{display}, exit_litteral => 'warning' } ]); return $exit; } diff --git a/hardware/sensors/geist/snmp/mode/sensors.pm b/hardware/sensors/geist/snmp/mode/sensors.pm index 140efd117..ac3cc2478 100644 --- a/hardware/sensors/geist/snmp/mode/sensors.pm +++ b/hardware/sensors/geist/snmp/mode/sensors.pm @@ -39,7 +39,7 @@ sub set_counters { key_values => [ { name => 'climateTempC', no_value => 0, } ], output_template => 'temperature %s C', perfdatas => [ - { value => 'climateTempC_absolute', template => '%s', unit => 'C', label_extra_instance => 1 }, + { value => 'climateTempC', template => '%s', unit => 'C', label_extra_instance => 1 }, ], } }, @@ -47,7 +47,7 @@ sub set_counters { key_values => [ { name => 'climateHumidity', no_value => 0 } ], output_template => 'humidity %.2f %%', perfdatas => [ - { value => 'climateHumidity_absolute', template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1 }, + { value => 'climateHumidity', template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1 }, ], } }, @@ -55,7 +55,7 @@ sub set_counters { key_values => [ { name => 'climateLight', no_value => 0 } ], output_template => 'ambient light %.2f %%', perfdatas => [ - { value => 'climateLight_absolute', template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1 }, + { value => 'climateLight', template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1 }, ], } }, @@ -63,7 +63,7 @@ sub set_counters { key_values => [ { name => 'climateAirflow', no_value => 0 } ], output_template => 'airflow %.2f %%', perfdatas => [ - { value => 'climateAirflow_absolute', template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1 }, + { value => 'climateAirflow', template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1 }, ], } }, @@ -71,7 +71,7 @@ sub set_counters { key_values => [ { name => 'climateSound', no_value => 0 } ], output_template => 'sound %.2f %%', perfdatas => [ - { value => 'climateSound_absolute', template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1 }, + { value => 'climateSound', template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1 }, ], } }, @@ -79,7 +79,7 @@ sub set_counters { key_values => [ { name => 'climateDewPointC', no_value => 0 } ], output_template => 'dew point %s C', perfdatas => [ - { value => 'climateDewPointC_absolute', template => '%s', unit => 'C', label_extra_instance => 1 }, + { value => 'climateDewPointC', template => '%s', unit => 'C', label_extra_instance => 1 }, ], } }, @@ -90,7 +90,7 @@ sub set_counters { key_values => [ { name => 'internalTemp', no_value => 0, } ], output_template => 'temperature %s C', perfdatas => [ - { value => 'internalTemp_absolute', template => '%s', unit => 'C', label_extra_instance => 1 }, + { value => 'internalTemp', template => '%s', unit => 'C', label_extra_instance => 1 }, ], } }, @@ -98,7 +98,7 @@ sub set_counters { key_values => [ { name => 'internalHumidity', no_value => 0 } ], output_template => 'humidity %.2f %%', perfdatas => [ - { value => 'internalHumidity_absolute', template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1 }, + { value => 'internalHumidity', template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1 }, ], } }, @@ -106,7 +106,7 @@ sub set_counters { key_values => [ { name => 'internalDewPoint', no_value => 0 } ], output_template => 'dew point %s C', perfdatas => [ - { value => 'internalDewPoint_absolute', template => '%s', unit => 'C', label_extra_instance => 1 }, + { value => 'internalDewPoint', template => '%s', unit => 'C', label_extra_instance => 1 }, ], } }, diff --git a/hardware/sensors/temperhum/local/mode/environment.pm b/hardware/sensors/temperhum/local/mode/environment.pm index 3d957e35f..420d7ede6 100644 --- a/hardware/sensors/temperhum/local/mode/environment.pm +++ b/hardware/sensors/temperhum/local/mode/environment.pm @@ -38,8 +38,8 @@ sub set_counters { key_values => [ { name => 'humidity' }, { name => 'display' } ], output_template => 'Humidity: %.2f%%', perfdatas => [ - { label => 'humidity', value => 'humidity_absolute', template => '%.2f', - unit => '%', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'humidity', value => 'humidity', template => '%.2f', + unit => '%', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], }, }, @@ -47,8 +47,8 @@ sub set_counters { key_values => [ { name => 'temperature' }, { name => 'dewpoint' }, { name => 'display' } ], output_template => 'Temperature: %.2f C', perfdatas => [ - { label => 'temperature', value => 'temperature_absolute', template => '%.2f', - unit => 'C', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'temperature', value => 'temperature', template => '%.2f', + unit => 'C', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], }, }, @@ -56,8 +56,8 @@ sub set_counters { key_values => [ { name => 'dewpoint' }, { name => 'display' } ], output_template => 'Dew Point : %.2f C', perfdatas => [ - { label => 'dew_point', value => 'dewpoint_absolute', template => '%.2f', - unit => 'C', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'dew_point', value => 'dewpoint', template => '%.2f', + unit => 'C', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -65,8 +65,8 @@ sub set_counters { key_values => [ { name => 'delta' }, { name => 'display' } ], output_template => 'Delta (Temp - Dew) : %.2f C', perfdatas => [ - { label => 'delta', value => 'delta_absolute', template => '%.2f', - unit => 'C', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'delta', value => 'delta', template => '%.2f', + unit => 'C', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/hardware/server/hp/oneview/restapi/mode/storagepools.pm b/hardware/server/hp/oneview/restapi/mode/storagepools.pm index de43346c6..0bdb6d474 100644 --- a/hardware/server/hp/oneview/restapi/mode/storagepools.pm +++ b/hardware/server/hp/oneview/restapi/mode/storagepools.pm @@ -36,13 +36,13 @@ sub custom_status_output { sub custom_usage_output { my ($self, %options) = @_; - my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_space_absolute}); - my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_space_absolute}); - my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_space_absolute}); + my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_space}); + my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_space}); + my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_space}); my $msg = sprintf('space usage total: %s used: %s (%.2f%%) free: %s (%.2f%%)', $total_size_value . " " . $total_size_unit, - $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used_space_absolute}, - $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free_space_absolute} + $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used_space}, + $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free_space} ); return $msg; } @@ -67,8 +67,8 @@ sub set_counters { key_values => [ { name => 'used_space' }, { name => 'free_space' }, { name => 'prct_used_space' }, { name => 'prct_free_space' }, { name => 'total_space' }, { name => 'display' }, ], closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ - { value => 'used_space_absolute', template => '%d', min => 0, max => 'total_space_absolute', - unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'used_space', template => '%d', min => 0, max => 'total_space', + unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -76,8 +76,8 @@ sub set_counters { key_values => [ { name => 'free_space' }, { name => 'used_space' }, { name => 'prct_used_space' }, { name => 'prct_free_space' }, { name => 'total_space' }, { name => 'display' }, ], closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ - { value => 'free_space_absolute', template => '%d', min => 0, max => 'total_space_absolute', - unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'free_space', template => '%d', min => 0, max => 'total_space', + unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -85,8 +85,8 @@ sub set_counters { key_values => [ { name => 'prct_used_space' }, { name => 'display' } ], output_template => 'used : %.2f %%', perfdatas => [ - { value => 'prct_used_space_absolute', template => '%.2f', min => 0, max => 100, - unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'prct_used_space', template => '%.2f', min => 0, max => 100, + unit => '%', label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/hardware/telephony/avaya/aes/snmp/mode/services.pm b/hardware/telephony/avaya/aes/snmp/mode/services.pm index b94eb5184..19755d40e 100644 --- a/hardware/telephony/avaya/aes/snmp/mode/services.pm +++ b/hardware/telephony/avaya/aes/snmp/mode/services.pm @@ -70,7 +70,7 @@ sub set_counters { key_values => [ { name => 'avAesTsapiClientsConnected' } ], output_template => 'client connected: %s', perfdatas => [ - { value => 'avAesTsapiClientsConnected_absolute', template => '%s', min => 0 }, + { value => 'avAesTsapiClientsConnected', template => '%s', min => 0 }, ], } }, @@ -78,7 +78,7 @@ sub set_counters { key_values => [ { name => 'mem_used_prct' } ], output_template => 'memory used : %.2f %%', perfdatas => [ - { value => 'mem_used_prct_absolute', template => '%.2f', min => 0, max => 100, unit => '%' }, + { value => 'mem_used_prct', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } }, diff --git a/hardware/telephony/avaya/cm/snmp/mode/calls.pm b/hardware/telephony/avaya/cm/snmp/mode/calls.pm index c81d9af49..bbdb82e4f 100644 --- a/hardware/telephony/avaya/cm/snmp/mode/calls.pm +++ b/hardware/telephony/avaya/cm/snmp/mode/calls.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'avCmListMeasCallRateTotalNumCallsCompLstHr' } ], output_template => 'total calls last hour: %s', perfdatas => [ - { value => 'avCmListMeasCallRateTotalNumCallsCompLstHr_absolute', template => '%s', min => 0 }, + { value => 'avCmListMeasCallRateTotalNumCallsCompLstHr', template => '%s', min => 0 }, ], } } diff --git a/hardware/telephony/avaya/cm/snmp/mode/licenses.pm b/hardware/telephony/avaya/cm/snmp/mode/licenses.pm index d5ce337c9..3d8001978 100644 --- a/hardware/telephony/avaya/cm/snmp/mode/licenses.pm +++ b/hardware/telephony/avaya/cm/snmp/mode/licenses.pm @@ -29,11 +29,11 @@ sub custom_station_output { my ($self, %options) = @_; my $msg = sprintf("station capacity total: %s used: %s (%.2f%%) free: %s (%.2f%%)", - $self->{result_values}->{total_absolute}, - $self->{result_values}->{used_absolute}, - $self->{result_values}->{prct_used_absolute}, - $self->{result_values}->{free_absolute}, - $self->{result_values}->{prct_free_absolute} + $self->{result_values}->{total}, + $self->{result_values}->{used}, + $self->{result_values}->{prct_used}, + $self->{result_values}->{free}, + $self->{result_values}->{prct_free} ); return $msg; } @@ -50,7 +50,7 @@ sub set_counters { key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], closure_custom_output => $self->can('custom_station_output'), perfdatas => [ - { value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute', cast_int => 1 }, + { value => 'used', template => '%d', min => 0, max => 'total', cast_int => 1 }, ], } }, @@ -58,7 +58,7 @@ sub set_counters { key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], closure_custom_output => $self->can('custom_station_output'), perfdatas => [ - { value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute', cast_int => 1 }, + { value => 'free', template => '%d', min => 0, max => 'total', cast_int => 1 }, ], } }, @@ -66,7 +66,7 @@ sub set_counters { key_values => [ { name => 'prct_used' } ], output_template => 'station capacity used : %.2f %%', perfdatas => [ - { value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, unit => '%' }, + { value => 'prct_used', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } } diff --git a/hardware/ups/alpha/snmp/mode/batterystatus.pm b/hardware/ups/alpha/snmp/mode/batterystatus.pm index 8014a18f4..1d03d7c83 100644 --- a/hardware/ups/alpha/snmp/mode/batterystatus.pm +++ b/hardware/ups/alpha/snmp/mode/batterystatus.pm @@ -60,7 +60,7 @@ sub set_counters { key_values => [ { name => 'upsBatteryCapacity' } ], output_template => 'Remaining capacity : %s %%', perfdatas => [ - { label => 'load', value => 'upsBatteryCapacity_absolute', template => '%s', + { label => 'load', value => 'upsBatteryCapacity', template => '%s', min => 0, max => 100, unit => '%' }, ], } @@ -69,7 +69,7 @@ sub set_counters { key_values => [ { name => 'upsBatteryChargingCurrent' } ], output_template => 'Current : %s A', perfdatas => [ - { label => 'current', value => 'upsBatteryChargingCurrent_absolute', template => '%s', + { label => 'current', value => 'upsBatteryChargingCurrent', template => '%s', min => 0, unit => 'A' }, ], } @@ -78,7 +78,7 @@ sub set_counters { key_values => [ { name => 'upsBatteryVoltage' } ], output_template => 'Voltage : %s V', perfdatas => [ - { label => 'voltage', value => 'upsBatteryVoltage_absolute', template => '%s', + { label => 'voltage', value => 'upsBatteryVoltage', template => '%s', unit => 'V' }, ], } @@ -87,7 +87,7 @@ sub set_counters { key_values => [ { name => 'upsBatteryTemperature' } ], output_template => 'Temperature : %s C', perfdatas => [ - { label => 'temperature', value => 'upsBatteryTemperature_absolute', template => '%s', + { label => 'temperature', value => 'upsBatteryTemperature', template => '%s', unit => 'C'}, ], } diff --git a/hardware/ups/apc/snmp/mode/batterystatus.pm b/hardware/ups/apc/snmp/mode/batterystatus.pm index 741b201c7..823548796 100644 --- a/hardware/ups/apc/snmp/mode/batterystatus.pm +++ b/hardware/ups/apc/snmp/mode/batterystatus.pm @@ -71,7 +71,7 @@ sub set_counters { key_values => [ { name => 'upsAdvBatteryCapacity' } ], output_template => 'remaining capacity: %s %%', perfdatas => [ - { label => 'load', value => 'upsAdvBatteryCapacity_absolute', template => '%s', + { label => 'load', value => 'upsAdvBatteryCapacity', template => '%s', min => 0, max => 100, unit => '%' }, ], } @@ -80,7 +80,7 @@ sub set_counters { key_values => [ { name => 'upsAdvBatteryRunTimeRemaining' } ], output_template => 'remaining time: %.2f minutes', perfdatas => [ - { label => 'load_time', value => 'upsAdvBatteryRunTimeRemaining_absolute', template => '%.2f', + { label => 'load_time', value => 'upsAdvBatteryRunTimeRemaining', template => '%.2f', min => 0, unit => 'm' }, ], } @@ -89,7 +89,7 @@ sub set_counters { key_values => [ { name => 'upsAdvBatteryCurrent' } ], output_template => 'current: %s A', perfdatas => [ - { label => 'current', value => 'upsAdvBatteryCurrent_absolute', template => '%s', + { label => 'current', value => 'upsAdvBatteryCurrent', template => '%s', min => 0, unit => 'A' }, ], } @@ -98,7 +98,7 @@ sub set_counters { key_values => [ { name => 'upsAdvBatteryActualVoltage' } ], output_template => 'voltage: %s V', perfdatas => [ - { label => 'voltage', value => 'upsAdvBatteryActualVoltage_absolute', template => '%s', + { label => 'voltage', value => 'upsAdvBatteryActualVoltage', template => '%s', unit => 'V' }, ], } @@ -107,7 +107,7 @@ sub set_counters { key_values => [ { name => 'upsAdvBatteryTemperature' } ], output_template => 'temperature: %s C', perfdatas => [ - { label => 'temperature', value => 'upsAdvBatteryTemperature_absolute', template => '%s', + { label => 'temperature', value => 'upsAdvBatteryTemperature', template => '%s', unit => 'C'}, ], } @@ -116,7 +116,7 @@ sub set_counters { key_values => [ { name => 'last_replace_time' } ], output_template => 'replace last time: %s s', perfdatas => [ - { label => 'replace_last_time', value => 'last_replace_time_absolute', template => '%s', + { label => 'replace_last_time', value => 'last_replace_time', template => '%s', unit => 's'}, ], } diff --git a/hardware/ups/apc/snmp/mode/inputlines.pm b/hardware/ups/apc/snmp/mode/inputlines.pm index a131232e3..ae962021c 100644 --- a/hardware/ups/apc/snmp/mode/inputlines.pm +++ b/hardware/ups/apc/snmp/mode/inputlines.pm @@ -44,7 +44,7 @@ sub set_counters { key_values => [ { name => 'voltage' } ], output_template => 'voltage: %s V', perfdatas => [ - { label => 'voltage', value => 'voltage_absolute', template => '%s', + { label => 'voltage', value => 'voltage', template => '%s', unit => 'V' }, ], } @@ -53,7 +53,7 @@ sub set_counters { key_values => [ { name => 'frequency' } ], output_template => 'frequence: %s Hz', perfdatas => [ - { label => 'frequence', value => 'frequency_absolute', template => '%s', + { label => 'frequence', value => 'frequency', template => '%s', unit => 'Hz' }, ], } diff --git a/hardware/ups/apc/snmp/mode/outputlines.pm b/hardware/ups/apc/snmp/mode/outputlines.pm index a4aa76339..a1e1a9096 100644 --- a/hardware/ups/apc/snmp/mode/outputlines.pm +++ b/hardware/ups/apc/snmp/mode/outputlines.pm @@ -52,7 +52,7 @@ sub set_counters { key_values => [ { name => 'load' } ], output_template => 'load: %s %%', perfdatas => [ - { label => 'load', value => 'load_absolute', template => '%s', + { label => 'load', value => 'load', template => '%s', min => 0, max => 100, unit => '%' }, ], } @@ -61,7 +61,7 @@ sub set_counters { key_values => [ { name => 'current' } ], output_template => 'current: %s A', perfdatas => [ - { label => 'current', value => 'current_absolute', template => '%s', + { label => 'current', value => 'current', template => '%s', min => 0, unit => 'A' }, ], } @@ -70,7 +70,7 @@ sub set_counters { key_values => [ { name => 'voltage' } ], output_template => 'voltage: %s V', perfdatas => [ - { label => 'voltage', value => 'voltage_absolute', template => '%s', + { label => 'voltage', value => 'voltage', template => '%s', unit => 'V' }, ], } @@ -79,7 +79,7 @@ sub set_counters { key_values => [ { name => 'frequency' } ], output_template => 'frequence: %s Hz', perfdatas => [ - { label => 'frequence', value => 'frequency_absolute', template => '%s', + { label => 'frequence', value => 'frequency', template => '%s', unit => 'Hz' }, ], } diff --git a/hardware/ups/hp/snmp/mode/batterystatus.pm b/hardware/ups/hp/snmp/mode/batterystatus.pm index 1f44938a5..835392ae3 100644 --- a/hardware/ups/hp/snmp/mode/batterystatus.pm +++ b/hardware/ups/hp/snmp/mode/batterystatus.pm @@ -53,7 +53,7 @@ sub set_counters { key_values => [ { name => 'upsBatCapacity' } ], output_template => 'remaining capacity: %s %%', perfdatas => [ - { value => 'upsBatCapacity_absolute', template => '%s', min => 0, max => 100, unit => '%' }, + { value => 'upsBatCapacity', template => '%s', min => 0, max => 100, unit => '%' }, ], } }, @@ -61,7 +61,7 @@ sub set_counters { key_values => [ { name => 'upsBatTimeRemaining' } ], output_template => 'remaining time: %s minutes', perfdatas => [ - { value => 'upsBatTimeRemaining_absolute', template => '%s', min => 0, unit => 'm' }, + { value => 'upsBatTimeRemaining', template => '%s', min => 0, unit => 'm' }, ], } }, @@ -69,7 +69,7 @@ sub set_counters { key_values => [ { name => 'upsBatCurrent', no_value => 0 } ], output_template => 'current: %s A', perfdatas => [ - { value => 'upsBatCurrent_absolute', template => '%s', unit => 'A' }, + { value => 'upsBatCurrent', template => '%s', unit => 'A' }, ], } }, @@ -77,7 +77,7 @@ sub set_counters { key_values => [ { name => 'upsBatVoltage', no_value => 0 } ], output_template => 'voltage: %s V', perfdatas => [ - { value => 'upsBatVoltage_absolute', template => '%s', unit => 'V' }, + { value => 'upsBatVoltage', template => '%s', unit => 'V' }, ], } }, diff --git a/hardware/ups/hp/snmp/mode/environment.pm b/hardware/ups/hp/snmp/mode/environment.pm index ec41ff317..ec5a969dc 100644 --- a/hardware/ups/hp/snmp/mode/environment.pm +++ b/hardware/ups/hp/snmp/mode/environment.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'internal_temperature' } ], output_template => 'internal temperature: %.2f C', perfdatas => [ - { value => 'internal_temperature_absolute', template => '%.2f', + { value => 'internal_temperature', template => '%.2f', min => 0, unit => 'C' }, ], } @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'internal_humidity' } ], output_template => 'internal humidity: %.2f %%', perfdatas => [ - { value => 'internal_humidity_absolute', template => '%.2f', + { value => 'internal_humidity', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } @@ -55,7 +55,7 @@ sub set_counters { key_values => [ { name => 'remote_temperature' } ], output_template => 'remote temperature: %.2f C', perfdatas => [ - { value => 'remote_temperature_absolute', template => '%.2f', + { value => 'remote_temperature', template => '%.2f', min => 0, unit => 'C' }, ], } @@ -64,7 +64,7 @@ sub set_counters { key_values => [ { name => 'remote_humidity' } ], output_template => 'remote humidity: %.2f %%', perfdatas => [ - { value => 'remote_humidity_absolute', template => '%.2f', + { value => 'remote_humidity', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } diff --git a/hardware/ups/hp/snmp/mode/inputlines.pm b/hardware/ups/hp/snmp/mode/inputlines.pm index 04350a663..48971438e 100644 --- a/hardware/ups/hp/snmp/mode/inputlines.pm +++ b/hardware/ups/hp/snmp/mode/inputlines.pm @@ -38,7 +38,7 @@ sub set_counters { key_values => [ { name => 'upsInputFrequency', no_value => 0 } ], output_template => 'frequence: %.2f Hz', perfdatas => [ - { value => 'upsInputFrequency_absolute', template => '%.2f', + { value => 'upsInputFrequency', template => '%.2f', unit => 'Hz' }, ], } @@ -50,7 +50,7 @@ sub set_counters { key_values => [ { name => 'upsInputCurrent', no_value => 0 } ], output_template => 'current: %.2f A', perfdatas => [ - { value => 'upsInputCurrent_absolute', template => '%.2f', + { value => 'upsInputCurrent', template => '%.2f', min => 0, unit => 'A', label_extra_instance => 1 }, ], } @@ -59,7 +59,7 @@ sub set_counters { key_values => [ { name => 'upsInputVoltage', no_value => 0 } ], output_template => 'voltage: %s V', perfdatas => [ - { value => 'upsInputVoltage_absolute', template => '%s', + { value => 'upsInputVoltage', template => '%s', unit => 'V', label_extra_instance => 1 }, ], } @@ -68,7 +68,7 @@ sub set_counters { key_values => [ { name => 'upsInputWatts', no_value => 0 } ], output_template => 'power: %s W', perfdatas => [ - { value => 'upsInputWatts_absolute', template => '%s', + { value => 'upsInputWatts', template => '%s', unit => 'W', label_extra_instance => 1 }, ], } diff --git a/hardware/ups/hp/snmp/mode/outputlines.pm b/hardware/ups/hp/snmp/mode/outputlines.pm index af37765fa..8ce324623 100644 --- a/hardware/ups/hp/snmp/mode/outputlines.pm +++ b/hardware/ups/hp/snmp/mode/outputlines.pm @@ -53,7 +53,7 @@ sub set_counters { key_values => [ { name => 'upsOutputLoad', no_value => -1 } ], output_template => 'load: %.2f %%', perfdatas => [ - { value => 'upsOutputLoad_absolute', template => '%.2f', min => 0, max => 100 }, + { value => 'upsOutputLoad', template => '%.2f', min => 0, max => 100 }, ], } }, @@ -61,7 +61,7 @@ sub set_counters { key_values => [ { name => 'upsOutputFrequency', no_value => 0 } ], output_template => 'frequence: %.2f Hz', perfdatas => [ - { value => 'upsOutputFrequency_absolute', template => '%.2f', unit => 'Hz' }, + { value => 'upsOutputFrequency', template => '%.2f', unit => 'Hz' }, ], } }, @@ -72,7 +72,7 @@ sub set_counters { key_values => [ { name => 'upsOutputCurrent', no_value => 0 } ], output_template => 'current: %.2f A', perfdatas => [ - { value => 'upsOutputCurrent_absolute', template => '%.2f', + { value => 'upsOutputCurrent', template => '%.2f', min => 0, unit => 'A', label_extra_instance => 1 }, ], } @@ -81,7 +81,7 @@ sub set_counters { key_values => [ { name => 'upsOutputVoltage', no_value => 0 } ], output_template => 'voltage: %s V', perfdatas => [ - { value => 'upsOutputVoltage_absolute', template => '%s', + { value => 'upsOutputVoltage', template => '%s', unit => 'V', label_extra_instance => 1 }, ], } @@ -90,7 +90,7 @@ sub set_counters { key_values => [ { name => 'upsOutputWatts', no_value => 0 } ], output_template => 'power: %s W', perfdatas => [ - { value => 'upsOutputWatts_absolute', template => '%s', + { value => 'upsOutputWatts', template => '%s', unit => 'W', label_extra_instance => 1 }, ], } diff --git a/hardware/ups/mge/snmp/mode/environment.pm b/hardware/ups/mge/snmp/mode/environment.pm index 6da9a3409..88b53c73e 100644 --- a/hardware/ups/mge/snmp/mode/environment.pm +++ b/hardware/ups/mge/snmp/mode/environment.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'temperature', no_value => 0, } ], output_template => 'Ambiant Temperature: %.2f C', output_error_template => 'Ambiant Temperature: %s', perfdatas => [ - { value => 'temperature_absolute', label => 'temperature', template => '%.2f', + { value => 'temperature', label => 'temperature', template => '%.2f', unit => 'C' }, ], } @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'humidity', no_value => 0 } ], output_template => 'Humidity: %.2f %%', output_error_template => 'Humidity: %s', perfdatas => [ - { value => 'humidity_absolute', label => 'humidity', template => '%.2f', + { value => 'humidity', label => 'humidity', template => '%.2f', unit => '%', min => 0, max => 100 }, ], } diff --git a/hardware/ups/mge/snmp/mode/inputlines.pm b/hardware/ups/mge/snmp/mode/inputlines.pm index 87fa7b0dd..da87f37e9 100644 --- a/hardware/ups/mge/snmp/mode/inputlines.pm +++ b/hardware/ups/mge/snmp/mode/inputlines.pm @@ -66,7 +66,7 @@ sub set_counters { key_values => [ { name => 'mginputCurrent', no_value => 0 } ], output_template => 'Current : %.2f A', perfdatas => [ - { label => 'current', value => 'mginputCurrent_absolute', template => '%.2f', + { label => 'current', value => 'mginputCurrent', template => '%.2f', min => 0, unit => 'A', label_extra_instance => 1 }, ], } @@ -75,7 +75,7 @@ sub set_counters { key_values => [ { name => 'mginputVoltage', no_value => 0 } ], output_template => 'Voltage : %.2f V', perfdatas => [ - { label => 'voltage', value => 'mginputVoltage_absolute', template => '%.2f', + { label => 'voltage', value => 'mginputVoltage', template => '%.2f', unit => 'V', label_extra_instance => 1 }, ], } @@ -84,7 +84,7 @@ sub set_counters { key_values => [ { name => 'mginputFrequency', no_value => 0 } ], output_template => 'Frequence : %.2f Hz', perfdatas => [ - { label => 'frequence', value => 'mginputFrequency_absolute', template => '%.2f', + { label => 'frequence', value => 'mginputFrequency', template => '%.2f', unit => 'Hz', label_extra_instance => 1 }, ], } diff --git a/hardware/ups/mge/snmp/mode/outputlines.pm b/hardware/ups/mge/snmp/mode/outputlines.pm index de2d9cb70..7f1806596 100644 --- a/hardware/ups/mge/snmp/mode/outputlines.pm +++ b/hardware/ups/mge/snmp/mode/outputlines.pm @@ -38,7 +38,7 @@ sub set_counters { key_values => [ { name => 'stdev' } ], output_template => 'Load Standard Deviation : %.2f', perfdatas => [ - { label => 'stdev', value => 'stdev_absolute', template => '%.2f' }, + { label => 'stdev', value => 'stdev', template => '%.2f' }, ], } }, @@ -49,7 +49,7 @@ sub set_counters { key_values => [ { name => 'mgoutputLoadPerPhase', no_value => 0 } ], output_template => 'Load : %.2f %%', perfdatas => [ - { value => 'mgoutputLoadPerPhase_absolute', template => '%.2f', + { value => 'mgoutputLoadPerPhase', template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 }, ], } @@ -58,7 +58,7 @@ sub set_counters { key_values => [ { name => 'mgoutputCurrent', no_value => 0 } ], output_template => 'Current : %.2f A', perfdatas => [ - { value => 'mgoutputCurrent_absolute', template => '%.2f', + { value => 'mgoutputCurrent', template => '%.2f', min => 0, unit => 'A', label_extra_instance => 1 }, ], } @@ -67,7 +67,7 @@ sub set_counters { key_values => [ { name => 'mgoutputVoltage', no_value => 0 } ], output_template => 'Voltage : %.2f V', perfdatas => [ - { value => 'mgoutputVoltage_absolute', template => '%.2f', + { value => 'mgoutputVoltage', template => '%.2f', unit => 'V', label_extra_instance => 1 }, ], } @@ -76,7 +76,7 @@ sub set_counters { key_values => [ { name => 'mgoutputFrequency', no_value => -1 } ], output_template => 'Frequence : %.2f Hz', perfdatas => [ - { value => 'mgoutputFrequency_absolute', template => '%.2f', + { value => 'mgoutputFrequency', template => '%.2f', unit => 'Hz', label_extra_instance => 1 }, ], } diff --git a/hardware/ups/powerware/snmp/mode/batterystatus.pm b/hardware/ups/powerware/snmp/mode/batterystatus.pm index bdc3fa2d2..339e8e49b 100644 --- a/hardware/ups/powerware/snmp/mode/batterystatus.pm +++ b/hardware/ups/powerware/snmp/mode/batterystatus.pm @@ -53,7 +53,7 @@ sub set_counters { key_values => [ { name => 'xupsBatCapacity' } ], output_template => 'remaining capacity: %s %%', perfdatas => [ - { value => 'xupsBatCapacity_absolute', template => '%s', min => 0, max => 100, unit => '%' }, + { value => 'xupsBatCapacity', template => '%s', min => 0, max => 100, unit => '%' }, ], } }, @@ -61,7 +61,7 @@ sub set_counters { key_values => [ { name => 'xupsBatTimeRemaining' } ], output_template => 'remaining time: %s minutes', perfdatas => [ - { value => 'xupsBatTimeRemaining_absolute', template => '%s', min => 0, unit => 'm' }, + { value => 'xupsBatTimeRemaining', template => '%s', min => 0, unit => 'm' }, ], } }, @@ -69,7 +69,7 @@ sub set_counters { key_values => [ { name => 'xupsBatCurrent', no_value => 0 } ], output_template => 'current: %s A', perfdatas => [ - { value => 'xupsBatCurrent_absolute', template => '%s', unit => 'A' }, + { value => 'xupsBatCurrent', template => '%s', unit => 'A' }, ], } }, @@ -77,7 +77,7 @@ sub set_counters { key_values => [ { name => 'xupsBatVoltage', no_value => 0 } ], output_template => 'voltage: %s V', perfdatas => [ - { value => 'xupsBatVoltage_absolute', template => '%s', unit => 'V' }, + { value => 'xupsBatVoltage', template => '%s', unit => 'V' }, ], } }, diff --git a/hardware/ups/powerware/snmp/mode/environment.pm b/hardware/ups/powerware/snmp/mode/environment.pm index 5d71ec134..7c5b5d134 100644 --- a/hardware/ups/powerware/snmp/mode/environment.pm +++ b/hardware/ups/powerware/snmp/mode/environment.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'internal_temperature' } ], output_template => 'internal temperature: %.2f C', perfdatas => [ - { label => 'internal_temperature', value => 'internal_temperature_absolute', template => '%.2f', + { label => 'internal_temperature', value => 'internal_temperature', template => '%.2f', min => 0, unit => 'C' }, ], } @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'internal_humidity' } ], output_template => 'internal humidity: %.2f %%', perfdatas => [ - { label => 'internal_humidity', value => 'internal_humidity_absolute', template => '%.2f', + { label => 'internal_humidity', value => 'internal_humidity', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } @@ -55,7 +55,7 @@ sub set_counters { key_values => [ { name => 'remote_temperature' } ], output_template => 'remote temperature: %.2f C', perfdatas => [ - { label => 'remote_temperature', value => 'remote_temperature_absolute', template => '%.2f', + { label => 'remote_temperature', value => 'remote_temperature', template => '%.2f', min => 0, unit => 'C' }, ], } @@ -64,7 +64,7 @@ sub set_counters { key_values => [ { name => 'remote_humidity' } ], output_template => 'remote humidity: %.2f %%', perfdatas => [ - { label => 'remote_humidity', value => 'remote_humidity_absolute', template => '%.2f', + { label => 'remote_humidity', value => 'remote_humidity', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } diff --git a/hardware/ups/powerware/snmp/mode/inputlines.pm b/hardware/ups/powerware/snmp/mode/inputlines.pm index 4181739d9..711035d5c 100644 --- a/hardware/ups/powerware/snmp/mode/inputlines.pm +++ b/hardware/ups/powerware/snmp/mode/inputlines.pm @@ -38,7 +38,7 @@ sub set_counters { key_values => [ { name => 'xupsInputFrequency', no_value => 0 } ], output_template => 'frequence: %.2f Hz', perfdatas => [ - { value => 'xupsInputFrequency_absolute', template => '%.2f', + { value => 'xupsInputFrequency', template => '%.2f', unit => 'Hz' }, ], } @@ -50,7 +50,7 @@ sub set_counters { key_values => [ { name => 'xupsInputCurrent', no_value => 0 } ], output_template => 'current: %.2f A', perfdatas => [ - { value => 'xupsInputCurrent_absolute', template => '%.2f', + { value => 'xupsInputCurrent', template => '%.2f', min => 0, unit => 'A', label_extra_instance => 1 }, ], } @@ -59,7 +59,7 @@ sub set_counters { key_values => [ { name => 'xupsInputVoltage', no_value => 0 } ], output_template => 'voltage: %.2f V', perfdatas => [ - { value => 'xupsInputVoltage_absolute', template => '%.2f', + { value => 'xupsInputVoltage', template => '%.2f', unit => 'V', label_extra_instance => 1 }, ], } @@ -68,7 +68,7 @@ sub set_counters { key_values => [ { name => 'xupsInputWatts', no_value => 0 } ], output_template => 'power: %.2f W', perfdatas => [ - { value => 'xupsInputWatts_absolute', template => '%.2f', + { value => 'xupsInputWatts', template => '%.2f', unit => 'W', label_extra_instance => 1 }, ], } diff --git a/hardware/ups/powerware/snmp/mode/outputlines.pm b/hardware/ups/powerware/snmp/mode/outputlines.pm index 75fd73242..408aa93c8 100644 --- a/hardware/ups/powerware/snmp/mode/outputlines.pm +++ b/hardware/ups/powerware/snmp/mode/outputlines.pm @@ -38,7 +38,7 @@ sub set_counters { key_values => [ { name => 'xupsOutputLoad', no_value => -1 } ], output_template => 'Load : %.2f %%', perfdatas => [ - { value => 'xupsOutputLoad_absolute', template => '%.2f', + { value => 'xupsOutputLoad', template => '%.2f', min => 0, max => 100 }, ], } @@ -47,7 +47,7 @@ sub set_counters { key_values => [ { name => 'xupsOutputFrequency', no_value => 0 } ], output_template => 'Frequence : %.2f Hz', perfdatas => [ - { value => 'xupsOutputFrequency_absolute', template => '%.2f', + { value => 'xupsOutputFrequency', template => '%.2f', unit => 'Hz' }, ], } @@ -59,7 +59,7 @@ sub set_counters { key_values => [ { name => 'xupsOutputCurrent', no_value => 0 } ], output_template => 'Current : %.2f A', perfdatas => [ - { value => 'xupsOutputCurrent_absolute', template => '%.2f', + { value => 'xupsOutputCurrent', template => '%.2f', min => 0, unit => 'A', label_extra_instance => 1 }, ], } @@ -68,7 +68,7 @@ sub set_counters { key_values => [ { name => 'xupsOutputVoltage', no_value => 0 } ], output_template => 'Voltage : %.2f V', perfdatas => [ - { value => 'xupsOutputVoltage_absolute', template => '%.2f', + { value => 'xupsOutputVoltage', template => '%.2f', unit => 'V', label_extra_instance => 1 }, ], } @@ -77,7 +77,7 @@ sub set_counters { key_values => [ { name => 'xupsOutputWatts', no_value => 0 } ], output_template => 'Power: %.2f W', perfdatas => [ - { value => 'xupsOutputWatts_absolute', template => '%.2f', + { value => 'xupsOutputWatts', template => '%.2f', unit => 'W', label_extra_instance => 1 }, ], } diff --git a/hardware/ups/standard/rfc1628/snmp/mode/batterystatus.pm b/hardware/ups/standard/rfc1628/snmp/mode/batterystatus.pm index 50be23a72..5717b4f61 100644 --- a/hardware/ups/standard/rfc1628/snmp/mode/batterystatus.pm +++ b/hardware/ups/standard/rfc1628/snmp/mode/batterystatus.pm @@ -36,8 +36,8 @@ sub custom_load_output { my ($self, %options) = @_; return sprintf("charge remaining: %s%% (%s minutes remaining)", - $self->{result_values}->{charge_remain_absolute}, - $self->{result_values}->{minute_remain_absolute} + $self->{result_values}->{charge_remain}, + $self->{result_values}->{minute_remain} ); } @@ -61,7 +61,7 @@ sub set_counters { key_values => [ { name => 'charge_remain' }, { name => 'minute_remain' } ], closure_custom_output => $self->can('custom_load_output'), perfdatas => [ - { label => 'load', value => 'charge_remain_absolute', template => '%s', min => 0, max => 100, unit => '%' }, + { label => 'load', value => 'charge_remain', template => '%s', min => 0, max => 100, unit => '%' }, ], } }, @@ -69,7 +69,7 @@ sub set_counters { key_values => [ { name => 'minute_remain' } ], output_template => 'minutes remaining: %s', perfdatas => [ - { label => 'charge_remaining', value => 'minute_remain_absolute', template => '%s', min => 0, unit => 'minutes' }, + { label => 'charge_remaining', value => 'minute_remain', template => '%s', min => 0, unit => 'minutes' }, ], } }, @@ -77,7 +77,7 @@ sub set_counters { key_values => [ { name => 'current', no_value => 0 } ], output_template => 'current: %s A', perfdatas => [ - { label => 'current', value => 'current_absolute', template => '%s', min => 0, unit => 'A' }, + { label => 'current', value => 'current', template => '%s', min => 0, unit => 'A' }, ], } }, @@ -85,7 +85,7 @@ sub set_counters { key_values => [ { name => 'voltage', no_value => 0 } ], output_template => 'voltage: %s V', perfdatas => [ - { label => 'voltage', value => 'voltage_absolute', template => '%s', unit => 'V' }, + { label => 'voltage', value => 'voltage', template => '%s', unit => 'V' }, ], } }, @@ -93,7 +93,7 @@ sub set_counters { key_values => [ { name => 'temperature', no_value => 0 } ], output_template => 'temperature: %s C', perfdatas => [ - { label => 'temp', value => 'temperature_absolute', template => '%s', unit => 'C' }, + { label => 'temp', value => 'temperature', template => '%s', unit => 'C' }, ], } }, diff --git a/hardware/ups/standard/rfc1628/snmp/mode/inputlines.pm b/hardware/ups/standard/rfc1628/snmp/mode/inputlines.pm index 866062cff..d00a9b39b 100644 --- a/hardware/ups/standard/rfc1628/snmp/mode/inputlines.pm +++ b/hardware/ups/standard/rfc1628/snmp/mode/inputlines.pm @@ -37,8 +37,8 @@ sub set_counters { key_values => [ { name => 'upsInputFrequency' }, { name => 'display' } ], output_template => 'Frequence : %.2f Hz', perfdatas => [ - { label => 'frequence', value => 'upsInputFrequency_absolute', template => '%s', - unit => 'Hz', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'frequence', value => 'upsInputFrequency', template => '%s', + unit => 'Hz', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -46,8 +46,8 @@ sub set_counters { key_values => [ { name => 'upsInputVoltage' }, { name => 'display' } ], output_template => 'Voltage : %.2f V', perfdatas => [ - { label => 'voltage', value => 'upsInputVoltage_absolute', template => '%s', - unit => 'V', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'voltage', value => 'upsInputVoltage', template => '%s', + unit => 'V', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -55,8 +55,8 @@ sub set_counters { key_values => [ { name => 'upsInputCurrent' }, { name => 'display' } ], output_template => 'Current : %.2f A', perfdatas => [ - { label => 'current', value => 'upsInputCurrent_absolute', template => '%s', - unit => 'A', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'current', value => 'upsInputCurrent', template => '%s', + unit => 'A', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -64,8 +64,8 @@ sub set_counters { key_values => [ { name => 'upsInputTruePower' }, { name => 'display' } ], output_template => 'Power : %.2f W', perfdatas => [ - { label => 'power', value => 'upsInputTruePower_absolute', template => '%s', - unit => 'W', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'power', value => 'upsInputTruePower', template => '%s', + unit => 'W', label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/hardware/ups/standard/rfc1628/snmp/mode/outputlines.pm b/hardware/ups/standard/rfc1628/snmp/mode/outputlines.pm index 54f32bc9d..b56ade5fb 100644 --- a/hardware/ups/standard/rfc1628/snmp/mode/outputlines.pm +++ b/hardware/ups/standard/rfc1628/snmp/mode/outputlines.pm @@ -38,7 +38,7 @@ sub set_counters { key_values => [ { name => 'stdev' } ], output_template => 'Load Standard Deviation : %.2f', perfdatas => [ - { label => 'stdev', value => 'stdev_absolute', template => '%.2f' }, + { label => 'stdev', value => 'stdev', template => '%.2f' }, ], } }, @@ -49,7 +49,7 @@ sub set_counters { key_values => [ { name => 'upsOutputPercentLoad' } ], output_template => 'Load : %.2f %%', perfdatas => [ - { value => 'upsOutputPercentLoad_absolute', template => '%.2f', + { value => 'upsOutputPercentLoad', template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 }, ], } @@ -58,7 +58,7 @@ sub set_counters { key_values => [ { name => 'upsOutputCurrent' } ], output_template => 'Current : %.2f A', perfdatas => [ - { value => 'upsOutputCurrent_absolute', template => '%.2f', + { value => 'upsOutputCurrent', template => '%.2f', min => 0, unit => 'A', label_extra_instance => 1 }, ], } @@ -67,7 +67,7 @@ sub set_counters { key_values => [ { name => 'upsOutputVoltage' } ], output_template => 'Voltage : %.2f V', perfdatas => [ - { value => 'upsOutputVoltage_absolute', template => '%.2f', + { value => 'upsOutputVoltage', template => '%.2f', unit => 'V', label_extra_instance => 1 }, ], } @@ -76,7 +76,7 @@ sub set_counters { key_values => [ { name => 'upsOutputPower' } ], output_template => 'Power : %.2f W', perfdatas => [ - { value => 'upsOutputPower_absolute', template => '%.2f', + { value => 'upsOutputPower', template => '%.2f', unit => 'W', label_extra_instance => 1 }, ], } diff --git a/network/3com/snmp/mode/cpu.pm b/network/3com/snmp/mode/cpu.pm index 7e99a70f3..4c4f79b6a 100644 --- a/network/3com/snmp/mode/cpu.pm +++ b/network/3com/snmp/mode/cpu.pm @@ -36,8 +36,8 @@ sub set_counters { key_values => [ { name => 'usage_5s' }, { name => 'display' } ], output_template => '%s %% (5sec)', output_error_template => "%s (5sec)", perfdatas => [ - { label => 'cpu_5s', value => 'usage_5s_absolute', template => '%d', - unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'cpu_5s', value => 'usage_5s', template => '%d', + unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -45,8 +45,8 @@ sub set_counters { key_values => [ { name => 'usage_1m' }, { name => 'display' } ], output_template => '%s %% (1m)', output_error_template => "%s (1min)", perfdatas => [ - { label => 'cpu_1m', value => 'usage_1m_absolute', template => '%d', - unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'cpu_1m', value => 'usage_1m', template => '%d', + unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -54,8 +54,8 @@ sub set_counters { key_values => [ { name => 'usage_5m' }, { name => 'display' } ], output_template => '%s %% (5min)', output_error_template => "%s (5min)", perfdatas => [ - { label => 'cpu_5m', value => 'usage_5m_absolute', template => '%d', - unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'cpu_5m', value => 'usage_5m', template => '%d', + unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/network/a10/ax/snmp/mode/cpu.pm b/network/a10/ax/snmp/mode/cpu.pm index 5152ac668..8988dd7d1 100644 --- a/network/a10/ax/snmp/mode/cpu.pm +++ b/network/a10/ax/snmp/mode/cpu.pm @@ -37,8 +37,8 @@ sub set_counters { key_values => [ { name => 'cpu_30s' }, { name => 'display' } ], output_template => '30s : %s %%', perfdatas => [ - { label => 'cpu_30s', value => 'cpu_30s_absolute', template => '%s', - unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'cpu_30s', value => 'cpu_30s', template => '%s', + unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -46,8 +46,8 @@ sub set_counters { key_values => [ { name => 'cpu_1m' }, { name => 'display' } ], output_template => '1m : %s %%', perfdatas => [ - { label => 'cpu_1m', value => 'cpu_1m_absolute', template => '%s', - unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'cpu_1m', value => 'cpu_1m', template => '%s', + unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/network/a10/ax/snmp/mode/globalstats.pm b/network/a10/ax/snmp/mode/globalstats.pm index 1c0d77e7a..476f45d7d 100644 --- a/network/a10/ax/snmp/mode/globalstats.pm +++ b/network/a10/ax/snmp/mode/globalstats.pm @@ -38,7 +38,7 @@ sub set_counters { key_values => [ { name => 'current_connections' } ], output_template => 'Current Connections : %s', perfdatas => [ - { label => 'current_connections', value => 'current_connections_absolute', template => '%s', + { label => 'current_connections', value => 'current_connections', template => '%s', min => 0 }, ], } @@ -47,7 +47,7 @@ sub set_counters { key_values => [ { name => 'total_connections', diff => 1 } ], output_template => 'Total Connections : %s', perfdatas => [ - { label => 'total_connections', value => 'total_connections_absolute', template => '%s', + { label => 'total_connections', value => 'total_connections', template => '%s', min => 0 }, ], } @@ -56,7 +56,7 @@ sub set_counters { key_values => [ { name => 'total_ssl_connections', diff => 1 } ], output_template => 'Total SSL Connections : %s', perfdatas => [ - { label => 'total_ssl_connections', value => 'total_ssl_connections_absolute', template => '%s', + { label => 'total_ssl_connections', value => 'total_ssl_connections', template => '%s', min => 0 }, ], } diff --git a/network/a10/ax/snmp/mode/vserverusage.pm b/network/a10/ax/snmp/mode/vserverusage.pm index 00e13b3eb..ed57ea02c 100644 --- a/network/a10/ax/snmp/mode/vserverusage.pm +++ b/network/a10/ax/snmp/mode/vserverusage.pm @@ -62,8 +62,8 @@ sub set_counters { key_values => [ { name => 'axVirtualServerStatCurConns' }, { name => 'display' } ], output_template => 'Current Connections : %s', perfdatas => [ - { label => 'current_connections', value => 'axVirtualServerStatCurConns_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'current_connections', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -71,28 +71,28 @@ sub set_counters { key_values => [ { name => 'axVirtualServerStatTotConns', diff => 1 }, { name => 'display' } ], output_template => 'Total Connections : %s', perfdatas => [ - { label => 'total_connections', value => 'axVirtualServerStatTotConns_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'total_connections', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'traffic-in', nlabel => 'virtualserver.traffic.in.bitspersecond', set => { - key_values => [ { name => 'axVirtualServerStatBytesIn', diff => 1 }, { name => 'display' } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'axVirtualServerStatBytesIn', per_second => 1 }, { name => 'display' } ], output_template => 'Traffic In : %s %s/s', + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_in', value => 'axVirtualServerStatBytesIn_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_in', template => '%.2f', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'traffic-out', nlabel => 'virtualserver.traffic.out.bitspersecond', set => { - key_values => [ { name => 'axVirtualServerStatBytesOut', diff => 1 }, { name => 'display' } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'axVirtualServerStatBytesOut', per_second => 1 }, { name => 'display' } ], output_template => 'Traffic Out : %s %s/s', + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_out', value => 'axVirtualServerStatBytesOut_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_out', template => '%.2f', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -110,13 +110,12 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - "warning-status:s" => { name => 'warning_status', default => '' }, - "critical-status:s" => { name => 'critical_status', default => '%{status} =~ /down/i' }, - }); - + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '%{status} =~ /down/i' } + }); + return $self; } diff --git a/network/acmepacket/snmp/mode/realmusage.pm b/network/acmepacket/snmp/mode/realmusage.pm index f01a8b63b..de1cef17c 100644 --- a/network/acmepacket/snmp/mode/realmusage.pm +++ b/network/acmepacket/snmp/mode/realmusage.pm @@ -38,8 +38,8 @@ sub set_counters { key_values => [ { name => 'apSigRealmStatsCurrentActiveSessionsInbound' }, { name => 'display' } ], output_template => 'Current Inbound Sessions : %s', perfdatas => [ - { label => 'current_inbound_sessions', value => 'apSigRealmStatsCurrentActiveSessionsInbound_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'current_inbound_sessions', value => 'apSigRealmStatsCurrentActiveSessionsInbound', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -47,8 +47,8 @@ sub set_counters { key_values => [ { name => 'apSigRealmStatsCurrentSessionRateInbound' }, { name => 'display' } ], output_template => 'Current Inbound Sessions Rate : %s/s', perfdatas => [ - { label => 'current_inbound_sessions_rate', value => 'apSigRealmStatsCurrentSessionRateInbound_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'current_inbound_sessions_rate', value => 'apSigRealmStatsCurrentSessionRateInbound', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -56,8 +56,8 @@ sub set_counters { key_values => [ { name => 'apSigRealmStatsTotalSessionsInbound', diff => 1 }, { name => 'display' } ], output_template => 'Total Inbound Sessions : %s', perfdatas => [ - { label => 'total_inbound_sessions', value => 'apSigRealmStatsTotalSessionsInbound_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'total_inbound_sessions', value => 'apSigRealmStatsTotalSessionsInbound', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -65,8 +65,8 @@ sub set_counters { key_values => [ { name => 'apSigRealmStatsCurrentActiveSessionsOutbound' }, { name => 'display' } ], output_template => 'Current Outbound Sessions : %s', perfdatas => [ - { label => 'current_outbound_sessions', value => 'apSigRealmStatsCurrentActiveSessionsOutbound_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'current_outbound_sessions', value => 'apSigRealmStatsCurrentActiveSessionsOutbound', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -74,8 +74,8 @@ sub set_counters { key_values => [ { name => 'apSigRealmStatsCurrentSessionRateOutbound' }, { name => 'display' } ], output_template => 'Current Outbound Sessions Rate : %s/s', perfdatas => [ - { label => 'current_outbound_sessions_rate', value => 'apSigRealmStatsCurrentSessionRateOutbound_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'current_outbound_sessions_rate', value => 'apSigRealmStatsCurrentSessionRateOutbound', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -83,8 +83,8 @@ sub set_counters { key_values => [ { name => 'apSigRealmStatsTotalSessionsOutbound', diff => 1 }, { name => 'display' } ], output_template => 'Total Outbound Sessions : %s', perfdatas => [ - { label => 'total_outbound_sessions', value => 'apSigRealmStatsTotalSessionsOutbound_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'total_outbound_sessions', value => 'apSigRealmStatsTotalSessionsOutbound', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -92,8 +92,8 @@ sub set_counters { key_values => [ { name => 'apSigRealmStatsAverageQoSRFactor' }, { name => 'display' } ], output_template => 'Average QoS RFactor : %s', perfdatas => [ - { label => 'avg_qos_rfactor', value => 'apSigRealmStatsAverageQoSRFactor_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'avg_qos_rfactor', value => 'apSigRealmStatsAverageQoSRFactor', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -101,8 +101,8 @@ sub set_counters { key_values => [ { name => 'apSigRealmStatsTotalMajorRFactorExceeded', diff => 1 }, { name => 'display' } ], output_template => 'Total Rfactor Exceeded : %s', perfdatas => [ - { label => 'total_rfactor', value => 'apSigRealmStatsTotalMajorRFactorExceeded_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'total_rfactor', value => 'apSigRealmStatsTotalMajorRFactorExceeded', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/network/acmepacket/snmp/mode/sipusage.pm b/network/acmepacket/snmp/mode/sipusage.pm index af674f1ca..65a5d2cd1 100644 --- a/network/acmepacket/snmp/mode/sipusage.pm +++ b/network/acmepacket/snmp/mode/sipusage.pm @@ -58,22 +58,20 @@ sub set_counters { } }, { label => 'in-sessions-rate', nlabel => 'sip.sessions.in.rate', set => { - key_values => [ { name => 'apSipSAStatsTotalSessionsInbound', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'apSipSAStatsTotalSessionsInbound', per_second => 1 }, { name => 'display' } ], output_template => 'Inbound Sessions Rate : %.2f/s', - per_second => 1, perfdatas => [ - { label => 'inbound_sessions_rate', value => 'apSipSAStatsTotalSessionsInbound_per_second', template => '%.2f', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'inbound_sessions_rate', template => '%.2f', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'out-sessions-rate', nlabel => 'sip.sessions.out.rate', set => { - key_values => [ { name => 'apSipSAStatsTotalSessionsOutbound', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'apSipSAStatsTotalSessionsOutbound', per_second => 1 }, { name => 'display' } ], output_template => 'Outbound Sessions Rate : %.2f/s', - per_second => 1, perfdatas => [ - { label => 'outbound_sessions_rate', value => 'apSipSAStatsTotalSessionsOutbound_per_second', template => '%.2f', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'outbound_sessions_rate', template => '%.2f', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -81,8 +79,8 @@ sub set_counters { key_values => [ { name => 'apSipSAStatsAverageLatency' }, { name => 'display' } ], output_template => 'Average Latency : %s ms', perfdatas => [ - { label => 'avg_latency', value => 'apSipSAStatsAverageLatency_absolute', template => '%s', - unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'avg_latency', template => '%s', + unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -90,8 +88,8 @@ sub set_counters { key_values => [ { name => 'apSipSAStatsPeriodASR' }, { name => 'display' } ], output_template => 'Answer-to-seizure Ratio : %s %%', perfdatas => [ - { label => 'asr', value => 'apSipSAStatsPeriodASR_absolute', template => '%s', - unit => '%', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'asr', template => '%s', + unit => '%', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -109,13 +107,12 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - "warning-status:s" => { name => 'warning_status', default => '' }, - "critical-status:s" => { name => 'critical_status', default => '%{status} =~ /outOfService|constraintsViolation|inServiceTimedOut/i' }, - }); - + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '%{status} =~ /outOfService|constraintsViolation|inServiceTimedOut/i' } + }); + return $self; } diff --git a/network/acmepacket/snmp/mode/systemusage.pm b/network/acmepacket/snmp/mode/systemusage.pm index 6a98e117a..5249c62f5 100644 --- a/network/acmepacket/snmp/mode/systemusage.pm +++ b/network/acmepacket/snmp/mode/systemusage.pm @@ -52,7 +52,7 @@ sub set_counters { key_values => [ { name => 'health_score' } ], output_template => 'Health Score : %.2f %%', perfdatas => [ - { label => 'health_score', value => 'health_score_absolute', template => '%.2f', + { label => 'health_score', value => 'health_score', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } @@ -61,7 +61,7 @@ sub set_counters { key_values => [ { name => 'cpu_load' } ], output_template => 'Cpu Load : %.2f %%', perfdatas => [ - { label => 'cpu_load', value => 'cpu_load_absolute', template => '%.2f', + { label => 'cpu_load', value => 'cpu_load', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } @@ -70,7 +70,7 @@ sub set_counters { key_values => [ { name => 'memory_used' } ], output_template => 'Memory Used : %.2f %%', perfdatas => [ - { label => 'memory_used', value => 'memory_used_absolute', template => '%.2f', + { label => 'memory_used', value => 'memory_used', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } @@ -79,7 +79,7 @@ sub set_counters { key_values => [ { name => 'license_used' } ], output_template => 'License Used : %.2f %%', perfdatas => [ - { label => 'license_used', value => 'license_used_absolute', template => '%.2f', + { label => 'license_used', value => 'license_used', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } @@ -88,7 +88,7 @@ sub set_counters { key_values => [ { name => 'current_sessions' } ], output_template => 'Current Sessions : %s', perfdatas => [ - { label => 'current_sessions', value => 'current_sessions_absolute', template => '%s', + { label => 'current_sessions', value => 'current_sessions', template => '%s', min => 0 }, ], } @@ -97,7 +97,7 @@ sub set_counters { key_values => [ { name => 'current_calls' } ], output_template => 'Current Calls : %s/s', perfdatas => [ - { label => 'current_calls', value => 'current_calls_absolute', template => '%s', + { label => 'current_calls', value => 'current_calls', template => '%s', unit => '/s', min => 0 }, ], } diff --git a/network/adva/fsp150/snmp/mode/systems.pm b/network/adva/fsp150/snmp/mode/systems.pm index d4a345c5e..69eaecf34 100644 --- a/network/adva/fsp150/snmp/mode/systems.pm +++ b/network/adva/fsp150/snmp/mode/systems.pm @@ -52,11 +52,11 @@ sub set_counters { nlabel => $self->{nlabel}, unit => '%', instances => [ - $self->{result_values}->{ne_name_absolute}, - $self->{result_values}->{shelf_name_absolute}, - $self->{result_values}->{slot_name_absolute} + $self->{result_values}->{ne_name}, + $self->{result_values}->{shelf_name}, + $self->{result_values}->{slot_name} ], - value => sprintf('%.2f', $self->{result_values}->{cpu_average_absolute}), + value => sprintf('%.2f', $self->{result_values}->{cpu_average}), warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}), min => 0, max => 100 @@ -78,11 +78,11 @@ sub set_counters { nlabel => $self->{nlabel}, unit => 'B', instances => [ - $self->{result_values}->{ne_name_absolute}, - $self->{result_values}->{shelf_name_absolute}, - $self->{result_values}->{slot_name_absolute} + $self->{result_values}->{ne_name}, + $self->{result_values}->{shelf_name}, + $self->{result_values}->{slot_name} ], - value => $self->{result_values}->{memory_used_absolute}, + value => $self->{result_values}->{memory_used}, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}), min => 0 diff --git a/network/adva/fsp3000/snmp/mode/interfaces.pm b/network/adva/fsp3000/snmp/mode/interfaces.pm index c5d33d00f..a1e8f9ca6 100644 --- a/network/adva/fsp3000/snmp/mode/interfaces.pm +++ b/network/adva/fsp3000/snmp/mode/interfaces.pm @@ -42,22 +42,20 @@ sub set_counters_traffic { push @{$self->{maps_counters}->{int}}, { label => 'traffic-in', filter => 'add_traffic', nlabel => 'interface.traffic.in.bitspersecond', set => { key_values => [ { name => 'traffic_in_15min', diff => 1 }, { name => 'traffic_in_1day', diff => 1 }, { name => 'speed_in'}, { name => 'display' } ], - per_second => 1, closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'in' }, closure_custom_output => $self->can('custom_traffic_output'), output_error_template => 'Traffic In : %s', closure_custom_perfdata => $self->can('custom_traffic_perfdata'), - closure_custom_threshold_check => $self->can('custom_traffic_threshold'), + closure_custom_threshold_check => $self->can('custom_traffic_threshold') } }, { label => 'traffic-out', filter => 'add_traffic', nlabel => 'interface.traffic.out.bitspersecond', set => { key_values => [ { name => 'traffic_out_15min', diff => 1 }, { name => 'traffic_out_1day', diff => 1 }, { name => 'speed_out'}, { name => 'display' } ], - per_second => 1, closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'out' }, closure_custom_output => $self->can('custom_traffic_output'), output_error_template => 'Traffic Out : %s', closure_custom_perfdata => $self->can('custom_traffic_perfdata'), - closure_custom_threshold_check => $self->can('custom_traffic_threshold'), + closure_custom_threshold_check => $self->can('custom_traffic_threshold') } - }, + } ; } @@ -71,8 +69,8 @@ sub set_counters { key_values => [ { name => 'laser_temp' }, { name => 'display' } ], output_template => 'Laser Temperature : %.2f C', output_error_template => 'Laser Temperature : %.2f', perfdatas => [ - { label => 'laser_temp', value => 'laser_temp_absolute', template => '%.2f', - unit => 'C', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'laser_temp', template => '%.2f', + unit => 'C', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -80,8 +78,8 @@ sub set_counters { key_values => [ { name => 'input_power' }, { name => 'display' } ], output_template => 'Input Power : %s dBm', output_error_template => 'Input Power : %s', perfdatas => [ - { label => 'input_power', value => 'input_power_absolute', template => '%s', - unit => 'dBm', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'input_power', template => '%s', + unit => 'dBm', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -89,8 +87,8 @@ sub set_counters { key_values => [ { name => 'output_power' }, { name => 'display' } ], output_template => 'Output Power : %s dBm', output_error_template => 'Output Power : %s', perfdatas => [ - { label => 'output_power', value => 'output_power_absolute', template => '%s', - unit => 'dBm', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'output_power', template => '%s', + unit => 'dBm', label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/network/aerohive/snmp/mode/connectedusers.pm b/network/aerohive/snmp/mode/connectedusers.pm index 9d08a517e..04dc84c50 100644 --- a/network/aerohive/snmp/mode/connectedusers.pm +++ b/network/aerohive/snmp/mode/connectedusers.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'total' } ], output_template => 'Total Users : %s', perfdatas => [ - { label => 'total', value => 'total_absolute', template => '%s', + { label => 'total', value => 'total', template => '%s', unit => 'users', min => 0 }, ], } @@ -48,8 +48,8 @@ sub set_counters { key_values => [ { name => 'total' }, { name => 'display' } ], output_template => 'users : %s', perfdatas => [ - { label => 'ssid', value => 'total_absolute', template => '%s', - unit => 'users', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'ssid', value => 'total', template => '%s', + unit => 'users', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/network/alcatel/isam/snmp/mode/cpu.pm b/network/alcatel/isam/snmp/mode/cpu.pm index c2ff800c1..6fbdea86d 100644 --- a/network/alcatel/isam/snmp/mode/cpu.pm +++ b/network/alcatel/isam/snmp/mode/cpu.pm @@ -37,8 +37,8 @@ sub set_counters { key_values => [ { name => 'usage' }, { name => 'display' }, ], output_template => 'Usage : %.2f %%', perfdatas => [ - { label => 'cpu', value => 'usage_absolute', template => '%.2f', - min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'cpu', value => 'usage', template => '%.2f', + min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/network/alcatel/isam/snmp/mode/hubsapusage.pm b/network/alcatel/isam/snmp/mode/hubsapusage.pm index 4524380d1..614d1e6cf 100644 --- a/network/alcatel/isam/snmp/mode/hubsapusage.pm +++ b/network/alcatel/isam/snmp/mode/hubsapusage.pm @@ -42,25 +42,23 @@ sub set_counters { closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => $self->can('custom_status_threshold'), + closure_custom_threshold_check => $self->can('custom_status_threshold') } }, { label => 'in-traffic', nlabel => 'sap.traffic.in.bitspersecond', set => { key_values => [ { name => 'in', diff => 1 }, { name => 'display' } ], - per_second => 1, closure_custom_calc => $self->can('custom_sap_calc'), closure_custom_calc_extra_options => { label_ref => 'in' }, closure_custom_output => $self->can('custom_sap_output'), closure_custom_perfdata => $self->can('custom_sap_perfdata'), - closure_custom_threshold_check => $self->can('custom_qsap_threshold'), + closure_custom_threshold_check => $self->can('custom_qsap_threshold') } }, { label => 'out-traffic', nlabel => 'sap.traffic.out.bitspersecond', set => { key_values => [ { name => 'out', diff => 1 }, { name => 'display' } ], - per_second => 1, closure_custom_calc => $self->can('custom_sap_calc'), closure_custom_calc_extra_options => { label_ref => 'out' }, closure_custom_output => $self->can('custom_sap_output'), closure_custom_perfdata => $self->can('custom_sap_perfdata'), - closure_custom_threshold_check => $self->can('custom_sap_threshold'), + closure_custom_threshold_check => $self->can('custom_sap_threshold') } }, ]; @@ -68,20 +66,20 @@ sub set_counters { $self->{maps_counters}->{global} = [ { label => 'total-in-traffic', nlabel => 'sap.traffic.in.bitspersecond', set => { key_values => [], - manual_keys => 1, per_second => 1, output_change_bytes => 2, + manual_keys => 1, closure_custom_calc => $self->can('custom_total_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'in' }, closure_custom_output => $self->can('custom_total_traffic_output'), closure_custom_perfdata => $self->can('custom_total_traffic_perfdata'), - closure_custom_threshold_check => $self->can('custom_total_traffic_threshold'), + closure_custom_threshold_check => $self->can('custom_total_traffic_threshold') } }, { label => 'total-out-traffic', nlabel => 'sap.traffic.out.bitspersecond', set => { key_values => [], - manual_keys => 1, per_second => 1, output_change_bytes => 2, + manual_keys => 1, closure_custom_calc => $self->can('custom_total_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'out' }, closure_custom_output => $self->can('custom_total_traffic_output'), closure_custom_perfdata => $self->can('custom_total_traffic_perfdata'), - closure_custom_threshold_check => $self->can('custom_total_traffic_threshold'), + closure_custom_threshold_check => $self->can('custom_total_traffic_threshold') } }, ]; @@ -283,16 +281,16 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - "reload-cache-time:s" => { name => 'reload_cache_time', default => 300 }, - "display-name:s" => { name => 'display_name', default => '%{SvcDescription}.%{IfName}.%{SapEncapName}' }, - "filter-name:s" => { name => 'filter_name' }, - "speed-in:s" => { name => 'speed_in' }, - "speed-out:s" => { name => 'speed_out' }, - "speed-total-in:s" => { name => 'speed_total_in' }, - "speed-total-out:s" => { name => 'speed_total_out' }, - "units-traffic:s" => { name => 'units_traffic', default => '%' }, - "warning-status:s" => { name => 'warning_status', default => '' }, - "critical-status:s" => { name => 'critical_status', default => '%{admin} =~ /up/i and %{status} !~ /up/i' }, + 'reload-cache-time:s' => { name => 'reload_cache_time', default => 300 }, + 'display-name:s' => { name => 'display_name', default => '%{SvcDescription}.%{IfName}.%{SapEncapName}' }, + 'filter-name:s' => { name => 'filter_name' }, + 'speed-in:s' => { name => 'speed_in' }, + 'speed-out:s' => { name => 'speed_out' }, + 'speed-total-in:s' => { name => 'speed_total_in' }, + 'speed-total-out:s' => { name => 'speed_total_out' }, + 'units-traffic:s' => { name => 'units_traffic', default => '%' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '%{admin} =~ /up/i and %{status} !~ /up/i' }, }); $self->{statefile_cache} = centreon::plugins::statefile->new(%options); diff --git a/network/alcatel/pss/1830/snmp/mode/sapqosstats.pm b/network/alcatel/pss/1830/snmp/mode/sapqosstats.pm index f69f9135b..6e492b3fc 100644 --- a/network/alcatel/pss/1830/snmp/mode/sapqosstats.pm +++ b/network/alcatel/pss/1830/snmp/mode/sapqosstats.pm @@ -41,46 +41,42 @@ sub set_counters { closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => \&catalog_status_threshold, + closure_custom_threshold_check => \&catalog_status_threshold } }, { label => 'traffic-in-below-cir', set => { - key_values => [ { name => 'tnSapBaseStatsIngressQchipForwardedInProfOctets', diff => 1 }, { name => 'display' } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'tnSapBaseStatsIngressQchipForwardedInProfOctets', per_second => 1 }, { name => 'display' } ], output_template => 'Traffic In Below CIR : %s %s/s', + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_in_below_cir', value => 'tnSapBaseStatsIngressQchipForwardedInProfOctets_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_in_below_cir', template => '%.2f', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'traffic-in-above-cir', set => { - key_values => [ { name => 'tnSapBaseStatsIngressQchipForwardedOutProfOctets', diff => 1 }, { name => 'display' } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'tnSapBaseStatsIngressQchipForwardedOutProfOctets', per_second => 1 }, { name => 'display' } ], output_template => 'Traffic In Above CIR : %s %s/s', + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_in_above_cir', value => 'tnSapBaseStatsIngressQchipForwardedOutProfOctets_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_in_above_cir', template => '%.2f', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'traffic-out-below-cir', set => { - key_values => [ { name => 'tnSapBaseStatsEgressQchipForwardedInProfOctets', diff => 1 }, { name => 'display' } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'tnSapBaseStatsEgressQchipForwardedInProfOctets', per_second => 1 }, { name => 'display' } ], output_template => 'Traffic Out Below CIR : %s %s/s', + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_out_below_cir', value => 'tnSapBaseStatsEgressQchipForwardedInProfOctets_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_out_below_cir', template => '%.2f', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'traffic-out-above-cir', set => { - key_values => [ { name => 'tnSapBaseStatsEgressQchipForwardedOutProfOctets', diff => 1 }, { name => 'display' } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'tnSapBaseStatsEgressQchipForwardedOutProfOctets', per_second => 1 }, { name => 'display' } ], output_template => 'Traffic Out Above CIR : %s %s/s', + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_out_above_cir', value => 'tnSapBaseStatsEgressQchipForwardedOutProfOctets_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_out_above_cir', template => '%.2f', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -108,15 +104,14 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; - $options{options}->add_options(arguments => - { - "reload-cache-time:s" => { name => 'reload_cache_time', default => 300 }, - "display-name:s" => { name => 'display_name', default => '%{SysSwitchId}.%{SvcId}.%{SapPortId}.%{SapEncapValue}' }, - "filter-name:s" => { name => 'filter_name' }, - "warning-status:s" => { name => 'warning_status', default => '' }, - "critical-status:s" => { name => 'critical_status', default => '%{admin} =~ /up/i and %{status} !~ /up/i' }, - }); - + $options{options}->add_options(arguments => { + 'reload-cache-time:s' => { name => 'reload_cache_time', default => 300 }, + 'display-name:s' => { name => 'display_name', default => '%{SysSwitchId}.%{SvcId}.%{SapPortId}.%{SapEncapValue}' }, + 'filter-name:s' => { name => 'filter_name' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '%{admin} =~ /up/i and %{status} !~ /up/i' } + }); + $self->{statefile_cache} = centreon::plugins::statefile->new(%options); return $self; } diff --git a/network/allied/snmp/mode/cpu.pm b/network/allied/snmp/mode/cpu.pm index b3078d390..b8ae1fb73 100644 --- a/network/allied/snmp/mode/cpu.pm +++ b/network/allied/snmp/mode/cpu.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'average_1m' } ], output_template => '%.2f %% (1m)', perfdatas => [ - { value => 'average_1m_absolute', template => '%.2f', + { value => 'average_1m', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'average_5m' } ], output_template => '%.2f %% (5m)', perfdatas => [ - { value => 'average_5m_absolute', template => '%.2f', + { value => 'average_5m', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } diff --git a/network/allied/snmp/mode/memory.pm b/network/allied/snmp/mode/memory.pm index 91bc2989b..0e33e34ef 100644 --- a/network/allied/snmp/mode/memory.pm +++ b/network/allied/snmp/mode/memory.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'used_prct' } ], output_template => 'memory used: %.2f %%', perfdatas => [ - { value => 'used_prct_absolute', template => '%.2f', + { value => 'used_prct', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } diff --git a/network/alvarion/breezeaccess/snmp/mode/radiostatus.pm b/network/alvarion/breezeaccess/snmp/mode/radiostatus.pm index af225d0ca..114ed7c79 100644 --- a/network/alvarion/breezeaccess/snmp/mode/radiostatus.pm +++ b/network/alvarion/breezeaccess/snmp/mode/radiostatus.pm @@ -50,7 +50,7 @@ sub set_counters { key_values => [ { name => 'rx_snr' } ], output_template => 'Average signal to noise ratio: %s Dbm', perfdatas => [ - { label => 'rx_snr', value => 'rx_snr_absolute', template => '%s', min => 0 , unit => 'Dbm' }, + { label => 'rx_snr', value => 'rx_snr', template => '%s', min => 0 , unit => 'Dbm' }, ], } }, @@ -58,7 +58,7 @@ sub set_counters { key_values => [ { name => 'rx_power' } ], output_template => 'Received signal strength: %s Dbm', perfdatas => [ - { label => 'rx_power', value => 'rx_power_absolute', template => '%s', min => 0 , unit => 'Dbm' }, + { label => 'rx_power', value => 'rx_power', template => '%s', min => 0 , unit => 'Dbm' }, ], } }, diff --git a/network/arista/snmp/mode/memory.pm b/network/arista/snmp/mode/memory.pm index 9d8b90d59..13071a73c 100644 --- a/network/arista/snmp/mode/memory.pm +++ b/network/arista/snmp/mode/memory.pm @@ -30,11 +30,11 @@ sub custom_usage_output { return sprintf( 'Ram Total: %s %s Used (-buffers/cache): %s %s (%.2f%%) Free: %s %s (%.2f%%)', - $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_absolute}), - $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_absolute}), - $self->{result_values}->{prct_used_absolute}, - $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute}), - $self->{result_values}->{prct_free_absolute} + $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}), + $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}), + $self->{result_values}->{prct_used}, + $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}), + $self->{result_values}->{prct_free} ); } @@ -50,7 +50,7 @@ sub set_counters { key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ - { value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute', + { value => 'used', template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1 } ] } @@ -59,7 +59,7 @@ sub set_counters { key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ - { value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute', + { value => 'free', template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1 } ] } @@ -68,7 +68,7 @@ sub set_counters { key_values => [ { name => 'prct_used' } ], output_template => 'Ram Used : %.2f %%', perfdatas => [ - { value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, + { value => 'prct_used', template => '%.2f', min => 0, max => 100, unit => '%' } ] } @@ -78,7 +78,7 @@ sub set_counters { output_template => 'Buffer: %s %s', output_change_bytes => 1, perfdatas => [ - { value => 'buffer_absolute', template => '%d', + { value => 'buffer', template => '%d', min => 0, unit => 'B' } ] } @@ -88,7 +88,7 @@ sub set_counters { output_template => 'Cached: %s %s', output_change_bytes => 1, perfdatas => [ - { value => 'cached_absolute', template => '%d', + { value => 'cached', template => '%d', min => 0, unit => 'B' } ] } diff --git a/network/aruba/instant/snmp/mode/apusage.pm b/network/aruba/instant/snmp/mode/apusage.pm index 11f976a00..2989321c9 100644 --- a/network/aruba/instant/snmp/mode/apusage.pm +++ b/network/aruba/instant/snmp/mode/apusage.pm @@ -37,11 +37,11 @@ sub custom_memory_output { my ($self, %options) = @_; my $msg = sprintf("Memory Total: %s %s Used: %s %s (%.2f%%) Free: %s %s (%.2f%%)", - $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_absolute}), - $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_absolute}), - $self->{result_values}->{prct_used_absolute}, - $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute}), - $self->{result_values}->{prct_free_absolute}); + $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}), + $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}), + $self->{result_values}->{prct_used}, + $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}), + $self->{result_values}->{prct_free}); return $msg; } @@ -59,7 +59,7 @@ sub set_counters { key_values => [ { name => 'total' } ], output_template => 'total access points: %s', perfdatas => [ - { value => 'total_absolute', template => '%s', min => 0 }, + { value => 'total', template => '%s', min => 0 }, ], } }, @@ -78,8 +78,8 @@ sub set_counters { key_values => [ { name => 'clients' }, { name => 'display' } ], output_template => 'Current Clients: %s', perfdatas => [ - { label => 'clients', value => 'clients_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'clients', value => 'clients', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -87,8 +87,8 @@ sub set_counters { key_values => [ { name => 'cpu' }, { name => 'display' } ], output_template => 'Cpu: %.2f%%', perfdatas => [ - { label => 'cpu', value => 'cpu_absolute', template => '%.2f', - min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'cpu', value => 'cpu', template => '%.2f', + min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -97,8 +97,8 @@ sub set_counters { { name => 'prct_free' }, { name => 'total' }, { name => 'display' } ], closure_custom_output => $self->can('custom_memory_output'), perfdatas => [ - { label => 'mem_used', value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute', - unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'mem_used', value => 'used', template => '%d', min => 0, max => 'total', + unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -107,8 +107,8 @@ sub set_counters { { name => 'prct_free' }, { name => 'total' }, { name => 'display' } ], closure_custom_output => $self->can('custom_memory_output'), perfdatas => [ - { label => 'mem_free', value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute', - unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'mem_free', value => 'free', template => '%d', min => 0, max => 'total', + unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -116,8 +116,8 @@ sub set_counters { key_values => [ { name => 'prct_used' }, { name => 'display' } ], output_template => 'Memory Used: %.2f %%', perfdatas => [ - { label => 'mem_used_prct', value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, - unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'mem_used_prct', value => 'prct_used', template => '%.2f', min => 0, max => 100, + unit => '%', label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/network/atrica/snmp/mode/connections.pm b/network/atrica/snmp/mode/connections.pm index 01976643c..bc7f2c6f6 100644 --- a/network/atrica/snmp/mode/connections.pm +++ b/network/atrica/snmp/mode/connections.pm @@ -148,7 +148,6 @@ sub set_counters_traffic { push @{$self->{maps_counters}->{int}}, { label => 'in-cir', filter => 'add_traffic', nlabel => 'interface.traffic.in.cir.bitspersecond', set => { key_values => [ { name => 'in_cir', diff => 1 }, { name => 'speed_in'}, { name => 'display' } ], - per_second => 1, closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'in_cir' }, closure_custom_output => $self->can('custom_traffic_output'), output_error_template => 'Traffic In CIR : %s', closure_custom_perfdata => $self->can('custom_traffic_perfdata'), @@ -157,7 +156,6 @@ sub set_counters_traffic { }, { label => 'in-eir', filter => 'add_traffic', nlabel => 'interface.traffic.in.eir.bitspersecond', set => { key_values => [ { name => 'in_eir', diff => 1 }, { name => 'speed_in'}, { name => 'display' } ], - per_second => 1, closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'in_eir' }, closure_custom_output => $self->can('custom_traffic_output'), output_error_template => 'Traffic In EIR : %s', closure_custom_perfdata => $self->can('custom_traffic_perfdata'), @@ -166,7 +164,6 @@ sub set_counters_traffic { }, { label => 'out-cir', filter => 'add_traffic', nlabel => 'interface.traffic.out.cir.bitspersecond', set => { key_values => [ { name => 'out_cir', diff => 1 }, { name => 'speed_out'}, { name => 'display' } ], - per_second => 1, closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'out_cir' }, closure_custom_output => $self->can('custom_traffic_output'), output_error_template => 'Traffic Out CIR : %s', closure_custom_perfdata => $self->can('custom_traffic_perfdata'), @@ -175,13 +172,12 @@ sub set_counters_traffic { }, { label => 'out-eir', filter => 'add_traffic', nlabel => 'interface.traffic.out.eir.bitspersecond', set => { key_values => [ { name => 'out_eir', diff => 1 }, { name => 'speed_out'}, { name => 'display' } ], - per_second => 1, closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'out_eir' }, closure_custom_output => $self->can('custom_traffic_output'), output_error_template => 'Traffic Out EIR : %s', closure_custom_perfdata => $self->can('custom_traffic_perfdata'), closure_custom_threshold_check => $self->can('custom_traffic_threshold'), } - }, + } ; } @@ -191,7 +187,6 @@ sub set_counters_errors { push @{$self->{maps_counters}->{int}}, { label => 'in-eir-discard', filter => 'add_errors', nlabel => 'interface.packets.in.eir.discard.count', set => { key_values => [ { name => 'in_eir_discard', diff => 1 }, { name => 'speed_in'}, { name => 'display' } ], - per_second => 1, closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'in_eir_discard' }, closure_custom_output => $self->can('custom_traffic_output'), output_error_template => 'Traffic In EIR Discard : %s', closure_custom_perfdata => $self->can('custom_traffic_perfdata'), @@ -200,13 +195,12 @@ sub set_counters_errors { }, { label => 'out-eir-discard', filter => 'add_errors', nlabel => 'interface.packets.out.eir.discard.count', set => { key_values => [ { name => 'out_eir_discard', diff => 1 }, { name => 'speed_out'}, { name => 'display' } ], - per_second => 1, closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'out_eir_discard' }, closure_custom_output => $self->can('custom_traffic_output'), output_error_template => 'Traffic Out EIR Discard : %s', closure_custom_perfdata => $self->can('custom_traffic_perfdata'), closure_custom_threshold_check => $self->can('custom_traffic_threshold'), } - }, + } ; } diff --git a/network/atto/fibrebridge/snmp/mode/fcportusage.pm b/network/atto/fibrebridge/snmp/mode/fcportusage.pm index 8f6df5378..a58d39891 100644 --- a/network/atto/fibrebridge/snmp/mode/fcportusage.pm +++ b/network/atto/fibrebridge/snmp/mode/fcportusage.pm @@ -57,26 +57,24 @@ sub set_counters { closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => \&catalog_status_threshold, + closure_custom_threshold_check => \&catalog_status_threshold } }, { label => 'traffic-in', nlabel => 'fc.port.traffic.in.wordspersecond', set => { - key_values => [ { name => 'fcStatsRxWords', diff => 1 }, { name => 'display' } ], - per_second => 1, + key_values => [ { name => 'fcStatsRxWords', per_second => 1 }, { name => 'display' } ], output_template => 'traffic in : %.2f words/s', perfdatas => [ - { label => 'traffic_in', template => '%.2f', value => 'fcStatsRxWords_per_second', - unit => 'words/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_in', template => '%.2f', + unit => 'words/s', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'traffic-out', nlabel => 'fc.port.traffic.out.wordspersecond', set => { - key_values => [ { name => 'fcStatsTxWords', diff => 1 }, { name => 'display' } ], - per_second => 1, + key_values => [ { name => 'fcStatsTxWords', per_second => 1 }, { name => 'display' } ], output_template => 'traffic out : %.2f words/s', perfdatas => [ - { label => 'traffic_out', template => '%.2f', value => 'fcStatsTxWords_per_second', - unit => 'words/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_out', template => '%.2f', + unit => 'words/s', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -84,8 +82,7 @@ sub set_counters { key_values => [ { name => 'fcStatsErrInvalidCRC', diff => 1 }, { name => 'display' } ], output_template => 'number of invalid CRC : %s', perfdatas => [ - { label => 'invalid_crc', value => 'fcStatsErrInvalidCRC_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'invalid_crc', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -93,11 +90,10 @@ sub set_counters { key_values => [ { name => 'fcStatsErrSignalLoss', diff => 1 }, { name => 'display' } ], output_template => 'number of signal loss : %s', perfdatas => [ - { label => 'signal_loss', value => 'fcStatsErrSignalLoss_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, - ], + { label => 'signal_loss', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' }, + ] } - }, + } ]; } @@ -113,9 +109,9 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - "filter-name:s" => { name => 'filter_name' }, - "warning-status:s" => { name => 'warning_status', default => '' }, - "critical-status:s" => { name => 'critical_status', default => '%{admin} =~ /enabled/ and %{status} !~ /online/' }, + 'filter-name:s' => { name => 'filter_name' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '%{admin} =~ /enabled/ and %{status} !~ /online/' } }); return $self; diff --git a/network/audiocodes/snmp/mode/cpu.pm b/network/audiocodes/snmp/mode/cpu.pm index 1b8413dc7..06590819c 100644 --- a/network/audiocodes/snmp/mode/cpu.pm +++ b/network/audiocodes/snmp/mode/cpu.pm @@ -36,7 +36,7 @@ sub set_counters { key_values => [ { name => 'voip' } ], output_template => 'CPU VoIp Usage : %.2f %%', perfdatas => [ - { label => 'cpu_voip', value => 'voip_absolute', template => '%.2f', min => 0, max => 100, unit => '%' }, + { label => 'cpu_voip', value => 'voip', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } }, @@ -44,7 +44,7 @@ sub set_counters { key_values => [ { name => 'data' } ], output_template => 'CPU Data Usage : %.2f %%', perfdatas => [ - { label => 'cpu_data', value => 'data_absolute', template => '%.2f', min => 0, max => 100, unit => '%' }, + { label => 'cpu_data', value => 'data', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } }, diff --git a/network/audiocodes/snmp/mode/memory.pm b/network/audiocodes/snmp/mode/memory.pm index 92c6d5e1b..7a92c5b19 100644 --- a/network/audiocodes/snmp/mode/memory.pm +++ b/network/audiocodes/snmp/mode/memory.pm @@ -36,7 +36,7 @@ sub set_counters { key_values => [ { name => 'voip' } ], output_template => 'Memory VoIp Usage : %.2f %%', perfdatas => [ - { label => 'used_voip', value => 'voip_absolute', template => '%.2f', min => 0, max => 100, unit => '%' }, + { label => 'used_voip', value => 'voip', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } }, @@ -44,7 +44,7 @@ sub set_counters { key_values => [ { name => 'data' } ], output_template => 'Memory Data Usage : %.2f %%', perfdatas => [ - { label => 'used_data', value => 'data_absolute', template => '%.2f', min => 0, max => 100, unit => '%' }, + { label => 'used_data', value => 'data', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } }, diff --git a/network/audiocodes/snmp/mode/trunkstatus.pm b/network/audiocodes/snmp/mode/trunkstatus.pm index c718c450b..dafc5e028 100644 --- a/network/audiocodes/snmp/mode/trunkstatus.pm +++ b/network/audiocodes/snmp/mode/trunkstatus.pm @@ -64,8 +64,8 @@ sub set_counters { key_values => [ { name => 'acPMTrunkUtilizationAverage' }, { name => 'display' } ], output_template => 'Average calls : %s', perfdatas => [ - { label => 'avg_calls', value => 'acPMTrunkUtilizationAverage_absolute', template => '%d', - min => 0, unit => 'calls', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'avg_calls', value => 'acPMTrunkUtilizationAverage', template => '%d', + min => 0, unit => 'calls', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -73,8 +73,8 @@ sub set_counters { key_values => [ { name => 'acPMTrunkUtilizationMax' }, { name => 'display' } ], output_template => 'Max calls : %s', perfdatas => [ - { label => 'max_calls', value => 'acPMTrunkUtilizationMax_absolute', template => '%d', - min => 0, unit => 'calls', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'max_calls', value => 'acPMTrunkUtilizationMax', template => '%d', + min => 0, unit => 'calls', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -82,8 +82,8 @@ sub set_counters { key_values => [ { name => 'acPMTrunkUtilizationTotal', diff => 1 }, { name => 'display' } ], output_template => 'Count calls : %s', perfdatas => [ - { label => 'count_calls', value => 'acPMTrunkUtilizationTotal_absolute', template => '%d', - min => 0, unit => 'calls', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'count_calls', value => 'acPMTrunkUtilizationTotal', template => '%d', + min => 0, unit => 'calls', label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/network/beeware/snmp/mode/reverseproxyusage.pm b/network/beeware/snmp/mode/reverseproxyusage.pm index d821eda5c..b929991e2 100644 --- a/network/beeware/snmp/mode/reverseproxyusage.pm +++ b/network/beeware/snmp/mode/reverseproxyusage.pm @@ -61,8 +61,8 @@ sub set_counters { key_values => [ { name => 'cpu' }, { name => 'display' } ], output_template => 'CPU Usage : %.2f %%', perfdatas => [ - { label => 'cpu', value => 'cpu_absolute', template => '%.2f', - min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'cpu', value => 'cpu', template => '%.2f', + min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -71,8 +71,8 @@ sub set_counters { output_template => 'Memory Usage : %s %s', output_change_bytes => 1, perfdatas => [ - { label => 'memory', value => 'memory_absolute', template => '%s', - min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'memory', value => 'memory', template => '%s', + min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -80,8 +80,8 @@ sub set_counters { key_values => [ { name => 'nbchilds' }, { name => 'display' } ], output_template => 'Num childs : %s', perfdatas => [ - { label => 'nbchilds', value => 'nbchilds_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'nbchilds', value => 'nbchilds', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/network/checkpoint/snmp/mode/memory.pm b/network/checkpoint/snmp/mode/memory.pm index 67203270f..9588136fa 100644 --- a/network/checkpoint/snmp/mode/memory.pm +++ b/network/checkpoint/snmp/mode/memory.pm @@ -29,15 +29,15 @@ use Digest::MD5 qw(md5_hex); sub custom_usage_output { my ($self, %options) = @_; - my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_absolute}); - my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_absolute}); - my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute}); + my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}); + my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}); + my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}); return sprintf( 'Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)', $total_size_value . " " . $total_size_unit, - $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used_absolute}, - $total_free_value . " " . $total_free_unit, 100 - $self->{result_values}->{prct_used_absolute} + $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used}, + $total_free_value . " " . $total_free_unit, 100 - $self->{result_values}->{prct_used} ); } @@ -54,10 +54,10 @@ sub set_counters { { label => 'memory', set => { key_values => [ { name => 'prct_used'}, { name => 'used' }, { name => 'free' }, { name => 'total' } ], closure_custom_output => $self->can('custom_usage_output'), - threshold_use => 'prct_used_absolute', + threshold_use => 'prct_used', perfdatas => [ - { label => 'memory', value => 'used_absolute', template => '%.2f', threshold_total => 'total_absolute', cast_int => 1, - min => 0, max => 'total_absolute', unit => 'B' }, + { label => 'memory', value => 'used', template => '%.2f', threshold_total => 'total', cast_int => 1, + min => 0, max => 'total', unit => 'B' }, ], } }, @@ -67,10 +67,10 @@ sub set_counters { { label => 'swap', set => { key_values => [ { name => 'prct_used' }, { name => 'used' }, { name => 'free' }, { name => 'total' } ], closure_custom_output => $self->can('custom_usage_output'), - threshold_use => 'prct_used_absolute', + threshold_use => 'prct_used', perfdatas => [ - { label => 'swap', value => 'used_absolute', template => '%.2f', threshold_total => 'total_absolute', cast_int => 1, - min => 0, max => 'total_absolute', unit => 'B' }, + { label => 'swap', value => 'used', template => '%.2f', threshold_total => 'total', cast_int => 1, + min => 0, max => 'total', unit => 'B' }, ], } }, @@ -78,14 +78,13 @@ sub set_counters { $self->{maps_counters}->{malloc} = [ { label => 'failed-malloc', set => { - key_values => [ { name => 'failed_mallocs', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'failed_mallocs', per_second => 1 } ], output_template => 'Failed memory allocations %.2f/s', perfdatas => [ - { label => 'failed_mallocs', value => 'failed_mallocs_per_second', template => '%.2f', min => 0 }, - ], + { label => 'failed_mallocs', template => '%.2f', min => 0 } + ] } - }, + } ]; } diff --git a/network/checkpoint/snmp/mode/vpnstatus.pm b/network/checkpoint/snmp/mode/vpnstatus.pm index 08c42fa21..048b789ca 100644 --- a/network/checkpoint/snmp/mode/vpnstatus.pm +++ b/network/checkpoint/snmp/mode/vpnstatus.pm @@ -45,7 +45,7 @@ sub set_counters { key_values => [ { name => 'total' } ], output_template => 'current total number of tunnels: %d', perfdatas => [ - { value => 'total_absolute', template => '%d', min => 0 } + { value => 'total', template => '%d', min => 0 } ] } } diff --git a/network/checkpoint/snmp/mode/vsx.pm b/network/checkpoint/snmp/mode/vsx.pm index 5418e8e5e..27c8ba1fe 100644 --- a/network/checkpoint/snmp/mode/vsx.pm +++ b/network/checkpoint/snmp/mode/vsx.pm @@ -65,8 +65,7 @@ sub set_counters { key_values => [ { name => 'cpu_1hour' }, { name => 'display' } ], output_template => '%.2f%% (1hour)', perfdatas => [ - { value => 'cpu_1hour_absolute', template => '%.2f', unit => '%', min => 0, max => 100, - label_extra_instance => 1, instance_use => 'display_absolute' } + { template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' } ] } }, @@ -74,8 +73,7 @@ sub set_counters { key_values => [ { name => 'cpu_1min' }, { name => 'display' } ], output_template => '%.2f%% (1min)', perfdatas => [ - { value => 'cpu_1min_absolute', template => '%.2f', unit => '%', min => 0, max => 100, - label_extra_instance => 1, instance_use => 'display_absolute' } + { template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' } ] } } @@ -87,8 +85,7 @@ sub set_counters { output_template => 'memory used: %s%s', output_change_bytes => 1, perfdatas => [ - { value => 'memory_used_absolute', template => '%s', min => 0, - unit => 'B', label_extra_instance => 1, instance_use => 'display_absolute' } + { template => '%s', min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'display' } ] } } @@ -99,8 +96,7 @@ sub set_counters { key_values => [ { name => 'active_connections' }, { name => 'display' } ], output_template => 'active connections: %d', perfdatas => [ - { value => 'active_connections_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' } + { template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display' } ] } } @@ -108,32 +104,29 @@ sub set_counters { $self->{maps_counters}->{vsx_traffic} = [ { label => 'traffic-accepted', nlabel => 'virtualsystem.traffic.accepted.bitspersecond', set => { - key_values => [ { name => 'traffic_accepted', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'traffic_accepted', per_second => 1 }, { name => 'display' } ], output_template => 'traffic accepted: %s%s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { value => 'traffic_accepted_per_second', template => '%s', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' } + { template => '%s', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' } ] } }, { label => 'traffic-dropped', nlabel => 'virtualsystem.traffic.dropped.bitspersecond', set => { - key_values => [ { name => 'traffic_dropped', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'traffic_dropped', per_second => 1 }, { name => 'display' } ], output_template => 'traffic dropped: %s%s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { value => 'traffic_dropped_per_second', template => '%s', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' } + { template => '%s', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' } ] } }, { label => 'traffic-rejected', nlabel => 'virtualsystem.traffic.rejected.bitspersecond', set => { - key_values => [ { name => 'traffic_rejected', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'traffic_rejected', per_second => 1 }, { name => 'display' } ], output_template => 'traffic rejected: %s%s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { value => 'traffic_rejected_per_second', template => '%s', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' } + { template => '%s', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' } ] } } diff --git a/network/cisco/aci/apic/restapi/mode/node.pm b/network/cisco/aci/apic/restapi/mode/node.pm index d027d0370..67cf6c4f3 100644 --- a/network/cisco/aci/apic/restapi/mode/node.pm +++ b/network/cisco/aci/apic/restapi/mode/node.pm @@ -38,8 +38,8 @@ sub set_counters { key_values => [ { name => 'current' }, { name => 'dn' } ], output_template => 'current: %s %%', output_error_template => "current: %s %%", perfdatas => [ - { label => 'health_current', value => 'current_absolute', template => '%d', - unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'dn_absolute' }, + { label => 'health_current', value => 'current', template => '%d', + unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'dn' }, ], } }, @@ -47,8 +47,8 @@ sub set_counters { key_values => [ { name => 'min' }, { name => 'dn' } ], output_template => 'min: %s %%', output_error_template => "min: %s %%", perfdatas => [ - { label => 'health_min', value => 'min_absolute', template => '%d', - unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'dn_absolute' }, + { label => 'health_min', value => 'min', template => '%d', + unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'dn' }, ], } }, @@ -56,8 +56,8 @@ sub set_counters { key_values => [ { name => 'avg' }, { name => 'dn' } ], output_template => 'average: %s %%', output_error_template => "average %s %%", perfdatas => [ - { label => 'health_avg', value => 'avg_absolute', template => '%d', - unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'dn_absolute' }, + { label => 'health_avg', value => 'avg', template => '%d', + unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'dn' }, ], } }, diff --git a/network/cisco/asa/snmp/mode/failover.pm b/network/cisco/asa/snmp/mode/failover.pm index 6a99d3cfa..22d795d9d 100644 --- a/network/cisco/asa/snmp/mode/failover.pm +++ b/network/cisco/asa/snmp/mode/failover.pm @@ -60,7 +60,7 @@ sub set_counters { key_values => [ { name => 'active_units' } ], output_template => 'Active units : %s', perfdatas => [ - { label => 'active_units', value => 'active_units_absolute', template => '%s', + { label => 'active_units', value => 'active_units', template => '%s', min => 0, max => 2 }, ], } diff --git a/network/cisco/callmanager/snmp/mode/ccmusage.pm b/network/cisco/callmanager/snmp/mode/ccmusage.pm index a40ab4beb..24a83e870 100644 --- a/network/cisco/callmanager/snmp/mode/ccmusage.pm +++ b/network/cisco/callmanager/snmp/mode/ccmusage.pm @@ -80,7 +80,7 @@ sub set_counters { key_values => [ { name => $_->[2] } ], output_template => $_->[1], perfdatas => [ - { label => $label, value => $_->[2] . '_absolute', template => '%s', min => 0 }, + { label => $label, value => $_->[2] , template => '%s', min => 0 }, ], } }, diff --git a/network/cisco/callmanager/snmp/mode/ctiusage.pm b/network/cisco/callmanager/snmp/mode/ctiusage.pm index fc3437172..f60a66520 100644 --- a/network/cisco/callmanager/snmp/mode/ctiusage.pm +++ b/network/cisco/callmanager/snmp/mode/ctiusage.pm @@ -74,7 +74,7 @@ sub set_counters { key_values => [ { name => $_->[2] } ], output_template => $_->[1], perfdatas => [ - { value => $_->[2] . '_absolute', template => '%s', min => 0 }, + { value => $_->[2] , template => '%s', min => 0 }, ], } }, diff --git a/network/cisco/callmanager/snmp/mode/gatewayusage.pm b/network/cisco/callmanager/snmp/mode/gatewayusage.pm index fae840597..a15904ad7 100644 --- a/network/cisco/callmanager/snmp/mode/gatewayusage.pm +++ b/network/cisco/callmanager/snmp/mode/gatewayusage.pm @@ -76,7 +76,7 @@ sub set_counters { key_values => [ { name => $_->[2] } ], output_template => $_->[1], perfdatas => [ - { label => $label, value => $_->[2] . '_absolute', template => '%s', min => 0 }, + { label => $label, value => $_->[2] , template => '%s', min => 0 }, ], } }, diff --git a/network/cisco/callmanager/snmp/mode/mediadeviceusage.pm b/network/cisco/callmanager/snmp/mode/mediadeviceusage.pm index 9466d56a2..145b61c94 100644 --- a/network/cisco/callmanager/snmp/mode/mediadeviceusage.pm +++ b/network/cisco/callmanager/snmp/mode/mediadeviceusage.pm @@ -76,7 +76,7 @@ sub set_counters { key_values => [ { name => $_->[2] } ], output_template => $_->[1], perfdatas => [ - { label => $label, value => $_->[2] . '_absolute', template => '%s', min => 0 }, + { label => $label, value => $_->[2] , template => '%s', min => 0 }, ], } }, diff --git a/network/cisco/callmanager/snmp/mode/phoneusage.pm b/network/cisco/callmanager/snmp/mode/phoneusage.pm index 16f76d568..1c0f7fc17 100644 --- a/network/cisco/callmanager/snmp/mode/phoneusage.pm +++ b/network/cisco/callmanager/snmp/mode/phoneusage.pm @@ -77,7 +77,7 @@ sub set_counters { key_values => [ { name => $_->[2] } ], output_template => $_->[1], perfdatas => [ - { label => $label, value => $_->[2] . '_absolute', template => '%s', min => 0 }, + { label => $label, value => $_->[2] , template => '%s', min => 0 }, ], } }, diff --git a/network/cisco/callmanager/snmp/mode/voicemailusage.pm b/network/cisco/callmanager/snmp/mode/voicemailusage.pm index 5253bf7d2..0a6f0c637 100644 --- a/network/cisco/callmanager/snmp/mode/voicemailusage.pm +++ b/network/cisco/callmanager/snmp/mode/voicemailusage.pm @@ -74,7 +74,7 @@ sub set_counters { key_values => [ { name => $_->[2] } ], output_template => $_->[1], perfdatas => [ - { value => $_->[2] . '_absolute', template => '%s', min => 0 }, + { value => $_->[2] , template => '%s', min => 0 }, ], } }, diff --git a/network/cisco/meraki/cloudcontroller/restapi/mode/apirequests.pm b/network/cisco/meraki/cloudcontroller/restapi/mode/apirequests.pm index 092c91dda..440738a70 100644 --- a/network/cisco/meraki/cloudcontroller/restapi/mode/apirequests.pm +++ b/network/cisco/meraki/cloudcontroller/restapi/mode/apirequests.pm @@ -38,8 +38,8 @@ sub set_counters { key_values => [ { name => 'requests_200' }, { name => 'display' } ], output_template => 'code 200: %s', perfdatas => [ - { value => 'requests_200_absolute', - template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' } + { value => 'requests_200', + template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display' } ] } }, @@ -47,8 +47,8 @@ sub set_counters { key_values => [ { name => 'requests_404' }, { name => 'display' } ], output_template => 'code 404: %s', perfdatas => [ - { value => 'requests_404_absolute', - template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' } + { value => 'requests_404', + template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display' } ] } }, @@ -56,8 +56,8 @@ sub set_counters { key_values => [ { name => 'requests_429' }, { name => 'display' } ], output_template => 'code 429: %s', perfdatas => [ - { value => 'requests_429_absolute', - template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' } + { value => 'requests_429', + template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display' } ] } } diff --git a/network/cisco/meraki/cloudcontroller/restapi/mode/devices.pm b/network/cisco/meraki/cloudcontroller/restapi/mode/devices.pm index db4ad3088..f9d5f8796 100644 --- a/network/cisco/meraki/cloudcontroller/restapi/mode/devices.pm +++ b/network/cisco/meraki/cloudcontroller/restapi/mode/devices.pm @@ -59,7 +59,7 @@ sub set_counters { key_values => [ { name => 'online'}, { name => 'total'} ], output_template => 'online: %s', perfdatas => [ - { value => 'online_absolute', template => '%s', min => 0, max => 'total_absolute' } + { template => '%s', min => 0, max => 'total' } ] } }, @@ -67,7 +67,7 @@ sub set_counters { key_values => [ { name => 'offline'}, { name => 'total'} ], output_template => 'offline: %s', perfdatas => [ - { value => 'offline_absolute', template => '%s', min => 0, max => 'total_absolute' } + { template => '%s', min => 0, max => 'total' } ] } }, @@ -75,7 +75,7 @@ sub set_counters { key_values => [ { name => 'alerting'}, { name => 'total'} ], output_template => 'alerting: %s', perfdatas => [ - { value => 'alerting_absolute', template => '%s', min => 0, max => 'total_absolute' } + { template => '%s', min => 0, max => 'total' } ] } }, @@ -97,8 +97,7 @@ sub set_counters { key_values => [ { name => 'assoc' }, { name => 'display' } ], output_template => 'success: %s', perfdatas => [ - { value => 'assoc_absolute', - template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' } + { template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display' } ] } }, @@ -106,8 +105,7 @@ sub set_counters { key_values => [ { name => 'auth' }, { name => 'display' } ], output_template => 'auth: %s', perfdatas => [ - { value => 'auth_absolute', - template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' } + { template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display' } ] } }, @@ -115,8 +113,7 @@ sub set_counters { key_values => [ { name => 'assoc' }, { name => 'display' } ], output_template => 'assoc: %s', perfdatas => [ - { value => 'assoc_absolute', - template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' } + { template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display' } ] } }, @@ -124,8 +121,7 @@ sub set_counters { key_values => [ { name => 'dhcp' }, { name => 'display' } ], output_template => 'dhcp: %s', perfdatas => [ - { value => 'dhcp_absolute', - template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' } + { template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display' } ] } }, @@ -133,8 +129,7 @@ sub set_counters { key_values => [ { name => 'dns' }, { name => 'display' } ], output_template => 'dns: %s', perfdatas => [ - { value => 'dns_absolute', - template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' } + { template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display' } ] } } @@ -142,22 +137,20 @@ sub set_counters { $self->{maps_counters}->{device_traffic} = [ { label => 'traffic-in', nlabel => 'device.traffic.in.bitspersecond', set => { - key_values => [ { name => 'traffic_in', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'traffic_in', per_second => 1 }, { name => 'display' } ], output_template => 'in: %s %s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { value => 'traffic_in_per_second', template => '%s', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' } + { template => '%s', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' } ] } }, { label => 'traffic-out', nlabel => 'device.traffic.out.bitspersecond', set => { - key_values => [ { name => 'traffic_out', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'traffic_out', per_second => 1 }, { name => 'display' } ], output_template => 'out: %s %s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { value => 'traffic_out_per_second', template => '%s', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' } + { template => '%s', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' } ] } } diff --git a/network/cisco/meraki/cloudcontroller/restapi/mode/networks.pm b/network/cisco/meraki/cloudcontroller/restapi/mode/networks.pm index 64e53ef5e..f8c703213 100644 --- a/network/cisco/meraki/cloudcontroller/restapi/mode/networks.pm +++ b/network/cisco/meraki/cloudcontroller/restapi/mode/networks.pm @@ -38,8 +38,7 @@ sub set_counters { key_values => [ { name => 'assoc' }, { name => 'display' } ], output_template => 'connections success: %s', perfdatas => [ - { value => 'assoc_absolute', - template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' } + { template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display' } ] } }, @@ -47,8 +46,7 @@ sub set_counters { key_values => [ { name => 'auth' }, { name => 'display' } ], output_template => 'connections auth: %s', perfdatas => [ - { value => 'auth_absolute', - template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' } + { template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display' } ] } }, @@ -56,8 +54,7 @@ sub set_counters { key_values => [ { name => 'assoc' }, { name => 'display' } ], output_template => 'connections assoc: %s', perfdatas => [ - { value => 'assoc_absolute', - template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' } + { template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display' } ] } }, @@ -65,8 +62,7 @@ sub set_counters { key_values => [ { name => 'dhcp' }, { name => 'display' } ], output_template => 'connections dhcp: %s', perfdatas => [ - { value => 'dhcp_absolute', - template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' } + { template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display' } ] } }, @@ -74,28 +70,25 @@ sub set_counters { key_values => [ { name => 'dns' }, { name => 'display' } ], output_template => 'connections dns: %s', perfdatas => [ - { value => 'dns_absolute', - template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' } + { template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display' } ] } }, { label => 'traffic-in', nlabel => 'network.traffic.in.bitspersecond', set => { - key_values => [ { name => 'traffic_in', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'traffic_in', per_second => 1 }, { name => 'display' } ], output_template => 'traffic in: %s %s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { value => 'traffic_in_per_second', template => '%s', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' } + { template => '%s', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' } ] } }, { label => 'traffic-out', nlabel => 'network.traffic.out.bitspersecond', set => { - key_values => [ { name => 'traffic_out', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'traffic_out', per_second => 1 }, { name => 'display' } ], output_template => 'traffic out: %s %s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { value => 'traffic_out_per_second', template => '%s', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' } + { template => '%s', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' } ] } } diff --git a/network/cisco/meraki/cloudcontroller/snmp/mode/deviceusage.pm b/network/cisco/meraki/cloudcontroller/snmp/mode/deviceusage.pm index ecdfa8981..4ba0559ce 100644 --- a/network/cisco/meraki/cloudcontroller/snmp/mode/deviceusage.pm +++ b/network/cisco/meraki/cloudcontroller/snmp/mode/deviceusage.pm @@ -119,7 +119,7 @@ sub set_counters { key_values => [ { name => 'total' } ], output_template => 'Total devices : %s', perfdatas => [ - { label => 'total', value => 'total_absolute', template => '%s', min => 0 }, + { label => 'total', template => '%s', min => 0 }, ], } }, @@ -138,8 +138,8 @@ sub set_counters { key_values => [ { name => 'clients' }, { name => 'display' } ], output_template => 'Clients : %s', perfdatas => [ - { label => 'clients', value => 'clients_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'clients', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -148,7 +148,6 @@ sub set_counters { $self->{maps_counters}->{interface} = [ { label => 'in', set => { key_values => [ { name => 'in', diff => 1 }, { name => 'display' } ], - per_second => 1, closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'in' }, closure_custom_output => $self->can('custom_traffic_output'), closure_custom_perfdata => $self->can('custom_traffic_perfdata'), @@ -157,7 +156,6 @@ sub set_counters { }, { label => 'out', set => { key_values => [ { name => 'out', diff => 1 }, { name => 'display' } ], - per_second => 1, closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'out' }, closure_custom_output => $self->can('custom_traffic_output'), closure_custom_perfdata => $self->can('custom_traffic_perfdata'), diff --git a/network/cisco/prime/restapi/mode/apusage.pm b/network/cisco/prime/restapi/mode/apusage.pm index 64dff0f7f..ef8c06042 100644 --- a/network/cisco/prime/restapi/mode/apusage.pm +++ b/network/cisco/prime/restapi/mode/apusage.pm @@ -48,14 +48,14 @@ sub custom_status_calc { sub custom_uptime_output { my ($self, %options) = @_; - my $msg = 'uptime started since : ' . centreon::plugins::misc::change_seconds(value => $self->{result_values}->{uptime_absolute}); + my $msg = 'uptime started since : ' . centreon::plugins::misc::change_seconds(value => $self->{result_values}->{uptime}); return $msg; } sub custom_lwappuptime_output { my ($self, %options) = @_; - my $msg = 'lwapp uptime started since : ' . centreon::plugins::misc::change_seconds(value => $self->{result_values}->{lwapp_uptime_absolute}); + my $msg = 'lwapp uptime started since : ' . centreon::plugins::misc::change_seconds(value => $self->{result_values}->{lwapp_uptime}); return $msg; } @@ -81,8 +81,8 @@ sub set_counters { key_values => [ { name => 'client_count' }, { name => 'name' } ], output_template => 'Clients : %s', perfdatas => [ - { label => 'ap_clients', value => 'client_count_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'name_absolute' }, + { label => 'ap_clients', value => 'client_count', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'name' }, ], } }, @@ -90,8 +90,8 @@ sub set_counters { key_values => [ { name => 'uptime' }, { name => 'name' } ], closure_custom_output => $self->can('custom_uptime_output'), perfdatas => [ - { label => 'ap_uptime', value => 'uptime_absolute', template => '%s', - min => 0, unit => 's', label_extra_instance => 1, instance_use => 'name_absolute' }, + { label => 'ap_uptime', value => 'uptime', template => '%s', + min => 0, unit => 's', label_extra_instance => 1, instance_use => 'name' }, ], } }, @@ -99,8 +99,8 @@ sub set_counters { key_values => [ { name => 'lwapp_uptime' }, { name => 'name' } ], closure_custom_output => $self->can('custom_lwappuptime_output'), perfdatas => [ - { label => 'ap_lwappuptime', value => 'lwapp_uptime_absolute', template => '%s', - min => 0, unit => 's', label_extra_instance => 1, instance_use => 'name_absolute' }, + { label => 'ap_lwappuptime', value => 'lwapp_uptime', template => '%s', + min => 0, unit => 's', label_extra_instance => 1, instance_use => 'name' }, ], } }, @@ -111,8 +111,8 @@ sub set_counters { key_values => [ { name => 'ap_count' }, { name => 'name' } ], output_template => 'Number of access points : %s', perfdatas => [ - { label => 'ctrl_ap_count', value => 'ap_count_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'name_absolute' }, + { label => 'ctrl_ap_count', value => 'ap_count', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'name' }, ], } }, diff --git a/network/cisco/standard/ssh/mode/cpu.pm b/network/cisco/standard/ssh/mode/cpu.pm index 399600482..8964a2c85 100644 --- a/network/cisco/standard/ssh/mode/cpu.pm +++ b/network/cisco/standard/ssh/mode/cpu.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'average_5s' } ], output_template => '%.2f %% (5s)', perfdatas => [ - { label => 'total_cpu_5s_avg', value => 'average_5s_absolute', template => '%.2f', + { label => 'total_cpu_5s_avg', value => 'average_5s', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'average_1m' } ], output_template => '%.2f %% (1m)', perfdatas => [ - { label => 'total_cpu_1m_avg', value => 'average_1m_absolute', template => '%.2f', + { label => 'total_cpu_1m_avg', value => 'average_1m', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } @@ -55,7 +55,7 @@ sub set_counters { key_values => [ { name => 'average_5m' } ], output_template => '%.2f %% (5m)', perfdatas => [ - { label => 'total_cpu_5m_avg', value => 'average_5m_absolute', template => '%.2f', + { label => 'total_cpu_5m_avg', value => 'average_5m', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } diff --git a/network/cisco/standard/ssh/mode/voicedialpeer.pm b/network/cisco/standard/ssh/mode/voicedialpeer.pm index a667f7cc8..4b89696dd 100644 --- a/network/cisco/standard/ssh/mode/voicedialpeer.pm +++ b/network/cisco/standard/ssh/mode/voicedialpeer.pm @@ -49,7 +49,7 @@ sub set_counters { key_values => [ { name => 'total' } ], output_template => 'peers total %s', perfdatas => [ - { value => 'total_absolute', template => '%s', min => 0 }, + { value => 'total', template => '%s', min => 0 }, ], } }, @@ -57,7 +57,7 @@ sub set_counters { key_values => [ { name => 'oper_up' } ], output_template => 'peers operational up %s', perfdatas => [ - { value => 'oper_up_absolute', template => '%s', min => 0 }, + { value => 'oper_up', template => '%s', min => 0 }, ], } }, diff --git a/network/cisco/vcs/restapi/mode/calls.pm b/network/cisco/vcs/restapi/mode/calls.pm index bafebd105..d8c20dc7d 100644 --- a/network/cisco/vcs/restapi/mode/calls.pm +++ b/network/cisco/vcs/restapi/mode/calls.pm @@ -56,7 +56,7 @@ sub set_counters { key_values => [ { name => 'Traversal' } ], output_template => 'Traversal: %d', perfdatas => [ - { label => 'traversal', value => 'Traversal_absolute', template => '%d', + { label => 'traversal', value => 'Traversal', template => '%d', min => 0, unit => 'calls' }, ], } @@ -65,7 +65,7 @@ sub set_counters { key_values => [ { name => 'NonTraversal' } ], output_template => 'Non Traversal: %d', perfdatas => [ - { label => 'non_traversal', value => 'NonTraversal_absolute', template => '%d', + { label => 'non_traversal', value => 'NonTraversal', template => '%d', min => 0, unit => 'calls' }, ], } @@ -74,7 +74,7 @@ sub set_counters { key_values => [ { name => 'CollaborationEdge' } ], output_template => 'Collaboration Edge: %d', perfdatas => [ - { label => 'collaboration_edge', value => 'CollaborationEdge_absolute', template => '%d', + { label => 'collaboration_edge', value => 'CollaborationEdge', template => '%d', min => 0, unit => 'calls' }, ], } @@ -83,7 +83,7 @@ sub set_counters { key_values => [ { name => 'Cloud' } ], output_template => 'Cloud: %d', perfdatas => [ - { label => 'cloud', value => 'Cloud_absolute', template => '%d', + { label => 'cloud', value => 'Cloud', template => '%d', min => 0, unit => 'calls' }, ], } @@ -92,7 +92,7 @@ sub set_counters { key_values => [ { name => 'MicrosoftContent' } ], output_template => 'Microsoft Content: %d', perfdatas => [ - { label => 'microsoft_content', value => 'MicrosoftContent_absolute', template => '%d', + { label => 'microsoft_content', value => 'MicrosoftContent', template => '%d', min => 0, unit => 'calls' }, ], } @@ -101,7 +101,7 @@ sub set_counters { key_values => [ { name => 'MicrosoftIMP' } ], output_template => 'Microsoft IMP: %d', perfdatas => [ - { label => 'microsoft_imp', value => 'MicrosoftIMP_absolute', template => '%d', + { label => 'microsoft_imp', value => 'MicrosoftIMP', template => '%d', min => 0, unit => 'calls' }, ], } diff --git a/network/cisco/vcs/restapi/mode/httpproxystats.pm b/network/cisco/vcs/restapi/mode/httpproxystats.pm index f8c8a0432..405356ab0 100644 --- a/network/cisco/vcs/restapi/mode/httpproxystats.pm +++ b/network/cisco/vcs/restapi/mode/httpproxystats.pm @@ -63,106 +63,88 @@ sub set_counters { ]; $self->{maps_counters}->{connections} = [ { label => 'client-connections', set => { - key_values => [ { name => 'TotalClientConnection', diff => 1 } ], + key_values => [ { name => 'TotalClientConnection', per_second => 1 } ], output_template => 'Client: %.2f/s', - per_second => 1, perfdatas => [ - { label => 'client_connections', value => 'TotalClientConnection_per_second', template => '%.2f', - min => 0, unit => 'connections/s' }, + { label => 'client_connections', template => '%.2f', min => 0, unit => 'connections/s' }, ], } }, { label => 'server-connections', set => { - key_values => [ { name => 'TotalServerConnection', diff => 1 } ], + key_values => [ { name => 'TotalServerConnection', per_second => 1 } ], output_template => 'Server: %.2f/s', - per_second => 1, perfdatas => [ - { label => 'server_connections', value => 'TotalServerConnection_per_second', template => '%.2f', - min => 0, unit => 'connections/s' }, + { label => 'server_connections', template => '%.2f', min => 0, unit => 'connections/s' }, ], } - }, + } ]; + $self->{maps_counters}->{requests} = [ { label => 'completed-requests', set => { - key_values => [ { name => 'CompletedRequests', diff => 1 } ], + key_values => [ { name => 'CompletedRequests', per_second => 1 } ], output_template => 'Completed: %.2f/s', - per_second => 1, perfdatas => [ - { label => 'completed_requests', value => 'CompletedRequests_per_second', template => '%.2f', - min => 0, unit => 'requests/s' }, + { label => 'completed_requests', template => '%.2f', min => 0, unit => 'requests/s' }, ], } }, { label => 'get-requests', set => { - key_values => [ { name => 'GetRequests', diff => 1 } ], + key_values => [ { name => 'GetRequests', per_second => 1 } ], output_template => 'Get: %.2f/s', - per_second => 1, perfdatas => [ - { label => 'get_requests', value => 'GetRequests_per_second', template => '%.2f', - min => 0, unit => 'requests/s' }, + { label => 'get_requests', template => '%.2f', min => 0, unit => 'requests/s' }, ], } }, { label => 'post-requests', set => { - key_values => [ { name => 'PostRequests', diff => 1 } ], + key_values => [ { name => 'PostRequests', per_second => 1 } ], output_template => 'Post: %.2f/s', - per_second => 1, perfdatas => [ - { label => 'post_requests', value => 'PostRequests_per_second', template => '%.2f', - min => 0, unit => 'requests/s' }, + { label => 'post_requests', template => '%.2f', min => 0, unit => 'requests/s' }, ], } - }, + } ]; + $self->{maps_counters}->{responses} = [ { label => 'responses-1xx', set => { - key_values => [ { name => 'Response1XXCount', diff => 1 } ], + key_values => [ { name => 'Response1XXCount', per_second => 1 } ], output_template => '1XX: %.2f/s', - per_second => 1, perfdatas => [ - { label => 'responses_1xx', value => 'Response1XXCount_per_second', template => '%.2f', - min => 0, unit => 'responses/s' }, + { label => 'responses_1xx', template => '%.2f', min => 0, unit => 'responses/s' }, ], } }, { label => 'responses-2xx', set => { - key_values => [ { name => 'Response2XXCount', diff => 1 } ], + key_values => [ { name => 'Response2XXCount', per_second => 1 } ], output_template => '2XX: %.2f/s', - per_second => 1, perfdatas => [ - { label => 'responses_2xx', value => 'Response2XXCount_per_second', template => '%.2f', - min => 0, unit => 'responses/s' }, + { label => 'responses_2xx', template => '%.2f', min => 0, unit => 'responses/s' }, ], } }, { label => 'responses-3xx', set => { - key_values => [ { name => 'Response3XXCount', diff => 1 } ], + key_values => [ { name => 'Response3XXCount', per_second => 1 } ], output_template => '3XX: %.2f/s', - per_second => 1, perfdatas => [ - { label => 'responses_3xx', value => 'Response3XXCount_per_second', template => '%.2f', - min => 0, unit => 'responses/s' }, + { label => 'responses_3xx', template => '%.2f', min => 0, unit => 'responses/s' }, ], } }, { label => 'responses-4xx', set => { - key_values => [ { name => 'Response4XXCount', diff => 1 } ], + key_values => [ { name => 'Response4XXCount', per_second => 1 } ], output_template => '4XX: %.2f/s', - per_second => 1, perfdatas => [ - { label => 'responses_4xx', value => 'Response4XXCount_per_second', template => '%.2f', - min => 0, unit => 'responses/s' }, + { label => 'responses_4xx', template => '%.2f', min => 0, unit => 'responses/s' }, ], } }, { label => 'responses-5xx', set => { - key_values => [ { name => 'Response5XXCount', diff => 1 } ], + key_values => [ { name => 'Response5XXCount', per_second => 1 } ], output_template => '5XX: %.2f/s', - per_second => 1, perfdatas => [ - { label => 'responses_5xx', value => 'Response5XXCount_per_second', template => '%.2f', - min => 0, unit => 'responses/s' }, + { label => 'responses_5xx', template => '%.2f', min => 0, unit => 'responses/s' }, ], } }, @@ -192,12 +174,10 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-counters:s" => { name => 'filter_counters' }, - "warning-status:s" => { name => 'warning_status' }, - "critical-status:s" => { name => 'critical_status', default => '%{status} ne "Active"' }, - }); + $options{options}->add_options(arguments => { + 'warning-status:s' => { name => 'warning_status' }, + 'critical-status:s' => { name => 'critical_status', default => '%{status} ne "Active"' } + }); return $self; } diff --git a/network/cisco/vcs/restapi/mode/zones.pm b/network/cisco/vcs/restapi/mode/zones.pm index 1b075e05f..fa5fdfc8a 100644 --- a/network/cisco/vcs/restapi/mode/zones.pm +++ b/network/cisco/vcs/restapi/mode/zones.pm @@ -58,72 +58,65 @@ sub set_counters { key_values => [ { name => 'count' } ], output_template => 'Number of zones: %d', perfdatas => [ - { label => 'zones_count', value => 'count_absolute', template => '%d', - min => 0 }, - ], + { label => 'zones_count', template => '%d', min => 0 } + ] } - }, + } ]; + $self->{maps_counters}->{searches} = [ { label => 'searches-total', set => { - key_values => [ { name => 'Total', diff => 1 } ], + key_values => [ { name => 'Total', per_second => 1 } ], output_template => 'Total: %.2f/s', - per_second => 1, perfdatas => [ - { label => 'searches_total', value => 'Total_per_second', template => '%.2f', - min => 0, unit => 'searches/s' }, + { label => 'searches_total', template => '%.2f', min => 0, unit => 'searches/s' }, ], } }, { label => 'searches-dropped', set => { - key_values => [ { name => 'Dropped', diff => 1 } ], + key_values => [ { name => 'Dropped', per_second => 1 } ], output_template => 'Dropped: %.2f/s', - per_second => 1, perfdatas => [ - { label => 'searches_dropped', value => 'Dropped_per_second', template => '%.2f', - min => 0, unit => 'searches/s' }, + { label => 'searches_dropped', template => '%.2f', min => 0, unit => 'searches/s' }, ], } }, { label => 'searches-max-sub-search-exceeded', set => { - key_values => [ { name => 'MaxSubSearchExceeded', diff => 1 } ], + key_values => [ { name => 'MaxSubSearchExceeded', per_second => 1 } ], output_template => 'Max Sub Search Exceeded: %.2f/s', - per_second => 1, perfdatas => [ - { label => 'searches_max_sub_search_exceeded', value => 'MaxSubSearchExceeded_per_second', template => '%.2f', + { label => 'searches_max_sub_search_exceeded', template => '%.2f', min => 0, unit => 'searches/s' }, ], } }, { label => 'searches-max-targets-exceeded', set => { - key_values => [ { name => 'MaxTargetsExceeded', diff => 1 } ], + key_values => [ { name => 'MaxTargetsExceeded', per_second => 1 } ], output_template => 'Max Targets Exceeded: %.2f/s', - per_second => 1, perfdatas => [ - { label => 'searches_max_targets_exceeded', value => 'MaxTargetsExceeded_per_second', template => '%.2f', - min => 0, unit => 'searches/s' }, + { label => 'searches_max_targets_exceeded', template => '%.2f', min => 0, unit => 'searches/s' }, ], } - }, + } ]; + $self->{maps_counters}->{zones} = [ { label => 'status', set => { key_values => [ { name => 'Status' }, { name => 'Type' }, { name => 'Name' } ], closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => \&catalog_status_threshold, + closure_custom_threshold_check => \&catalog_status_threshold } }, { label => 'calls-count', set => { key_values => [ { name => 'Calls' }, { name => 'Name' } ], output_template => 'Number of Calls: %d', perfdatas => [ - { label => 'calls_count', value => 'Calls_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'Name_absolute' }, - ], + { label => 'calls_count', template => '%d', min => 0, label_extra_instance => 1, instance_use => 'Name' } + ] } - }, + } ]; } @@ -144,12 +137,10 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-counters:s" => { name => 'filter_counters' }, - "warning-status:s" => { name => 'warning_status' }, - "critical-status:s" => { name => 'critical_status', default => '%{status} ne "Active"' }, - }); + $options{options}->add_options(arguments => { + 'warning-status:s' => { name => 'warning_status' }, + 'critical-status:s' => { name => 'critical_status', default => '%{status} ne "Active"' } + }); return $self; } diff --git a/network/citrix/appacceleration/snmp/mode/cpu.pm b/network/citrix/appacceleration/snmp/mode/cpu.pm index c4d8fee1e..10785d0db 100644 --- a/network/citrix/appacceleration/snmp/mode/cpu.pm +++ b/network/citrix/appacceleration/snmp/mode/cpu.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'cpu' } ], output_template => 'CPU Usage : %.2f%% (1min)', perfdatas => [ - { label => 'cpu', value => 'cpu_absolute', template => '%.2f', + { label => 'cpu', value => 'cpu', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'load' } ], output_template => 'Load : %s', perfdatas => [ - { label => 'load', value => 'load_absolute', template => '%s', + { label => 'load', value => 'load', template => '%s', min => 0 }, ], } diff --git a/network/citrix/appacceleration/snmp/mode/serviceclassusage.pm b/network/citrix/appacceleration/snmp/mode/serviceclassusage.pm index 12064ce1e..df6539cda 100644 --- a/network/citrix/appacceleration/snmp/mode/serviceclassusage.pm +++ b/network/citrix/appacceleration/snmp/mode/serviceclassusage.pm @@ -38,8 +38,8 @@ sub set_counters { key_values => [ { name => 'wsScsCurrentAcceleratedConnections' }, { name => 'display' } ], output_template => 'Current Accelerated Connections : %s', perfdatas => [ - { label => 'current_accelerated_connections', value => 'wsScsCurrentAcceleratedConnections_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'current_accelerated_connections', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -47,8 +47,8 @@ sub set_counters { key_values => [ { name => 'wsScsTotalAcceleratedConnections', diff => 1 }, { name => 'display' } ], output_template => 'Total Accelerated Connections : %s', perfdatas => [ - { label => 'total_accelerated_connections', value => 'wsScsTotalAcceleratedConnections_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'total_accelerated_connections', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -56,48 +56,48 @@ sub set_counters { key_values => [ { name => 'wsScsTotalNonAcceleratedConnections', diff => 1 }, { name => 'display' } ], output_template => 'Total Non Accelerated Connections : %s', perfdatas => [ - { label => 'total_nonaccelerated_connections', value => 'wsScsTotalNonAcceleratedConnections_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'total_nonaccelerated_connections', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'traffic-in', set => { - key_values => [ { name => 'wsScsPreCompressReceivedOctets', diff => 1 }, { name => 'display' } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'wsScsPreCompressReceivedOctets', per_second => 1 }, { name => 'display' } ], output_template => 'Traffic In : %s %s/s', + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_in', value => 'wsScsPreCompressReceivedOctets_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_in', template => '%.2f', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'traffic-in-compressed', set => { - key_values => [ { name => 'wsScsCompressReceivedOctets', diff => 1 }, { name => 'display' } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'wsScsCompressReceivedOctets', per_second => 1 }, { name => 'display' } ], output_template => 'Traffic In Compressed : %s %s/s', + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_in_compressed', value => 'wsScsCompressReceivedOctets_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_in_compressed', template => '%.2f', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'traffic-out', set => { - key_values => [ { name => 'wsScsPreCompressSentOctets', diff => 1 }, { name => 'display' } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'wsScsPreCompressSentOctets', per_second => 1 }, { name => 'display' } ], output_template => 'Traffic Out : %s %s/s', + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_out', value => 'wsScsPreCompressSentOctets_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_out', template => '%.2f', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'traffic-out-compressed', set => { - key_values => [ { name => 'wsScsCompressSentOctets', diff => 1 }, { name => 'display' } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'wsScsCompressSentOctets', per_second => 1 }, { name => 'display' } ], output_template => 'Traffic Out Compressed : %s %s/s', + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_out_compressed', value => 'wsScsCompressSentOctets_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_out_compressed', template => '%.2f', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -115,11 +115,10 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - }); - + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' } + }); + return $self; } diff --git a/network/citrix/netscaler/snmp/mode/connections.pm b/network/citrix/netscaler/snmp/mode/connections.pm index 303753a2e..22f032fcb 100644 --- a/network/citrix/netscaler/snmp/mode/connections.pm +++ b/network/citrix/netscaler/snmp/mode/connections.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'active' } ], output_template => 'Active Server TCP connections : %s', perfdatas => [ - { label => 'active_server', value => 'active_absolute', template => '%s', + { label => 'active_server', value => 'active', template => '%s', unit => 'con', min => 0 }, ], } @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'server' } ], output_template => 'Server TCP connections : %s', perfdatas => [ - { label => 'server', value => 'server_absolute', template => '%s', + { label => 'server', value => 'server', template => '%s', unit => 'con', min => 0 }, ], } @@ -55,7 +55,7 @@ sub set_counters { key_values => [ { name => 'client' } ], output_template => 'Client TCP connections : %s', perfdatas => [ - { label => 'client', value => 'client_absolute', template => '%s', + { label => 'client', value => 'client', template => '%s', unit => 'con', min => 0 }, ], } diff --git a/network/citrix/netscaler/snmp/mode/vserverstatus.pm b/network/citrix/netscaler/snmp/mode/vserverstatus.pm index 0a7b93dc5..ae570f0dd 100644 --- a/network/citrix/netscaler/snmp/mode/vserverstatus.pm +++ b/network/citrix/netscaler/snmp/mode/vserverstatus.pm @@ -46,28 +46,28 @@ sub set_counters { key_values => [ { name => 'health' }, { name => 'display' } ], output_template => 'Health: %.2f %%', output_error_template => 'Health: %s', perfdatas => [ - { value => 'health_absolute', label => 'health', template => '%.2f', - unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'health', template => '%.2f', + unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'in-traffic', set => { - key_values => [ { name => 'in', diff => 1 }, { name => 'display' } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'in', per_second => 1 }, { name => 'display' } ], output_template => 'Traffic In: %s %s/s', + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_in', value => 'in_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_in', template => '%.2f', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'out-traffic', set => { - key_values => [ { name => 'out', diff => 1 }, { name => 'display' } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'out', per_second => 1 }, { name => 'display' } ], output_template => 'Traffic Out: %s %s/s', + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_out', value => 'out_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_out', template => '%.2f', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -75,8 +75,8 @@ sub set_counters { key_values => [ { name => 'clients', diff => 1 }, { name => 'display' } ], output_template => 'Total Client Connections : %s', perfdatas => [ - { label => 'clients', value => 'clients_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'clients', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -84,8 +84,8 @@ sub set_counters { key_values => [ { name => 'servers', diff => 1 }, { name => 'display' } ], output_template => 'Total Server Connections : %s', perfdatas => [ - { label => 'servers', value => 'servers_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'servers', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -156,9 +156,9 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - 'filter-name:s' => { name => 'filter_name' }, - 'filter-type:s' => { name => 'filter_type' }, - 'threshold-overload:s@' => { name => 'threshold_overload' }, + 'filter-name:s' => { name => 'filter_name' }, + 'filter-type:s' => { name => 'filter_type' }, + 'threshold-overload:s@' => { name => 'threshold_overload' }, }); return $self; diff --git a/network/citrix/sdx/snmp/mode/diskusage.pm b/network/citrix/sdx/snmp/mode/diskusage.pm index 6c6eeeb0b..279420cba 100644 --- a/network/citrix/sdx/snmp/mode/diskusage.pm +++ b/network/citrix/sdx/snmp/mode/diskusage.pm @@ -109,22 +109,20 @@ sub set_counters { } }, { label => 'read-iops', set => { - key_values => [ { name => 'diskTotalBlocksRead', diff => 1 }, { name => 'display' } ], - per_second => 1, + key_values => [ { name => 'diskTotalBlocksRead', per_second => 1 }, { name => 'display' } ], output_template => 'Read IOPs : %.2f', output_error_template => "Read IOPs : %s", perfdatas => [ - { label => 'read_iops', value => 'diskTotalBlocksRead_per_second', template => '%.2f', - unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'read_iops', template => '%.2f', + unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'write-iops', set => { - key_values => [ { name => 'diskTotalBlocksWritten', diff => 1 }, { name => 'display' } ], - per_second => 1, + key_values => [ { name => 'diskTotalBlocksWritten', per_second => 1 }, { name => 'display' } ], output_template => 'Write IOPs : %.2f', output_error_template => "Write IOPs : %s", perfdatas => [ - { label => 'write_iops', value => 'diskTotalBlocksWritten_per_second', template => '%.2f', - unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'write_iops', template => '%.2f', + unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -137,9 +135,9 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - "filter-name:s" => { name => 'filter_name' }, - "units:s" => { name => 'units', default => '%' }, - "free" => { name => 'free' }, + 'filter-name:s' => { name => 'filter_name' }, + 'units:s' => { name => 'units', default => '%' }, + 'free' => { name => 'free' }, }); return $self; diff --git a/network/citrix/sdx/snmp/mode/xenusage.pm b/network/citrix/sdx/snmp/mode/xenusage.pm index 06ae42129..35b9d372a 100644 --- a/network/citrix/sdx/snmp/mode/xenusage.pm +++ b/network/citrix/sdx/snmp/mode/xenusage.pm @@ -111,8 +111,8 @@ sub set_counters { key_values => [ { name => 'xenCpuUsage' }, { name => 'display' } ], output_template => 'CPU Usage : %.2f %%', output_error_template => "CPU Usage : %s", perfdatas => [ - { label => 'cpu_usage', value => 'xenCpuUsage_absolute', template => '%.2f', - unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'cpu_usage', value => 'xenCpuUsage', template => '%.2f', + unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/network/colubris/snmp/mode/apusage.pm b/network/colubris/snmp/mode/apusage.pm index 312479c66..d5c16db89 100644 --- a/network/colubris/snmp/mode/apusage.pm +++ b/network/colubris/snmp/mode/apusage.pm @@ -55,7 +55,7 @@ sub set_counters { key_values => [ { name => 'total_ap' } ], output_template => 'total AP: %s', perfdatas => [ - { label => 'total_ap', value => 'total_ap_absolute', template => '%s', min => 0 }, + { label => 'total_ap', value => 'total_ap', template => '%s', min => 0 }, ], } }, @@ -63,7 +63,7 @@ sub set_counters { key_values => [ { name => 'total_users' } ], output_template => 'total users: %s', perfdatas => [ - { label => 'total_users', value => 'total_users_absolute', template => '%s', min => 0 }, + { label => 'total_users', value => 'total_users', template => '%s', min => 0 }, ], } }, @@ -82,8 +82,8 @@ sub set_counters { key_values => [ { name => 'users' }, { name => 'display' } ], output_template => 'current users: %s', perfdatas => [ - { label => 'ap_users', value => 'users_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'ap_users', value => 'users', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/network/colubris/snmp/mode/cpu.pm b/network/colubris/snmp/mode/cpu.pm index fb32b1436..61e1d3e79 100644 --- a/network/colubris/snmp/mode/cpu.pm +++ b/network/colubris/snmp/mode/cpu.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'usage_now' } ], output_template => '%.2f %% (current)', perfdatas => [ - { label => 'cpu_current', value => 'usage_now_absolute', template => '%.2f', + { label => 'cpu_current', value => 'usage_now', template => '%.2f', unit => '%', min => 0, max => 100 }, ], } @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'usage_5s' } ], output_template => '%.2f %% (5sec)', perfdatas => [ - { label => 'cpu_5s', value => 'usage_5s_absolute', template => '%.2f', + { label => 'cpu_5s', value => 'usage_5s', template => '%.2f', unit => '%', min => 0, max => 100 }, ], } @@ -55,7 +55,7 @@ sub set_counters { key_values => [ { name => 'usage_10s' } ], output_template => '%.2f %% (10sec)', perfdatas => [ - { label => 'cpu_10s', value => 'usage_10s_absolute', template => '%.2f', + { label => 'cpu_10s', value => 'usage_10s', template => '%.2f', unit => '%', min => 0, max => 100 }, ], } @@ -64,7 +64,7 @@ sub set_counters { key_values => [ { name => 'usage_20s' } ], output_template => '%.2f %% (5sec)', perfdatas => [ - { label => 'cpu_20s', value => 'usage_20s_absolute', template => '%.2f', + { label => 'cpu_20s', value => 'usage_20s', template => '%.2f', unit => '%', min => 0, max => 100 }, ], } diff --git a/network/colubris/snmp/mode/load.pm b/network/colubris/snmp/mode/load.pm index 00ea0dee2..e2a9e757d 100644 --- a/network/colubris/snmp/mode/load.pm +++ b/network/colubris/snmp/mode/load.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'load1' } ], output_template => '%s', perfdatas => [ - { label => 'load1', value => 'load1_absolute', template => '%s', min => 0 }, + { label => 'load1', value => 'load1', template => '%s', min => 0 }, ], } }, @@ -45,7 +45,7 @@ sub set_counters { key_values => [ { name => 'load5' } ], output_template => '%s', perfdatas => [ - { label => 'load5', value => 'load5_absolute', template => '%s', min => 0 }, + { label => 'load5', value => 'load5', template => '%s', min => 0 }, ], } }, @@ -53,7 +53,7 @@ sub set_counters { key_values => [ { name => 'load15' } ], output_template => '%s', perfdatas => [ - { label => 'load15', value => 'load15_absolute', template => '%s', min => 0 }, + { label => 'load15', value => 'load15', template => '%s', min => 0 }, ], } }, diff --git a/network/colubris/snmp/mode/storage.pm b/network/colubris/snmp/mode/storage.pm index 4f9e3c39a..c65ea08cd 100644 --- a/network/colubris/snmp/mode/storage.pm +++ b/network/colubris/snmp/mode/storage.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'perm_used' } ], output_template => 'Permanent Storage Used: %.2f%%', perfdatas => [ - { label => 'storage_permanent_used', value => 'perm_used_absolute', template => '%.2f', + { label => 'storage_permanent_used', value => 'perm_used', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'temp_used' } ], output_template => 'Temporary Storage Used: %.2f%%', perfdatas => [ - { label => 'storage_temporary_used', value => 'temp_used_absolute', template => '%.2f', + { label => 'storage_temporary_used', value => 'temp_used', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } diff --git a/network/cyberoam/snmp/mode/requests.pm b/network/cyberoam/snmp/mode/requests.pm index 731b23bfb..b898c01a2 100644 --- a/network/cyberoam/snmp/mode/requests.pm +++ b/network/cyberoam/snmp/mode/requests.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'live_users' } ], output_template => 'live users = %s', perfdatas => [ - { label => 'live_users', value => 'live_users_absolute', template => '%s', min => 0 }, + { label => 'live_users', value => 'live_users', template => '%s', min => 0 }, ], } }, @@ -45,7 +45,7 @@ sub set_counters { key_values => [ { name => 'http_hits', diff => 1 } ], output_template => 'http hits = %s', perfdatas => [ - { label => 'http_hits', value => 'http_hits_absolute', template => '%s', min => 0 }, + { label => 'http_hits', value => 'http_hits', template => '%s', min => 0 }, ], } }, @@ -53,7 +53,7 @@ sub set_counters { key_values => [ { name => 'ftp_hits', diff => 1 } ], output_template => 'ftp hits = %s', perfdatas => [ - { label => 'ftp_hits', value => 'ftp_hits_absolute', template => '%s', min => 0 }, + { label => 'ftp_hits', value => 'ftp_hits', template => '%s', min => 0 }, ], } }, @@ -61,7 +61,7 @@ sub set_counters { key_values => [ { name => 'pop3_hits', diff => 1 } ], output_template => 'pop3 hits = %s', perfdatas => [ - { label => 'pop3_hits', value => 'pop3_hits_absolute', template => '%s', min => 0 }, + { label => 'pop3_hits', value => 'pop3_hits', template => '%s', min => 0 }, ], } }, @@ -69,7 +69,7 @@ sub set_counters { key_values => [ { name => 'imap_hits', diff => 1 } ], output_template => 'imap hits = %s', perfdatas => [ - { label => 'imap_hits', value => 'imap_hits_absolute', template => '%s', min => 0 }, + { label => 'imap_hits', value => 'imap_hits', template => '%s', min => 0 }, ], } }, @@ -77,7 +77,7 @@ sub set_counters { key_values => [ { name => 'smtp_hits', diff => 1 } ], output_template => 'smtp hits = %s', perfdatas => [ - { label => 'smtp_hits', value => 'smtp_hits_absolute', template => '%s', min => 0 }, + { label => 'smtp_hits', value => 'smtp_hits', template => '%s', min => 0 }, ], } }, diff --git a/network/digi/sarian/snmp/mode/gprs.pm b/network/digi/sarian/snmp/mode/gprs.pm index 63128c4d5..5d88e9bc9 100644 --- a/network/digi/sarian/snmp/mode/gprs.pm +++ b/network/digi/sarian/snmp/mode/gprs.pm @@ -69,7 +69,7 @@ sub set_counters { key_values => [ { name => 'signal' } ], output_template => 'Signal : %d dBm', perfdatas => [ - { label => 'signal_strenght', value => 'signal_absolute', template => '%s', + { label => 'signal_strenght', value => 'signal', template => '%s', unit => 'dBm' }, ], } diff --git a/network/digi/sarian/snmp/mode/temperature.pm b/network/digi/sarian/snmp/mode/temperature.pm index 0746e0df2..0fbddcc61 100644 --- a/network/digi/sarian/snmp/mode/temperature.pm +++ b/network/digi/sarian/snmp/mode/temperature.pm @@ -36,7 +36,7 @@ sub set_counters { key_values => [ { name => 'device' } ], output_template => 'Temp Device : %d °C', perfdatas => [ - { label => 'tempDevice', value => 'device_absolute', template => '%d', + { label => 'tempDevice', value => 'device', template => '%d', unit => 'C' }, ], } @@ -45,7 +45,7 @@ sub set_counters { key_values => [ { name => 'processor' } ], output_template => 'Temp Processor : %d °C', perfdatas => [ - { label => 'tempProcessor', value => 'processor_absolute', template => '%d', + { label => 'tempProcessor', value => 'processor', template => '%d', unit => 'C' }, ], } @@ -54,7 +54,7 @@ sub set_counters { key_values => [ { name => 'modem' } ], output_template => 'Temp Modem : %d °C', perfdatas => [ - { label => 'tempModem', value => 'modem_absolute', template => '%d', + { label => 'tempModem', value => 'modem', template => '%d', unit => 'C' }, ], } diff --git a/network/efficientip/snmp/mode/dhcpusage.pm b/network/efficientip/snmp/mode/dhcpusage.pm index 9e2e9739c..c7c4f4302 100644 --- a/network/efficientip/snmp/mode/dhcpusage.pm +++ b/network/efficientip/snmp/mode/dhcpusage.pm @@ -38,7 +38,7 @@ sub set_counters { key_values => [ { name => 'ack', diff => 1 } ], output_template => 'Ack : %s', perfdatas => [ - { label => 'ack', value => 'ack_absolute', template => '%s', min => 0 }, + { label => 'ack', value => 'ack', template => '%s', min => 0 }, ], } }, @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'nack', diff => 1 } ], output_template => 'Nack : %s', perfdatas => [ - { label => 'nack', value => 'nack_absolute', template => '%s', min => 0 }, + { label => 'nack', value => 'nack', template => '%s', min => 0 }, ], } }, @@ -54,7 +54,7 @@ sub set_counters { key_values => [ { name => 'offer', diff => 1 } ], output_template => 'Offer : %s', perfdatas => [ - { label => 'offer', value => 'offer_absolute', template => '%s', min => 0 }, + { label => 'offer', value => 'offer', template => '%s', min => 0 }, ], } }, @@ -62,7 +62,7 @@ sub set_counters { key_values => [ { name => 'inform', diff => 1 } ], output_template => 'Inform : %s', perfdatas => [ - { label => 'inform', value => 'inform_absolute', template => '%s', min => 0 }, + { label => 'inform', value => 'inform', template => '%s', min => 0 }, ], } }, @@ -70,7 +70,7 @@ sub set_counters { key_values => [ { name => 'decline', diff => 1 } ], output_template => 'Decline : %s', perfdatas => [ - { label => 'decline', value => 'decline_absolute', template => '%s', min => 0 }, + { label => 'decline', value => 'decline', template => '%s', min => 0 }, ], } }, @@ -78,7 +78,7 @@ sub set_counters { key_values => [ { name => 'release', diff => 1 } ], output_template => 'Release : %s', perfdatas => [ - { label => 'release', value => 'release_absolute', template => '%s', min => 0 }, + { label => 'release', value => 'release', template => '%s', min => 0 }, ], } }, @@ -86,7 +86,7 @@ sub set_counters { key_values => [ { name => 'request', diff => 1 } ], output_template => 'Request : %s', perfdatas => [ - { label => 'request', value => 'request_absolute', template => '%s', min => 0 }, + { label => 'request', value => 'request', template => '%s', min => 0 }, ], } }, @@ -94,7 +94,7 @@ sub set_counters { key_values => [ { name => 'discover', diff => 1 } ], output_template => 'Discover : %s', perfdatas => [ - { label => 'discover', value => 'discover_absolute', template => '%s', min => 0 }, + { label => 'discover', value => 'discover', template => '%s', min => 0 }, ], } }, diff --git a/network/efficientip/snmp/mode/dnsusage.pm b/network/efficientip/snmp/mode/dnsusage.pm index 74ef231cf..e8be9daec 100644 --- a/network/efficientip/snmp/mode/dnsusage.pm +++ b/network/efficientip/snmp/mode/dnsusage.pm @@ -52,7 +52,7 @@ sub set_counters { key_values => [ { name => $map[$i], diff => 1 } ], output_template => $map[$i + 1], perfdatas => [ - { label => $map[$i], value => $map[$i] . '_absolute', template => '%s', min => 0 }, + { label => $map[$i], value => $map[$i] , template => '%s', min => 0 }, ], } }, diff --git a/network/extreme/snmp/mode/cpu.pm b/network/extreme/snmp/mode/cpu.pm index 49cb13891..74998fd54 100644 --- a/network/extreme/snmp/mode/cpu.pm +++ b/network/extreme/snmp/mode/cpu.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'total' } ], output_template => 'Total CPU Usage : %.2f %%', perfdatas => [ - { label => 'cpu_total', value => 'total_absolute', template => '%.2f', min => 0, max => 100, unit => '%' }, + { label => 'cpu_total', value => 'total', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } }, @@ -48,8 +48,8 @@ sub set_counters { key_values => [ { name => 'extremeCpuMonitorSystemUtilization5secs' }, { name => 'num' }, ], output_template => '5 seconds : %.2f %%', perfdatas => [ - { label => 'cpu_5secs', value => 'extremeCpuMonitorSystemUtilization5secs_absolute', template => '%.2f', - min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'num_absolute' }, + { label => 'cpu_5secs', value => 'extremeCpuMonitorSystemUtilization5secs', template => '%.2f', + min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'num' }, ], } }, @@ -57,8 +57,8 @@ sub set_counters { key_values => [ { name => 'extremeCpuMonitorSystemUtilization10secs' }, { name => 'num' }, ], output_template => '10 seconds : %.2f %%', perfdatas => [ - { label => 'cpu_10secs', value => 'extremeCpuMonitorSystemUtilization10secs_absolute', template => '%.2f', - min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'num_absolute' }, + { label => 'cpu_10secs', value => 'extremeCpuMonitorSystemUtilization10secs', template => '%.2f', + min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'num' }, ], } }, @@ -66,8 +66,8 @@ sub set_counters { key_values => [ { name => 'extremeCpuMonitorSystemUtilization30secs' }, { name => 'num' }, ], output_template => '30 seconds : %.2f %%', perfdatas => [ - { label => 'cpu_30secs', value => 'extremeCpuMonitorSystemUtilization30secs_absolute', template => '%.2f', - min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'num_absolute' }, + { label => 'cpu_30secs', value => 'extremeCpuMonitorSystemUtilization30secs', template => '%.2f', + min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'num' }, ], } }, @@ -75,8 +75,8 @@ sub set_counters { key_values => [ { name => 'extremeCpuMonitorSystemUtilization1min' }, { name => 'num' }, ], output_template => '1 minute : %.2f %%', perfdatas => [ - { label => 'cpu_1min', value => 'extremeCpuMonitorSystemUtilization1min_absolute', template => '%.2f', - min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'num_absolute' }, + { label => 'cpu_1min', value => 'extremeCpuMonitorSystemUtilization1min', template => '%.2f', + min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'num' }, ], } }, @@ -84,8 +84,8 @@ sub set_counters { key_values => [ { name => 'extremeCpuMonitorSystemUtilization5mins' }, { name => 'num' }, ], output_template => '5 minutes : %.2f %%', perfdatas => [ - { label => 'cpu_5min', value => 'extremeCpuMonitorSystemUtilization5mins_absolute', template => '%.2f', - min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'num_absolute' }, + { label => 'cpu_5min', value => 'extremeCpuMonitorSystemUtilization5mins', template => '%.2f', + min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'num' }, ], } }, diff --git a/network/f5/bigip/snmp/mode/apm.pm b/network/f5/bigip/snmp/mode/apm.pm index 0a9137376..8f117a94e 100644 --- a/network/f5/bigip/snmp/mode/apm.pm +++ b/network/f5/bigip/snmp/mode/apm.pm @@ -43,7 +43,7 @@ sub set_counters { key_values => [ { name => 'apmAccessStatTotalSessions', diff => 1 } ], output_template => 'created sessions: %s', perfdatas => [ - { value => 'apmAccessStatTotalSessions_absolute', template => '%s', min => 0 }, + { value => 'apmAccessStatTotalSessions', template => '%s', min => 0 }, ], } }, @@ -51,7 +51,7 @@ sub set_counters { key_values => [ { name => 'apmAccessStatCurrentActiveSessions' } ], output_template => 'active sessions: %s', perfdatas => [ - { value => 'apmAccessStatCurrentActiveSessions_absolute', template => '%s', min => 0 }, + { value => 'apmAccessStatCurrentActiveSessions', template => '%s', min => 0 }, ], } }, @@ -59,7 +59,7 @@ sub set_counters { key_values => [ { name => 'apmAccessStatCurrentPendingSessions' } ], output_template => 'pending sessions: %s', perfdatas => [ - { value => 'apmAccessStatCurrentPendingSessions_absolute', template => '%s', min => 0 }, + { value => 'apmAccessStatCurrentPendingSessions', template => '%s', min => 0 }, ], } }, @@ -70,7 +70,7 @@ sub set_counters { key_values => [ { name => 'apmPaStatTotalSessions', diff => 1 } ], output_template => 'created sessions: %s', perfdatas => [ - { value => 'apmPaStatTotalSessions_absolute', template => '%s', + { value => 'apmPaStatTotalSessions', template => '%s', min => 0, label_extra_instance => 1 }, ], } @@ -79,7 +79,7 @@ sub set_counters { key_values => [ { name => 'apmPaStatCurrentActiveSessions' } ], output_template => 'active sessions: %s', perfdatas => [ - { value => 'apmPaStatCurrentActiveSessions_absolute', template => '%s', + { value => 'apmPaStatCurrentActiveSessions', template => '%s', min => 0, label_extra_instance => 1 }, ], } @@ -88,7 +88,7 @@ sub set_counters { key_values => [ { name => 'apmPaStatCurrentPendingSessions' } ], output_template => 'pending sessions: %s', perfdatas => [ - { value => 'apmPaStatCurrentPendingSessions_absolute', template => '%s', + { value => 'apmPaStatCurrentPendingSessions', template => '%s', min => 0, label_extra_instance => 1 }, ], } diff --git a/network/f5/bigip/snmp/mode/connections.pm b/network/f5/bigip/snmp/mode/connections.pm index 9bf093eb6..66926e429 100644 --- a/network/f5/bigip/snmp/mode/connections.pm +++ b/network/f5/bigip/snmp/mode/connections.pm @@ -47,8 +47,7 @@ sub set_counters { key_values => [ { name => 'client' } ], output_template => 'Current client connections : %s', perfdatas => [ - { label => 'Client', value => 'client_absolute', template => '%s', - min => 0, unit => 'con' }, + { label => 'Client', template => '%s', min => 0, unit => 'con' }, ], } }, @@ -56,8 +55,7 @@ sub set_counters { key_values => [ { name => 'client_ssl' } ], output_template => 'Current client SSL connections : %s', perfdatas => [ - { label => 'ClientSSL', value => 'client_ssl_absolute', template => '%s', - min => 0, unit => 'con' }, + { label => 'ClientSSL', template => '%s', min => 0, unit => 'con' }, ], } }, @@ -65,7 +63,6 @@ sub set_counters { key_values => [ { name => 'client_ssl_tot_native', diff => 1 }, { name => 'client_ssl_tot_compat', diff => 1 } ], output_template => 'TPS client SSL connections : %.2f', threshold_use => 'client_ssl_tps', output_use => 'client_ssl_tps', closure_custom_calc => $self->can('custom_client_tps_calc'), - per_second => 1, perfdatas => [ { label => 'ClientSSL_Tps', value => 'client_ssl_tps', template => '%.2f', unit => 'tps', min => 0 }, @@ -76,8 +73,7 @@ sub set_counters { key_values => [ { name => 'server' } ], output_template => 'Current server connections: %s', perfdatas => [ - { label => 'Server', value => 'server_absolute', template => '%s', - min => 0, unit => 'con' }, + { label => 'Server', template => '%s', min => 0, unit => 'con' }, ], } }, @@ -85,8 +81,7 @@ sub set_counters { key_values => [ { name => 'server_ssl' } ], output_template => 'Current server SSL connections : %s', perfdatas => [ - { label => 'ServerSSL', value => 'server_ssl_absolute', template => '%s', - min => 0, unit => 'con' }, + { label => 'ServerSSL', template => '%s', min => 0, unit => 'con' }, ], } }, diff --git a/network/f5/bigip/snmp/mode/nodestatus.pm b/network/f5/bigip/snmp/mode/nodestatus.pm index ecbd38ab2..f79aa0910 100644 --- a/network/f5/bigip/snmp/mode/nodestatus.pm +++ b/network/f5/bigip/snmp/mode/nodestatus.pm @@ -57,8 +57,8 @@ sub set_counters { key_values => [ { name => 'ltmNodeAddrStatServerCurConns' }, { name => 'display' } ], output_template => 'current server connections : %s', perfdatas => [ - { label => 'current_server_connections', value => 'ltmNodeAddrStatServerCurConns_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'current_server_connections', value => 'ltmNodeAddrStatServerCurConns', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/network/f5/bigip/snmp/mode/poolstatus.pm b/network/f5/bigip/snmp/mode/poolstatus.pm index 0c7580856..cdbca22bd 100644 --- a/network/f5/bigip/snmp/mode/poolstatus.pm +++ b/network/f5/bigip/snmp/mode/poolstatus.pm @@ -58,8 +58,8 @@ sub set_counters { key_values => [ { name => 'ltmPoolStatServerCurConns' }, { name => 'display' } ], output_template => 'current server connections: %s', perfdatas => [ - { label => 'current_server_connections', value => 'ltmPoolStatServerCurConns_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'current_server_connections', value => 'ltmPoolStatServerCurConns', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -67,8 +67,8 @@ sub set_counters { key_values => [ { name => 'ltmPoolActiveMemberCnt' }, { name => 'display' } ], output_template => 'current active members: %s', perfdatas => [ - { label => 'current_active_members', value => 'ltmPoolActiveMemberCnt_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'current_active_members', value => 'ltmPoolActiveMemberCnt', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -76,8 +76,8 @@ sub set_counters { key_values => [ { name => 'ltmPoolMemberCnt' }, { name => 'display' } ], output_template => 'current total members: %s', perfdatas => [ - { label => 'current_total_members', value => 'ltmPoolMemberCnt_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'current_total_members', value => 'ltmPoolMemberCnt', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/network/f5/bigip/snmp/mode/tmmusage.pm b/network/f5/bigip/snmp/mode/tmmusage.pm index 6d735f9b1..a965d06a2 100644 --- a/network/f5/bigip/snmp/mode/tmmusage.pm +++ b/network/f5/bigip/snmp/mode/tmmusage.pm @@ -93,8 +93,8 @@ sub set_counters { key_values => [ { name => 'sysTmmStatTmUsageRatio1m' }, { name => 'display' } ], output_template => 'CPU Usage 1min : %s %%', output_error_template => "CPU Usage 1min : %s", perfdatas => [ - { label => 'cpu_1m', value => 'sysTmmStatTmUsageRatio1m_absolute', template => '%s', - unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'cpu_1m', value => 'sysTmmStatTmUsageRatio1m', template => '%s', + unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -102,8 +102,8 @@ sub set_counters { key_values => [ { name => 'sysTmmStatTmUsageRatio5m' }, { name => 'display' } ], output_template => 'CPU Usage 5min : %s %%', output_error_template => "CPU Usage 5min : %s", perfdatas => [ - { label => 'cpu_5m', value => 'sysTmmStatTmUsageRatio5m_absolute', template => '%s', - unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'cpu_5m', value => 'sysTmmStatTmUsageRatio5m', template => '%s', + unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -111,8 +111,8 @@ sub set_counters { key_values => [ { name => 'sysTmmStatClientCurConns' }, { name => 'display' } ], output_template => 'Current Client Connections : %s', output_error_template => "Current Client Connections : %s", perfdatas => [ - { label => 'current_client_connections', value => 'sysTmmStatClientCurConns_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'current_client_connections', value => 'sysTmmStatClientCurConns', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -120,8 +120,8 @@ sub set_counters { key_values => [ { name => 'sysTmmStatClientTotConns', diff => 1 }, { name => 'display' } ], output_template => 'Total Client Connections : %s', output_error_template => "Total Client Connections : %s", perfdatas => [ - { label => 'total_client_connections', value => 'sysTmmStatClientTotConns_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'total_client_connections', value => 'sysTmmStatClientTotConns', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -129,8 +129,8 @@ sub set_counters { key_values => [ { name => 'sysTmmStatServerCurConns' }, { name => 'display' } ], output_template => 'Current Server Connections : %s', output_error_template => "Current Server Connections : %s", perfdatas => [ - { label => 'current_server_connections', value => 'sysTmmStatServerCurConns_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'current_server_connections', value => 'sysTmmStatServerCurConns', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -138,8 +138,8 @@ sub set_counters { key_values => [ { name => 'sysTmmStatServerTotConns', diff => 1 }, { name => 'display' } ], output_template => 'Total Server Connections : %s', output_error_template => "Total Server Connections : %s", perfdatas => [ - { label => 'total_server_connections', value => 'sysTmmStatServerTotConns_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'total_server_connections', value => 'sysTmmStatServerTotConns', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/network/f5/bigip/snmp/mode/trunks.pm b/network/f5/bigip/snmp/mode/trunks.pm index 44adeddf9..40dc1777e 100644 --- a/network/f5/bigip/snmp/mode/trunks.pm +++ b/network/f5/bigip/snmp/mode/trunks.pm @@ -229,25 +229,25 @@ sub set_counters { output_template => "status is '%s'", output_error_template => 'Status : %s', output_use => 'sysTrunkStatus', closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => $self->can('custom_threshold_output'), + closure_custom_threshold_check => $self->can('custom_threshold_output') } }, { label => 'traffic-in', set => { key_values => [ { name => 'sysTrunkStatBytesIn', diff => 1 }, { name => 'sysTrunkOperBw', diff => 1 }, { name => 'display' } ], - closure_custom_calc => $self->can('custom_traffic_calc'), per_second => 1, + closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'sysTrunkStatBytesIn', speed => 'sysTrunkOperBw', label => 'in' }, closure_custom_output => $self->can('custom_traffic_output'), output_error_template => 'Traffic In : %s', closure_custom_perfdata => $self->can('custom_traffic_perfdata'), - closure_custom_threshold_check => $self->can('custom_traffic_threshold'), + closure_custom_threshold_check => $self->can('custom_traffic_threshold') } }, { label => 'traffic-out', set => { key_values => [ { name => 'sysTrunkStatBytesOut', diff => 1 }, { name => 'sysTrunkOperBw', diff => 1 }, { name => 'display' } ], - closure_custom_calc => $self->can('custom_traffic_calc'), per_second => 1, + closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'sysTrunkStatBytesOut', speed => 'sysTrunkOperBw', label => 'out' }, closure_custom_output => $self->can('custom_traffic_output'), output_error_template => 'Traffic Out : %s', closure_custom_perfdata => $self->can('custom_traffic_perfdata'), - closure_custom_threshold_check => $self->can('custom_traffic_threshold'), + closure_custom_threshold_check => $self->can('custom_traffic_threshold') } }, { label => 'packets-error-in', set => { @@ -256,7 +256,7 @@ sub set_counters { closure_custom_calc_extra_options => { errors => 'sysTrunkStatErrorsIn', packets => 'sysTrunkStatPktsIn', label => 'in' }, closure_custom_output => $self->can('custom_errors_output'), output_error_template => 'Packets In Error : %s', closure_custom_perfdata => $self->can('custom_errors_perfdata'), - closure_custom_threshold_check => $self->can('custom_errors_threshold'), + closure_custom_threshold_check => $self->can('custom_errors_threshold') } }, { label => 'packets-error-out', set => { @@ -265,7 +265,7 @@ sub set_counters { closure_custom_calc_extra_options => { errors => 'sysTrunkStatErrorsOut', packets => 'sysTrunkStatPktsOut', label => 'out' }, closure_custom_output => $self->can('custom_errors_output'), output_error_template => 'Packets Out Error : %s', closure_custom_perfdata => $self->can('custom_errors_perfdata'), - closure_custom_threshold_check => $self->can('custom_errors_threshold'), + closure_custom_threshold_check => $self->can('custom_errors_threshold') } }, { label => 'packets-drop-in', set => { @@ -274,7 +274,7 @@ sub set_counters { closure_custom_calc_extra_options => { drops => 'sysTrunkStatDropsIn', packets => 'sysTrunkStatPktsIn', label => 'in' }, closure_custom_output => $self->can('custom_drops_output'), output_error_template => 'Packets In Drop : %s', closure_custom_perfdata => $self->can('custom_drops_perfdata'), - closure_custom_threshold_check => $self->can('custom_drops_threshold'), + closure_custom_threshold_check => $self->can('custom_drops_threshold') } }, { label => 'packets-drop-out', set => { @@ -283,9 +283,9 @@ sub set_counters { closure_custom_calc_extra_options => { drops => 'sysTrunkStatDropsOut', packets => 'sysTrunkStatPktsOut', label => 'out' }, closure_custom_output => $self->can('custom_drops_output'), output_error_template => 'Packets Out Drop : %s', closure_custom_perfdata => $self->can('custom_drops_perfdata'), - closure_custom_threshold_check => $self->can('custom_drops_threshold'), + closure_custom_threshold_check => $self->can('custom_drops_threshold') } - }, + } ]; } diff --git a/network/freebox/restapi/mode/dslusage.pm b/network/freebox/restapi/mode/dslusage.pm index 42d6ea608..9fdcd4628 100644 --- a/network/freebox/restapi/mode/dslusage.pm +++ b/network/freebox/restapi/mode/dslusage.pm @@ -38,7 +38,7 @@ sub set_counters { output_template => 'Dsl available upload bandwidth : %.2f %s/s', output_change_bytes => 2, perfdatas => [ - { label => 'rate_up', value => 'rate_up_absolute', template => '%s', + { label => 'rate_up', value => 'rate_up', template => '%s', unit => 'b/s', min => 0 } ] } @@ -48,7 +48,7 @@ sub set_counters { output_template => 'Dsl available download bandwidth : %.2f %s/s', output_change_bytes => 2, perfdatas => [ - { label => 'rate_down', value => 'rate_down_absolute', template => '%s', + { label => 'rate_down', value => 'rate_down', template => '%s', unit => 'b/s', min => 0 } ] } @@ -58,7 +58,7 @@ sub set_counters { output_template => 'Dsl upload signal/noise ratio : %.2f dB', output_change_bytes => 2, perfdatas => [ - { label => 'snr_up', value => 'snr_up_absolute', template => '%.2f', + { label => 'snr_up', value => 'snr_up', template => '%.2f', unit => 'dB' } ] } @@ -68,7 +68,7 @@ sub set_counters { output_template => 'Dsl download signal/noise ratio : %.2f dB', output_change_bytes => 2, perfdatas => [ - { label => 'snr_down', value => 'snr_down_absolute', template => '%.2f', + { label => 'snr_down', value => 'snr_down', template => '%.2f', unit => 'dB' } ] } diff --git a/network/freebox/restapi/mode/netusage.pm b/network/freebox/restapi/mode/netusage.pm index f0bc001ad..90d233a5d 100644 --- a/network/freebox/restapi/mode/netusage.pm +++ b/network/freebox/restapi/mode/netusage.pm @@ -38,7 +38,7 @@ sub set_counters { output_template => 'Upload available bandwidth : %.2f %s/s', output_change_bytes => 2, perfdatas => [ - { label => 'bw_up', value => 'bw_up_absolute', template => '%s', + { label => 'bw_up', value => 'bw_up', template => '%s', unit => 'b/s', min => 0 } ] } @@ -48,7 +48,7 @@ sub set_counters { output_template => 'Download available bandwidth : %.2f %s/s', output_change_bytes => 2, perfdatas => [ - { label => 'bw_down', value => 'bw_down_absolute', template => '%s', + { label => 'bw_down', value => 'bw_down', template => '%s', unit => 'b/s', min => 0 } ] } @@ -58,7 +58,7 @@ sub set_counters { output_template => 'Upload rate : %.2f %s/s', output_change_bytes => 2, perfdatas => [ - { label => 'rate_up', value => 'rate_up_absolute', template => '%s', + { label => 'rate_up', value => 'rate_up', template => '%s', unit => 'b/s', min => 0 } ] } @@ -68,7 +68,7 @@ sub set_counters { output_template => 'Download rate : %.2f %s/s', output_change_bytes => 2, perfdatas => [ - { label => 'rate_down', value => 'rate_down_absolute', template => '%s', + { label => 'rate_down', value => 'rate_down', template => '%s', unit => 'b/s', min => 0 } ] } @@ -78,7 +78,7 @@ sub set_counters { output_template => 'Vpn client upload rate : %.2f %s/s', output_change_bytes => 2, perfdatas => [ - { label => 'vpn_rate_up', value => 'vpn_rate_up_absolute', template => '%s', + { label => 'vpn_rate_up', value => 'vpn_rate_up', template => '%s', unit => 'b/s', min => 0 } ] } @@ -88,7 +88,7 @@ sub set_counters { output_template => 'Vpn client download rate : %.2f %s/s', output_change_bytes => 2, perfdatas => [ - { label => 'vpn_rate_down', value => 'vpn_rate_down_absolute', template => '%s', + { label => 'vpn_rate_down', value => 'vpn_rate_down', template => '%s', unit => 'b/s', min => 0 } ] } diff --git a/network/freebox/restapi/mode/system.pm b/network/freebox/restapi/mode/system.pm index a57c43ee1..4cdfe5127 100644 --- a/network/freebox/restapi/mode/system.pm +++ b/network/freebox/restapi/mode/system.pm @@ -39,7 +39,7 @@ sub set_counters { key_values => [ { name => 'temp_cpum' } ], output_template => 'Temperature cpum : %s C', perfdatas => [ - { label => 'temp_cpum', value => 'temp_cpum_absolute', template => '%s', + { label => 'temp_cpum', value => 'temp_cpum', template => '%s', unit => 'C' } ] } @@ -48,7 +48,7 @@ sub set_counters { key_values => [ { name => 'temp_cpub' } ], output_template => 'Temperature cpub : %s C', perfdatas => [ - { label => 'temp_cpub', value => 'temp_cpub_absolute', template => '%s', + { label => 'temp_cpub', value => 'temp_cpub', template => '%s', unit => 'C' } ] } @@ -57,7 +57,7 @@ sub set_counters { key_values => [ { name => 'temp_sw' } ], output_template => 'Temperature switch : %s C', perfdatas => [ - { label => 'temp_sw', value => 'temp_sw_absolute', template => '%s', + { label => 'temp_sw', value => 'temp_sw', template => '%s', unit => 'C' } ] } @@ -66,7 +66,7 @@ sub set_counters { key_values => [ { name => 'fan_rpm' } ], output_template => 'fan speed : %s rpm', perfdatas => [ - { label => 'fan_rpm', value => 'fan_rpm_absolute', template => '%s', + { label => 'fan_rpm', value => 'fan_rpm', template => '%s', min => 0, unit => 'rpm' } ] } diff --git a/network/fritzbox/mode/traffic.pm b/network/fritzbox/mode/traffic.pm index d07f535e7..18d9ad7a8 100644 --- a/network/fritzbox/mode/traffic.pm +++ b/network/fritzbox/mode/traffic.pm @@ -131,28 +131,28 @@ sub run { # At least one second. two fast calls ;) $time_delta = 1; } - my $in_absolute_per_sec = ($new_datas->{in} - $old_in) / $time_delta; - my $out_absolute_per_sec = ($new_datas->{out} - $old_out) / $time_delta; + my $in_per_sec = ($new_datas->{in} - $old_in) / $time_delta; + my $out_per_sec = ($new_datas->{out} - $old_out) / $time_delta; my ($exit, $in_prct, $out_prct); - $in_prct = $in_absolute_per_sec * 100 / $NewLayer1DownstreamMaxBitRate; - $out_prct = $out_absolute_per_sec * 100 / $NewLayer1UpstreamMaxBitRate; + $in_prct = $in_per_sec * 100 / $NewLayer1DownstreamMaxBitRate; + $out_prct = $out_per_sec * 100 / $NewLayer1UpstreamMaxBitRate; if ($self->{option_results}->{units} eq '%') { my $exit1 = $self->{perfdata}->threshold_check(value => $in_prct, threshold => [ { label => 'critical-in', 'exit_litteral' => 'critical' }, { label => 'warning-in', exit_litteral => 'warning' } ]); my $exit2 = $self->{perfdata}->threshold_check(value => $out_prct, threshold => [ { label => 'critical-out', 'exit_litteral' => 'critical' }, { label => 'warning-out', exit_litteral => 'warning' } ]); $exit = $self->{output}->get_most_critical(status => [ $exit1, $exit2 ]); } else { - my $exit1 = $self->{perfdata}->threshold_check(value => $in_absolute_per_sec, threshold => [ { label => 'critical-in', 'exit_litteral' => 'critical' }, { label => 'warning-in', exit_litteral => 'warning' } ]); - my $exit2 = $self->{perfdata}->threshold_check(value => $out_absolute_per_sec, threshold => [ { label => 'critical-out', 'exit_litteral' => 'critical' }, { label => 'warning-out', exit_litteral => 'warning' } ]); + my $exit1 = $self->{perfdata}->threshold_check(value => $in_per_sec, threshold => [ { label => 'critical-in', 'exit_litteral' => 'critical' }, { label => 'warning-in', exit_litteral => 'warning' } ]); + my $exit2 = $self->{perfdata}->threshold_check(value => $out_per_sec, threshold => [ { label => 'critical-out', 'exit_litteral' => 'critical' }, { label => 'warning-out', exit_litteral => 'warning' } ]); $exit = $self->{output}->get_most_critical(status => [ $exit1, $exit2 ]); } $in_prct = sprintf("%.2f", $in_prct); $out_prct = sprintf("%.2f", $out_prct); ### Manage Output - my ($in_value, $in_unit) = $self->{perfdata}->change_bytes(value => $in_absolute_per_sec, network => 1); - my ($out_value, $out_unit) = $self->{perfdata}->change_bytes(value => $out_absolute_per_sec, network => 1); + my ($in_value, $in_unit) = $self->{perfdata}->change_bytes(value => $in_per_sec, network => 1); + my ($out_value, $out_unit) = $self->{perfdata}->change_bytes(value => $out_per_sec, network => 1); $self->{output}->output_add(short_msg => sprintf("Traffic In : %s/s (%s %%), Out : %s/s (%s %%)", $in_value . $in_unit, $in_prct, $out_value . $out_unit, $out_prct)); @@ -165,13 +165,13 @@ sub run { $self->{output}->perfdata_add(label => 'traffic_in', unit => 'b/s', - value => sprintf("%.2f", $in_absolute_per_sec), + value => sprintf("%.2f", $in_per_sec), warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-in', total => $NewLayer1DownstreamMaxBitRate), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-in', total => $NewLayer1DownstreamMaxBitRate), min => 0, max => $NewLayer1DownstreamMaxBitRate); $self->{output}->perfdata_add(label => 'traffic_out', unit => 'b/s', - value => sprintf("%.2f", $out_absolute_per_sec), + value => sprintf("%.2f", $out_per_sec), warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-out', total => $NewLayer1UpstreamMaxBitRate), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-out', total => $NewLayer1UpstreamMaxBitRate), min => 0, max => $NewLayer1UpstreamMaxBitRate); diff --git a/network/hp/procurve/snmp/mode/virtualchassis.pm b/network/hp/procurve/snmp/mode/virtualchassis.pm index 8e9927158..bcc8269a8 100644 --- a/network/hp/procurve/snmp/mode/virtualchassis.pm +++ b/network/hp/procurve/snmp/mode/virtualchassis.pm @@ -73,13 +73,13 @@ sub custom_link_status_output { sub custom_memory_usage_output { my ($self, %options) = @_; - my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_absolute}); - my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_absolute}); - my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute}); + my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}); + my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}); + my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}); my $msg = sprintf("memory usage total: %s used: %s (%.2f%%) free: %s (%.2f%%)", $total_size_value . " " . $total_size_unit, - $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used_absolute}, - $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free_absolute} + $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used}, + $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free} ); return $msg; } @@ -110,7 +110,7 @@ sub set_counters { key_values => [ { name => 'members'} ], output_template => 'total members: %s', perfdatas => [ - { value => 'members_absolute', template => '%s', min => 0 }, + { value => 'members', template => '%s', min => 0 }, ], } }, @@ -129,7 +129,7 @@ sub set_counters { key_values => [ { name => 'cpu'}, { name => 'display'} ], output_template => 'cpu usage: %.2f%%', perfdatas => [ - { value => 'cpu_absolute', template => '%.2f', unit => '%', min => 0, max => 100, + { value => 'cpu', template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1 }, ], } @@ -138,7 +138,7 @@ sub set_counters { key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'display' } ], closure_custom_output => $self->can('custom_memory_usage_output'), perfdatas => [ - { value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute', + { value => 'used', template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1, label_extra_instance => 1 }, ], } @@ -147,7 +147,7 @@ sub set_counters { key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'display' } ], closure_custom_output => $self->can('custom_memory_usage_output'), perfdatas => [ - { value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute', + { value => 'free', template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1, label_extra_instance => 1 }, ], } @@ -156,7 +156,7 @@ sub set_counters { key_values => [ { name => 'prct_used' }, { name => 'display' } ], output_template => 'memory used : %.2f %%', perfdatas => [ - { value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, + { value => 'prct_used', template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 }, ], } diff --git a/network/huawei/snmp/mode/cpu.pm b/network/huawei/snmp/mode/cpu.pm index b2b952a45..7ce136b42 100644 --- a/network/huawei/snmp/mode/cpu.pm +++ b/network/huawei/snmp/mode/cpu.pm @@ -37,8 +37,8 @@ sub set_counters { key_values => [ { name => 'cpu' }, { name => 'num' }, ], output_template => 'Usage : %.2f %%', perfdatas => [ - { label => 'cpu', value => 'cpu_absolute', template => '%.2f', - min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'num_absolute' }, + { label => 'cpu', value => 'cpu', template => '%.2f', + min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'num' }, ], } }, diff --git a/network/infoblox/snmp/mode/cpu.pm b/network/infoblox/snmp/mode/cpu.pm index 174c8a595..738c368f1 100644 --- a/network/infoblox/snmp/mode/cpu.pm +++ b/network/infoblox/snmp/mode/cpu.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'cpu' } ], output_template => 'CPU Usage : %.2f %%', perfdatas => [ - { label => 'cpu_usage', value => 'cpu_absolute', template => '%.2f', + { label => 'cpu_usage', value => 'cpu', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } diff --git a/network/infoblox/snmp/mode/dhcpusage.pm b/network/infoblox/snmp/mode/dhcpusage.pm index a76f72187..90f162f56 100644 --- a/network/infoblox/snmp/mode/dhcpusage.pm +++ b/network/infoblox/snmp/mode/dhcpusage.pm @@ -54,7 +54,7 @@ sub set_counters { key_values => [ { name => $map[$i]->[0], diff => 1 } ], output_template => $map[$i]->[1], perfdatas => [ - { label => $perf_label, value => $map[$i]->[0] . '_absolute', template => '%s', min => 0 }, + { label => $perf_label, value => $map[$i]->[0] , template => '%s', min => 0 }, ], } }; @@ -65,8 +65,8 @@ sub set_counters { key_values => [ { name => 'ibDHCPSubnetPercentUsed' }, { name => 'display' } ], output_template => 'Used : %.2f %%', perfdatas => [ - { label => 'subnet_used', value => 'iibDHCPSubnetPercentUsed_absolute', template => '%.2f', - min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'subnet_used', value => 'iibDHCPSubnetPercentUsed', template => '%.2f', + min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/network/infoblox/snmp/mode/dnsusage.pm b/network/infoblox/snmp/mode/dnsusage.pm index 548d86506..929ad1e4e 100644 --- a/network/infoblox/snmp/mode/dnsusage.pm +++ b/network/infoblox/snmp/mode/dnsusage.pm @@ -39,7 +39,7 @@ sub set_counters { key_values => [ { name => 'ibDnsQueryRate' } ], output_template => 'Total query rate : %s', perfdatas => [ - { label => 'total_query_rate', value => 'ibDnsQueryRate_absolute', template => '%s', + { label => 'total_query_rate', value => 'ibDnsQueryRate', template => '%s', min => 0 }, ], } @@ -48,7 +48,7 @@ sub set_counters { key_values => [ { name => 'ibDnsHitRatio' } ], output_template => 'Total hit ratio : %.2f %%', perfdatas => [ - { label => 'total_hit_ratio', value => 'ibDnsHitRatio_absolute', template => '%.2f', + { label => 'total_hit_ratio', value => 'ibDnsHitRatio', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } @@ -60,8 +60,8 @@ sub set_counters { key_values => [ { name => 'ibBindZoneSuccess', diff => 1 }, { name => 'display' } ], output_template => 'Success responses : %s', perfdatas => [ - { label => 'success_count', value => 'ibBindZoneSuccess_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'success_count', value => 'ibBindZoneSuccess', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -69,8 +69,8 @@ sub set_counters { key_values => [ { name => 'ibBindZoneReferral', diff => 1 }, { name => 'display' } ], output_template => 'Referrals : %s', perfdatas => [ - { label => 'referral_count', value => 'ibBindZoneReferral_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'referral_count', value => 'ibBindZoneReferral', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -78,8 +78,8 @@ sub set_counters { key_values => [ { name => 'ibBindZoneNxRRset', diff => 1 }, { name => 'display' } ], output_template => 'Non-existent record : %s', perfdatas => [ - { label => 'nxrrset_count', value => 'ibBindZoneNxRRset_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'nxrrset_count', value => 'ibBindZoneNxRRset', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -87,8 +87,8 @@ sub set_counters { key_values => [ { name => 'ibBindZoneFailure', diff => 1 }, { name => 'display' } ], output_template => 'Failed queries : %s', perfdatas => [ - { label => 'failure_count', value => 'ibBindZoneFailure_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'failure_count', value => 'ibBindZoneFailure', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/network/infoblox/snmp/mode/memory.pm b/network/infoblox/snmp/mode/memory.pm index 813026caf..2c10ad45a 100644 --- a/network/infoblox/snmp/mode/memory.pm +++ b/network/infoblox/snmp/mode/memory.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'ram_used' } ], output_template => 'Memory Used: %.2f%%', perfdatas => [ - { label => 'memory_used', value => 'ram_used_absolute', template => '%.2f', + { label => 'memory_used', value => 'ram_used', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'swap_used' } ], output_template => 'Swap Used: %.2f%%', perfdatas => [ - { label => 'swap_used', value => 'swap_used_absolute', template => '%.2f', + { label => 'swap_used', value => 'swap_used', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } diff --git a/network/juniper/common/ive/mode/users.pm b/network/juniper/common/ive/mode/users.pm index 5c7ee4f93..a132a3186 100644 --- a/network/juniper/common/ive/mode/users.pm +++ b/network/juniper/common/ive/mode/users.pm @@ -28,19 +28,19 @@ use warnings; sub custom_node_output { my ($self, %options) = @_; - if ($self->{result_values}->{node_total_absolute} ne '') { + if ($self->{result_values}->{node_total} ne '') { return sprintf( 'concurrent users licenses usage total: %s used: %s (%.2f%%) free: %s (%.2f%%)', - $self->{result_values}->{node_total_absolute}, - $self->{result_values}->{node_used_absolute}, - $self->{result_values}->{node_used_absolute} * 100 / $self->{result_values}->{node_total_absolute}, - $self->{result_values}->{node_total_absolute} - $self->{result_values}->{node_used_absolute}, - ($self->{result_values}->{node_total_absolute} - $self->{result_values}->{node_used_absolute}) * 100 / $self->{result_values}->{node_total_absolute} + $self->{result_values}->{node_total}, + $self->{result_values}->{node_used}, + $self->{result_values}->{node_used} * 100 / $self->{result_values}->{node_total}, + $self->{result_values}->{node_total} - $self->{result_values}->{node_used}, + ($self->{result_values}->{node_total} - $self->{result_values}->{node_used}) * 100 / $self->{result_values}->{node_total} ); } else { return sprintf( 'concurrent users licenses used: %s', - $self->{result_values}->{node_used_absolute} + $self->{result_values}->{node_used} ); } } @@ -57,7 +57,7 @@ sub set_counters { key_values => [ { name => 'node_used' }, { name => 'node_total' } ], closure_custom_output => $self->can('custom_node_output'), perfdatas => [ - { value => 'node_used_absolute', template => '%d', min => 0, max => 'node_total_absolute' }, + { value => 'node_used', template => '%d', min => 0, max => 'node_total' }, ], } }, @@ -65,7 +65,7 @@ sub set_counters { key_values => [ { name => 'node_free' }, { name => 'node_used' }, { name => 'node_total' } ], closure_custom_output => $self->can('custom_node_output'), perfdatas => [ - { value => 'node_free_absolute', template => '%d', min => 0, max => 'node_total_absolute' }, + { value => 'node_free', template => '%d', min => 0, max => 'node_total' }, ], } }, @@ -73,7 +73,7 @@ sub set_counters { key_values => [ { name => 'prct_node_used' } ], output_template => 'concurrent users licenses used: %.2f %%', perfdatas => [ - { value => 'prct_node_used_absolute', template => '%.2f', min => 0, max => 100, + { value => 'prct_node_used', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } @@ -82,7 +82,7 @@ sub set_counters { key_values => [ { name => 'web' } ], output_template => 'current concurrent signed-in web users connections: %s', perfdatas => [ - { value => 'web_absolute', template => '%s', min => 0 }, + { value => 'web', template => '%s', min => 0 }, ], } }, @@ -90,7 +90,7 @@ sub set_counters { key_values => [ { name => 'meeting' } ], output_template => 'current concurrent meeting users connections: %s', perfdatas => [ - { value => 'meeting_absolute', template => '%s', min => 0 }, + { value => 'meeting', template => '%s', min => 0 }, ], } }, @@ -98,7 +98,7 @@ sub set_counters { key_values => [ { name => 'cluster' } ], output_template => 'current concurrent cluster logged users connections: %s', perfdatas => [ - { value => 'cluster_absolute', template => '%s', min => 0 }, + { value => 'cluster', template => '%s', min => 0 }, ], } } diff --git a/network/juniper/common/junos/mode/bgppeerprefixstatistics.pm b/network/juniper/common/junos/mode/bgppeerprefixstatistics.pm index f77c02239..66bf406dc 100644 --- a/network/juniper/common/junos/mode/bgppeerprefixstatistics.pm +++ b/network/juniper/common/junos/mode/bgppeerprefixstatistics.pm @@ -44,7 +44,7 @@ sub set_counters { key_values => [ { name => 'jnxBgpM2PrefixInPrefixes' }, { name => 'jnxBgpM2PrefixCountersAfiSafi' } ], output_template => 'Prefixes In: %d', perfdatas => [ - { value => 'jnxBgpM2PrefixInPrefixes_absolute', template => '%d', + { value => 'jnxBgpM2PrefixInPrefixes', template => '%d', label_extra_instance => 1 }, ], } @@ -53,7 +53,7 @@ sub set_counters { key_values => [ { name => 'jnxBgpM2PrefixInPrefixesAccepted' }, { name => 'jnxBgpM2PrefixCountersAfiSafi' } ], output_template => 'Prefixes In Accepted: %d', perfdatas => [ - { value => 'jnxBgpM2PrefixInPrefixesAccepted_absolute', template => '%d', + { value => 'jnxBgpM2PrefixInPrefixesAccepted', template => '%d', label_extra_instance => 1 }, ], } @@ -62,7 +62,7 @@ sub set_counters { key_values => [ { name => 'jnxBgpM2PrefixInPrefixesRejected' }, { name => 'jnxBgpM2PrefixCountersAfiSafi' } ], output_template => 'Prefixes In Rejected: %d', perfdatas => [ - { value => 'jnxBgpM2PrefixInPrefixesRejected_absolute', template => '%d', + { value => 'jnxBgpM2PrefixInPrefixesRejected', template => '%d', label_extra_instance => 1 }, ], } @@ -71,7 +71,7 @@ sub set_counters { key_values => [ { name => 'jnxBgpM2PrefixInPrefixesActive' }, { name => 'jnxBgpM2PrefixCountersAfiSafi' } ], output_template => 'Prefixes In Active: %d', perfdatas => [ - { value => 'jnxBgpM2PrefixInPrefixesActive_absolute', template => '%d', + { value => 'jnxBgpM2PrefixInPrefixesActive', template => '%d', label_extra_instance => 1 }, ], } @@ -80,7 +80,7 @@ sub set_counters { key_values => [ { name => 'jnxBgpM2PrefixOutPrefixes' }, { name => 'jnxBgpM2PrefixCountersAfiSafi' } ], output_template => 'Prefixes Out: %d', perfdatas => [ - { value => 'jnxBgpM2PrefixOutPrefixes_absolute', template => '%d', + { value => 'jnxBgpM2PrefixOutPrefixes', template => '%d', label_extra_instance => 1 }, ], } diff --git a/network/juniper/common/junos/mode/cpu.pm b/network/juniper/common/junos/mode/cpu.pm index 7a3f981de..1069be191 100644 --- a/network/juniper/common/junos/mode/cpu.pm +++ b/network/juniper/common/junos/mode/cpu.pm @@ -37,8 +37,8 @@ sub set_counters { key_values => [ { name => 'cpu_usage' }, { name => 'display' } ], output_template => 'average usage is: %.2f%%', perfdatas => [ - { label => 'cpu', value => 'cpu_usage_absolute', template => '%.2f', - unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'cpu', value => 'cpu_usage', template => '%.2f', + unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -46,8 +46,8 @@ sub set_counters { key_values => [ { name => 'cpu_load1' }, { name => 'display' } ], output_template => 'load 1min: %s', perfdatas => [ - { label => 'load1', value => 'cpu_load1_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'load1', value => 'cpu_load1', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -55,8 +55,8 @@ sub set_counters { key_values => [ { name => 'cpu_load5' }, { name => 'display' } ], output_template => 'load 5min: %s', perfdatas => [ - { label => 'load5', value => 'cpu_load5_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'load5', value => 'cpu_load5', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -64,8 +64,8 @@ sub set_counters { key_values => [ { name => 'cpu_load15' }, { name => 'display' } ], output_template => 'load 15min: %s', perfdatas => [ - { label => 'load15', value => 'cpu_load15_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'load15', value => 'cpu_load15', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/network/juniper/common/junos/mode/interfaces.pm b/network/juniper/common/junos/mode/interfaces.pm index 30e027430..2ef4fc297 100644 --- a/network/juniper/common/junos/mode/interfaces.pm +++ b/network/juniper/common/junos/mode/interfaces.pm @@ -57,8 +57,8 @@ sub set_counters { key_values => [ { name => 'input_power' }, { name => 'display' } ], output_template => 'Input Power : %s dBm', perfdatas => [ - { value => 'input_power_absolute', template => '%s', - unit => 'dBm', label_extra_instance => 1, instance_use => 'display_absolute' } + { value => 'input_power', template => '%s', + unit => 'dBm', label_extra_instance => 1, instance_use => 'display' } ] } }, @@ -66,8 +66,8 @@ sub set_counters { key_values => [ { name => 'bias_current' }, { name => 'display' } ], output_template => 'Bias Current : %s mA', perfdatas => [ - { value => 'bias_current_absolute', template => '%s', - unit => 'mA', label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'bias_current', template => '%s', + unit => 'mA', label_extra_instance => 1, instance_use => 'display' }, ] } }, @@ -75,8 +75,8 @@ sub set_counters { key_values => [ { name => 'output_power' }, { name => 'display' } ], output_template => 'Output Power : %s dBm', perfdatas => [ - { value => 'output_power_absolute', template => '%s', - unit => 'dBm', label_extra_instance => 1, instance_use => 'display_absolute' } + { value => 'output_power', template => '%s', + unit => 'dBm', label_extra_instance => 1, instance_use => 'display' } ] } }, @@ -84,8 +84,8 @@ sub set_counters { key_values => [ { name => 'module_temperature' }, { name => 'display' } ], output_template => 'Module Temperature : %.2f C', perfdatas => [ - { value => 'module_temperature_absolute', template => '%.2f', - unit => 'C', label_extra_instance => 1, instance_use => 'display_absolute' } + { value => 'module_temperature', template => '%.2f', + unit => 'C', label_extra_instance => 1, instance_use => 'display' } ] } } diff --git a/network/juniper/common/junos/mode/ipsectunnel.pm b/network/juniper/common/junos/mode/ipsectunnel.pm index 25cfb05ad..c07c5130c 100644 --- a/network/juniper/common/junos/mode/ipsectunnel.pm +++ b/network/juniper/common/junos/mode/ipsectunnel.pm @@ -47,12 +47,12 @@ sub set_counters { key_values => [ { name => 'total' } ], output_template => 'Total Tunnels: %s', perfdatas => [ - { label => 'total_tunnels', value => 'total_absolute', template => '%s', - min => 0 }, - ], + { label => 'total_tunnels', template => '%s', min => 0 } + ] } - }, + } ]; + $self->{maps_counters}->{tunnel} = [ { label => 'status', threshold => 0, set => { key_values => [ { name => 'ike_state' }, { name => 'display' } ], @@ -64,7 +64,7 @@ sub set_counters { }, { label => 'tunnel-traffic-in', nlabel => 'ipsec.tunnel.traffic.in.bitspersecond', set => { key_values => [], - per_second => 1, manual_keys => 1, + manual_keys => 1, closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'in' }, closure_custom_output => $self->can('custom_traffic_output'), threshold_use => 'traffic_per_second', @@ -76,7 +76,7 @@ sub set_counters { }, { label => 'tunnel-traffic-out', nlabel => 'ipsec.tunnel.traffic.out.bitspersecond', set => { key_values => [], - per_second => 1, manual_keys => 1, + manual_keys => 1, closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'out' }, closure_custom_output => $self->can('custom_traffic_output'), threshold_use => 'traffic_per_second', @@ -85,7 +85,7 @@ sub set_counters { min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } - }, + } ]; } diff --git a/network/juniper/common/junos/mode/ldpsessionstatus.pm b/network/juniper/common/junos/mode/ldpsessionstatus.pm index e7cac7055..f0a302362 100644 --- a/network/juniper/common/junos/mode/ldpsessionstatus.pm +++ b/network/juniper/common/junos/mode/ldpsessionstatus.pm @@ -68,8 +68,8 @@ sub set_counters { { name => 'label' } ], output_template => 'Last change: %s', perfdatas => [ - { label => 'last_change', value => 'jnxMplsLdpSesStateLastChange_absolute', template => '%d', - min => 0, unit => 's', label_extra_instance => 1, instance_use => 'label_absolute' }, + { label => 'last_change', value => 'jnxMplsLdpSesStateLastChange', template => '%d', + min => 0, unit => 's', label_extra_instance => 1, instance_use => 'label' }, ], } }, diff --git a/network/juniper/common/junos/mode/lspstatus.pm b/network/juniper/common/junos/mode/lspstatus.pm index 5d85325b2..c76b159bc 100644 --- a/network/juniper/common/junos/mode/lspstatus.pm +++ b/network/juniper/common/junos/mode/lspstatus.pm @@ -67,8 +67,8 @@ sub set_counters { key_values => [ { name => 'mplsLspInfoTransitions' }, { name => 'mplsLspName' } ], output_template => 'Transition count: %d', perfdatas => [ - { label => 'transition_count', value => 'mplsLspInfoTransitions_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'mplsLspName_absolute' }, + { label => 'transition_count', value => 'mplsLspInfoTransitions', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'mplsLspName' }, ], } }, @@ -77,8 +77,8 @@ sub set_counters { { name => 'mplsLspName' } ], output_template => 'Last transition: %s', perfdatas => [ - { label => 'last_transition', value => 'mplsLspInfoLastTransition_absolute', template => '%d', - min => 0, unit => 's', label_extra_instance => 1, instance_use => 'mplsLspName_absolute' }, + { label => 'last_transition', value => 'mplsLspInfoLastTransition', template => '%d', + min => 0, unit => 's', label_extra_instance => 1, instance_use => 'mplsLspName' }, ], } }, diff --git a/network/juniper/common/junos/mode/memory.pm b/network/juniper/common/junos/mode/memory.pm index 40c39886e..7229c1f40 100644 --- a/network/juniper/common/junos/mode/memory.pm +++ b/network/juniper/common/junos/mode/memory.pm @@ -29,11 +29,11 @@ sub custom_mem_output { my ($self, %options) = @_; return sprintf("Total: %s %s Used: %s %s (%.2f%%) Free: %s %s (%.2f%%)", - $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_absolute}), - $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_absolute}), - $self->{result_values}->{prct_used_absolute}, - $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute}), - $self->{result_values}->{prct_free_absolute} + $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}), + $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}), + $self->{result_values}->{prct_used}, + $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}), + $self->{result_values}->{prct_free} ); } @@ -49,8 +49,8 @@ sub set_counters { key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'display' } ], closure_custom_output => $self->can('custom_mem_output'), perfdatas => [ - { label => 'used', value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute', - unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'used', value => 'used', template => '%d', min => 0, max => 'total', + unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -58,8 +58,8 @@ sub set_counters { key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'display' } ], closure_custom_output => $self->can('custom_mem_output'), perfdatas => [ - { label => 'free', value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute', - unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'free', value => 'free', template => '%d', min => 0, max => 'total', + unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -67,8 +67,8 @@ sub set_counters { key_values => [ { name => 'prct_used' }, { name => 'display' } ], output_template => 'Used : %.2f %%', perfdatas => [ - { label => 'used_prct', value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, unit => '%', - label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'used_prct', value => 'prct_used', template => '%.2f', min => 0, max => 100, unit => '%', + label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/network/juniper/common/screenos/snmp/mode/nsrp.pm b/network/juniper/common/screenos/snmp/mode/nsrp.pm index b79d3d0ce..b6404e379 100644 --- a/network/juniper/common/screenos/snmp/mode/nsrp.pm +++ b/network/juniper/common/screenos/snmp/mode/nsrp.pm @@ -65,7 +65,7 @@ sub set_counters { key_values => [ { name => 'nsrpVsdGroupCntStateChange', diff => 1 } ], output_template => 'number of state transition events: %s', perfdatas => [ - { value => 'nsrpVsdGroupCntStateChange_absolute', template => '%s', + { value => 'nsrpVsdGroupCntStateChange', template => '%s', min => 0, label_extra_instance => 1 }, ], } diff --git a/network/juniper/common/screenos/snmp/mode/sessions.pm b/network/juniper/common/screenos/snmp/mode/sessions.pm index 64a5e03cd..b51bc58ba 100644 --- a/network/juniper/common/screenos/snmp/mode/sessions.pm +++ b/network/juniper/common/screenos/snmp/mode/sessions.pm @@ -37,42 +37,40 @@ sub set_counters { key_values => [ { name => 'prct_used' }, { name => 'total' }, { name => 'used' } ], closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ - { label => 'sessions', value => 'used_absolute', template => '%s', - min => 0, max => 'total_absolute', threshold_total => 'total_absolute', cast_int => 1 }, + { label => 'sessions', value => 'used', template => '%s', + min => 0, max => 'total', threshold_total => 'total', cast_int => 1 }, ], } }, { label => 'failed', set => { - key_values => [ { name => 'failed', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'failed', per_second => 1 } ], output_template => 'Failed sessions : %.2f/s', output_error_template => "Failed sessions : %s", perfdatas => [ - { label => 'sessions_failed', value => 'failed_per_second', template => '%.2f', unit => '/s', - min => 0 }, + { label => 'sessions_failed', template => '%.2f', unit => '/s', min => 0 }, ], } - }, + } ]; } sub custom_usage_output { my ($self, %options) = @_; - my $msg = sprintf("%.2f%% of the sessions limit reached (%d of max. %d)", - $self->{result_values}->{prct_used_absolute}, - $self->{result_values}->{used_absolute}, - $self->{result_values}->{total_absolute}); - return $msg; + return sprintf( + "%.2f%% of the sessions limit reached (%d of max. %d)", + $self->{result_values}->{prct_used}, + $self->{result_values}->{used}, + $self->{result_values}->{total} + ); } sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; - - $options{options}->add_options(arguments => - { - }); + + $options{options}->add_options(arguments => { + }); return $self; } @@ -85,12 +83,13 @@ sub manage_selection { my $oid_nsResSessFailed = '.1.3.6.1.4.1.3224.16.3.4.0'; my $result = $options{snmp}->get_leef(oids => [$oid_nsResSessAllocate, $oid_nsResSessMaxium, $oid_nsResSessFailed], nothing_quit => 1); - $self->{global} = { total => $result->{$oid_nsResSessMaxium}, - used => $result->{$oid_nsResSessAllocate}, - failed => $result->{$oid_nsResSessFailed}, - prct_used => $result->{$oid_nsResSessAllocate} * 100 / $result->{$oid_nsResSessMaxium}, - }; - + $self->{global} = { + total => $result->{$oid_nsResSessMaxium}, + used => $result->{$oid_nsResSessAllocate}, + failed => $result->{$oid_nsResSessFailed}, + prct_used => $result->{$oid_nsResSessAllocate} * 100 / $result->{$oid_nsResSessMaxium}, + }; + $self->{cache_name} = "juniper_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' . (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); } diff --git a/network/juniper/common/screenos/snmp/mode/vpnstatus.pm b/network/juniper/common/screenos/snmp/mode/vpnstatus.pm index 8ece4c35d..3aee38850 100644 --- a/network/juniper/common/screenos/snmp/mode/vpnstatus.pm +++ b/network/juniper/common/screenos/snmp/mode/vpnstatus.pm @@ -46,7 +46,7 @@ sub custom_update_output { my ($self, %options) = @_; my $msg = sprintf("Update time: %s", - $self->{result_values}->{update_time_absolute} != 0 ? centreon::plugins::misc::change_seconds(value => $self->{result_values}->{update_time_absolute}) : 0); + $self->{result_values}->{update_time} != 0 ? centreon::plugins::misc::change_seconds(value => $self->{result_values}->{update_time}) : 0); return $msg; } @@ -76,8 +76,8 @@ sub set_counters { key_values => [ { name => 'update_time'}, { name => 'display' } ], closure_custom_output => $self->can('custom_update_output'), perfdatas => [ - { label => 'update_time', value => 'update_time_absolute', template => '%d', - min => 0, unit => 's', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'update_time', value => 'update_time', template => '%d', + min => 0, unit => 's', label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/network/juniper/common/screenos/snmp/mode/vpnusage.pm b/network/juniper/common/screenos/snmp/mode/vpnusage.pm index 6ab443f70..28d3c2297 100644 --- a/network/juniper/common/screenos/snmp/mode/vpnusage.pm +++ b/network/juniper/common/screenos/snmp/mode/vpnusage.pm @@ -41,25 +41,25 @@ sub set_counters { $self->{maps_counters}->{vpn} = [ { label => 'traffic-in', set => { - key_values => [ { name => 'traffic_in', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'traffic_in', per_second => 1 }, { name => 'display' } ], output_template => 'Traffic In: %s %s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_in', value => 'traffic_in_absolute', template => '%s', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_in', template => '%s', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'traffic-out', set => { - key_values => [ { name => 'traffic_out', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'traffic_out', per_second => 1 }, { name => 'display' } ], output_template => 'Traffic Out: %s %s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_out', value => 'traffic_out_absolute', template => '%s', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_out', template => '%s', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } - }, + } ]; } @@ -68,11 +68,10 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - }); - + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' } + }); + return $self; } diff --git a/network/juniper/ggsn/mode/apnstats.pm b/network/juniper/ggsn/mode/apnstats.pm index 7b070ebaf..f244b998e 100644 --- a/network/juniper/ggsn/mode/apnstats.pm +++ b/network/juniper/ggsn/mode/apnstats.pm @@ -30,12 +30,12 @@ sub custom_drop_in_calc { my ($self, %options) = @_; $self->{result_values}->{ggsnApnName} = $options{new_datas}->{$self->{instance} . '_ggsnApnName'}; - $self->{result_values}->{ggsnApnUplinkDrops_absolute} = $options{new_datas}->{$self->{instance} . '_ggsnApnUplinkDrops'} - $options{old_datas}->{$self->{instance} . '_ggsnApnUplinkDrops'}; - $self->{result_values}->{ggsnApnUplinkPackets_absolute} = $options{new_datas}->{$self->{instance} . '_ggsnApnUplinkPackets'} - $options{old_datas}->{$self->{instance} . '_ggsnApnUplinkPackets'}; - if ($self->{result_values}->{ggsnApnUplinkPackets_absolute} == 0) { + $self->{result_values}->{ggsnApnUplinkDrops} = $options{new_datas}->{$self->{instance} . '_ggsnApnUplinkDrops'} - $options{old_datas}->{$self->{instance} . '_ggsnApnUplinkDrops'}; + $self->{result_values}->{ggsnApnUplinkPackets} = $options{new_datas}->{$self->{instance} . '_ggsnApnUplinkPackets'} - $options{old_datas}->{$self->{instance} . '_ggsnApnUplinkPackets'}; + if ($self->{result_values}->{ggsnApnUplinkPackets} == 0) { $self->{result_values}->{drop_prct} = 0; } else { - $self->{result_values}->{drop_prct} = $self->{result_values}->{ggsnApnUplinkDrops_absolute} * 100 / $self->{result_values}->{ggsnApnUplinkPackets_absolute}; + $self->{result_values}->{drop_prct} = $self->{result_values}->{ggsnApnUplinkDrops} * 100 / $self->{result_values}->{ggsnApnUplinkPackets}; } return 0; } @@ -44,12 +44,12 @@ sub custom_drop_out_calc { my ($self, %options) = @_; $self->{result_values}->{ggsnApnName} = $options{new_datas}->{$self->{instance} . '_ggsnApnName'}; - $self->{result_values}->{ggsnApnDownlinkDrops_absolute} = $options{new_datas}->{$self->{instance} . '_ggsnApnDownlinkDrops'} - $options{old_datas}->{$self->{instance} . '_ggsnApnDownlinkDrops'}; - $self->{result_values}->{ggsnApnDownlinkPackets_absolute} = $options{new_datas}->{$self->{instance} . '_ggsnApnDownlinkPackets'} - $options{old_datas}->{$self->{instance} . '_ggsnApnDownlinkPackets'}; - if ($self->{result_values}->{ggsnApnDownlinkPackets_absolute} == 0) { + $self->{result_values}->{ggsnApnDownlinkDrops} = $options{new_datas}->{$self->{instance} . '_ggsnApnDownlinkDrops'} - $options{old_datas}->{$self->{instance} . '_ggsnApnDownlinkDrops'}; + $self->{result_values}->{ggsnApnDownlinkPackets} = $options{new_datas}->{$self->{instance} . '_ggsnApnDownlinkPackets'} - $options{old_datas}->{$self->{instance} . '_ggsnApnDownlinkPackets'}; + if ($self->{result_values}->{ggsnApnDownlinkPackets} == 0) { $self->{result_values}->{drop_prct} = 0; } else { - $self->{result_values}->{drop_prct} = $self->{result_values}->{ggsnApnDownlinkDrops_absolute} * 100 / $self->{result_values}->{ggsnApnDownlinkPackets_absolute}; + $self->{result_values}->{drop_prct} = $self->{result_values}->{ggsnApnDownlinkDrops} * 100 / $self->{result_values}->{ggsnApnDownlinkPackets}; } return 0; } @@ -63,22 +63,22 @@ sub set_counters { $self->{maps_counters}->{apn} = [ { label => 'traffic-in', set => { - key_values => [ { name => 'ggsnApnUplinkBytes', diff => 1 }, { name => 'ggsnApnName' } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'ggsnApnUplinkBytes', per_second => 1 }, { name => 'ggsnApnName' } ], output_template => 'Traffic In : %s %s/s', + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_in', value => 'ggsnApnUplinkBytes_per_second', template => '%s', - unit => 'b/s', min => 0, label_extra_instance => 1, cast_int => 1, instance_use => 'ggsnApnName_absolute' }, + { label => 'traffic_in', template => '%s', + unit => 'b/s', min => 0, label_extra_instance => 1, cast_int => 1, instance_use => 'ggsnApnName' }, ], } }, { label => 'traffic-out', set => { - key_values => [ { name => 'ggsnApnDownlinkBytes', diff => 1 }, { name => 'ggsnApnName' } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'ggsnApnDownlinkBytes', per_second => 1 }, { name => 'ggsnApnName' } ], output_template => 'Traffic Out : %s %s/s', + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_out', value => 'ggsnApnDownlinkBytes_per_second', template => '%s', - unit => 'b/s', min => 0, label_extra_instance => 1, cast_int => 1, instance_use => 'ggsnApnName_absolute' }, + { label => 'traffic_out', template => '%s', + unit => 'b/s', min => 0, label_extra_instance => 1, cast_int => 1, instance_use => 'ggsnApnName' }, ], } }, @@ -87,8 +87,8 @@ sub set_counters { output_template => 'Drop In Packets : %.2f %%', threshold_use => 'drop_prct', output_use => 'drop_prct', closure_custom_calc => $self->can('custom_drop_in_calc'), perfdatas => [ - { label => 'drop_in', value => 'ggsnApnUplinkDrops_absolute', template => '%s', - min => 0, max => 'ggsnApnUplinkPackets_absolute', label_extra_instance => 1, instance_use => 'ggsnApnName' }, + { label => 'drop_in', value => 'ggsnApnUplinkDrops', template => '%s', + min => 0, max => 'ggsnApnUplinkPackets', label_extra_instance => 1, instance_use => 'ggsnApnName' }, ], } }, @@ -97,8 +97,8 @@ sub set_counters { output_template => 'Drop Out Packets : %.2f %%', threshold_use => 'drop_prct', output_use => 'drop_prct', closure_custom_calc => $self->can('custom_drop_out_calc'), perfdatas => [ - { label => 'drop_out', value => 'ggsnApnDownlinkDrops_absolute', template => '%s', - min => 0, max => 'ggsnApnDownlinkPackets_absolute', label_extra_instance => 1, instance_use => 'ggsnApnName' }, + { label => 'drop_out', value => 'ggsnApnDownlinkDrops', template => '%s', + min => 0, max => 'ggsnApnDownlinkPackets', label_extra_instance => 1, instance_use => 'ggsnApnName' }, ], } }, @@ -106,7 +106,7 @@ sub set_counters { key_values => [ { name => 'ggsnApnActivePdpContextCount' }, { name => 'ggsnApnName' } ], output_template => 'Active Pdp : %s', perfdatas => [ - { label => 'active_pdp', value => 'ggsnApnActivePdpContextCount_absolute', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'ggsnApnName_absolute' }, + { label => 'active_pdp', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'ggsnApnName' }, ], } }, @@ -114,7 +114,7 @@ sub set_counters { key_values => [ { name => 'ggsnApnAttemptedActivation', diff => 1 }, { name => 'ggsnApnName' } ], output_template => 'Attempted Activation Pdp : %s', perfdatas => [ - { label => 'attempted_activation_pdp', value => 'ggsnApnAttemptedActivation_absolute', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'ggsnApnName_absolute' }, + { label => 'attempted_activation_pdp', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'ggsnApnName' }, ], } }, @@ -122,7 +122,7 @@ sub set_counters { key_values => [ { name => 'ggsnApnAttemptedDynActivation', diff => 1 }, { name => 'ggsnApnName' } ], output_template => 'Attempted Dyn Activation Pdp : %s', perfdatas => [ - { label => 'attempted_dyn_activation_pdp', value => 'ggsnApnAttemptedDynActivation_absolute', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'ggsnApnName_absolute' }, + { label => 'attempted_dyn_activation_pdp', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'ggsnApnName' }, ], } }, @@ -130,7 +130,7 @@ sub set_counters { key_values => [ { name => 'ggsnApnAttemptedDeactivation', diff => 1 }, { name => 'ggsnApnName' } ], output_template => 'Attempted Deactivation Pdp : %s', perfdatas => [ - { label => 'attempted_deactivation_pdp', value => 'ggsnApnAttemptedDeactivation_absolute', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'ggsnApnName_absolute' }, + { label => 'attempted_deactivation_pdp', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'ggsnApnName' }, ], } }, @@ -138,7 +138,7 @@ sub set_counters { key_values => [ { name => 'ggsnApnAttemptedSelfDeactivation', diff => 1 }, { name => 'ggsnApnName' } ], output_template => 'Attempted Self Deactivation Pdp : %s', perfdatas => [ - { label => 'attempted_self_deactivation_pdp', value => 'ggsnApnAttemptedSelfDeactivation_absolute', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'ggsnApnName_absolute' }, + { label => 'attempted_self_deactivation_pdp', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'ggsnApnName' }, ], } }, @@ -146,7 +146,7 @@ sub set_counters { key_values => [ { name => 'ggsnApnCompletedActivation', diff => 1 }, { name => 'ggsnApnName' } ], output_template => 'Completed Activation Pdp : %s', perfdatas => [ - { label => 'completed_activation_pdp', value => 'ggsnApnCompletedActivation_absolute', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'ggsnApnName_absolute' }, + { label => 'completed_activation_pdp', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'ggsnApnName' }, ], } }, @@ -154,7 +154,7 @@ sub set_counters { key_values => [ { name => 'ggsnApnCompletedDynActivation', diff => 1 }, { name => 'ggsnApnName' } ], output_template => 'Completed Dyn Activation Pdp : %s', perfdatas => [ - { label => 'completed_dyn_activation_pdp', value => 'ggsnApnCompletedDynActivation_absolute', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'ggsnApnName_absolute' }, + { label => 'completed_dyn_activation_pdp', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'ggsnApnName' }, ], } }, @@ -162,7 +162,7 @@ sub set_counters { key_values => [ { name => 'ggsnApnCompletedDeactivation', diff => 1 }, { name => 'ggsnApnName' } ], output_template => 'Completed Deactivation Pdp : %s', perfdatas => [ - { label => 'completed_deactivation_pdp', value => 'ggsnApnCompletedDeactivation_absolute', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'ggsnApnName_absolute' }, + { label => 'completed_deactivation_pdp', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'ggsnApnName' }, ], } }, @@ -170,7 +170,7 @@ sub set_counters { key_values => [ { name => 'ggsnApnCompletedSelfDeactivation', diff => 1 }, { name => 'ggsnApnName' } ], output_template => 'Completed Self Deactivation Pdp : %s', perfdatas => [ - { label => 'completed_self_deactivation_pdp', value => 'ggsnApnCompletedSelfDeactivation_absolute', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'ggsnApnName_absolute' }, + { label => 'completed_self_deactivation_pdp', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'ggsnApnName' }, ], } }, @@ -183,7 +183,7 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - "filter-name:s" => { name => 'filter_name' }, + 'filter-name:s' => { name => 'filter_name' } }); return $self; diff --git a/network/juniper/ggsn/mode/globalstats.pm b/network/juniper/ggsn/mode/globalstats.pm index 0753bb493..ca1b15ec1 100644 --- a/network/juniper/ggsn/mode/globalstats.pm +++ b/network/juniper/ggsn/mode/globalstats.pm @@ -29,12 +29,12 @@ use Digest::MD5 qw(md5_hex); sub custom_drop_in_calc { my ($self, %options) = @_; - $self->{result_values}->{ggsnUplinkDrops_absolute} = $options{new_datas}->{$self->{instance} . '_ggsnUplinkDrops'} - $options{old_datas}->{$self->{instance} . '_ggsnUplinkDrops'}; - $self->{result_values}->{ggsnUplinkPackets_absolute} = $options{new_datas}->{$self->{instance} . '_ggsnUplinkPackets'} - $options{old_datas}->{$self->{instance} . '_ggsnUplinkPackets'}; - if ($self->{result_values}->{ggsnUplinkPackets_absolute} == 0) { + $self->{result_values}->{ggsnUplinkDrops} = $options{new_datas}->{$self->{instance} . '_ggsnUplinkDrops'} - $options{old_datas}->{$self->{instance} . '_ggsnUplinkDrops'}; + $self->{result_values}->{ggsnUplinkPackets} = $options{new_datas}->{$self->{instance} . '_ggsnUplinkPackets'} - $options{old_datas}->{$self->{instance} . '_ggsnUplinkPackets'}; + if ($self->{result_values}->{ggsnUplinkPackets} == 0) { $self->{result_values}->{drop_prct} = 0; } else { - $self->{result_values}->{drop_prct} = $self->{result_values}->{ggsnUplinkDrops_absolute} * 100 / $self->{result_values}->{ggsnUplinkPackets_absolute}; + $self->{result_values}->{drop_prct} = $self->{result_values}->{ggsnUplinkDrops} * 100 / $self->{result_values}->{ggsnUplinkPackets}; } return 0; } @@ -42,12 +42,12 @@ sub custom_drop_in_calc { sub custom_drop_out_calc { my ($self, %options) = @_; - $self->{result_values}->{ggsnDownlinkDrops_absolute} = $options{new_datas}->{$self->{instance} . '_ggsnDownlinkDrops'} - $options{old_datas}->{$self->{instance} . '_ggsnDownlinkDrops'}; - $self->{result_values}->{ggsnDownlinkPackets_absolute} = $options{new_datas}->{$self->{instance} . '_ggsnDownlinkPackets'} - $options{old_datas}->{$self->{instance} . '_ggsnDownlinkPackets'}; - if ($self->{result_values}->{ggsnDownlinkPackets_absolute} == 0) { + $self->{result_values}->{ggsnDownlinkDrops} = $options{new_datas}->{$self->{instance} . '_ggsnDownlinkDrops'} - $options{old_datas}->{$self->{instance} . '_ggsnDownlinkDrops'}; + $self->{result_values}->{ggsnDownlinkPackets} = $options{new_datas}->{$self->{instance} . '_ggsnDownlinkPackets'} - $options{old_datas}->{$self->{instance} . '_ggsnDownlinkPackets'}; + if ($self->{result_values}->{ggsnDownlinkPackets} == 0) { $self->{result_values}->{drop_prct} = 0; } else { - $self->{result_values}->{drop_prct} = $self->{result_values}->{ggsnDownlinkDrops_absolute} * 100 / $self->{result_values}->{ggsnDownlinkPackets_absolute}; + $self->{result_values}->{drop_prct} = $self->{result_values}->{ggsnDownlinkDrops} * 100 / $self->{result_values}->{ggsnDownlinkPackets}; } return 0; } @@ -61,22 +61,20 @@ sub set_counters { $self->{maps_counters}->{global} = [ { label => 'traffic-in', set => { - key_values => [ { name => 'ggsnUplinkBytes', diff => 1 } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'ggsnUplinkBytes', per_second => 1 } ], output_template => 'Traffic In : %s %s/s', + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_in', value => 'ggsnUplinkBytes_per_second', template => '%s', - unit => 'b/s', min => 0, cast_int => 1 }, + { label => 'traffic_in', template => '%s', unit => 'b/s', min => 0, cast_int => 1 }, ], } }, { label => 'traffic-out', set => { - key_values => [ { name => 'ggsnDownlinkBytes', diff => 1 } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'ggsnDownlinkBytes', per_second => 1 } ], output_template => 'Traffic Out : %s %s/s', + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_out', value => 'ggsnDownlinkBytes_per_second', template => '%s', - unit => 'b/s', min => 0, cast_int => 1 }, + { label => 'traffic_out', template => '%s', unit => 'b/s', min => 0, cast_int => 1 }, ], } }, @@ -85,8 +83,8 @@ sub set_counters { output_template => 'Drop In Packets : %.2f %%', threshold_use => 'drop_prct', output_use => 'drop_prct', closure_custom_calc => \&custom_drop_in_calc, perfdatas => [ - { label => 'drop_in', value => 'ggsnUplinkDrops_absolute', template => '%s', - min => 0, max => 'ggsnUplinkPackets_absolute' }, + { label => 'drop_in', value => 'ggsnUplinkDrops', template => '%s', + min => 0, max => 'ggsnUplinkPackets' }, ], } }, @@ -95,8 +93,8 @@ sub set_counters { output_template => 'Drop Out Packets : %.2f %%', threshold_use => 'drop_prct', output_use => 'drop_prct', closure_custom_calc => \&custom_drop_out_calc, perfdatas => [ - { label => 'drop_out', value => 'ggsnDownlinkDrops_absolute', template => '%s', - min => 0, max => 'ggsnDownlinkPackets_absolute' }, + { label => 'drop_out', value => 'ggsnDownlinkDrops', template => '%s', + min => 0, max => 'ggsnDownlinkPackets' }, ], } }, @@ -104,7 +102,7 @@ sub set_counters { key_values => [ { name => 'ggsnNbrOfActivePdpContexts' } ], output_template => 'Active Pdp : %s', perfdatas => [ - { label => 'active_pdp', value => 'ggsnNbrOfActivePdpContexts_absolute', template => '%s', min => 0 }, + { label => 'active_pdp', template => '%s', min => 0 }, ], } }, @@ -112,7 +110,7 @@ sub set_counters { key_values => [ { name => 'ggsnAttemptedActivation', diff => 1 } ], output_template => 'Attempted Activation Pdp : %s', perfdatas => [ - { label => 'attempted_activation_pdp', value => 'ggsnAttemptedActivation_absolute', template => '%s', min => 0 }, + { label => 'attempted_activation_pdp', template => '%s', min => 0 }, ], } }, @@ -120,7 +118,7 @@ sub set_counters { key_values => [ { name => 'ggsnAttemptedDeactivation', diff => 1 } ], output_template => 'Attempted Deactivation Pdp : %s', perfdatas => [ - { label => 'attempted_deactivation_pdp', value => 'ggsnAttemptedDeactivation_absolute', template => '%s', min => 0 }, + { label => 'attempted_deactivation_pdp', template => '%s', min => 0 }, ], } }, @@ -128,7 +126,7 @@ sub set_counters { key_values => [ { name => 'ggsnAttemptedDeactivation', diff => 1 } ], output_template => 'Attempted Deactivation Pdp : %s', perfdatas => [ - { label => 'attempted_deactivation_pdp', value => 'ggsnAttemptedDeactivation_absolute', template => '%s', min => 0 }, + { label => 'attempted_deactivation_pdp', template => '%s', min => 0 }, ], } }, @@ -136,7 +134,7 @@ sub set_counters { key_values => [ { name => 'ggsnAttemptedSelfDeactivation', diff => 1 } ], output_template => 'Attempted Self Deactivation Pdp : %s', perfdatas => [ - { label => 'attempted_self_deactivation_pdp', value => 'ggsnAttemptedSelfDeactivation_absolute', template => '%s', min => 0 }, + { label => 'attempted_self_deactivation_pdp', template => '%s', min => 0 }, ], } }, @@ -144,7 +142,7 @@ sub set_counters { key_values => [ { name => 'ggsnAttemptedUpdate', diff => 1 } ], output_template => 'Attempted Update Pdp : %s', perfdatas => [ - { label => 'attempted_update_pdp', value => 'ggsnAttemptedUpdate_absolute', template => '%s', min => 0 }, + { label => 'attempted_update_pdp', template => '%s', min => 0 }, ], } }, @@ -152,7 +150,7 @@ sub set_counters { key_values => [ { name => 'ggsnCompletedActivation', diff => 1 } ], output_template => 'Completed Activation Pdp : %s', perfdatas => [ - { label => 'completed_activation_pdp', value => 'ggsnCompletedActivation_absolute', template => '%s', min => 0 }, + { label => 'completed_activation_pdp', template => '%s', min => 0 }, ], } }, @@ -160,7 +158,7 @@ sub set_counters { key_values => [ { name => 'ggsnCompletedDeactivation', diff => 1 } ], output_template => 'Completed Deactivation Pdp : %s', perfdatas => [ - { label => 'completed_deactivation_pdp', value => 'ggsnCompletedDeactivation_absolute', template => '%s', min => 0 }, + { label => 'completed_deactivation_pdp', template => '%s', min => 0 }, ], } }, @@ -168,7 +166,7 @@ sub set_counters { key_values => [ { name => 'ggsnCompletedSelfDeactivation', diff => 1 } ], output_template => 'Completed Self Deactivation Pdp : %s', perfdatas => [ - { label => 'completed_self_deactivation_pdp', value => 'ggsnCompletedSelfDeactivation_absolute', template => '%s', min => 0 }, + { label => 'completed_self_deactivation_pdp', emplate => '%s', min => 0 }, ], } }, @@ -176,7 +174,7 @@ sub set_counters { key_values => [ { name => 'ggsnCompletedUpdate', diff => 1 } ], output_template => 'Completed Update Pdp : %s', perfdatas => [ - { label => 'completed_update_pdp', value => 'ggsnCompletedUpdate_absolute', template => '%s', min => 0 }, + { label => 'completed_update_pdp', template => '%s', min => 0 }, ], } }, diff --git a/network/juniper/trapeze/snmp/mode/apstatus.pm b/network/juniper/trapeze/snmp/mode/apstatus.pm index d528e3717..378158ba4 100644 --- a/network/juniper/trapeze/snmp/mode/apstatus.pm +++ b/network/juniper/trapeze/snmp/mode/apstatus.pm @@ -58,7 +58,7 @@ sub set_counters { key_values => [ { name => 'total' } ], output_template => 'Total ap : %s', perfdatas => [ - { label => 'total', value => 'total_absolute', template => '%s', + { label => 'total', value => 'total', template => '%s', min => 0 }, ], } diff --git a/network/juniper/trapeze/snmp/mode/apusers.pm b/network/juniper/trapeze/snmp/mode/apusers.pm index 8f0b0ed85..10245b263 100644 --- a/network/juniper/trapeze/snmp/mode/apusers.pm +++ b/network/juniper/trapeze/snmp/mode/apusers.pm @@ -39,7 +39,7 @@ sub set_counters { key_values => [ { name => 'total' } ], output_template => 'Total Users : %s', perfdatas => [ - { label => 'total', value => 'total_absolute', template => '%s', + { label => 'total', value => 'total', template => '%s', unit => 'users', min => 0 }, ], } @@ -51,8 +51,8 @@ sub set_counters { key_values => [ { name => 'total' }, { name => 'display' } ], output_template => 'users : %s', perfdatas => [ - { label => 'ssid', value => 'total_absolute', template => '%s', - unit => 'users', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'ssid', value => 'total', template => '%s', + unit => 'users', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -63,8 +63,8 @@ sub set_counters { key_values => [ { name => 'total' }, { name => 'display' } ], output_template => 'users : %s', perfdatas => [ - { label => 'ap', value => 'total_absolute', template => '%s', - unit => 'users', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'ap', value => 'total', template => '%s', + unit => 'users', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/network/juniper/trapeze/snmp/mode/cpu.pm b/network/juniper/trapeze/snmp/mode/cpu.pm index bf65b9dc6..255a26e1a 100644 --- a/network/juniper/trapeze/snmp/mode/cpu.pm +++ b/network/juniper/trapeze/snmp/mode/cpu.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'trpzSysCpuAverageLoad' } ], output_template => 'average : %.2f %%', perfdatas => [ - { label => 'cpu_average', value => 'trpzSysCpuAverageLoad_absolute', template => '%.2f', + { label => 'cpu_average', value => 'trpzSysCpuAverageLoad', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'trpzSysCpuLastMinuteLoad' } ], output_template => '1 minute : %.2f %%', perfdatas => [ - { label => 'cpu_1m', value => 'trpzSysCpuLastMinuteLoad_absolute', template => '%.2f', + { label => 'cpu_1m', value => 'trpzSysCpuLastMinuteLoad', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } @@ -55,7 +55,7 @@ sub set_counters { key_values => [ { name => 'trpzSysCpuLast5MinutesLoad' } ], output_template => '5 minutes : %.2f %%', perfdatas => [ - { label => 'cpu_5m', value => 'trpzSysCpuLast5MinutesLoad_absolute', template => '%.2f', + { label => 'cpu_5m', value => 'trpzSysCpuLast5MinutesLoad', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } @@ -64,7 +64,7 @@ sub set_counters { key_values => [ { name => ' trpzSysCpuLastHourLoad' } ], output_template => '1 hour : %.2f %%', perfdatas => [ - { label => 'cpu_1h', value => ' trpzSysCpuLastHourLoad_absolute', template => '%.2f', + { label => 'cpu_1h', value => ' trpzSysCpuLastHourLoad', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } diff --git a/network/juniper/trapeze/snmp/mode/memory.pm b/network/juniper/trapeze/snmp/mode/memory.pm index f9ec9c328..f824b74b0 100644 --- a/network/juniper/trapeze/snmp/mode/memory.pm +++ b/network/juniper/trapeze/snmp/mode/memory.pm @@ -28,14 +28,14 @@ use warnings; sub custom_usage_output { my ($self, %options) = @_; - my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_absolute}); - my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_absolute}); - my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute}); + my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}); + my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}); + my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}); my $msg = sprintf("Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", $total_size_value . " " . $total_size_unit, - $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used_absolute}, - $total_free_value . " " . $total_free_unit, 100 - $self->{result_values}->{prct_used_absolute}); + $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used}, + $total_free_value . " " . $total_free_unit, 100 - $self->{result_values}->{prct_used}); return $msg; } @@ -51,10 +51,10 @@ sub set_counters { { label => 'memory', set => { key_values => [ { name => 'prct_used'}, { name => 'used' }, { name => 'free' }, { name => 'total' } ], closure_custom_output => $self->can('custom_usage_output'), - threshold_use => 'prct_used_absolute', + threshold_use => 'prct_used', perfdatas => [ - { label => 'memory', value => 'used_absolute', template => '%.2f', threshold_total => 'total_absolute', cast_int => 1, - min => 0, max => 'total_absolute', unit => 'B' }, + { label => 'memory', value => 'used', template => '%.2f', threshold_total => 'total', cast_int => 1, + min => 0, max => 'total', unit => 'B' }, ], } }, @@ -63,10 +63,10 @@ sub set_counters { { label => 'flash', set => { key_values => [ { name => 'prct_used' }, { name => 'used' }, { name => 'free' }, { name => 'total' } ], closure_custom_output => $self->can('custom_usage_output'), - threshold_use => 'prct_used_absolute', + threshold_use => 'prct_used', perfdatas => [ - { label => 'flash', value => 'used_absolute', template => '%.2f', threshold_total => 'total_absolute', cast_int => 1, - min => 0, max => 'total_absolute', unit => 'B' }, + { label => 'flash', value => 'used', template => '%.2f', threshold_total => 'total', cast_int => 1, + min => 0, max => 'total', unit => 'B' }, ], } }, diff --git a/network/kemp/snmp/mode/rsstatus.pm b/network/kemp/snmp/mode/rsstatus.pm index 934ac0dbb..dba4ec7c8 100644 --- a/network/kemp/snmp/mode/rsstatus.pm +++ b/network/kemp/snmp/mode/rsstatus.pm @@ -62,28 +62,25 @@ sub set_counters { key_values => [ { name => 'rSActiveConns' }, { name => 'display' } ], output_template => 'Active connections : %s', perfdatas => [ - { label => 'active', value => 'rSActiveConns_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'active', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'in-traffic', set => { - key_values => [ { name => 'rSInBytes', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'rSInBytes', per_second => 1 }, { name => 'display' } ], output_template => 'Traffic In : %s %s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_in', value => 'rSInBytes_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_in', template => '%.2f', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'out-traffic', set => { - key_values => [ { name => 'rSOutBytes', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'rSOutBytes', per_second => 1 }, { name => 'display' } ], output_template => 'Traffic Out : %s %s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_out', value => 'rSOutBytes_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_out', template => '%.2f', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -95,13 +92,12 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - "warning-status:s" => { name => 'warning_status', default => '' }, - "critical-status:s" => { name => 'critical_status', default => '%{status} !~ /inService|disabled/i' }, - }); - + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '%{status} !~ /inService|disabled/i' } + }); + return $self; } diff --git a/network/kemp/snmp/mode/vsstatus.pm b/network/kemp/snmp/mode/vsstatus.pm index 700f6c9a6..295fc3a63 100644 --- a/network/kemp/snmp/mode/vsstatus.pm +++ b/network/kemp/snmp/mode/vsstatus.pm @@ -62,31 +62,28 @@ sub set_counters { key_values => [ { name => 'vSActivConns' }, { name => 'display' } ], output_template => 'Active connections : %s', perfdatas => [ - { label => 'active', value => 'vSActivConns_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'active', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'in-traffic', set => { - key_values => [ { name => 'vSInBytes', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'vSInBytes', per_second => 1 }, { name => 'display' } ], output_template => 'Traffic In : %s %s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_in', value => 'vSInBytes_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_in', template => '%.2f', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'out-traffic', set => { - key_values => [ { name => 'vSOutBytes', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'vSOutBytes', per_second => 1 }, { name => 'display' } ], output_template => 'Traffic Out : %s %s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_out', value => 'vSOutBytes_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, - ], + { label => 'traffic_out', template => '%.2f', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, + ] } - }, + } ]; } @@ -95,13 +92,12 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - "warning-status:s" => { name => 'warning_status', default => '' }, - "critical-status:s" => { name => 'critical_status', default => '%{status} !~ /inService|disabled|redirect/i' }, - }); - + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '%{status} !~ /inService|disabled|redirect/i' } + }); + return $self; } diff --git a/network/lenovo/flexsystem/snmp/mode/cpu.pm b/network/lenovo/flexsystem/snmp/mode/cpu.pm index 869d1bdb6..79312b7b6 100644 --- a/network/lenovo/flexsystem/snmp/mode/cpu.pm +++ b/network/lenovo/flexsystem/snmp/mode/cpu.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'average_1m' }, { name => 'display' } ], output_template => '%.2f %% (1m)', perfdatas => [ - { value => 'average_1m_absolute', template => '%.2f', + { value => 'average_1m', template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 } ] } @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'average_5m' }, { name => 'display' } ], output_template => '%.2f %% (5m)', perfdatas => [ - { value => 'average_5m_absolute', template => '%.2f', + { value => 'average_5m', template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 } ] } diff --git a/network/lenovo/flexsystem/snmp/mode/memory.pm b/network/lenovo/flexsystem/snmp/mode/memory.pm index aeddb4205..73afad8a7 100644 --- a/network/lenovo/flexsystem/snmp/mode/memory.pm +++ b/network/lenovo/flexsystem/snmp/mode/memory.pm @@ -30,11 +30,11 @@ sub custom_usage_output { return sprintf( 'Ram Total: %s %s Used: %s %s (%.2f%%) Free: %s %s (%.2f%%)', - $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_absolute}), - $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_absolute}), - $self->{result_values}->{prct_used_absolute}, - $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute}), - $self->{result_values}->{prct_free_absolute} + $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}), + $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}), + $self->{result_values}->{prct_used}, + $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}), + $self->{result_values}->{prct_free} ); } @@ -50,7 +50,7 @@ sub set_counters { key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'display' } ], closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ - { value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute', + { value => 'used', template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1, label_extra_instance => 1 } ] } @@ -59,7 +59,7 @@ sub set_counters { key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'display' } ], closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ - { value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute', + { value => 'free', template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1, label_extra_instance => 1 } ] } @@ -68,7 +68,7 @@ sub set_counters { key_values => [ { name => 'prct_used' }, { name => 'display' } ], output_template => 'Ram Used : %.2f %%', perfdatas => [ - { value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, + { value => 'prct_used', template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 } ] } diff --git a/network/libraesva/snmp/mode/system.pm b/network/libraesva/snmp/mode/system.pm index 6f9d5a58c..34a7b57a5 100644 --- a/network/libraesva/snmp/mode/system.pm +++ b/network/libraesva/snmp/mode/system.pm @@ -45,7 +45,7 @@ sub set_counters { key_values => [ { name => 'mailSent', diff => 1 } ], output_template => 'mails sent: %s', perfdatas => [ - { value => 'mailSent_absolute', template => '%s', min => 0 }, + { value => 'mailSent', template => '%s', min => 0 }, ], } }, @@ -53,7 +53,7 @@ sub set_counters { key_values => [ { name => 'mailReceived', diff => 1 } ], output_template => 'mails received: %s', perfdatas => [ - { value => 'mailReceived_absolute', template => '%s', min => 0 }, + { value => 'mailReceived', template => '%s', min => 0 }, ], } }, @@ -61,7 +61,7 @@ sub set_counters { key_values => [ { name => 'mailRejected', diff => 1 } ], output_template => 'mails rejected: %s', perfdatas => [ - { value => 'mailRejected_absolute', template => '%s', min => 0 }, + { value => 'mailRejected', template => '%s', min => 0 }, ], } }, @@ -69,7 +69,7 @@ sub set_counters { key_values => [ { name => 'mailBounced', diff => 1 } ], output_template => 'mails bounced: %s', perfdatas => [ - { value => 'mailBounced_absolute', template => '%s', min => 0 }, + { value => 'mailBounced', template => '%s', min => 0 }, ], } }, @@ -77,7 +77,7 @@ sub set_counters { key_values => [ { name => 'spamMessages', diff => 1 } ], output_template => 'spam messages: %s', perfdatas => [ - { value => 'spamMessages_absolute', template => '%s', min => 0 }, + { value => 'spamMessages', template => '%s', min => 0 }, ], } }, @@ -85,7 +85,7 @@ sub set_counters { key_values => [ { name => 'virusMessages', diff => 1 } ], output_template => 'virus messages: %s', perfdatas => [ - { value => 'virusMessages_absolute', template => '%s', min => 0 }, + { value => 'virusMessages', template => '%s', min => 0 }, ], } }, @@ -93,7 +93,7 @@ sub set_counters { key_values => [ { name => 'incomingMailQueue' } ], output_template => 'mails queue in: %s', perfdatas => [ - { value => 'incomingMailQueue_absolute', template => '%s', min => 0 }, + { value => 'incomingMailQueue', template => '%s', min => 0 }, ], } }, @@ -101,7 +101,7 @@ sub set_counters { key_values => [ { name => 'outgoingMailQueue' } ], output_template => 'mails queue out: %s', perfdatas => [ - { value => 'outgoingMailQueue_absolute', template => '%s', min => 0 }, + { value => 'outgoingMailQueue', template => '%s', min => 0 }, ], } }, diff --git a/network/mikrotik/snmp/mode/signal.pm b/network/mikrotik/snmp/mode/signal.pm index ec02d07da..4c5922087 100644 --- a/network/mikrotik/snmp/mode/signal.pm +++ b/network/mikrotik/snmp/mode/signal.pm @@ -37,8 +37,8 @@ sub set_counters { key_values => [ { name => 'mtxrWlRtabStrength' }, { name => 'display' } ], output_template => 'signal strength Rx: %s dBm', perfdatas => [ - { label => 'signal_rx', value => 'mtxrWlRtabStrength_absolute', template => '%s', unit => 'dBm', - label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'signal_rx', value => 'mtxrWlRtabStrength', template => '%s', unit => 'dBm', + label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -46,8 +46,8 @@ sub set_counters { key_values => [ { name => 'mtxrWlRtabTxStrength' }, { name => 'display' } ], output_template => 'signal strength Tx: %s dBm', perfdatas => [ - { label => 'signal_tx', value => 'mtxrWlRtabTxStrength_absolute', template => '%s', unit => 'dBm', - label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'signal_tx', value => 'mtxrWlRtabTxStrength', template => '%s', unit => 'dBm', + label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -55,8 +55,8 @@ sub set_counters { key_values => [ { name => 'mtxrWlRtabSignalToNoise', no_value => 0 }, { name => 'display' } ], output_template => 'signal to noise: %s dB', perfdatas => [ - { label => 'signal_noise', value => 'mtxrWlRtabSignalToNoise_absolute', template => '%s', unit => 'dB', - label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'signal_noise', value => 'mtxrWlRtabSignalToNoise', template => '%s', unit => 'dB', + label_extra_instance => 1, instance_use => 'display' }, ], } } diff --git a/network/mitel/3300icp/snmp/mode/zapcalls.pm b/network/mitel/3300icp/snmp/mode/zapcalls.pm index aaab7b4d5..c58a7913d 100644 --- a/network/mitel/3300icp/snmp/mode/zapcalls.pm +++ b/network/mitel/3300icp/snmp/mode/zapcalls.pm @@ -38,8 +38,8 @@ sub set_counters { key_values => [ { name => 'mitelBWMCumCACAdmissions', diff => 1 }, { name => 'display' } ], output_template => 'Admitted calls: %s', perfdatas => [ - { label => 'admitted', value => 'mitelBWMCumCACAdmissions_absolute', template => '%s', - min => 0, unit => 'calls', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'admitted', value => 'mitelBWMCumCACAdmissions', template => '%s', + min => 0, unit => 'calls', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -47,8 +47,8 @@ sub set_counters { key_values => [ { name => 'mitelBWMCumCACRejections', diff => 1 }, { name => 'display' } ], output_template => 'Rejected calls: %s', perfdatas => [ - { label => 'rejected', value => 'mitelBWMCumCACRejections_absolute', template => '%s', - min => 0, unit => 'calls', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'rejected', value => 'mitelBWMCumCACRejections', template => '%s', + min => 0, unit => 'calls', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -56,8 +56,8 @@ sub set_counters { key_values => [ { name => 'mitelBWMCumCACRejectionRatio' }, { name => 'display' } ], output_template => 'Rejection ratio: %s%%', perfdatas => [ - { label => 'rejection_ratio', value => 'mitelBWMCumCACRejectionRatio_absolute', template => '%s', - min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'rejection_ratio', value => 'mitelBWMCumCACRejectionRatio', template => '%s', + min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/network/moxa/switch/snmp/mode/cpu.pm b/network/moxa/switch/snmp/mode/cpu.pm index a947d11e8..05ca0e741 100644 --- a/network/moxa/switch/snmp/mode/cpu.pm +++ b/network/moxa/switch/snmp/mode/cpu.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'cpuLoading5s' } ], output_template => '5 seconds : %.2f %%', perfdatas => [ - { label => 'cpu_5s', value => 'cpuLoading5s_absolute', template => '%.2f', + { label => 'cpu_5s', value => 'cpuLoading5s', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'cpuLoading30s' } ], output_template => '30 seconds : %.2f %%', perfdatas => [ - { label => 'cpu_30s', value => 'cpuLoading30s_absolute', template => '%.2f', + { label => 'cpu_30s', value => 'cpuLoading30s', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } @@ -55,7 +55,7 @@ sub set_counters { key_values => [ { name => 'cpuLoading300s' } ], output_template => '300 seconds : %.2f %%', perfdatas => [ - { label => 'cpu_300s', value => 'cpuLoading300s_absolute', template => '%.2f', + { label => 'cpu_300s', value => 'cpuLoading300s', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } diff --git a/network/moxa/switch/snmp/mode/memory.pm b/network/moxa/switch/snmp/mode/memory.pm index 2aca2b174..d0354efc5 100644 --- a/network/moxa/switch/snmp/mode/memory.pm +++ b/network/moxa/switch/snmp/mode/memory.pm @@ -28,14 +28,14 @@ use warnings; sub custom_usage_output { my ($self, %options) = @_; - my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_absolute}); - my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_absolute}); - my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute}); + my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}); + my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}); + my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}); my $msg = sprintf("Memory Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", $total_size_value . " " . $total_size_unit, - $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used_absolute}, - $total_free_value . " " . $total_free_unit, 100 - $self->{result_values}->{prct_used_absolute}); + $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used}, + $total_free_value . " " . $total_free_unit, 100 - $self->{result_values}->{prct_used}); return $msg; } @@ -50,11 +50,11 @@ sub set_counters { { label => 'usage', set => { key_values => [ { name => 'used' }, { name => 'free' }, { name => 'total' }, { name => 'prct_used' } ], closure_custom_output => $self->can('custom_usage_output'), - threshold_use => 'prct_used_absolute', + threshold_use => 'prct_used', perfdatas => [ - { label => 'used', value => 'used_absolute', template => '%.2f', - threshold_total => 'total_absolute', cast_int => 1, - min => 0, max => 'total_absolute', unit => 'B' }, + { label => 'used', value => 'used', template => '%.2f', + threshold_total => 'total', cast_int => 1, + min => 0, max => 'total', unit => 'B' }, ], } }, diff --git a/network/mrv/optiswitch/snmp/mode/interfaces.pm b/network/mrv/optiswitch/snmp/mode/interfaces.pm index e49c9c1ef..f2cd1e64a 100644 --- a/network/mrv/optiswitch/snmp/mode/interfaces.pm +++ b/network/mrv/optiswitch/snmp/mode/interfaces.pm @@ -55,20 +55,20 @@ sub set_counters_global { { label => 'total-link-up', filter => 'add_global', nlabel => 'total.interfaces.link.up.count', set => { key_values => [ { name => 'global_link_up' }, { name => 'total_port' } ], output_template => 'LinkStatus Up : %s', output_error_template => 'LinkStatus Up : %s', - output_use => 'global_link_up_absolute', threshold_use => 'global_link_up_absolute', + output_use => 'global_link_up', threshold_use => 'global_link_up', perfdatas => [ - { label => 'total_link_up', value => 'global_link_up_absolute', template => '%s', - min => 0, max => 'total_port_absolute' }, + { label => 'total_link_up', value => 'global_link_up', template => '%s', + min => 0, max => 'total_port' }, ], } }, { label => 'total-link-down', filter => 'add_global', nlabel => 'total.interfaces.link.down.count', set => { key_values => [ { name => 'global_link_down' }, { name => 'total_port' } ], output_template => 'LinkStatus Down : %s', output_error_template => 'LinkStatus Down : %s', - output_use => 'global_link_down_absolute', threshold_use => 'global_link_down_absolute', + output_use => 'global_link_down', threshold_use => 'global_link_down', perfdatas => [ - { label => 'total_link_down', value => 'global_link_down_absolute', template => '%s', - min => 0, max => 'total_port_absolute' }, + { label => 'total_link_down', value => 'global_link_down', template => '%s', + min => 0, max => 'total_port' }, ], } }, diff --git a/network/netgear/mseries/snmp/mode/cpu.pm b/network/netgear/mseries/snmp/mode/cpu.pm index b496f1101..f31042cf2 100644 --- a/network/netgear/mseries/snmp/mode/cpu.pm +++ b/network/netgear/mseries/snmp/mode/cpu.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'usage_5s' } ], output_template => '%.2f %% (5sec)', output_error_template => "%s (5sec)", perfdatas => [ - { label => 'cpu_5s', value => 'usage_5s_absolute', template => '%.2f', + { label => 'cpu_5s', value => 'usage_5s', template => '%.2f', unit => '%', min => 0, max => 100 }, ], } @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'usage_1m' } ], output_template => '%.2f %% (1m)', output_error_template => "%s (1min)", perfdatas => [ - { label => 'cpu_1m', value => 'usage_1m_absolute', template => '%.2f', + { label => 'cpu_1m', value => 'usage_1m', template => '%.2f', unit => '%', min => 0, max => 100 }, ], } @@ -55,7 +55,7 @@ sub set_counters { key_values => [ { name => 'usage_5m' } ], output_template => '%.2f %% (5min)', output_error_template => "%s (5min)", perfdatas => [ - { label => 'cpu_5m', value => 'usage_5m_absolute', template => '%.2f', + { label => 'cpu_5m', value => 'usage_5m', template => '%.2f', unit => '%', min => 0, max => 100 }, ], } diff --git a/network/nokia/timos/snmp/mode/bgpusage.pm b/network/nokia/timos/snmp/mode/bgpusage.pm index 3c86b2053..6c2c6bedd 100644 --- a/network/nokia/timos/snmp/mode/bgpusage.pm +++ b/network/nokia/timos/snmp/mode/bgpusage.pm @@ -61,8 +61,8 @@ sub set_counters { key_values => [ { name => 'active_prefixes' }, { name => 'display' } ], output_template => 'Active Prefixes : %s', perfdatas => [ - { label => 'active_prefixes', value => 'active_prefixes_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'active_prefixes', value => 'active_prefixes', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -70,8 +70,8 @@ sub set_counters { key_values => [ { name => 'sent_prefixes', diff => 1 }, { name => 'display' } ], output_template => 'Sent Prefixes : %s', perfdatas => [ - { label => 'sent_prefixes', value => 'sent_prefixes_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'sent_prefixes', value => 'sent_prefixes', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -79,8 +79,8 @@ sub set_counters { key_values => [ { name => 'received_prefixes', diff => 1 }, { name => 'display' } ], output_template => 'Received Prefixes : %s', perfdatas => [ - { label => 'received_prefixes', value => 'received_prefixes_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'received_prefixes', value => 'received_prefixes', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/network/nokia/timos/snmp/mode/cpu.pm b/network/nokia/timos/snmp/mode/cpu.pm index c83cbf859..0c30c84d8 100644 --- a/network/nokia/timos/snmp/mode/cpu.pm +++ b/network/nokia/timos/snmp/mode/cpu.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'cpu' } ], output_template => 'Usage : %.2f %%', perfdatas => [ - { label => 'cpu', value => 'cpu_absolute', template => '%.2f', + { label => 'cpu', value => 'cpu', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } diff --git a/network/nokia/timos/snmp/mode/isisusage.pm b/network/nokia/timos/snmp/mode/isisusage.pm index 75c128648..845b6a584 100644 --- a/network/nokia/timos/snmp/mode/isisusage.pm +++ b/network/nokia/timos/snmp/mode/isisusage.pm @@ -87,8 +87,8 @@ sub set_counters { key_values => [ { name => 'inService' }, { name => 'display' } ], output_template => 'Total Interfaces InServices : %s', perfdatas => [ - { label => 'total_int_inservice', value => 'inService_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'total_int_inservice', value => 'inService', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -96,8 +96,8 @@ sub set_counters { key_values => [ { name => 'outOfService' }, { name => 'display' } ], output_template => 'Total Interfaces OutOfServices : %s', perfdatas => [ - { label => 'total_int_outservice', value => 'outOfService_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'total_int_outservice', value => 'outOfService', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/network/nokia/timos/snmp/mode/l2tpusage.pm b/network/nokia/timos/snmp/mode/l2tpusage.pm index 62c18b82b..9892a5abb 100644 --- a/network/nokia/timos/snmp/mode/l2tpusage.pm +++ b/network/nokia/timos/snmp/mode/l2tpusage.pm @@ -93,8 +93,8 @@ sub set_counters { key_values => [ { name => 'total_tunnel' }, { name => 'display' } ], output_template => 'Total : %s', perfdatas => [ - { label => 'vrtr_total_tunnel', value => 'total_tunnel_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'vrtr_total_tunnel', value => 'total_tunnel', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -102,8 +102,8 @@ sub set_counters { key_values => [ { name => 'active_sessions' }, { name => 'display' } ], output_template => 'Active Sessions : %s', perfdatas => [ - { label => 'vrtr_tunnel_active_sessions', value => 'active_sessions_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'vrtr_tunnel_active_sessions', value => 'active_sessions', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -115,7 +115,7 @@ sub set_counters { closure_custom_calc => $self->can('custom_total_sessions_calc'), perfdatas => [ { label => 'vrtr_tunnel_total_sessions', value => 'total_sessions', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -126,8 +126,8 @@ sub set_counters { key_values => [ { name => 'total_tunnel' }, { name => 'display' } ], output_template => 'Total : %s', perfdatas => [ - { label => 'peer_total_tunnel', value => 'total_tunnel_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'peer_total_tunnel', value => 'total_tunnel', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -135,8 +135,8 @@ sub set_counters { key_values => [ { name => 'active_sessions' }, { name => 'display' } ], output_template => 'Active Sessions : %s', perfdatas => [ - { label => 'peer_tunnel_active_sessions', value => 'active_sessions_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'peer_tunnel_active_sessions', value => 'active_sessions', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -148,7 +148,7 @@ sub set_counters { closure_custom_calc => $self->can('custom_total_sessions_calc'), perfdatas => [ { label => 'peer_tunnel_total_sessions', value => 'total_sessions', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/network/nokia/timos/snmp/mode/ldpusage.pm b/network/nokia/timos/snmp/mode/ldpusage.pm index f0baa3b1d..cea94cb98 100644 --- a/network/nokia/timos/snmp/mode/ldpusage.pm +++ b/network/nokia/timos/snmp/mode/ldpusage.pm @@ -63,8 +63,8 @@ sub set_counters { key_values => [ { name => 'ipv4_active_sessions' }, { name => 'display' } ], output_template => 'IPv4 Active Sessions : %s', perfdatas => [ - { label => 'ipv4_active_sessions', value => 'ipv4_active_sessions_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'ipv4_active_sessions', value => 'ipv4_active_sessions', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -72,8 +72,8 @@ sub set_counters { key_values => [ { name => 'ipv4_active_link_adj' }, { name => 'display' } ], output_template => 'IPv4 Active Link Adjacencies : %s', perfdatas => [ - { label => 'ipv4_active_link_adj', value => 'ipv4_active_link_adj_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'ipv4_active_link_adj', value => 'ipv4_active_link_adj', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -81,8 +81,8 @@ sub set_counters { key_values => [ { name => 'ipv4_active_target_adj' }, { name => 'display' } ], output_template => 'IPv4 Active Target Adjacencies : %s', perfdatas => [ - { label => 'ipv4_active_target_adj', value => 'ipv4_active_target_adj_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'ipv4_active_target_adj', value => 'ipv4_active_target_adj', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -90,8 +90,8 @@ sub set_counters { key_values => [ { name => 'ipv4_oper_down_events', diff => 1 }, { name => 'display' } ], output_template => 'IPv4 Oper Down Events : %s', perfdatas => [ - { label => 'ipv4_oper_down_events', value => 'ipv4_oper_down_events_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'ipv4_oper_down_events', value => 'ipv4_oper_down_events', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/network/nokia/timos/snmp/mode/sapusage.pm b/network/nokia/timos/snmp/mode/sapusage.pm index fb5287f5c..fac76b7de 100644 --- a/network/nokia/timos/snmp/mode/sapusage.pm +++ b/network/nokia/timos/snmp/mode/sapusage.pm @@ -56,46 +56,42 @@ sub set_counters { closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => \&catalog_status_threshold, + closure_custom_threshold_check => \&catalog_status_threshold } }, { label => 'traffic-in-below-cir', set => { - key_values => [ { name => 'sapBaseStatsIngressQchipForwardedInProfOctets', diff => 1 }, { name => 'display' } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'sapBaseStatsIngressQchipForwardedInProfOctets', per_second => 1 }, { name => 'display' } ], output_template => 'Traffic In Below CIR : %s %s/s', + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_in_below_cir', value => 'sapBaseStatsIngressQchipForwardedInProfOctets_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_in_below_cir', template => '%.2f', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'traffic-in-above-cir', set => { - key_values => [ { name => 'sapBaseStatsIngressQchipForwardedOutProfOctets', diff => 1 }, { name => 'display' } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'sapBaseStatsIngressQchipForwardedOutProfOctets', per_second => 1 }, { name => 'display' } ], output_template => 'Traffic In Above CIR : %s %s/s', + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_in_above_cir', value => 'sapBaseStatsIngressQchipForwardedOutProfOctets_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_in_above_cir', template => '%.2f', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'traffic-out-below-cir', set => { - key_values => [ { name => 'sapBaseStatsEgressQchipForwardedInProfOctets', diff => 1 }, { name => 'display' } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'sapBaseStatsEgressQchipForwardedInProfOctets', per_second => 1 }, { name => 'display' } ], output_template => 'Traffic Out Below CIR : %s %s/s', + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_out_below_cir', value => 'sapBaseStatsEgressQchipForwardedInProfOctets_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_out_below_cir', template => '%.2f', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'traffic-out-above-cir', set => { - key_values => [ { name => 'sapBaseStatsEgressQchipForwardedOutProfOctets', diff => 1 }, { name => 'display' } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'sapBaseStatsEgressQchipForwardedOutProfOctets', per_second => 1 }, { name => 'display' } ], output_template => 'Traffic Out Above CIR : %s %s/s', + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_out_above_cir', value => 'sapBaseStatsEgressQchipForwardedOutProfOctets_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_out_above_cir', template => '%.2f', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -113,12 +109,11 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - "warning-status:s" => { name => 'warning_status', default => '' }, - "critical-status:s" => { name => 'critical_status', default => '%{admin_state} eq "up" and %{oper_state} !~ /up/' }, - }); + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '%{admin_state} eq "up" and %{oper_state} !~ /up/' } + }); return $self; } diff --git a/network/nortel/standard/snmp/mode/cpu.pm b/network/nortel/standard/snmp/mode/cpu.pm index f95ef9523..709d2967c 100644 --- a/network/nortel/standard/snmp/mode/cpu.pm +++ b/network/nortel/standard/snmp/mode/cpu.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'total' }, { name => 'num' } ], output_template => '%.2f %% (total)', perfdatas => [ - { label => 'cpu_total', value => 'total_absolute', template => '%.2f', + { label => 'cpu_total', value => 'total', template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 } ] } @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => '1m' }, { name => 'num' } ], output_template => '%.2f %% (1min)', perfdatas => [ - { label => 'cpu_1min', value => '1m_absolute', template => '%.2f', + { label => 'cpu_1min', value => '1m', template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 } ] } @@ -55,7 +55,7 @@ sub set_counters { key_values => [ { name => '5m' }, { name => 'num' } ], output_template => '%.2f %% (5min)', perfdatas => [ - { label => 'cpu_5min', value => '5m_absolute', template => '%.2f', + { label => 'cpu_5min', value => '5m', template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 } ] } @@ -64,7 +64,7 @@ sub set_counters { key_values => [ { name => '10m' }, { name => 'num' } ], output_template => '%.2f %% (10min)', perfdatas => [ - { label => 'cpu_10min', value => '10m_absolute', template => '%.2f', + { label => 'cpu_10min', value => '10m', template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 } ] } @@ -73,7 +73,7 @@ sub set_counters { key_values => [ { name => '1h' }, { name => 'num' } ], output_template => '%.2f %% (1h)', perfdatas => [ - { label => 'cpu_1h', value => '1h_absolute', template => '%.2f', + { label => 'cpu_1h', value => '1h', template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 } ] } diff --git a/network/nortel/standard/snmp/mode/memory.pm b/network/nortel/standard/snmp/mode/memory.pm index 6a18a407b..2212cb51d 100644 --- a/network/nortel/standard/snmp/mode/memory.pm +++ b/network/nortel/standard/snmp/mode/memory.pm @@ -30,11 +30,11 @@ sub custom_usage_output { return sprintf( 'total: %s %s used: %s %s (%.2f%%) free: %s %s (%.2f%%)', - $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_absolute}), - $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_absolute}), - $self->{result_values}->{prct_used_absolute}, - $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute}), - $self->{result_values}->{prct_free_absolute} + $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}), + $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}), + $self->{result_values}->{prct_used}, + $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}), + $self->{result_values}->{prct_free} ); } @@ -50,7 +50,7 @@ sub set_counters { key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'display' } ], closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ - { value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute', + { value => 'used', template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1, label_extra_instance => 1 } ] } @@ -59,7 +59,7 @@ sub set_counters { key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'display' } ], closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ - { value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute', + { value => 'free', template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1, label_extra_instance => 1 } ] } @@ -68,7 +68,7 @@ sub set_counters { key_values => [ { name => 'prct_used' }, { name => 'display' } ], output_template => 'used: %.2f %%', perfdatas => [ - { value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, unit => '%', + { value => 'prct_used', template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 }, ] } diff --git a/network/oracle/infiniband/snmp/mode/infinibandusage.pm b/network/oracle/infiniband/snmp/mode/infinibandusage.pm index b89c2b840..bd9f812cb 100644 --- a/network/oracle/infiniband/snmp/mode/infinibandusage.pm +++ b/network/oracle/infiniband/snmp/mode/infinibandusage.pm @@ -40,55 +40,52 @@ sub set_counters { closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => $self->can('custom_status_threshold'), + closure_custom_threshold_check => $self->can('custom_status_threshold') } }, { label => 'in', set => { key_values => [ { name => 'in', diff => 1 }, { name => 'display' }, { name => 'speed_in' } ], - per_second => 1, closure_custom_calc => $self->can('custom_ib_calc'), closure_custom_calc_extra_options => { label_ref => 'in' }, closure_custom_output => $self->can('custom_ib_output'), closure_custom_perfdata => $self->can('custom_ib_perfdata'), - closure_custom_threshold_check => $self->can('custom_ib_threshold'), + closure_custom_threshold_check => $self->can('custom_ib_threshold') } }, { label => 'out', set => { key_values => [ { name => 'out', diff => 1 }, { name => 'display' }, { name => 'speed_out' } ], - per_second => 1, closure_custom_calc => $self->can('custom_ib_calc'), closure_custom_calc_extra_options => { label_ref => 'out' }, closure_custom_output => $self->can('custom_ib_output'), closure_custom_perfdata => $self->can('custom_ib_perfdata'), - closure_custom_threshold_check => $self->can('custom_ib_threshold'), + closure_custom_threshold_check => $self->can('custom_ib_threshold') } - }, + } ]; + $self->{maps_counters}->{ibgw} = [ { label => 'ibgw-status', threshold => 0, set => { key_values => [ { name => 'status' }, { name => 'display' } ], closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => $self->can('custom_status_threshold'), + closure_custom_threshold_check => $self->can('custom_status_threshold') } }, { label => 'in', set => { key_values => [ { name => 'in', diff => 1 }, { name => 'display' }, { name => 'speed_in' } ], - per_second => 1, closure_custom_calc => $self->can('custom_ib_calc'), closure_custom_calc_extra_options => { label_ref => 'in' }, closure_custom_output => $self->can('custom_ib_output'), closure_custom_perfdata => $self->can('custom_ib_perfdata'), - closure_custom_threshold_check => $self->can('custom_ib_threshold'), + closure_custom_threshold_check => $self->can('custom_ib_threshold') } }, { label => 'out', set => { key_values => [ { name => 'out', diff => 1 }, { name => 'display' }, { name => 'speed_out' } ], - per_second => 1, closure_custom_calc => $self->can('custom_ib_calc'), closure_custom_calc_extra_options => { label_ref => 'out' }, closure_custom_output => $self->can('custom_ib_output'), closure_custom_perfdata => $self->can('custom_ib_perfdata'), - closure_custom_threshold_check => $self->can('custom_ib_threshold'), + closure_custom_threshold_check => $self->can('custom_ib_threshold') } - }, + } ]; } @@ -213,15 +210,15 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - "filter-ib-name:s" => { name => 'filter_ib_name' }, - "filter-ibgw-name:s" => { name => 'filter_ibgw_name' }, - "warning-ib-status:s" => { name => 'warning_ib_status', default => '' }, - "critical-ib-status:s" => { name => 'critical_ib_status', default => '%{status} !~ /active/i' }, - "warning-ibgw-status:s" => { name => 'warning_ibgw_status', default => '' }, - "critical-ibgw-status:s" => { name => 'critical_ibgw_status', default => '%{status} !~ /up/i' }, - "speed-in:s" => { name => 'speed_in' }, - "speed-out:s" => { name => 'speed_out' }, - "units-traffic:s" => { name => 'units_traffic', default => '%' }, + 'filter-ib-name:s' => { name => 'filter_ib_name' }, + 'filter-ibgw-name:s' => { name => 'filter_ibgw_name' }, + 'warning-ib-status:s' => { name => 'warning_ib_status', default => '' }, + 'critical-ib-status:s' => { name => 'critical_ib_status', default => '%{status} !~ /active/i' }, + 'warning-ibgw-status:s' => { name => 'warning_ibgw_status', default => '' }, + 'critical-ibgw-status:s' => { name => 'critical_ibgw_status', default => '%{status} !~ /up/i' }, + 'speed-in:s' => { name => 'speed_in' }, + 'speed-out:s' => { name => 'speed_out' }, + 'units-traffic:s' => { name => 'units_traffic', default => '%' } }); return $self; diff --git a/network/oracle/otd/snmp/mode/vserverusage.pm b/network/oracle/otd/snmp/mode/vserverusage.pm index 0d60193ad..d3cde0645 100644 --- a/network/oracle/otd/snmp/mode/vserverusage.pm +++ b/network/oracle/otd/snmp/mode/vserverusage.pm @@ -35,22 +35,20 @@ sub set_counters { $self->{maps_counters}->{vs} = [ { label => 'in', set => { - key_values => [ { name => 'vsInOctets', diff => 1 }, { name => 'display' } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'vsInOctets', per_second => 1 }, { name => 'display' } ], output_template => 'Traffic In: %s %s/s', + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_in', value => 'vsInOctets_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_in', template => '%.2f', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'out', set => { - key_values => [ { name => 'vsOutOctets', diff => 1 }, { name => 'display' } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'vsOutOctets', per_second => 1 }, { name => 'display' } ], output_template => 'Traffic Out: %s %s/s', + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_out', value => 'vsOutOctets_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_out', template => '%.2f', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } } @@ -67,9 +65,8 @@ sub set_counters { key_values => [ { name => $map[$i + 2], diff => 1 }, { name => 'display' } ], output_template => $map[$i + 1], perfdatas => [ - { label => $map[$i + 3], value => $map[$i + 2] . '_absolute', template => '%s', min => 0, - label_extra_instance => 1, instance_use => 'display_absolute' }, - ], + { label => $map[$i + 3], template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' } + ] } }; } @@ -80,11 +77,10 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - }); - + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' } + }); + return $self; } diff --git a/network/paloalto/snmp/mode/cpu.pm b/network/paloalto/snmp/mode/cpu.pm index 099755cf4..022844703 100644 --- a/network/paloalto/snmp/mode/cpu.pm +++ b/network/paloalto/snmp/mode/cpu.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'managementplane' } ], output_template => 'management plane usage is: %.2f %%', perfdatas => [ - { value => 'managementplane_absolute', template => '%.2f', + { value => 'managementplane', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'dataplane' } ], output_template => 'dataplane usage is: %.2f %%', perfdatas => [ - { value => 'dataplane_absolute', template => '%.2f', + { value => 'dataplane', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } diff --git a/network/paloalto/snmp/mode/gpusage.pm b/network/paloalto/snmp/mode/gpusage.pm index f89c5496d..dd377ca1d 100644 --- a/network/paloalto/snmp/mode/gpusage.pm +++ b/network/paloalto/snmp/mode/gpusage.pm @@ -29,11 +29,11 @@ sub custom_tunnel_output { my ($self, %options) = @_; my $msg = sprintf("tunnels total: %s used: %s (%.2f%%) free: %s (%.2f%%)", - $self->{result_values}->{total_absolute}, - $self->{result_values}->{used_absolute}, - $self->{result_values}->{prct_used_absolute}, - $self->{result_values}->{free_absolute}, - $self->{result_values}->{prct_free_absolute} + $self->{result_values}->{total}, + $self->{result_values}->{used}, + $self->{result_values}->{prct_used}, + $self->{result_values}->{free}, + $self->{result_values}->{prct_free} ); return $msg; } @@ -50,7 +50,7 @@ sub set_counters { key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], closure_custom_output => $self->can('custom_tunnel_output'), perfdatas => [ - { value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute', + { value => 'used', template => '%d', min => 0, max => 'total', cast_int => 1 }, ], } @@ -59,7 +59,7 @@ sub set_counters { key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], closure_custom_output => $self->can('custom_tunnel_output'), perfdatas => [ - { value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute', + { value => 'free', template => '%d', min => 0, max => 'total', cast_int => 1 }, ], } @@ -68,7 +68,7 @@ sub set_counters { key_values => [ { name => 'prct_used' } ], output_template => 'tunnels active used: %.2f %%', perfdatas => [ - { value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, unit => '%' }, + { value => 'prct_used', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } }, diff --git a/network/paloalto/snmp/mode/sessions.pm b/network/paloalto/snmp/mode/sessions.pm index 78567fd68..765336142 100644 --- a/network/paloalto/snmp/mode/sessions.pm +++ b/network/paloalto/snmp/mode/sessions.pm @@ -31,12 +31,12 @@ sub custom_vsys_active_perfdata { $self->{output}->perfdata_add( label => $self->{label}, nlabel => $self->{nlabel}, - instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display_absolute} : undef, - value => $self->{result_values}->{sessions_active_absolute}, + instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef, + value => $self->{result_values}->{sessions_active}, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}), min => 0, - max => $self->{result_values}->{sessions_max_absolute} != 0 ? $self->{result_values}->{sessions_max_absolute} : undef + max => $self->{result_values}->{sessions_max} != 0 ? $self->{result_values}->{sessions_max} : undef ); } @@ -46,11 +46,11 @@ sub custom_active_perfdata { $self->{output}->perfdata_add( label => $self->{label}, nlabel => $self->{nlabel}, - value => $self->{result_values}->{sessions_active_absolute}, + value => $self->{result_values}->{sessions_active}, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}), min => 0, - max => $self->{result_values}->{sessions_max_absolute} != 0 ? $self->{result_values}->{sessions_max_absolute} : undef + max => $self->{result_values}->{sessions_max} != 0 ? $self->{result_values}->{sessions_max} : undef ); } @@ -58,8 +58,8 @@ sub custom_active_output { my ($self, %options) = @_; return sprintf('active: %s (%s)', - $self->{result_values}->{sessions_active_absolute}, - $self->{result_values}->{sessions_max_absolute} != 0 ? $self->{result_values}->{sessions_max_absolute} : '-' + $self->{result_values}->{sessions_active}, + $self->{result_values}->{sessions_max} != 0 ? $self->{result_values}->{sessions_max} : '-' ); } @@ -81,7 +81,7 @@ sub set_counters { key_values => [ { name => 'sessions_active_prct' } ], output_template => 'active: %.2f %%', perfdatas => [ - { label => 'active_prct', value => 'sessions_active_prct_absolute', template => '%.2f', unit => '%', + { label => 'active_prct', value => 'sessions_active_prct', template => '%.2f', unit => '%', min => 0, max => 100 } ] } @@ -90,7 +90,7 @@ sub set_counters { key_values => [ { name => 'panSessionActiveTcp' } ], output_template => 'active TCP: %s', perfdatas => [ - { label => 'active_tcp', value => 'panSessionActiveTcp_absolute', template => '%s', min => 0 } + { label => 'active_tcp', value => 'panSessionActiveTcp', template => '%s', min => 0 } ] } }, @@ -98,7 +98,7 @@ sub set_counters { key_values => [ { name => 'panSessionActiveUdp' } ], output_template => 'active UDP: %s', perfdatas => [ - { label => 'active_udp', value => 'panSessionActiveUdp_absolute', template => '%s', min => 0 } + { label => 'active_udp', value => 'panSessionActiveUdp', template => '%s', min => 0 } ] } }, @@ -106,7 +106,7 @@ sub set_counters { key_values => [ { name => 'panSessionActiveICMP' } ], output_template => 'active ICMP: %s', perfdatas => [ - { label => 'active_icmp', value => 'panSessionActiveICMP_absolute', template => '%s', min => 0 } + { label => 'active_icmp', value => 'panSessionActiveICMP', template => '%s', min => 0 } ] } } @@ -123,7 +123,7 @@ sub set_counters { key_values => [ { name => 'sessions_active_prct' } ], output_template => 'active: %.2f %%', perfdatas => [ - { label => 'active_prct', value => 'sessions_active_prct_absolute', template => '%.2f', unit => '%', + { label => 'active_prct', value => 'sessions_active_prct', template => '%.2f', unit => '%', min => 0, max => 100 } ] } @@ -132,7 +132,7 @@ sub set_counters { key_values => [ { name => 'panVsysActiveTcpCps' }, { name => 'display' } ], output_template => 'active TCP: %s', perfdatas => [ - { label => 'active_tcp', value => 'panVsysActiveTcpCps_absolute', template => '%s', + { label => 'active_tcp', value => 'panVsysActiveTcpCps', template => '%s', label_extra_instance => 1, min => 0 } ] } @@ -141,7 +141,7 @@ sub set_counters { key_values => [ { name => 'panVsysActiveUdpCps' }, { name => 'display' } ], output_template => 'active UDP: %s', perfdatas => [ - { label => 'active_udp', value => 'panVsysActiveUdpCps_absolute', template => '%s', + { label => 'active_udp', value => 'panVsysActiveUdpCps', template => '%s', label_extra_instance => 1, min => 0 } ] } @@ -150,7 +150,7 @@ sub set_counters { key_values => [ { name => 'panVsysActiveOtherIpCps' }, { name => 'display' } ], output_template => 'other: %s', perfdatas => [ - { label => 'active_other', value => 'panVsysActiveOtherIpCps_absolute', template => '%s', + { label => 'active_other', value => 'panVsysActiveOtherIpCps', template => '%s', label_extra_instance => 1, min => 0 } ] } diff --git a/network/paloalto/ssh/mode/interfaces.pm b/network/paloalto/ssh/mode/interfaces.pm index ac4d8e96d..ccb778615 100644 --- a/network/paloalto/ssh/mode/interfaces.pm +++ b/network/paloalto/ssh/mode/interfaces.pm @@ -51,7 +51,7 @@ sub set_counters { key_values => [ { name => 'total' } ], output_template => 'total interfaces: %s', perfdatas => [ - { value => 'total_absolute', template => '%s', min => 0 } + { value => 'total', template => '%s', min => 0 } ] } }, diff --git a/network/paloalto/ssh/mode/ipsec.pm b/network/paloalto/ssh/mode/ipsec.pm index f1d752066..7ee5be6ed 100644 --- a/network/paloalto/ssh/mode/ipsec.pm +++ b/network/paloalto/ssh/mode/ipsec.pm @@ -51,7 +51,7 @@ sub set_counters { key_values => [ { name => 'total_ipsec' } ], output_template => 'total ipsec tunnels: %s', perfdatas => [ - { value => 'total_ipsec_absolute', template => '%s', min => 0 } + { value => 'total_ipsec', template => '%s', min => 0 } ] } } diff --git a/network/paloalto/ssh/mode/system.pm b/network/paloalto/ssh/mode/system.pm index 2cc828ac1..c56426064 100644 --- a/network/paloalto/ssh/mode/system.pm +++ b/network/paloalto/ssh/mode/system.pm @@ -41,8 +41,8 @@ sub custom_av_output { return sprintf( "antivirus version '%s', last update %s", - $self->{result_values}->{av_version_absolute}, - centreon::plugins::misc::change_seconds(value => $self->{result_values}->{av_lastupdate_time_absolute}) + $self->{result_values}->{av_version}, + centreon::plugins::misc::change_seconds(value => $self->{result_values}->{av_lastupdate_time}) ); } @@ -51,8 +51,8 @@ sub custom_threat_output { return sprintf( "threat version '%s', last update %s", - $self->{result_values}->{threat_version_absolute}, - centreon::plugins::misc::change_seconds(value => $self->{result_values}->{threat_lastupdate_time_absolute}) + $self->{result_values}->{threat_version}, + centreon::plugins::misc::change_seconds(value => $self->{result_values}->{threat_lastupdate_time}) ); } @@ -76,7 +76,7 @@ sub set_counters { key_values => [ { name => 'av_lastupdate_time' }, { name => 'av_version' } ], closure_custom_output => $self->can('custom_av_output'), perfdatas => [ - { value => 'av_lastupdate_time_absolute', template => '%d', min => 0, unit => 's' } + { value => 'av_lastupdate_time', template => '%d', min => 0, unit => 's' } ], } }, @@ -84,7 +84,7 @@ sub set_counters { key_values => [ { name => 'threat_lastupdate_time' }, { name => 'threat_version' } ], closure_custom_output => $self->can('custom_threat_output'), perfdatas => [ - { value => 'threat_lastupdate_time_absolute', template => '%d', min => 0, unit => 's' } + { value => 'threat_lastupdate_time', template => '%d', min => 0, unit => 's' } ], } }, @@ -93,7 +93,7 @@ sub set_counters { output_template => 'session traffic: %s %s/s', output_change_bytes => 2, perfdatas => [ - { value => 'throughput_absolute', template => '%s', + { value => 'throughput', template => '%s', unit => 'b/s', min => 0 }, ], } @@ -102,7 +102,7 @@ sub set_counters { key_values => [ { name => 'active_sessions' } ], output_template => 'total active sessions: %s', perfdatas => [ - { value => 'active_sessions_absolute', template => '%s', min => 0 }, + { value => 'active_sessions', template => '%s', min => 0 }, ], } }, diff --git a/network/peplink/pepwave/snmp/mode/cpu.pm b/network/peplink/pepwave/snmp/mode/cpu.pm index 3723db46b..002e6b9b1 100644 --- a/network/peplink/pepwave/snmp/mode/cpu.pm +++ b/network/peplink/pepwave/snmp/mode/cpu.pm @@ -36,7 +36,7 @@ sub set_counters { key_values => [ { name => 'cpu_load' } ], output_template => 'CPU Load %.2f %%', perfdatas => [ - { label => 'cpu_load', value => 'cpu_load_absolute', template => '%.2f', min => 0, max => 100, unit => '%' }, + { label => 'cpu_load', value => 'cpu_load', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } }, diff --git a/network/peplink/pepwave/snmp/mode/wanusage.pm b/network/peplink/pepwave/snmp/mode/wanusage.pm index 74ad3d5cf..934c3d7f4 100644 --- a/network/peplink/pepwave/snmp/mode/wanusage.pm +++ b/network/peplink/pepwave/snmp/mode/wanusage.pm @@ -62,31 +62,28 @@ sub set_counters { key_values => [ { name => 'signal' }, { name => 'display' } ], output_template => 'Signal Strength : %s dBm', perfdatas => [ - { label => 'signal', value => 'signal_absolute', template => '%s', unit => 'dBm', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'signal', template => '%s', unit => 'dBm', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'traffic-in', set => { - key_values => [ { name => 'traffic_in', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'traffic_in', per_second => 1 }, { name => 'display' } ], output_template => 'Traffic In : %s %s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_in', value => 'traffic_in_per_second', template => '%d', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_in', template => '%d', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'traffic-out', set => { - key_values => [ { name => 'traffic_out', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'traffic_out', per_second => 1 }, { name => 'display' } ], output_template => 'Traffic Out : %s %s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_out', value => 'traffic_out_per_second', template => '%d', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_out', template => '%d', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } - }, + } ]; } @@ -100,13 +97,13 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; - + $options{options}->add_options(arguments => { - "filter-name:s" => { name => 'filter_name' }, - "warning-health-status:s" => { name => 'warning_health_status', default => '' }, - "critical-health-status:s" => { name => 'critical_health_status', default => '%{health_status} =~ /fail/' }, + 'filter-name:s' => { name => 'filter_name' }, + 'warning-health-status:s' => { name => 'warning_health_status', default => '' }, + 'critical-health-status:s' => { name => 'critical_health_status', default => '%{health_status} =~ /fail/' } }); - + return $self; } diff --git a/network/perle/ids/snmp/mode/systemusage.pm b/network/perle/ids/snmp/mode/systemusage.pm index 9f05bd422..9cdfc1c26 100644 --- a/network/perle/ids/snmp/mode/systemusage.pm +++ b/network/perle/ids/snmp/mode/systemusage.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'cpu_load' } ], output_template => 'cpu load : %.2f %%', perfdatas => [ - { value => 'cpu_load_absolute', template => '%.2f', + { value => 'cpu_load', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } @@ -47,7 +47,7 @@ sub set_counters { output_template => 'memory free : %s %s', output_change_bytes => 1, perfdatas => [ - { value => 'memory_free_absolute', template => '%d', + { value => 'memory_free', template => '%d', min => 0, unit => 'B' }, ], } @@ -57,7 +57,7 @@ sub set_counters { output_template => 'flash disk free : %s %s', output_change_bytes => 1, perfdatas => [ - { value => 'flashdisk_free_absolute', template => '%d', + { value => 'flashdisk_free', template => '%d', min => 0, unit => 'B' }, ], } diff --git a/network/polycom/rmx/snmp/mode/videoconferencingusage.pm b/network/polycom/rmx/snmp/mode/videoconferencingusage.pm index 10b79dc86..88317e5b7 100644 --- a/network/polycom/rmx/snmp/mode/videoconferencingusage.pm +++ b/network/polycom/rmx/snmp/mode/videoconferencingusage.pm @@ -36,7 +36,7 @@ sub set_counters { key_values => [ { name => 'NewCallsLastMinTotal' } ], output_template => 'New Calls : %s (last min)', perfdatas => [ - { label => 'calls_new', value => 'NewCallsLastMinTotal_absolute', template => '%d', min => 0 }, + { label => 'calls_new', value => 'NewCallsLastMinTotal', template => '%d', min => 0 }, ], } }, @@ -44,7 +44,7 @@ sub set_counters { key_values => [ { name => 'ActiveCallsSummaryVoiceTotalCalls' } ], output_template => 'Current Voice Calls : %s', perfdatas => [ - { label => 'calls_voice_active', value => 'ActiveCallsSummaryVoiceTotalCalls_absolute', template => '%d', min => 0 }, + { label => 'calls_voice_active', value => 'ActiveCallsSummaryVoiceTotalCalls', template => '%d', min => 0 }, ], } }, @@ -52,7 +52,7 @@ sub set_counters { key_values => [ { name => 'ActiveCallsSummaryVideoTotalCalls' } ], output_template => 'Current Video Calls : %s', perfdatas => [ - { label => 'calls_video_active', value => 'ActiveCallsSummaryVideoTotalCalls_absolute', template => '%d', min => 0 }, + { label => 'calls_video_active', value => 'ActiveCallsSummaryVideoTotalCalls', template => '%d', min => 0 }, ], } }, @@ -60,7 +60,7 @@ sub set_counters { key_values => [ { name => 'NumberActiveConferences' } ], output_template => 'Current Conferences : %s', perfdatas => [ - { label => 'conferences_active', value => 'NumberActiveConferences_absolute', template => '%d', min => 0 }, + { label => 'conferences_active', value => 'NumberActiveConferences', template => '%d', min => 0 }, ], } }, diff --git a/network/rad/airmux/snmp/mode/radiostatus.pm b/network/rad/airmux/snmp/mode/radiostatus.pm index a0bf32336..8e35609f8 100644 --- a/network/rad/airmux/snmp/mode/radiostatus.pm +++ b/network/rad/airmux/snmp/mode/radiostatus.pm @@ -50,7 +50,7 @@ sub set_counters { key_values => [ { name => 'rx_power' } ], output_template => 'Received signal strength: %s Dbm', perfdatas => [ - { label => 'rx_power', value => 'rx_power_absolute', template => '%s', min => 0 , unit => 'Dbm' }, + { label => 'rx_power', value => 'rx_power', template => '%s', min => 0 , unit => 'Dbm' }, ], } }, @@ -58,7 +58,7 @@ sub set_counters { key_values => [ { name => 'tx_power' } ], output_template => 'Current transmit power: %s Dbm', perfdatas => [ - { label => 'tx_power', value => 'tx_power_absolute', template => '%s', min => 0 , unit => 'Dbm' }, + { label => 'tx_power', value => 'tx_power', template => '%s', min => 0 , unit => 'Dbm' }, ], } }, diff --git a/network/radware/alteon/snmp/mode/cpu.pm b/network/radware/alteon/snmp/mode/cpu.pm index 15c066593..ff9df860d 100644 --- a/network/radware/alteon/snmp/mode/cpu.pm +++ b/network/radware/alteon/snmp/mode/cpu.pm @@ -39,7 +39,7 @@ sub set_counters { key_values => [ { name => 'mp_1s' } ], output_template => '%.2f%% (1sec)', perfdatas => [ - { label => 'mp_cpu_1s', value => 'mp_1s_absolute', template => '%.2f', + { label => 'mp_cpu_1s', value => 'mp_1s', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } @@ -48,7 +48,7 @@ sub set_counters { key_values => [ { name => 'mp_4s' } ], output_template => '%.2f%% (4sec)', perfdatas => [ - { label => 'mp_cpu_4s', value => 'mp_4s_absolute', template => '%.2f', + { label => 'mp_cpu_4s', value => 'mp_4s', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } @@ -57,7 +57,7 @@ sub set_counters { key_values => [ { name => 'mp_64s' } ], output_template => '%.2f%% (64sec)', perfdatas => [ - { label => 'mp_cpu_64s', value => 'mp_64s_absolute', template => '%.2f', + { label => 'mp_cpu_64s', value => 'mp_64s', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } @@ -69,7 +69,7 @@ sub set_counters { key_values => [ { name => 'sp_1s' } ], output_template => 'SP GA Average CPU Usage: %.2f%% (1sec)', perfdatas => [ - { label => 'avg_spga_cpu_1s', value => 'sp_1s_absolute', template => '%.2f', + { label => 'avg_spga_cpu_1s', value => 'sp_1s', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } @@ -78,7 +78,7 @@ sub set_counters { key_values => [ { name => 'sp_4s' } ], output_template => '%.2f%% (4sec)', perfdatas => [ - { label => 'avg_spga_cpu_4s', value => 'sp_4s_absolute', template => '%.2f', + { label => 'avg_spga_cpu_4s', value => 'sp_4s', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } @@ -87,7 +87,7 @@ sub set_counters { key_values => [ { name => 'sp_64s' } ], output_template => '%.2f%% (64sec)', perfdatas => [ - { label => 'avg_spga_cpu_64s', value => 'sp_64s_absolute', template => '%.2f', + { label => 'avg_spga_cpu_64s', value => 'sp_64s', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } @@ -99,8 +99,8 @@ sub set_counters { key_values => [ { name => 'sp_1s' }, { name => 'display' } ], output_template => '%.2f%% (1sec)', perfdatas => [ - { label => 'spga_cpu_1s', value => 'sp_1s_absolute', template => '%.2f', - min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'spga_cpu_1s', value => 'sp_1s', template => '%.2f', + min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -108,8 +108,8 @@ sub set_counters { key_values => [ { name => 'sp_4s' }, { name => 'display' } ], output_template => '%.2f%% (4sec)', perfdatas => [ - { label => 'spga_cpu_4s', value => 'sp_4s_absolute', template => '%.2f', - min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'spga_cpu_4s', value => 'sp_4s', template => '%.2f', + min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -117,8 +117,8 @@ sub set_counters { key_values => [ { name => 'sp_64s' }, { name => 'display' } ], output_template => '%.2f%% (64sec)', perfdatas => [ - { label => 'spga_cpu_64s', value => 'sp_64s_absolute', template => '%.2f', - min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'spga_cpu_64s', value => 'sp_64s', template => '%.2f', + min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/network/radware/alteon/snmp/mode/vserverstatus.pm b/network/radware/alteon/snmp/mode/vserverstatus.pm index 242ecf31c..2860bf4b3 100644 --- a/network/radware/alteon/snmp/mode/vserverstatus.pm +++ b/network/radware/alteon/snmp/mode/vserverstatus.pm @@ -55,16 +55,15 @@ sub set_counters { closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => \&catalog_status_threshold, + closure_custom_threshold_check => \&catalog_status_threshold } }, { label => 'traffic', set => { - key_values => [ { name => 'traffic', diff => 1 }, { name => 'display' } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'traffic', per_second => 1 }, { name => 'display' } ], output_template => 'Traffic : %s %s/s', + output_change_bytes => 2, perfdatas => [ - { label => 'traffic', value => 'traffic_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic', template => '%.2f', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -72,8 +71,7 @@ sub set_counters { key_values => [ { name => 'current_sessions' }, { name => 'display' } ], output_template => 'Current Sessions : %s', perfdatas => [ - { label => 'current_sessions', value => 'current_sessions_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'current_sessions', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -81,11 +79,10 @@ sub set_counters { key_values => [ { name => 'total_sessions', diff => 1 }, { name => 'display' } ], output_template => 'Total Sessions : %s', perfdatas => [ - { label => 'total_sessions', value => 'total_sessions_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, - ], + { label => 'total_sessions', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' } + ] } - }, + } ]; } @@ -99,14 +96,13 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; - - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - "warning-status:s" => { name => 'warning_status', default => '' }, - "critical-status:s" => { name => 'critical_status', default => '' }, - }); - + + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '' } + }); + return $self; } diff --git a/network/raisecom/snmp/mode/cpu.pm b/network/raisecom/snmp/mode/cpu.pm index 6fb9bf52a..b604acb35 100644 --- a/network/raisecom/snmp/mode/cpu.pm +++ b/network/raisecom/snmp/mode/cpu.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'fiveSec' } ], output_template => '%.2f%% (5sec)', perfdatas => [ - { label => 'cpu_5s', value => 'fiveSec_absolute', template => '%.2f', + { label => 'cpu_5s', value => 'fiveSec', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'oneMin' } ], output_template => '%.2f%% (1min)', perfdatas => [ - { label => 'cpu_1m', value => 'oneMin_absolute', template => '%.2f', + { label => 'cpu_1m', value => 'oneMin', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } @@ -55,7 +55,7 @@ sub set_counters { key_values => [ { name => 'tenMin' } ], output_template => '%.2f%% (10min)', perfdatas => [ - { label => 'cpu_10m', value => 'tenMin_absolute', template => '%.2f', + { label => 'cpu_10m', value => 'tenMin', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } @@ -64,7 +64,7 @@ sub set_counters { key_values => [ { name => 'twoHour' } ], output_template => '%.2f%% (2h)', perfdatas => [ - { label => 'cpu_2h', value => 'twoHour_absolute', template => '%.2f', + { label => 'cpu_2h', value => 'twoHour', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } diff --git a/network/riverbed/interceptor/snmp/mode/neighborconnections.pm b/network/riverbed/interceptor/snmp/mode/neighborconnections.pm index 9b1253443..518c86942 100644 --- a/network/riverbed/interceptor/snmp/mode/neighborconnections.pm +++ b/network/riverbed/interceptor/snmp/mode/neighborconnections.pm @@ -38,8 +38,8 @@ sub set_counters { key_values => [ { name => 'neighborConnectionCount' }, { name => 'display' } ], output_template => 'Optimized Connections Count: %d', perfdatas => [ - { label => 'connections', value => 'neighborConnectionCount_absolute', template => '%d', min => 0, - label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'connections', value => 'neighborConnectionCount', template => '%d', min => 0, + label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/network/ruckus/ap/snmp/mode/cpu.pm b/network/ruckus/ap/snmp/mode/cpu.pm index 970611aee..894b95cbe 100644 --- a/network/ruckus/ap/snmp/mode/cpu.pm +++ b/network/ruckus/ap/snmp/mode/cpu.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'cpu' } ], output_template => 'Usage : %.2f %%', perfdatas => [ - { label => 'cpu', value => 'cpu_absolute', template => '%.2f', + { label => 'cpu', value => 'cpu', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } diff --git a/network/ruckus/ap/snmp/mode/users.pm b/network/ruckus/ap/snmp/mode/users.pm index 69312c138..178f74bf3 100644 --- a/network/ruckus/ap/snmp/mode/users.pm +++ b/network/ruckus/ap/snmp/mode/users.pm @@ -100,8 +100,8 @@ sub set_counters { key_values => [ { name => 'total' }, { name => 'display' } ], output_template => 'users : %s', perfdatas => [ - { label => 'ssid', value => 'total_absolute', template => '%s', - unit => 'users', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'ssid', value => 'total', template => '%s', + unit => 'users', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/network/ruckus/scg/snmp/mode/apusage.pm b/network/ruckus/scg/snmp/mode/apusage.pm index 3121ab6f0..92292ea1a 100644 --- a/network/ruckus/scg/snmp/mode/apusage.pm +++ b/network/ruckus/scg/snmp/mode/apusage.pm @@ -38,28 +38,28 @@ sub set_counters { key_values => [ { name => 'ruckusSCGAPNumSta' }, { name => 'display' } ], output_template => 'Users count: %s', perfdatas => [ - { label => 'users_count', value => 'ruckusSCGAPNumSta_absolute', template => '%s', - unit => 'users', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'users_count', template => '%s', + unit => 'users', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'traffic-in', set => { - key_values => [ { name => 'ruckusSCGAPRXBytes', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'ruckusSCGAPRXBytes', per_second => 1 }, { name => 'display' } ], output_template => 'Traffic In: %s %s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_in', value => 'ruckusSCGAPRXBytes_absolute', template => '%s', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_in', template => '%s', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'traffic-out', set => { - key_values => [ { name => 'ruckusSCGAPTXBytes', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'ruckusSCGAPTXBytes', per_second => 1 }, { name => 'display' } ], output_template => 'Traffic Out: %s %s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_out', value => 'ruckusSCGAPTXBytes_absolute', template => '%s', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_out', template => '%s', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -77,10 +77,9 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - }); + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' } + }); return $self; } diff --git a/network/ruckus/scg/snmp/mode/ssidusage.pm b/network/ruckus/scg/snmp/mode/ssidusage.pm index f48a57a70..c69b524f0 100644 --- a/network/ruckus/scg/snmp/mode/ssidusage.pm +++ b/network/ruckus/scg/snmp/mode/ssidusage.pm @@ -38,28 +38,28 @@ sub set_counters { key_values => [ { name => 'ruckusSCGWLANNumSta' }, { name => 'display' } ], output_template => 'Users count: %s', perfdatas => [ - { label => 'users_count', value => 'ruckusSCGWLANNumSta_absolute', template => '%s', - unit => 'users', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'users_count', template => '%s', + unit => 'users', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'traffic-in', set => { - key_values => [ { name => 'ruckusSCGWLANRxBytes', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'ruckusSCGWLANRxBytes', per_second => 1 }, { name => 'display' } ], output_template => 'Traffic In: %s %s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_in', value => 'ruckusSCGWLANRxBytes_absolute', template => '%s', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_in', template => '%s', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'traffic-out', set => { - key_values => [ { name => 'ruckusSCGWLANTxBytes', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'ruckusSCGWLANTxBytes', per_second => 1 }, { name => 'display' } ], output_template => 'Traffic Out: %s %s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_out', value => 'ruckusSCGWLANTxBytes_absolute', template => '%s', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_out', template => '%s', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -77,10 +77,9 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - }); + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' } + }); return $self; } diff --git a/network/ruckus/scg/snmp/mode/systemstats.pm b/network/ruckus/scg/snmp/mode/systemstats.pm index 6af6465df..c454ae156 100644 --- a/network/ruckus/scg/snmp/mode/systemstats.pm +++ b/network/ruckus/scg/snmp/mode/systemstats.pm @@ -38,8 +38,7 @@ sub set_counters { key_values => [ { name => 'ruckusSystemStatsNumAP' } ], output_template => 'APs count: %s', perfdatas => [ - { label => 'aps_count', value => 'ruckusSystemStatsNumAP_absolute', template => '%s', - unit => 'aps', min => 0 }, + { label => 'aps_count', template => '%s', unit => 'aps', min => 0 }, ], } }, @@ -47,88 +46,73 @@ sub set_counters { key_values => [ { name => 'ruckusSystemStatsNumSta' } ], output_template => 'Users count: %s', perfdatas => [ - { label => 'users_count', value => 'ruckusSystemStatsNumSta_absolute', template => '%s', - unit => 'users', min => 0 }, + { label => 'users_count', template => '%s', unit => 'users', min => 0 }, ], } }, { label => 'total-traffic-in', set => { - key_values => [ { name => 'ruckusSystemStatsWLANTotalRxBytes', diff => 1 } ], + key_values => [ { name => 'ruckusSystemStatsWLANTotalRxBytes', per_second => 1 } ], output_template => 'Total Traffic In: %s %s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { label => 'total_traffic_in', value => 'ruckusSystemStatsWLANTotalRxBytes_absolute', template => '%s', - min => 0, unit => 'b/s' }, + { label => 'total_traffic_in', template => '%s', min => 0, unit => 'b/s' }, ], } }, { label => 'total-traffic-out', set => { - key_values => [ { name => 'ruckusSystemStatsWLANTotalTxBytes', diff => 1 } ], + key_values => [ { name => 'ruckusSystemStatsWLANTotalTxBytes', per_second => 1 } ], output_template => 'Total Traffic Out: %s %s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { label => 'total_traffic_out', value => 'ruckusSystemStatsWLANTotalTxBytes_absolute', template => '%s', - min => 0, unit => 'b/s' }, + { label => 'total_traffic_out', template => '%s', min => 0, unit => 'b/s' }, ], } }, { label => 'total-packets-in', set => { - key_values => [ { name => 'ruckusSystemStatsWLANTotalRxPkts', diff => 1 } ], + key_values => [ { name => 'ruckusSystemStatsWLANTotalRxPkts', per_second => 1 } ], output_template => 'Total Packets In: %s packets/s', - per_second => 1, perfdatas => [ - { label => 'total_packets_in', value => 'ruckusSystemStatsWLANTotalRxPkts_absolute', template => '%s', - min => 0, unit => 'packets/s' }, + { label => 'total_packets_in', template => '%s', min => 0, unit => 'packets/s' }, ], } }, { label => 'total-mcast-packets-in', set => { - key_values => [ { name => 'ruckusSystemStatsWLANTotalRxMulticast', diff => 1 } ], + key_values => [ { name => 'ruckusSystemStatsWLANTotalRxMulticast', per_second => 1 } ], output_template => 'Total Multicast Packets In: %s packets/s', - per_second => 1, perfdatas => [ - { label => 'total_mcast_packets_in', value => 'ruckusSystemStatsWLANTotalRxMulticast_absolute', template => '%s', - min => 0, unit => 'packets/s' }, + { label => 'total_mcast_packets_in', template => '%s', min => 0, unit => 'packets/s' }, ], } }, { label => 'total-packets-out', set => { - key_values => [ { name => 'ruckusSystemStatsWLANTotalTxPkts', diff => 1 } ], + key_values => [ { name => 'ruckusSystemStatsWLANTotalTxPkts', per_second => 1 } ], output_template => 'Total Packets Out: %s packets/s', - per_second => 1, perfdatas => [ - { label => 'total_packets_out', value => 'ruckusSystemStatsWLANTotalTxPkts_absolute', template => '%s', - min => 0, unit => 'packets/s' }, + { label => 'total_packets_out', template => '%s', min => 0, unit => 'packets/s' }, ], } }, { label => 'total-mcast-packets-out', set => { - key_values => [ { name => 'ruckusSystemStatsWLANTotalTxMulticast', diff => 1 } ], + key_values => [ { name => 'ruckusSystemStatsWLANTotalTxMulticast', per_second => 1 } ], output_template => 'Total Multicast Packets Out: %s packets/s', - per_second => 1, perfdatas => [ - { label => 'total_mcast_packets_out', value => 'ruckusSystemStatsWLANTotalTxMulticast_absolute', template => '%s', - min => 0, unit => 'packets/s' }, + { label => 'total_mcast_packets_out', template => '%s', min => 0, unit => 'packets/s' }, ], } }, { label => 'total-fail-packets-out', set => { - key_values => [ { name => 'ruckusSystemStatsWLANTotalTxFail', diff => 1 } ], + key_values => [ { name => 'ruckusSystemStatsWLANTotalTxFail', per_second => 1 } ], output_template => 'Total Fail Packets Out: %s packets/s', - per_second => 1, perfdatas => [ - { label => 'total_fail_packets_out', value => 'ruckusSystemStatsWLANTotalTxFail_absolute', template => '%s', - min => 0, unit => 'packets/s' }, + { label => 'total_fail_packets_out', template => '%s', min => 0, unit => 'packets/s' }, ], } }, { label => 'total-retry-packets-out', set => { - key_values => [ { name => 'ruckusSystemStatsWLANTotalTxRetry', diff => 1 } ], + key_values => [ { name => 'ruckusSystemStatsWLANTotalTxRetry', per_second => 1 } ], output_template => 'Total Retry Packets Out: %s packets/s', - per_second => 1, perfdatas => [ - { label => 'total_retry_packets_out', value => 'ruckusSystemStatsWLANTotalTxRetry_absolute', template => '%s', - min => 0, unit => 'packets/s' }, + { label => 'total_retry_packets_out', template => '%s', min => 0, unit => 'packets/s' }, ], } }, @@ -140,9 +124,8 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; - $options{options}->add_options(arguments => - { - }); + $options{options}->add_options(arguments => { + }); return $self; } diff --git a/network/ruckus/smartzone/snmp/mode/accesspoints.pm b/network/ruckus/smartzone/snmp/mode/accesspoints.pm index 15d0cf6af..d67ab5b67 100644 --- a/network/ruckus/smartzone/snmp/mode/accesspoints.pm +++ b/network/ruckus/smartzone/snmp/mode/accesspoints.pm @@ -83,7 +83,7 @@ sub set_counters { key_values => [ { name => 'authorized_clients' }, { name => 'display' } ], output_template => 'client devices authorized connections: %d', perfdatas => [ - { value => 'authorized_clients_absolute', template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' } + { template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display' } ] } } @@ -91,22 +91,20 @@ sub set_counters { $self->{maps_counters}->{traffic} = [ { label => 'traffic-in', nlabel => 'accesspoint.traffic.in.bitspersecond', set => { - key_values => [ { name => 'traffic_in', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'traffic_in', per_second => 1 }, { name => 'display' } ], output_template => 'traffic in: %s%s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { value => 'traffic_in_per_second', template => '%s', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' } + { template => '%s', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' } ] } }, { label => 'traffic-out', nlabel => 'accesspoint.traffic.out.bitspersecond', set => { - key_values => [ { name => 'traffic_out', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'traffic_out', per_second => 1 }, { name => 'display' } ], output_template => 'traffic in: %s%s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { value => 'traffic_out_per_second', template => '%s', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' } + { template => '%s', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' } ] } } diff --git a/network/ruckus/smartzone/snmp/mode/system.pm b/network/ruckus/smartzone/snmp/mode/system.pm index 42f89bb79..9433a9075 100644 --- a/network/ruckus/smartzone/snmp/mode/system.pm +++ b/network/ruckus/smartzone/snmp/mode/system.pm @@ -50,7 +50,7 @@ sub set_counters { key_values => [ { name => 'ap' } ], output_template => 'access points connections: %d', perfdatas => [ - { value => 'ap_absolute', template => '%d', min => 0 } + { template => '%d', min => 0 } ] } }, @@ -58,7 +58,7 @@ sub set_counters { key_values => [ { name => 'authorized_clients' } ], output_template => 'client devices authorized connections: %d', perfdatas => [ - { value => 'authorized_clients_absolute', template => '%d', min => 0 } + { template => '%d', min => 0 } ] } } @@ -66,22 +66,20 @@ sub set_counters { $self->{maps_counters}->{traffic} = [ { label => 'traffic-in', nlabel => 'system.traffic.in.bitspersecond', set => { - key_values => [ { name => 'traffic_in', diff => 1 } ], + key_values => [ { name => 'traffic_in', per_second => 1 } ], output_template => 'traffic in: %s%s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { value => 'traffic_in_per_second', template => '%s', - min => 0, unit => 'b/s' } + { template => '%s', min => 0, unit => 'b/s' } ] } }, { label => 'traffic-out', nlabel => 'system.traffic.out.bitspersecond', set => { - key_values => [ { name => 'traffic_out', diff => 1 } ], + key_values => [ { name => 'traffic_out', per_second => 1 } ], output_template => 'traffic in: %s%s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { value => 'traffic_out_per_second', template => '%s', - min => 0, unit => 'b/s' } + { template => '%s', min => 0, unit => 'b/s' } ] } } diff --git a/network/ruckus/zonedirector/snmp/mode/accesspoints.pm b/network/ruckus/zonedirector/snmp/mode/accesspoints.pm index cff5240fe..ff5f71460 100644 --- a/network/ruckus/zonedirector/snmp/mode/accesspoints.pm +++ b/network/ruckus/zonedirector/snmp/mode/accesspoints.pm @@ -52,11 +52,11 @@ sub custom_usage_output { return sprintf( 'ram total: %s %s used: %s %s (%.2f%%) free: %s %s (%.2f%%)', - $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_absolute}), - $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_absolute}), - $self->{result_values}->{prct_used_absolute}, - $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute}), - $self->{result_values}->{prct_free_absolute} + $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}), + $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}), + $self->{result_values}->{prct_used}, + $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}), + $self->{result_values}->{prct_free} ); } @@ -92,8 +92,7 @@ sub set_counters { key_values => [ { name => 'cpu_util' }, { name => 'display' } ], output_template => 'cpu usage: %.2f%%', perfdatas => [ - { value => 'cpu_util_absolute', template => '%.2f', unit => '%', - min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' } + { template => '%.2f', unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' } ] } } @@ -104,8 +103,7 @@ sub set_counters { key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'display' } ], closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ - { value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute', - unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' } + { template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display' } ] } }, @@ -113,8 +111,7 @@ sub set_counters { key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'display' } ], closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ - { value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute', - unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' } + { template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display' } ] } }, @@ -122,8 +119,7 @@ sub set_counters { key_values => [ { name => 'prct_used' }, { name => 'display' } ], output_template => 'ram used: %.2f %%', perfdatas => [ - { value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, - label_extra_instance => 1, instance_use => 'display_absolute' } + { template => '%.2f', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' } ] } } @@ -134,7 +130,7 @@ sub set_counters { key_values => [ { name => 'ap' }, { name => 'display' } ], output_template => 'access points connections: %d', perfdatas => [ - { value => 'ap_absolute', template => '%d', min => 0 } + { template => '%d', min => 0 } ] } }, @@ -142,7 +138,7 @@ sub set_counters { key_values => [ { name => 'authorized_clients' }, { name => 'display' } ], output_template => 'client devices authorized connections: %d', perfdatas => [ - { value => 'authorized_clients_absolute', template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' } + { template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display' } ] } }, @@ -150,7 +146,7 @@ sub set_counters { key_values => [ { name => 'rogues' }, { name => 'display' } ], output_template => 'rogue devices connections: %d', perfdatas => [ - { value => 'rogues_absolute', template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' } + { template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display' } ] } } @@ -158,22 +154,20 @@ sub set_counters { $self->{maps_counters}->{traffic} = [ { label => 'traffic-in', nlabel => 'accesspoint.traffic.in.bitspersecond', set => { - key_values => [ { name => 'traffic_in', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'traffic_in', per_second => 1 }, { name => 'display' } ], output_template => 'traffic in: %s%s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { value => 'traffic_in_per_second', template => '%s', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' } + { template => '%s', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' } ] } }, { label => 'traffic-out', nlabel => 'accesspoint.traffic.out.bitspersecond', set => { - key_values => [ { name => 'traffic_out', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'traffic_out', per_second => 1 }, { name => 'display' } ], output_template => 'traffic in: %s%s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { value => 'traffic_out_per_second', template => '%s', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' } + { template => '%s', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' } ] } } diff --git a/network/ruckus/zonedirector/snmp/mode/system.pm b/network/ruckus/zonedirector/snmp/mode/system.pm index 54f0886a6..a73240834 100644 --- a/network/ruckus/zonedirector/snmp/mode/system.pm +++ b/network/ruckus/zonedirector/snmp/mode/system.pm @@ -47,11 +47,11 @@ sub custom_usage_output { return sprintf( 'ram total: %s %s used: %s %s (%.2f%%) free: %s %s (%.2f%%)', - $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_absolute}), - $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_absolute}), - $self->{result_values}->{prct_used_absolute}, - $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute}), - $self->{result_values}->{prct_free_absolute} + $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}), + $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}), + $self->{result_values}->{prct_used}, + $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}), + $self->{result_values}->{prct_free} ); } @@ -87,7 +87,7 @@ sub set_counters { key_values => [ { name => 'cpu_util' } ], output_template => 'cpu usage: %.2f%%', perfdatas => [ - { value => 'cpu_util_absolute', template => '%.2f', unit => '%', min => 0, max => 100 } + { template => '%.2f', unit => '%', min => 0, max => 100 } ] } } @@ -98,8 +98,7 @@ sub set_counters { key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ - { value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute', - unit => 'B', cast_int => 1 } + { template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1 } ] } }, @@ -107,8 +106,7 @@ sub set_counters { key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ - { value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute', - unit => 'B', cast_int => 1 } + { template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1 } ] } }, @@ -116,7 +114,7 @@ sub set_counters { key_values => [ { name => 'prct_used' } ], output_template => 'ram used: %.2f %%', perfdatas => [ - { value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100 } + { template => '%.2f', min => 0, max => 100 } ] } } @@ -127,7 +125,7 @@ sub set_counters { key_values => [ { name => 'ap' } ], output_template => 'access points connections: %d', perfdatas => [ - { value => 'ap_absolute', template => '%d', min => 0 } + { template => '%d', min => 0 } ] } }, @@ -135,7 +133,7 @@ sub set_counters { key_values => [ { name => 'authorized_clients' } ], output_template => 'client devices authorized connections: %d', perfdatas => [ - { value => 'authorized_clients_absolute', template => '%d', min => 0 } + { template => '%d', min => 0 } ] } }, @@ -143,7 +141,7 @@ sub set_counters { key_values => [ { name => 'rogues' } ], output_template => 'rogue devices connections: %d', perfdatas => [ - { value => 'rogues_absolute', template => '%d', min => 0 } + { template => '%d', min => 0 } ] } } @@ -151,22 +149,20 @@ sub set_counters { $self->{maps_counters}->{traffic} = [ { label => 'traffic-in', nlabel => 'system.traffic.in.bitspersecond', set => { - key_values => [ { name => 'traffic_in', diff => 1 } ], + key_values => [ { name => 'traffic_in', per_second => 1 } ], output_template => 'traffic in: %s%s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { value => 'traffic_in_per_second', template => '%s', - min => 0, unit => 'b/s' } + { template => '%s', min => 0, unit => 'b/s' } ] } }, { label => 'traffic-out', nlabel => 'system.traffic.out.bitspersecond', set => { - key_values => [ { name => 'traffic_out', diff => 1 } ], + key_values => [ { name => 'traffic_out', per_second => 1 } ], output_template => 'traffic in: %s%s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { value => 'traffic_out_per_second', template => '%s', - min => 0, unit => 'b/s' } + { template => '%s', min => 0, unit => 'b/s' } ] } } diff --git a/network/sonicwall/snmp/mode/connections.pm b/network/sonicwall/snmp/mode/connections.pm index 83eea9734..0920ca06a 100644 --- a/network/sonicwall/snmp/mode/connections.pm +++ b/network/sonicwall/snmp/mode/connections.pm @@ -36,8 +36,8 @@ sub set_counters { key_values => [ { name => 'prct_used' }, { name => 'total' }, { name => 'used' } ], closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ - { label => 'connections', value => 'used_absolute', template => '%s', - min => 0, max => 'total_absolute', threshold_total => 'total_absolute', cast_int => 1 }, + { label => 'connections', value => 'used', template => '%s', + min => 0, max => 'total', threshold_total => 'total', cast_int => 1 }, ], } }, @@ -48,9 +48,9 @@ sub custom_usage_output { my ($self, %options) = @_; my $msg = sprintf("%.2f%% of the connections cached are used (%d of max. %d)", - $self->{result_values}->{prct_used_absolute}, - $self->{result_values}->{used_absolute}, - $self->{result_values}->{total_absolute}); + $self->{result_values}->{prct_used}, + $self->{result_values}->{used}, + $self->{result_values}->{total}); return $msg; } diff --git a/network/sonicwall/snmp/mode/cpu.pm b/network/sonicwall/snmp/mode/cpu.pm index a81fd6fac..9bee586e8 100644 --- a/network/sonicwall/snmp/mode/cpu.pm +++ b/network/sonicwall/snmp/mode/cpu.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'prct_used' } ], output_template => 'CPU Usage %.2f %%', perfdatas => [ - { label => 'cpu', value => 'prct_used_absolute', template => '%.2f', + { label => 'cpu', value => 'prct_used', template => '%.2f', unit => '%', min => 0, max => 100 }, ], } diff --git a/network/sonicwall/snmp/mode/memory.pm b/network/sonicwall/snmp/mode/memory.pm index dee952bd4..a5ab9c83f 100644 --- a/network/sonicwall/snmp/mode/memory.pm +++ b/network/sonicwall/snmp/mode/memory.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'prct_used' } ], output_template => 'Memory Usage %.2f %%', perfdatas => [ - { label => 'memory', value => 'prct_used_absolute', template => '%.2f', + { label => 'memory', value => 'prct_used', template => '%.2f', unit => '%', min => 0, max => 100 }, ], } diff --git a/network/sonicwall/snmp/mode/vpn.pm b/network/sonicwall/snmp/mode/vpn.pm index 2fabd6b4e..25d84478f 100644 --- a/network/sonicwall/snmp/mode/vpn.pm +++ b/network/sonicwall/snmp/mode/vpn.pm @@ -35,22 +35,22 @@ sub set_counters { $self->{maps_counters}->{vpn} = [ { label => 'traffic-in', set => { - key_values => [ { name => 'traffic_in', diff => 1 }, { name => 'display' } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'traffic_in', per_second => 1 }, { name => 'display' } ], output_template => 'Traffic In: %s %s/s', + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_in', value => 'traffic_in_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_in', template => '%.2f', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'traffic-out', set => { - key_values => [ { name => 'traffic_out', diff => 1 }, { name => 'display' } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'traffic_out', per_second => 1 }, { name => 'display' } ], output_template => 'Traffic Out: %s %s/s', + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_out', value => 'traffic_out_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_out', template => '%.2f', + min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } } @@ -68,10 +68,10 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - }); + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' } + }); + return $self; } diff --git a/network/sonus/sbc/snmp/mode/callstats.pm b/network/sonus/sbc/snmp/mode/callstats.pm index a4211c776..0ae61737f 100644 --- a/network/sonus/sbc/snmp/mode/callstats.pm +++ b/network/sonus/sbc/snmp/mode/callstats.pm @@ -38,58 +38,53 @@ sub set_counters { key_values => [ { name => 'current' }, { name => 'display' } ], output_template => 'Current calls : %s', perfdatas => [ - { label => 'current', value => 'current_absolute', template => '%d', - min => 0, unit => 'calls', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'current', template => '%d', + min => 0, unit => 'calls', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'total-per-sec', set => { - key_values => [ { name => 'total', diff => 1 }, { name => 'display' } ], - per_second => 1, + key_values => [ { name => 'total', per_second => 1 }, { name => 'display' } ], output_template => 'total calls: %.2f/s', perfdatas => [ - { label => 'total', value => 'total_per_second', template => '%.2f', - min => 0, unit => 'calls', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'total', template => '%.2f', + min => 0, unit => 'calls', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'connected-per-sec', set => { - key_values => [ { name => 'connected', diff => 1 }, { name => 'display' } ], - per_second => 1, + key_values => [ { name => 'connected', per_second => 1 }, { name => 'display' } ], output_template => 'connected calls: %.2f/s', perfdatas => [ - { label => 'connected', value => 'connected_per_second', template => '%.2f', - min => 0, unit => 'calls', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'connected', template => '%.2f', + min => 0, unit => 'calls', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'refused-per-sec', set => { - key_values => [ { name => 'refused', diff => 1 }, { name => 'display' } ], - per_second => 1, + key_values => [ { name => 'refused', per_second => 1 }, { name => 'display' } ], output_template => 'refused calls: %.2f/s', perfdatas => [ - { label => 'refused', value => 'refused_per_second', template => '%.2f', - min => 0, unit => 'calls', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'refused', template => '%.2f', + min => 0, unit => 'calls', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'errored-per-sec', set => { - key_values => [ { name => 'errored', diff => 1 }, { name => 'display' } ], - per_second => 1, + key_values => [ { name => 'errored', per_second => 1 }, { name => 'display' } ], output_template => 'errored calls: %.2f/s', perfdatas => [ - { label => 'errored', value => 'errored_per_second', template => '%.2f', - min => 0, unit => 'calls', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'errored', template => '%.2f', + min => 0, unit => 'calls', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'blocked-per-sec', set => { - key_values => [ { name => 'blocked', diff => 1 }, { name => 'display' } ], - per_second => 1, + key_values => [ { name => 'blocked', per_second => 1 }, { name => 'display' } ], output_template => 'blocked calls: %.2f/s', perfdatas => [ - { label => 'blocked', value => 'blocked_per_second', template => '%.2f', - min => 0, unit => 'calls', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'blocked', template => '%.2f', + min => 0, unit => 'calls', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -107,9 +102,9 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; - $options{options}->add_options(arguments => - { - }); + $options{options}->add_options(arguments => { + }); + return $self; } diff --git a/network/sonus/sbc/snmp/mode/channels.pm b/network/sonus/sbc/snmp/mode/channels.pm index fe66f43ed..ce850e305 100644 --- a/network/sonus/sbc/snmp/mode/channels.pm +++ b/network/sonus/sbc/snmp/mode/channels.pm @@ -60,7 +60,7 @@ sub set_counters { key_values => [ { name => 'total' } ], output_template => 'Total channels : %s', perfdatas => [ - { label => 'total', value => 'total_absolute', template => '%s', + { label => 'total', value => 'total', template => '%s', min => 0 }, ], } @@ -69,7 +69,7 @@ sub set_counters { key_values => [ { name => 'outofservice' } ], output_template => 'OutOfService : %s', perfdatas => [ - { label => 'total_outofservice', value => 'outofservice_absolute', template => '%s', + { label => 'total_outofservice', value => 'outofservice', template => '%s', min => 0 }, ], } @@ -78,7 +78,7 @@ sub set_counters { key_values => [ { name => 'idle' } ], output_template => 'Idle : %s', perfdatas => [ - { label => 'total_idle', value => 'idle_absolute', template => '%s', + { label => 'total_idle', value => 'idle', template => '%s', min => 0 }, ], } @@ -87,7 +87,7 @@ sub set_counters { key_values => [ { name => 'pending' } ], output_template => 'Pending : %s', perfdatas => [ - { label => 'total_pending', value => 'pending_absolute', template => '%s', + { label => 'total_pending', value => 'pending', template => '%s', min => 0 }, ], } @@ -96,7 +96,7 @@ sub set_counters { key_values => [ { name => 'waitingforroute' } ], output_template => 'WaitingForRoute : %s', perfdatas => [ - { label => 'total_waitingforroute', value => 'waitingforroute_absolute_absolute', template => '%s', + { label => 'total_waitingforroute', value => 'waitingforroute', template => '%s', min => 0 }, ], } @@ -105,7 +105,7 @@ sub set_counters { key_values => [ { name => 'actionlist' } ], output_template => 'ActionList : %s', perfdatas => [ - { label => 'total_actionlist', value => 'actionlist_absolute', template => '%s', + { label => 'total_actionlist', value => 'actionlist', template => '%s', min => 0 }, ], } @@ -114,7 +114,7 @@ sub set_counters { key_values => [ { name => 'waitingfordigits' } ], output_template => 'WaitingForDigits : %s', perfdatas => [ - { label => 'total_waitingfordigits', value => 'waitingfordigits_absolute', template => '%s', + { label => 'total_waitingfordigits', value => 'waitingfordigits', template => '%s', min => 0 }, ], } @@ -123,7 +123,7 @@ sub set_counters { key_values => [ { name => 'remotesetup' } ], output_template => 'RemoteSetup : %s', perfdatas => [ - { label => 'total_remotesetup', value => 'remotesetup_absolute', template => '%s', + { label => 'total_remotesetup', value => 'remotesetup', template => '%s', min => 0 }, ], } @@ -132,7 +132,7 @@ sub set_counters { key_values => [ { name => 'peersetup' } ], output_template => 'PeerSetup : %s', perfdatas => [ - { label => 'total_peersetup', value => 'peersetup_absolute', template => '%s', + { label => 'total_peersetup', value => 'peersetup', template => '%s', min => 0 }, ], } @@ -141,7 +141,7 @@ sub set_counters { key_values => [ { name => 'alerting' } ], output_template => 'Alerting : %s', perfdatas => [ - { label => 'total_alerting', value => 'alerting_absolute', template => '%s', + { label => 'total_alerting', value => 'alerting', template => '%s', min => 0 }, ], } @@ -150,7 +150,7 @@ sub set_counters { key_values => [ { name => 'inbandinfo' } ], output_template => 'InBandInfo : %s', perfdatas => [ - { label => 'total_inbandinfo', value => 'inbandinfo_absolute', template => '%s', + { label => 'total_inbandinfo', value => 'inbandinfo', template => '%s', min => 0 }, ], } @@ -159,7 +159,7 @@ sub set_counters { key_values => [ { name => 'connected' } ], output_template => 'Connected : %s', perfdatas => [ - { label => 'total_connected', value => 'connected_absolute', template => '%s', + { label => 'total_connected', value => 'connected', template => '%s', min => 0 }, ], } @@ -168,7 +168,7 @@ sub set_counters { key_values => [ { name => 'tonegeneration' } ], output_template => 'ToneGeneration : %s', perfdatas => [ - { label => 'total_tonegeneration', value => 'tonegeneration_absolute', template => '%s', + { label => 'total_tonegeneration', value => 'tonegeneration', template => '%s', min => 0 }, ], } @@ -177,7 +177,7 @@ sub set_counters { key_values => [ { name => 'releasing' } ], output_template => 'Releasing : %s', perfdatas => [ - { label => 'total_releasing', value => 'releasing_absolute', template => '%s', + { label => 'total_releasing', value => 'releasing', template => '%s', min => 0 }, ], } @@ -186,7 +186,7 @@ sub set_counters { key_values => [ { name => 'aborting' } ], output_template => 'Aborting : %s', perfdatas => [ - { label => 'total_aborting', value => 'aborting_absolute', template => '%s', + { label => 'total_aborting', value => 'aborting', template => '%s', min => 0 }, ], } @@ -195,7 +195,7 @@ sub set_counters { key_values => [ { name => 'resetting' } ], output_template => 'Resetting : %s', perfdatas => [ - { label => 'total_resetting', value => 'resetting_absolute', template => '%s', + { label => 'total_resetting', value => 'resetting', template => '%s', min => 0 }, ], } @@ -204,7 +204,7 @@ sub set_counters { key_values => [ { name => 'up' } ], output_template => 'Up : %s', perfdatas => [ - { label => 'total_up', value => 'up_absolute', template => '%s', + { label => 'total_up', value => 'up', template => '%s', min => 0 }, ], } @@ -213,7 +213,7 @@ sub set_counters { key_values => [ { name => 'down' } ], output_template => 'Down : %s', perfdatas => [ - { label => 'total_down', value => 'down_absolute', template => '%s', + { label => 'total_down', value => 'down', template => '%s', min => 0 }, ], } @@ -233,8 +233,8 @@ sub set_counters { key_values => [ { name => 'seconds' }, { name => 'display' } ], output_template => 'lifetime : %s seconds', perfdatas => [ - { label => 'seconds', value => 'seconds_absolute', template => '%s', - min => 0, unit => 's', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'seconds', value => 'seconds', template => '%s', + min => 0, unit => 's', label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/network/sonus/sbc/snmp/mode/dspstats.pm b/network/sonus/sbc/snmp/mode/dspstats.pm index 971979ecb..1c57ef6d6 100644 --- a/network/sonus/sbc/snmp/mode/dspstats.pm +++ b/network/sonus/sbc/snmp/mode/dspstats.pm @@ -60,8 +60,8 @@ sub set_counters { key_values => [ { name => 'cpu' }, { name => 'display' } ], output_template => 'CPU Usage: %s', perfdatas => [ - { label => 'cpu', value => 'cpu_absolute', template => '%d', - min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'cpu', value => 'cpu', template => '%d', + min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -69,8 +69,8 @@ sub set_counters { key_values => [ { name => 'channels' }, { name => 'display' } ], output_template => 'Active Channels: %s', perfdatas => [ - { label => 'channels', value => 'channels_absolute', template => '%d', - min => 0, unit => 'channels', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'channels', value => 'channels', template => '%d', + min => 0, unit => 'channels', label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/network/sophos/es/snmp/mode/message.pm b/network/sophos/es/snmp/mode/message.pm index a9c3434cd..0b132da25 100644 --- a/network/sophos/es/snmp/mode/message.pm +++ b/network/sophos/es/snmp/mode/message.pm @@ -39,49 +39,45 @@ sub set_counters { key_values => [ { name => 'queue' } ], output_template => 'Current Queue : %s', perfdatas => [ - { label => 'queue', value => 'queue_absolute', template => '%s', min => 0 }, - ], + { label => 'queue', template => '%s', min => 0 } + ] } }, { label => 'total-msg-in', set => { - key_values => [ { name => 'total_in', diff => 1 } ], - output_template => 'Total Message In : %.2f/s', per_second => 1, + key_values => [ { name => 'total_in', per_second => 1 } ], + output_template => 'Total Message In : %.2f/s', perfdatas => [ - { label => 'total_msg_in', value => 'total_in_per_second', template => '%.2f', - unit => '/s', min => 0 }, - ], + { label => 'total_msg_in', template => '%.2f', unit => '/s', min => 0 } + ] } }, { label => 'total-msg-out', set => { - key_values => [ { name => 'total_out', diff => 1 } ], - output_template => 'Total Message Out : %.2f/s', per_second => 1, + key_values => [ { name => 'total_out', per_second => 1 } ], + output_template => 'Total Message Out : %.2f/s', perfdatas => [ - { label => 'total_msg_out', value => 'total_out_per_second', template => '%.2f', - unit => '/s', min => 0 }, - ], + { label => 'total_msg_out', template => '%.2f', unit => '/s', min => 0 } + ] } - }, + } ]; $self->{maps_counters}->{sea_msg} = [ { label => 'msg-in', set => { - key_values => [ { name => 'in', diff => 1 }, { name => 'display' } ], - output_template => 'In : %.2f/s', per_second => 1, + key_values => [ { name => 'in', per_second => 1 }, { name => 'display' } ], + output_template => 'In : %.2f/s', perfdatas => [ - { label => 'msg_in', value => 'in_per_second', template => '%.2f', - unit => '/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, - ], + { label => 'msg_in', template => '%.2f', unit => '/s', min => 0, label_extra_instance => 1, instance_use => 'display' } + ] } }, { label => 'msg-out', set => { - key_values => [ { name => 'out', diff => 1 }, { name => 'display' } ], - output_template => 'Out : %.2f/s', per_second => 1, + key_values => [ { name => 'out', per_second => 1 }, { name => 'display' } ], + output_template => 'Out : %.2f/s', perfdatas => [ - { label => 'msg_out', value => 'out_per_second', template => '%.2f', - unit => '/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, - ], + { label => 'msg_out', template => '%.2f', unit => '/s', min => 0, label_extra_instance => 1, instance_use => 'display' } + ] } - }, + } ]; } diff --git a/network/stonesoft/snmp/mode/connections.pm b/network/stonesoft/snmp/mode/connections.pm index 0a9127d30..c09c6f683 100644 --- a/network/stonesoft/snmp/mode/connections.pm +++ b/network/stonesoft/snmp/mode/connections.pm @@ -38,21 +38,18 @@ sub set_counters { key_values => [ { name => 'fwConnNumber', diff => 1 } ], output_template => 'Connections : %s', perfdatas => [ - { label => 'connections', value => 'fwConnNumber_absolute', template => '%s', - unit => 'con', min => 0 }, + { label => 'connections', template => '%s', unit => 'con', min => 0 }, ], } }, { label => 'rate-connections', nlabel => 'connections.total.persecond', set => { - key_values => [ { name => 'fwConnNumber', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'fwConnNumber', per_second => 1 } ], output_template => 'Rate Connections : %.2f /s', perfdatas => [ - { label => 'rate_connections', value => 'fwConnNumber_per_second', template => '%.2f', - unit => 'con/s', min => 0 }, + { label => 'rate_connections', template => '%.2f', unit => 'con/s', min => 0 } ], } - }, + } ]; } @@ -60,7 +57,7 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; - + $options{options}->add_options(arguments => { }); diff --git a/network/stonesoft/snmp/mode/droppedpackets.pm b/network/stonesoft/snmp/mode/droppedpackets.pm index 11b46aae1..f346379ea 100644 --- a/network/stonesoft/snmp/mode/droppedpackets.pm +++ b/network/stonesoft/snmp/mode/droppedpackets.pm @@ -93,17 +93,17 @@ sub run { $time_delta = 1; } - my $dropped_absolute = $new_datas->{dropped_packets} - $old_datas->{old_dropped_packets}; - my $dropped_absolute_per_sec = $dropped_absolute / $time_delta; + my $dropped = $new_datas->{dropped_packets} - $old_datas->{old_dropped_packets}; + my $dropped_per_sec = $dropped / $time_delta; - my $exit = $self->{perfdata}->threshold_check(value => $dropped_absolute_per_sec, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + my $exit = $self->{perfdata}->threshold_check(value => $dropped_per_sec, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); $self->{output}->output_add(severity => $exit, short_msg => sprintf("Packets Dropped : %.2f /s [%i packets]", - $dropped_absolute_per_sec, $dropped_absolute)); + $dropped_per_sec, $dropped)); $self->{output}->perfdata_add(label => 'dropped_packets_per_sec', - value => sprintf("%.2f", $dropped_absolute_per_sec), + value => sprintf("%.2f", $dropped_per_sec), warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), min => 0); diff --git a/network/stonesoft/snmp/mode/rejectedpackets.pm b/network/stonesoft/snmp/mode/rejectedpackets.pm index 8f92ac917..ce320b51b 100644 --- a/network/stonesoft/snmp/mode/rejectedpackets.pm +++ b/network/stonesoft/snmp/mode/rejectedpackets.pm @@ -93,17 +93,17 @@ sub run { $time_delta = 1; } - my $rejected_absolute = $new_datas->{rejected_packets} - $old_datas->{old_rejected_packets}; - my $rejected_absolute_per_sec = $rejected_absolute / $time_delta; + my $rejected = $new_datas->{rejected_packets} - $old_datas->{old_rejected_packets}; + my $rejected_per_sec = $rejected / $time_delta; - my $exit = $self->{perfdata}->threshold_check(value => $rejected_absolute_per_sec, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); + my $exit = $self->{perfdata}->threshold_check(value => $rejected_per_sec, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); $self->{output}->output_add(severity => $exit, short_msg => sprintf("Packets Rejected : %.2f /s [%i packets]", - $rejected_absolute_per_sec, $rejected_absolute)); + $rejected_per_sec, $rejected)); $self->{output}->perfdata_add(label => 'rejected_packets_per_sec', - value => sprintf("%.2f", $rejected_absolute_per_sec), + value => sprintf("%.2f", $rejected_per_sec), warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), min => 0); diff --git a/network/stormshield/local/mode/qosusage.pm b/network/stormshield/local/mode/qosusage.pm index aa0333c19..f5102a867 100644 --- a/network/stormshield/local/mode/qosusage.pm +++ b/network/stormshield/local/mode/qosusage.pm @@ -46,8 +46,8 @@ sub set_counters { output_template => 'In Peak : %s %s/s', output_change_bytes => 2, perfdatas => [ - { label => 'traffic_in_peak', value => 'in_peak_absolute', template => '%.2f', - unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_in_peak', value => 'in_peak', template => '%.2f', + unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -64,8 +64,8 @@ sub set_counters { output_template => 'Out Peak : %s %s/s', output_change_bytes => 2, perfdatas => [ - { label => 'traffic_out_peak', value => 'out_peak_absolute', template => '%.2f', - unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_out_peak', value => 'out_peak', template => '%.2f', + unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/network/stormshield/snmp/mode/connections.pm b/network/stormshield/snmp/mode/connections.pm index 4b4afa366..54b1b1441 100644 --- a/network/stormshield/snmp/mode/connections.pm +++ b/network/stormshield/snmp/mode/connections.pm @@ -34,25 +34,21 @@ sub set_counters { ]; $self->{maps_counters}->{global} = [ { label => 'udp', set => { - key_values => [ { name => 'udp', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'udp', per_second => 1 } ], output_template => 'UDP : %d connections/s', perfdatas => [ - { label => 'udp', value => 'udp_per_second', template => '%d', - min => 0, unit => 'con' }, - ], + { label => 'udp', template => '%d', min => 0, unit => 'con' } + ] } }, { label => 'tcp', set => { - key_values => [ { name => 'tcp', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'tcp', per_second => 1 } ], output_template => 'TCP : %d connections/s', perfdatas => [ - { label => 'tcp', value => 'tcp_per_second', template => '%d', - min => 0, unit => 'con' }, - ], + { label => 'tcp', template => '%d', min => 0, unit => 'con' } + ] } - }, + } ]; } @@ -61,9 +57,9 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; - $options{options}->add_options(arguments => - { - }); + $options{options}->add_options(arguments => { + }); + return $self; } diff --git a/network/stormshield/snmp/mode/hanodes.pm b/network/stormshield/snmp/mode/hanodes.pm index 02dc27f9e..d108d1065 100644 --- a/network/stormshield/snmp/mode/hanodes.pm +++ b/network/stormshield/snmp/mode/hanodes.pm @@ -108,8 +108,8 @@ sub set_counters { key_values => [ { name => 'ntqHAQuality' }, { name => 'display' } ], output_template => 'health: %s%%', perfdatas => [ - { label => 'health', value => 'ntqHAQuality_absolute', template => '%d', min => 0, max => 100, - unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'health', value => 'ntqHAQuality', template => '%d', min => 0, max => 100, + unit => '%', label_extra_instance => 1, instance_use => 'display' }, ], } } diff --git a/network/stormshield/snmp/mode/vpnstatus.pm b/network/stormshield/snmp/mode/vpnstatus.pm index 0e870b45a..6b32b6cb7 100644 --- a/network/stormshield/snmp/mode/vpnstatus.pm +++ b/network/stormshield/snmp/mode/vpnstatus.pm @@ -51,18 +51,17 @@ sub set_counters { key_values => [ { name => 'ntqVPNState' } ], closure_custom_calc => $self->can('custom_status_calc'), output_template => 'status: %s', output_error_template => 'Status : %s', - output_use => 'ntqVPNState', closure_custom_perfdata => sub { return 0; }, closure_custom_threshold_check => $self->can('custom_threshold_output'), } }, { label => 'traffic', nlabel => 'vpn.traffic.bitspersecond', set => { - key_values => [ { name => 'ntqVPNBytes', diff => 1 }, { name => 'num' } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'ntqVPNBytes', per_second => 1 }, { name => 'num' } ], output_template => 'traffic: %s %s/s', + output_change_bytes => 2, perfdatas => [ - { label => 'traffic', value => 'ntqVPNBytes_per_second', template => '%s', - unit => 'b/s', min => 0, label_extra_instance => 1, cast_int => 1, instance_use => 'num_absolute' }, + { label => 'traffic', template => '%s', + unit => 'b/s', min => 0, label_extra_instance => 1, cast_int => 1, instance_use => 'num' }, ], } }, @@ -90,10 +89,10 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - "filter-id:s" => { name => 'filter_id' }, - "filter-src-ip:s" => { name => 'filter_src_ip' }, - "filter-dst-ip:s" => { name => 'filter_dst_ip' }, - "threshold-overload:s@" => { name => 'threshold_overload' }, + 'filter-id:s' => { name => 'filter_id' }, + 'filter-src-ip:s' => { name => 'filter_src_ip' }, + 'filter-dst-ip:s' => { name => 'filter_dst_ip' }, + 'threshold-overload:s@' => { name => 'threshold_overload' }, }); return $self; diff --git a/network/teltonika/snmp/mode/system.pm b/network/teltonika/snmp/mode/system.pm index 5604db4e8..e11ce4734 100644 --- a/network/teltonika/snmp/mode/system.pm +++ b/network/teltonika/snmp/mode/system.pm @@ -58,35 +58,33 @@ sub set_counters { key_values => [ { name => 'signal' } ], output_template => 'signal strength: %s Dbm', perfdatas => [ - { value => 'signal_absolute', template => '%s', min => 0 , unit => 'Dbm' }, - ], + { template => '%s', min => 0 , unit => 'Dbm' }, + ] } }, { label => 'temperature', nlabel => 'system.temperature.celsius', display_ok => 0, set => { key_values => [ { name => 'temperature' } ], output_template => 'temperature: %s C', perfdatas => [ - { value => 'temperature_absolute', template => '%s', min => 0 , unit => 'C' }, + { template => '%s', min => 0 , unit => 'C' }, ], } }, { label => 'traffic-in', nlabel => 'system.traffic.in.bitspersecond', display_ok => 0, set => { - key_values => [ { name => 'traffic_in', diff => 1 } ], + key_values => [ { name => 'traffic_in', per_second => 1 } ], output_template => 'traffic in: %s %s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { value => 'traffic_in_per_second', template => '%s', - min => 0, unit => 'b/s' }, + { template => '%s', min => 0, unit => 'b/s' }, ], } }, { label => 'traffic-out', nlabel => 'system.traffic.out.bitspersecond', display_ok => 0, set => { - key_values => [ { name => 'traffic_out', diff => 1 } ], + key_values => [ { name => 'traffic_out', per_second => 1 } ], output_template => 'traffic out: %s %s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { value => 'traffic_out_per_second', template => '%s', - min => 0, unit => 'b/s' }, + { template => '%s', min => 0, unit => 'b/s' }, ], } }, @@ -94,7 +92,7 @@ sub set_counters { key_values => [ { name => 'rsrp' } ], output_template => 'signal receive power: %s Dbm', perfdatas => [ - { value => 'rsrp_absolute', template => '%s', min => 0 , unit => 'Dbm' }, + { template => '%s', min => 0 , unit => 'Dbm' }, ], } }, @@ -102,7 +100,7 @@ sub set_counters { key_values => [ { name => 'rsrq' } ], output_template => 'signal receive quality: %s Dbm', perfdatas => [ - { value => 'rsrq_absolute', template => '%s', min => 0 , unit => 'Dbm' }, + { template => '%s', min => 0 , unit => 'Dbm' }, ], } }, diff --git a/network/ucopia/wlc/snmp/mode/system.pm b/network/ucopia/wlc/snmp/mode/system.pm index dad2352fd..5ebfe22cb 100644 --- a/network/ucopia/wlc/snmp/mode/system.pm +++ b/network/ucopia/wlc/snmp/mode/system.pm @@ -48,8 +48,8 @@ sub custom_users_output { my ($self, %options) = @_; my $msg = sprintf("%d connected users (Available licence: %s)", - $self->{result_values}->{connected_users_absolute}, - $self->{result_values}->{max_users_absolute} ne '' ? $self->{result_values}->{max_users_absolute} : '-' + $self->{result_values}->{connected_users}, + $self->{result_values}->{max_users} ne '' ? $self->{result_values}->{max_users} : '-' ); return $msg; } @@ -67,7 +67,7 @@ sub set_counters { key_values => [ { name => 'connected_users' }, { name => 'max_users' } ], closure_custom_output => $self->can('custom_users_output'), perfdatas => [ - { value => 'connected_users_absolute', template => '%s', min => 0, max => 'max_users_absolute' }, + { value => 'connected_users', template => '%s', min => 0, max => 'max_users' }, ], } }, @@ -75,7 +75,7 @@ sub set_counters { key_values => [ { name => 'connected_users_prct' } ], output_template => 'users connected: %.2f %%', perfdatas => [ - { value => 'connected_users_prct_absolute', template => '%.2f', unit => '%', min => 0, max => 100 }, + { value => 'connected_users_prct', template => '%.2f', unit => '%', min => 0, max => 100 }, ], } }, @@ -91,7 +91,7 @@ sub set_counters { key_values => [ { name => 'disk_temperature', no_value => 0 } ], output_template => 'disk temperature: %s C', perfdatas => [ - { value => 'disk_temperature_absolute', template => '%s', unit => 'C' }, + { value => 'disk_temperature', template => '%s', unit => 'C' }, ], } }, @@ -99,7 +99,7 @@ sub set_counters { key_values => [ { name => 'cpu_temperature', no_value => 0 } ], output_template => 'cpu temperature: %s C', perfdatas => [ - { value => 'cpu_temperature_absolute', template => '%s', unit => 'C' }, + { value => 'cpu_temperature', template => '%s', unit => 'C' }, ], } }, diff --git a/network/watchguard/snmp/mode/cpu.pm b/network/watchguard/snmp/mode/cpu.pm index 6d5675d91..c1a5fce9e 100644 --- a/network/watchguard/snmp/mode/cpu.pm +++ b/network/watchguard/snmp/mode/cpu.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => '1min' } ], output_template => '1 minute : %.2f %%', perfdatas => [ - { label => 'cpu_1min', value => '1min_absolute', template => '%.2f', + { label => 'cpu_1min', value => '1min', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => '5min' } ], output_template => '5 minutes : %.2f %%', perfdatas => [ - { label => 'cpu_5min', value => '5min_absolute', template => '%.2f', + { label => 'cpu_5min', value => '5min', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } @@ -55,7 +55,7 @@ sub set_counters { key_values => [ { name => '15min' } ], output_template => '15 minutes : %.2f %%', perfdatas => [ - { label => 'cpu_15min', value => '15min_absolute', template => '%.2f', + { label => 'cpu_15min', value => '15min', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } diff --git a/network/watchguard/snmp/mode/ipsectunnel.pm b/network/watchguard/snmp/mode/ipsectunnel.pm index 24696faa6..ce301cab9 100644 --- a/network/watchguard/snmp/mode/ipsectunnel.pm +++ b/network/watchguard/snmp/mode/ipsectunnel.pm @@ -40,30 +40,28 @@ sub set_counters { key_values => [ { name => 'total' } ], output_template => 'Total Tunnels: %s', perfdatas => [ - { label => 'total_tunnels', value => 'total_absolute', template => '%s', - min => 0 }, - ], + { template => '%s', min => 0 } + ] } - }, + } ]; + $self->{maps_counters}->{tunnel} = [ { label => 'tunnel-traffic-in', nlabel => 'ipsec.tunnel.traffic.in.bitspersecond', set => { - key_values => [ { name => 'wgIpsecTunnelInKbytes', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'wgIpsecTunnelInKbytes', per_second => 1 }, { name => 'display' } ], output_template => 'Traffic In : %s %s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { value => 'wgIpsecTunnelInKbytes_per_second', template => '%s', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { template => '%s', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'tunnel-traffic-out', nlabel => 'ipsec.tunnel.traffic.out.bitspersecond', set => { - key_values => [ { name => 'wgIpsecTunnelOutKbytes', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'wgIpsecTunnelOutKbytes', per_second => 1 }, { name => 'display' } ], output_template => 'Traffic Out : %s %s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { value => 'wgIpsecTunnelOutKbytes_per_second', template => '%s', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { template => '%s', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -82,7 +80,7 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - 'filter-name:s' => { name => 'filter_name' }, + 'filter-name:s' => { name => 'filter_name' } }); return $self; diff --git a/network/watchguard/snmp/mode/policyusage.pm b/network/watchguard/snmp/mode/policyusage.pm index 5116a589b..8e9e8a75b 100644 --- a/network/watchguard/snmp/mode/policyusage.pm +++ b/network/watchguard/snmp/mode/policyusage.pm @@ -38,8 +38,7 @@ sub set_counters { key_values => [ { name => 'wgPolicyCurrActiveConns' }, { name => 'display' } ], output_template => 'Current connections : %s', perfdatas => [ - { label => 'current_connections', value => 'wgPolicyCurrActiveConns_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'current_connections', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -47,28 +46,25 @@ sub set_counters { key_values => [ { name => 'wgPolicyActiveStreams', diff => 1 }, { name => 'display' } ], output_template => 'Total connections : %s', perfdatas => [ - { label => 'total_connections', value => 'wgPolicyActiveStreams_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'total_connections', template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'l3-traffic', set => { - key_values => [ { name => 'wgPolicyL3PackageBytes', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'wgPolicyL3PackageBytes', per_second => 1 }, { name => 'display' } ], output_template => 'L3 Traffic : %s %s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_l3', value => 'wgPolicyL3PackageBytes_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_l3', template => '%.2f', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'l2-traffic', set => { - key_values => [ { name => 'wgPolicyL2PackageBytes', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'wgPolicyL2PackageBytes', per_second => 1 }, { name => 'display' } ], output_template => 'L2 Traffic : %s %s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_l2', value => 'wgPolicyL2PackageBytes_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_l2', template => '%.2f', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -79,12 +75,11 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; - - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - }); - + + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' } + }); + return $self; } diff --git a/network/watchguard/snmp/mode/system.pm b/network/watchguard/snmp/mode/system.pm index a7deb0872..1c67053cc 100644 --- a/network/watchguard/snmp/mode/system.pm +++ b/network/watchguard/snmp/mode/system.pm @@ -38,28 +38,25 @@ sub set_counters { key_values => [ { name => 'connections' } ], output_template => 'Current connections : %s', perfdatas => [ - { label => 'current_connections', value => 'connections_absolute', template => '%s', - min => 0 }, + { label => 'current_connections', template => '%s', min => 0 }, ], } }, { label => 'in-traffic', set => { - key_values => [ { name => 'in_traffic', diff => 1 } ], + key_values => [ { name => 'in_traffic', per_second => 1 } ], output_template => 'Traffic In : %s %s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_in', value => 'in_traffic_per_second', template => '%s', - min => 0, unit => 'b/s' }, + { label => 'traffic_in', template => '%s', min => 0, unit => 'b/s' }, ], } }, { label => 'out-traffic', set => { - key_values => [ { name => 'out_traffic', diff => 1 } ], + key_values => [ { name => 'out_traffic', per_second => 1 } ], output_template => 'Traffic Out : %s %s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_out', value => 'out_traffic_per_second', template => '%s', - min => 0, unit => 'b/s' }, + { label => 'traffic_out', template => '%s', min => 0, unit => 'b/s' }, ], } }, @@ -70,11 +67,10 @@ sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; - - $options{options}->add_options(arguments => - { - }); - + + $options{options}->add_options(arguments => { + }); + return $self; } diff --git a/network/zyxel/snmp/mode/cpu.pm b/network/zyxel/snmp/mode/cpu.pm index 0746b364f..3844b351f 100644 --- a/network/zyxel/snmp/mode/cpu.pm +++ b/network/zyxel/snmp/mode/cpu.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'usage_5s' } ], output_template => '%.2f %% (5sec)', output_error_template => "%s (5sec)", perfdatas => [ - { label => 'cpu_5s', value => 'usage_5s_absolute', template => '%.2f', + { label => 'cpu_5s', value => 'usage_5s', template => '%.2f', unit => '%', min => 0, max => 100 }, ], } @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'usage_1m' } ], output_template => '%.2f %% (1m)', output_error_template => "%s (1min)", perfdatas => [ - { label => 'cpu_1m', value => 'usage_1m_absolute', template => '%.2f', + { label => 'cpu_1m', value => 'usage_1m', template => '%.2f', unit => '%', min => 0, max => 100 }, ], } @@ -55,7 +55,7 @@ sub set_counters { key_values => [ { name => 'usage_5m' } ], output_template => '%.2f %% (5min)', output_error_template => "%s (5min)", perfdatas => [ - { label => 'cpu_5m', value => 'usage_5m_absolute', template => '%.2f', + { label => 'cpu_5m', value => 'usage_5m', template => '%.2f', unit => '%', min => 0, max => 100 }, ], } diff --git a/network/zyxel/snmp/mode/memory.pm b/network/zyxel/snmp/mode/memory.pm index 33f149105..fe1db266f 100644 --- a/network/zyxel/snmp/mode/memory.pm +++ b/network/zyxel/snmp/mode/memory.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'ram_used' } ], output_template => 'Memory Used: %.2f%%', perfdatas => [ - { label => 'memory_used', value => 'ram_used_absolute', template => '%.2f', + { label => 'memory_used', value => 'ram_used', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'flash_used' } ], output_template => 'Flash Used: %.2f%%', perfdatas => [ - { label => 'flash_used', value => 'flash_used_absolute', template => '%.2f', + { label => 'flash_used', value => 'flash_used', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } diff --git a/network/zyxel/snmp/mode/sessions.pm b/network/zyxel/snmp/mode/sessions.pm index 871522364..678306188 100644 --- a/network/zyxel/snmp/mode/sessions.pm +++ b/network/zyxel/snmp/mode/sessions.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'sessions' } ], output_template => 'Current active sessions : %s', perfdatas => [ - { label => 'sessions', value => 'sessions_absolute', template => '%s', min => 0 }, + { label => 'sessions', value => 'sessions', template => '%s', min => 0 }, ], } }, diff --git a/network/zyxel/snmp/mode/vpnstatus.pm b/network/zyxel/snmp/mode/vpnstatus.pm index c48504492..ff45d6f14 100644 --- a/network/zyxel/snmp/mode/vpnstatus.pm +++ b/network/zyxel/snmp/mode/vpnstatus.pm @@ -60,22 +60,19 @@ sub set_counters { } }, { label => 'traffic-in', set => { - key_values => [ { name => 'traffic_in', diff => 1 }, { name => 'display' } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'traffic_in', per_second => 1 }, { name => 'display' } ], output_template => 'Traffic In: %s %s/s', perfdatas => [ - { label => 'traffic_in', value => 'traffic_in_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_in', template => '%.2f', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'traffic-out', set => { - key_values => [ { name => 'traffic_out', diff => 1 }, { name => 'display' } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'traffic_out', per_second => 1 }, { name => 'display' } ], output_template => 'Traffic Out: %s %s/s', + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_out', value => 'traffic_out_per_second', template => '%.2f', - min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_out', template => '%.2f', min => 0, unit => 'b/s', label_extra_instance => 1, instance_use => 'display' }, ], } } @@ -93,12 +90,12 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); bless $self, $class; - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - "warning-status:s" => { name => 'warning_status', default => '' }, - "critical-status:s" => { name => 'critical_status', default => '%{connectstatus} eq "disconnected"' }, - }); + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '%{connectstatus} eq "disconnected"' } + }); + return $self; } diff --git a/os/aix/local/mode/inodes.pm b/os/aix/local/mode/inodes.pm index d350a6f2d..41edea786 100644 --- a/os/aix/local/mode/inodes.pm +++ b/os/aix/local/mode/inodes.pm @@ -38,8 +38,8 @@ sub set_counters { key_values => [ { name => 'used' }, { name => 'display' } ], output_template => 'Used: %s %%', perfdatas => [ - { label => 'used', value => 'used_absolute', template => '%d', - unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'used', value => 'used', template => '%d', + unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/os/aix/local/mode/process.pm b/os/aix/local/mode/process.pm index ced007f47..8bab5d2a1 100644 --- a/os/aix/local/mode/process.pm +++ b/os/aix/local/mode/process.pm @@ -55,7 +55,7 @@ sub set_counters { key_values => [ { name => 'total' } ], output_template => 'Number of current processes: %s', perfdatas => [ - { value => 'total_absolute', template => '%s', min => 0 }, + { value => 'total', template => '%s', min => 0 }, ], } }, diff --git a/os/aix/snmp/mode/swap.pm b/os/aix/snmp/mode/swap.pm index f0678df34..87cf893a4 100644 --- a/os/aix/snmp/mode/swap.pm +++ b/os/aix/snmp/mode/swap.pm @@ -76,7 +76,7 @@ sub set_counters { key_values => [ { name => 'nactive' }, { name => 'ntotal' } ], output_template => 'Total page space active : %s', perfdatas => [ - { label => 'total_active', value => 'nactive_absolute', template => '%s', + { label => 'total_active', value => 'nactive', template => '%s', min => 0, max => 'ntotal' }, ], } diff --git a/os/hpux/local/mode/inodes.pm b/os/hpux/local/mode/inodes.pm index 0664f8733..120376fae 100644 --- a/os/hpux/local/mode/inodes.pm +++ b/os/hpux/local/mode/inodes.pm @@ -38,8 +38,8 @@ sub set_counters { key_values => [ { name => 'used' }, { name => 'display' } ], output_template => 'Used: %s %%', perfdatas => [ - { label => 'used', value => 'used_absolute', template => '%d', - unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'used', value => 'used', template => '%d', + unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/os/linux/local/mode/directlvmusage.pm b/os/linux/local/mode/directlvmusage.pm index 81e8160d2..216c496c9 100644 --- a/os/linux/local/mode/directlvmusage.pm +++ b/os/linux/local/mode/directlvmusage.pm @@ -38,8 +38,8 @@ sub set_counters { key_values => [ { name => 'data' }, { name => 'display' } ], output_template => 'Data Usage : %.2f %%', perfdatas => [ - { label => 'data_used', value => 'data_absolute', template => '%.2f', - unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'data_used', value => 'data', template => '%.2f', + unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -47,8 +47,8 @@ sub set_counters { key_values => [ { name => 'meta' }, { name => 'display' } ], output_template => 'Meta Usage : %.2f %%', perfdatas => [ - { label => 'meta_used', value => 'meta_absolute', template => '%.2f', - unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'meta_used', value => 'meta', template => '%.2f', + unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/os/linux/local/mode/diskio.pm b/os/linux/local/mode/diskio.pm index 5aa7d4c08..085b360f6 100644 --- a/os/linux/local/mode/diskio.pm +++ b/os/linux/local/mode/diskio.pm @@ -69,7 +69,7 @@ sub set_counters { key_values => [ { name => 'read_sectors', diff => 1 }, { name => 'display' } ], closure_custom_calc => $self->can('custom_usage_calc'), closure_custom_calc_extra_options => { label_ref => 'read' }, output_template => 'read I/O : %s %s/s', - output_change_bytes => 1, per_second => 1, + output_change_bytes => 1, output_use => 'usage_persecond', threshold_use => 'usage_persecond', perfdatas => [ { label => 'readio', value => 'usage_persecond', template => '%d', @@ -81,7 +81,7 @@ sub set_counters { key_values => [ { name => 'write_sectors', diff => 1 }, { name => 'display' } ], closure_custom_calc => $self->can('custom_usage_calc'), closure_custom_calc_extra_options => { label_ref => 'write' }, output_template => 'write I/O : %s %s/s', - output_change_bytes => 1, per_second => 1, + output_change_bytes => 1, output_use => 'usage_persecond', threshold_use => 'usage_persecond', perfdatas => [ { label => 'writeio', value => 'usage_persecond', template => '%d', @@ -93,8 +93,8 @@ sub set_counters { key_values => [ { name => 'read_ms', diff => 1 }, { name => 'display' } ], output_template => 'read time : %.2f ms', perfdatas => [ - { label => 'readtime', value => 'read_ms_absolute', template => '%.2f', - unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'readtime', template => '%.2f', + unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -102,8 +102,8 @@ sub set_counters { key_values => [ { name => 'write_ms', diff => 1 }, { name => 'display' } ], output_template => 'write time : %.2f ms', perfdatas => [ - { label => 'writetime', value => 'write_ms_absolute', template => '%.2f', - unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'writetime', template => '%.2f', + unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -118,7 +118,6 @@ sub set_counters { { name => 'display' } ], closure_custom_calc => $self->can('custom_utils_calc'), - per_second => 1, output_template => '%%utils: %.2f %%', output_use => 'utils', threshold_use => 'utils', perfdatas => [ @@ -199,7 +198,7 @@ sub manage_selection { } $self->{device} = {}; - while ($disk_parts =~ /^\s*\S+\s+\S+\s+(\S+)\s+\S+\s+\S+\s+(\S+)\s+(\S+)\s+\S+\s+\S+\s+(\S+)\s+(\S+)\s+\S+\s+\S+\s+(\S+)\s*$/msg) { + while ($disk_parts =~ /^\s*\S+\s+\S+\s+(\S+)\s+\S+\s+\S+\s+(\S+)\s+(\S+)\s+\S+\s+\S+\s+(\S+)\s+(\S+)\s+\S+\s+\S+\s+(\S+)\s*/msg) { my ($partition_name, $read_sector, $write_sector, $read_ms, $write_ms, $ms_ticks) = ($1, $2, $4, $3, $5, $6); next if (defined($self->{option_results}->{name}) && defined($self->{option_results}->{use_regexp}) && defined($self->{option_results}->{use_regexpi}) @@ -228,7 +227,7 @@ sub manage_selection { cpu_iowait => $cpu_iowait, }; } - + if (scalar(keys %{$self->{device}}) <= 0) { if (defined($self->{option_results}->{name})) { $self->{output}->add_option_msg(short_msg => "No device found for name '" . $self->{option_results}->{name} . "'."); diff --git a/os/linux/local/mode/inodes.pm b/os/linux/local/mode/inodes.pm index 9b51a3f67..0014f110a 100644 --- a/os/linux/local/mode/inodes.pm +++ b/os/linux/local/mode/inodes.pm @@ -38,8 +38,8 @@ sub set_counters { key_values => [ { name => 'used' }, { name => 'display' } ], output_template => 'Used: %s %%', perfdatas => [ - { label => 'used', value => 'used_absolute', template => '%d', - unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'used', value => 'used', template => '%d', + unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/os/linux/local/mode/ntp.pm b/os/linux/local/mode/ntp.pm index ec09bdc88..dbc9e5383 100644 --- a/os/linux/local/mode/ntp.pm +++ b/os/linux/local/mode/ntp.pm @@ -101,18 +101,18 @@ sub custom_status_calc { sub custom_offset_perfdata { my ($self, %options) = @_; - if ($self->{result_values}->{state_absolute} ne '*') { + if ($self->{result_values}->{state} ne '*') { $self->{output}->perfdata_add( label => 'offset', unit => 'ms', - instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display_absolute} : undef, - value => $self->{result_values}->{offset_absolute}, + instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef, + value => $self->{result_values}->{offset}, min => 0 ); } else { $self->{output}->perfdata_add( label => 'offset', unit => 'ms', - instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display_absolute} : undef, - value => $self->{result_values}->{offset_absolute}, + instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef, + value => $self->{result_values}->{offset}, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}), min => 0 @@ -123,10 +123,10 @@ sub custom_offset_perfdata { sub custom_offset_threshold { my ($self, %options) = @_; - if ($self->{result_values}->{state_absolute} ne '*') { + if ($self->{result_values}->{state} ne '*') { return 'ok'; } - return $self->{perfdata}->threshold_check(value => $self->{result_values}->{offset_absolute}, threshold => [ { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, { label => 'warning-'. $self->{thlabel}, exit_litteral => 'warning' } ]); + return $self->{perfdata}->threshold_check(value => $self->{result_values}->{offset}, threshold => [ { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, { label => 'warning-'. $self->{thlabel}, exit_litteral => 'warning' } ]); } sub set_counters { @@ -142,7 +142,7 @@ sub set_counters { key_values => [ { name => 'peers' } ], output_template => 'Number of ntp peers : %d', perfdatas => [ - { label => 'peers', value => 'peers_absolute', template => '%d', + { label => 'peers', value => 'peers', template => '%d', min => 0 }, ], } @@ -164,8 +164,8 @@ sub set_counters { closure_custom_threshold_check => $self->can('custom_offset_threshold'), closure_custom_perfdata => $self->can('custom_offset_perfdata'), perfdatas => [ - { label => 'offset', value => 'offset_absolute', template => '%s', - min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'offset', value => 'offset', template => '%s', + min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -173,8 +173,8 @@ sub set_counters { key_values => [ { name => 'stratum' }, { name => 'display' } ], output_template => 'Stratum : %s', perfdatas => [ - { label => 'stratum', value => 'stratum_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'stratum', value => 'stratum', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/os/linux/local/mode/openfiles.pm b/os/linux/local/mode/openfiles.pm index c3c4106f5..97fa8e3f8 100644 --- a/os/linux/local/mode/openfiles.pm +++ b/os/linux/local/mode/openfiles.pm @@ -38,7 +38,7 @@ sub set_counters { key_values => [ { name => 'openfiles' } ], output_template => 'current open files: %s', perfdatas => [ - { value => 'openfiles_absolute', template => '%s', min => 0 }, + { value => 'openfiles', template => '%s', min => 0 }, ], } }, diff --git a/os/linux/local/mode/paging.pm b/os/linux/local/mode/paging.pm index 32bfbb1a2..caf1c231b 100644 --- a/os/linux/local/mode/paging.pm +++ b/os/linux/local/mode/paging.pm @@ -36,56 +36,56 @@ sub set_counters { $self->{maps_counters}->{global} = [ { label => 'pgpgin', nlabel => 'system.pgpin.usage.bytespersecond', set => { - key_values => [ { name => 'pgpgin', diff => 1 } ], - output_template => 'pgpgin : %s %s/s', per_second => 1, output_change_bytes => 1, + key_values => [ { name => 'pgpgin', per_second => 1 } ], + output_template => 'pgpgin : %s %s/s', + output_change_bytes => 1, perfdatas => [ - { value => 'pgpgin_per_second', label => 'pgpgin', template => '%d', - unit => 'B/s', min => 0 }, + { label => 'pgpgin', template => '%d', unit => 'B/s', min => 0 }, ], } }, { label => 'pgpgout', nlabel => 'system.pgpgout.usage.bytespersecond', set => { - key_values => [ { name => 'pgpgout', diff => 1 } ], - output_template => 'pgpgout : %s %s/s', per_second => 1, output_change_bytes => 1, + key_values => [ { name => 'pgpgout', per_second => 1 } ], + output_template => 'pgpgout : %s %s/s', + output_change_bytes => 1, perfdatas => [ - { value => 'pgpgout_per_second', label => 'pgpgout', template => '%d', - unit => 'B/s', min => 0 }, + { label => 'pgpgout', template => '%d', unit => 'B/s', min => 0 }, ], } }, { label => 'pswpin', nlabel => 'system.pswpin.usage.bytespersecond', set => { - key_values => [ { name => 'pswpin', diff => 1 } ], - output_template => 'pswpin : %s %s/s', per_second => 1, output_change_bytes => 1, + key_values => [ { name => 'pswpin', per_second => 1 } ], + output_template => 'pswpin : %s %s/s', + output_change_bytes => 1, perfdatas => [ - { value => 'pswpin_per_second', label => 'pswpin', template => '%d', - unit => 'B/s', min => 0 }, + { label => 'pswpin', template => '%d', unit => 'B/s', min => 0 }, ], } }, { label => 'pswpout', nlabel => 'system.pswpout.usage.bytespersecond', set => { - key_values => [ { name => 'pswpout', diff => 1 } ], - output_template => 'pswpout : %s %s/s', per_second => 1, output_change_bytes => 1, + key_values => [ { name => 'pswpout', per_second => 1 } ], + output_template => 'pswpout : %s %s/s', + output_change_bytes => 1, perfdatas => [ - { value => 'pswpout_per_second', label => 'pswpout', template => '%d', - unit => 'B/s', min => 0 }, + { label => 'pswpout', template => '%d', unit => 'B/s', min => 0 }, ], } }, { label => 'pgfault', nlabel => 'system.pgfault.usage.bytespersecond', set => { - key_values => [ { name => 'pgfault', diff => 1 } ], - output_template => 'pgfault : %s %s/s', per_second => 1, output_change_bytes => 1, + key_values => [ { name => 'pgfault', per_second => 1 } ], + output_template => 'pgfault : %s %s/s', + output_change_bytes => 1, perfdatas => [ - { value => 'pgfault_per_second', label => 'pgfault', template => '%d', - unit => 'B/s', min => 0 }, + { label => 'pgfault', template => '%d', unit => 'B/s', min => 0 }, ], } }, { label => 'pgmajfault', nlabel => 'system.pgmajfault.usage.bytespersecond', set => { - key_values => [ { name => 'pgmajfault', diff => 1 } ], - output_template => 'pgmajfault : %s %s/s', per_second => 1, output_change_bytes => 1, + key_values => [ { name => 'pgmajfault', per_second => 1 } ], + output_template => 'pgmajfault : %s %s/s', + output_change_bytes => 1, perfdatas => [ - { value => 'pgmajfault_per_second', label => 'pgmajfault', template => '%d', - unit => 'B/s', min => 0 }, + { label => 'pgmajfault', template => '%d', unit => 'B/s', min => 0 }, ], } }, @@ -98,16 +98,16 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - "hostname:s" => { name => 'hostname' }, - "remote" => { name => 'remote' }, - "ssh-option:s@" => { name => 'ssh_option' }, - "ssh-path:s" => { name => 'ssh_path' }, - "ssh-command:s" => { name => 'ssh_command', default => 'ssh' }, - "timeout:s" => { name => 'timeout', default => 30 }, - "sudo" => { name => 'sudo' }, - "command:s" => { name => 'command', default => 'cat' }, - "command-path:s" => { name => 'command_path' }, - "command-options:s" => { name => 'command_options', default => '/proc/vmstat 2>&1' }, + 'hostname:s' => { name => 'hostname' }, + 'remote' => { name => 'remote' }, + 'ssh-option:s@' => { name => 'ssh_option' }, + 'ssh-path:s' => { name => 'ssh_path' }, + 'ssh-command:s' => { name => 'ssh_command', default => 'ssh' }, + 'timeout:s' => { name => 'timeout', default => 30 }, + 'sudo' => { name => 'sudo' }, + 'command:s' => { name => 'command', default => 'cat' }, + 'command-path:s' => { name => 'command_path' }, + 'command-options:s' => { name => 'command_options', default => '/proc/vmstat 2>&1' }, }); return $self; diff --git a/os/linux/local/mode/pendingupdates.pm b/os/linux/local/mode/pendingupdates.pm index bd94dc218..cf0dbfa90 100644 --- a/os/linux/local/mode/pendingupdates.pm +++ b/os/linux/local/mode/pendingupdates.pm @@ -39,7 +39,7 @@ sub set_counters { key_values => [ { name => 'total' } ], output_template => 'Number of pending updates : %d', perfdatas => [ - { label => 'total', value => 'total_absolute', template => '%d', + { label => 'total', value => 'total', template => '%d', min => 0 }, ], } diff --git a/os/linux/local/mode/swap.pm b/os/linux/local/mode/swap.pm index e747e7137..f5c9c4234 100644 --- a/os/linux/local/mode/swap.pm +++ b/os/linux/local/mode/swap.pm @@ -31,11 +31,11 @@ sub custom_swap_output { my $output = sprintf( 'Swap Total: %s %s Used: %s %s (%.2f%%) Free: %s %s (%.2f%%)', - $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_absolute}), - $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_absolute}), - $self->{result_values}->{prct_used_absolute}, - $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute}), - $self->{result_values}->{prct_free_absolute}, + $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}), + $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}), + $self->{result_values}->{prct_used}, + $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}), + $self->{result_values}->{prct_free}, ); return $output; } @@ -53,7 +53,7 @@ sub set_counters { key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], closure_custom_output => $self->can('custom_swap_output'), perfdatas => [ - { label => 'used', value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute', unit => 'B', cast_int => 1 }, + { label => 'used', value => 'used', template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1 }, ], }, }, @@ -61,7 +61,7 @@ sub set_counters { key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], closure_custom_output => $self->can('custom_swap_output'), perfdatas => [ - { label => 'free', value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute', + { label => 'free', value => 'free', template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1 }, ], }, @@ -70,7 +70,7 @@ sub set_counters { key_values => [ { name => 'prct_used' } ], output_template => 'Swap used: %.2f %%', perfdatas => [ - { label => 'used_prct', value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, unit => '%' }, + { label => 'used_prct', value => 'prct_used', template => '%.2f', min => 0, max => 100, unit => '%' }, ], }, }, diff --git a/os/linux/local/mode/systemdscstatus.pm b/os/linux/local/mode/systemdscstatus.pm index 7340c5251..ba0d5fae6 100644 --- a/os/linux/local/mode/systemdscstatus.pm +++ b/os/linux/local/mode/systemdscstatus.pm @@ -64,8 +64,8 @@ sub set_counters { key_values => [ { name => 'running' }, { name => 'total' } ], output_template => 'Total Running: %s', perfdatas => [ - { label => 'total_running', value => 'running_absolute', template => '%s', - min => 0, max => 'total_absolute' }, + { label => 'total_running', value => 'running', template => '%s', + min => 0, max => 'total' }, ], } }, @@ -73,8 +73,8 @@ sub set_counters { key_values => [ { name => 'failed' }, { name => 'total' } ], output_template => 'Total Failed: %s', perfdatas => [ - { label => 'total_failed', value => 'failed_absolute', template => '%s', - min => 0, max => 'total_absolute' }, + { label => 'total_failed', value => 'failed', template => '%s', + min => 0, max => 'total' }, ], } }, @@ -82,8 +82,8 @@ sub set_counters { key_values => [ { name => 'dead' }, { name => 'total' } ], output_template => 'Total Dead: %s', perfdatas => [ - { label => 'total_dead', value => 'dead_absolute', template => '%s', - min => 0, max => 'total_absolute' }, + { label => 'total_dead', value => 'dead', template => '%s', + min => 0, max => 'total' }, ], } }, @@ -91,8 +91,8 @@ sub set_counters { key_values => [ { name => 'exited' }, { name => 'total' } ], output_template => 'Total Exited: %s', perfdatas => [ - { label => 'total_exited', value => 'exited_absolute', template => '%s', - min => 0, max => 'total_absolute' }, + { label => 'total_exited', value => 'exited', template => '%s', + min => 0, max => 'total' }, ], } }, diff --git a/os/linux/local/mode/traffic.pm b/os/linux/local/mode/traffic.pm index d7dfaf2a6..fa75d7eeb 100644 --- a/os/linux/local/mode/traffic.pm +++ b/os/linux/local/mode/traffic.pm @@ -123,7 +123,6 @@ sub set_counters { }, { label => 'in', set => { key_values => [ { name => 'in', diff => 1 }, { name => 'speed_in' }, { name => 'display' } ], - per_second => 1, closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'in' }, closure_custom_output => $self->can('custom_traffic_output'), output_error_template => 'Traffic In : %s', closure_custom_perfdata => $self->can('custom_traffic_perfdata'), @@ -132,7 +131,6 @@ sub set_counters { }, { label => 'out', set => { key_values => [ { name => 'out', diff => 1 }, { name => 'speed_out' }, { name => 'display' } ], - per_second => 1, closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'out' }, closure_custom_output => $self->can('custom_traffic_output'), output_error_template => 'Traffic Out : %s', closure_custom_perfdata => $self->can('custom_traffic_perfdata'), diff --git a/os/windows/local/mode/sessions.pm b/os/windows/local/mode/sessions.pm index bc597df9e..8e8260982 100644 --- a/os/windows/local/mode/sessions.pm +++ b/os/windows/local/mode/sessions.pm @@ -39,7 +39,7 @@ sub set_counters { key_values => [ { name => 'sessions_created', diff => 1 } ], output_template => 'created : %s', perfdatas => [ - { label => 'sessions_created', value => 'sessions_created_absolute', template => '%s', min => 0 }, + { label => 'sessions_created', value => 'sessions_created', template => '%s', min => 0 }, ], } }, @@ -47,7 +47,7 @@ sub set_counters { key_values => [ { name => 'sessions_disconnected', diff => 1 } ], output_template => 'disconnected : %s', perfdatas => [ - { label => 'sessions_disconnected', value => 'sessions_disconnected_absolute', template => '%s', min => 0 }, + { label => 'sessions_disconnected', value => 'sessions_disconnected', template => '%s', min => 0 }, ], } }, @@ -55,7 +55,7 @@ sub set_counters { key_values => [ { name => 'sessions_reconnected', diff => 1 } ], output_template => 'reconnected : %s', perfdatas => [ - { label => 'sessions_reconnected', value => 'sessions_reconnected_absolute', template => '%s', min => 0 }, + { label => 'sessions_reconnected', value => 'sessions_reconnected', template => '%s', min => 0 }, ], } }, @@ -63,7 +63,7 @@ sub set_counters { key_values => [ { name => 'sessions_active' } ], output_template => 'current active : %s', perfdatas => [ - { label => 'sessions_active', value => 'sessions_active_absolute', template => '%s', min => 0 }, + { label => 'sessions_active', value => 'sessions_active', template => '%s', min => 0 }, ], } }, @@ -71,7 +71,7 @@ sub set_counters { key_values => [ { name => 'sessions_disconnected_current' } ], output_template => 'current disconnected : %s', perfdatas => [ - { label => 'sessions_disconnected_current', value => 'sessions_disconnected_current_absolute', + { label => 'sessions_disconnected_current', value => 'sessions_disconnected_current', template => '%s', min => 0 }, ], } diff --git a/snmp_standard/mode/arp.pm b/snmp_standard/mode/arp.pm index cce5164ae..c71d91132 100644 --- a/snmp_standard/mode/arp.pm +++ b/snmp_standard/mode/arp.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'total' } ], output_template => 'total entries %s', perfdatas => [ - { value => 'total_absolute', template => '%s', min => 0 }, + { value => 'total', template => '%s', min => 0 }, ], } }, @@ -45,7 +45,7 @@ sub set_counters { key_values => [ { name => 'duplicate_macaddress' } ], output_template => 'duplicate mac address %s', perfdatas => [ - { value => 'duplicate_macaddress_absolute', template => '%s', min => 0 }, + { value => 'duplicate_macaddress', template => '%s', min => 0 }, ], } }, @@ -53,7 +53,7 @@ sub set_counters { key_values => [ { name => 'duplicate_ipaddress' } ], output_template => 'duplicate ip address %s', perfdatas => [ - { value => 'duplicate_ipaddress_absolute', template => '%s', min => 0 }, + { value => 'duplicate_ipaddress', template => '%s', min => 0 }, ], } }, diff --git a/snmp_standard/mode/cpu.pm b/snmp_standard/mode/cpu.pm index 0c02fc807..8640fce89 100644 --- a/snmp_standard/mode/cpu.pm +++ b/snmp_standard/mode/cpu.pm @@ -38,7 +38,7 @@ sub set_counters { key_values => [ { name => 'average' }, { name => 'count' } ], output_template => '%.2f %%', perfdatas => [ - { label => 'total_cpu_avg', value => 'average_absolute', template => '%.2f', + { label => 'total_cpu_avg', value => 'average', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } @@ -50,8 +50,8 @@ sub set_counters { key_values => [ { name => 'cpu' }, { name => 'display' } ], output_template => 'usage : %.2f %%', perfdatas => [ - { label => 'cpu', value => 'cpu_absolute', template => '%.2f', - min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'cpu', value => 'cpu', template => '%.2f', + min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/snmp_standard/mode/diskio.pm b/snmp_standard/mode/diskio.pm index 27d702177..8d0f20979 100644 --- a/snmp_standard/mode/diskio.pm +++ b/snmp_standard/mode/diskio.pm @@ -36,41 +36,39 @@ sub set_counters { ]; $self->{maps_counters}->{global} = [ { label => 'total-read', set => { - key_values => [ { name => 'total_read', diff => 1 } ], + key_values => [ { name => 'total_read', per_second => 1 } ], output_template => 'Read I/O : %s %s/s', output_error_template => "Read I/O : %s", - output_change_bytes => 1, per_second => 1, + output_change_bytes => 1, perfdatas => [ - { label => 'total_read', value => 'total_read_per_second', template => '%d', + { label => 'total_read', template => '%d', unit => 'B/s', min => 0 }, ], } }, { label => 'total-write', set => { - key_values => [ { name => 'total_write', diff => 1 } ], + key_values => [ { name => 'total_write', per_second => 1 } ], output_template => 'Write I/O : %s %s/s', output_error_template => "Write I/O : %s", - output_change_bytes => 1, per_second => 1, + output_change_bytes => 1, perfdatas => [ - { label => 'total_write', value => 'total_write_per_second', template => '%d', + { label => 'total_write', template => '%d', unit => 'B/s', min => 0 }, ], } }, { label => 'total-read-iops', set => { - key_values => [ { name => 'total_read_iops', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'total_read_iops', per_second => 1 } ], output_template => 'Read IOPs : %.2f', output_error_template => "Read IOPs : %s", perfdatas => [ - { label => 'total_read_iops', value => 'total_read_iops_per_second', template => '%.2f', + { label => 'total_read_iops', template => '%.2f', unit => 'iops', min => 0 }, ], } }, { label => 'total-write-iops', set => { - key_values => [ { name => 'total_write_iops', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'total_write_iops', per_second => 1 } ], output_template => 'Write IOPs : %.2f', output_error_template => "Write IOPs : %s", perfdatas => [ - { label => 'total_write_iops', value => 'total_write_iops_per_second', template => '%.2f', + { label => 'total_write_iops', template => '%.2f', unit => 'iops', min => 0 }, ], } @@ -79,22 +77,20 @@ sub set_counters { $self->{maps_counters}->{sum} = [ { label => 'sum-read-write', set => { - key_values => [ { name => 'sum_read_write', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'sum_read_write', per_second => 1 } ], output_template => 'R+W I/O : %s %s/s', output_error_template => "R+W I/O : %s", output_change_bytes => 1, perfdatas => [ - { label => 'sum_read_write', value => 'sum_read_write_per_second', template => '%d', + { label => 'sum_read_write', template => '%d', unit => 'B/s', min => 0 }, ], } }, { label => 'sum-read-write-iops', set => { - key_values => [ { name => 'sum_read_write_iops', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'sum_read_write_iops', per_second => 1 } ], output_template => 'R+W IOPs : %.2f', output_error_template => "R+W IOPs : %s", perfdatas => [ - { label => 'sum_read_write_iops', value => 'sum_read_write_iops_per_second', template => '%.2f', + { label => 'sum_read_write_iops', template => '%.2f', unit => 'iops', min => 0 }, ], } @@ -103,42 +99,40 @@ sub set_counters { $self->{maps_counters}->{disk} = [ { label => 'read', set => { - key_values => [ { name => 'read', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'read', per_second => 1 }, { name => 'display' } ], output_template => 'Read I/O : %s %s/s', output_error_template => "Read I/O : %s", - output_change_bytes => 1, per_second => 1, + output_change_bytes => 1, perfdatas => [ - { label => 'read', value => 'read_per_second', template => '%d', - unit => 'B/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'read', template => '%d', + unit => 'B/s', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'write', set => { - key_values => [ { name => 'write', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'write', per_second => 1 }, { name => 'display' } ], output_template => 'Write I/O : %s %s/s', output_error_template => "Write I/O : %s", - output_change_bytes => 1, per_second => 1, + output_change_bytes => 1, perfdatas => [ - { label => 'write', value => 'write_per_second', template => '%d', - unit => 'B/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'write', template => '%d', + unit => 'B/s', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'read-iops', set => { - key_values => [ { name => 'read_iops', diff => 1 }, { name => 'display' } ], - per_second => 1, + key_values => [ { name => 'read_iops', per_second => 1 }, { name => 'display' } ], output_template => 'Read IOPs : %.2f', output_error_template => "Read IOPs : %s", perfdatas => [ - { label => 'read_iops', value => 'read_iops_per_second', template => '%.2f', - unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'read_iops', template => '%.2f', + unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'write-iops', set => { - key_values => [ { name => 'write_iops', diff => 1 }, { name => 'display' } ], - per_second => 1, + key_values => [ { name => 'write_iops', per_second => 1 }, { name => 'display' } ], output_template => 'Write IOPs : %.2f', output_error_template => "Write IOPs : %s", perfdatas => [ - { label => 'write_iops', value => 'write_iops_per_second', template => '%.2f', - unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'write_iops', template => '%.2f', + unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -154,7 +148,7 @@ sub new { 'name' => { name => 'use_name' }, 'device:s' => { name => 'device' }, 'regexp' => { name => 'use_regexp' }, - 'regexp-isensitive' => { name => 'use_regexpi' }, + 'regexp-isensitive' => { name => 'use_regexpi' } }); return $self; diff --git a/snmp_standard/mode/diskusage.pm b/snmp_standard/mode/diskusage.pm index b51652272..f5da5b23f 100644 --- a/snmp_standard/mode/diskusage.pm +++ b/snmp_standard/mode/diskusage.pm @@ -30,14 +30,14 @@ use Digest::MD5 qw(md5_hex); sub custom_usage_output { my ($self, %options) = @_; - my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_absolute}); - my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_absolute}); - my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute}); + my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}); + my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}); + my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}); return sprintf( 'Usage Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)', $total_size_value . " " . $total_size_unit, - $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used_absolute}, - $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free_absolute} + $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used}, + $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free} ); } @@ -54,7 +54,7 @@ sub set_counters { key_values => [ { name => 'count' } ], output_template => 'Partitions count : %d', perfdatas => [ - { label => 'count', value => 'count_absolute', template => '%d', min => 0 } + { label => 'count', value => 'count', template => '%d', min => 0 } ] } } @@ -65,8 +65,8 @@ sub set_counters { key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'display' } ], closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ - { label => 'used', value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute', - unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' } + { label => 'used', value => 'used', template => '%d', min => 0, max => 'total', + unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display' } ] } }, @@ -74,8 +74,8 @@ sub set_counters { key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'display' } ], closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ - { label => 'free', value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute', - unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' } + { label => 'free', value => 'free', template => '%d', min => 0, max => 'total', + unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display' } ] } }, @@ -83,8 +83,8 @@ sub set_counters { key_values => [ { name => 'prct_used' }, { name => 'display' } ], output_template => 'Used : %.2f %%', perfdatas => [ - { label => 'used_prct', value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, - unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' } + { label => 'used_prct', value => 'prct_used', template => '%.2f', min => 0, max => 100, + unit => '%', label_extra_instance => 1, instance_use => 'display' } ] } }, @@ -92,8 +92,8 @@ sub set_counters { key_values => [ { name => 'inodes' }, { name => 'display' } ], output_template => 'Inodes Used: %s %%', perfdatas => [ - { label => 'inodes', value => 'inodes_absolute', template => '%d', - unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' } + { label => 'inodes', value => 'inodes', template => '%d', + unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' } ] } } diff --git a/snmp_standard/mode/inodes.pm b/snmp_standard/mode/inodes.pm index ee844de74..5dd6b71e8 100644 --- a/snmp_standard/mode/inodes.pm +++ b/snmp_standard/mode/inodes.pm @@ -37,8 +37,8 @@ sub set_counters { key_values => [ { name => 'usage' }, { name => 'display' } ], output_template => 'Used: %s %%', output_error_template => "%s", perfdatas => [ - { label => 'used', value => 'usage_absolute', template => '%d', - unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'used', value => 'usage', template => '%d', + unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/snmp_standard/mode/interfaces.pm b/snmp_standard/mode/interfaces.pm index b46afc57b..b2b701e41 100644 --- a/snmp_standard/mode/interfaces.pm +++ b/snmp_standard/mode/interfaces.pm @@ -297,50 +297,50 @@ sub set_counters_global { { label => 'total-port', filter => 'add_global', nlabel => 'total.interfaces.count', set => { key_values => [ { name => 'total_port' } ], output_template => 'Total port : %s', output_error_template => 'Total port : %s', - output_use => 'total_port_absolute', threshold_use => 'total_port_absolute', + output_use => 'total_port', threshold_use => 'total_port', perfdatas => [ - { label => 'total_port', value => 'total_port_absolute', template => '%s', - min => 0, max => 'total_port_absolute' } + { label => 'total_port', value => 'total_port', template => '%s', + min => 0, max => 'total_port' } ] } }, { label => 'global-admin-up', filter => 'add_global', nlabel => 'total.interfaces.admin.up.count', set => { key_values => [ { name => 'global_admin_up' }, { name => 'total_port' } ], output_template => 'AdminStatus Up : %s', output_error_template => 'AdminStatus Up : %s', - output_use => 'global_admin_up_absolute', threshold_use => 'global_admin_up_absolute', + output_use => 'global_admin_up', threshold_use => 'global_admin_up', perfdatas => [ - { label => 'total_admin_up', value => 'global_admin_up_absolute', template => '%s', - min => 0, max => 'total_port_absolute' } + { label => 'total_admin_up', value => 'global_admin_up', template => '%s', + min => 0, max => 'total_port' } ] } }, { label => 'total-admin-down', filter => 'add_global', nlabel => 'total.interfaces.admin.down.count', set => { key_values => [ { name => 'global_admin_down' }, { name => 'total_port' } ], output_template => 'AdminStatus Down : %s', output_error_template => 'AdminStatus Down : %s', - output_use => 'global_admin_down_absolute', threshold_use => 'global_admin_down_absolute', + output_use => 'global_admin_down', threshold_use => 'global_admin_down', perfdatas => [ - { label => 'total_admin_down', value => 'global_admin_down_absolute', template => '%s', - min => 0, max => 'total_port_absolute' } + { label => 'total_admin_down', value => 'global_admin_down', template => '%s', + min => 0, max => 'total_port' } ] } }, { label => 'total-oper-up', filter => 'add_global', nlabel => 'total.interfaces.operational.up.count', set => { key_values => [ { name => 'global_oper_up' }, { name => 'total_port' } ], output_template => 'OperStatus Up : %s', output_error_template => 'OperStatus Up : %s', - output_use => 'global_oper_up_absolute', threshold_use => 'global_oper_up_absolute', + output_use => 'global_oper_up', threshold_use => 'global_oper_up', perfdatas => [ - { label => 'total_oper_up', value => 'global_oper_up_absolute', template => '%s', - min => 0, max => 'total_port_absolute' } + { label => 'total_oper_up', value => 'global_oper_up', template => '%s', + min => 0, max => 'total_port' } ] } }, { label => 'total-oper-down', filter => 'add_global', nlabel => 'total.interfaces.operational.down.count', set => { key_values => [ { name => 'global_oper_down' }, { name => 'total_port' } ], output_template => 'OperStatus Down : %s', output_error_template => 'OperStatus Down : %s', - output_use => 'global_oper_down_absolute', threshold_use => 'global_oper_down_absolute', + output_use => 'global_oper_down', threshold_use => 'global_oper_down', perfdatas => [ - { label => 'global_oper_down', value => 'global_oper_down_absolute', template => '%s', - min => 0, max => 'total_port_absolute' } + { label => 'global_oper_down', value => 'global_oper_down', template => '%s', + min => 0, max => 'total_port' } ] } } @@ -370,7 +370,6 @@ sub set_counters_traffic { push @{$self->{maps_counters}->{int}}, { label => 'in-traffic', filter => 'add_traffic', nlabel => 'interface.traffic.in.bitspersecond', set => { key_values => $self->set_key_values_in_traffic(), - per_second => 1, closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'in' }, closure_custom_output => $self->can('custom_traffic_output'), output_error_template => 'Traffic In : %s', closure_custom_perfdata => $self->can('custom_traffic_perfdata'), @@ -379,7 +378,6 @@ sub set_counters_traffic { }, { label => 'out-traffic', filter => 'add_traffic', nlabel => 'interface.traffic.out.bitspersecond', set => { key_values => $self->set_key_values_out_traffic(), - per_second => 1, closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'out' }, closure_custom_output => $self->can('custom_traffic_output'), output_error_template => 'Traffic Out : %s', closure_custom_perfdata => $self->can('custom_traffic_perfdata'), @@ -537,8 +535,8 @@ sub set_counters_volume { output_template => 'Volume In : %.2f %s', output_change_bytes => 1, perfdatas => [ - { label => 'volume_in', value => 'in_volume_absolute', template => '%s', - unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' } + { label => 'volume_in', value => 'in_volume', template => '%s', + unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'display' } ] } }, @@ -547,8 +545,8 @@ sub set_counters_volume { output_template => 'Volume Out : %.2f %s', output_change_bytes => 1, perfdatas => [ - { label => 'volume_out', value => 'out_volume_absolute', template => '%s', - unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' } + { label => 'volume_out', value => 'out_volume', template => '%s', + unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'display' } ] } } @@ -960,9 +958,9 @@ sub reload_cache { $self->{option_results}->{oid_extra_display} ne $self->{option_results}->{oid_filter}) { push @{$snmp_get}, { oid => $self->{oids_label}->{$self->{option_results}->{oid_extra_display}}->{oid} }; } - + my $result = $self->{snmp}->get_multiple_table(oids => $snmp_get); - + my $func = $self->can($self->{oids_label}->{$self->{option_results}->{oid_filter}}->{cache}); $func->($self, result => $result, datas => $datas, name => $self->{option_results}->{oid_filter}, store_index => 1); @@ -1055,7 +1053,7 @@ sub load_status { sub load_traffic { my ($self, %options) = @_; - + $self->set_oids_traffic(); $self->{snmp}->load(oids => [$self->{oid_in32}, $self->{oid_out32}], instances => $self->{array_interface_selected}); if ($self->{get_speed} == 1) { @@ -1071,7 +1069,7 @@ sub load_traffic { sub load_errors { my ($self, %options) = @_; - + $self->set_oids_errors(); $self->{snmp}->load( oids => [ diff --git a/snmp_standard/mode/isdnusage.pm b/snmp_standard/mode/isdnusage.pm index 2ae3a929a..30dd155f4 100644 --- a/snmp_standard/mode/isdnusage.pm +++ b/snmp_standard/mode/isdnusage.pm @@ -39,8 +39,8 @@ sub set_counters { key_values => [ { name => 'in', diff => 1 }, { name => 'display' } ], output_template => 'Incoming calls : %s', perfdatas => [ - { label => 'in_calls', value => 'in_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'in_calls', value => 'in', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -48,8 +48,8 @@ sub set_counters { key_values => [ { name => 'out', diff => 1 }, { name => 'display' } ], output_template => 'Outgoing calls : %s', perfdatas => [ - { label => 'out_calls', value => 'out_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'out_calls', value => 'out', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -59,8 +59,8 @@ sub set_counters { key_values => [ { name => 'active' }, { name => 'total' } ], output_template => 'Current calls : %s', perfdatas => [ - { label => 'current_calls', value => 'active_absolute', template => '%s', - min => 0, max => 'total_absolute' }, + { label => 'current_calls', value => 'active', template => '%s', + min => 0, max => 'total' }, ], } }, diff --git a/snmp_standard/mode/memory.pm b/snmp_standard/mode/memory.pm index 79289c4a9..5f23c43e3 100644 --- a/snmp_standard/mode/memory.pm +++ b/snmp_standard/mode/memory.pm @@ -30,11 +30,11 @@ sub custom_usage_output { return sprintf( 'Ram Total: %s %s Used (-buffers/cache): %s %s (%.2f%%) Free: %s %s (%.2f%%)', - $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_absolute}), - $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_absolute}), - $self->{result_values}->{prct_used_absolute}, - $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute}), - $self->{result_values}->{prct_free_absolute} + $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}), + $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}), + $self->{result_values}->{prct_used}, + $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}), + $self->{result_values}->{prct_free} ); } @@ -43,11 +43,11 @@ sub custom_swap_output { return sprintf( 'Swap Total: %s %s Used: %s %s (%.2f%%) Free: %s %s (%.2f%%)', - $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_absolute}), - $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_absolute}), - $self->{result_values}->{prct_used_absolute}, - $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute}), - $self->{result_values}->{prct_free_absolute} + $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}), + $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}), + $self->{result_values}->{prct_used}, + $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}), + $self->{result_values}->{prct_free} ); } @@ -64,7 +64,7 @@ sub set_counters { key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ - { label => 'used', value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute', + { label => 'used', value => 'used', template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1 } ] } @@ -73,7 +73,7 @@ sub set_counters { key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ - { label => 'free', value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute', + { label => 'free', value => 'free', template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1 } ] } @@ -82,7 +82,7 @@ sub set_counters { key_values => [ { name => 'prct_used' } ], output_template => 'Ram Used : %.2f %%', perfdatas => [ - { label => 'used_prct', value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, + { label => 'used_prct', value => 'prct_used', template => '%.2f', min => 0, max => 100, unit => '%' } ] } @@ -92,7 +92,7 @@ sub set_counters { output_template => 'Buffer: %s %s', output_change_bytes => 1, perfdatas => [ - { label => 'buffer', value => 'memBuffer_absolute', template => '%d', + { label => 'buffer', value => 'memBuffer', template => '%d', min => 0, unit => 'B' } ] } @@ -102,7 +102,7 @@ sub set_counters { output_template => 'Cached: %s %s', output_change_bytes => 1, perfdatas => [ - { label => 'cached', value => 'memCached_absolute', template => '%d', + { label => 'cached', value => 'memCached', template => '%d', min => 0, unit => 'B' } ] } @@ -112,7 +112,7 @@ sub set_counters { output_template => 'Shared: %s %s', output_change_bytes => 1, perfdatas => [ - { label => 'shared', value => 'memShared_absolute', template => '%d', + { label => 'shared', value => 'memShared', template => '%d', min => 0, unit => 'B' } ] } @@ -123,7 +123,7 @@ sub set_counters { key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], closure_custom_output => $self->can('custom_swap_output'), perfdatas => [ - { label => 'swap', value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute', + { label => 'swap', value => 'used', template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1 } ] } @@ -132,7 +132,7 @@ sub set_counters { key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], closure_custom_output => $self->can('custom_swap_output'), perfdatas => [ - { label => 'swap_free', value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute', + { label => 'swap_free', value => 'free', template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1 } ] } @@ -141,7 +141,7 @@ sub set_counters { key_values => [ { name => 'prct_used' } ], output_template => 'Swap Used : %.2f %%', perfdatas => [ - { label => 'swap_prct', value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, + { label => 'swap_prct', value => 'prct_used', template => '%.2f', min => 0, max => 100, unit => '%' } ] } diff --git a/snmp_standard/mode/mtausage.pm b/snmp_standard/mode/mtausage.pm index 158fc6d16..339e99d4c 100644 --- a/snmp_standard/mode/mtausage.pm +++ b/snmp_standard/mode/mtausage.pm @@ -39,8 +39,8 @@ sub set_counters { key_values => [ { name => 'mtaReceivedMessages', diff => 1 }, { name => 'display' } ], output_template => 'Total Received Messages : %s', output_error_template => "Total Received Messages : %s", perfdatas => [ - { label => 'total_received_messages', value => 'mtaReceivedMessages_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'total_received_messages', value => 'mtaReceivedMessages', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -49,8 +49,8 @@ sub set_counters { output_template => 'Total Received Volume : %s %s', output_error_template => "Total Received Volume : %s", output_change_bytes => 1, perfdatas => [ - { label => 'total_received_volume', value => 'mtaReceivedVolume_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'total_received_volume', value => 'mtaReceivedVolume', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -58,8 +58,8 @@ sub set_counters { key_values => [ { name => 'mtaStoredMessages' }, { name => 'display' } ], output_template => 'Total Stored Messages : %s', output_error_template => "Total Stored Messages : %s", perfdatas => [ - { label => 'total_stored_messages', value => 'mtaStoredMessages_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'total_stored_messages', value => 'mtaStoredMessages', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -68,8 +68,8 @@ sub set_counters { output_template => 'Total Stored Volume : %s %s', output_error_template => "Total Stored Volume : %s", output_change_bytes => 1, perfdatas => [ - { label => 'total_stored_volume', value => 'mtaStoredVolume_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'total_stored_volume', value => 'mtaStoredVolume', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -77,8 +77,8 @@ sub set_counters { key_values => [ { name => 'mtaTransmittedMessages', diff => 1 }, { name => 'display' } ], output_template => 'Total Transmitted Messages : %s', output_error_template => "Total Transmitted Messages : %s", perfdatas => [ - { label => 'total_transmitted_messages', value => 'mtaTransmittedMessages_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'total_transmitted_messages', value => 'mtaTransmittedMessages', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -87,8 +87,8 @@ sub set_counters { output_template => 'Total Transmitted Volume : %s %s', output_error_template => "Total Transmitted Volume : %s", output_change_bytes => 1, perfdatas => [ - { label => 'total_transmitted_volume', value => 'mtaTransmittedVolume_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'total_transmitted_volume', value => 'mtaTransmittedVolume', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -99,8 +99,8 @@ sub set_counters { key_values => [ { name => 'mtaGroupReceivedMessages', diff => 1 }, { name => 'display' } ], output_template => 'Received Messages : %s', output_error_template => "Received Messages : %s", perfdatas => [ - { label => 'received_messages', value => 'mtaGroupReceivedMessages_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'received_messages', value => 'mtaGroupReceivedMessages', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -109,8 +109,8 @@ sub set_counters { output_template => 'Received Volume : %s %s', output_error_template => "Received Volume : %s", output_change_bytes => 1, perfdatas => [ - { label => 'received_volume', value => 'mtaGroupReceivedVolume_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'received_volume', value => 'mtaGroupReceivedVolume', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -118,8 +118,8 @@ sub set_counters { key_values => [ { name => 'mtaGroupStoredMessages' }, { name => 'display' } ], output_template => 'Stored Messages : %s', output_error_template => "Stored Messages : %s", perfdatas => [ - { label => 'stored_messages', value => 'mtaGroupStoredMessages_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'stored_messages', value => 'mtaGroupStoredMessages', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -128,8 +128,8 @@ sub set_counters { output_template => 'Stored Volume : %s %s', output_error_template => "Stored Volume : %s", output_change_bytes => 1, perfdatas => [ - { label => 'stored_volume', value => 'mtaGroupStoredVolume_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'stored_volume', value => 'mtaGroupStoredVolume', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -137,8 +137,8 @@ sub set_counters { key_values => [ { name => 'mtaGroupTransmittedMessages', diff => 1 }, { name => 'display' } ], output_template => 'Transmitted Messages : %s', output_error_template => "Transmitted Messages : %s", perfdatas => [ - { label => 'transmitted_messages', value => 'mtaGroupTransmittedMessages_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'transmitted_messages', value => 'mtaGroupTransmittedMessages', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -147,8 +147,8 @@ sub set_counters { output_template => 'Transmitted Volume : %s %s', output_error_template => "Transmitted Volume : %s", output_change_bytes => 1, perfdatas => [ - { label => 'transmitted_volume', value => 'mtaGroupTransmittedVolume_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'transmitted_volume', value => 'mtaGroupTransmittedVolume', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -156,8 +156,8 @@ sub set_counters { key_values => [ { name => 'mtaGroupRejectedMessages', diff => 1 }, { name => 'display' } ], output_template => 'Rejected Messages : %s', output_error_template => "Rejected Messages : %s", perfdatas => [ - { label => 'rejected_messages', value => 'mtaGroupRejectedMessages_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'rejected_messages', value => 'mtaGroupRejectedMessages', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/snmp_standard/mode/ntp.pm b/snmp_standard/mode/ntp.pm index e30f1e7c7..c7e67fc51 100644 --- a/snmp_standard/mode/ntp.pm +++ b/snmp_standard/mode/ntp.pm @@ -32,8 +32,8 @@ sub custom_usage_output { return sprintf( 'Time offset %d second(s): %s', - $self->{result_values}->{offset_absolute}, - $self->{result_values}->{date_absolute} + $self->{result_values}->{offset}, + $self->{result_values}->{date} ); } @@ -49,7 +49,7 @@ sub set_counters { key_values => [ { name => 'offset' }, { name => 'date' } ], closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ - { label => 'offset', value => 'offset_absolute', template => '%d', unit => 's' }, + { label => 'offset', value => 'offset', template => '%d', unit => 's' }, ], } }, diff --git a/snmp_standard/mode/storage.pm b/snmp_standard/mode/storage.pm index 9321f5c29..9f877ff1c 100644 --- a/snmp_standard/mode/storage.pm +++ b/snmp_standard/mode/storage.pm @@ -159,7 +159,7 @@ sub custom_access_output { my ($self, %options) = @_; my $msg = sprintf("Access : %s", - $self->{result_values}->{access_absolute} == 1 ? 'readWrite' : 'readOnly' + $self->{result_values}->{access} == 1 ? 'readWrite' : 'readOnly' ); return $msg; @@ -178,7 +178,7 @@ sub set_counters { key_values => [ { name => 'count' } ], output_template => 'Partitions count : %d', perfdatas => [ - { label => 'count', value => 'count_absolute', template => '%d', min => 0 } + { label => 'count', value => 'count', template => '%d', min => 0 } ] } }, @@ -197,8 +197,8 @@ sub set_counters { key_values => [ { name => 'access' }, { name => 'display' } ], closure_custom_output => $self->can('custom_access_output'), perfdatas => [ - { label => 'access', value => 'access_absolute', template => '%d', min => 1, max => 2, - label_extra_instance => 1, instance_use => 'display_absolute' } + { label => 'access', value => 'access', template => '%d', min => 1, max => 2, + label_extra_instance => 1, instance_use => 'display' } ] } } diff --git a/snmp_standard/mode/swap.pm b/snmp_standard/mode/swap.pm index a15a3862a..2e6d4df6e 100644 --- a/snmp_standard/mode/swap.pm +++ b/snmp_standard/mode/swap.pm @@ -29,11 +29,11 @@ sub custom_swap_output { my ($self, %options) = @_; my $msg = sprintf("Swap Total: %s %s Used: %s %s (%.2f%%) Free: %s %s (%.2f%%)", - $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_absolute}), - $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_absolute}), - $self->{result_values}->{prct_used_absolute}, - $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute}), - $self->{result_values}->{prct_free_absolute}); + $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}), + $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}), + $self->{result_values}->{prct_used}, + $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}), + $self->{result_values}->{prct_free}); return $msg; } @@ -49,7 +49,7 @@ sub set_counters { key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], closure_custom_output => $self->can('custom_swap_output'), perfdatas => [ - { label => 'used', value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute', + { label => 'used', value => 'used', template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1 }, ], } @@ -58,7 +58,7 @@ sub set_counters { key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], closure_custom_output => $self->can('custom_swap_output'), perfdatas => [ - { label => 'free', value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute', + { label => 'free', value => 'free', template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1 }, ], } @@ -67,7 +67,7 @@ sub set_counters { key_values => [ { name => 'prct_used' } ], output_template => 'Used : %.2f %%', perfdatas => [ - { label => 'used_prct', value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, + { label => 'used_prct', value => 'prct_used', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } diff --git a/storage/avid/isis/snmp/mode/performance.pm b/storage/avid/isis/snmp/mode/performance.pm index c2173aa60..84e942673 100644 --- a/storage/avid/isis/snmp/mode/performance.pm +++ b/storage/avid/isis/snmp/mode/performance.pm @@ -84,7 +84,7 @@ sub set_counters { key_values => [ { name => 'OpenFiles' } ], output_template => 'Open files: %s files', perfdatas => [ - { label => 'open_files', value => 'OpenFiles_absolute', + { label => 'open_files', value => 'OpenFiles', template => '%s', min => 0, unit => 'files' }, ], } @@ -93,7 +93,7 @@ sub set_counters { key_values => [ { name => 'MessagesPerSecond' } ], output_template => 'Message processing speed: %s messages/s', perfdatas => [ - { label => 'processing_speed', value => 'MessagesPerSecond_absolute', + { label => 'processing_speed', value => 'MessagesPerSecond', template => '%s', min => 0, unit => 'messages/s' }, ], } @@ -103,7 +103,7 @@ sub set_counters { output_template => 'Read throughput: %s %s/s', output_change_bytes => 1, perfdatas => [ - { label => 'read_throughput', value => 'ReadMegabytesPerSecond_absolute', + { label => 'read_throughput', value => 'ReadMegabytesPerSecond', template => '%s', min => 0, unit => 'B/s' }, ], } @@ -113,7 +113,7 @@ sub set_counters { output_template => 'Write throughput: %s %s/s', output_change_bytes => 1, perfdatas => [ - { label => 'write_throughput', value => 'WriteMegabytesPerSecond_absolute', + { label => 'write_throughput', value => 'WriteMegabytesPerSecond', template => '%s', min => 0, unit => 'B/s' }, ], } diff --git a/storage/avid/isis/snmp/mode/status.pm b/storage/avid/isis/snmp/mode/status.pm index 645311d40..0b5fdf5b8 100644 --- a/storage/avid/isis/snmp/mode/status.pm +++ b/storage/avid/isis/snmp/mode/status.pm @@ -60,7 +60,7 @@ sub set_counters { key_values => [ { name => 'WorkspaceRedistributingCount' } ], output_template => 'Workspace redistributing count: %d', perfdatas => [ - { label => 'redistributing_count', value => 'WorkspaceRedistributingCount_absolute', + { label => 'redistributing_count', value => 'WorkspaceRedistributingCount', template => '%d', min => 0 }, ], } diff --git a/storage/avid/isis/snmp/mode/usage.pm b/storage/avid/isis/snmp/mode/usage.pm index 9b4217ac5..70daa51ee 100644 --- a/storage/avid/isis/snmp/mode/usage.pm +++ b/storage/avid/isis/snmp/mode/usage.pm @@ -118,7 +118,7 @@ sub set_counters { key_values => [ { name => 'WorkspaceCount' } ], output_template => 'Workspace count: %d', perfdatas => [ - { label => 'workspace_count', value => 'WorkspaceCount_absolute', + { label => 'workspace_count', value => 'WorkspaceCount', template => '%d', min => 0 }, ], } @@ -127,7 +127,7 @@ sub set_counters { key_values => [ { name => 'FolderCount' } ], output_template => 'Folder count: %d', perfdatas => [ - { label => 'folder_count', value => 'FolderCount_absolute', + { label => 'folder_count', value => 'FolderCount', template => '%d', min => 0 }, ], } @@ -136,7 +136,7 @@ sub set_counters { key_values => [ { name => 'FileCount' } ], output_template => 'File count: %d', perfdatas => [ - { label => 'file_count', value => 'FileCount_absolute', + { label => 'file_count', value => 'FileCount', template => '%d', min => 0 }, ], } diff --git a/storage/dell/compellent/local/mode/hbausage.pm b/storage/dell/compellent/local/mode/hbausage.pm index de5a1190e..b7bb56d37 100644 --- a/storage/dell/compellent/local/mode/hbausage.pm +++ b/storage/dell/compellent/local/mode/hbausage.pm @@ -40,8 +40,8 @@ sub set_counters { key_values => [ { name => 'read_iops' }, { name => 'display' } ], output_template => 'Read IOPs : %s', perfdatas => [ - { label => 'read_iops', value => 'read_iops_absolute', template => '%d', - unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'read_iops', value => 'read_iops', template => '%d', + unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -50,8 +50,8 @@ sub set_counters { output_template => 'Read usage : %s %s/s', output_change_bytes => 2, perfdatas => [ - { label => 'read_usage', value => 'read_bps_absolute', template => '%d', - unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'read_usage', value => 'read_bps', template => '%d', + unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -59,8 +59,8 @@ sub set_counters { key_values => [ { name => 'read_latency' }, { name => 'display' } ], output_template => 'Read latency : %s ms', perfdatas => [ - { label => 'read_latency', value => 'read_latency_absolute', template => '%d', - unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'read_latency', value => 'read_latency', template => '%d', + unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -68,8 +68,8 @@ sub set_counters { key_values => [ { name => 'write_iops' }, { name => 'display' } ], output_template => 'Write IOPs : %s', perfdatas => [ - { label => 'write_iops', value => 'write_iops_absolute', template => '%d', - unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'write_iops', value => 'write_iops', template => '%d', + unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -78,8 +78,8 @@ sub set_counters { output_template => 'Write Usage : %s %s/s', output_change_bytes => 2, perfdatas => [ - { label => 'write_usage', value => 'write_bps_absolute', template => '%d', - unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'write_usage', value => 'write_bps', template => '%d', + unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -87,8 +87,8 @@ sub set_counters { key_values => [ { name => 'write_latency' }, { name => 'display' } ], output_template => 'Write Latency : %s ms', perfdatas => [ - { label => 'write_latency', value => 'write_latency_absolute', template => '%d', - unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'write_latency', value => 'write_latency', template => '%d', + unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/storage/dell/compellent/local/mode/volumeusage.pm b/storage/dell/compellent/local/mode/volumeusage.pm index aa8dfe2cc..32c67d707 100644 --- a/storage/dell/compellent/local/mode/volumeusage.pm +++ b/storage/dell/compellent/local/mode/volumeusage.pm @@ -60,8 +60,8 @@ sub set_counters { output_template => 'Raid Overhead : %s %s', output_change_bytes => 1, perfdatas => [ - { label => 'volume_overhead', value => 'overhead_absolute', template => '%d', - unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'volume_overhead', value => 'overhead', template => '%d', + unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -70,8 +70,8 @@ sub set_counters { output_template => 'Replay : %s %s', output_change_bytes => 1, perfdatas => [ - { label => 'volume_replay', value => 'replay_absolute', template => '%d', - unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'volume_replay', value => 'replay', template => '%d', + unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/storage/dell/equallogic/snmp/mode/arrayusage.pm b/storage/dell/equallogic/snmp/mode/arrayusage.pm index d28522b96..d976a074b 100644 --- a/storage/dell/equallogic/snmp/mode/arrayusage.pm +++ b/storage/dell/equallogic/snmp/mode/arrayusage.pm @@ -119,21 +119,21 @@ sub set_counters { }, { label => 'snapshot', set => { key_values => [ { name => 'eqlMemberSnapStorage' }, { name => 'display' } ], - output_change_bytes => 1, output_template => 'Snapshot usage : %s %s', + output_change_bytes => 1, perfdatas => [ - { label => 'snapshost', value => 'eqlMemberSnapStorage_absolute', template => '%s', - unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'snapshost', template => '%s', + unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'replication', set => { key_values => [ { name => 'eqlMemberReplStorage' }, { name => 'display' } ], - output_change_bytes => 1, output_template => 'Replication usage : %s %s', + output_change_bytes => 1, perfdatas => [ - { label => 'replication', value => 'eqlMemberReplStorage_absolute', template => '%s', - unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'replication', template => '%s', + unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -141,8 +141,8 @@ sub set_counters { key_values => [ { name => 'eqlMemberNumberOfConnections' }, { name => 'display' } ], output_template => 'iSCSI connections : %s', perfdatas => [ - { label => 'connections', value => 'eqlMemberNumberOfConnections_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'connections', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -150,8 +150,8 @@ sub set_counters { key_values => [ { name => 'eqlMemberNumberOfExtConnections' }, { name => 'display' } ], output_template => 'External iSCSI connections : %s', perfdatas => [ - { label => 'ext_connections', value => 'eqlMemberNumberOfExtConnections_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'ext_connections', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -159,8 +159,8 @@ sub set_counters { key_values => [ { name => 'eqlMemberReadAvgLatency' }, { name => 'display' } ], output_template => 'Global read average latency : %s ms', perfdatas => [ - { label => 'global_read_avg_latency', value => 'eqlMemberReadAvgLatency_absolute', template => '%s', - unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'global_read_avg_latency', template => '%s', + unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -168,8 +168,8 @@ sub set_counters { key_values => [ { name => 'eqlMemberWriteAvgLatency' }, { name => 'display' } ], output_template => 'Global write average latency : %s ms', perfdatas => [ - { label => 'global_write_avg_latency', value => 'eqlMemberWriteAvgLatency_absolute', template => '%s', - unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'global_write_avg_latency', template => '%s', + unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -179,7 +179,7 @@ sub set_counters { closure_custom_calc => $self->can('custom_read_avg_latency_calc'), perfdatas => [ { label => 'read_avg_latency', value => 'read_avg_latency', template => '%.2f', - unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -189,47 +189,45 @@ sub set_counters { closure_custom_calc => $self->can('custom_write_avg_latency_calc'), perfdatas => [ { label => 'write_avg_latency', value => 'write_avg_latency', template => '%.2f', - unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'read-iops', set => { - key_values => [ { name => 'eqlMemberReadOpCount', diff => 1 }, { name => 'display' } ], - per_second => 1, + key_values => [ { name => 'eqlMemberReadOpCount', per_second => 1 }, { name => 'display' } ], output_template => 'Read IOPs : %.2f', perfdatas => [ - { label => 'read_iops', template => '%.2f', value => 'eqlMemberReadOpCount_per_second', - unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'read_iops', template => '%.2f', + unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'write-iops', set => { - key_values => [ { name => 'eqlMemberWriteOpCount', diff => 1 }, { name => 'display' } ], - per_second => 1, + key_values => [ { name => 'eqlMemberWriteOpCount', per_second => 1 }, { name => 'display' } ], output_template => 'Write IOPs : %.2f', perfdatas => [ - { label => 'write_iops', template => '%.2f', value => 'eqlMemberWriteOpCount_per_second', - unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'write_iops', template => '%.2f', + unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'traffic-in', display_ok => 0, set => { - key_values => [ { name => 'eqlMemberRxData', diff => 1 }, { name => 'display' } ], - per_second => 1, output_change_bytes => 2, + key_values => [ { name => 'eqlMemberRxData', per_second => 1 }, { name => 'display' } ], output_template => 'Traffic In : %s %s/s', + output_change_bytes => 2, perfdatas => [ { label => 'traffic_in', value => 'eqlMemberRxData_per_second', template => '%s', - unit => 'b/s', min => 0, cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' }, + unit => 'b/s', min => 0, cast_int => 1, label_extra_instance => 1, instance_use => 'display' }, ], } }, - { label => 'traffic-out', display_ok => 0, set => { - key_values => [ { name => 'eqlMemberTxData', diff => 1 }, { name => 'display' } ], - per_second => 1, output_change_bytes => 2, + { label => 'traffic-out', display_ok => 0, set => { + key_values => [ { name => 'eqlMemberTxData', per_second => 1 }, { name => 'display' } ], output_template => 'Traffic Out : %s %s/s', + output_change_bytes => 2, perfdatas => [ - { label => 'traffic_out', value => 'eqlMemberTxData_per_second', template => '%s', - unit => 'b/s', min => 0, cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'traffic_out', template => '%s', + unit => 'b/s', min => 0, cast_int => 1, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -248,7 +246,7 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - "filter-name:s" => { name => 'filter_name' }, + 'filter-name:s' => { name => 'filter_name' } }); return $self; diff --git a/storage/dell/equallogic/snmp/mode/diskusage.pm b/storage/dell/equallogic/snmp/mode/diskusage.pm index 48370c29e..badc8b0f5 100644 --- a/storage/dell/equallogic/snmp/mode/diskusage.pm +++ b/storage/dell/equallogic/snmp/mode/diskusage.pm @@ -60,22 +60,22 @@ sub set_counters { } }, { label => 'read', set => { - key_values => [ { name => 'eqlDiskStatusBytesRead', diff => 1 }, { name => 'display' } ], - per_second => 1, output_change_bytes => 1, + key_values => [ { name => 'eqlDiskStatusBytesRead', per_second => 1 }, { name => 'display' } ], output_template => 'read : %s %s/s', + output_change_bytes => 1, perfdatas => [ - { label => 'read_iops', template => '%.2f', value => 'eqlDiskStatusBytesRead_per_second', - unit => 'B/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'read_iops', template => '%.2f', + unit => 'B/s', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'write', set => { - key_values => [ { name => 'eqlDiskStatusBytesWritten', diff => 1 }, { name => 'display' } ], - per_second => 1, output_change_bytes => 1, + key_values => [ { name => 'eqlDiskStatusBytesWritten', per_second => 1 }, { name => 'display' } ], output_template => 'write : %s %s/s', + output_change_bytes => 1, perfdatas => [ - { label => 'write', template => '%.2f', value => 'eqlDiskStatusBytesWritten_per_second', - unit => 'B/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'write', template => '%.2f', + unit => 'B/s', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -83,8 +83,8 @@ sub set_counters { key_values => [ { name => 'eqlDiskStatusBusyTime', diff => 1 }, { name => 'display' } ], output_template => 'time busy : %s sec', perfdatas => [ - { label => 'busy_time', template => '%s', value => 'eqlDiskStatusBusyTime_absolute', - unit => 's', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'busy_time', template => '%s', + unit => 's', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -103,10 +103,10 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - "filter-name:s" => { name => 'filter_name' }, - "unknown-status:s" => { name => 'unknown_status', default => '' }, - "warning-status:s" => { name => 'warning_status', default => '' }, - "critical-status:s" => { name => 'critical_status', default => '%{status} !~ /on-line|spare|off-line/i' }, + 'filter-name:s' => { name => 'filter_name' }, + 'unknown-status:s' => { name => 'unknown_status', default => '' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '%{status} !~ /on-line|spare|off-line/i' } }); return $self; diff --git a/storage/dell/me4/restapi/mode/controllerstatistics.pm b/storage/dell/me4/restapi/mode/controllerstatistics.pm index 8b3bb3ade..c14a3459c 100644 --- a/storage/dell/me4/restapi/mode/controllerstatistics.pm +++ b/storage/dell/me4/restapi/mode/controllerstatistics.pm @@ -35,146 +35,112 @@ sub set_counters { $self->{maps_counters}->{controllers} = [ { label => 'data-read', nlabel => 'controller.data.read.bytespersecond', set => { - key_values => [ { name => 'data-read-numeric', diff => 1 }, { name => 'display'} ], + key_values => [ { name => 'data-read-numeric', per_second => 1 }, { name => 'display' } ], output_template => 'Data Read: %s%s/s', output_change_bytes => 1, - per_second => 1, perfdatas => [ - { label => 'data_read', value => 'data-read-numeric_per_second', - template => '%s', min => 0, unit => 'B/s', label_extra_instance => 1, - instance_use => 'display_absolute' }, + { template => '%s', min => 0, unit => 'B/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'data-written', nlabel => 'controller.data.written.bytespersecond', set => { - key_values => [ { name => 'data-written-numeric', diff => 1 }, { name => 'display'} ], + key_values => [ { name => 'data-written-numeric', per_second => 1 }, { name => 'display' } ], output_template => 'Data Written: %s%s/s', output_change_bytes => 1, - per_second => 1, perfdatas => [ - { label => 'data_written', value => 'data-written-numeric_per_second', - template => '%s', min => 0, unit => 'B/s', label_extra_instance => 1, - instance_use => 'display_absolute' }, + { template => '%s', min => 0, unit => 'B/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'reads', nlabel => 'controller.reads.count', set => { - key_values => [ { name => 'number-of-reads', diff => 1 }, { name => 'display'} ], + key_values => [ { name => 'number-of-reads', per_second => 1 }, { name => 'display' } ], output_template => 'Reads: %s/s', - per_second => 1, perfdatas => [ - { label => 'reads', value => 'number-of-reads_per_second', - template => '%s', min => 0, label_extra_instance => 1, - instance_use => 'display_absolute' }, + { template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'writes', nlabel => 'controller.writes.count', set => { - key_values => [ { name => 'number-of-writes', diff => 1 }, { name => 'display'} ], + key_values => [ { name => 'number-of-writes', per_second => 1 }, { name => 'display' } ], output_template => 'Writes: %s/s', - per_second => 1, perfdatas => [ - { label => 'writes', value => 'number-of-writes_per_second', - template => '%s', min => 0, label_extra_instance => 1, - instance_use => 'display_absolute' }, + { template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'data-transfer', nlabel => 'controller.data.transfer.bytespersecond', set => { - key_values => [ { name => 'bytes-per-second-numeric'}, { name => 'display'} ], + key_values => [ { name => 'bytes-per-second-numeric'}, { name => 'display' } ], output_template => 'Data Transfer: %s%s/s', output_change_bytes => 1, perfdatas => [ - { label => 'data_transfer', value => 'bytes-per-second-numeric_absolute', - template => '%s', min => 0, unit => 'B/s', label_extra_instance => 1, - instance_use => 'display_absolute' }, + { template => '%s', min => 0, unit => 'B/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'iops', nlabel => 'controller.iops.ops', set => { - key_values => [ { name => 'iops'}, { name => 'display'} ], + key_values => [ { name => 'iops'}, { name => 'display' } ], output_template => 'IOPS: %d ops', perfdatas => [ - { label => 'iops', value => 'iops_absolute', - template => '%d', min => 0, unit => 'ops', label_extra_instance => 1, - instance_use => 'display_absolute' }, + { template => '%d', min => 0, unit => 'ops', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'forwarded-cmds', nlabel => 'controller.commands.forwarded.count', set => { - key_values => [ { name => 'num-forwarded-cmds'}, { name => 'display'} ], + key_values => [ { name => 'num-forwarded-cmds'}, { name => 'display' } ], output_template => 'Forwarded Commands: %d', perfdatas => [ - { label => 'forwarded_cmds', value => 'num-forwarded-cmds_absolute', - template => '%d', min => 0, label_extra_instance => 1, - instance_use => 'display_absolute' }, + { template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'write-cache-used', nlabel => 'controller.cache.write.usage.percentage', set => { - key_values => [ { name => 'write-cache-used'}, { name => 'display'} ], + key_values => [ { name => 'write-cache-used'}, { name => 'display' } ], output_template => 'Cache Write Usage: %s%%', perfdatas => [ - { label => 'write_cache_used', value => 'write-cache-used_absolute', - template => '%d', min => 0, label_extra_instance => 1, - instance_use => 'display_absolute' }, + { template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'write-cache-hits', nlabel => 'controller.cache.write.hits.count', set => { - key_values => [ { name => 'write-cache-hits', diff => 1 }, { name => 'display'} ], + key_values => [ { name => 'write-cache-hits', per_second => 1 }, { name => 'display' } ], output_template => 'Cache Write Hits: %s/s', - per_second => 1, perfdatas => [ - { label => 'write_cache_hits', value => 'write-cache-hits_per_second', - template => '%s', min => 0, label_extra_instance => 1, - instance_use => 'display_absolute' }, + { template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'write-cache-misses', nlabel => 'controller.cache.write.misses.count', set => { - key_values => [ { name => 'write-cache-misses', diff => 1 }, { name => 'display'} ], + key_values => [ { name => 'write-cache-misses', per_second => 1 }, { name => 'display' } ], output_template => 'Cache Write Misses: %s/s', - per_second => 1, perfdatas => [ - { label => 'write_cache_misses', value => 'write-cache-misses_per_second', - template => '%s', min => 0, label_extra_instance => 1, - instance_use => 'display_absolute' }, + { template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'read-cache-hits', nlabel => 'controller.cache.read.hits.count', set => { - key_values => [ { name => 'read-cache-hits', diff => 1 }, { name => 'display'} ], + key_values => [ { name => 'read-cache-hits', per_second => 1 }, { name => 'display' } ], output_template => 'Cache Read Hits: %s/s', - per_second => 1, perfdatas => [ - { label => 'read_cache_hits', value => 'read-cache-hits_per_second', - template => '%s', min => 0, label_extra_instance => 1, - instance_use => 'display_absolute' }, + { template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'read-cache-misses', nlabel => 'controller.cache.read.misses.count', set => { - key_values => [ { name => 'read-cache-misses', diff => 1 }, { name => 'display'} ], + key_values => [ { name => 'read-cache-misses', per_second => 1 }, { name => 'display' } ], output_template => 'Cache Read Misses: %s/s', - per_second => 1, perfdatas => [ - { label => 'read_cache_misses', value => 'read-cache-misses_per_second', - template => '%s', min => 0, label_extra_instance => 1, - instance_use => 'display_absolute' }, + { template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'cpu-utilization', nlabel => 'controller.cpu.utilization.percentage', set => { - key_values => [ { name => 'cpu-load'}, { name => 'display'} ], + key_values => [ { name => 'cpu-load'}, { name => 'display' } ], output_template => 'CPU Utilization: %.2f%%', perfdatas => [ - { label => 'cpu_utilization', value => 'cpu-load_absolute', - template => '%s', min => 0, label_extra_instance => 1, - instance_use => 'display_absolute' }, + { template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } - }, + } ]; } @@ -190,7 +156,7 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - 'filter-name:s' => { name => 'filter_name' }, + 'filter-name:s' => { name => 'filter_name' } }); return $self; diff --git a/storage/dell/me4/restapi/mode/interfaces.pm b/storage/dell/me4/restapi/mode/interfaces.pm index 0936724b2..710e50071 100644 --- a/storage/dell/me4/restapi/mode/interfaces.pm +++ b/storage/dell/me4/restapi/mode/interfaces.pm @@ -59,42 +59,36 @@ sub set_counters { } }, { label => 'read-iops', nlabel => 'port.io.read.usage.iops', set => { - key_values => [ { name => 'number_of_reads', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'number_of_reads', per_second => 1 }, { name => 'display' } ], output_template => 'read iops: %.2f', - per_second => 1, perfdatas => [ - { value => 'number_of_reads_per_second', template => '%.2f', - unit => 'iops', min => 0, label_extra_instance => 1 } + { template => '%.2f', unit => 'iops', min => 0, label_extra_instance => 1 } ] } }, { label => 'write-iops', nlabel => 'port.io.write.usage.iops', set => { - key_values => [ { name => 'number_of_writes', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'number_of_writes', per_second => 1 }, { name => 'display' } ], output_template => 'write iops: %.2f', - per_second => 1, perfdatas => [ - { value => 'number_of_writes_per_second', template => '%.2f', - unit => 'iops', min => 0, label_extra_instance => 1 } + { template => '%.2f', unit => 'iops', min => 0, label_extra_instance => 1 } ] } }, { label => 'read-traffic', nlabel => 'port.traffic.read.usage.bitspersecond', set => { - key_values => [ { name => 'data_read_numeric', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'data_read_numeric', per_second => 1 }, { name => 'display' } ], output_template => 'read traffic: %s %s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { value => 'data_read_numeric_per_second', template => '%d', - unit => 'b/s', min => 0, label_extra_instance => 1 } + { template => '%d', unit => 'b/s', min => 0, label_extra_instance => 1 } ] } }, { label => 'write-traffic', nlabel => 'port.traffic.write.usage.bitspersecond', set => { - key_values => [ { name => 'data_write_numeric' }, { name => 'display' } ], + key_values => [ { name => 'data_write_numeric', per_second => 1 }, { name => 'display' } ], output_template => 'write traffic: %s %s/s', - per_second => 1, output_change_bytes => 2, + output_change_bytes => 2, perfdatas => [ - { value => 'data_write_numeric_per_second', template => '%d', - unit => 'b/s', min => 0, label_extra_instance => 1 } + { template => '%d', unit => 'b/s', min => 0, label_extra_instance => 1 } ] } } @@ -105,8 +99,7 @@ sub set_counters { key_values => [ { name => 'disparity_errors' }, { name => 'display' } ], output_template => 'disparity errors: %s', perfdatas => [ - { value => 'disparity_errors_absolute', template => '%d', - min => 0, label_extra_instance => 1 } + { template => '%d', min => 0, label_extra_instance => 1 } ] } }, @@ -114,17 +107,15 @@ sub set_counters { key_values => [ { name => 'lost_dwords' }, { name => 'display' } ], output_template => 'lost dwords: %s', perfdatas => [ - { value => 'lost_dwords_absolute', template => '%d', - min => 0, label_extra_instance => 1 } + { template => '%d', min => 0, label_extra_instance => 1 } ] } }, { label => 'interface-invalid-dwords', nlabel => 'port.interface.invalid.dwords.count', set => { - key_values => [ { name => 'lost_dwords' }, { name => 'display' } ], + key_values => [ { name => 'invalid_dwords' }, { name => 'display' } ], output_template => 'invalid dwords: %s', perfdatas => [ - { value => 'invalid_dwords_absolute', template => '%d', - min => 0, label_extra_instance => 1 } + { template => '%d', min => 0, label_extra_instance => 1 } ] } } diff --git a/storage/dell/me4/restapi/mode/volumestatistics.pm b/storage/dell/me4/restapi/mode/volumestatistics.pm index af015344e..fa64a9370 100644 --- a/storage/dell/me4/restapi/mode/volumestatistics.pm +++ b/storage/dell/me4/restapi/mode/volumestatistics.pm @@ -35,126 +35,96 @@ sub set_counters { $self->{maps_counters}->{volumes} = [ { label => 'data-read', nlabel => 'volume.data.read.bytespersecond', set => { - key_values => [ { name => 'data-read-numeric', diff => 1 }, { name => 'display'} ], + key_values => [ { name => 'data-read-numeric', per_second => 1 }, { name => 'display' } ], output_template => 'Data Read: %s%s/s', output_change_bytes => 1, - per_second => 1, perfdatas => [ - { label => 'data_read', value => 'data-read-numeric_per_second', - template => '%s', min => 0, unit => 'B/s', label_extra_instance => 1, - instance_use => 'display_absolute' }, + { template => '%s', min => 0, unit => 'B/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'data-written', nlabel => 'volume.data.written.bytespersecond', set => { - key_values => [ { name => 'data-written-numeric', diff => 1 }, { name => 'display'} ], + key_values => [ { name => 'data-written-numeric', per_second => 1 }, { name => 'display' } ], output_template => 'Data Written: %s%s/s', output_change_bytes => 1, - per_second => 1, perfdatas => [ - { label => 'data_written', value => 'data-written-numeric_per_second', - template => '%s', min => 0, unit => 'B/s', label_extra_instance => 1, - instance_use => 'display_absolute' }, + { template => '%s', min => 0, unit => 'B/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'reads', nlabel => 'volume.reads.count', set => { - key_values => [ { name => 'number-of-reads', diff => 1 }, { name => 'display'} ], + key_values => [ { name => 'number-of-reads', per_second => 1 }, { name => 'display' } ], output_template => 'Reads: %s/s', - per_second => 1, perfdatas => [ - { label => 'reads', value => 'number-of-reads_per_second', - template => '%s', min => 0, label_extra_instance => 1, - instance_use => 'display_absolute' }, + { template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'writes', nlabel => 'volume.writes.count', set => { - key_values => [ { name => 'number-of-writes', diff => 1 }, { name => 'display'} ], + key_values => [ { name => 'number-of-writes', per_second => 1 }, { name => 'display' } ], output_template => 'Writes: %s/s', - per_second => 1, perfdatas => [ - { label => 'writes', value => 'number-of-writes_per_second', - template => '%s', min => 0, label_extra_instance => 1, - instance_use => 'display_absolute' }, + { template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'data-transfer', nlabel => 'volume.data.transfer.bytespersecond', set => { - key_values => [ { name => 'bytes-per-second-numeric'}, { name => 'display'} ], + key_values => [ { name => 'bytes-per-second-numeric' }, { name => 'display' } ], output_template => 'Data Transfer: %s%s/s', output_change_bytes => 1, perfdatas => [ - { label => 'data_transfer', value => 'bytes-per-second-numeric_absolute', - template => '%s', min => 0, unit => 'B/s', label_extra_instance => 1, - instance_use => 'display_absolute' }, + { template => '%s', min => 0, unit => 'B/s', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'iops', nlabel => 'volume.iops.ops', set => { - key_values => [ { name => 'iops'}, { name => 'display'} ], + key_values => [ { name => 'iops' }, { name => 'display' } ], output_template => 'IOPS: %d ops', perfdatas => [ - { label => 'iops', value => 'iops_absolute', - template => '%d', min => 0, unit => 'ops', label_extra_instance => 1, - instance_use => 'display_absolute' }, + { template => '%d', min => 0, unit => 'ops', label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'write-cache-percent', nlabel => 'volume.cache.write.usage.percentage', set => { - key_values => [ { name => 'write-cache-percent'}, { name => 'display'} ], + key_values => [ { name => 'write-cache-percent'}, { name => 'display' } ], output_template => 'Cache Write Usage: %s%%', perfdatas => [ - { label => 'write_cache_used', value => 'write-cache-percent_absolute', - template => '%d', min => 0, label_extra_instance => 1, - instance_use => 'display_absolute' }, + { template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'write-cache-hits', nlabel => 'volume.cache.write.hits.count', set => { - key_values => [ { name => 'write-cache-hits', diff => 1 }, { name => 'display'} ], + key_values => [ { name => 'write-cache-hits', per_second => 1 }, { name => 'display' } ], output_template => 'Cache Write Hits: %s/s', - per_second => 1, perfdatas => [ - { label => 'write_cache_hits', value => 'write-cache-hits_per_second', - template => '%s', min => 0, label_extra_instance => 1, - instance_use => 'display_absolute' }, + { template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'write-cache-misses', nlabel => 'volume.cache.write.misses.count', set => { - key_values => [ { name => 'write-cache-misses', diff => 1 }, { name => 'display'} ], + key_values => [ { name => 'write-cache-misses', per_second => 1 }, { name => 'display' } ], output_template => 'Cache Write Misses: %s/s', - per_second => 1, perfdatas => [ - { label => 'write_cache_misses', value => 'write-cache-misses_per_second', - template => '%s', min => 0, label_extra_instance => 1, - instance_use => 'display_absolute' }, + { template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'read-cache-hits', nlabel => 'volume.cache.read.hits.count', set => { - key_values => [ { name => 'read-cache-hits', diff => 1 }, { name => 'display'} ], + key_values => [ { name => 'read-cache-hits', per_second => 1 }, { name => 'display' } ], output_template => 'Cache Read Hits: %s/s', - per_second => 1, perfdatas => [ - { label => 'read_cache_hits', value => 'read-cache-hits_per_second', - template => '%s', min => 0, label_extra_instance => 1, - instance_use => 'display_absolute' }, + { template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'read-cache-misses', nlabel => 'volume.cache.read.misses.count', set => { - key_values => [ { name => 'read-cache-misses', diff => 1 }, { name => 'display'} ], + key_values => [ { name => 'read-cache-misses', per_second => 1 }, { name => 'display'} ], output_template => 'Cache Read Misses: %s/s', - per_second => 1, perfdatas => [ - { label => 'read_cache_misses', value => 'read-cache-misses_per_second', - template => '%s', min => 0, label_extra_instance => 1, - instance_use => 'display_absolute' }, - ], + { template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' }, + ] } - }, + } ]; } diff --git a/storage/emc/DataDomain/mode/replication.pm b/storage/emc/DataDomain/mode/replication.pm index cff1000c1..9a468cc68 100644 --- a/storage/emc/DataDomain/mode/replication.pm +++ b/storage/emc/DataDomain/mode/replication.pm @@ -55,8 +55,8 @@ sub set_counters { key_values => [ { name => 'offset' }, { name => 'display' } ], output_template => 'last time peer sync : %s seconds ago', perfdatas => [ - { label => 'offset', value => 'offset_absolute', template => '%s', - label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'offset', value => 'offset', template => '%s', + label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/storage/emc/isilon/snmp/mode/clusterusage.pm b/storage/emc/isilon/snmp/mode/clusterusage.pm index e66bf9180..9a5bd52b8 100644 --- a/storage/emc/isilon/snmp/mode/clusterusage.pm +++ b/storage/emc/isilon/snmp/mode/clusterusage.pm @@ -122,7 +122,7 @@ sub set_counters { key_values => [ { name => 'health' } ], output_template => 'Node health: %.2f%%', perfdatas => [ - { label => 'health', value => 'health_absolute', template => '%.2f', + { label => 'health', value => 'health', template => '%.2f', min => 0, max => 100, unit => '%' }, ], } diff --git a/storage/emc/unisphere/restapi/mode/pools.pm b/storage/emc/unisphere/restapi/mode/pools.pm index 48467c891..93b108391 100644 --- a/storage/emc/unisphere/restapi/mode/pools.pm +++ b/storage/emc/unisphere/restapi/mode/pools.pm @@ -37,13 +37,13 @@ sub custom_status_output { sub custom_usage_output { my ($self, %options) = @_; - my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_space_absolute}); - my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_space_absolute}); - my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_space_absolute}); + my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_space}); + my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_space}); + my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_space}); my $msg = sprintf('space usage total: %s used: %s (%.2f%%) free: %s (%.2f%%)', $total_size_value . " " . $total_size_unit, - $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used_space_absolute}, - $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free_space_absolute} + $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used_space}, + $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free_space} ); return $msg; } @@ -51,15 +51,15 @@ sub custom_usage_output { sub custom_subscribed_output { my ($self, %options) = @_; - my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_space_absolute}); - my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_sub_absolute}); - $self->{result_values}->{free_sub_absolute} = 0 if ($self->{result_values}->{free_sub_absolute} < 0); - $self->{result_values}->{prct_free_sub_absolute} = 0 if ($self->{result_values}->{prct_free_sub_absolute} < 0); - my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_sub_absolute}); + my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_space}); + my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_sub}); + $self->{result_values}->{free_sub} = 0 if ($self->{result_values}->{free_sub} < 0); + $self->{result_values}->{prct_free_sub} = 0 if ($self->{result_values}->{prct_free_sub} < 0); + my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_sub}); my $msg = sprintf('subscribed usage total: %s used: %s (%.2f%%) free: %s (%.2f%%)', $total_size_value . " " . $total_size_unit, - $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used_sub_absolute}, - $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free_sub_absolute} + $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used_sub}, + $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free_sub} ); return $msg; } @@ -84,8 +84,8 @@ sub set_counters { key_values => [ { name => 'used_space' }, { name => 'free_space' }, { name => 'prct_used_space' }, { name => 'prct_free_space' }, { name => 'total_space' }, { name => 'display' }, ], closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ - { value => 'used_space_absolute', template => '%d', min => 0, max => 'total_space_absolute', - unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'used_space', template => '%d', min => 0, max => 'total_space', + unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -93,8 +93,8 @@ sub set_counters { key_values => [ { name => 'free_space' }, { name => 'used_space' }, { name => 'prct_used_space' }, { name => 'prct_free_space' }, { name => 'total_space' }, { name => 'display' }, ], closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ - { value => 'free_space_absolute', template => '%d', min => 0, max => 'total_space_absolute', - unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'free_space', template => '%d', min => 0, max => 'total_space', + unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -102,8 +102,8 @@ sub set_counters { key_values => [ { name => 'prct_used_space' }, { name => 'display' } ], output_template => 'used : %.2f %%', perfdatas => [ - { value => 'prct_used_space_absolute', template => '%.2f', min => 0, max => 100, - unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'prct_used_space', template => '%.2f', min => 0, max => 100, + unit => '%', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -111,8 +111,8 @@ sub set_counters { key_values => [ { name => 'used_sub' }, { name => 'free_sub' }, { name => 'prct_used_sub' }, { name => 'prct_free_sub' }, { name => 'total_space' }, { name => 'display' }, ], closure_custom_output => $self->can('custom_subscribed_output'), perfdatas => [ - { value => 'used_sub_absolute', template => '%d', min => 0, max => 'total_space_absolute', - unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'used_sub', template => '%d', min => 0, max => 'total_space', + unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -120,8 +120,8 @@ sub set_counters { key_values => [ { name => 'prct_used_sub' }, { name => 'display' } ], output_template => 'subcribed used : %.2f %%', perfdatas => [ - { value => 'prct_used_sub_absolute', template => '%.2f', min => 0, max => 100, - unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'prct_used_sub', template => '%.2f', min => 0, max => 100, + unit => '%', label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/storage/emc/unisphere/restapi/mode/storageresources.pm b/storage/emc/unisphere/restapi/mode/storageresources.pm index 87fb88220..57815a469 100644 --- a/storage/emc/unisphere/restapi/mode/storageresources.pm +++ b/storage/emc/unisphere/restapi/mode/storageresources.pm @@ -37,13 +37,13 @@ sub custom_status_output { sub custom_usage_output { my ($self, %options) = @_; - my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_space_absolute}); - my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_space_absolute}); - my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_space_absolute}); + my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_space}); + my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_space}); + my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_space}); my $msg = sprintf('space usage total: %s used: %s (%.2f%%) free: %s (%.2f%%)', $total_size_value . " " . $total_size_unit, - $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used_space_absolute}, - $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free_space_absolute} + $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used_space}, + $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free_space} ); return $msg; } @@ -51,15 +51,15 @@ sub custom_usage_output { sub custom_allocated_output { my ($self, %options) = @_; - my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_space_absolute}); - my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_alloc_absolute}); - $self->{result_values}->{free_alloc_absolute} = 0 if ($self->{result_values}->{free_alloc_absolute} < 0); - $self->{result_values}->{prct_free_alloc_absolute} = 0 if ($self->{result_values}->{prct_free_alloc_absolute} < 0); - my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_alloc_absolute}); + my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_space}); + my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_alloc}); + $self->{result_values}->{free_alloc} = 0 if ($self->{result_values}->{free_alloc} < 0); + $self->{result_values}->{prct_free_alloc} = 0 if ($self->{result_values}->{prct_free_alloc} < 0); + my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_alloc}); my $msg = sprintf('allocated usage total: %s used: %s (%.2f%%) free: %s (%.2f%%)', $total_size_value . " " . $total_size_unit, - $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used_alloc_absolute}, - $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free_alloc_absolute} + $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used_alloc}, + $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free_alloc} ); return $msg; } @@ -84,8 +84,8 @@ sub set_counters { key_values => [ { name => 'used_space' }, { name => 'free_space' }, { name => 'prct_used_space' }, { name => 'prct_free_space' }, { name => 'total_space' }, { name => 'display' }, ], closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ - { value => 'used_space_absolute', template => '%d', min => 0, max => 'total_space_absolute', - unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'used_space', template => '%d', min => 0, max => 'total_space', + unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -93,8 +93,8 @@ sub set_counters { key_values => [ { name => 'free_space' }, { name => 'used_space' }, { name => 'prct_used_space' }, { name => 'prct_free_space' }, { name => 'total_space' }, { name => 'display' }, ], closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ - { value => 'free_space_absolute', template => '%d', min => 0, max => 'total_space_absolute', - unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'free_space', template => '%d', min => 0, max => 'total_space', + unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -102,8 +102,8 @@ sub set_counters { key_values => [ { name => 'prct_used_space' }, { name => 'display' } ], output_template => 'used : %.2f %%', perfdatas => [ - { value => 'prct_used_space_absolute', template => '%.2f', min => 0, max => 100, - unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'prct_used_space', template => '%.2f', min => 0, max => 100, + unit => '%', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -111,8 +111,8 @@ sub set_counters { key_values => [ { name => 'used_alloc' }, { name => 'free_alloc' }, { name => 'prct_used_alloc' }, { name => 'prct_free_alloc' }, { name => 'total_space' }, { name => 'display' }, ], closure_custom_output => $self->can('custom_allocated_output'), perfdatas => [ - { value => 'used_alloc_absolute', template => '%d', min => 0, max => 'total_space_absolute', - unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'used_alloc', template => '%d', min => 0, max => 'total_space', + unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -120,8 +120,8 @@ sub set_counters { key_values => [ { name => 'prct_used_alloc' }, { name => 'display' } ], output_template => 'allocated used : %.2f %%', perfdatas => [ - { value => 'prct_used_alloc_absolute', template => '%.2f', min => 0, max => 100, - unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'prct_used_alloc', template => '%.2f', min => 0, max => 100, + unit => '%', label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/storage/emc/xtremio/restapi/mode/ssdiops.pm b/storage/emc/xtremio/restapi/mode/ssdiops.pm index 816456b2c..a5c51d189 100644 --- a/storage/emc/xtremio/restapi/mode/ssdiops.pm +++ b/storage/emc/xtremio/restapi/mode/ssdiops.pm @@ -38,7 +38,7 @@ sub set_counters { key_values => [ { name => 'total' } ], output_template => 'Total : %s iops', perfdatas => [ - { label => 'total', value => 'total_absolute', template => '%s', + { label => 'total', value => 'total', template => '%s', min => 0, unit => 'iops' }, ], } @@ -47,7 +47,7 @@ sub set_counters { key_values => [ { name => 'total_read' } ], output_template => 'Total read : %s iops', perfdatas => [ - { label => 'total_read', value => 'total_read_absolute', template => '%s', + { label => 'total_read', value => 'total_read', template => '%s', min => 0, unit => 'iops' }, ], } @@ -56,7 +56,7 @@ sub set_counters { key_values => [ { name => 'total_write' } ], output_template => 'Total write : %s iops', perfdatas => [ - { label => 'total_write', value => 'total_write_absolute', template => '%s', + { label => 'total_write', value => 'total_write', template => '%s', min => 0, unit => 'iops' }, ], } @@ -68,8 +68,8 @@ sub set_counters { key_values => [ { name => 'global_iops' }, { name => 'display' }, ], output_template => 'Global : %s iops', perfdatas => [ - { label => 'global', value => 'global_iops_absolute', template => '%s', - min => 0, unit => 'iops', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'global', value => 'global_iops', template => '%s', + min => 0, unit => 'iops', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -77,8 +77,8 @@ sub set_counters { key_values => [ { name => 'read_iops' }, { name => 'display' }, ], output_template => 'Read : %s iops', perfdatas => [ - { label => 'read', value => 'read_iops_absolute', template => '%s', - min => 0, unit => 'iops', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'read', value => 'read_iops', template => '%s', + min => 0, unit => 'iops', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -86,8 +86,8 @@ sub set_counters { key_values => [ { name => 'write_iops' }, { name => 'display' }, ], output_template => 'Write : %s iopss', perfdatas => [ - { label => 'write', value => 'write_iops_absolute', template => '%s', - min => 0, unit => 'iops', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'write', value => 'write_iops', template => '%s', + min => 0, unit => 'iops', label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/storage/fujitsu/eternus/dx/ssh/mode/cpu.pm b/storage/fujitsu/eternus/dx/ssh/mode/cpu.pm index 5ae8aca14..a15f638b9 100644 --- a/storage/fujitsu/eternus/dx/ssh/mode/cpu.pm +++ b/storage/fujitsu/eternus/dx/ssh/mode/cpu.pm @@ -38,8 +38,8 @@ sub set_counters { key_values => [ { name => 'usage' }, { name => 'display' } ], output_template => 'Usage : %d %%', perfdatas => [ - { label => 'cpu', value => 'usage_absolute', template => '%d', - unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'cpu', value => 'usage', template => '%d', + unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/storage/fujitsu/eternus/dx/ssh/mode/portstats.pm b/storage/fujitsu/eternus/dx/ssh/mode/portstats.pm index cdb6fe8e0..1a6bd8036 100644 --- a/storage/fujitsu/eternus/dx/ssh/mode/portstats.pm +++ b/storage/fujitsu/eternus/dx/ssh/mode/portstats.pm @@ -38,8 +38,8 @@ sub set_counters { key_values => [ { name => 'read_iops' }, { name => 'display' } ], output_template => 'Read IOPS : %d', perfdatas => [ - { label => 'read_iops', value => 'read_iops_absolute', template => '%d', - unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'read_iops', value => 'read_iops', template => '%d', + unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -47,8 +47,8 @@ sub set_counters { key_values => [ { name => 'write_iops' }, { name => 'display' } ], output_template => 'Write IOPS : %d', perfdatas => [ - { label => 'write_iops', value => 'write_iops_absolute', template => '%d', - unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'write_iops', value => 'write_iops', template => '%d', + unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -56,8 +56,8 @@ sub set_counters { key_values => [ { name => 'read_traffic' }, { name => 'display' } ], output_template => 'Read Traffic : %s %s/s', output_change_bytes => 2, perfdatas => [ - { label => 'read_traffic', value => 'read_traffic_absolute', template => '%d', - unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'read_traffic', value => 'read_traffic', template => '%d', + unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -65,8 +65,8 @@ sub set_counters { key_values => [ { name => 'write_traffic' }, { name => 'display' } ], output_template => 'Write Traffic : %s %s/s', output_change_bytes => 2, perfdatas => [ - { label => 'write_traffic', value => 'write_traffic_absolute', template => '%d', - unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'write_traffic', value => 'write_traffic', template => '%d', + unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/storage/fujitsu/eternus/dx/ssh/mode/volumestats.pm b/storage/fujitsu/eternus/dx/ssh/mode/volumestats.pm index 5251608cd..55a096ee0 100644 --- a/storage/fujitsu/eternus/dx/ssh/mode/volumestats.pm +++ b/storage/fujitsu/eternus/dx/ssh/mode/volumestats.pm @@ -38,8 +38,8 @@ sub set_counters { key_values => [ { name => 'read_iops' }, { name => 'display' } ], output_template => 'Read IOPS : %d', perfdatas => [ - { label => 'read_iops', value => 'read_iops_absolute', template => '%d', - unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'read_iops', value => 'read_iops', template => '%d', + unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -47,8 +47,8 @@ sub set_counters { key_values => [ { name => 'write_iops' }, { name => 'display' } ], output_template => 'Write IOPS : %d', perfdatas => [ - { label => 'write_iops', value => 'write_iops_absolute', template => '%d', - unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'write_iops', value => 'write_iops', template => '%d', + unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -56,8 +56,8 @@ sub set_counters { key_values => [ { name => 'read_throughput' }, { name => 'display' } ], output_template => 'Read Traffic : %s %s/s', output_change_bytes => 2, perfdatas => [ - { label => 'read_throughput', value => 'read_throughput_absolute', template => '%d', - unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'read_throughput', value => 'read_throughput', template => '%d', + unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -65,8 +65,8 @@ sub set_counters { key_values => [ { name => 'write_throughput' }, { name => 'display' } ], output_template => 'Write Traffic : %s %s/s', output_change_bytes => 2, perfdatas => [ - { label => 'write_throughput', value => 'write_throughput_absolute', template => '%d', - unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'write_throughput', value => 'write_throughput', template => '%d', + unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -74,8 +74,8 @@ sub set_counters { key_values => [ { name => 'read_response_time' }, { name => 'display' } ], output_template => 'Read Response Time : %d ms', perfdatas => [ - { label => 'read_response_time', value => 'read_response_time_absolute', template => '%d', - unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'read_response_time', value => 'read_response_time', template => '%d', + unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -83,8 +83,8 @@ sub set_counters { key_values => [ { name => 'write_response_time' }, { name => 'display' } ], output_template => 'Write Response Time : %d ms', perfdatas => [ - { label => 'write_response_time', value => 'write_response_time_absolute', template => '%d', - unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'write_response_time', value => 'write_response_time', template => '%d', + unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -92,8 +92,8 @@ sub set_counters { key_values => [ { name => 'read_processing_time' }, { name => 'display' } ], output_template => 'Read Processing Time : %d ms', perfdatas => [ - { label => 'read_processing_time', value => 'read_processing_time_absolute', template => '%d', - unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'read_processing_time', value => 'read_processing_time', template => '%d', + unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -101,8 +101,8 @@ sub set_counters { key_values => [ { name => 'write_processing_time' }, { name => 'display' } ], output_template => 'Write Processing Time : %d ms', perfdatas => [ - { label => 'write_processing_time', value => 'write_processing_time_absolute', template => '%d', - unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'write_processing_time', value => 'write_processing_time', template => '%d', + unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -110,8 +110,8 @@ sub set_counters { key_values => [ { name => 'read_cache_hit_rate' }, { name => 'display' } ], output_template => 'Read Cache Hit Rate : %d %%', perfdatas => [ - { label => 'read_cache_hit_rate', value => 'read_cache_hit_rate_absolute', template => '%d', - unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'read_cache_hit_rate', value => 'read_cache_hit_rate', template => '%d', + unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -119,8 +119,8 @@ sub set_counters { key_values => [ { name => 'write_cache_hit_rate' }, { name => 'display' } ], output_template => 'Write Cache Hit Rate : %d %%', perfdatas => [ - { label => 'write_cache_hit_rate', value => 'write_cache_hit_rate_absolute', template => '%d', - unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'write_cache_hit_rate', value => 'write_cache_hit_rate', template => '%d', + unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/storage/hp/3par/ssh/mode/diskusage.pm b/storage/hp/3par/ssh/mode/diskusage.pm index aa0063094..e61737403 100644 --- a/storage/hp/3par/ssh/mode/diskusage.pm +++ b/storage/hp/3par/ssh/mode/diskusage.pm @@ -36,13 +36,13 @@ sub custom_status_output { sub custom_usage_output { my ($self, %options) = @_; - my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_absolute}); - my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_absolute}); - my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute}); + my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}); + my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}); + my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}); my $msg = sprintf("Usage Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", $total_size_value . " " . $total_size_unit, - $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used_absolute}, - $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free_absolute}); + $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used}, + $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free}); return $msg; } @@ -66,8 +66,8 @@ sub set_counters { key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'display' }, ], closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ - { label => 'used', value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute', - unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'used', value => 'used', template => '%d', min => 0, max => 'total', + unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -75,8 +75,8 @@ sub set_counters { key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'display' }, ], closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ - { label => 'free', value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute', - unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'free', value => 'free', template => '%d', min => 0, max => 'total', + unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -84,8 +84,8 @@ sub set_counters { key_values => [ { name => 'prct_used' }, { name => 'display' } ], output_template => 'Used : %.2f %%', perfdatas => [ - { label => 'used_prct', value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, - unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'used_prct', value => 'prct_used', template => '%.2f', min => 0, max => 100, + unit => '%', label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/storage/hp/3par/ssh/mode/volumeusage.pm b/storage/hp/3par/ssh/mode/volumeusage.pm index e2a5b502a..4f900d840 100644 --- a/storage/hp/3par/ssh/mode/volumeusage.pm +++ b/storage/hp/3par/ssh/mode/volumeusage.pm @@ -28,13 +28,13 @@ use warnings; sub custom_usage_output { my ($self, %options) = @_; - my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_absolute}); - my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_absolute}); - my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute}); + my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}); + my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}); + my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}); my $msg = sprintf("Usage Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", $total_size_value . " " . $total_size_unit, - $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used_absolute}, - $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free_absolute}); + $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used}, + $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free}); return $msg; } @@ -50,8 +50,8 @@ sub set_counters { key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'display' }, ], closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ - { label => 'used', value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute', - unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'used', value => 'used', template => '%d', min => 0, max => 'total', + unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -59,8 +59,8 @@ sub set_counters { key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'display' }, ], closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ - { label => 'free', value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute', - unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'free', value => 'free', template => '%d', min => 0, max => 'total', + unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -68,8 +68,8 @@ sub set_counters { key_values => [ { name => 'prct_used' }, { name => 'display' } ], output_template => 'Used : %.2f %%', perfdatas => [ - { label => 'used_prct', value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, - unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'used_prct', value => 'prct_used', template => '%.2f', min => 0, max => 100, + unit => '%', label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/storage/hp/lefthand/snmp/mode/volumeusage.pm b/storage/hp/lefthand/snmp/mode/volumeusage.pm index 7c3a84525..494d1ca6b 100644 --- a/storage/hp/lefthand/snmp/mode/volumeusage.pm +++ b/storage/hp/lefthand/snmp/mode/volumeusage.pm @@ -125,42 +125,40 @@ sub set_counters { } }, { label => 'read', set => { - key_values => [ { name => 'clusVolumeStatsKbytesRead', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'clusVolumeStatsKbytesRead', per_second => 1 }, { name => 'display' } ], output_template => 'Read I/O : %s %s/s', output_error_template => "Read I/O : %s", - output_change_bytes => 1, per_second => 1, + output_change_bytes => 1, perfdatas => [ - { label => 'read', value => 'clusVolumeStatsKbytesRead_per_second', template => '%d', - unit => 'B/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'read', template => '%d', + unit => 'B/s', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'write', set => { - key_values => [ { name => 'clusVolumeStatsKbytesWrite', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'clusVolumeStatsKbytesWrite', per_second => 1 }, { name => 'display' } ], output_template => 'Write I/O : %s %s/s', output_error_template => "Write I/O : %s", - output_change_bytes => 1, per_second => 1, + output_change_bytes => 1, perfdatas => [ - { label => 'write', value => 'clusVolumeStatsKbytesWrite_per_second', template => '%d', - unit => 'B/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'write', template => '%d', + unit => 'B/s', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'read-iops', set => { - key_values => [ { name => 'clusVolumeStatsIOsRead', diff => 1 }, { name => 'display' } ], - per_second => 1, + key_values => [ { name => 'clusVolumeStatsIOsRead', per_second => 1 }, { name => 'display' } ], output_template => 'Read IOPs : %.2f', output_error_template => "Read IOPs : %s", perfdatas => [ - { label => 'read_iops', value => 'clusVolumeStatsIOsRead_per_second', template => '%.2f', - unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'read_iops', template => '%.2f', + unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'write-iops', set => { - key_values => [ { name => 'clusVolumeStatsIOsWrite', diff => 1 }, { name => 'display' } ], - per_second => 1, + key_values => [ { name => 'clusVolumeStatsIOsWrite', per_second => 1 }, { name => 'display' } ], output_template => 'Write IOPs : %.2f', output_error_template => "Write IOPs : %s", perfdatas => [ - { label => 'write_iops', value => 'clusVolumeStatsIOsWrite_per_second', template => '%.2f', - unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'write_iops', template => '%.2f', + unit => 'iops', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -168,8 +166,8 @@ sub set_counters { key_values => [ { name => 'clusVolumeStatsIoLatencyRead', diff => 1 }, { name => 'display' } ], output_template => 'Read Latency : %.2f ms', output_error_template => "Read Latency : %s", perfdatas => [ - { label => 'read_latency', value => 'clusVolumeStatsIoLatencyRead_absolute', template => '%.2f', - unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'read_latency', template => '%.2f', + unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -177,8 +175,8 @@ sub set_counters { key_values => [ { name => 'clusVolumeStatsIoLatencyWrite', diff => 1 }, { name => 'display' } ], output_template => 'Write Latency : %.2f ms', output_error_template => "Write Latency : %s", perfdatas => [ - { label => 'write_latency', value => 'clusVolumeStatsIoLatencyWrite_absolute', template => '%.2f', - unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'write_latency', template => '%.2f', + unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -187,9 +185,9 @@ sub set_counters { closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => \&catalog_status_threshold, + closure_custom_threshold_check => \&catalog_status_threshold } - }, + } ]; } @@ -199,11 +197,11 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - "filter-name:s" => { name => 'filter_name' }, - "warning-replication-status:s" => { name => 'warning_replication_status', default => '' }, - "critical-replication-status:s" => { name => 'critical_replication_status', default => '%{status} !~ /normal/i' }, - "units:s" => { name => 'units', default => '%' }, - "free" => { name => 'free' }, + 'filter-name:s' => { name => 'filter_name' }, + 'warning-replication-status:s' => { name => 'warning_replication_status', default => '' }, + 'critical-replication-status:s' => { name => 'critical_replication_status', default => '%{status} !~ /normal/i' }, + 'units:s' => { name => 'units', default => '%' }, + 'free' => { name => 'free' } }); return $self; diff --git a/storage/hp/p2000/xmlapi/mode/vdisks.pm b/storage/hp/p2000/xmlapi/mode/vdisks.pm index da4cf1183..f36098eb2 100644 --- a/storage/hp/p2000/xmlapi/mode/vdisks.pm +++ b/storage/hp/p2000/xmlapi/mode/vdisks.pm @@ -36,13 +36,13 @@ sub custom_status_output { sub custom_usage_output { my ($self, %options) = @_; - my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_space_absolute}); - my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_space_absolute}); - my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_space_absolute}); + my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_space}); + my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_space}); + my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_space}); my $msg = sprintf('space usage total: %s used: %s (%.2f%%) free: %s (%.2f%%)', $total_size_value . " " . $total_size_unit, - $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used_space_absolute}, - $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free_space_absolute} + $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used_space}, + $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free_space} ); return $msg; } @@ -67,8 +67,8 @@ sub set_counters { key_values => [ { name => 'used_space' }, { name => 'free_space' }, { name => 'prct_used_space' }, { name => 'prct_free_space' }, { name => 'total_space' }, { name => 'display' }, ], closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ - { value => 'used_space_absolute', template => '%d', min => 0, max => 'total_space_absolute', - unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'used_space', template => '%d', min => 0, max => 'total_space', + unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -76,8 +76,8 @@ sub set_counters { key_values => [ { name => 'free_space' }, { name => 'used_space' }, { name => 'prct_used_space' }, { name => 'prct_free_space' }, { name => 'total_space' }, { name => 'display' }, ], closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ - { value => 'free_space_absolute', template => '%d', min => 0, max => 'total_space_absolute', - unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'free_space', template => '%d', min => 0, max => 'total_space', + unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -85,8 +85,8 @@ sub set_counters { key_values => [ { name => 'prct_used_space' }, { name => 'display' } ], output_template => 'used : %.2f %%', perfdatas => [ - { value => 'prct_used_space_absolute', template => '%.2f', min => 0, max => 100, - unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'prct_used_space', template => '%.2f', min => 0, max => 100, + unit => '%', label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/storage/hp/p2000/xmlapi/mode/volumesstats.pm b/storage/hp/p2000/xmlapi/mode/volumesstats.pm index df1cb53b1..a415698be 100644 --- a/storage/hp/p2000/xmlapi/mode/volumesstats.pm +++ b/storage/hp/p2000/xmlapi/mode/volumesstats.pm @@ -65,24 +65,20 @@ sub set_counters { $self->{maps_counters}->{volume} = [ { label => 'read', nlabel => 'volume.io.read.usage.bytespersecond', set => { - key_values => [ { name => 'data-read-numeric', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'data-read-numeric', per_second => 1 } ], output_template => 'Read I/O : %s %s/s', output_change_bytes => 1, perfdatas => [ - { value => 'data-read-numeric_per_second', template => '%d', - unit => 'B/s', min => 0, label_extra_instance => 1 }, + { template => '%d', unit => 'B/s', min => 0, label_extra_instance => 1 }, ], } }, { label => 'write', nlabel => 'volume.io.write.usage.bytespersecond', set => { - key_values => [ { name => 'data-written-numeric', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'data-written-numeric', per_second => 1 } ], output_template => 'Write I/O : %s %s/s', output_change_bytes => 1, perfdatas => [ - { value => 'data-written-numeric_per_second', template => '%d', - unit => 'B/s', min => 0, label_extra_instance => 1 }, + { template => '%d', unit => 'B/s', min => 0, label_extra_instance => 1 }, ], } }, @@ -112,11 +108,10 @@ sub set_counters { key_values => [ { name => 'iops' } ], output_template => 'IOPs : %s', perfdatas => [ - { value => 'iops_absolute', - unit => 'iops', min => 0, label_extra_instance => 1 }, - ], + { unit => 'iops', min => 0, label_extra_instance => 1 } + ] } - }, + } ]; } @@ -126,8 +121,8 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - 'name:s' => { name => 'name' }, - 'regexp' => { name => 'use_regexp' }, + 'name:s' => { name => 'name' }, + 'regexp' => { name => 'use_regexp' }, }); return $self; diff --git a/storage/hp/storeonce/restapi/mode/clusterusage.pm b/storage/hp/storeonce/restapi/mode/clusterusage.pm index 503d49ab4..1e430b549 100644 --- a/storage/hp/storeonce/restapi/mode/clusterusage.pm +++ b/storage/hp/storeonce/restapi/mode/clusterusage.pm @@ -135,8 +135,8 @@ sub set_counters { key_values => [ { name => 'dedup' }, { name => 'display' } ], output_template => 'Dedup Ratio : %.2f', perfdatas => [ - { label => 'dedup_ratio', value => 'dedup_absolute', template => '%.2f', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'dedup_ratio', value => 'dedup', template => '%.2f', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/storage/hp/storeonce/restapi/mode/fcsusage.pm b/storage/hp/storeonce/restapi/mode/fcsusage.pm index 33a1d6fe6..95a44d7ec 100644 --- a/storage/hp/storeonce/restapi/mode/fcsusage.pm +++ b/storage/hp/storeonce/restapi/mode/fcsusage.pm @@ -63,8 +63,8 @@ sub set_counters { output_template => 'Used : %s %s', output_change_bytes => 1, perfdatas => [ - { label => 'used', value => 'used_absolute', template => '%s', - unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'used', value => 'used', template => '%s', + unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -72,8 +72,8 @@ sub set_counters { key_values => [ { name => 'dedup' }, { name => 'display' } ], output_template => 'Dedup Ratio : %.2f', perfdatas => [ - { label => 'dedup_ratio', value => 'dedup_absolute', template => '%.2f', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'dedup_ratio', value => 'dedup', template => '%.2f', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -81,8 +81,8 @@ sub set_counters { key_values => [ { name => 'num_items' }, { name => 'display' } ], output_template => 'Num Items : %s', perfdatas => [ - { label => 'items', value => 'num_items_absolute', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'items', value => 'num_items', template => '%s', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/storage/hp/storeonce/restapi/mode/servicesetusage.pm b/storage/hp/storeonce/restapi/mode/servicesetusage.pm index 93c5e5519..bafc14c03 100644 --- a/storage/hp/storeonce/restapi/mode/servicesetusage.pm +++ b/storage/hp/storeonce/restapi/mode/servicesetusage.pm @@ -138,8 +138,8 @@ sub set_counters { key_values => [ { name => 'dedup' }, { name => 'display' } ], output_template => 'Dedup Ratio : %.2f', perfdatas => [ - { label => 'dedup_ratio', value => 'dedup_absolute', template => '%.2f', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'dedup_ratio', value => 'dedup', template => '%.2f', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/storage/ibm/fs900/snmp/mode/arraysstatus.pm b/storage/ibm/fs900/snmp/mode/arraysstatus.pm index a357b014f..2b3c5a142 100644 --- a/storage/ibm/fs900/snmp/mode/arraysstatus.pm +++ b/storage/ibm/fs900/snmp/mode/arraysstatus.pm @@ -60,8 +60,8 @@ sub set_counters { key_values => [ { name => 'arrayVDiskCount' }, { name => 'arrayId' } ], output_template => 'VDisk count: %s', perfdatas => [ - { label => 'vdisk_count', value => 'arrayVDiskCount_absolute', template => '%s', label_extra_instance => 1, - instance_use => 'arrayId_absolute', min => 0 }, + { label => 'vdisk_count', value => 'arrayVDiskCount', template => '%s', label_extra_instance => 1, + instance_use => 'arrayId', min => 0 }, ], } }, diff --git a/storage/ibm/fs900/snmp/mode/fcusage.pm b/storage/ibm/fs900/snmp/mode/fcusage.pm index a0c7f6b7f..8b6c282b8 100644 --- a/storage/ibm/fs900/snmp/mode/fcusage.pm +++ b/storage/ibm/fs900/snmp/mode/fcusage.pm @@ -96,8 +96,8 @@ sub set_counters { key_values => [ { name => 'fcReadIOPS' }, { name => 'fcObject' } ], output_template => 'Read IOPS: %s iops', perfdatas => [ - { label => 'read_iops', value => 'fcReadIOPS_absolute', template => '%s', label_extra_instance => 1, - instance_use => 'fcObject_absolute', min => 0, unit => 'iops' }, + { label => 'read_iops', value => 'fcReadIOPS', template => '%s', label_extra_instance => 1, + instance_use => 'fcObject', min => 0, unit => 'iops' }, ], } }, @@ -105,8 +105,8 @@ sub set_counters { key_values => [ { name => 'fcWriteIOPS' }, { name => 'fcObject' } ], output_template => 'Write IOPS: %s iops', perfdatas => [ - { label => 'write_iops', value => 'fcWriteIOPS_absolute', template => '%s', label_extra_instance => 1, - instance_use => 'fcObject_absolute', min => 0, unit => 'iops' }, + { label => 'write_iops', value => 'fcWriteIOPS', template => '%s', label_extra_instance => 1, + instance_use => 'fcObject', min => 0, unit => 'iops' }, ], } }, @@ -114,8 +114,8 @@ sub set_counters { key_values => [ { name => 'fcReadQueueDepth' }, { name => 'fcObject' } ], output_template => 'Read queue depth: %s', perfdatas => [ - { label => 'read_queue_depth', value => 'fcReadQueueDepth_absolute', template => '%s', label_extra_instance => 1, - instance_use => 'fcObject_absolute', min => 0, unit => 'iops' }, + { label => 'read_queue_depth', value => 'fcReadQueueDepth', template => '%s', label_extra_instance => 1, + instance_use => 'fcObject', min => 0, unit => 'iops' }, ], } }, @@ -123,8 +123,8 @@ sub set_counters { key_values => [ { name => 'fcWriteQueueDepth' }, { name => 'fcObject' } ], output_template => 'Write queue depth: %s', perfdatas => [ - { label => 'write_queue_depth', value => 'fcWriteQueueDepth_absolute', template => '%s', label_extra_instance => 1, - instance_use => 'fcObject_absolute', min => 0, unit => 'iops' }, + { label => 'write_queue_depth', value => 'fcWriteQueueDepth', template => '%s', label_extra_instance => 1, + instance_use => 'fcObject', min => 0, unit => 'iops' }, ], } }, diff --git a/storage/kaminario/restapi/mode/systemusage.pm b/storage/kaminario/restapi/mode/systemusage.pm index 569a5d935..b0a903ed2 100644 --- a/storage/kaminario/restapi/mode/systemusage.pm +++ b/storage/kaminario/restapi/mode/systemusage.pm @@ -38,7 +38,7 @@ sub set_counters { key_values => [ { name => 'iops_avg' } ], output_template => 'Average IOPs : %s', perfdatas => [ - { label => 'iops', value => 'iops_avg_absolute', template => '%s', + { label => 'iops', value => 'iops_avg', template => '%s', min => 0, unit => 'iops' }, ], } @@ -48,7 +48,7 @@ sub set_counters { output_template => 'Average Throughput : %s %s', output_change_bytes => 1, perfdatas => [ - { label => 'throughput', value => 'throughput_avg_absolute', template => '%s', + { label => 'throughput', value => 'throughput_avg', template => '%s', min => 0, unit => 'B' }, ], } @@ -57,7 +57,7 @@ sub set_counters { key_values => [ { name => 'latency_inner' } ], output_template => 'Latency Inner : %.6fms', perfdatas => [ - { label => 'latency_inner', value => 'latency_inner_absolute', template => '%.6f', + { label => 'latency_inner', value => 'latency_inner', template => '%.6f', min => 0, unit => 'ms' }, ], } @@ -66,7 +66,7 @@ sub set_counters { key_values => [ { name => 'latency_outer' } ], output_template => 'Latency Outer : %.6fms', perfdatas => [ - { label => 'latency_outer', value => 'latency_outer_absolute', template => '%.6f', + { label => 'latency_outer', value => 'latency_outer', template => '%.6f', min => 0, unit => 'ms' }, ], } @@ -78,8 +78,8 @@ sub set_counters { key_values => [ { name => 'iops_avg' }, { name => 'display' } ], output_template => 'Average IOPs : %s', perfdatas => [ - { label => 'iops', value => 'iops_avg_absolute', template => '%s', - min => 0, unit => 'iops', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'iops', value => 'iops_avg', template => '%s', + min => 0, unit => 'iops', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -88,8 +88,8 @@ sub set_counters { output_template => 'Average Throughput : %s %s', output_change_bytes => 1, perfdatas => [ - { label => 'throughput', value => 'throughput_avg_absolute', template => '%s', - min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'throughput', value => 'throughput_avg', template => '%s', + min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -97,8 +97,8 @@ sub set_counters { key_values => [ { name => 'latency_inner' }, { name => 'display' } ], output_template => 'Latency Inner : %.6fms', perfdatas => [ - { label => 'latency_inner', value => 'latency_inner_absolute', template => '%.6f', - min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'latency_inner', value => 'latency_inner', template => '%.6f', + min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -106,8 +106,8 @@ sub set_counters { key_values => [ { name => 'latency_outer' }, { name => 'display' } ], output_template => 'Latency Outer : %.6fms', perfdatas => [ - { label => 'latency_outer', value => 'latency_outer_absolute', template => '%.6f', - min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'latency_outer', value => 'latency_outer', template => '%.6f', + min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/storage/kaminario/restapi/mode/volumeusage.pm b/storage/kaminario/restapi/mode/volumeusage.pm index b9f6a26a6..1696e596a 100644 --- a/storage/kaminario/restapi/mode/volumeusage.pm +++ b/storage/kaminario/restapi/mode/volumeusage.pm @@ -37,8 +37,8 @@ sub set_counters { key_values => [ { name => 'iops_avg' }, { name => 'display' } ], output_template => 'Average IOPs : %s', perfdatas => [ - { label => 'iops', value => 'iops_avg_absolute', template => '%s', - min => 0, unit => 'iops', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'iops', value => 'iops_avg', template => '%s', + min => 0, unit => 'iops', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -47,8 +47,8 @@ sub set_counters { output_template => 'Average Throughput : %s %s', output_change_bytes => 1, perfdatas => [ - { label => 'throughput', value => 'throughput_avg_absolute', template => '%s', - min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'throughput', value => 'throughput_avg', template => '%s', + min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -56,8 +56,8 @@ sub set_counters { key_values => [ { name => 'latency_inner' }, { name => 'display' } ], output_template => 'Latency Inner : %.6fms', perfdatas => [ - { label => 'latency_inner', value => 'latency_inner_absolute', template => '%.6f', - min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'latency_inner', value => 'latency_inner', template => '%.6f', + min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -65,8 +65,8 @@ sub set_counters { key_values => [ { name => 'latency_outer' }, { name => 'display' } ], output_template => 'Latency Outer : %.6fms', perfdatas => [ - { label => 'latency_outer', value => 'latency_outer_absolute', template => '%.6f', - min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'latency_outer', value => 'latency_outer', template => '%.6f', + min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/storage/lenovo/iomega/snmp/mode/memory.pm b/storage/lenovo/iomega/snmp/mode/memory.pm index 41a997002..157d36343 100644 --- a/storage/lenovo/iomega/snmp/mode/memory.pm +++ b/storage/lenovo/iomega/snmp/mode/memory.pm @@ -30,11 +30,11 @@ sub custom_usage_output { return sprintf( 'Ram Total: %s %s Used (-buffers/cache): %s %s (%.2f%%) Free: %s %s (%.2f%%)', - $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_absolute}), - $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_absolute}), - $self->{result_values}->{prct_used_absolute}, - $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute}), - $self->{result_values}->{prct_free_absolute} + $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}), + $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}), + $self->{result_values}->{prct_used}, + $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}), + $self->{result_values}->{prct_free} ); } @@ -50,7 +50,7 @@ sub set_counters { key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ - { value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute', + { value => 'used', template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1 } ] } @@ -59,7 +59,7 @@ sub set_counters { key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ - { value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute', + { value => 'free', template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1 } ] } @@ -68,7 +68,7 @@ sub set_counters { key_values => [ { name => 'prct_used' } ], output_template => 'Ram Used : %.2f %%', perfdatas => [ - { value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, + { value => 'prct_used', template => '%.2f', min => 0, max => 100, unit => '%' } ] } @@ -78,7 +78,7 @@ sub set_counters { output_template => 'Buffer: %s %s', output_change_bytes => 1, perfdatas => [ - { value => 'buffer_absolute', template => '%d', + { value => 'buffer', template => '%d', min => 0, unit => 'B' } ] } @@ -88,7 +88,7 @@ sub set_counters { output_template => 'Cached: %s %s', output_change_bytes => 1, perfdatas => [ - { value => 'cached_absolute', template => '%d', + { value => 'cached', template => '%d', min => 0, unit => 'B' } ] } diff --git a/storage/netapp/ontap/oncommandapi/mode/clusterio.pm b/storage/netapp/ontap/oncommandapi/mode/clusterio.pm index 93b09c122..1a11219f9 100644 --- a/storage/netapp/ontap/oncommandapi/mode/clusterio.pm +++ b/storage/netapp/ontap/oncommandapi/mode/clusterio.pm @@ -44,8 +44,8 @@ sub set_counters { output_template => 'Total throughput: %.2f %s/s', output_change_bytes => 1, perfdatas => [ - { label => 'total_throughput', value => 'total_throughput_absolute', template => '%.2f', - min => 0, unit => 'B/s', label_extra_instance => 1, instance_use => 'name_absolute' }, + { label => 'total_throughput', value => 'total_throughput', template => '%.2f', + min => 0, unit => 'B/s', label_extra_instance => 1, instance_use => 'name' }, ], } }, @@ -53,8 +53,8 @@ sub set_counters { key_values => [ { name => 'total_ops' }, { name => 'name' } ], output_template => 'Total IOPS: %.2f ops/s', perfdatas => [ - { label => 'total_ops', value => 'total_ops_absolute', template => '%.2f', - min => 0, unit => 'ops/s', label_extra_instance => 1, instance_use => 'name_absolute' }, + { label => 'total_ops', value => 'total_ops', template => '%.2f', + min => 0, unit => 'ops/s', label_extra_instance => 1, instance_use => 'name' }, ], } }, diff --git a/storage/netapp/ontap/oncommandapi/mode/clusterusage.pm b/storage/netapp/ontap/oncommandapi/mode/clusterusage.pm index a90f45f24..930b94f54 100644 --- a/storage/netapp/ontap/oncommandapi/mode/clusterusage.pm +++ b/storage/netapp/ontap/oncommandapi/mode/clusterusage.pm @@ -43,8 +43,8 @@ sub set_counters { key_values => [ { name => 'max_node_utilization' }, { name => 'name' } ], output_template => 'Node utilization: %.2f %%', perfdatas => [ - { label => 'max_node_utilization', value => 'max_node_utilization_absolute', template => '%.2f', - min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'name_absolute' }, + { label => 'max_node_utilization', value => 'max_node_utilization', template => '%.2f', + min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'name' }, ], } }, @@ -52,8 +52,8 @@ sub set_counters { key_values => [ { name => 'max_aggregate_utilization' }, { name => 'name' } ], output_template => 'Aggregate utilization: %.2f %%', perfdatas => [ - { label => 'max_aggregate_utilization', value => 'max_aggregate_utilization_absolute', template => '%.2f', - min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'name_absolute' }, + { label => 'max_aggregate_utilization', value => 'max_aggregate_utilization', template => '%.2f', + min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'name' }, ], } }, diff --git a/storage/netapp/ontap/oncommandapi/mode/diskfailed.pm b/storage/netapp/ontap/oncommandapi/mode/diskfailed.pm index 6ba8e3680..e9f6ecd7f 100644 --- a/storage/netapp/ontap/oncommandapi/mode/diskfailed.pm +++ b/storage/netapp/ontap/oncommandapi/mode/diskfailed.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'failed' } ], output_template => 'Failed disks: %d', perfdatas => [ - { label => 'failed', value => 'failed_absolute', template => '%d', + { label => 'failed', value => 'failed', template => '%d', min => 0 }, ], } @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'pre_failed' } ], output_template => 'Pre-failed disks: %d', perfdatas => [ - { label => 'pre_failed', value => 'pre_failed_absolute', template => '%d', + { label => 'pre_failed', value => 'pre_failed', template => '%d', min => 0 }, ], } diff --git a/storage/netapp/ontap/oncommandapi/mode/diskspare.pm b/storage/netapp/ontap/oncommandapi/mode/diskspare.pm index 49fa4ffb1..1db7c293e 100644 --- a/storage/netapp/ontap/oncommandapi/mode/diskspare.pm +++ b/storage/netapp/ontap/oncommandapi/mode/diskspare.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'spare' } ], output_template => 'Spare disks: %d', perfdatas => [ - { label => 'spare', value => 'spare_absolute', template => '%d', + { label => 'spare', value => 'spare', template => '%d', min => 0 }, ], } @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'zeroed' } ], output_template => 'Zeroed disks: %d', perfdatas => [ - { label => 'zeroed', value => 'zeroed_absolute', template => '%d', + { label => 'zeroed', value => 'zeroed', template => '%d', min => 0 }, ], } @@ -55,7 +55,7 @@ sub set_counters { key_values => [ { name => 'not_zeroed' } ], output_template => 'Not zeroed disks: %d', perfdatas => [ - { label => 'not_zeroed', value => 'not_zeroed_absolute', template => '%d', + { label => 'not_zeroed', value => 'not_zeroed', template => '%d', min => 0 }, ], } diff --git a/storage/netapp/ontap/oncommandapi/mode/lunalignment.pm b/storage/netapp/ontap/oncommandapi/mode/lunalignment.pm index b2604736a..959cda854 100644 --- a/storage/netapp/ontap/oncommandapi/mode/lunalignment.pm +++ b/storage/netapp/ontap/oncommandapi/mode/lunalignment.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'aligned' } ], output_template => 'Luns aligned: %d', perfdatas => [ - { label => 'aligned', value => 'aligned_absolute', template => '%d', + { label => 'aligned', value => 'aligned', template => '%d', min => 0 }, ], } @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'misaligned' } ], output_template => 'Luns misaligned: %d', perfdatas => [ - { label => 'misaligned', value => 'misaligned_absolute', template => '%d', + { label => 'misaligned', value => 'misaligned', template => '%d', min => 0 }, ], } @@ -55,7 +55,7 @@ sub set_counters { key_values => [ { name => 'possibly_misaligned' } ], output_template => 'Luns possibly misaligned: %d', perfdatas => [ - { label => 'possibly_misaligned', value => 'possibly_misaligned_absolute', template => '%d', + { label => 'possibly_misaligned', value => 'possibly_misaligned', template => '%d', min => 0 }, ], } @@ -64,7 +64,7 @@ sub set_counters { key_values => [ { name => 'indeterminate' } ], output_template => 'Luns indeterminate: %d', perfdatas => [ - { label => 'indeterminate', value => 'indeterminate_absolute', template => '%d', + { label => 'indeterminate', value => 'indeterminate', template => '%d', min => 0 }, ], } @@ -73,7 +73,7 @@ sub set_counters { key_values => [ { name => 'partial_writes' } ], output_template => 'Luns partial writes: %d', perfdatas => [ - { label => 'partial_writes', value => 'partial_writes_absolute', template => '%d', + { label => 'partial_writes', value => 'partial_writes', template => '%d', min => 0 }, ], } @@ -82,7 +82,7 @@ sub set_counters { key_values => [ { name => 'not_mapped' } ], output_template => 'Luns not mapped: %d', perfdatas => [ - { label => 'not_mapped', value => 'not_mapped_absolute', template => '%d', + { label => 'not_mapped', value => 'not_mapped', template => '%d', min => 0 }, ], } diff --git a/storage/netapp/ontap/oncommandapi/mode/lunonline.pm b/storage/netapp/ontap/oncommandapi/mode/lunonline.pm index b587ebed7..bf3d917a2 100644 --- a/storage/netapp/ontap/oncommandapi/mode/lunonline.pm +++ b/storage/netapp/ontap/oncommandapi/mode/lunonline.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'online' } ], output_template => 'Luns online: %d', perfdatas => [ - { label => 'online', value => 'online_absolute', template => '%d', + { label => 'online', value => 'online', template => '%d', min => 0 }, ], } @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'not_online' } ], output_template => 'Luns not online: %d', perfdatas => [ - { label => 'not_online', value => 'not_online_absolute', template => '%d', + { label => 'not_online', value => 'not_online', template => '%d', min => 0 }, ], } @@ -55,7 +55,7 @@ sub set_counters { key_values => [ { name => 'mapped' } ], output_template => 'Luns mapped: %d', perfdatas => [ - { label => 'mapped', value => 'mapped_absolute', template => '%d', + { label => 'mapped', value => 'mapped', template => '%d', min => 0 }, ], } @@ -64,7 +64,7 @@ sub set_counters { key_values => [ { name => 'not_mapped' } ], output_template => 'Luns not mapped: %d', perfdatas => [ - { label => 'not_mapped', value => 'not_mapped_absolute', template => '%d', + { label => 'not_mapped', value => 'not_mapped', template => '%d', min => 0 }, ], } diff --git a/storage/netapp/ontap/oncommandapi/mode/nodehardwarestatus.pm b/storage/netapp/ontap/oncommandapi/mode/nodehardwarestatus.pm index 73cff9aa7..b0e14fe5c 100644 --- a/storage/netapp/ontap/oncommandapi/mode/nodehardwarestatus.pm +++ b/storage/netapp/ontap/oncommandapi/mode/nodehardwarestatus.pm @@ -74,8 +74,8 @@ sub set_counters { key_values => [ { name => 'failed_fan_count' }, { name => 'name' } ], output_template => '%d failed fan(s)', perfdatas => [ - { label => 'failed_fans', value => 'failed_fan_count_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'name_absolute' }, + { label => 'failed_fans', value => 'failed_fan_count', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'name' }, ], } }, @@ -83,8 +83,8 @@ sub set_counters { key_values => [ { name => 'failed_power_supply_count' }, { name => 'name' } ], output_template => '%d failed psu', perfdatas => [ - { label => 'failed_psu', value => 'failed_power_supply_count_absolute', template => '%d', - min => 0, label_extra_instance => 1, instance_use => 'name_absolute' }, + { label => 'failed_psu', value => 'failed_power_supply_count', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'name' }, ], } }, diff --git a/storage/netapp/ontap/oncommandapi/mode/snapmirrorusage.pm b/storage/netapp/ontap/oncommandapi/mode/snapmirrorusage.pm index b035117fd..6de1394c8 100644 --- a/storage/netapp/ontap/oncommandapi/mode/snapmirrorusage.pm +++ b/storage/netapp/ontap/oncommandapi/mode/snapmirrorusage.pm @@ -43,8 +43,8 @@ sub set_counters { key_values => [ { name => 'last_transfer_duration' }, { name => 'source_location' } ], output_template => 'Last transfer duration: %.2f s', perfdatas => [ - { label => 'last_transfer_duration', value => 'last_transfer_duration_absolute', template => '%.2f', - min => 0, unit => 's', label_extra_instance => 1, instance_use => 'source_location_absolute' }, + { label => 'last_transfer_duration', value => 'last_transfer_duration', template => '%.2f', + min => 0, unit => 's', label_extra_instance => 1, instance_use => 'source_location' }, ], } }, @@ -53,8 +53,8 @@ sub set_counters { output_template => 'Last transfer size: %s %s', output_change_bytes => 1, perfdatas => [ - { label => 'last_transfer_size', value => 'last_transfer_size_absolute', template => '%d', - min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'source_location_absolute' }, + { label => 'last_transfer_size', value => 'last_transfer_size', template => '%d', + min => 0, unit => 'B', label_extra_instance => 1, instance_use => 'source_location' }, ], } }, @@ -62,8 +62,8 @@ sub set_counters { key_values => [ { name => 'lag_time' }, { name => 'source_location' } ], output_template => 'Lag time: %.2f s', perfdatas => [ - { label => 'lag_time', value => 'lag_time_absolute', template => '%.2f', - min => 0, unit => 's', label_extra_instance => 1, instance_use => 'source_location_absolute' }, + { label => 'lag_time', value => 'lag_time', template => '%.2f', + min => 0, unit => 's', label_extra_instance => 1, instance_use => 'source_location' }, ], } }, diff --git a/storage/netapp/ontap/oncommandapi/mode/volumeio.pm b/storage/netapp/ontap/oncommandapi/mode/volumeio.pm index 674020deb..f9ebd0cb0 100644 --- a/storage/netapp/ontap/oncommandapi/mode/volumeio.pm +++ b/storage/netapp/ontap/oncommandapi/mode/volumeio.pm @@ -43,8 +43,8 @@ sub set_counters { key_values => [ { name => 'read_ops' }, { name => 'name' } ], output_template => 'Read IOPS: %.2f ops/s', perfdatas => [ - { label => 'read_iops', value => 'read_ops_absolute', template => '%.2f', - min => 0, unit => 'ops/s', label_extra_instance => 1, instance_use => 'name_absolute' }, + { label => 'read_iops', value => 'read_ops', template => '%.2f', + min => 0, unit => 'ops/s', label_extra_instance => 1, instance_use => 'name' }, ], } }, @@ -52,8 +52,8 @@ sub set_counters { key_values => [ { name => 'write_ops' }, { name => 'name' } ], output_template => 'Write IOPS: %.2f ops/s', perfdatas => [ - { label => 'write_iops', value => 'write_ops_absolute', template => '%.2f', - min => 0, unit => 'ops/s', label_extra_instance => 1, instance_use => 'name_absolute' }, + { label => 'write_iops', value => 'write_ops', template => '%.2f', + min => 0, unit => 'ops/s', label_extra_instance => 1, instance_use => 'name' }, ], } }, @@ -61,8 +61,8 @@ sub set_counters { key_values => [ { name => 'other_ops' }, { name => 'name' } ], output_template => 'Other IOPS: %.2f ops/s', perfdatas => [ - { label => 'other_iops', value => 'other_ops_absolute', template => '%.2f', - min => 0, unit => 'ops/s', label_extra_instance => 1, instance_use => 'name_absolute' }, + { label => 'other_iops', value => 'other_ops', template => '%.2f', + min => 0, unit => 'ops/s', label_extra_instance => 1, instance_use => 'name' }, ], } }, @@ -70,8 +70,8 @@ sub set_counters { key_values => [ { name => 'avg_latency' }, { name => 'name' } ], output_template => 'Average latency: %.2f ms', perfdatas => [ - { label => 'avg_latency', value => 'avg_latency_absolute', template => '%.2f', - min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'name_absolute' }, + { label => 'avg_latency', value => 'avg_latency', template => '%.2f', + min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'name' }, ], } }, @@ -79,8 +79,8 @@ sub set_counters { key_values => [ { name => 'read_latency' }, { name => 'name' } ], output_template => 'Read latency: %.2f ms', perfdatas => [ - { label => 'read_latency', value => 'read_latency_absolute', template => '%.2f', - min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'name_absolute' }, + { label => 'read_latency', value => 'read_latency', template => '%.2f', + min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'name' }, ], } }, @@ -88,8 +88,8 @@ sub set_counters { key_values => [ { name => 'write_latency' }, { name => 'name' } ], output_template => 'Write latency: %.2f ms', perfdatas => [ - { label => 'write_latency', value => 'write_latency_absolute', template => '%.2f', - min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'name_absolute' }, + { label => 'write_latency', value => 'write_latency', template => '%.2f', + min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'name' }, ], } }, @@ -97,8 +97,8 @@ sub set_counters { key_values => [ { name => 'other_latency' }, { name => 'name' } ], output_template => 'Other latency: %.2f ms', perfdatas => [ - { label => 'other_latency', value => 'other_latency_absolute', template => '%.2f', - min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'name_absolute' }, + { label => 'other_latency', value => 'other_latency', template => '%.2f', + min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'name' }, ], } }, diff --git a/storage/netapp/ontap/snmp/mode/cpstatistics.pm b/storage/netapp/ontap/snmp/mode/cpstatistics.pm index bf5d06254..a827424d0 100644 --- a/storage/netapp/ontap/snmp/mode/cpstatistics.pm +++ b/storage/netapp/ontap/snmp/mode/cpstatistics.pm @@ -38,7 +38,7 @@ sub set_counters { key_values => [ { name => 'timer', diff => 1 }, ], output_template => 'CP timer : %s', perfdatas => [ - { value => 'timer_absolute', template => '%d', min => 0 }, + { value => 'timer', template => '%d', min => 0 }, ], } }, @@ -46,7 +46,7 @@ sub set_counters { key_values => [ { name => 'snapshot', diff => 1 }, ], output_template => 'CP snapshot : %s', perfdatas => [ - { value => 'snapshot_absolute', template => '%d', min => 0 }, + { value => 'snapshot', template => '%d', min => 0 }, ], } }, @@ -54,7 +54,7 @@ sub set_counters { key_values => [ { name => 'lowerwater', diff => 1 }, ], output_template => 'CP low water mark : %s', perfdatas => [ - { value => 'lowerwater_absolute', template => '%d', min => 0 }, + { value => 'lowerwater', template => '%d', min => 0 }, ], } }, @@ -62,7 +62,7 @@ sub set_counters { key_values => [ { name => 'highwater', diff => 1 }, ], output_template => 'CP high water mark : %s', perfdatas => [ - { value => 'highwater_absolute', template => '%d', min => 0 }, + { value => 'highwater', template => '%d', min => 0 }, ], } }, @@ -70,7 +70,7 @@ sub set_counters { key_values => [ { name => 'logfull', diff => 1 }, ], output_template => 'CP nv-log full : %s', perfdatas => [ - { value => 'logfull_absolute', template => '%d', min => 0 }, + { value => 'logfull', template => '%d', min => 0 }, ], } }, @@ -78,7 +78,7 @@ sub set_counters { key_values => [ { name => 'back', diff => 1 }, ], output_template => 'CP back-to-back : %s', perfdatas => [ - { value => 'back_absolute', template => '%d', min => 0 }, + { value => 'back', template => '%d', min => 0 }, ], } }, @@ -86,7 +86,7 @@ sub set_counters { key_values => [ { name => 'flush', diff => 1 }, ], output_template => 'CP flush unlogged write data : %s', perfdatas => [ - { value => 'flush_absolute', template => '%d', min => 0 }, + { value => 'flush', template => '%d', min => 0 }, ], } }, @@ -94,7 +94,7 @@ sub set_counters { key_values => [ { name => 'sync', diff => 1 }, ], output_template => 'CP sync requests : %s', perfdatas => [ - { value => 'sync_absolute', template => '%d', min => 0 }, + { value => 'sync', template => '%d', min => 0 }, ], } }, @@ -102,7 +102,7 @@ sub set_counters { key_values => [ { name => 'lowvbuf', diff => 1 }, ], output_template => 'CP low virtual buffers : %s', perfdatas => [ - { value => 'lowvbuf_absolute', template => '%d', min => 0 }, + { value => 'lowvbuf', template => '%d', min => 0 }, ], } }, @@ -110,7 +110,7 @@ sub set_counters { key_values => [ { name => 'deferred', diff => 1 }, ], output_template => 'CP deferred : %s', perfdatas => [ - { value => 'deferred_absolute', template => '%d', min => 0 }, + { value => 'deferred', template => '%d', min => 0 }, ], } }, @@ -118,7 +118,7 @@ sub set_counters { key_values => [ { name => 'lowdatavecs', diff => 1 }, ], output_template => 'CP low datavecs : %s', perfdatas => [ - { value => 'lowdatavecs_absolute', template => '%d', min => 0 }, + { value => 'lowdatavecs', template => '%d', min => 0 }, ], } }, diff --git a/storage/netapp/ontap/snmp/mode/filesys.pm b/storage/netapp/ontap/snmp/mode/filesys.pm index b197795b9..2405bfe37 100644 --- a/storage/netapp/ontap/snmp/mode/filesys.pm +++ b/storage/netapp/ontap/snmp/mode/filesys.pm @@ -57,8 +57,8 @@ sub set_counters { key_values => [ { name => 'dfPerCentInodeCapacity' }, { name => 'display' } ], output_template => 'Inodes Used : %s %%', output_error_template => "Inodes : %s", perfdatas => [ - { label => 'inodes', value => 'dfPerCentInodeCapacity_absolute', template => '%d', - unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'inodes', value => 'dfPerCentInodeCapacity', template => '%d', + unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -66,8 +66,8 @@ sub set_counters { key_values => [ { name => 'dfCompressSavedPercent' }, { name => 'display' } ], output_template => 'Compress Saved : %s %%', output_error_template => "Compress Saved : %s", perfdatas => [ - { label => 'compresssaved', value => 'dfCompressSavedPercent_absolute', template => '%d', - unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'compresssaved', value => 'dfCompressSavedPercent', template => '%d', + unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -75,8 +75,8 @@ sub set_counters { key_values => [ { name => 'dfDedupeSavedPercent' }, { name => 'display' } ], output_template => 'Dedupe Saved : %s %%', output_error_template => "Dedupe Saved : %s", perfdatas => [ - { label => 'dedupsaved', value => 'dfDedupeSavedPercent_absolute', template => '%d', - unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'dedupsaved', value => 'dfDedupeSavedPercent', template => '%d', + unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/storage/netapp/ontap/snmp/mode/globalstatus.pm b/storage/netapp/ontap/snmp/mode/globalstatus.pm index 7aead567f..e9ef13c99 100644 --- a/storage/netapp/ontap/snmp/mode/globalstatus.pm +++ b/storage/netapp/ontap/snmp/mode/globalstatus.pm @@ -35,27 +35,23 @@ sub set_counters { $self->{maps_counters}->{global} = [ { label => 'read', nlabel => 'storage.io.read.usage.bytespersecond', set => { - key_values => [ { name => 'read', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'read', per_second => 1 } ], output_template => 'Read I/O : %s %s/s', output_change_bytes => 1, perfdatas => [ - { value => 'read_per_second', template => '%d', - unit => 'B/s', min => 0 }, - ], + { template => '%d', unit => 'B/s', min => 0 } + ] } }, { label => 'write', nlabel => 'storage.io.write.usage.bytespersecond', set => { - key_values => [ { name => 'write', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'write', per_second => 1 } ], output_template => 'Write I/O : %s %s/s', output_change_bytes => 1, perfdatas => [ - { value => 'write_per_second', template => '%d', - unit => 'B/s', min => 0 }, - ], + { template => '%d', unit => 'B/s', min => 0 } + ] } - }, + } ]; } diff --git a/storage/netapp/ontap/snmp/mode/sharecalls.pm b/storage/netapp/ontap/snmp/mode/sharecalls.pm index f524fdfe6..e49294528 100644 --- a/storage/netapp/ontap/snmp/mode/sharecalls.pm +++ b/storage/netapp/ontap/snmp/mode/sharecalls.pm @@ -35,23 +35,21 @@ sub set_counters { $self->{maps_counters}->{global} = [ { label => 'cifs', nlabel => 'storage.cifs.calls.persecond', set => { - key_values => [ { name => 'cifs', diff => 1 }, ], - per_second => 1, + key_values => [ { name => 'cifs', per_second => 1 } ], output_template => 'CIFS : %s calls/s', perfdatas => [ - { value => 'cifs_per_second', template => '%d', min => 0 }, - ], + { template => '%d', min => 0 } + ] } }, { label => 'nfs', nlabel => 'storage.nfs.calls.persecond', set => { - key_values => [ { name => 'nfs', diff => 1 }, ], - per_second => 1, + key_values => [ { name => 'nfs', per_second => 1 } ], output_template => 'NFS : %s calls/s', perfdatas => [ - { value => 'nfs_per_second', template => '%d', min => 0 }, - ], + { template => '%d', min => 0 } + ] } - }, + } ]; } diff --git a/storage/netapp/ontap/snmp/mode/snapmirrorlag.pm b/storage/netapp/ontap/snmp/mode/snapmirrorlag.pm index da872b363..4277e53d6 100644 --- a/storage/netapp/ontap/snmp/mode/snapmirrorlag.pm +++ b/storage/netapp/ontap/snmp/mode/snapmirrorlag.pm @@ -55,8 +55,8 @@ sub set_counters { key_values => [ { name => 'lag' }, { name => 'display' } ], output_template => 'lag: %s seconds', perfdatas => [ - { label => 'lag', value => 'lag_absolute', template => '%s', min => 0, unit => 's', - label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'lag', value => 'lag', template => '%s', min => 0, unit => 's', + label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/storage/netapp/ontap/snmp/mode/snapvaultusage.pm b/storage/netapp/ontap/snmp/mode/snapvaultusage.pm index e39bc7c0c..72949c045 100644 --- a/storage/netapp/ontap/snmp/mode/snapvaultusage.pm +++ b/storage/netapp/ontap/snmp/mode/snapvaultusage.pm @@ -63,18 +63,18 @@ sub set_counters { key_values => [ { name => 'svLag' }, { name => 'display' } ], output_template => 'lag : %s seconds', perfdatas => [ - { label => 'lag', value => 'svLag_absolute', template => '%s', min => 0, unit => 's', - label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'lag', template => '%s', min => 0, unit => 's', + label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'transfer-traffic', set => { - key_values => [ { name => 'svTotalTransMBs', diff => 1 }, { name => 'display' } ], - per_second => 1, output_change_bytes => 1, + key_values => [ { name => 'svTotalTransMBs', per_second => 1 }, { name => 'display' } ], output_template => 'transfer traffic : %s %s/s', + output_change_bytes => 1, perfdatas => [ - { label => 'transfer_traffic', template => '%.2f', value => 'svTotalTransMBs_per_second', - unit => 'B/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'transfer_traffic', template => '%.2f', + unit => 'B/s', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -82,8 +82,8 @@ sub set_counters { key_values => [ { name => 'svTotalSuccesses' }, { name => 'display' } ], output_template => 'transfer succeed : %s', perfdatas => [ - { label => 'transfer_succeed', value => 'svTotalSuccesses_absolute', template => '%s', min => 0, - label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'transfer_succeed', template => '%s', min => 0, + label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -91,8 +91,8 @@ sub set_counters { key_values => [ { name => 'svTotalFailures' }, { name => 'display' } ], output_template => 'transfer failed : %s', perfdatas => [ - { label => 'transfer_failed', value => 'svTotalFailures_absolute', template => '%s', min => 0, - label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'transfer_failed', template => '%s', min => 0, + label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/storage/netapp/ontap/snmp/mode/volumeoptions.pm b/storage/netapp/ontap/snmp/mode/volumeoptions.pm index 5bef56586..1cea6ed95 100644 --- a/storage/netapp/ontap/snmp/mode/volumeoptions.pm +++ b/storage/netapp/ontap/snmp/mode/volumeoptions.pm @@ -86,7 +86,7 @@ sub set_counters { key_values => [ { name => 'failed' } ], output_template => 'Failed: %s', perfdatas => [ - { label => 'failed', value => 'failed_absolute', template => '%s', min => 0 }, + { label => 'failed', value => 'failed', template => '%s', min => 0 }, ], } }, diff --git a/storage/netapp/santricity/restapi/mode/storagecontrollers.pm b/storage/netapp/santricity/restapi/mode/storagecontrollers.pm index b8af42419..6fc59d935 100644 --- a/storage/netapp/santricity/restapi/mode/storagecontrollers.pm +++ b/storage/netapp/santricity/restapi/mode/storagecontrollers.pm @@ -75,52 +75,44 @@ sub set_counters { } }, { label => 'cpu-utilization', nlabel => 'volume.cpu.utilization.percentage', set => { - key_values => [ { name => 'cpu_util', diff => 1 }, { name => 'display' } ], - per_second => 1, + key_values => [ { name => 'cpu_util', per_second => 1 }, { name => 'display' } ], output_template => 'cpu usage: %.2f %%', perfdatas => [ - { value => 'cpu_util_per_second', template => '%d', - unit => '%', label_extra_instance => 1 } + { template => '%d', unit => '%', label_extra_instance => 1 } ] } }, { label => 'read', nlabel => 'volume.io.read.usage.bytespersecond', set => { - key_values => [ { name => 'read_bytes', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'read_bytes', per_second => 1 }, { name => 'display' } ], output_template => 'read: %s %s/s', - per_second => 1, output_change_bytes => 1, + output_change_bytes => 1, perfdatas => [ - { value => 'read_bytes_per_second', template => '%d', - unit => 'B/s', label_extra_instance => 1 } + { template => '%d', unit => 'B/s', label_extra_instance => 1 } ] } }, { label => 'write', nlabel => 'volume.io.write.usage.bytespersecond', set => { - key_values => [ { name => 'write_bytes', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'write_bytes', per_second => 1 }, { name => 'display' } ], output_template => 'write: %s %s/s', - per_second => 1, output_change_bytes => 1, + output_change_bytes => 1, perfdatas => [ - { value => 'write_bytes_per_second', template => '%d', - unit => 'B/s', min => 0, label_extra_instance => 1 } + { template => '%d', unit => 'B/s', min => 0, label_extra_instance => 1 } ] } }, { label => 'read-iops', nlabel => 'system.io.read.usage.iops', set => { - key_values => [ { name => 'read_iops', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'read_iops', per_second => 1 }, { name => 'display' } ], output_template => 'read: %.2f iops', - per_second => 1, perfdatas => [ - { value => 'read_iops_per_second', template => '%.2f', - unit => 'iops', min => 0, label_extra_instance => 1 } + { template => '%.2f', unit => 'iops', min => 0, label_extra_instance => 1 } ] } }, { label => 'write-iops', nlabel => 'system.io.write.usage.iops', set => { - key_values => [ { name => 'write_iops', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'write_iops', per_second => 1 }, { name => 'display' } ], output_template => 'write: %.2f iops', - per_second => 1, perfdatas => [ - { value => 'write_iops_per_second', template => '%.2f', - unit => 'iops', min => 0, label_extra_instance => 1 } + { template => '%.2f', unit => 'iops', min => 0, label_extra_instance => 1 } ] } } diff --git a/storage/netapp/santricity/restapi/mode/storagesystems.pm b/storage/netapp/santricity/restapi/mode/storagesystems.pm index a1ca67925..5c2b4cf1d 100644 --- a/storage/netapp/santricity/restapi/mode/storagesystems.pm +++ b/storage/netapp/santricity/restapi/mode/storagesystems.pm @@ -38,14 +38,14 @@ sub custom_status_output { sub custom_usage_output { my ($self, %options) = @_; - my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_space_absolute}); - my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_space_absolute}); - my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_space_absolute}); + my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_space}); + my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_space}); + my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_space}); my $msg = sprintf( 'space usage total: %s used: %s (%.2f%%) free: %s (%.2f%%)', $total_size_value . " " . $total_size_unit, - $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used_space_absolute}, - $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free_space_absolute} + $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used_space}, + $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free_space} ); return $msg; } @@ -76,7 +76,7 @@ sub set_counters { key_values => [ { name => 'used_space' }, { name => 'free_space' }, { name => 'prct_used_space' }, { name => 'prct_free_space' }, { name => 'total_space' }, { name => 'display' }, ], closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ - { value => 'used_space_absolute', template => '%d', min => 0, max => 'total_space_absolute', + { value => 'used_space', template => '%d', min => 0, max => 'total_space', unit => 'B', cast_int => 1, label_extra_instance => 1 } ] } @@ -85,7 +85,7 @@ sub set_counters { key_values => [ { name => 'free_space' }, { name => 'used_space' }, { name => 'prct_used_space' }, { name => 'prct_free_space' }, { name => 'total_space' }, { name => 'display' }, ], closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ - { value => 'free_space_absolute', template => '%d', min => 0, max => 'total_space_absolute', + { value => 'free_space', template => '%d', min => 0, max => 'total_space', unit => 'B', cast_int => 1, label_extra_instance => 1 } ] } @@ -94,7 +94,7 @@ sub set_counters { key_values => [ { name => 'prct_used_space' }, { name => 'display' } ], output_template => 'used : %.2f %%', perfdatas => [ - { value => 'prct_used_space_absolute', template => '%.2f', min => 0, max => 100, + { value => 'prct_used_space', template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 } ] } diff --git a/storage/netapp/santricity/restapi/mode/storagevolumes.pm b/storage/netapp/santricity/restapi/mode/storagevolumes.pm index 544ef1b40..2d61a8082 100644 --- a/storage/netapp/santricity/restapi/mode/storagevolumes.pm +++ b/storage/netapp/santricity/restapi/mode/storagevolumes.pm @@ -75,42 +75,36 @@ sub set_counters { } }, { label => 'read', nlabel => 'volume.io.read.usage.bytespersecond', set => { - key_values => [ { name => 'read_bytes', diff => 1 }, { name => 'display' } ], - per_second => 1, - output_change_bytes => 1, output_template => 'read: %s %s/s', + key_values => [ { name => 'read_bytes', per_second => 1 }, { name => 'display' } ], + output_template => 'read: %s %s/s', + output_change_bytes => 1, perfdatas => [ - { value => 'read_bytes_per_second', template => '%d', - unit => 'B/s', label_extra_instance => 1 } + { template => '%d', unit => 'B/s', label_extra_instance => 1 } ] } }, { label => 'write', nlabel => 'volume.io.write.usage.bytespersecond', set => { - key_values => [ { name => 'write_bytes', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'write_bytes', per_second => 1 }, { name => 'display' } ], output_template => 'write: %s %s/s', - per_second => 1, output_change_bytes => 1, + output_change_bytes => 1, perfdatas => [ - { value => 'write_bytes_per_second', template => '%d', - unit => 'B/s', min => 0, label_extra_instance => 1 } + { template => '%d', unit => 'B/s', min => 0, label_extra_instance => 1 } ] } }, { label => 'read-iops', nlabel => 'system.io.read.usage.iops', set => { - key_values => [ { name => 'read_iops', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'read_iops', per_second => 1 }, { name => 'display' } ], output_template => 'read: %.2f iops', - per_second => 1, perfdatas => [ - { value => 'read_iops_per_second', template => '%.2f', - unit => 'iops', min => 0, label_extra_instance => 1 } + { template => '%.2f', unit => 'iops', min => 0, label_extra_instance => 1 } ] } }, { label => 'write-iops', nlabel => 'system.io.write.usage.iops', set => { - key_values => [ { name => 'write_iops', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'write_iops', per_second => 1 }, { name => 'display' } ], output_template => 'write: %.2f iops', - per_second => 1, perfdatas => [ - { value => 'write_iops_per_second', template => '%.2f', - unit => 'iops', min => 0, label_extra_instance => 1 } + { template => '%.2f', unit => 'iops', min => 0, label_extra_instance => 1 } ] } } diff --git a/storage/nimble/snmp/mode/globalstats.pm b/storage/nimble/snmp/mode/globalstats.pm index 126b7b5ba..be3d3b65d 100644 --- a/storage/nimble/snmp/mode/globalstats.pm +++ b/storage/nimble/snmp/mode/globalstats.pm @@ -35,44 +35,36 @@ sub set_counters { $self->{maps_counters}->{global} = [ { label => 'read', nlabel => 'system.io.read.usage.bytespersecond', set => { - key_values => [ { name => 'read', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'read', per_second => 1 } ], output_template => 'Read I/O : %s %s/s', output_error_template => "Read I/O : %s", output_change_bytes => 1, perfdatas => [ - { label => 'read', value => 'read_per_second', template => '%d', - unit => 'B/s' }, + { label => 'read', template => '%d', unit => 'B/s' }, ], } }, { label => 'write', nlabel => 'system.io.write.usage.bytespersecond', set => { - key_values => [ { name => 'write', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'write', per_second => 1 } ], output_template => 'Write I/O : %s %s/s', output_error_template => "Write I/O : %s", output_change_bytes => 1, perfdatas => [ - { label => 'write', value => 'write_per_second', template => '%d', - unit => 'B/s', min => 0 }, + { label => 'write', template => '%d', unit => 'B/s', min => 0 }, ], } }, { label => 'read-iops', nlabel => 'system.io.read.usage.iops', set => { - key_values => [ { name => 'read_iops', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'read_iops', per_second => 1 } ], output_template => 'Read IOPs : %.2f', output_error_template => "Read IOPs : %s", perfdatas => [ - { label => 'read_iops', value => 'read_iops_per_second', template => '%.2f', - unit => 'iops', min => 0 }, + { label => 'read_iops', template => '%.2f', unit => 'iops', min => 0 }, ], } }, { label => 'write-iops', nlabel => 'system.io.write.usage.iops', set => { - key_values => [ { name => 'write_iops', diff => 1 } ], - per_second => 1, + key_values => [ { name => 'write_iops', per_second => 1 } ], output_template => 'Write IOPs : %.2f', output_error_template => "Write IOPs : %s", perfdatas => [ - { label => 'write_iops', value => 'write_iops_per_second', template => '%.2f', - unit => 'iops', min => 0 }, + { label => 'write_iops', template => '%.2f', unit => 'iops', min => 0 }, ], } }, @@ -80,8 +72,7 @@ sub set_counters { key_values => [ { name => 'read_time', diff => 1 } ], output_template => 'Read Time : %.3f s', output_error_template => "Read Time : %s", perfdatas => [ - { label => 'read_time', value => 'read_time_absolute', template => '%.3f', - unit => 's', min => 0 }, + { label => 'read_time', template => '%.3f', unit => 's', min => 0 }, ], } }, @@ -89,8 +80,7 @@ sub set_counters { key_values => [ { name => 'write_time', diff => 1 } ], output_template => 'Write Time : %.3f s', output_error_template => "Write Time : %s", perfdatas => [ - { label => 'write_time', value => 'write_time_absolute', template => '%.3f', - unit => 's', min => 0 }, + { label => 'write_time', template => '%.3f', unit => 's', min => 0 }, ], } }, diff --git a/storage/oracle/zs/restapi/mode/pools.pm b/storage/oracle/zs/restapi/mode/pools.pm index c7bcc5fc3..bb48c40d8 100644 --- a/storage/oracle/zs/restapi/mode/pools.pm +++ b/storage/oracle/zs/restapi/mode/pools.pm @@ -36,13 +36,13 @@ sub custom_status_output { sub custom_usage_output { my ($self, %options) = @_; - my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_space_absolute}); - my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_space_absolute}); - my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_space_absolute}); + my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_space}); + my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_space}); + my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_space}); my $msg = sprintf('space usage total: %s used: %s (%.2f%%) free: %s (%.2f%%)', $total_size_value . " " . $total_size_unit, - $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used_space_absolute}, - $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free_space_absolute} + $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used_space}, + $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free_space} ); return $msg; } @@ -67,8 +67,8 @@ sub set_counters { key_values => [ { name => 'used_space' }, { name => 'free_space' }, { name => 'prct_used_space' }, { name => 'prct_free_space' }, { name => 'total_space' }, { name => 'display' }, ], closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ - { value => 'used_space_absolute', template => '%d', min => 0, max => 'total_space_absolute', - unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'used_space', template => '%d', min => 0, max => 'total_space', + unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -76,8 +76,8 @@ sub set_counters { key_values => [ { name => 'free_space' }, { name => 'used_space' }, { name => 'prct_used_space' }, { name => 'prct_free_space' }, { name => 'total_space' }, { name => 'display' }, ], closure_custom_output => $self->can('custom_usage_output'), perfdatas => [ - { value => 'free_space_absolute', template => '%d', min => 0, max => 'total_space_absolute', - unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'free_space', template => '%d', min => 0, max => 'total_space', + unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -85,8 +85,8 @@ sub set_counters { key_values => [ { name => 'prct_used_space' }, { name => 'display' } ], output_template => 'used : %.2f %%', perfdatas => [ - { value => 'prct_used_space_absolute', template => '%.2f', min => 0, max => 100, - unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' }, + { value => 'prct_used_space', template => '%.2f', min => 0, max => 100, + unit => '%', label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/storage/panzura/snmp/mode/ratios.pm b/storage/panzura/snmp/mode/ratios.pm index 4f0cf53b7..4c8a795b7 100644 --- a/storage/panzura/snmp/mode/ratios.pm +++ b/storage/panzura/snmp/mode/ratios.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'dedup' }, ], output_template => 'Deduplication ratio : %.2f', perfdatas => [ - { value => 'dedup_absolute', template => '%.2f', min => 0 }, + { value => 'dedup', template => '%.2f', min => 0 }, ], } }, @@ -45,7 +45,7 @@ sub set_counters { key_values => [ { name => 'comp' }, ], output_template => 'Compression ratio : %.2f', perfdatas => [ - { value => 'comp_absolute', template => '%.2f', min => 0 }, + { value => 'comp', template => '%.2f', min => 0 }, ], } }, @@ -53,7 +53,7 @@ sub set_counters { key_values => [ { name => 'save' }, ], output_template => 'Save ratio : %.2f', perfdatas => [ - { value => 'save_absolute', template => '%.2f', min => 0 }, + { value => 'save', template => '%.2f', min => 0 }, ], } }, diff --git a/storage/purestorage/restapi/mode/pgroupreplication.pm b/storage/purestorage/restapi/mode/pgroupreplication.pm index c7510aa12..6692f1efa 100644 --- a/storage/purestorage/restapi/mode/pgroupreplication.pm +++ b/storage/purestorage/restapi/mode/pgroupreplication.pm @@ -39,28 +39,28 @@ sub set_counters { key_values => [ { name => 'progress' }, { name => 'display' } ], output_template => 'Progress : %s %%', perfdatas => [ - { label => 'progress', value => 'progress_absolute', template => '%s', unit => '%', - min => 0, max => 100, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'progress', value => 'progress', template => '%s', unit => '%', + min => 0, max => 100, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'creation', set => { key_values => [ { name => 'creation_human' }, { name => 'creation_seconds' }, { name => 'display' } ], - threshold_use => 'creation_seconds_absolute', + threshold_use => 'creation_seconds', output_template => 'Creation Time : %s', perfdatas => [ - { label => 'creation', value => 'creation_seconds_absolute', template => '%d', - unit => 's', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'creation', value => 'creation_seconds', template => '%d', + unit => 's', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, { label => 'duration', set => { key_values => [ { name => 'duration_human' }, { name => 'duration_seconds' }, { name => 'display' } ], - threshold_use => 'duration_seconds_absolute', + threshold_use => 'duration_seconds', output_template => 'Duration : %s', perfdatas => [ - { label => 'duration', value => 'duration_seconds_absolute', template => '%d', - unit => 's', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'duration', value => 'duration_seconds', template => '%d', + unit => 's', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -69,8 +69,8 @@ sub set_counters { output_template => 'Physical Bytes Written : %s %s', output_change_bytes => 1, perfdatas => [ - { label => 'physical_bytes_written', value => 'physical_bytes_written_absolute', template => '%s', - unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'physical_bytes_written', value => 'physical_bytes_written', template => '%s', + unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -79,8 +79,8 @@ sub set_counters { output_template => 'Data Transferred : %s %s', output_change_bytes => 1, perfdatas => [ - { label => 'data_transferred', value => 'data_transferred_absolute', template => '%s', - unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'data_transferred', value => 'data_transferred', template => '%s', + unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/storage/purestorage/restapi/mode/volumeusage.pm b/storage/purestorage/restapi/mode/volumeusage.pm index cdcd97484..b5759798d 100644 --- a/storage/purestorage/restapi/mode/volumeusage.pm +++ b/storage/purestorage/restapi/mode/volumeusage.pm @@ -111,8 +111,8 @@ sub set_counters { key_values => [ { name => 'data_reduction' }, { name => 'display' } ], output_template => 'Data Reduction : %.3f', perfdatas => [ - { label => 'data_reduction', value => 'data_reduction_absolute', template => '%.3f', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'data_reduction', value => 'data_reduction', template => '%.3f', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -120,8 +120,8 @@ sub set_counters { key_values => [ { name => 'total_reduction' }, { name => 'display' } ], output_template => 'Total Reduction : %.3f', perfdatas => [ - { label => 'total_reduction', value => 'total_reduction_absolute', template => '%.3f', - min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'total_reduction', value => 'total_reduction', template => '%.3f', + min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, @@ -130,8 +130,8 @@ sub set_counters { output_template => 'Snapshots : %s %s', output_change_bytes => 1, perfdatas => [ - { label => 'snapshots', value => 'snapshots_absolute', template => '%s', - unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + { label => 'snapshots', value => 'snapshots', template => '%s', + unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } }, diff --git a/storage/purestorage/snmp/mode/stats.pm b/storage/purestorage/snmp/mode/stats.pm index 506a261d0..34f3fcdfe 100644 --- a/storage/purestorage/snmp/mode/stats.pm +++ b/storage/purestorage/snmp/mode/stats.pm @@ -38,7 +38,7 @@ sub set_counters { output_change_bytes => 2, output_template => 'Read Bandwith : %s %s/s', perfdatas => [ - { label => 'read_bandwidth', value => 'pureArrayReadBandwidth_absolute', template => '%.2f', + { label => 'read_bandwidth', value => 'pureArrayReadBandwidth', template => '%.2f', min => 0, unit => 'b/s' }, ], } @@ -48,7 +48,7 @@ sub set_counters { output_change_bytes => 2, output_template => 'Write Bandwith : %s %s/s', perfdatas => [ - { label => 'write_bandwidth', value => 'pureArrayWriteBandwidth_absolute', template => '%.2f', + { label => 'write_bandwidth', value => 'pureArrayWriteBandwidth', template => '%.2f', min => 0, unit => 'b/s' }, ], } @@ -57,7 +57,7 @@ sub set_counters { key_values => [ { name => 'pureArrayReadIOPS' } ], output_template => 'Read IOPs : %s', perfdatas => [ - { label => 'read_iops', value => 'pureArrayReadIOPS_absolute', template => '%s', + { label => 'read_iops', value => 'pureArrayReadIOPS', template => '%s', unit => 'iops', min => 0 }, ], } @@ -66,7 +66,7 @@ sub set_counters { key_values => [ { name => 'pureArrayWriteIOPS' } ], output_template => 'Write IOPs : %s', perfdatas => [ - { label => 'write_iops', value => 'pureArrayWriteIOPS_absolute', template => '%s', + { label => 'write_iops', value => 'pureArrayWriteIOPS', template => '%s', unit => 'iops', min => 0 }, ], } @@ -75,7 +75,7 @@ sub set_counters { key_values => [ { name => 'pureArrayReadLatency' } ], output_template => 'Read Latency : %s us/op', perfdatas => [ - { label => 'read_latency', value => 'pureArrayReadLatency_absolute', template => '%s', + { label => 'read_latency', value => 'pureArrayReadLatency', template => '%s', unit => 'us/op', min => 0 }, ], } @@ -84,7 +84,7 @@ sub set_counters { key_values => [ { name => 'pureArrayWriteLatency' } ], output_template => 'Write Latency : %s us/op', perfdatas => [ - { label => 'write_latency', value => 'pureArrayWriteLatency_absolute', template => '%s', + { label => 'write_latency', value => 'pureArrayWriteLatency', template => '%s', unit => 'us/op', min => 0 }, ], } diff --git a/storage/quantum/dxi/ssh/mode/compaction.pm b/storage/quantum/dxi/ssh/mode/compaction.pm index aceea5e4d..74d6fa07e 100644 --- a/storage/quantum/dxi/ssh/mode/compaction.pm +++ b/storage/quantum/dxi/ssh/mode/compaction.pm @@ -96,7 +96,7 @@ sub set_counters { key_values => [ { name => 'status_progress' } ], output_template => 'Status progress: %.2f %%', perfdatas => [ - { label => 'status_progress', value => 'status_progress_absolute', template => '%.2f', + { label => 'status_progress', value => 'status_progress', template => '%.2f', unit => '%', min => 0, max => 100 }, ], } diff --git a/storage/quantum/dxi/ssh/mode/dedupnas.pm b/storage/quantum/dxi/ssh/mode/dedupnas.pm index da013a0b5..ecd4e3922 100644 --- a/storage/quantum/dxi/ssh/mode/dedupnas.pm +++ b/storage/quantum/dxi/ssh/mode/dedupnas.pm @@ -91,8 +91,8 @@ sub set_counters { output_template => 'Original data size: %s %s', output_change_bytes => 1, perfdatas => [ - { label => 'original_data_size', value => 'original_size_absolute', template => '%d', - unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'name_absolute' }, + { label => 'original_data_size', value => 'original_size', template => '%d', + unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'name' }, ], } }, @@ -101,8 +101,8 @@ sub set_counters { output_template => 'Sent data size: %s %s', output_change_bytes => 1, perfdatas => [ - { label => 'sent_data_size', value => 'sent_size_absolute', template => '%d', - unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'name_absolute' }, + { label => 'sent_data_size', value => 'sent_size', template => '%d', + unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'name' }, ], } }, diff --git a/storage/quantum/dxi/ssh/mode/dedupvtl.pm b/storage/quantum/dxi/ssh/mode/dedupvtl.pm index 2cc2e19df..57994d11a 100644 --- a/storage/quantum/dxi/ssh/mode/dedupvtl.pm +++ b/storage/quantum/dxi/ssh/mode/dedupvtl.pm @@ -92,8 +92,8 @@ sub set_counters { output_template => 'Original data size: %s %s', output_change_bytes => 1, perfdatas => [ - { label => 'original_data_size', value => 'original_size_absolute', template => '%d', - unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'name_absolute' }, + { label => 'original_data_size', value => 'original_size', template => '%d', + unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'name' }, ], } }, @@ -102,8 +102,8 @@ sub set_counters { output_template => 'Sent data size: %s %s', output_change_bytes => 1, perfdatas => [ - { label => 'sent_data_size', value => 'sent_size_absolute', template => '%d', - unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'name_absolute' }, + { label => 'sent_data_size', value => 'sent_size', template => '%d', + unit => 'B', min => 0, label_extra_instance => 1, instance_use => 'name' }, ], } }, diff --git a/storage/quantum/dxi/ssh/mode/reclamation.pm b/storage/quantum/dxi/ssh/mode/reclamation.pm index 11e2006a0..28213b5a1 100644 --- a/storage/quantum/dxi/ssh/mode/reclamation.pm +++ b/storage/quantum/dxi/ssh/mode/reclamation.pm @@ -97,7 +97,7 @@ sub set_counters { key_values => [ { name => 'stage_status_progress' } ], output_template => 'Stage Status progress: %.2f %%', perfdatas => [ - { label => 'stage_status_progress', value => 'stage_status_progress_absolute', template => '%.2f', + { label => 'stage_status_progress', value => 'stage_status_progress', template => '%.2f', unit => '%', min => 0, max => 100 }, ], } @@ -106,7 +106,7 @@ sub set_counters { key_values => [ { name => 'total_progress' } ], output_template => 'Total progress: %.2f %%', perfdatas => [ - { label => 'total_progress', value => 'total_progress_absolute', template => '%.2f', + { label => 'total_progress', value => 'total_progress', template => '%.2f', unit => '%', min => 0, max => 100 }, ], } diff --git a/storage/quantum/dxi/ssh/mode/reduction.pm b/storage/quantum/dxi/ssh/mode/reduction.pm index e76854e6d..53bb4456e 100644 --- a/storage/quantum/dxi/ssh/mode/reduction.pm +++ b/storage/quantum/dxi/ssh/mode/reduction.pm @@ -147,7 +147,7 @@ sub set_counters { key_values => [ { name => 'total_reduction_ratio' } ], output_template => 'Total Reduction Ratio: %.2f', perfdatas => [ - { label => 'total_reduction_ratio', value => 'total_reduction_ratio_absolute', template => '%.2f', + { label => 'total_reduction_ratio', value => 'total_reduction_ratio', template => '%.2f', unit => '%', min => 0, max => 100 }, ], } @@ -156,7 +156,7 @@ sub set_counters { key_values => [ { name => 'deduplication_ratio' } ], output_template => 'Deduplication Ratio: %.2f', perfdatas => [ - { label => 'deduplication_ratio', value => 'deduplication_ratio_absolute', template => '%.2f', + { label => 'deduplication_ratio', value => 'deduplication_ratio', template => '%.2f', unit => '%', min => 0, max => 100 }, ], } @@ -165,7 +165,7 @@ sub set_counters { key_values => [ { name => 'compression_ratio' } ], output_template => 'Compression Ratio: %.2f', perfdatas => [ - { label => 'compression_ratio', value => 'compression_ratio_absolute', template => '%.2f', + { label => 'compression_ratio', value => 'compression_ratio', template => '%.2f', unit => '%', min => 0, max => 100 }, ], } diff --git a/storage/synology/snmp/mode/ha.pm b/storage/synology/snmp/mode/ha.pm index 5987e5b6b..920b43a79 100644 --- a/storage/synology/snmp/mode/ha.pm +++ b/storage/synology/snmp/mode/ha.pm @@ -61,7 +61,7 @@ sub set_counters { key_values => [ { name => 'heartbeat_latency' } ], output_template => 'heartbeat latency: %s us', perfdatas => [ - { value => 'heartbeat_latency_absolute', template => '%s', min => 0, unit => 'us' } + { value => 'heartbeat_latency', template => '%s', min => 0, unit => 'us' } ] } } diff --git a/storage/synology/snmp/mode/temperature.pm b/storage/synology/snmp/mode/temperature.pm index f97aead39..0af9d9bf0 100644 --- a/storage/synology/snmp/mode/temperature.pm +++ b/storage/synology/snmp/mode/temperature.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'temperature' } ], output_template => 'system temperature: %s C', perfdatas => [ - { value => 'temperature_absolute', template => '%s', unit => 'C' }, + { value => 'temperature', template => '%s', unit => 'C' }, ], } }, diff --git a/storage/synology/snmp/mode/ups.pm b/storage/synology/snmp/mode/ups.pm index 185808759..cb448e203 100644 --- a/storage/synology/snmp/mode/ups.pm +++ b/storage/synology/snmp/mode/ups.pm @@ -37,7 +37,7 @@ sub set_counters { key_values => [ { name => 'ups_load' } ], output_template => 'ups load: %s%%', perfdatas => [ - { value => 'ups_load_absolute', template => '%s', min => 0, max => 100, unit => '%' }, + { value => 'ups_load', template => '%s', min => 0, max => 100, unit => '%' }, ], } }, @@ -45,7 +45,7 @@ sub set_counters { key_values => [ { name => 'charge_remain' } ], output_template => 'battery charge remaining: %s%%', perfdatas => [ - { value => 'charge_remain_absolute', template => '%s', min => 0, max => 100, unit => '%' }, + { value => 'charge_remain', template => '%s', min => 0, max => 100, unit => '%' }, ], } }, @@ -53,7 +53,7 @@ sub set_counters { key_values => [ { name => 'lifetime_remain' } ], output_template => 'battery estimated lifetime: %s seconds', perfdatas => [ - { value => 'lifetime_remain_absolute', template => '%s', min => 0, unit => 's' }, + { value => 'lifetime_remain', template => '%s', min => 0, unit => 's' }, ], } }, From 10cc8baf672ab340a474945e05d7f3316844797d Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 13 May 2020 14:38:32 +0200 Subject: [PATCH 215/283] remove some status callback --- apps/vmware/connector/mode/alarmdatacenter.pm | 14 -------------- apps/vmware/connector/mode/alarmhost.pm | 14 -------------- apps/vmware/connector/mode/datastoreusage.pm | 8 -------- apps/vmware/connector/mode/datastorevm.pm | 9 --------- apps/vmware/connector/mode/devicevm.pm | 9 --------- apps/vmware/connector/mode/discovery.pm | 4 ++-- apps/vmware/connector/mode/getmap.pm | 16 ++++++++-------- apps/vmware/connector/mode/listclusters.pm | 10 +++++----- apps/vmware/connector/mode/listdatacenters.pm | 11 +++++------ apps/vmware/connector/mode/listdatastores.pm | 12 ++++++------ apps/vmware/connector/mode/listnichost.pm | 10 +++++----- apps/vmware/connector/mode/maintenancehost.pm | 8 -------- apps/vmware/connector/mode/memoryvm.pm | 9 --------- apps/vmware/connector/mode/servicehost.pm | 11 ----------- apps/vmware/connector/mode/statusvm.pm | 8 -------- apps/vmware/connector/mode/swapvm.pm | 9 --------- os/linux/local/mode/mountpoint.pm | 13 +------------ os/linux/local/mode/packeterrors.pm | 9 --------- os/linux/local/mode/systemdscstatus.pm | 12 ------------ os/linux/local/mode/traffic.pm | 9 --------- .../hp/storeonce/restapi/mode/clusterusage.pm | 9 --------- storage/hp/storeonce/restapi/mode/fcsusage.pm | 10 ---------- storage/hp/storeonce/restapi/mode/nasusage.pm | 19 ------------------- .../storeonce/restapi/mode/servicesetusage.pm | 11 ----------- storage/quantum/dxi/ssh/mode/compaction.pm | 8 -------- storage/quantum/dxi/ssh/mode/health.pm | 10 ---------- .../dxi/ssh/mode/hostbusadapterstatus.pm | 9 --------- storage/quantum/dxi/ssh/mode/network.pm | 10 ---------- storage/quantum/dxi/ssh/mode/reclamation.pm | 8 -------- .../dxi/ssh/mode/storagearraystatus.pm | 9 --------- storage/quantum/dxi/ssh/mode/systemstatus.pm | 11 ----------- 31 files changed, 32 insertions(+), 287 deletions(-) diff --git a/apps/vmware/connector/mode/alarmdatacenter.pm b/apps/vmware/connector/mode/alarmdatacenter.pm index 5dc2b828c..c82c08c02 100644 --- a/apps/vmware/connector/mode/alarmdatacenter.pm +++ b/apps/vmware/connector/mode/alarmdatacenter.pm @@ -70,19 +70,6 @@ sub custom_status_output { return $msg; } -sub custom_status_calc { - my ($self, %options) = @_; - - $self->{result_values}->{entity_name} = $options{new_datas}->{$self->{instance} . '_entity_name'}; - $self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_status'}; - $self->{result_values}->{name} = $options{new_datas}->{$self->{instance} . '_name'}; - $self->{result_values}->{type} = $options{new_datas}->{$self->{instance} . '_type'}; - $self->{result_values}->{since} = $options{new_datas}->{$self->{instance} . '_since'}; - $self->{result_values}->{description} = $options{new_datas}->{$self->{instance} . '_description'}; - $self->{result_values}->{time} = $options{new_datas}->{$self->{instance} . '_time'}; - return 0; -} - sub custom_dcmetrics_perfdata { my ($self, %options) = @_; @@ -146,7 +133,6 @@ sub set_counters { { label => 'status', threshold => 0, set => { key_values => [ { name => 'entity_name' }, { name => 'status' }, { name => 'time' }, { name => 'description' }, { name => 'name' }, { name => 'type' }, { name => 'since' } ], - closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, closure_custom_threshold_check => \&catalog_status_threshold, diff --git a/apps/vmware/connector/mode/alarmhost.pm b/apps/vmware/connector/mode/alarmhost.pm index 708524b5e..07be989fd 100644 --- a/apps/vmware/connector/mode/alarmhost.pm +++ b/apps/vmware/connector/mode/alarmhost.pm @@ -70,19 +70,6 @@ sub custom_status_output { return $msg; } -sub custom_status_calc { - my ($self, %options) = @_; - - $self->{result_values}->{entity_name} = $options{new_datas}->{$self->{instance} . '_entity_name'}; - $self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_status'}; - $self->{result_values}->{name} = $options{new_datas}->{$self->{instance} . '_name'}; - $self->{result_values}->{type} = $options{new_datas}->{$self->{instance} . '_type'}; - $self->{result_values}->{since} = $options{new_datas}->{$self->{instance} . '_since'}; - $self->{result_values}->{description} = $options{new_datas}->{$self->{instance} . '_description'}; - $self->{result_values}->{time} = $options{new_datas}->{$self->{instance} . '_time'}; - return 0; -} - sub custom_esxhost_perfdata { my ($self, %options) = @_; @@ -145,7 +132,6 @@ sub set_counters { { label => 'status', threshold => 0, set => { key_values => [ { name => 'entity_name' }, { name => 'status' }, { name => 'time' }, { name => 'description' }, { name => 'name' }, { name => 'type' }, { name => 'since' } ], - closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, closure_custom_threshold_check => \&catalog_status_threshold, diff --git a/apps/vmware/connector/mode/datastoreusage.pm b/apps/vmware/connector/mode/datastoreusage.pm index d60959c89..c03815b50 100644 --- a/apps/vmware/connector/mode/datastoreusage.pm +++ b/apps/vmware/connector/mode/datastoreusage.pm @@ -33,13 +33,6 @@ sub custom_status_output { return $msg; } -sub custom_status_calc { - my ($self, %options) = @_; - - $self->{result_values}->{accessible} = $options{new_datas}->{$self->{instance} . '_accessible'}; - return 0; -} - sub custom_usage_output { my ($self, %options) = @_; @@ -94,7 +87,6 @@ sub set_counters { $self->{maps_counters}->{datastore} = [ { label => 'status', threshold => 0, set => { key_values => [ { name => 'accessible' }, { name => 'display' } ], - closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, closure_custom_threshold_check => \&catalog_status_threshold, diff --git a/apps/vmware/connector/mode/datastorevm.pm b/apps/vmware/connector/mode/datastorevm.pm index abcb4a60f..6f74e6646 100644 --- a/apps/vmware/connector/mode/datastorevm.pm +++ b/apps/vmware/connector/mode/datastorevm.pm @@ -34,14 +34,6 @@ sub custom_status_output { return $msg; } -sub custom_status_calc { - my ($self, %options) = @_; - - $self->{result_values}->{connection_state} = $options{new_datas}->{$self->{instance} . '_connection_state'}; - $self->{result_values}->{power_state} = $options{new_datas}->{$self->{instance} . '_power_state'}; - return 0; -} - sub set_counters { my ($self, %options) = @_; @@ -58,7 +50,6 @@ sub set_counters { $self->{maps_counters}->{global} = [ { label => 'status', threshold => 0, set => { key_values => [ { name => 'connection_state' }, { name => 'power_state' } ], - closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, closure_custom_threshold_check => \&catalog_status_threshold, diff --git a/apps/vmware/connector/mode/devicevm.pm b/apps/vmware/connector/mode/devicevm.pm index f8ba791eb..3693db2da 100644 --- a/apps/vmware/connector/mode/devicevm.pm +++ b/apps/vmware/connector/mode/devicevm.pm @@ -33,14 +33,6 @@ sub custom_status_output { return $msg; } -sub custom_status_calc { - my ($self, %options) = @_; - - $self->{result_values}->{connection_state} = $options{new_datas}->{$self->{instance} . '_connection_state'}; - $self->{result_values}->{power_state} = $options{new_datas}->{$self->{instance} . '_power_state'}; - return 0; -} - sub custom_device_output { my ($self, %options) = @_; @@ -71,7 +63,6 @@ sub set_counters { $self->{maps_counters}->{vm} = [ { label => 'status', threshold => 0, set => { key_values => [ { name => 'connection_state' }, { name => 'power_state' } ], - closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, closure_custom_threshold_check => \&catalog_status_threshold, diff --git a/apps/vmware/connector/mode/discovery.pm b/apps/vmware/connector/mode/discovery.pm index dc2efc1f4..4f848f564 100644 --- a/apps/vmware/connector/mode/discovery.pm +++ b/apps/vmware/connector/mode/discovery.pm @@ -32,8 +32,8 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - "resource-type:s" => { name => 'resource_type' }, - "prettify" => { name => 'prettify' }, + 'resource-type:s' => { name => 'resource_type' }, + 'prettify' => { name => 'prettify' } }); return $self; diff --git a/apps/vmware/connector/mode/getmap.pm b/apps/vmware/connector/mode/getmap.pm index 4ce5b292a..38b30a543 100644 --- a/apps/vmware/connector/mode/getmap.pm +++ b/apps/vmware/connector/mode/getmap.pm @@ -30,14 +30,14 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - "esx-hostname:s" => { name => 'esx_hostname' }, - "filter" => { name => 'filter' }, - "scope-datacenter:s" => { name => 'scope_datacenter' }, - "scope-cluster:s" => { name => 'scope_cluster' }, - "vm-no" => { name => 'vm_no' }, - }); + $options{options}->add_options(arguments => { + 'esx-hostname:s' => { name => 'esx_hostname' }, + 'filter' => { name => 'filter' }, + 'scope-datacenter:s' => { name => 'scope_datacenter' }, + 'scope-cluster:s' => { name => 'scope_cluster' }, + 'vm-no' => { name => 'vm_no' }, + }); + return $self; } diff --git a/apps/vmware/connector/mode/listclusters.pm b/apps/vmware/connector/mode/listclusters.pm index 34454fa13..3243a1730 100644 --- a/apps/vmware/connector/mode/listclusters.pm +++ b/apps/vmware/connector/mode/listclusters.pm @@ -30,11 +30,11 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - "cluster:s" => { name => 'cluster' }, - "filter" => { name => 'filter' }, - }); + $options{options}->add_options(arguments => { + 'cluster:s' => { name => 'cluster' }, + 'filter' => { name => 'filter' }, + }); + return $self; } diff --git a/apps/vmware/connector/mode/listdatacenters.pm b/apps/vmware/connector/mode/listdatacenters.pm index febaa7fcf..8446d0c0b 100644 --- a/apps/vmware/connector/mode/listdatacenters.pm +++ b/apps/vmware/connector/mode/listdatacenters.pm @@ -30,11 +30,11 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - "datacenter:s" => { name => 'datacenter' }, - "filter" => { name => 'filter' }, - }); + $options{options}->add_options(arguments => { + 'datacenter:s' => { name => 'datacenter' }, + 'filter' => { name => 'filter' } + }); + return $self; } @@ -43,7 +43,6 @@ sub check_options { $self->SUPER::init(%options); } - sub run { my ($self, %options) = @_; diff --git a/apps/vmware/connector/mode/listdatastores.pm b/apps/vmware/connector/mode/listdatastores.pm index e4e93bd38..e0395ed7e 100644 --- a/apps/vmware/connector/mode/listdatastores.pm +++ b/apps/vmware/connector/mode/listdatastores.pm @@ -30,12 +30,12 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - "datastore-name:s" => { name => 'datastore_name' }, - "filter" => { name => 'filter' }, - "scope-datacenter:s" => { name => 'scope_datacenter' }, - }); + $options{options}->add_options(arguments => { + 'datastore-name:s' => { name => 'datastore_name' }, + 'filter' => { name => 'filter' }, + 'scope-datacenter:s' => { name => 'scope_datacenter' } + }); + return $self; } diff --git a/apps/vmware/connector/mode/listnichost.pm b/apps/vmware/connector/mode/listnichost.pm index b057d1f34..daafc28c7 100644 --- a/apps/vmware/connector/mode/listnichost.pm +++ b/apps/vmware/connector/mode/listnichost.pm @@ -30,11 +30,11 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $options{options}->add_options(arguments => - { - "esx-hostname:s" => { name => 'esx_hostname' }, - "filter" => { name => 'filter' }, - }); + $options{options}->add_options(arguments => { + 'esx-hostname:s' => { name => 'esx_hostname' }, + 'filter' => { name => 'filter' } + }); + return $self; } diff --git a/apps/vmware/connector/mode/maintenancehost.pm b/apps/vmware/connector/mode/maintenancehost.pm index d4bd4e308..22572d5f0 100644 --- a/apps/vmware/connector/mode/maintenancehost.pm +++ b/apps/vmware/connector/mode/maintenancehost.pm @@ -47,13 +47,6 @@ sub custom_maintenance_output { return $msg; } -sub custom_maintenance_calc { - my ($self, %options) = @_; - - $self->{result_values}->{maintenance} = $options{new_datas}->{$self->{instance} . '_maintenance'}; - return 0; -} - sub set_counters { my ($self, %options) = @_; @@ -72,7 +65,6 @@ sub set_counters { }, { label => 'maintenance-status', threshold => 0, set => { key_values => [ { name => 'maintenance' } ], - closure_custom_calc => $self->can('custom_maintenance_calc'), closure_custom_output => $self->can('custom_maintenance_output'), closure_custom_perfdata => sub { return 0; }, closure_custom_threshold_check => \&catalog_status_threshold, diff --git a/apps/vmware/connector/mode/memoryvm.pm b/apps/vmware/connector/mode/memoryvm.pm index 3d337967c..8f7841083 100644 --- a/apps/vmware/connector/mode/memoryvm.pm +++ b/apps/vmware/connector/mode/memoryvm.pm @@ -33,14 +33,6 @@ sub custom_status_output { return $msg; } -sub custom_status_calc { - my ($self, %options) = @_; - - $self->{result_values}->{connection_state} = $options{new_datas}->{$self->{instance} . '_connection_state'}; - $self->{result_values}->{power_state} = $options{new_datas}->{$self->{instance} . '_power_state'}; - return 0; -} - sub custom_usage_perfdata { my ($self, %options) = @_; @@ -157,7 +149,6 @@ sub set_counters { $self->{maps_counters}->{global} = [ { label => 'status', threshold => 0, set => { key_values => [ { name => 'connection_state' }, { name => 'power_state' } ], - closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, closure_custom_threshold_check => \&catalog_status_threshold diff --git a/apps/vmware/connector/mode/servicehost.pm b/apps/vmware/connector/mode/servicehost.pm index 64a7559c8..56ec777ff 100644 --- a/apps/vmware/connector/mode/servicehost.pm +++ b/apps/vmware/connector/mode/servicehost.pm @@ -48,16 +48,6 @@ sub custom_service_output { return $msg; } -sub custom_service_calc { - my ($self, %options) = @_; - - $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; - $self->{result_values}->{policy} = $options{new_datas}->{$self->{instance} . '_policy'}; - $self->{result_values}->{running} = $options{new_datas}->{$self->{instance} . '_running'}; - $self->{result_values}->{key} = $options{new_datas}->{$self->{instance} . '_key'}; - return 0; -} - sub set_counters { my ($self, %options) = @_; @@ -84,7 +74,6 @@ sub set_counters { $self->{maps_counters}->{service} = [ { label => 'service-status', threshold => 0, set => { key_values => [ { name => 'display' }, { name => 'policy' }, { name => 'running' }, { name => 'key' } ], - closure_custom_calc => $self->can('custom_service_calc'), closure_custom_output => $self->can('custom_service_output'), closure_custom_perfdata => sub { return 0; }, closure_custom_threshold_check => \&catalog_status_threshold, diff --git a/apps/vmware/connector/mode/statusvm.pm b/apps/vmware/connector/mode/statusvm.pm index 5e48394fa..0f1b1f3ad 100644 --- a/apps/vmware/connector/mode/statusvm.pm +++ b/apps/vmware/connector/mode/statusvm.pm @@ -33,13 +33,6 @@ sub custom_status_output { return $msg; } -sub custom_status_calc { - my ($self, %options) = @_; - - $self->{result_values}->{connection_state} = $options{new_datas}->{$self->{instance} . '_connection_state'}; - return 0; -} - sub custom_overall_output { my ($self, %options) = @_; @@ -64,7 +57,6 @@ sub set_counters { $self->{maps_counters}->{vm} = [ { label => 'status', threshold => 0, set => { key_values => [ { name => 'connection_state' } ], - closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, closure_custom_threshold_check => \&catalog_status_threshold, diff --git a/apps/vmware/connector/mode/swapvm.pm b/apps/vmware/connector/mode/swapvm.pm index 84b007cf8..23680dd7f 100644 --- a/apps/vmware/connector/mode/swapvm.pm +++ b/apps/vmware/connector/mode/swapvm.pm @@ -33,14 +33,6 @@ sub custom_status_output { return $msg; } -sub custom_status_calc { - my ($self, %options) = @_; - - $self->{result_values}->{connection_state} = $options{new_datas}->{$self->{instance} . '_connection_state'}; - $self->{result_values}->{power_state} = $options{new_datas}->{$self->{instance} . '_power_state'}; - return 0; -} - sub set_counters { my ($self, %options) = @_; @@ -51,7 +43,6 @@ sub set_counters { $self->{maps_counters}->{vm} = [ { label => 'status', threshold => 0, set => { key_values => [ { name => 'connection_state' }, { name => 'power_state' } ], - closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, closure_custom_threshold_check => \&catalog_status_threshold, diff --git a/os/linux/local/mode/mountpoint.pm b/os/linux/local/mode/mountpoint.pm index 4edcd2886..b554db344 100644 --- a/os/linux/local/mode/mountpoint.pm +++ b/os/linux/local/mode/mountpoint.pm @@ -33,16 +33,6 @@ sub custom_status_output { return "options are '" . $self->{result_values}->{options} . "' [type: " . $self->{result_values}->{type} . "]"; } -sub custom_status_calc { - my ($self, %options) = @_; - - $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; - $self->{result_values}->{type} = $options{new_datas}->{$self->{instance} . '_type'}; - $self->{result_values}->{options} = $options{new_datas}->{$self->{instance} . '_options'}; - - return 0; -} - sub prefix_output { my ($self, %options) = @_; @@ -59,12 +49,11 @@ sub set_counters { $self->{maps_counters}->{mountpoints} = [ { label => 'status', set => { key_values => [ { name => 'display' }, { name => 'options' }, { name => 'type' } ], - closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, closure_custom_threshold_check => \&catalog_status_threshold, } - }, + } ]; } diff --git a/os/linux/local/mode/packeterrors.pm b/os/linux/local/mode/packeterrors.pm index ae36efe81..00a7f08e2 100644 --- a/os/linux/local/mode/packeterrors.pm +++ b/os/linux/local/mode/packeterrors.pm @@ -34,14 +34,6 @@ sub custom_status_output { return sprintf('status : %s', $self->{result_values}->{status}); } -sub custom_status_calc { - my ($self, %options) = @_; - - $self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_status'}; - $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; - return 0; -} - sub custom_packet_output { my ($self, %options) = @_; @@ -78,7 +70,6 @@ sub set_counters { $self->{maps_counters}->{interface} = [ { label => 'status', threshold => 0, set => { key_values => [ { name => 'status' }, { name => 'display' } ], - closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, closure_custom_threshold_check => \&catalog_status_threshold, diff --git a/os/linux/local/mode/systemdscstatus.pm b/os/linux/local/mode/systemdscstatus.pm index ba0d5fae6..50921f6b7 100644 --- a/os/linux/local/mode/systemdscstatus.pm +++ b/os/linux/local/mode/systemdscstatus.pm @@ -40,17 +40,6 @@ sub custom_status_output { return $msg; } -sub custom_status_calc { - my ($self, %options) = @_; - - $self->{result_values}->{load} = $options{new_datas}->{$self->{instance} . '_load'}; - $self->{result_values}->{active} = $options{new_datas}->{$self->{instance} . '_active'}; - $self->{result_values}->{sub} = $options{new_datas}->{$self->{instance} . '_sub'}; - $self->{result_values}->{boot} = $options{new_datas}->{$self->{instance} . '_boot'}; - $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; - return 0; -} - sub set_counters { my ($self, %options) = @_; @@ -100,7 +89,6 @@ sub set_counters { $self->{maps_counters}->{sc} = [ { label => 'status', threshold => 0, set => { key_values => [ { name => 'load' }, { name => 'active' }, { name => 'sub' }, { name => 'boot' }, { name => 'display' } ], - closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, closure_custom_threshold_check => \&catalog_status_threshold, diff --git a/os/linux/local/mode/traffic.pm b/os/linux/local/mode/traffic.pm index fa75d7eeb..5a103dd7f 100644 --- a/os/linux/local/mode/traffic.pm +++ b/os/linux/local/mode/traffic.pm @@ -34,14 +34,6 @@ sub custom_status_output { return sprintf('status : %s', $self->{result_values}->{status}); } -sub custom_status_calc { - my ($self, %options) = @_; - - $self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_status'}; - $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; - return 0; -} - sub custom_traffic_perfdata { my ($self, %options) = @_; @@ -115,7 +107,6 @@ sub set_counters { $self->{maps_counters}->{interface} = [ { label => 'status', threshold => 0, set => { key_values => [ { name => 'status' }, { name => 'display' } ], - closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, closure_custom_threshold_check => \&catalog_status_threshold, diff --git a/storage/hp/storeonce/restapi/mode/clusterusage.pm b/storage/hp/storeonce/restapi/mode/clusterusage.pm index 1e430b549..6a2aacfe6 100644 --- a/storage/hp/storeonce/restapi/mode/clusterusage.pm +++ b/storage/hp/storeonce/restapi/mode/clusterusage.pm @@ -33,14 +33,6 @@ sub custom_status_output { return $msg; } -sub custom_status_calc { - my ($self, %options) = @_; - - $self->{result_values}->{health} = $options{new_datas}->{$self->{instance} . '_health'}; - $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; - return 0; -} - sub custom_usage_perfdata { my ($self, %options) = @_; @@ -117,7 +109,6 @@ sub set_counters { $self->{maps_counters}->{cluster} = [ { label => 'status', threshold => 0, set => { key_values => [ { name => 'health' }, { name => 'display' } ], - closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, closure_custom_threshold_check => \&catalog_status_threshold diff --git a/storage/hp/storeonce/restapi/mode/fcsusage.pm b/storage/hp/storeonce/restapi/mode/fcsusage.pm index 95a44d7ec..52a04f41a 100644 --- a/storage/hp/storeonce/restapi/mode/fcsusage.pm +++ b/storage/hp/storeonce/restapi/mode/fcsusage.pm @@ -33,15 +33,6 @@ sub custom_status_output { return $msg; } -sub custom_status_calc { - my ($self, %options) = @_; - - $self->{result_values}->{health} = $options{new_datas}->{$self->{instance} . '_health'}; - $self->{result_values}->{is_online} = $options{new_datas}->{$self->{instance} . '_is_online'}; - $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; - return 0; -} - sub set_counters { my ($self, %options) = @_; @@ -52,7 +43,6 @@ sub set_counters { $self->{maps_counters}->{fcs} = [ { label => 'status', threshold => 0, set => { key_values => [ { name => 'is_online' }, { name => 'health' }, { name => 'display' } ], - closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, closure_custom_threshold_check => \&catalog_status_threshold, diff --git a/storage/hp/storeonce/restapi/mode/nasusage.pm b/storage/hp/storeonce/restapi/mode/nasusage.pm index 943336bf6..29e10195d 100644 --- a/storage/hp/storeonce/restapi/mode/nasusage.pm +++ b/storage/hp/storeonce/restapi/mode/nasusage.pm @@ -34,15 +34,6 @@ sub custom_nas_status_output { return $msg; } -sub custom_nas_status_calc { - my ($self, %options) = @_; - - $self->{result_values}->{health} = $options{new_datas}->{$self->{instance} . '_health'}; - $self->{result_values}->{replication_health} = $options{new_datas}->{$self->{instance} . '_replication_health'}; - $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; - return 0; -} - sub custom_share_status_output { my ($self, %options) = @_; @@ -50,14 +41,6 @@ sub custom_share_status_output { return $msg; } -sub custom_share_status_calc { - my ($self, %options) = @_; - - $self->{result_values}->{health} = $options{new_datas}->{$self->{instance} . '_health'}; - $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; - return 0; -} - sub set_counters { my ($self, %options) = @_; @@ -69,7 +52,6 @@ sub set_counters { $self->{maps_counters}->{nas} = [ { label => 'nas-status', threshold => 0, set => { key_values => [ { name => 'replication_health' }, { name => 'health' }, { name => 'display' } ], - closure_custom_calc => $self->can('custom_nas_status_calc'), closure_custom_output => $self->can('custom_nas_status_output'), closure_custom_perfdata => sub { return 0; }, closure_custom_threshold_check => \&catalog_status_threshold, @@ -80,7 +62,6 @@ sub set_counters { $self->{maps_counters}->{share} = [ { label => 'share-status', threshold => 0, set => { key_values => [ { name => 'health' }, { name => 'display' } ], - closure_custom_calc => $self->can('custom_share_status_calc'), closure_custom_output => $self->can('custom_share_status_output'), closure_custom_perfdata => sub { return 0; }, closure_custom_threshold_check => \&catalog_status_threshold, diff --git a/storage/hp/storeonce/restapi/mode/servicesetusage.pm b/storage/hp/storeonce/restapi/mode/servicesetusage.pm index bafc14c03..805332e51 100644 --- a/storage/hp/storeonce/restapi/mode/servicesetusage.pm +++ b/storage/hp/storeonce/restapi/mode/servicesetusage.pm @@ -34,16 +34,6 @@ sub custom_status_output { return $msg; } -sub custom_status_calc { - my ($self, %options) = @_; - - $self->{result_values}->{health} = $options{new_datas}->{$self->{instance} . '_health'}; - $self->{result_values}->{housekeeping_health} = $options{new_datas}->{$self->{instance} . '_housekeeping_health'}; - $self->{result_values}->{replication_health} = $options{new_datas}->{$self->{instance} . '_replication_health'}; - $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; - return 0; -} - sub custom_usage_perfdata { my ($self, %options) = @_; @@ -120,7 +110,6 @@ sub set_counters { $self->{maps_counters}->{scs} = [ { label => 'status', threshold => 0, set => { key_values => [ { name => 'health' }, { name => 'replication_health' }, { name => 'housekeeping_health' }, { name => 'display' } ], - closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, closure_custom_threshold_check => \&catalog_status_threshold, diff --git a/storage/quantum/dxi/ssh/mode/compaction.pm b/storage/quantum/dxi/ssh/mode/compaction.pm index 74d6fa07e..0eee28be1 100644 --- a/storage/quantum/dxi/ssh/mode/compaction.pm +++ b/storage/quantum/dxi/ssh/mode/compaction.pm @@ -32,13 +32,6 @@ sub custom_status_output { return 'Compaction status: ' . $self->{result_values}->{compaction_status}; } -sub custom_status_calc { - my ($self, %options) = @_; - - $self->{result_values}->{compaction_status} = $options{new_datas}->{$self->{instance} . '_compaction_status'}; - return 0; -} - sub custom_volume_perfdata { my ($self, %options) = @_; @@ -86,7 +79,6 @@ sub set_counters { $self->{maps_counters}->{global} = [ { label => 'status', threshold => 0, set => { key_values => [ { name => 'compaction_status' } ], - closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, closure_custom_threshold_check => \&catalog_status_threshold, diff --git a/storage/quantum/dxi/ssh/mode/health.pm b/storage/quantum/dxi/ssh/mode/health.pm index 7f63cab4a..1fc8afcfe 100644 --- a/storage/quantum/dxi/ssh/mode/health.pm +++ b/storage/quantum/dxi/ssh/mode/health.pm @@ -32,15 +32,6 @@ sub custom_status_output { return "status is '" . $self->{result_values}->{status} . "' [state = " . $self->{result_values}->{state} . "]"; } -sub custom_status_calc { - my ($self, %options) = @_; - - $self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_status'}; - $self->{result_values}->{state} = $options{new_datas}->{$self->{instance} . '_state'}; - $self->{result_values}->{name} = $options{new_datas}->{$self->{instance} . '_name'}; - return 0; -} - sub prefix_output { my ($self, %options) = @_; @@ -57,7 +48,6 @@ sub set_counters { $self->{maps_counters}->{global} = [ { label => 'status', set => { key_values => [ { name => 'status' }, { name => 'state' }, { name => 'name' } ], - closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, closure_custom_threshold_check => \&catalog_status_threshold, diff --git a/storage/quantum/dxi/ssh/mode/hostbusadapterstatus.pm b/storage/quantum/dxi/ssh/mode/hostbusadapterstatus.pm index e7b7b3861..2dc597611 100644 --- a/storage/quantum/dxi/ssh/mode/hostbusadapterstatus.pm +++ b/storage/quantum/dxi/ssh/mode/hostbusadapterstatus.pm @@ -32,14 +32,6 @@ sub custom_status_output { return "status is '" . $self->{result_values}->{status} . "'"; } -sub custom_status_calc { - my ($self, %options) = @_; - - $self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_status'}; - $self->{result_values}->{name} = $options{new_datas}->{$self->{instance} . '_name'}; - return 0; -} - sub prefix_output { my ($self, %options) = @_; @@ -56,7 +48,6 @@ sub set_counters { $self->{maps_counters}->{global} = [ { label => 'status', set => { key_values => [ { name => 'status' }, { name => 'name' } ], - closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, closure_custom_threshold_check => \&catalog_status_threshold, diff --git a/storage/quantum/dxi/ssh/mode/network.pm b/storage/quantum/dxi/ssh/mode/network.pm index 765a255ee..859c8af8e 100644 --- a/storage/quantum/dxi/ssh/mode/network.pm +++ b/storage/quantum/dxi/ssh/mode/network.pm @@ -32,15 +32,6 @@ sub custom_status_output { return "status is '" . $self->{result_values}->{status} . "' [value = " . $self->{result_values}->{value} . "]"; } -sub custom_status_calc { - my ($self, %options) = @_; - - $self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_status'}; - $self->{result_values}->{name} = $options{new_datas}->{$self->{instance} . '_name'}; - $self->{result_values}->{value} = $options{new_datas}->{$self->{instance} . '_value'}; - return 0; -} - sub prefix_output { my ($self, %options) = @_; @@ -57,7 +48,6 @@ sub set_counters { $self->{maps_counters}->{global} = [ { label => 'status', set => { key_values => [ { name => 'status' }, { name => 'name' }, { name => 'value' } ], - closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, closure_custom_threshold_check => \&catalog_status_threshold, diff --git a/storage/quantum/dxi/ssh/mode/reclamation.pm b/storage/quantum/dxi/ssh/mode/reclamation.pm index 28213b5a1..178d41df7 100644 --- a/storage/quantum/dxi/ssh/mode/reclamation.pm +++ b/storage/quantum/dxi/ssh/mode/reclamation.pm @@ -32,13 +32,6 @@ sub custom_status_output { return 'Reclamation status: ' . $self->{result_values}->{reclamation_status}; } -sub custom_status_calc { - my ($self, %options) = @_; - - $self->{result_values}->{reclamation_status} = $options{new_datas}->{$self->{instance} . '_reclamation_status'}; - return 0; -} - sub custom_volume_perfdata { my ($self, %options) = @_; @@ -87,7 +80,6 @@ sub set_counters { $self->{maps_counters}->{global} = [ { label => 'status', threshold => 0, set => { key_values => [ { name => 'reclamation_status' } ], - closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, closure_custom_threshold_check => \&catalog_status_threshold, diff --git a/storage/quantum/dxi/ssh/mode/storagearraystatus.pm b/storage/quantum/dxi/ssh/mode/storagearraystatus.pm index b205d5435..466e59d4e 100644 --- a/storage/quantum/dxi/ssh/mode/storagearraystatus.pm +++ b/storage/quantum/dxi/ssh/mode/storagearraystatus.pm @@ -32,14 +32,6 @@ sub custom_status_output { return "status is '" . $self->{result_values}->{status} . "'"; } -sub custom_status_calc { - my ($self, %options) = @_; - - $self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_status'}; - $self->{result_values}->{name} = $options{new_datas}->{$self->{instance} . '_name'}; - return 0; -} - sub prefix_output { my ($self, %options) = @_; @@ -56,7 +48,6 @@ sub set_counters { $self->{maps_counters}->{global} = [ { label => 'status', set => { key_values => [ { name => 'status' }, { name => 'name' } ], - closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, closure_custom_threshold_check => \&catalog_status_threshold, diff --git a/storage/quantum/dxi/ssh/mode/systemstatus.pm b/storage/quantum/dxi/ssh/mode/systemstatus.pm index 94c35fc4f..fb819b115 100644 --- a/storage/quantum/dxi/ssh/mode/systemstatus.pm +++ b/storage/quantum/dxi/ssh/mode/systemstatus.pm @@ -32,16 +32,6 @@ sub custom_status_output { return "status is '" . $self->{result_values}->{status} . "' [type = " . $self->{result_values}->{type} . "] [value = " . $self->{result_values}->{value} . "]"; } -sub custom_status_calc { - my ($self, %options) = @_; - - $self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_status'}; - $self->{result_values}->{name} = $options{new_datas}->{$self->{instance} . '_name'}; - $self->{result_values}->{type} = $options{new_datas}->{$self->{instance} . '_type'}; - $self->{result_values}->{value} = $options{new_datas}->{$self->{instance} . '_value'}; - return 0; -} - sub prefix_output { my ($self, %options) = @_; @@ -58,7 +48,6 @@ sub set_counters { $self->{maps_counters}->{global} = [ { label => 'status', set => { key_values => [ { name => 'status' }, { name => 'name' }, { name => 'type' }, { name => 'value' } ], - closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, closure_custom_threshold_check => \&catalog_status_threshold, From 198c765894cb05d7b0cf8a314c54b93c5124c0e4 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 13 May 2020 18:28:10 +0200 Subject: [PATCH 216/283] Fix #1995 --- centreon/plugins/backend/ssh/sshcli.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/centreon/plugins/backend/ssh/sshcli.pm b/centreon/plugins/backend/ssh/sshcli.pm index 159b871f2..3298f2003 100644 --- a/centreon/plugins/backend/ssh/sshcli.pm +++ b/centreon/plugins/backend/ssh/sshcli.pm @@ -57,7 +57,7 @@ sub check_options { $self->{output}->option_exit(); } - push @{$self->{ssh_option}}, '-o=BatchMode yes'; + push @{$self->{ssh_option}}, '-o=BatchMode=yes'; push @{$self->{ssh_option}}, '-l=' . $self->{ssh_username} if (defined($self->{ssh_username}) && $self->{ssh_username} ne ''); push @{$self->{ssh_option}}, '-p=' . $self->{ssh_port} if (defined($self->{ssh_port}) && $self->{ssh_port} ne ''); push @{$self->{ssh_option}}, '-i=' . $self->{ssh_priv_key} if (defined($self->{ssh_priv_key}) && $self->{ssh_priv_key} ne ''); From 12186928423cbcb6553f10b001848ed86f045fa4 Mon Sep 17 00:00:00 2001 From: Alfredo SILVESTRE Date: Wed, 13 May 2020 17:49:23 +0100 Subject: [PATCH 217/283] Bugfix on infinite loop --- network/cisco/prime/restapi/custom/api.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/network/cisco/prime/restapi/custom/api.pm b/network/cisco/prime/restapi/custom/api.pm index 594ca0dcc..869b9abee 100644 --- a/network/cisco/prime/restapi/custom/api.pm +++ b/network/cisco/prime/restapi/custom/api.pm @@ -183,7 +183,7 @@ sub get { } $first_result += $max_results; - last if ($max_results > $content->{queryResponse}->{'@count'}); + last if ($first_result > $content->{queryResponse}->{'@count'}); } return $result; } From 80d9e8e35fbed7bbf416b143c758c6c18b3bc385 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 14 May 2020 16:16:40 +0200 Subject: [PATCH 218/283] Fix #1998 --- centreon/plugins/values.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/centreon/plugins/values.pm b/centreon/plugins/values.pm index 5e9794725..5b3ff38e3 100644 --- a/centreon/plugins/values.pm +++ b/centreon/plugins/values.pm @@ -113,7 +113,7 @@ sub threshold_check { if (defined($self->{threshold_use})) { $value = $self->{result_values}->{ $self->{threshold_use} }; } else { - $value = defined($self->{key_values}->[0]) ? $self->{key_values}->[0]->{name} : ''; + $value = defined($self->{key_values}->[0]) ? $self->{result_values}->{ $self->{key_values}->[0]->{name} } : ''; } return $self->{perfdata}->threshold_check( From ba92bfa7b25d5d1a8575d117509bd8a7e179b410 Mon Sep 17 00:00:00 2001 From: UrBnW <40244829+UrBnW@users.noreply.github.com> Date: Thu, 14 May 2020 21:57:08 +0200 Subject: [PATCH 219/283] fix(checkpoint) unknown if can't compute thresholds --- network/checkpoint/snmp/mode/connections.pm | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/network/checkpoint/snmp/mode/connections.pm b/network/checkpoint/snmp/mode/connections.pm index 90adbcc9c..46bc69dba 100644 --- a/network/checkpoint/snmp/mode/connections.pm +++ b/network/checkpoint/snmp/mode/connections.pm @@ -76,6 +76,13 @@ sub run { $value = $prct_used; %total_options = ( total => $result->{$oid_fwConnTableLimit}, cast_int => 1); } + } elsif ($self->{option_results}->{units} eq '%') { + $self->{output}->output_add( + severity => 'UNKNOWN', + short_msg => "Couldn't get fwConnTableLimit OID ($oid_fwConnTableLimit) to compute thresholds" + ); + $self->{output}->display(); + $self->{output}->exit(); } my $exit = $self->{perfdata}->threshold_check(value => $value, From 2f78e4192f73d4ce097e6c19acd9aae1723e77fc Mon Sep 17 00:00:00 2001 From: Sims24 Date: Thu, 14 May 2020 22:22:33 +0200 Subject: [PATCH 220/283] enh(plugin)review-option-name --- cloud/aws/ebs/mode/volumeio.pm | 2 +- cloud/aws/ebs/mode/volumeiops.pm | 2 +- cloud/aws/ebs/mode/volumetime.pm | 14 ++++++++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/cloud/aws/ebs/mode/volumeio.pm b/cloud/aws/ebs/mode/volumeio.pm index d58c02afd..ed149b350 100644 --- a/cloud/aws/ebs/mode/volumeio.pm +++ b/cloud/aws/ebs/mode/volumeio.pm @@ -161,7 +161,7 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - 'volumeid:s@' => { name => 'volume_id' }, + 'volume-id:s@' => { name => 'volume_id' }, 'per-sec' => { name => 'per_sec' }, 'filter-metric:s' => { name => 'filter_metric' } }); diff --git a/cloud/aws/ebs/mode/volumeiops.pm b/cloud/aws/ebs/mode/volumeiops.pm index 8207c81e0..f6ddb8fd1 100644 --- a/cloud/aws/ebs/mode/volumeiops.pm +++ b/cloud/aws/ebs/mode/volumeiops.pm @@ -189,7 +189,7 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - 'volumeid:s@' => { name => 'volume_id' }, + 'volume-id:s@' => { name => 'volume_id' }, 'per-sec' => { name => 'per_sec' }, 'filter-metric:s' => { name => 'filter_metric' } }); diff --git a/cloud/aws/ebs/mode/volumetime.pm b/cloud/aws/ebs/mode/volumetime.pm index aea3122e9..4e3fbcff1 100644 --- a/cloud/aws/ebs/mode/volumetime.pm +++ b/cloud/aws/ebs/mode/volumetime.pm @@ -29,19 +29,25 @@ my %metrics_mapping = ( 'VolumeTotalReadTime' => { 'output' => 'Total Read Time', 'label' => 'total-read-time', - 'nlabel' => { 'absolute' => 'ebs.volume.totalread.time.second' }, + 'nlabel' => { + 'absolute' => 'ebs.volume.totalread.time.second' + }, 'unit' => 's' }, 'VolumeTotalWriteTime' => { 'output' => 'Total Write Time', 'label' => 'total-write-time', - 'nlabel' => { 'absolute' => 'ebs.volume.totalwrite.time.second' }, + 'nlabel' => { + 'absolute' => 'ebs.volume.totalwrite.time.second' + }, 'unit' => 's' }, 'VolumeIdleTime' => { 'output' => 'Idle Time', 'label' => 'idle-time', - 'nlabel' => { 'absolute' => 'ebs.volume.idle.time.second' }, + 'nlabel' => { + 'absolute' => 'ebs.volume.idle.time.second' + }, 'unit' => 's', 'display_percent' => 1 } @@ -154,7 +160,7 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - 'volumeid:s@' => { name => 'volume_id' }, + 'volume-id:s@' => { name => 'volume_id' }, 'filter-metric:s' => { name => 'filter_metric' } }); From 307bb396971900d81d7c97a8658ba9b413a74201 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Fri, 15 May 2020 09:21:59 +0200 Subject: [PATCH 221/283] fix #2000 --- apps/hyperv/2012/local/mode/nodesnapshot.pm | 22 ++++++++++++++------- network/checkpoint/snmp/mode/connections.pm | 2 +- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/apps/hyperv/2012/local/mode/nodesnapshot.pm b/apps/hyperv/2012/local/mode/nodesnapshot.pm index 0ddde6896..4192abb8c 100644 --- a/apps/hyperv/2012/local/mode/nodesnapshot.pm +++ b/apps/hyperv/2012/local/mode/nodesnapshot.pm @@ -31,21 +31,22 @@ sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ - { name => 'vm', type => 1, cb_prefix_output => 'prefix_vm_output', message_multiple => 'All VM snapshots are ok', skipped_code => { -10 => 1 } }, + { name => 'vm', type => 1, cb_prefix_output => 'prefix_vm_output', message_multiple => 'All VM snapshots are ok', skipped_code => { -10 => 1 } } ]; + $self->{maps_counters}->{vm} = [ { label => 'snapshot', set => { - key_values => [ { name => 'snapshot' }, { name => 'status' }, { name => 'display' }], + key_values => [ { name => 'snapshot' }, { name => 'status' }, { name => 'display' } ], closure_custom_output => $self->can('custom_snapshot_output'), - closure_custom_perfdata => sub { return 0; }, + closure_custom_perfdata => sub { return 0; } } }, { label => 'backing', set => { - key_values => [ { name => 'backing' }, { name => 'status' }, { name => 'display' }], + key_values => [ { name => 'backing' }, { name => 'status' }, { name => 'display' } ], closure_custom_output => $self->can('custom_backing_output'), - closure_custom_perfdata => sub { return 0; }, + closure_custom_perfdata => sub { return 0; } } - }, + } ]; } @@ -82,7 +83,7 @@ sub new { 'ps-display' => { name => 'ps_display' }, 'filter-vm:s' => { name => 'filter_vm' }, 'filter-note:s' => { name => 'filter_note' }, - 'filter-status:s' => { name => 'filter_status', default => 'running' }, + 'filter-status:s' => { name => 'filter_status', default => 'running' } }); return $self; @@ -161,6 +162,13 @@ sub manage_selection { }; $id++; } + + if (scalar(keys %{$self->{vm}}) <= 0) { + $self->{output}->output_add( + severity => 'OK', + short_msg => 'no snapshot found' + ); + } } 1; diff --git a/network/checkpoint/snmp/mode/connections.pm b/network/checkpoint/snmp/mode/connections.pm index 46bc69dba..09c74e6e6 100644 --- a/network/checkpoint/snmp/mode/connections.pm +++ b/network/checkpoint/snmp/mode/connections.pm @@ -92,7 +92,7 @@ sub run { short_msg => sprintf("Connections: %d%s", $result->{$oid_fwNumCom}, $extra) ); $self->{output}->perfdata_add( - label => "connections", unit => 'con', + label => 'connections', unit => 'con', value => $result->{$oid_fwNumCom}, warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', %total_options), critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', %total_options), From cd25bd955c8985672f83d3b73dbbc9edbb10d519 Mon Sep 17 00:00:00 2001 From: UrBnW <40244829+UrBnW@users.noreply.github.com> Date: Mon, 18 May 2020 14:58:57 +0200 Subject: [PATCH 222/283] fix(aix) simplify buggy swap state detection --- os/aix/snmp/mode/swap.pm | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/os/aix/snmp/mode/swap.pm b/os/aix/snmp/mode/swap.pm index 87cf893a4..2e295832e 100644 --- a/os/aix/snmp/mode/swap.pm +++ b/os/aix/snmp/mode/swap.pm @@ -127,13 +127,6 @@ sub new { sub manage_selection { my ($self, %options) = @_; - # sysDescr values: - # Aix 5.2: .*Base Operating System Runtime AIX version: 05.02.* - # Aix 5.3: .*Base Operating System Runtime AIX version: 05.03.* - # Aix 6.1: .*Base Operating System Runtime AIX version: 06.01.* - # Aix 7.1: .*Base Operating System Runtime AIX version: 07.01.* - - my $oid_sysDescr = ".1.3.6.1.2.1.1.1"; my $aix_swap_pool = ".1.3.6.1.4.1.2.6.191.2.4.2.1"; # aixPageEntry my $aix_swap_name = ".1.3.6.1.4.1.2.6.191.2.4.2.1.1"; # aixPageName my $aix_swap_total = ".1.3.6.1.4.1.2.6.191.2.4.2.1.4"; # aixPageSize (in MB) @@ -145,7 +138,6 @@ sub manage_selection { my $results = $options{snmp}->get_multiple_table( oids => [ { oid => $aix_swap_pool }, - { oid => $oid_sysDescr }, ] ); @@ -164,17 +156,10 @@ sub manage_selection { # Values are : # 1 = "active" # 2 = "notActive" - # On AIX 5.x it's ok. But in AIX 6.x, 7.x, it's the contrary ??!!! - my $active_swap = 2; - if ($results->{$oid_sysDescr}->{$oid_sysDescr . ".0"} =~ /AIX version: 05\./i) { - $active_swap = 1; - } + # Some systems may however return the contrary. + my $active_swap = 1; if (defined($self->{option_results}->{paging_state_buggy})) { - if ($active_swap == 2) { - $active_swap = 1; - } else { - $active_swap = 2; - } + $active_swap = 2; } $self->{global} = { nactive => 0, ntotal => 0, total => 0, used => 0 }; From dfae72911c283786cf7936ef6e890a712ca777dd Mon Sep 17 00:00:00 2001 From: UrBnW <40244829+UrBnW@users.noreply.github.com> Date: Mon, 18 May 2020 18:56:25 +0200 Subject: [PATCH 223/283] enh(checkpoint) add some standard modes --- network/checkpoint/snmp/plugin.pm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/network/checkpoint/snmp/plugin.pm b/network/checkpoint/snmp/plugin.pm index 42d7a5ba1..409ac4caf 100644 --- a/network/checkpoint/snmp/plugin.pm +++ b/network/checkpoint/snmp/plugin.pm @@ -37,7 +37,10 @@ sub new { 'hastate' => 'network::checkpoint::snmp::mode::hastate', 'interfaces' => 'snmp_standard::mode::interfaces', 'list-interfaces' => 'snmp_standard::mode::listinterfaces', + 'list-storages' => 'snmp_standard::mode::liststorages', 'memory' => 'network::checkpoint::snmp::mode::memory', + 'storage' => 'snmp_standard::mode::storage', + 'time' => 'snmp_standard::mode::ntp', 'uptime' => 'snmp_standard::mode::uptime', 'vpn-status' => 'network::checkpoint::snmp::mode::vpnstatus', 'vrrp-status' => 'snmp_standard::mode::vrrp', From f1d415b3e2674a289b0e08b1df40e682a93bc214 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 19 May 2020 10:16:21 +0200 Subject: [PATCH 224/283] fix dell me4 interfaces --- storage/dell/me4/restapi/mode/interfaces.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/dell/me4/restapi/mode/interfaces.pm b/storage/dell/me4/restapi/mode/interfaces.pm index 710e50071..bf5e89dbf 100644 --- a/storage/dell/me4/restapi/mode/interfaces.pm +++ b/storage/dell/me4/restapi/mode/interfaces.pm @@ -216,7 +216,7 @@ sub manage_selection { }; } - $self->{cache_name} = 'dell_me4_' . $self->{mode} . '_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . + $self->{cache_name} = 'dell_me4_' . $self->{mode} . '_' . $options{custom}->get_hostname() . '_' . (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); } From 0363ce32efea5756bbe10dc168d2e3ec013e5377 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 19 May 2020 10:54:59 +0200 Subject: [PATCH 225/283] enhance dell me4 interfaces --- storage/dell/me4/restapi/mode/interfaces.pm | 9 +++++++++ storage/dell/me4/restapi/mode/volumestatistics.pm | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/storage/dell/me4/restapi/mode/interfaces.pm b/storage/dell/me4/restapi/mode/interfaces.pm index bf5e89dbf..f0abe6e01 100644 --- a/storage/dell/me4/restapi/mode/interfaces.pm +++ b/storage/dell/me4/restapi/mode/interfaces.pm @@ -146,6 +146,7 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { + 'filter-port-name:s' => { name => 'filter_port_name' }, 'unknown-port-status:s' => { name => 'unknown_port_status', default => '%{health} =~ /unknown/i' }, 'warning-port-status:s' => { name => 'warning_port_status', default => '%{health} =~ /degraded/i' }, 'critical-port-status:s' => { name => 'critical_port_status', default => '%{health} =~ /fault/i' } @@ -182,6 +183,10 @@ sub manage_selection { $self->{ports} = {}; foreach my $port (@{$result_ports->{port}}) { my $port_name = $port->{port}; + + next if (defined($self->{option_results}->{filter_port_name}) && $self->{option_results}->{filter_port_name} ne '' + && $port_name !~ /$self->{option_results}->{filter_port_name}/); + $mapping_ports->{ $port->{'durable-id'} } = $port_name; $self->{ports}->{$port_name} = { @@ -230,6 +235,10 @@ Check interfaces. =over 8 +=item B<--filter-port-name> + +Filter port name (Can be a regexp). + =item B<--unknown-port-status> Set unknown threshold for status (Default: '%{status} =~ /unknown/i'). diff --git a/storage/dell/me4/restapi/mode/volumestatistics.pm b/storage/dell/me4/restapi/mode/volumestatistics.pm index fa64a9370..b35cd80a2 100644 --- a/storage/dell/me4/restapi/mode/volumestatistics.pm +++ b/storage/dell/me4/restapi/mode/volumestatistics.pm @@ -140,7 +140,7 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - 'filter-name:s' => { name => 'filter_name' }, + 'filter-name:s' => { name => 'filter_name' } }); return $self; From 53c33b9408165ecc0837b78fcff8a8633a71ac5f Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 19 May 2020 10:55:33 +0200 Subject: [PATCH 226/283] enhance dell me4 interfaces --- storage/dell/me4/restapi/mode/interfaces.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/storage/dell/me4/restapi/mode/interfaces.pm b/storage/dell/me4/restapi/mode/interfaces.pm index f0abe6e01..714266d48 100644 --- a/storage/dell/me4/restapi/mode/interfaces.pm +++ b/storage/dell/me4/restapi/mode/interfaces.pm @@ -222,7 +222,8 @@ sub manage_selection { } $self->{cache_name} = 'dell_me4_' . $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_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' . + (defined($self->{option_results}->{filter_port_name}) ? md5_hex($self->{option_results}->{filter_port_name}) : md5_hex('all')); } 1; From 8490dd402a883e1687ed73bfdb0388b152bf9ed5 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 19 May 2020 12:01:44 +0200 Subject: [PATCH 227/283] fix dell me4 --- storage/dell/me4/restapi/mode/interfaces.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/dell/me4/restapi/mode/interfaces.pm b/storage/dell/me4/restapi/mode/interfaces.pm index 714266d48..04b624119 100644 --- a/storage/dell/me4/restapi/mode/interfaces.pm +++ b/storage/dell/me4/restapi/mode/interfaces.pm @@ -211,7 +211,7 @@ sub manage_selection { } foreach (@{$result_logical_interfaces->{'sas-host-phy-statistics'}}) { - next if ($self->{ports}->{ $_->{port} }); + next if (!defined($self->{ports}->{ $_->{port} })); $self->{ports}->{ $_->{port} }->{interfaces}->{ $_->{phy} } = { display => $_->{phy}, From 785a8ea21ce6287ec79dbad66e8217c9dd704dbc Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 20 May 2020 08:37:29 +0200 Subject: [PATCH 228/283] Fix #2005 #1634 --- network/checkpoint/snmp/mode/disk.pm | 159 ++++++++++++++++++++ network/checkpoint/snmp/plugin.pm | 5 +- network/juniper/common/junos/mode/memory.pm | 2 +- 3 files changed, 162 insertions(+), 4 deletions(-) create mode 100644 network/checkpoint/snmp/mode/disk.pm diff --git a/network/checkpoint/snmp/mode/disk.pm b/network/checkpoint/snmp/mode/disk.pm new file mode 100644 index 000000000..44b54e7dd --- /dev/null +++ b/network/checkpoint/snmp/mode/disk.pm @@ -0,0 +1,159 @@ +# +# Copyright 2020 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 network::checkpoint::snmp::mode::disk; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub custom_disk_output { + my ($self, %options) = @_; + + return sprintf( + 'total: %s %s used: %s %s (%.2f%%) free: %s %s (%.2f%%)', + $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}), + $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}), + $self->{result_values}->{prct_used}, + $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}), + $self->{result_values}->{prct_free} + ); +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'disk', type => 1, cb_prefix_output => 'prefix_disk_output', message_multiple => 'All disks are ok', skipped_code => { -10 => 1 } } + ]; + + $self->{maps_counters}->{disk} = [ + { label => 'usage', nlabel => 'disk.usage.bytes', set => { + key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'display' } ], + closure_custom_output => $self->can('custom_disk_output'), + perfdatas => [ + { template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1, label_extra_instance => 1 } + ] + } + }, + { label => 'usage-free', display_ok => 0, nlabel => 'disk.free.bytes', set => { + key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'display' } ], + closure_custom_output => $self->can('custom_disk_output'), + perfdatas => [ + { template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1, label_extra_instance => 1 } + ] + } + }, + { label => 'usage-prct', display_ok => 0, nlabel => 'disk.usage.percentage', set => { + key_values => [ { name => 'prct_used' }, { name => 'display' } ], + output_template => 'used: %.2f %%', + perfdatas => [ + { template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 } + ] + } + } + ]; +} + +sub prefix_disk_output { + my ($self, %options) = @_; + + return "Disk '" . $options{instance_value}->{display} . "' "; +} + +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' } + }); + + return $self; +} + +my $mapping = { + multiDiskName => { oid => '.1.3.6.1.4.1.2620.1.6.7.6.1.2' }, + multiDiskSize => { oid => '.1.3.6.1.4.1.2620.1.6.7.6.1.3' }, + multiDiskUsed => { oid => '.1.3.6.1.4.1.2620.1.6.7.6.1.4' } +}; +my $oid_multiDiskEntry = '.1.3.6.1.4.1.2620.1.6.7.6.1'; + +sub manage_selection { + my ($self, %options) = @_; + + if ($options{snmp}->is_snmpv1()) { + $self->{output}->add_option_msg(short_msg => 'Need to use SNMP v2c or v3.'); + $self->{output}->option_exit(); + } + + my $snmp_result = $options{snmp}->get_table( + oid => $oid_multiDiskEntry, + start => $mapping->{multiDiskName}->{oid}, + end => $mapping->{multiDiskUsed}->{oid}, + nothing_quit => 1 + ); + + foreach (keys %$snmp_result) { + next if (! /^$mapping->{multiDiskName}->{oid}\.(.*)$/); + + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $1); + + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $result->{multiDiskName} !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping '" . $result->{multiDiskName} . "': no matching filter.", debug => 1); + next; + } + + $self->{disk}->{ $result->{multiDiskName} } = { + display => $result->{multiDiskName}, + total => $result->{multiDiskSize}, + prct_used => $result->{multiDiskUsed} * 100 / $result->{multiDiskSize}, + prct_free => 100 - ($result->{multiDiskUsed} * 100 / $result->{multiDiskSize}), + used => $result->{multiDiskUsed}, + free => $result->{multiDiskSize} - $result->{multiDiskUsed} + }; + } +} + +1; + +__END__ + +=head1 MODE + +Check disk usage. + +=over 8 + +=item B<--filter-name> + +Filter disk name. + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'usage' (B), 'usage-free' (B), 'usage-prct' (%). + +=back + +=cut diff --git a/network/checkpoint/snmp/plugin.pm b/network/checkpoint/snmp/plugin.pm index 409ac4caf..091657f60 100644 --- a/network/checkpoint/snmp/plugin.pm +++ b/network/checkpoint/snmp/plugin.pm @@ -33,18 +33,17 @@ sub new { %{$self->{modes}} = ( 'connections' => 'network::checkpoint::snmp::mode::connections', 'cpu' => 'network::checkpoint::snmp::mode::cpu', + 'disk' => 'network::checkpoint::snmp::mode::disk', 'hardware' => 'network::checkpoint::snmp::mode::hardware', 'hastate' => 'network::checkpoint::snmp::mode::hastate', 'interfaces' => 'snmp_standard::mode::interfaces', 'list-interfaces' => 'snmp_standard::mode::listinterfaces', - 'list-storages' => 'snmp_standard::mode::liststorages', 'memory' => 'network::checkpoint::snmp::mode::memory', - 'storage' => 'snmp_standard::mode::storage', 'time' => 'snmp_standard::mode::ntp', 'uptime' => 'snmp_standard::mode::uptime', 'vpn-status' => 'network::checkpoint::snmp::mode::vpnstatus', 'vrrp-status' => 'snmp_standard::mode::vrrp', - 'vsx' => 'network::checkpoint::snmp::mode::vsx', + 'vsx' => 'network::checkpoint::snmp::mode::vsx' ); return $self; diff --git a/network/juniper/common/junos/mode/memory.pm b/network/juniper/common/junos/mode/memory.pm index 7229c1f40..2d79d1422 100644 --- a/network/juniper/common/junos/mode/memory.pm +++ b/network/juniper/common/junos/mode/memory.pm @@ -152,7 +152,7 @@ Check memory usage. Filter operating (Default: 'routing|fpc'). -=item B<--warning-*> B<--critical-usage> +=item B<--warning-*> B<--critical-*> Thresholds. Can be: 'usage' (B), 'usage-free' (B), 'usage-prct' (%). From d21b8a384a7f840b3eaf69a265cf1dd1bf9dde4f Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 20 May 2020 08:50:37 +0200 Subject: [PATCH 229/283] Refacto aix swap --- os/aix/snmp/mode/swap.pm | 98 ++++++++++++++++++---------------------- 1 file changed, 45 insertions(+), 53 deletions(-) diff --git a/os/aix/snmp/mode/swap.pm b/os/aix/snmp/mode/swap.pm index 2e295832e..4e44154e8 100644 --- a/os/aix/snmp/mode/swap.pm +++ b/os/aix/snmp/mode/swap.pm @@ -31,11 +31,12 @@ sub custom_usage_output { my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}); my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}); my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}); - my $msg = sprintf("Usage Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", - $total_size_value . " " . $total_size_unit, - $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used}, - $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free}); - return $msg; + return sprintf( + "Usage Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", + $total_size_value . " " . $total_size_unit, + $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used}, + $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free} + ); } sub custom_usage_calc { @@ -57,7 +58,7 @@ sub set_counters { $self->{maps_counters_type} = [ { name => 'global', type => 0, message_separator => ' - ', cb_init => 'skip_global', }, - { name => 'swap', type => 1, cb_prefix_output => 'prefix_swap_output', message_multiple => 'All Page spaces are ok' }, + { name => 'swap', type => 1, cb_prefix_output => 'prefix_swap_output', message_multiple => 'All page spaces are ok' } ]; $self->{maps_counters}->{global} = [ @@ -68,8 +69,8 @@ sub set_counters { threshold_use => 'prct_used', perfdatas => [ { label => 'total_page_space', value => 'used', template => '%s', cast_int => 1, - unit => 'B', min => 0, max => 'total', threshold_total => 'total' }, - ], + unit => 'B', min => 0, max => 'total', threshold_total => 'total' } + ] } }, { label => 'total-active', nlabel => 'page.space.active.count', display_ok => 0, set => { @@ -77,10 +78,10 @@ sub set_counters { output_template => 'Total page space active : %s', perfdatas => [ { label => 'total_active', value => 'nactive', template => '%s', - min => 0, max => 'ntotal' }, - ], + min => 0, max => 'ntotal' } + ] } - }, + } ]; $self->{maps_counters}->{swap} = [ @@ -92,10 +93,10 @@ sub set_counters { perfdatas => [ { label => 'page_space', value => 'used', template => '%s', cast_int => 1, unit => 'B', min => 0, max => 'total', threshold_total => 'total', - label_extra_instance => 1, instance_use => 'display' }, - ], + label_extra_instance => 1, instance_use => 'display' } + ] } - }, + } ]; } @@ -118,40 +119,30 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - 'paging-state-buggy' => { name => 'paging_state_buggy' }, + 'paging-state-buggy' => { name => 'paging_state_buggy' } }); return $self; } +my $mapping = { + swap_name => { oid => '.1.3.6.1.4.1.2.6.191.2.4.2.1.1' }, # aixPageName + swap_total => { oid => '.1.3.6.1.4.1.2.6.191.2.4.2.1.4' }, # aixPageSize (in MB) + swap_usage => { oid => '.1.3.6.1.4.1.2.6.191.2.4.2.1.5' }, # aixPagePercentUsed + swap_status => { oid => '.1.3.6.1.4.1.2.6.191.2.4.2.1.6' } # aixPageStatus +}; + sub manage_selection { my ($self, %options) = @_; my $aix_swap_pool = ".1.3.6.1.4.1.2.6.191.2.4.2.1"; # aixPageEntry - my $aix_swap_name = ".1.3.6.1.4.1.2.6.191.2.4.2.1.1"; # aixPageName - my $aix_swap_total = ".1.3.6.1.4.1.2.6.191.2.4.2.1.4"; # aixPageSize (in MB) - my $aix_swap_usage = ".1.3.6.1.4.1.2.6.191.2.4.2.1.5"; # aixPagePercentUsed - my $aix_swap_status = ".1.3.6.1.4.1.2.6.191.2.4.2.1.6"; # aixPageStatus - my $aix_swap_index = ".1.3.6.1.4.1.2.6.191.2.4.2.1.8"; - - my @indexes = (); - my $results = $options{snmp}->get_multiple_table( - oids => [ - { oid => $aix_swap_pool }, - ] + + my $snmp_result = $options{snmp}->get_table( + oid => $aix_swap_pool, + end => $mapping->{swap_status}->{oid}, + nothing_quit => 1 ); - foreach my $key (keys %{$results->{$aix_swap_pool}}) { - if ($key =~ /^$aix_swap_name\.(.*)/ ) { - push @indexes, $1; - } - } - - if (scalar(@indexes) <= 0) { - $self->{output}->add_option_msg(short_msg => "No paging space found."); - $self->{output}->option_exit(); - } - # Check if the paging space is active. # Values are : # 1 = "active" @@ -164,24 +155,25 @@ sub manage_selection { $self->{global} = { nactive => 0, ntotal => 0, total => 0, used => 0 }; $self->{swap} = {}; - foreach (@indexes) { + + foreach (keys %$snmp_result) { + next if (! /^$mapping->{swap_status}->{oid}\.(.*)$/); + $self->{global}->{ntotal}++; - - if ($results->{$aix_swap_pool}->{$aix_swap_status . "." . $_} == $active_swap) { - $self->{global}->{nactive}++; + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $1); + next if ($result->{swap_status} != $active_swap); + + $self->{global}->{nactive}++; - my $swap_name = $results->{$aix_swap_pool}->{$aix_swap_name . "." . $_}; - my $used = ($results->{$aix_swap_pool}->{$aix_swap_usage . "." . $_} * $results->{$aix_swap_pool}->{$aix_swap_total . "." . $_} / 100) - * 1024 * 1024; - my $total = $results->{$aix_swap_pool}->{$aix_swap_total . "." . $_} * 1024 * 1024; - $self->{swap}->{$swap_name} = { - display => $swap_name, - used => $used, - total => $total, - }; - $self->{global}->{used} += $used; - $self->{global}->{total} += $total; - } + my $used = ($result->{swap_usage} * $result->{swap_total} / 100) * 1024 * 1024; + my $total = $result->{swap_total} * 1024 * 1024; + $self->{swap}->{ $result->{swap_name} } = { + display => $result->{swap_name}, + used => $used, + total => $total + }; + $self->{global}->{used} += $used; + $self->{global}->{total} += $total; } } From f02c41061cadfa263680ad046d132ad59ee7557b Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 20 May 2020 09:09:22 +0200 Subject: [PATCH 230/283] add per_minute for counters --- centreon/plugins/values.pm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/centreon/plugins/values.pm b/centreon/plugins/values.pm index 5b3ff38e3..f6645795d 100644 --- a/centreon/plugins/values.pm +++ b/centreon/plugins/values.pm @@ -87,10 +87,12 @@ sub calc { # manage only one value ;) foreach my $value (@{$self->{key_values}}) { - if (defined($value->{per_second}) && $value->{per_second} == 1) { - $self->{result_values}->{$value->{name}} = ($options{new_datas}->{$self->{instance} . '_' . $value->{name}} - $options{old_datas}->{$self->{instance} . '_' . $value->{name}}) / $options{delta_time}; - } elsif (defined($value->{diff}) && $value->{diff} == 1) { + if (defined($value->{diff}) && $value->{diff} == 1) { $self->{result_values}->{$value->{name}} = $options{new_datas}->{$self->{instance} . '_' . $value->{name}} - $options{old_datas}->{$self->{instance} . '_' . $value->{name}}; + } elsif (defined($value->{per_second}) && $value->{per_second} == 1) { + $self->{result_values}->{$value->{name}} = ($options{new_datas}->{$self->{instance} . '_' . $value->{name}} - $options{old_datas}->{$self->{instance} . '_' . $value->{name}}) / $options{delta_time}; + } elsif (defined($value->{per_minute}) && $value->{per_minute} == 1) { + $self->{result_values}->{$value->{name}} = ($options{new_datas}->{$self->{instance} . '_' . $value->{name}} - $options{old_datas}->{$self->{instance} . '_' . $value->{name}}) / ($options{delta_time} / 60); } else { $self->{result_values}->{$value->{name}} = $options{new_datas}->{$self->{instance} . '_' . $value->{name}}; } From d11a8f3ee60d489d58e70876b3f2f23a589728e2 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 20 May 2020 09:20:17 +0200 Subject: [PATCH 231/283] Fix #2009 --- centreon/plugins/nrpe.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/centreon/plugins/nrpe.pm b/centreon/plugins/nrpe.pm index 01137def7..b180aa17e 100644 --- a/centreon/plugins/nrpe.pm +++ b/centreon/plugins/nrpe.pm @@ -154,9 +154,9 @@ sub assemble_v3 { $unpacked->{buffer_length} = $len; $unpacked->{buffer} = $buffer; $unpacked->{crc32_value} = "\x00\x00\x00\x00"; - $unpacked->{packet_type} = $options{type} // 1; + $unpacked->{packet_type} = defined($options{type}) ? $options{type} : 1; $unpacked->{packet_version} = 3; - $unpacked->{result_code} = $options{result_code} // 2324; + $unpacked->{result_code} = defined($options{result_code}) ? $options{result_code} : 2324; $self->{c}->parse(<{buffer} = $options{check}; $unpacked->{crc32_value} = "\x00\x00\x00\x00"; - $unpacked->{packet_type} = $options{type} // 1; + $unpacked->{packet_type} = defined($options{type}) ? $options{type} : 1; $unpacked->{packet_version} = 2; - $unpacked->{result_code} = $options{result_code} // 2324; + $unpacked->{result_code} = defined($options{result_code}) ? $options{result_code} : 2324; $self->{c}->parse(< Date: Mon, 23 Mar 2020 13:38:28 +0100 Subject: [PATCH 232/283] (wip)sample net mode for parity --- blockchain/parity/restapi/custom/api.pm | 187 ++++++++++++++++++++++++ blockchain/parity/restapi/mode/net.pm | 133 +++++++++++++++++ blockchain/parity/restapi/plugin.pm | 48 ++++++ 3 files changed, 368 insertions(+) create mode 100644 blockchain/parity/restapi/custom/api.pm create mode 100644 blockchain/parity/restapi/mode/net.pm create mode 100644 blockchain/parity/restapi/plugin.pm diff --git a/blockchain/parity/restapi/custom/api.pm b/blockchain/parity/restapi/custom/api.pm new file mode 100644 index 000000000..d792c57d8 --- /dev/null +++ b/blockchain/parity/restapi/custom/api.pm @@ -0,0 +1,187 @@ +# +# Copyright 2020 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 blockchain::parity::restapi::custom::api; + +use strict; +use warnings; +use centreon::plugins::http; +use JSON; + +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' }, + "timeout:s" => { name => 'timeout' }, + "api-path:s" => { name => 'api_path' }, + }); + } + $options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1); + + $self->{output} = $options{output}; + $self->{mode} = $options{mode}; + $self->{http} = centreon::plugins::http->new(%options); + + return $self; +} + +sub set_options { + my ($self, %options) = @_; + + $self->{option_results} = $options{option_results}; +} + +sub set_defaults { + my ($self, %options) = @_; + + 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} = (defined($self->{option_results}->{hostname})) ? $self->{option_results}->{hostname} : undef; + $self->{timeout} = (defined($self->{option_results}->{timeout})) ? $self->{option_results}->{timeout} : 10; + $self->{api_path} = (defined($self->{option_results}->{api_path})) ? $self->{option_results}->{api_path} : '/'; + + if (!defined($self->{hostname})) { + $self->{output}->add_option_msg(short_msg => "Need to specify hostname option."); + $self->{output}->option_exit(); + } + return 0; +} + +sub get_connection_infos { + my ($self, %options) = @_; + + return $self->{hostname} . '_' . $self->{http}->get_port(); +} + +sub build_options_for_httplib { + my ($self, %options) = @_; + + $self->{option_results}->{hostname} = $self->{hostname}; + $self->{option_results}->{timeout} = $self->{timeout}; + $self->{option_results}->{port} = 8545; + $self->{option_results}->{proto} = 'http'; +} + +sub settings { + my ($self, %options) = @_; + + $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}}); +} + +sub request_api { + my ($self, %options) = @_; + + + $self->settings(); + + my $encoded; + eval { + $encoded = encode_json($options{query_form_post}); + }; + if ($@) { + $self->{output}->add_option_msg(short_msg => "Cannot encode json request"); + $self->{output}->option_exit(); + } + + my $content = $self->{http}->request(method => $options{method}, url_path => '/', query_form_post => $encoded, + critical_status => '', warning_status => '', unknown_status => ''); + + my $decoded; + eval { + $decoded = decode_json($content); + }; + if ($@) { + $self->{output}->output_add(long_msg => $content, debug => 1); + $self->{output}->add_option_msg(short_msg => "Cannot decode json response"); + $self->{output}->option_exit(); + } + if ($self->{http}->get_code() != 200) { + $self->{output}->add_option_msg(short_msg => "Connection issue: " . $decoded->{msg}); + $self->{output}->option_exit(); + } + + return $decoded; +} + +1; + +__END__ + +=head1 NAME + +Parity node JSON WEBRPC + +=head1 SYNOPSIS + +Parity node JSON RPC API custom mode + +=head1 REST API OPTIONS + +=over 8 + +=item B<--hostname> + +Parity node hostname or IP + +=item B<--timeout> + +Set HTTP timeout in seconds (Default: '10'). + +=item B<--api-path> + +API base url path (Default: '/'). + +=back + +=head1 DESCRIPTION + +B. + +=cut diff --git a/blockchain/parity/restapi/mode/net.pm b/blockchain/parity/restapi/mode/net.pm new file mode 100644 index 000000000..a1f94ffc3 --- /dev/null +++ b/blockchain/parity/restapi/mode/net.pm @@ -0,0 +1,133 @@ +# +# Copyright 2020 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 blockchain::parity::restapi::mode::net; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); + +sub custom_status_output { + my ($self, %options) = @_; + + return sprintf( + 'Listening status: %s ', + $self->{result_values}->{listening}, + ); +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'network', cb_prefix_output => 'prefix_module_output', type => 0 }, + ]; + + $self->{maps_counters}->{network} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'listening' } ], + closure_custom_calc => \&catalog_status_calc, + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold + } + }, + { label => 'peers', nlabel => 'parity.network.peers.count', set => { + key_values => [ { name => 'peers' } ], + output_template => "connected peers: %s ", + perfdatas => [ + { label => 'peer_count', value => 'peers_absolute', template => '%d', min => 0 } + ], + } + }, + ]; +} + +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 => { + 'unknown-status:s' => { name => 'unknown_status', default => '' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '%{listening} !~ /true/' }, + }); + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->change_macros(macros => ['unknown_status', 'warning_status', 'critical_status']); +} + +sub prefix_module_output { + my ($self, %options) = @_; + + return "Parity network module: "; +} + +sub manage_selection { + my ($self, %options) = @_; + + my $query_form_post_listening = { method => 'net_listening', params => [], id => "1", jsonrpc => "2.0" }; + my $result_listening = $options{custom}->request_api(method => 'POST', query_form_post => $query_form_post_listening); + + my $query_form_post_peer = { method => 'net_peerCount', params => [], id => "1", jsonrpc => "2.0" }; + my $result_peer = $options{custom}->request_api(method => 'POST', query_form_post => $query_form_post_peer); + + $self->{network} = { listening => $result_listening->{result}, + peers => hex($result_peer->{result}) } + +} + +1; + +__END__ + +=head1 MODE + +Check network module metrics parity (net_isListening, net_peerCount) + +=over 8 + +=item B<--unknown-status> + +Set unknown threshold for listening status (Default: ''). + +=item B<--warning-status> + +Set warning threshold for listening status (Default: ''). + +=item B<--critical-status> + +Set critical threshold for listening status (Default: '%{listening} !~ /true/'). + +=item B<--warning-peers> B<--critical-peers> + +Warning and Critical threhsold on the number of peer + +=back + +=cut diff --git a/blockchain/parity/restapi/plugin.pm b/blockchain/parity/restapi/plugin.pm new file mode 100644 index 000000000..cda22b0ac --- /dev/null +++ b/blockchain/parity/restapi/plugin.pm @@ -0,0 +1,48 @@ +# +# Copyright 2020 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 blockchain::parity::restapi::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} = '0.1'; + %{$self->{modes}} = ( + 'net' => 'blockchain::parity::restapi::mode::net', + ); + $self->{custom_modes}{api} = 'blockchain::parity::restapi::custom::api'; + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Parity blockchain with JSON RPC + +=cut From 03c74acc353932441a7a092cf24f2607b2c270c8 Mon Sep 17 00:00:00 2001 From: Sims24 Date: Mon, 23 Mar 2020 15:21:56 +0100 Subject: [PATCH 233/283] (wip) sample multiple method post on RPC --- blockchain/parity/restapi/mode/net.pm | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/blockchain/parity/restapi/mode/net.pm b/blockchain/parity/restapi/mode/net.pm index a1f94ffc3..d5e8f88cf 100644 --- a/blockchain/parity/restapi/mode/net.pm +++ b/blockchain/parity/restapi/mode/net.pm @@ -91,15 +91,14 @@ sub prefix_module_output { sub manage_selection { my ($self, %options) = @_; - my $query_form_post_listening = { method => 'net_listening', params => [], id => "1", jsonrpc => "2.0" }; - my $result_listening = $options{custom}->request_api(method => 'POST', query_form_post => $query_form_post_listening); - - my $query_form_post_peer = { method => 'net_peerCount', params => [], id => "1", jsonrpc => "2.0" }; - my $result_peer = $options{custom}->request_api(method => 'POST', query_form_post => $query_form_post_peer); + my $query_form_post = [ { method => 'net_listening', params => [], id => "1", jsonrpc => "2.0" }, + { method => 'net_peerCount', params => [], id => "2", jsonrpc => "2.0" } ]; + + my $result = $options{custom}->request_api(method => 'POST', query_form_post => $query_form_post); + + $self->{network} = { listening => @{$result}[0]->{result}, + peers => hex(@{$result}[1]->{result}) }; - $self->{network} = { listening => $result_listening->{result}, - peers => hex($result_peer->{result}) } - } 1; From bf955bab400c36f4450e9f559f10b436da7d7b30 Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Wed, 25 Mar 2020 16:38:57 +0000 Subject: [PATCH 234/283] adding eth module --- blockchain/parity/restapi/mode/eth.pm | 223 ++++++++++++++++++++++++++ blockchain/parity/restapi/plugin.pm | 1 + 2 files changed, 224 insertions(+) create mode 100644 blockchain/parity/restapi/mode/eth.pm diff --git a/blockchain/parity/restapi/mode/eth.pm b/blockchain/parity/restapi/mode/eth.pm new file mode 100644 index 000000000..6beec926d --- /dev/null +++ b/blockchain/parity/restapi/mode/eth.pm @@ -0,0 +1,223 @@ +# +# Copyright 2020 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 blockchain::parity::restapi::mode::eth; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); + +sub custom_status_output { + my ($self, %options) = @_; + + return sprintf( + 'Listening status: %s ', + $self->{result_values}->{listening}, + ); +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'eth', cb_prefix_output => 'prefix_module_output', type => 0 }, + ]; + + $self->{maps_counters}->{eth} = [ + { label => 'is_minning', nlabel => 'parity.eth.peers.minning.status', set => { + key_values => [ { name => 'is_minning' } ], + output_template => "Client is minning: %s ", + perfdatas => [ + { label => 'is_minning', value => 'is_minning_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'coinbase', nlabel => 'parity.eth.client.coinbase', set => { + key_values => [ { name => 'coinbase' } ], + output_template => "Client coinbase is: %s ", + perfdatas => [ + { label => 'client_coinbase', value => 'coinbase_absolute', template => '%s', min => 0 } + ], + } + }, + { label => 'gas_price', nlabel => 'parity.eth.gas.price', set => { + key_values => [ { name => 'gas_price' } ], + output_template => "The gas price is: %d wei ", + perfdatas => [ + { label => 'gas_price', value => 'gas_price_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'hashrate', nlabel => 'parity.eth.node.hashrate', set => { + key_values => [ { name => 'hashrate' } ], + output_template => "Node hashrate is: %d/s ", + perfdatas => [ + { label => 'node_hashrate', value => 'hashrate_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'block_number', nlabel => 'parity.eth.block.number', set => { + key_values => [ { name => 'block_number' } ], + output_template => "Most recent block number is: %d ", + perfdatas => [ + { label => 'block_number', value => 'block_number_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'block_time', nlabel => 'parity.eth.block.time', set => { + key_values => [ { name => 'block_time' } ], + output_template => "Block time is: %s ", + perfdatas => [ + { label => 'block_time', value => 'block_time_absolute', template => '%s', min => 0 } + ], + } + }, + { label => 'sync_start', nlabel => 'parity.eth.sync.start.block', set => { + key_values => [ { name => 'sync_start' } ], + output_template => "Sync start block number is: %d ", + perfdatas => [ + { label => 'sync_start', value => 'sync_start_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'sync_current', nlabel => 'parity.eth.sync.current.block', set => { + key_values => [ { name => 'sync_current' } ], + output_template => "Sync current block number is: %d ", + perfdatas => [ + { label => 'sync_current', value => 'sync_current_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'sync_highest', nlabel => 'parity.eth.sync.highest.block', set => { + key_values => [ { name => 'sync_highest' } ], + output_template => "Sync highest block number is: %d ", + perfdatas => [ + { label => 'sync_highest', value => 'sync_highest_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'sync', nlabel => 'parity.eth.sync.ratio', set => { + key_values => [ { name => 'sync' } ], + output_template => "Sync ratio is: %d% ", + perfdatas => [ + { label => 'sync', value => 'sync_absolute', template => '%d', min => 0 } + ], + } + } + ]; +} + +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 => { + 'unknown-status:s' => { name => 'unknown_status', default => '' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '%{listening} !~ /true/' }, + }); + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->change_macros(macros => ['unknown_status', 'warning_status', 'critical_status']); +} + +sub prefix_module_output { + my ($self, %options) = @_; + + return "Parity Eth module: "; +} + +sub manage_selection { + my ($self, %options) = @_; + + my $query_form_post = [ { method => 'eth_mining', params => [], id => "1", jsonrpc => "2.0" }, + { method => 'eth_coinbase', params => [], id => "1", jsonrpc => "2.0" }, + { method => 'eth_gasPrice', params => [], id => "1", jsonrpc => "2.0" } , + { method => 'eth_hashrate', params => [], id => "1", jsonrpc => "2.0" } , + { method => 'eth_blockNumber', params => [], id => "1", jsonrpc => "2.0" }, + { method => 'eth_getBlockByNumber', params => ["latest","false"], id => "1", jsonrpc => "2.0" }, + { method => 'eth_syncing', params => [], id => "1", jsonrpc => "2.0" }, + { method => 'eth_coinbase', params => [], id => "1", jsonrpc => "2.0" }, + { method => 'eth_coinbase', params => [], id => "1", jsonrpc => "2.0" }, + { method => 'eth_coinbase', params => [], id => "1", jsonrpc => "2.0" }, + { method => 'eth_coinbase', params => [], id => "1", jsonrpc => "2.0" }, + { method => 'eth_coinbase', params => [], id => "1", jsonrpc => "2.0" } ]; + + my $result = $options{custom}->request_api(method => 'POST', query_form_post => $query_form_post); + + # conditional formating: + my $res_sync = @{$result}[6]->{result} ? (@{$result}[6]->{result}->{currentBlock} / @{$result}[6]->{result}->{highestBlock}) * 100 : 100; + my $res_startingBlock = $res_sync != 100 ? @{$result}[6]->{result}->{startingBlock} : undef; + my $res_currentBlock = $res_sync != 100 ? @{$result}[6]->{result}->{currentBlock} : undef; + my $res_highestBlock = $res_sync != 100 ? @{$result}[6]->{result}->{highestBlock} : undef; + + # Unix time conversion + my $res_timestamp = localtime((@{$result}[5]->{result}->{timestamp})); + + $self->{eth} = { is_minning => @{$result}[0]->{result}, + coinbase => @{$result}[1]->{result}, + gas_price => @{$result}[2]->{result}, + hashrate => hex(@{$result}[3]->{result}), + block_number => @{$result}[4]->{result}, + block_time => $res_timestamp, + sync_start => $res_startingBlock, + sync_current => $res_currentBlock, + sync_highest => $res_highestBlock, + sync => $res_sync }; + +} + +1; + +__END__ + +=head1 MODE + +Check eth module metrics parity (eth_mining, eth_coinbase, eth_gasPrice, eth_hashrate, eth_blockNumber, eth_getBlockByNumber::timestamp) + +=over 8 + +=item B<--unknown-status> + +Set unknown threshold for listening status (Default: ''). + +=item B<--warning-status> + +Set warning threshold for listening status (Default: ''). + +=item B<--critical-status> + +Set critical threshold for listening status (Default: '%{listening} !~ /true/'). + +=item B<--warning-peers> B<--critical-peers> + +Warning and Critical threhsold on the number of peer + +=back + +=cut diff --git a/blockchain/parity/restapi/plugin.pm b/blockchain/parity/restapi/plugin.pm index cda22b0ac..64e9f0a9b 100644 --- a/blockchain/parity/restapi/plugin.pm +++ b/blockchain/parity/restapi/plugin.pm @@ -32,6 +32,7 @@ sub new { $self->{version} = '0.1'; %{$self->{modes}} = ( 'net' => 'blockchain::parity::restapi::mode::net', + 'eth' => 'blockchain::parity::restapi::mode::eth', ); $self->{custom_modes}{api} = 'blockchain::parity::restapi::custom::api'; return $self; From 2b17471e737fc0e50291619a7f47728dc47bb437 Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Thu, 26 Mar 2020 08:40:14 +0000 Subject: [PATCH 235/283] adding parity mode --- blockchain/parity/restapi/mode/parity.pm | 204 +++++++++++++++++++++++ 1 file changed, 204 insertions(+) create mode 100644 blockchain/parity/restapi/mode/parity.pm diff --git a/blockchain/parity/restapi/mode/parity.pm b/blockchain/parity/restapi/mode/parity.pm new file mode 100644 index 000000000..122fd090b --- /dev/null +++ b/blockchain/parity/restapi/mode/parity.pm @@ -0,0 +1,204 @@ +# +# Copyright 2020 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 blockchain::parity::restapi::mode::parity; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'parity', cb_prefix_output => 'prefix_module_output', type => 0 }, + ]; + + $self->{maps_counters}->{parity} = [ + { label => 'parity_version', nlabel => 'parity.version', set => { + key_values => [ { name => 'parity_version' } ], + output_template => "Parity version is: %s ", + perfdatas => [ + { label => 'parity_version', value => 'parity_version_absolute', template => '%s', min => 0 } + ], + } + }, + { label => 'parity_version_hash', nlabel => 'parity.version.hash', set => { + key_values => [ { name => 'parity_version_hash' } ], + output_template => "Parity version hash is: %s ", + perfdatas => [ + { label => 'parity_version_hash', value => 'parity_version_hash_absolute', template => '%s', min => 0 } + ], + } + }, + { label => 'chain_name', nlabel => 'parity.chain.name', set => { + key_values => [ { name => 'chain_name' } ], + output_template => "Chain name is: %s ", + perfdatas => [ + { label => 'chain_name', value => 'chain_name_absolute', template => '%s', min => 0 } + ], + } + }, + { label => 'pending_transactions', nlabel => 'parity.pending.transactions', set => { + key_values => [ { name => 'pending_transactions' } ], + output_template => "Pending transactions: %d ", + perfdatas => [ + { label => 'pending_transactions', value => 'pending_transactions_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'mempool', nlabel => 'parity.mempol.capacity', set => { + key_values => [ { name => 'mempool' } ], + output_template => "Mempool: %d % ", + perfdatas => [ + { label => 'mempool', value => 'mempool_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'peers_connected', nlabel => 'parity.peers.connected', set => { + key_values => [ { name => 'peers_connected' } ], + output_template => "Number of connected peers: %d ", + perfdatas => [ + { label => 'peers_connected', value => 'peers_connected_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'peers_max', nlabel => 'parity.peers.max.connected', set => { + key_values => [ { name => 'peers_max' } ], + output_template => "Maximum number of connected peers: %d ", + perfdatas => [ + { label => 'peers_max', value => 'peers_max_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'peers', nlabel => 'parity.peers', set => { + key_values => [ { name => 'peers' } ], + output_template => "Peers: %d ", + perfdatas => [ + { label => 'peers', value => 'peers_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'enode', nlabel => 'parity.node.enode.uri', set => { + key_values => [ { name => 'enode' } ], + output_template => "Node enode URI: %s ", + perfdatas => [ + { label => 'enode', value => 'enode_absolute', template => '%s', min => 0 } + ], + } + }, + { label => 'node_name', nlabel => 'parity.node.name', set => { + key_values => [ { name => 'node_name' } ], + output_template => "Node name: %s ", + perfdatas => [ + { label => 'node_name', value => 'node_name_absolute', template => '%s', min => 0 } + ], + } + } + ]; +} + +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 => { + 'unknown-status:s' => { name => 'unknown_status', default => '' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '%{listening} !~ /true/' }, + }); + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->change_macros(macros => ['unknown_status', 'warning_status', 'critical_status']); +} + +sub prefix_module_output { + my ($self, %options) = @_; + + return "Parity module: "; +} + +sub manage_selection { + my ($self, %options) = @_; + + my $query_form_post = [ { method => 'parity_versionInfo', params => [], id => "1", jsonrpc => "2.0" }, + { method => 'parity_chain', params => [], id => "2", jsonrpc => "2.0" }, + { method => 'parity_pendingTransactions', params => [], id => "3", jsonrpc => "2.0" } , + { method => 'parity_netPeers', params => [], id => "4", jsonrpc => "2.0" }, + { method => 'parity_enode', params => [], id => "5", jsonrpc => "2.0" }, + { method => 'parity_nodeName', params => [], id => "6", jsonrpc => "2.0" }, + { method => 'parity_transactionsLimit', params => [], id => "7", jsonrpc => "2.0" } # could be done once, at the beginning of the process + ]; + + my $result = $options{custom}->request_api(method => 'POST', query_form_post => $query_form_post); + + # Parity version construction + my $res_parity_version = @{$result}[0]->{result}->{version}->{major} . @{$result}[0]->{result}->{version}->{minor} . @{$result}[0]->{result}->{version}->{patch}; + + $self->{eth} = { parity_version => $res_parity_version, + parity_version_hash => @{$result}[0]->{result}->{hash}, + chain_name => @{$result}[1]->{result}, + pending_transactions => scalar @{$result}[2]->{result}, + mempool => @{$result}[2]->{result} / @{$result}[6]->{result} * 100, + peers_connected => @{$result}[3]->{result}->{connected}, + peers_max => @{$result}[3]->{result}->{max}, + peers => scalar @{$result}[3]->{result}->{peers}, + enode => @{$result}[4]->{result}, + node_name => @{$result}[5]->{result} }; + +} + +1; + +__END__ + +=head1 MODE + +Check parity module metrics parity (parity_versionInfo, ) + +=over 8 + +=item B<--unknown-status> + +Set unknown threshold for listening status (Default: ''). + +=item B<--warning-status> + +Set warning threshold for listening status (Default: ''). + +=item B<--critical-status> + +Set critical threshold for listening status (Default: '%{listening} !~ /true/'). + +=item B<--warning-peers> B<--critical-peers> + +Warning and Critical threhsold on the number of peer + +=back + +=cut From 553463a684026c4c5b70d2e66c455888d6068467 Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Thu, 26 Mar 2020 08:45:23 +0000 Subject: [PATCH 236/283] adding parity mode --- blockchain/parity/restapi/plugin.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/blockchain/parity/restapi/plugin.pm b/blockchain/parity/restapi/plugin.pm index 64e9f0a9b..7cffb8686 100644 --- a/blockchain/parity/restapi/plugin.pm +++ b/blockchain/parity/restapi/plugin.pm @@ -31,8 +31,9 @@ sub new { $self->{version} = '0.1'; %{$self->{modes}} = ( - 'net' => 'blockchain::parity::restapi::mode::net', - 'eth' => 'blockchain::parity::restapi::mode::eth', + 'net' => 'blockchain::parity::restapi::mode::net', + 'eth' => 'blockchain::parity::restapi::mode::eth', + 'parity' => 'blockchain::parity::restapi::mode::parity' ); $self->{custom_modes}{api} = 'blockchain::parity::restapi::custom::api'; return $self; From 42650ed68c0922c175275b148d3f6ba522b514cb Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Thu, 26 Mar 2020 09:21:33 +0000 Subject: [PATCH 237/283] code cleanning --- blockchain/parity/restapi/mode/eth.pm | 64 ++++++++++++++------------- 1 file changed, 34 insertions(+), 30 deletions(-) diff --git a/blockchain/parity/restapi/mode/eth.pm b/blockchain/parity/restapi/mode/eth.pm index 6beec926d..5dcd4d71e 100644 --- a/blockchain/parity/restapi/mode/eth.pm +++ b/blockchain/parity/restapi/mode/eth.pm @@ -26,12 +26,12 @@ use strict; use warnings; use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); -sub custom_status_output { +sub custom_mining_status_output { my ($self, %options) = @_; return sprintf( - 'Listening status: %s ', - $self->{result_values}->{listening}, + 'Client mininig status: %s ', + $self->{result_values}->{is_mining}, ); } @@ -43,14 +43,23 @@ sub set_counters { ]; $self->{maps_counters}->{eth} = [ - { label => 'is_minning', nlabel => 'parity.eth.peers.minning.status', set => { - key_values => [ { name => 'is_minning' } ], - output_template => "Client is minning: %s ", + { label => 'is_mining', nlabel => 'parity.eth.peers.mining.status', set => { + key_values => [ { name => 'is_mining' } ], + output_template => "Client is mining: " . $self->can('custom_mining_status_output'), perfdatas => [ - { label => 'is_minning', value => 'is_minning_absolute', template => '%d', min => 0 } + { label => 'is_mining', value => 'is_mining_absolute', template => '%s', min => 0 } ], } }, + # { label => 'is_mining', nlabel => 'parity.eth.peers.mining.status', threshold => 0, set => { + # key_values => [ { name => 'is_mining' } ], + # output_template => "Client is mining: %s ", + # closure_custom_calc => \&catalog_status_calc, + # closure_custom_output => $self->can('custom_mining_status_output'), + # closure_custom_perfdata => sub { return 0; }, + # closure_custom_threshold_check => \&catalog_status_threshold + # } + # }, { label => 'coinbase', nlabel => 'parity.eth.client.coinbase', set => { key_values => [ { name => 'coinbase' } ], output_template => "Client coinbase is: %s ", @@ -156,39 +165,34 @@ sub manage_selection { my ($self, %options) = @_; my $query_form_post = [ { method => 'eth_mining', params => [], id => "1", jsonrpc => "2.0" }, - { method => 'eth_coinbase', params => [], id => "1", jsonrpc => "2.0" }, - { method => 'eth_gasPrice', params => [], id => "1", jsonrpc => "2.0" } , - { method => 'eth_hashrate', params => [], id => "1", jsonrpc => "2.0" } , - { method => 'eth_blockNumber', params => [], id => "1", jsonrpc => "2.0" }, - { method => 'eth_getBlockByNumber', params => ["latest","false"], id => "1", jsonrpc => "2.0" }, - { method => 'eth_syncing', params => [], id => "1", jsonrpc => "2.0" }, - { method => 'eth_coinbase', params => [], id => "1", jsonrpc => "2.0" }, - { method => 'eth_coinbase', params => [], id => "1", jsonrpc => "2.0" }, - { method => 'eth_coinbase', params => [], id => "1", jsonrpc => "2.0" }, - { method => 'eth_coinbase', params => [], id => "1", jsonrpc => "2.0" }, - { method => 'eth_coinbase', params => [], id => "1", jsonrpc => "2.0" } ]; + { method => 'eth_coinbase', params => [], id => "2", jsonrpc => "2.0" }, + { method => 'eth_gasPrice', params => [], id => "3", jsonrpc => "2.0" } , + { method => 'eth_hashrate', params => [], id => "4", jsonrpc => "2.0" } , + { method => 'eth_blockNumber', params => [], id => "5", jsonrpc => "2.0" }, + { method => 'eth_getBlockByNumber', params => ["latest","false"], id => "6", jsonrpc => "2.0" }, + { method => 'eth_syncing', params => [], id => "7", jsonrpc => "2.0" } ]; my $result = $options{custom}->request_api(method => 'POST', query_form_post => $query_form_post); # conditional formating: - my $res_sync = @{$result}[6]->{result} ? (@{$result}[6]->{result}->{currentBlock} / @{$result}[6]->{result}->{highestBlock}) * 100 : 100; + my $res_sync = @{$result}[6]->{result} ? hex((@{$result}[6]->{result}->{currentBlock} / @{$result}[6]->{result}->{highestBlock})) * 100 : 100; my $res_startingBlock = $res_sync != 100 ? @{$result}[6]->{result}->{startingBlock} : undef; my $res_currentBlock = $res_sync != 100 ? @{$result}[6]->{result}->{currentBlock} : undef; my $res_highestBlock = $res_sync != 100 ? @{$result}[6]->{result}->{highestBlock} : undef; # Unix time conversion - my $res_timestamp = localtime((@{$result}[5]->{result}->{timestamp})); + my $res_timestamp = localtime(hex(@{$result}[5]->{result}->{timestamp})); - $self->{eth} = { is_minning => @{$result}[0]->{result}, - coinbase => @{$result}[1]->{result}, - gas_price => @{$result}[2]->{result}, - hashrate => hex(@{$result}[3]->{result}), - block_number => @{$result}[4]->{result}, - block_time => $res_timestamp, - sync_start => $res_startingBlock, - sync_current => $res_currentBlock, - sync_highest => $res_highestBlock, - sync => $res_sync }; + $self->{eth} = { is_mining => @{$result}[0]->{result}, + coinbase => @{$result}[1]->{result}, + gas_price => hex(@{$result}[2]->{result}), + hashrate => hex(@{$result}[3]->{result}), + block_number => hex(@{$result}[4]->{result}), + block_time => $res_timestamp, + sync_start => hex($res_startingBlock), + sync_current => hex($res_currentBlock), + sync_highest => hex($res_highestBlock), + sync => $res_sync }; } From f92d23fcce77de919c01c7f48755cb5f8fcbe0b3 Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Thu, 26 Mar 2020 17:10:09 +0000 Subject: [PATCH 238/283] counters split --- blockchain/parity/restapi/mode/eth.pm | 118 ++++++++++++-------- blockchain/parity/restapi/mode/parity.pm | 134 ++++++++++++++--------- 2 files changed, 150 insertions(+), 102 deletions(-) diff --git a/blockchain/parity/restapi/mode/eth.pm b/blockchain/parity/restapi/mode/eth.pm index 5dcd4d71e..21aa5498b 100644 --- a/blockchain/parity/restapi/mode/eth.pm +++ b/blockchain/parity/restapi/mode/eth.pm @@ -26,7 +26,7 @@ use strict; use warnings; use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); -sub custom_mining_status_output { +sub custom_status_output { my ($self, %options) = @_; return sprintf( @@ -39,30 +39,17 @@ sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ - { name => 'eth', cb_prefix_output => 'prefix_module_output', type => 0 }, + { name => 'global', cb_prefix_output => 'prefix_module_output', type => 0 }, + { name => 'peer', cb_prefix_output => 'prefix_module_output', type => 0 }, + { name => 'block', cb_prefix_output => 'prefix_module_output', type => 0 }, + { name => 'sync', cb_prefix_output => 'prefix_module_output', type => 0 } ]; - $self->{maps_counters}->{eth} = [ - { label => 'is_mining', nlabel => 'parity.eth.peers.mining.status', set => { - key_values => [ { name => 'is_mining' } ], - output_template => "Client is mining: " . $self->can('custom_mining_status_output'), - perfdatas => [ - { label => 'is_mining', value => 'is_mining_absolute', template => '%s', min => 0 } - ], - } - }, - # { label => 'is_mining', nlabel => 'parity.eth.peers.mining.status', threshold => 0, set => { - # key_values => [ { name => 'is_mining' } ], - # output_template => "Client is mining: %s ", - # closure_custom_calc => \&catalog_status_calc, - # closure_custom_output => $self->can('custom_mining_status_output'), - # closure_custom_perfdata => sub { return 0; }, - # closure_custom_threshold_check => \&catalog_status_threshold - # } - # }, + $self->{maps_counters}->{global} = [ { label => 'coinbase', nlabel => 'parity.eth.client.coinbase', set => { key_values => [ { name => 'coinbase' } ], output_template => "Client coinbase is: %s ", + # closure_custom_perfdata => sub { return 0; } perfdatas => [ { label => 'client_coinbase', value => 'coinbase_absolute', template => '%s', min => 0 } ], @@ -75,6 +62,25 @@ sub set_counters { { label => 'gas_price', value => 'gas_price_absolute', template => '%d', min => 0 } ], } + } + ]; + + $self->{maps_counters}->{peer} = [ + # { label => 'status', nlabel => 'parity.eth.peers.mining.status', set => { + # key_values => [ { name => 'is_mining' } ], + # output_template => "Client is mining: " . $self->can('custom_mining_status_output'), + # perfdatas => [ + # { label => 'is_mining', value => 'is_mining_absolute', template => '%s', min => 0 } + # ], + # } + # }, + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'is_mining' } ], + closure_custom_calc => \&catalog_status_calc, + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold + } }, { label => 'hashrate', nlabel => 'parity.eth.node.hashrate', set => { key_values => [ { name => 'hashrate' } ], @@ -84,41 +90,52 @@ sub set_counters { ], } }, + ]; + + $self->{maps_counters}->{block} = [ { label => 'block_number', nlabel => 'parity.eth.block.number', set => { key_values => [ { name => 'block_number' } ], output_template => "Most recent block number is: %d ", - perfdatas => [ - { label => 'block_number', value => 'block_number_absolute', template => '%d', min => 0 } - ], + closure_custom_perfdata => sub { return 0; } + # perfdatas => [ + # { label => 'block_number', value => 'block_number_absolute', template => '%d', min => 0 } + # ], } }, { label => 'block_time', nlabel => 'parity.eth.block.time', set => { key_values => [ { name => 'block_time' } ], output_template => "Block time is: %s ", - perfdatas => [ - { label => 'block_time', value => 'block_time_absolute', template => '%s', min => 0 } - ], + closure_custom_perfdata => sub { return 0; } + # perfdatas => [ + # { label => 'block_time', value => 'block_time_absolute', template => '%s', min => 0 } + # ], } }, + ]; + + $self->{maps_counters}->{sync} = [ { label => 'sync_start', nlabel => 'parity.eth.sync.start.block', set => { key_values => [ { name => 'sync_start' } ], output_template => "Sync start block number is: %d ", - perfdatas => [ - { label => 'sync_start', value => 'sync_start_absolute', template => '%d', min => 0 } - ], + closure_custom_perfdata => sub { return 0; } + # perfdatas => [ + # { label => 'sync_start', value => 'sync_start_absolute', template => '%d', min => 0 } + # ], } }, { label => 'sync_current', nlabel => 'parity.eth.sync.current.block', set => { key_values => [ { name => 'sync_current' } ], output_template => "Sync current block number is: %d ", - perfdatas => [ - { label => 'sync_current', value => 'sync_current_absolute', template => '%d', min => 0 } - ], + closure_custom_perfdata => sub { return 0; } + # perfdatas => [ + # { label => 'sync_current', value => 'sync_current_absolute', template => '%d', min => 0 } + # ], } }, { label => 'sync_highest', nlabel => 'parity.eth.sync.highest.block', set => { key_values => [ { name => 'sync_highest' } ], output_template => "Sync highest block number is: %d ", + # closure_custom_perfdata => sub { return 0; } perfdatas => [ { label => 'sync_highest', value => 'sync_highest_absolute', template => '%d', min => 0 } ], @@ -131,7 +148,7 @@ sub set_counters { { label => 'sync', value => 'sync_absolute', template => '%d', min => 0 } ], } - } + } ]; } @@ -169,31 +186,36 @@ sub manage_selection { { method => 'eth_gasPrice', params => [], id => "3", jsonrpc => "2.0" } , { method => 'eth_hashrate', params => [], id => "4", jsonrpc => "2.0" } , { method => 'eth_blockNumber', params => [], id => "5", jsonrpc => "2.0" }, - { method => 'eth_getBlockByNumber', params => ["latest","false"], id => "6", jsonrpc => "2.0" }, + { method => 'eth_getBlockByNumber', params => ["latest",\0], id => "6", jsonrpc => "2.0" }, { method => 'eth_syncing', params => [], id => "7", jsonrpc => "2.0" } ]; my $result = $options{custom}->request_api(method => 'POST', query_form_post => $query_form_post); - + + # use Data::Dumper; + # print Dumper($result); + # conditional formating: my $res_sync = @{$result}[6]->{result} ? hex((@{$result}[6]->{result}->{currentBlock} / @{$result}[6]->{result}->{highestBlock})) * 100 : 100; - my $res_startingBlock = $res_sync != 100 ? @{$result}[6]->{result}->{startingBlock} : undef; - my $res_currentBlock = $res_sync != 100 ? @{$result}[6]->{result}->{currentBlock} : undef; - my $res_highestBlock = $res_sync != 100 ? @{$result}[6]->{result}->{highestBlock} : undef; + my $res_startingBlock = $res_sync != 100 ? hex(@{$result}[6]->{result}->{startingBlock}) : undef; + my $res_currentBlock = $res_sync != 100 ? hex(@{$result}[6]->{result}->{currentBlock}) : undef; + my $res_highestBlock = $res_sync != 100 ? hex(@{$result}[6]->{result}->{highestBlock}) : undef; # Unix time conversion my $res_timestamp = localtime(hex(@{$result}[5]->{result}->{timestamp})); - $self->{eth} = { is_mining => @{$result}[0]->{result}, - coinbase => @{$result}[1]->{result}, - gas_price => hex(@{$result}[2]->{result}), - hashrate => hex(@{$result}[3]->{result}), - block_number => hex(@{$result}[4]->{result}), - block_time => $res_timestamp, - sync_start => hex($res_startingBlock), - sync_current => hex($res_currentBlock), - sync_highest => hex($res_highestBlock), + $self->{global} = { coinbase => @{$result}[1]->{result}, + gas_price => hex(@{$result}[2]->{result}) }; + + $self->{block} = { block_number => defined @{$result}[4]->{result} ? hex(@{$result}[4]->{result}) : 0, + block_time => $res_timestamp }; + + $self->{sync} = { sync_start => $res_startingBlock, + sync_current => $res_currentBlock, + sync_highest => $res_highestBlock, sync => $res_sync }; + $self->{peer} = { is_mining => @{$result}[0]->{result}, + hashrate => hex(@{$result}[3]->{result}) }; } 1; @@ -216,7 +238,7 @@ Set warning threshold for listening status (Default: ''). =item B<--critical-status> -Set critical threshold for listening status (Default: '%{listening} !~ /true/'). +Set critical threshold for listening status (Default: '%{is_mining} !~ /true/'). =item B<--warning-peers> B<--critical-peers> diff --git a/blockchain/parity/restapi/mode/parity.pm b/blockchain/parity/restapi/mode/parity.pm index 122fd090b..099216314 100644 --- a/blockchain/parity/restapi/mode/parity.pm +++ b/blockchain/parity/restapi/mode/parity.pm @@ -30,50 +30,64 @@ sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ - { name => 'parity', cb_prefix_output => 'prefix_module_output', type => 0 }, + { name => 'global', cb_prefix_output => 'prefix_module_output', type => 0 }, + { name => 'node', cb_prefix_output => 'prefix_module_output', type => 0 }, + { name => 'mempool', cb_prefix_output => 'prefix_module_output', type => 0 }, + { name => 'network', cb_prefix_output => 'prefix_module_output', type => 0 } ]; - $self->{maps_counters}->{parity} = [ + $self->{maps_counters}->{global} = [ { label => 'parity_version', nlabel => 'parity.version', set => { key_values => [ { name => 'parity_version' } ], output_template => "Parity version is: %s ", - perfdatas => [ - { label => 'parity_version', value => 'parity_version_absolute', template => '%s', min => 0 } - ], + closure_custom_perfdata => sub { return 0; } + # perfdatas => [ + # { label => 'parity_version', value => 'parity_version_absolute', template => '%s', min => 0 } + # ], } }, { label => 'parity_version_hash', nlabel => 'parity.version.hash', set => { key_values => [ { name => 'parity_version_hash' } ], output_template => "Parity version hash is: %s ", - perfdatas => [ - { label => 'parity_version_hash', value => 'parity_version_hash_absolute', template => '%s', min => 0 } - ], + closure_custom_perfdata => sub { return 0; } + # perfdatas => [ + # { label => 'parity_version_hash', value => 'parity_version_hash_absolute', template => '%s', min => 0 } + # ], } }, { label => 'chain_name', nlabel => 'parity.chain.name', set => { key_values => [ { name => 'chain_name' } ], output_template => "Chain name is: %s ", - perfdatas => [ - { label => 'chain_name', value => 'chain_name_absolute', template => '%s', min => 0 } - ], + closure_custom_perfdata => sub { return 0; } + # perfdatas => [ + # { label => 'chain_name', value => 'chain_name_absolute', template => '%s', min => 0 } + # ], } }, - { label => 'pending_transactions', nlabel => 'parity.pending.transactions', set => { - key_values => [ { name => 'pending_transactions' } ], - output_template => "Pending transactions: %d ", - perfdatas => [ - { label => 'pending_transactions', value => 'pending_transactions_absolute', template => '%d', min => 0 } - ], + ]; + + $self->{maps_counters}->{node} = [ + { label => 'enode', nlabel => 'parity.node.enode.uri', set => { + key_values => [ { name => 'enode' } ], + output_template => "Node enode URI: %s ", + closure_custom_perfdata => sub { return 0; } + # perfdatas => [ + # { label => 'enode', value => 'enode_absolute', template => '%s', min => 0 } + # ], } }, - { label => 'mempool', nlabel => 'parity.mempol.capacity', set => { - key_values => [ { name => 'mempool' } ], - output_template => "Mempool: %d % ", - perfdatas => [ - { label => 'mempool', value => 'mempool_absolute', template => '%d', min => 0 } - ], + { label => 'node_name', nlabel => 'parity.node.name', set => { + key_values => [ { name => 'node_name' } ], + output_template => "Node name: %s ", + closure_custom_perfdata => sub { return 0; } + # perfdatas => [ + # { label => 'node_name', value => 'node_name_absolute', template => '%s', min => 0 } + # ], } - }, + } + ]; + + $self->{maps_counters}->{network} = [ { label => 'peers_connected', nlabel => 'parity.peers.connected', set => { key_values => [ { name => 'peers_connected' } ], output_template => "Number of connected peers: %d ", @@ -97,24 +111,28 @@ sub set_counters { { label => 'peers', value => 'peers_absolute', template => '%d', min => 0 } ], } - }, - { label => 'enode', nlabel => 'parity.node.enode.uri', set => { - key_values => [ { name => 'enode' } ], - output_template => "Node enode URI: %s ", - perfdatas => [ - { label => 'enode', value => 'enode_absolute', template => '%s', min => 0 } - ], - } - }, - { label => 'node_name', nlabel => 'parity.node.name', set => { - key_values => [ { name => 'node_name' } ], - output_template => "Node name: %s ", - perfdatas => [ - { label => 'node_name', value => 'node_name_absolute', template => '%s', min => 0 } - ], - } } ]; + + $self->{maps_counters}->{mempool} = [ + { label => 'pending_transactions', nlabel => 'parity.pending.transactions', set => { + key_values => [ { name => 'pending_transactions' } ], + output_template => "Pending transactions: %d ", + perfdatas => [ + { label => 'pending_transactions', value => 'pending_transactions_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'mempool', nlabel => 'parity.mempol.capacity', set => { + key_values => [ { name => 'mempool' } ], + output_template => "Mempool: %d % ", + perfdatas => [ + { label => 'mempool', value => 'mempool_absolute', template => '%d', min => 0 } + ], + } + }, + ]; + } sub new { @@ -152,24 +170,32 @@ sub manage_selection { { method => 'parity_netPeers', params => [], id => "4", jsonrpc => "2.0" }, { method => 'parity_enode', params => [], id => "5", jsonrpc => "2.0" }, { method => 'parity_nodeName', params => [], id => "6", jsonrpc => "2.0" }, - { method => 'parity_transactionsLimit', params => [], id => "7", jsonrpc => "2.0" } # could be done once, at the beginning of the process - ]; + { method => 'parity_transactionsLimit', params => [], id => "7", jsonrpc => "2.0" } ]; # parity_transactionsLimit could be done once, at the beginning of the process + my $result = $options{custom}->request_api(method => 'POST', query_form_post => $query_form_post); # Parity version construction - my $res_parity_version = @{$result}[0]->{result}->{version}->{major} . @{$result}[0]->{result}->{version}->{minor} . @{$result}[0]->{result}->{version}->{patch}; + my $res_parity_version = @{$result}[0]->{result}->{version}->{major} . '.' . @{$result}[0]->{result}->{version}->{minor} . '.' . @{$result}[0]->{result}->{version}->{patch}; - $self->{eth} = { parity_version => $res_parity_version, - parity_version_hash => @{$result}[0]->{result}->{hash}, - chain_name => @{$result}[1]->{result}, - pending_transactions => scalar @{$result}[2]->{result}, - mempool => @{$result}[2]->{result} / @{$result}[6]->{result} * 100, - peers_connected => @{$result}[3]->{result}->{connected}, - peers_max => @{$result}[3]->{result}->{max}, - peers => scalar @{$result}[3]->{result}->{peers}, - enode => @{$result}[4]->{result}, - node_name => @{$result}[5]->{result} }; + + # use Data::Dumper; + # print Dumper($res_parity_version); + + + $self->{global} = { parity_version => $res_parity_version, + parity_version_hash => @{$result}[0]->{result}->{hash}, + chain_name => @{$result}[1]->{result} }; + + $self->{node} = { enode => @{$result}[4]->{result}, + node_name => @{$result}[5]->{result} }; + + $self->{network} = { peers_connected => @{$result}[3]->{result}->{connected}, + peers_max => @{$result}[3]->{result}->{max}, + peers => length(@{$result}[3]->{result}->{peers}) }; + + $self->{mempool} = { pending_transactions => length(@{$result}[2]->{result}), + mempool => @{$result}[2]->{result} / @{$result}[6]->{result} * 100 }; } @@ -179,7 +205,7 @@ __END__ =head1 MODE -Check parity module metrics parity (parity_versionInfo, ) +Check parity module metrics parity (parity_versionInfo, parity_chain, parity_pendingTransactions, parity_netPeers, parity_enode, parity_nodeName, parity_transactionsLimit) =over 8 From 016873383809caf0a26f81adab3249c26b56deb6 Mon Sep 17 00:00:00 2001 From: Sims24 Date: Fri, 27 Mar 2020 16:12:08 +0100 Subject: [PATCH 239/283] dirty code update as an example --- blockchain/parity/restapi/mode/parity.pm | 26 ++++++++++++++---------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/blockchain/parity/restapi/mode/parity.pm b/blockchain/parity/restapi/mode/parity.pm index 099216314..0050e1ce9 100644 --- a/blockchain/parity/restapi/mode/parity.pm +++ b/blockchain/parity/restapi/mode/parity.pm @@ -30,17 +30,18 @@ sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ - { name => 'global', cb_prefix_output => 'prefix_module_output', type => 0 }, +# { name => 'global', cb_prefix_output => 'prefix_module_output', type => 0 }, { name => 'node', cb_prefix_output => 'prefix_module_output', type => 0 }, { name => 'mempool', cb_prefix_output => 'prefix_module_output', type => 0 }, { name => 'network', cb_prefix_output => 'prefix_module_output', type => 0 } ]; $self->{maps_counters}->{global} = [ - { label => 'parity_version', nlabel => 'parity.version', set => { + { label => 'parity_version', nlabel => 'parity.version', threshold => 0, set => { key_values => [ { name => 'parity_version' } ], output_template => "Parity version is: %s ", - closure_custom_perfdata => sub { return 0; } + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => sub { return 0; } # perfdatas => [ # { label => 'parity_version', value => 'parity_version_absolute', template => '%s', min => 0 } # ], @@ -67,10 +68,11 @@ sub set_counters { ]; $self->{maps_counters}->{node} = [ - { label => 'enode', nlabel => 'parity.node.enode.uri', set => { + { label => 'enode', nlabel => 'parity.node.enode.uri', threshold => 0, set => { key_values => [ { name => 'enode' } ], output_template => "Node enode URI: %s ", - closure_custom_perfdata => sub { return 0; } + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => sub { return 0; } # perfdatas => [ # { label => 'enode', value => 'enode_absolute', template => '%s', min => 0 } # ], @@ -125,7 +127,7 @@ sub set_counters { }, { label => 'mempool', nlabel => 'parity.mempol.capacity', set => { key_values => [ { name => 'mempool' } ], - output_template => "Mempool: %d % ", + output_template => "Mempool: %d %% ", perfdatas => [ { label => 'mempool', value => 'mempool_absolute', template => '%d', min => 0 } ], @@ -182,13 +184,15 @@ sub manage_selection { # use Data::Dumper; # print Dumper($res_parity_version); + $self->{output}->output_add(long_msg => "[config] chain name: " . @{$result}[1]->{result} . " parity version: " . $res_parity_version . " version_hash: " . @{$result}[0]->{result}->{hash}, + severity => 'OK'); - $self->{global} = { parity_version => $res_parity_version, - parity_version_hash => @{$result}[0]->{result}->{hash}, - chain_name => @{$result}[1]->{result} }; +# $self->{global} = { parity_version => $res_parity_version, +# parity_version_hash => @{$result}[0]->{result}->{hash}, +# chain_name => @{$result}[1]->{result} }; - $self->{node} = { enode => @{$result}[4]->{result}, - node_name => @{$result}[5]->{result} }; +# $self->{node} = { enode => @{$result}[4]->{result}, +# node_name => @{$result}[5]->{result} }; $self->{network} = { peers_connected => @{$result}[3]->{result}->{connected}, peers_max => @{$result}[3]->{result}->{max}, From eaa301dabacb85ede25465b794a3605a55f248b9 Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Fri, 27 Mar 2020 15:51:49 +0000 Subject: [PATCH 240/283] formating fix --- blockchain/parity/restapi/mode/eth.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blockchain/parity/restapi/mode/eth.pm b/blockchain/parity/restapi/mode/eth.pm index 21aa5498b..de8eb872f 100644 --- a/blockchain/parity/restapi/mode/eth.pm +++ b/blockchain/parity/restapi/mode/eth.pm @@ -143,7 +143,7 @@ sub set_counters { }, { label => 'sync', nlabel => 'parity.eth.sync.ratio', set => { key_values => [ { name => 'sync' } ], - output_template => "Sync ratio is: %d% ", + output_template => "Sync ratio is: %d%% ", perfdatas => [ { label => 'sync', value => 'sync_absolute', template => '%d', min => 0 } ], From c7d97547c8ae05e66a9875091e4a5ca82e4362cc Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Wed, 8 Apr 2020 16:34:15 +0000 Subject: [PATCH 241/283] eth-poller plugin and restapi plugin update --- blockchain/parity/ethpoller/custom/api.pm | 204 ++++++++++++++++++ blockchain/parity/ethpoller/mode/fork.pm | 98 +++++++++ blockchain/parity/ethpoller/mode/stats.pm | 114 ++++++++++ blockchain/parity/ethpoller/mode/watchlist.pm | 130 +++++++++++ blockchain/parity/ethpoller/plugin.pm | 50 +++++ blockchain/parity/restapi/mode/eth.pm | 175 +++++++-------- blockchain/parity/restapi/mode/net.pm | 29 ++- blockchain/parity/restapi/mode/parity.pm | 147 +++---------- 8 files changed, 720 insertions(+), 227 deletions(-) create mode 100644 blockchain/parity/ethpoller/custom/api.pm create mode 100644 blockchain/parity/ethpoller/mode/fork.pm create mode 100644 blockchain/parity/ethpoller/mode/stats.pm create mode 100644 blockchain/parity/ethpoller/mode/watchlist.pm create mode 100644 blockchain/parity/ethpoller/plugin.pm diff --git a/blockchain/parity/ethpoller/custom/api.pm b/blockchain/parity/ethpoller/custom/api.pm new file mode 100644 index 000000000..b6462c32f --- /dev/null +++ b/blockchain/parity/ethpoller/custom/api.pm @@ -0,0 +1,204 @@ +# +# Copyright 2020 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 blockchain::parity::ethpoller::custom::api; + +use strict; +use warnings; +use centreon::plugins::http; +use DateTime; +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 => { + "hostname:s" => { name => 'hostname' }, + "port:s" => { name => 'port' }, + "proto:s" => { name => 'proto' }, + "url-path:s" => { name => 'url_path' }, + "timeout:s" => { name => 'timeout' }, + }); + } + $options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1); + + $self->{output} = $options{output}; + $self->{mode} = $options{mode}; + $self->{http} = centreon::plugins::http->new(%options); + + return $self; +} + +sub set_options { + my ($self, %options) = @_; + + $self->{option_results} = $options{option_results}; +} + +sub set_defaults { + my ($self, %options) = @_; + + 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} = (defined($self->{option_results}->{hostname})) ? $self->{option_results}->{hostname} : undef; + $self->{port} = (defined($self->{option_results}->{port})) ? $self->{option_results}->{port} : 8000; + $self->{proto} = (defined($self->{option_results}->{proto})) ? $self->{option_results}->{proto} : 'http'; + $self->{url_path} = (defined($self->{option_results}->{url_path})) ? $self->{option_results}->{url_path} : ''; + $self->{timeout} = (defined($self->{option_results}->{timeout})) ? $self->{option_results}->{timeout} : 10; + + 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}->{url_path} = $self->{url_path}; + $self->{option_results}->{warning_status} = ''; + $self->{option_results}->{critical_status} = ''; +} + +sub settings { + my ($self, %options) = @_; + + $self->build_options_for_httplib(); + $self->{http}->add_header(key => 'Accept', value => 'application/json'); + $self->{http}->set_options(%{$self->{option_results}}); +} + +sub get_connection_info { + my ($self, %options) = @_; + + return $self->{hostname} . ":" . $self->{port}; +} + +sub get_hostname { + my ($self, %options) = @_; + + return $self->{hostname}; +} + +sub get_port { + my ($self, %options) = @_; + + return $self->{port}; +} + +sub request_api { + my ($self, %options) = @_; + + $self->settings; + + $self->{output}->output_add(long_msg => "Query URL: '" . $self->{proto} . "://" . $self->{hostname} . + $self->{url_path} . $options{url_path} . "'", debug => 1); + + my $content = $self->{http}->request(url_path => $self->{url_path} . $options{url_path}); + + my $decoded; + eval { + $decoded = JSON::XS->new->utf8->decode($content); + }; + if ($@) { + $self->{output}->add_option_msg(short_msg => "Cannot decode json response: $@"); + $self->{output}->option_exit(); + } + + return $decoded; +} + +1; + +__END__ + +=head1 NAME + +Parity eth-poller Rest API + +=head1 SYNOPSIS + +Parity eth-poller Rest API custom mode + +=head1 REST API OPTIONS + +Parity eth-poller Rest API + +=over 8 + +=item B<--hostname> + +Parity eth-poller API hostname. + +=item B<--port> + +API port (Default: 8000) + +=item B<--proto> + +Specify https if needed (Default: 'http') + +=item B<--url-path> + +API URL path (Default: '') + +=item B<--timeout> + +Set HTTP timeout + +=back + +=head1 DESCRIPTION + +B. + +=cut \ No newline at end of file diff --git a/blockchain/parity/ethpoller/mode/fork.pm b/blockchain/parity/ethpoller/mode/fork.pm new file mode 100644 index 000000000..226fdbc4a --- /dev/null +++ b/blockchain/parity/ethpoller/mode/fork.pm @@ -0,0 +1,98 @@ +# +# Copyright 2020 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 blockchain::parity::ethpoller::mode::fork; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); + +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 => { + 'unknown-status:s' => { name => 'unknown_status', default => '' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '%{listening} !~ /true/' }, + }); + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + my $result = $options{custom}->request_api(url_path => '/fork'); + + # use Data::Dumper; + # print Dumper($result); + + # Unix time conversion + my $res_timestamp = localtime(hex($result->{last_update}->{timestamp})); + + # Alerts management + my $cache = Cache::File->new( cache_root => './parity-eth-poller-cache' ); + + if (my $cached_timestamp = $cache->get('fork_timestamp')) { + if ($cached_timestamp ne $res_timestamp) { + #alert + } + } else { + $cache->set('fork_timestamp', $res_timestamp); + } + + $self->{output}->output_add(severity => 'OK', long_msg => '[Fork]: fork_timestamp: ' . $res_timestamp . + ' | fork_occurence: ' . $result->{occurence} . ' | fork_blockNumber: ' . $result->{last_update}->{blockNumber} . + ' | fork_in: ' . $result->{last_update}->{in} . ' | fork_out: ' . $result->{last_update}->{out} ); + +} + +1; + +__END__ + +=head1 MODE + +Check Parity eth-poller for forks details + +=over 8 + +=item B<--unknown-status> + +Set unknown threshold for listening status (Default: ''). + +=item B<--warning-status> + +Set warning threshold for listening status (Default: ''). + +=item B<--critical-status> + +Set critical threshold for listening status (Default: '%{is_mining} !~ /true/'). + +=item B<--warning-peers> B<--critical-peers> + +Warning and Critical threhsold on the number of peer + +=back + +=cut diff --git a/blockchain/parity/ethpoller/mode/stats.pm b/blockchain/parity/ethpoller/mode/stats.pm new file mode 100644 index 000000000..4844e9d6f --- /dev/null +++ b/blockchain/parity/ethpoller/mode/stats.pm @@ -0,0 +1,114 @@ +# +# Copyright 2020 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 blockchain::parity::ethpoller::mode::stats; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use Digest::MD5 qw(md5_hex); + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', cb_prefix_output => 'prefix_module_output', type => 0 }, + ]; + + $self->{maps_counters}->{global} = [ + { label => 'stats_blockInterval', nlabel => 'parity.network.peers.count', set => { + key_values => [ { name => 'stats_blockInterval' } ], + output_template => "Block interval: %d ", + perfdatas => [ + { label => 'stats_blockInterval', value => 'stats_blockInterval_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'stats_contracts', nlabel => 'eth.poller.stats.contracts.number', set => { + key_values => [ { name => 'stats_contracts' } ], + output_template => "Cumulative contracts: %d ", + perfdatas => [ + { label => 'stats_contracts', value => 'stats_contracts_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'stats_blocks', nlabel => 'eth.poller.stats.blocks.number', set => { + key_values => [ { name => 'stats_blocks' } ], + output_template => "Cumulative blocks: %d ", + perfdatas => [ + { label => 'stats_blocks', value => 'stats_blocks_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'stats_transactions', nlabel => 'eth.poller.stats.transactions.number', set => { + key_values => [ { name => 'stats_transactions' } ], + output_template => "Cumulative transactions: %d ", + perfdatas => [ + { label => 'stats_transactions', value => 'stats_transactions_absolute', template => '%d', min => 0 } + ], + } + }, + ]; + +} + +sub prefix_output { + my ($self, %options) = @_; + + return "Stats '"; +} + +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' }, + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + my $result = $options{custom}->request_api(url_path => '/stats'); + + # use Data::Dumper; + # print Dumper($result); + + $self->{global} = { stats_blockInterval => $result->{blockInterval}, + stats_contracts => $result->{cumulative}->{contracts}, + stats_blocks => $result->{cumulative}->{blocks}, + stats_transactions => $result->{cumulative}->{transactions} + }; +} + +1; + +__END__ + +=head1 MODE + +Check Parity eth-poller for accounts tracking + +=cut diff --git a/blockchain/parity/ethpoller/mode/watchlist.pm b/blockchain/parity/ethpoller/mode/watchlist.pm new file mode 100644 index 000000000..8a6e734f2 --- /dev/null +++ b/blockchain/parity/ethpoller/mode/watchlist.pm @@ -0,0 +1,130 @@ +# +# Copyright 2020 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 blockchain::parity::ethpoller::mode::watchlist; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use Digest::MD5 qw(md5_hex); + +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' }, + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + my $results = $options{custom}->request_api(url_path => '/watchlist'); + + # use Data::Dumper; + # print Dumper($results); + + # Alerts management + my $cache = Cache::File->new( cache_root => './parity-eth-poller-cache' ); + + if (my $cached_balance = $cache->get('contract_balance')) { + if ($cached_balance != $contract->{balance}) { + #alert + } + } else { + $cache->set('contract_balance', $contract->{balance}); + } + + foreach my $account (@{$results->{Accounts}}) { + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $account->{id} !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping '" . $account->{id} . "': no matching filter name.", debug => 1); + next; + } + + $self->{output}->output_add(severity => 'OK', long_msg => '[Account ' . $account->{id} . ']: label: ' . $account->{label} . ' | nonce: ' . $account->{nonce} . + ' | timestamp: ' . localtime(hex($account->{last_update}->{timestamp})) . ' | blockNumber: ' . $account->{last_update}->{blockNumber} . + ' | receiver: ' . $account->{last_update}->{receiver} . ' | value: ' . $account->{last_update}->{value} ); + } + + foreach my $minner (@{$results->{Miners}}) { + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $minner->{id} !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping '" . $minner->{id} . "': no matching filter name.", debug => 1); + next; + } + + $self->{output}->output_add(severity => 'OK', long_msg => '[Minner ' . $minner->{id} . ']: label: ' . $minner->{label} . ' | blocks: ' . $minner->{blocks} . + ' | timestamp: ' . localtime(hex($minner->{last_update}->{timestamp})) . ' | blockNumber: ' . $minner->{last_update}->{blockNumber} ); + } + + foreach my $contract (@{$results->{Constracts}}) { + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $contract->{id} !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping '" . $contract->{id} . "': no matching filter name.", debug => 1); + next; + } + + $self->{output}->output_add(severity => 'OK', long_msg => '[Contract ' . $contract->{id} . ']: label: ' . $contract->{label} . ' | balance: ' . $contract->{balance} . + ' | timestamp: ' . localtime(hex($contract->{last_update}->{timestamp})) . ' | blockNumber: ' . $contract->{last_update}->{blockNumber} . + ' | sender: ' . $contract->{last_update}->{sender} . ' | value: ' . $contract->{last_update}->{value} ); + } + + foreach my $function (@{$results->{Functions}}) { + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $function->{id} !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping '" . $function->{id} . "': no matching filter name.", debug => 1); + next; + } + + $self->{output}->output_add(severity => 'OK', long_msg => '[Function ' . $function->{id} . ']: label: ' . $function->{label} . ' | calls: ' . $function->{calls} . + ' | timestamp: ' . localtime(hex($function->{last_update}->{timestamp})) . ' | blockNumber: ' . $function->{last_update}->{blockNumber} . + ' | sender: ' . $function->{last_update}->{sender} . ' | receiver: ' . $function->{last_update}->{receiver} . + ' | value: ' . $function->{last_update}->{value} ); + } + + foreach my $event (@{$results->{Events}}) { + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $event->{id} !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping '" . $event->{id} . "': no matching filter name.", debug => 1); + next; + } + + $self->{output}->output_add(severity => 'OK', long_msg => '[Event ' . $event->{id} . ']: label: ' . $event->{label} . ' | calls: ' . $event->{calls} . + ' | timestamp: ' . localtime(hex($event->{last_update}->{timestamp})) . ' | blockNumber: ' . $event->{last_update}->{blockNumber} . + ' | sender: ' . $event->{last_update}->{sender} . ' | receiver: ' . $event->{last_update}->{receiver}); + } + +} + +1; + +__END__ + +=head1 MODE + +Check Parity eth-poller for accounts tracking + +=cut diff --git a/blockchain/parity/ethpoller/plugin.pm b/blockchain/parity/ethpoller/plugin.pm new file mode 100644 index 000000000..77989acd3 --- /dev/null +++ b/blockchain/parity/ethpoller/plugin.pm @@ -0,0 +1,50 @@ +# +# Copyright 2020 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 blockchain::parity::ethpoller::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} = '0.1'; + %{$self->{modes}} = ( + 'watchlist' => 'blockchain::parity::ethpoller::mode::watchlist', + 'fork' => 'blockchain::parity::ethpoller::mode::fork', + 'stats' => 'blockchain::parity::ethpoller::mode::stats' + ); + $self->{custom_modes}{api} = 'blockchain::parity::ethpoller::custom::api'; + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Parity blockchain accounts, contracts and forks from eth-poller with HTTP GET + +=cut diff --git a/blockchain/parity/restapi/mode/eth.pm b/blockchain/parity/restapi/mode/eth.pm index de8eb872f..ca604f753 100644 --- a/blockchain/parity/restapi/mode/eth.pm +++ b/blockchain/parity/restapi/mode/eth.pm @@ -40,21 +40,10 @@ sub set_counters { $self->{maps_counters_type} = [ { name => 'global', cb_prefix_output => 'prefix_module_output', type => 0 }, - { name => 'peer', cb_prefix_output => 'prefix_module_output', type => 0 }, { name => 'block', cb_prefix_output => 'prefix_module_output', type => 0 }, - { name => 'sync', cb_prefix_output => 'prefix_module_output', type => 0 } ]; $self->{maps_counters}->{global} = [ - { label => 'coinbase', nlabel => 'parity.eth.client.coinbase', set => { - key_values => [ { name => 'coinbase' } ], - output_template => "Client coinbase is: %s ", - # closure_custom_perfdata => sub { return 0; } - perfdatas => [ - { label => 'client_coinbase', value => 'coinbase_absolute', template => '%s', min => 0 } - ], - } - }, { label => 'gas_price', nlabel => 'parity.eth.gas.price', set => { key_values => [ { name => 'gas_price' } ], output_template => "The gas price is: %d wei ", @@ -65,90 +54,47 @@ sub set_counters { } ]; - $self->{maps_counters}->{peer} = [ - # { label => 'status', nlabel => 'parity.eth.peers.mining.status', set => { - # key_values => [ { name => 'is_mining' } ], - # output_template => "Client is mining: " . $self->can('custom_mining_status_output'), - # perfdatas => [ - # { label => 'is_mining', value => 'is_mining_absolute', template => '%s', min => 0 } - # ], - # } - # }, - { label => 'status', threshold => 0, set => { - key_values => [ { name => 'is_mining' } ], - closure_custom_calc => \&catalog_status_calc, - closure_custom_output => $self->can('custom_status_output'), - closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => \&catalog_status_threshold - } - }, - { label => 'hashrate', nlabel => 'parity.eth.node.hashrate', set => { - key_values => [ { name => 'hashrate' } ], - output_template => "Node hashrate is: %d/s ", - perfdatas => [ - { label => 'node_hashrate', value => 'hashrate_absolute', template => '%d', min => 0 } - ], - } - }, - ]; - $self->{maps_counters}->{block} = [ - { label => 'block_number', nlabel => 'parity.eth.block.number', set => { - key_values => [ { name => 'block_number' } ], - output_template => "Most recent block number is: %d ", - closure_custom_perfdata => sub { return 0; } - # perfdatas => [ - # { label => 'block_number', value => 'block_number_absolute', template => '%d', min => 0 } - # ], - } - }, - { label => 'block_time', nlabel => 'parity.eth.block.time', set => { - key_values => [ { name => 'block_time' } ], - output_template => "Block time is: %s ", - closure_custom_perfdata => sub { return 0; } - # perfdatas => [ - # { label => 'block_time', value => 'block_time_absolute', template => '%s', min => 0 } - # ], - } - }, - ]; - - $self->{maps_counters}->{sync} = [ - { label => 'sync_start', nlabel => 'parity.eth.sync.start.block', set => { - key_values => [ { name => 'sync_start' } ], - output_template => "Sync start block number is: %d ", - closure_custom_perfdata => sub { return 0; } - # perfdatas => [ - # { label => 'sync_start', value => 'sync_start_absolute', template => '%d', min => 0 } - # ], - } - }, - { label => 'sync_current', nlabel => 'parity.eth.sync.current.block', set => { - key_values => [ { name => 'sync_current' } ], - output_template => "Sync current block number is: %d ", - closure_custom_perfdata => sub { return 0; } - # perfdatas => [ - # { label => 'sync_current', value => 'sync_current_absolute', template => '%d', min => 0 } - # ], - } - }, - { label => 'sync_highest', nlabel => 'parity.eth.sync.highest.block', set => { - key_values => [ { name => 'sync_highest' } ], - output_template => "Sync highest block number is: %d ", - # closure_custom_perfdata => sub { return 0; } + { label => 'block_size', nlabel => 'parity.eth.block.size', set => { + key_values => [ { name => 'block_size' } ], + output_template => "Most recent block size: %d ", perfdatas => [ - { label => 'sync_highest', value => 'sync_highest_absolute', template => '%d', min => 0 } + { label => 'block_size', value => 'block_size_absolute', template => '%d', min => 0 } ], } }, - { label => 'sync', nlabel => 'parity.eth.sync.ratio', set => { - key_values => [ { name => 'sync' } ], - output_template => "Sync ratio is: %d%% ", + { label => 'block_transactions', nlabel => 'parity.eth.block.transactions.number', set => { + key_values => [ { name => 'block_transactions' } ], + output_template => "Block transactions number: %d ", perfdatas => [ - { label => 'sync', value => 'sync_absolute', template => '%d', min => 0 } + { label => 'block_transactions', value => 'block_transactions_absolute', template => '%d', min => 0 } ], } - } + }, + { label => 'block_gas', nlabel => 'parity.eth.block.gas', set => { + key_values => [ { name => 'block_gas' } ], + output_template => "Block gas: %d ", + perfdatas => [ + { label => 'block_gas', value => 'block_gas_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'block_difficulty', nlabel => 'parity.eth.block.difficulty', set => { + key_values => [ { name => 'block_difficulty' } ], + output_template => "Block difficulty: %f ", + perfdatas => [ + { label => 'block_difficulty', value => 'block_difficulty_absolute', template => '%f', min => 0 } + ], + } + }, + { label => 'block_uncles', nlabel => 'parity.eth.block.difficulty', set => { + key_values => [ { name => 'block_uncles' } ], + output_template => "Block uncles: %d ", + perfdatas => [ + { label => 'block_uncles', value => 'block_uncles_absolute', template => '%d', min => 0 } + ], + } + }, ]; } @@ -190,32 +136,55 @@ sub manage_selection { { method => 'eth_syncing', params => [], id => "7", jsonrpc => "2.0" } ]; my $result = $options{custom}->request_api(method => 'POST', query_form_post => $query_form_post); + + my $gas_price = hex(@{$result}[2]->{result}); # use Data::Dumper; - # print Dumper($result); + # my $length = scalar(@{$$result[5]->{result}->{transactions}}); + # print Dumper($result) ; # conditional formating: my $res_sync = @{$result}[6]->{result} ? hex((@{$result}[6]->{result}->{currentBlock} / @{$result}[6]->{result}->{highestBlock})) * 100 : 100; - my $res_startingBlock = $res_sync != 100 ? hex(@{$result}[6]->{result}->{startingBlock}) : undef; - my $res_currentBlock = $res_sync != 100 ? hex(@{$result}[6]->{result}->{currentBlock}) : undef; - my $res_highestBlock = $res_sync != 100 ? hex(@{$result}[6]->{result}->{highestBlock}) : undef; + my $res_startingBlock = $res_sync != 100 ? hex(@{$result}[6]->{result}->{startingBlock}) : 'none'; + my $res_currentBlock = $res_sync != 100 ? hex(@{$result}[6]->{result}->{currentBlock}) : 'none'; + my $res_highestBlock = $res_sync != 100 ? hex(@{$result}[6]->{result}->{highestBlock}) : 'none'; - # Unix time conversion - my $res_timestamp = localtime(hex(@{$result}[5]->{result}->{timestamp})); + # Alerts management + my $cache = Cache::File->new( cache_root => './parity-restapi-cache' ); - $self->{global} = { coinbase => @{$result}[1]->{result}, - gas_price => hex(@{$result}[2]->{result}) }; + if (my $cached_sync = $cache->get('node_sync')) { + if ($cached_sync == 100 && $res_sync < 100) { + #alert + } + } else { + $cache->set('node_sync', $res_sync); + } - $self->{block} = { block_number => defined @{$result}[4]->{result} ? hex(@{$result}[4]->{result}) : 0, - block_time => $res_timestamp }; + if (my $cached_price = $cache->get('gas_price')) { + if ($cached_price != $gas_price) { + #alert + } + } else { + $cache->set('gas_price', $gas_price); + } - $self->{sync} = { sync_start => $res_startingBlock, - sync_current => $res_currentBlock, - sync_highest => $res_highestBlock, - sync => $res_sync }; + $self->{global} = { gas_price => $gas_price }; - $self->{peer} = { is_mining => @{$result}[0]->{result}, - hashrate => hex(@{$result}[3]->{result}) }; + $self->{block} = { block_size => hex(@{$result}[5]->{result}->{size}), + block_gas => hex(@{$result}[5]->{result}->{gasUsed}), + block_difficulty => hex(@{$result}[5]->{result}->{totalDifficulty}), + block_uncles => scalar(@{$$result[5]->{result}->{uncles}}), + block_transactions => scalar(@{$$result[5]->{result}->{transactions}})}; + + $self->{output}->output_add(severity => 'OK', long_msg => '[Node status] is_mining: ' . @{$result}[0]->{result} . ' | sync_start: ' . $res_startingBlock . + ' | sync_current: ' . $res_currentBlock . ' | sync_highest: ' . $res_highestBlock . ' | sync: ' . $res_sync . '%%'); + $self->{output}->output_add(severity => 'OK', long_msg => '[Client] coinbase: ' . @{$result}[1]->{result}); + $self->{output}->output_add(severity => 'OK', long_msg => '[Global] hashrate: ' . hex(@{$result}[3]->{result}) . + ' | block_number: ' . (defined @{$result}[4]->{result} ? hex(@{$result}[4]->{result}) : 0)); + $self->{output}->output_add(severity => 'OK', long_msg => '[Last block] block_time: ' . localtime(hex(@{$result}[5]->{result}->{timestamp})) . ' | block_gas_limit: ' . hex(@{$result}[5]->{result}->{gasLimit}) . + ' | block_miner: ' . @{$result}[5]->{result}->{miner} . ' | block_hash: ' . @{$result}[5]->{result}->{hash} . + ' | last_block_number: ' . hex(@{$result}[5]->{result}->{number})); + } 1; diff --git a/blockchain/parity/restapi/mode/net.pm b/blockchain/parity/restapi/mode/net.pm index d5e8f88cf..02ba31028 100644 --- a/blockchain/parity/restapi/mode/net.pm +++ b/blockchain/parity/restapi/mode/net.pm @@ -43,15 +43,7 @@ sub set_counters { ]; $self->{maps_counters}->{network} = [ - { label => 'status', threshold => 0, set => { - key_values => [ { name => 'listening' } ], - closure_custom_calc => \&catalog_status_calc, - closure_custom_output => $self->can('custom_status_output'), - closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => \&catalog_status_threshold - } - }, - { label => 'peers', nlabel => 'parity.network.peers.count', set => { + { label => 'peers', nlabel => 'parity.network.peers.count', set => { key_values => [ { name => 'peers' } ], output_template => "connected peers: %s ", perfdatas => [ @@ -96,9 +88,24 @@ sub manage_selection { my $result = $options{custom}->request_api(method => 'POST', query_form_post => $query_form_post); - $self->{network} = { listening => @{$result}[0]->{result}, - peers => hex(@{$result}[1]->{result}) }; + my $peer_count = hex(@{$result}[1]->{result}); + # Alerts management + my $cache = Cache::File->new( cache_root => './parity-restapi-cache' ); + + if (my $cached_count = $cache->get('peers_count')) { + if ($peer_count < $cached_count) { + #alert + } elsif ($peer_count > $cached_count) { + #alert + } + } else { + $cache->set('peers_count', $peer_count); + } + + $self->{network} = { peers => hex(@{$result}[1]->{result}) }; + + $self->{output}->output_add(long_msg => "[Node] is_listening: " . $peer_count, severity => 'OK'); } 1; diff --git a/blockchain/parity/restapi/mode/parity.pm b/blockchain/parity/restapi/mode/parity.pm index 0050e1ce9..8823d1673 100644 --- a/blockchain/parity/restapi/mode/parity.pm +++ b/blockchain/parity/restapi/mode/parity.pm @@ -24,108 +24,18 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; +use Cache::File; use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ -# { name => 'global', cb_prefix_output => 'prefix_module_output', type => 0 }, - { name => 'node', cb_prefix_output => 'prefix_module_output', type => 0 }, - { name => 'mempool', cb_prefix_output => 'prefix_module_output', type => 0 }, - { name => 'network', cb_prefix_output => 'prefix_module_output', type => 0 } - ]; - - $self->{maps_counters}->{global} = [ - { label => 'parity_version', nlabel => 'parity.version', threshold => 0, set => { - key_values => [ { name => 'parity_version' } ], - output_template => "Parity version is: %s ", - closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => sub { return 0; } - # perfdatas => [ - # { label => 'parity_version', value => 'parity_version_absolute', template => '%s', min => 0 } - # ], - } - }, - { label => 'parity_version_hash', nlabel => 'parity.version.hash', set => { - key_values => [ { name => 'parity_version_hash' } ], - output_template => "Parity version hash is: %s ", - closure_custom_perfdata => sub { return 0; } - # perfdatas => [ - # { label => 'parity_version_hash', value => 'parity_version_hash_absolute', template => '%s', min => 0 } - # ], - } - }, - { label => 'chain_name', nlabel => 'parity.chain.name', set => { - key_values => [ { name => 'chain_name' } ], - output_template => "Chain name is: %s ", - closure_custom_perfdata => sub { return 0; } - # perfdatas => [ - # { label => 'chain_name', value => 'chain_name_absolute', template => '%s', min => 0 } - # ], - } - }, - ]; - - $self->{maps_counters}->{node} = [ - { label => 'enode', nlabel => 'parity.node.enode.uri', threshold => 0, set => { - key_values => [ { name => 'enode' } ], - output_template => "Node enode URI: %s ", - closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => sub { return 0; } - # perfdatas => [ - # { label => 'enode', value => 'enode_absolute', template => '%s', min => 0 } - # ], - } - }, - { label => 'node_name', nlabel => 'parity.node.name', set => { - key_values => [ { name => 'node_name' } ], - output_template => "Node name: %s ", - closure_custom_perfdata => sub { return 0; } - # perfdatas => [ - # { label => 'node_name', value => 'node_name_absolute', template => '%s', min => 0 } - # ], - } - } - ]; - - $self->{maps_counters}->{network} = [ - { label => 'peers_connected', nlabel => 'parity.peers.connected', set => { - key_values => [ { name => 'peers_connected' } ], - output_template => "Number of connected peers: %d ", - perfdatas => [ - { label => 'peers_connected', value => 'peers_connected_absolute', template => '%d', min => 0 } - ], - } - }, - { label => 'peers_max', nlabel => 'parity.peers.max.connected', set => { - key_values => [ { name => 'peers_max' } ], - output_template => "Maximum number of connected peers: %d ", - perfdatas => [ - { label => 'peers_max', value => 'peers_max_absolute', template => '%d', min => 0 } - ], - } - }, - { label => 'peers', nlabel => 'parity.peers', set => { - key_values => [ { name => 'peers' } ], - output_template => "Peers: %d ", - perfdatas => [ - { label => 'peers', value => 'peers_absolute', template => '%d', min => 0 } - ], - } - } - ]; + { name => 'mempool', cb_prefix_output => 'prefix_module_output', type => 0 } + ]; $self->{maps_counters}->{mempool} = [ - { label => 'pending_transactions', nlabel => 'parity.pending.transactions', set => { - key_values => [ { name => 'pending_transactions' } ], - output_template => "Pending transactions: %d ", - perfdatas => [ - { label => 'pending_transactions', value => 'pending_transactions_absolute', template => '%d', min => 0 } - ], - } - }, - { label => 'mempool', nlabel => 'parity.mempol.capacity', set => { + { label => 'mempool', nlabel => 'parity.mempol.usage', set => { key_values => [ { name => 'mempool' } ], output_template => "Mempool: %d %% ", perfdatas => [ @@ -172,35 +82,46 @@ sub manage_selection { { method => 'parity_netPeers', params => [], id => "4", jsonrpc => "2.0" }, { method => 'parity_enode', params => [], id => "5", jsonrpc => "2.0" }, { method => 'parity_nodeName', params => [], id => "6", jsonrpc => "2.0" }, - { method => 'parity_transactionsLimit', params => [], id => "7", jsonrpc => "2.0" } ]; # parity_transactionsLimit could be done once, at the beginning of the process + { method => 'parity_transactionsLimit', params => [], id => "7", jsonrpc => "2.0" } ]; #TO CHECK parity_transactionsLimit could be done once, at the beginning of the process - my $result = $options{custom}->request_api(method => 'POST', query_form_post => $query_form_post); + use Data::Dumper; + # print Dumper($result); + # Parity version construction my $res_parity_version = @{$result}[0]->{result}->{version}->{major} . '.' . @{$result}[0]->{result}->{version}->{minor} . '.' . @{$result}[0]->{result}->{version}->{patch}; + # Alerts management + my $cache = Cache::File->new( cache_root => './parity-restapi-cache' ); + + if (my $cached_version = $cache->get('parity_version')) { + if ($res_parity_version ne $cached_version) { + #alert + } + } else { + $cache->set('parity_version', $res_parity_version); + } + + if (my $cached_name = $cache->get('chain_name')) { + if ($cached_name ne @{$result}[1]->{result}) { + #alert + } + } else { + $cache->set('chain_name', @{$result}[1]->{result}); + } # use Data::Dumper; - # print Dumper($res_parity_version); + # print Dumper($result); - $self->{output}->output_add(long_msg => "[config] chain name: " . @{$result}[1]->{result} . " parity version: " . $res_parity_version . " version_hash: " . @{$result}[0]->{result}->{hash}, - severity => 'OK'); - -# $self->{global} = { parity_version => $res_parity_version, -# parity_version_hash => @{$result}[0]->{result}->{hash}, -# chain_name => @{$result}[1]->{result} }; - -# $self->{node} = { enode => @{$result}[4]->{result}, -# node_name => @{$result}[5]->{result} }; - - $self->{network} = { peers_connected => @{$result}[3]->{result}->{connected}, - peers_max => @{$result}[3]->{result}->{max}, - peers => length(@{$result}[3]->{result}->{peers}) }; - - $self->{mempool} = { pending_transactions => length(@{$result}[2]->{result}), - mempool => @{$result}[2]->{result} / @{$result}[6]->{result} * 100 }; + $self->{output}->output_add(long_msg => "[config] chain name: " . @{$result}[1]->{result} . " | parity version: " . $res_parity_version . " | version_hash: " + . @{$result}[0]->{result}->{hash}, severity => 'OK'); + $self->{output}->output_add(long_msg => "[Network] peers_connected: " . @{$result}[3]->{result}->{connected} . " | peers_max: " . @{$result}[3]->{result}->{max} . " | peers: " + . scalar(@{$$result[3]->{result}->{peers}}), severity => 'OK'); + $self->{output}->output_add(long_msg => "[Node] node_name: " . @{$result}[5]->{result} . " | enode: " . @{$result}[4]->{result} , severity => 'OK'); + $self->{output}->output_add(long_msg => "[Node] pending_transactions: " . scalar(@{$$result[2]->{result}}), severity => 'OK'); + $self->{mempool} = { mempool => scalar(@{$$result[2]->{result}}) / @{$result}[6]->{result} * 100 }; #TO CHECK division entière } 1; From 2b08bbb6aae3878ba22a6855ae5b1c32d4fbd50d Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Thu, 9 Apr 2020 08:00:11 +0000 Subject: [PATCH 242/283] add missing package --- blockchain/parity/ethpoller/mode/fork.pm | 1 + blockchain/parity/ethpoller/mode/watchlist.pm | 18 ++++++++++-------- blockchain/parity/restapi/mode/eth.pm | 1 + blockchain/parity/restapi/mode/net.pm | 1 + 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/blockchain/parity/ethpoller/mode/fork.pm b/blockchain/parity/ethpoller/mode/fork.pm index 226fdbc4a..7fc4f5c0c 100644 --- a/blockchain/parity/ethpoller/mode/fork.pm +++ b/blockchain/parity/ethpoller/mode/fork.pm @@ -24,6 +24,7 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; +use Cache::File; use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); sub new { diff --git a/blockchain/parity/ethpoller/mode/watchlist.pm b/blockchain/parity/ethpoller/mode/watchlist.pm index 8a6e734f2..a6a7b28f8 100644 --- a/blockchain/parity/ethpoller/mode/watchlist.pm +++ b/blockchain/parity/ethpoller/mode/watchlist.pm @@ -24,6 +24,7 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; +use Cache::File; use Digest::MD5 qw(md5_hex); sub new { @@ -49,14 +50,6 @@ sub manage_selection { # Alerts management my $cache = Cache::File->new( cache_root => './parity-eth-poller-cache' ); - if (my $cached_balance = $cache->get('contract_balance')) { - if ($cached_balance != $contract->{balance}) { - #alert - } - } else { - $cache->set('contract_balance', $contract->{balance}); - } - foreach my $account (@{$results->{Accounts}}) { if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && $account->{id} !~ /$self->{option_results}->{filter_name}/) { @@ -90,6 +83,15 @@ sub manage_selection { $self->{output}->output_add(severity => 'OK', long_msg => '[Contract ' . $contract->{id} . ']: label: ' . $contract->{label} . ' | balance: ' . $contract->{balance} . ' | timestamp: ' . localtime(hex($contract->{last_update}->{timestamp})) . ' | blockNumber: ' . $contract->{last_update}->{blockNumber} . ' | sender: ' . $contract->{last_update}->{sender} . ' | value: ' . $contract->{last_update}->{value} ); + + if (my $cached_balance = $cache->get('contract_balance_' . $contract->{id})) { + if ($cached_balance != $contract->{balance}) { + #alert + } + } else { + $cache->set('contract_balance_' . $contract->{id}, $contract->{balance}); + } + } foreach my $function (@{$results->{Functions}}) { diff --git a/blockchain/parity/restapi/mode/eth.pm b/blockchain/parity/restapi/mode/eth.pm index ca604f753..00c479110 100644 --- a/blockchain/parity/restapi/mode/eth.pm +++ b/blockchain/parity/restapi/mode/eth.pm @@ -24,6 +24,7 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; +use Cache::File; use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); sub custom_status_output { diff --git a/blockchain/parity/restapi/mode/net.pm b/blockchain/parity/restapi/mode/net.pm index 02ba31028..17ceaed4b 100644 --- a/blockchain/parity/restapi/mode/net.pm +++ b/blockchain/parity/restapi/mode/net.pm @@ -24,6 +24,7 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; +use Cache::File; use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); sub custom_status_output { From bcb95743d949e732684003402e8e85328baa8c13 Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Thu, 9 Apr 2020 08:28:21 +0000 Subject: [PATCH 243/283] remove Cache::File package --- blockchain/parity/ethpoller/mode/fork.pm | 23 +++++++----- blockchain/parity/ethpoller/mode/watchlist.pm | 22 ++++++----- blockchain/parity/restapi/mode/eth.pm | 37 ++++++++++--------- blockchain/parity/restapi/mode/net.pm | 27 ++++++++------ blockchain/parity/restapi/mode/parity.pm | 37 ++++++++++--------- 5 files changed, 80 insertions(+), 66 deletions(-) diff --git a/blockchain/parity/ethpoller/mode/fork.pm b/blockchain/parity/ethpoller/mode/fork.pm index 7fc4f5c0c..597dbd4a0 100644 --- a/blockchain/parity/ethpoller/mode/fork.pm +++ b/blockchain/parity/ethpoller/mode/fork.pm @@ -24,12 +24,12 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; -use Cache::File; +use Digest::MD5 qw(md5_hex); use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1, statefile => 1); bless $self, $class; $options{options}->add_options(arguments => { @@ -43,6 +43,9 @@ sub new { sub manage_selection { my ($self, %options) = @_; + $self->{cache_name} = "parity_ethpoller_" . $self->{mode} . '_' . (defined($self->{option_results}->{hostname}) ? $self->{option_results}->{hostname} : 'me') . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); + my $result = $options{custom}->request_api(url_path => '/fork'); # use Data::Dumper; @@ -52,15 +55,15 @@ sub manage_selection { my $res_timestamp = localtime(hex($result->{last_update}->{timestamp})); # Alerts management - my $cache = Cache::File->new( cache_root => './parity-eth-poller-cache' ); + # my $cache = Cache::File->new( cache_root => './parity-eth-poller-cache' ); - if (my $cached_timestamp = $cache->get('fork_timestamp')) { - if ($cached_timestamp ne $res_timestamp) { - #alert - } - } else { - $cache->set('fork_timestamp', $res_timestamp); - } + # if (my $cached_timestamp = $cache->get('fork_timestamp')) { + # if ($cached_timestamp ne $res_timestamp) { + # #alert + # } + # } else { + # $cache->set('fork_timestamp', $res_timestamp); + # } $self->{output}->output_add(severity => 'OK', long_msg => '[Fork]: fork_timestamp: ' . $res_timestamp . ' | fork_occurence: ' . $result->{occurence} . ' | fork_blockNumber: ' . $result->{last_update}->{blockNumber} . diff --git a/blockchain/parity/ethpoller/mode/watchlist.pm b/blockchain/parity/ethpoller/mode/watchlist.pm index a6a7b28f8..69e2baef2 100644 --- a/blockchain/parity/ethpoller/mode/watchlist.pm +++ b/blockchain/parity/ethpoller/mode/watchlist.pm @@ -24,12 +24,11 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; -use Cache::File; use Digest::MD5 qw(md5_hex); sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1, statefile => 1); bless $self, $class; $options{options}->add_options(arguments => { @@ -42,13 +41,16 @@ sub new { sub manage_selection { my ($self, %options) = @_; + $self->{cache_name} = "parity_ethpoller_" . $self->{mode} . '_' . (defined($self->{option_results}->{hostname}) ? $self->{option_results}->{hostname} : 'me') . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); + my $results = $options{custom}->request_api(url_path => '/watchlist'); # use Data::Dumper; # print Dumper($results); # Alerts management - my $cache = Cache::File->new( cache_root => './parity-eth-poller-cache' ); + # my $cache = Cache::File->new( cache_root => './parity-eth-poller-cache' ); foreach my $account (@{$results->{Accounts}}) { if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && @@ -84,13 +86,13 @@ sub manage_selection { ' | timestamp: ' . localtime(hex($contract->{last_update}->{timestamp})) . ' | blockNumber: ' . $contract->{last_update}->{blockNumber} . ' | sender: ' . $contract->{last_update}->{sender} . ' | value: ' . $contract->{last_update}->{value} ); - if (my $cached_balance = $cache->get('contract_balance_' . $contract->{id})) { - if ($cached_balance != $contract->{balance}) { - #alert - } - } else { - $cache->set('contract_balance_' . $contract->{id}, $contract->{balance}); - } + # if (my $cached_balance = $cache->get('contract_balance_' . $contract->{id})) { + # if ($cached_balance != $contract->{balance}) { + # #alert + # } + # } else { + # $cache->set('contract_balance_' . $contract->{id}, $contract->{balance}); + # } } diff --git a/blockchain/parity/restapi/mode/eth.pm b/blockchain/parity/restapi/mode/eth.pm index 00c479110..fd819842a 100644 --- a/blockchain/parity/restapi/mode/eth.pm +++ b/blockchain/parity/restapi/mode/eth.pm @@ -24,7 +24,7 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; -use Cache::File; +use Digest::MD5 qw(md5_hex); use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); sub custom_status_output { @@ -101,7 +101,7 @@ sub set_counters { sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1, statefile => 1); bless $self, $class; $options{options}->add_options(arguments => { @@ -128,6 +128,9 @@ sub prefix_module_output { sub manage_selection { my ($self, %options) = @_; + $self->{cache_name} = "parity_restapi_" . $self->{mode} . '_' . (defined($self->{option_results}->{hostname}) ? $self->{option_results}->{hostname} : 'me') . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); + my $query_form_post = [ { method => 'eth_mining', params => [], id => "1", jsonrpc => "2.0" }, { method => 'eth_coinbase', params => [], id => "2", jsonrpc => "2.0" }, { method => 'eth_gasPrice', params => [], id => "3", jsonrpc => "2.0" } , @@ -151,23 +154,23 @@ sub manage_selection { my $res_highestBlock = $res_sync != 100 ? hex(@{$result}[6]->{result}->{highestBlock}) : 'none'; # Alerts management - my $cache = Cache::File->new( cache_root => './parity-restapi-cache' ); + # my $cache = Cache::File->new( cache_root => './parity-restapi-cache' ); - if (my $cached_sync = $cache->get('node_sync')) { - if ($cached_sync == 100 && $res_sync < 100) { - #alert - } - } else { - $cache->set('node_sync', $res_sync); - } + # if (my $cached_sync = $cache->get('node_sync')) { + # if ($cached_sync == 100 && $res_sync < 100) { + # #alert + # } + # } else { + # $cache->set('node_sync', $res_sync); + # } - if (my $cached_price = $cache->get('gas_price')) { - if ($cached_price != $gas_price) { - #alert - } - } else { - $cache->set('gas_price', $gas_price); - } + # if (my $cached_price = $cache->get('gas_price')) { + # if ($cached_price != $gas_price) { + # #alert + # } + # } else { + # $cache->set('gas_price', $gas_price); + # } $self->{global} = { gas_price => $gas_price }; diff --git a/blockchain/parity/restapi/mode/net.pm b/blockchain/parity/restapi/mode/net.pm index 17ceaed4b..b3d9fdd5a 100644 --- a/blockchain/parity/restapi/mode/net.pm +++ b/blockchain/parity/restapi/mode/net.pm @@ -24,7 +24,7 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; -use Cache::File; +use Digest::MD5 qw(md5_hex); use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); sub custom_status_output { @@ -57,7 +57,7 @@ sub set_counters { sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1, statefile => 1); bless $self, $class; $options{options}->add_options(arguments => { @@ -84,6 +84,9 @@ sub prefix_module_output { sub manage_selection { my ($self, %options) = @_; + $self->{cache_name} = "parity_restapi_" . $self->{mode} . '_' . (defined($self->{option_results}->{hostname}) ? $self->{option_results}->{hostname} : 'me') . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); + my $query_form_post = [ { method => 'net_listening', params => [], id => "1", jsonrpc => "2.0" }, { method => 'net_peerCount', params => [], id => "2", jsonrpc => "2.0" } ]; @@ -92,17 +95,17 @@ sub manage_selection { my $peer_count = hex(@{$result}[1]->{result}); # Alerts management - my $cache = Cache::File->new( cache_root => './parity-restapi-cache' ); + # my $cache = Cache::File->new( cache_root => './parity-restapi-cache' ); - if (my $cached_count = $cache->get('peers_count')) { - if ($peer_count < $cached_count) { - #alert - } elsif ($peer_count > $cached_count) { - #alert - } - } else { - $cache->set('peers_count', $peer_count); - } + # if (my $cached_count = $cache->get('peers_count')) { + # if ($peer_count < $cached_count) { + # #alert + # } elsif ($peer_count > $cached_count) { + # #alert + # } + # } else { + # $cache->set('peers_count', $peer_count); + # } $self->{network} = { peers => hex(@{$result}[1]->{result}) }; diff --git a/blockchain/parity/restapi/mode/parity.pm b/blockchain/parity/restapi/mode/parity.pm index 8823d1673..f58e3234e 100644 --- a/blockchain/parity/restapi/mode/parity.pm +++ b/blockchain/parity/restapi/mode/parity.pm @@ -24,7 +24,7 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; -use Cache::File; +use Digest::MD5 qw(md5_hex); use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); sub set_counters { @@ -49,7 +49,7 @@ sub set_counters { sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1, statefile => 1); bless $self, $class; $options{options}->add_options(arguments => { @@ -76,6 +76,9 @@ sub prefix_module_output { sub manage_selection { my ($self, %options) = @_; + $self->{cache_name} = "parity_restapi_" . $self->{mode} . '_' . (defined($self->{option_results}->{hostname}) ? $self->{option_results}->{hostname} : 'me') . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); + my $query_form_post = [ { method => 'parity_versionInfo', params => [], id => "1", jsonrpc => "2.0" }, { method => 'parity_chain', params => [], id => "2", jsonrpc => "2.0" }, { method => 'parity_pendingTransactions', params => [], id => "3", jsonrpc => "2.0" } , @@ -93,23 +96,23 @@ sub manage_selection { my $res_parity_version = @{$result}[0]->{result}->{version}->{major} . '.' . @{$result}[0]->{result}->{version}->{minor} . '.' . @{$result}[0]->{result}->{version}->{patch}; # Alerts management - my $cache = Cache::File->new( cache_root => './parity-restapi-cache' ); + # my $cache = Cache::File->new( cache_root => './parity-restapi-cache' ); - if (my $cached_version = $cache->get('parity_version')) { - if ($res_parity_version ne $cached_version) { - #alert - } - } else { - $cache->set('parity_version', $res_parity_version); - } + # if (my $cached_version = $cache->get('parity_version')) { + # if ($res_parity_version ne $cached_version) { + # #alert + # } + # } else { + # $cache->set('parity_version', $res_parity_version); + # } - if (my $cached_name = $cache->get('chain_name')) { - if ($cached_name ne @{$result}[1]->{result}) { - #alert - } - } else { - $cache->set('chain_name', @{$result}[1]->{result}); - } + # if (my $cached_name = $cache->get('chain_name')) { + # if ($cached_name ne @{$result}[1]->{result}) { + # #alert + # } + # } else { + # $cache->set('chain_name', @{$result}[1]->{result}); + # } # use Data::Dumper; # print Dumper($result); From 94d5eafd131116412dc5f563182a29ae9ad020cd Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Thu, 9 Apr 2020 09:50:29 +0000 Subject: [PATCH 244/283] change long_msg output format --- blockchain/parity/ethpoller/mode/fork.pm | 6 ++-- blockchain/parity/ethpoller/mode/watchlist.pm | 30 +++++++++---------- blockchain/parity/restapi/mode/eth.pm | 16 +++++----- blockchain/parity/restapi/mode/net.pm | 2 +- blockchain/parity/restapi/mode/parity.pm | 12 ++++---- 5 files changed, 33 insertions(+), 33 deletions(-) diff --git a/blockchain/parity/ethpoller/mode/fork.pm b/blockchain/parity/ethpoller/mode/fork.pm index 597dbd4a0..84b1d194f 100644 --- a/blockchain/parity/ethpoller/mode/fork.pm +++ b/blockchain/parity/ethpoller/mode/fork.pm @@ -65,9 +65,9 @@ sub manage_selection { # $cache->set('fork_timestamp', $res_timestamp); # } - $self->{output}->output_add(severity => 'OK', long_msg => '[Fork]: fork_timestamp: ' . $res_timestamp . - ' | fork_occurence: ' . $result->{occurence} . ' | fork_blockNumber: ' . $result->{last_update}->{blockNumber} . - ' | fork_in: ' . $result->{last_update}->{in} . ' | fork_out: ' . $result->{last_update}->{out} ); + $self->{output}->output_add(severity => 'OK', long_msg => 'Fork: [fork_timestamp: ' . $res_timestamp . + '] [fork_occurence: ' . $result->{occurence} . '] [fork_blockNumber: ' . $result->{last_update}->{blockNumber} . + '] [fork_in: ' . $result->{last_update}->{in} . '] [fork_out: ' . $result->{last_update}->{out} . ']'); } diff --git a/blockchain/parity/ethpoller/mode/watchlist.pm b/blockchain/parity/ethpoller/mode/watchlist.pm index 69e2baef2..9ffb7fd85 100644 --- a/blockchain/parity/ethpoller/mode/watchlist.pm +++ b/blockchain/parity/ethpoller/mode/watchlist.pm @@ -59,9 +59,9 @@ sub manage_selection { next; } - $self->{output}->output_add(severity => 'OK', long_msg => '[Account ' . $account->{id} . ']: label: ' . $account->{label} . ' | nonce: ' . $account->{nonce} . - ' | timestamp: ' . localtime(hex($account->{last_update}->{timestamp})) . ' | blockNumber: ' . $account->{last_update}->{blockNumber} . - ' | receiver: ' . $account->{last_update}->{receiver} . ' | value: ' . $account->{last_update}->{value} ); + $self->{output}->output_add(severity => 'OK', long_msg => 'Account ' . $account->{id} . ': [label: ' . $account->{label} . '] [nonce: ' . $account->{nonce} . + '] [timestamp: ' . localtime(hex($account->{last_update}->{timestamp})) . '] [blockNumber: ' . $account->{last_update}->{blockNumber} . + '] [receiver: ' . $account->{last_update}->{receiver} . '] [value: ' . $account->{last_update}->{value} . ']' ); } foreach my $minner (@{$results->{Miners}}) { @@ -71,8 +71,8 @@ sub manage_selection { next; } - $self->{output}->output_add(severity => 'OK', long_msg => '[Minner ' . $minner->{id} . ']: label: ' . $minner->{label} . ' | blocks: ' . $minner->{blocks} . - ' | timestamp: ' . localtime(hex($minner->{last_update}->{timestamp})) . ' | blockNumber: ' . $minner->{last_update}->{blockNumber} ); + $self->{output}->output_add(severity => 'OK', long_msg => 'Minner ' . $minner->{id} . ': [label: ' . $minner->{label} . '] [blocks: ' . $minner->{blocks} . + '] [timestamp: ' . localtime(hex($minner->{last_update}->{timestamp})) . '] [blockNumber: ' . $minner->{last_update}->{blockNumber} . ']'); } foreach my $contract (@{$results->{Constracts}}) { @@ -82,9 +82,9 @@ sub manage_selection { next; } - $self->{output}->output_add(severity => 'OK', long_msg => '[Contract ' . $contract->{id} . ']: label: ' . $contract->{label} . ' | balance: ' . $contract->{balance} . - ' | timestamp: ' . localtime(hex($contract->{last_update}->{timestamp})) . ' | blockNumber: ' . $contract->{last_update}->{blockNumber} . - ' | sender: ' . $contract->{last_update}->{sender} . ' | value: ' . $contract->{last_update}->{value} ); + $self->{output}->output_add(severity => 'OK', long_msg => 'Contract ' . $contract->{id} . ': [label: ' . $contract->{label} . '] [balance: ' . $contract->{balance} . + '] [timestamp: ' . localtime(hex($contract->{last_update}->{timestamp})) . '] [blockNumber: ' . $contract->{last_update}->{blockNumber} . + '] [sender: ' . $contract->{last_update}->{sender} . '] [value: ' . $contract->{last_update}->{value} . ']'); # if (my $cached_balance = $cache->get('contract_balance_' . $contract->{id})) { # if ($cached_balance != $contract->{balance}) { @@ -103,10 +103,10 @@ sub manage_selection { next; } - $self->{output}->output_add(severity => 'OK', long_msg => '[Function ' . $function->{id} . ']: label: ' . $function->{label} . ' | calls: ' . $function->{calls} . - ' | timestamp: ' . localtime(hex($function->{last_update}->{timestamp})) . ' | blockNumber: ' . $function->{last_update}->{blockNumber} . - ' | sender: ' . $function->{last_update}->{sender} . ' | receiver: ' . $function->{last_update}->{receiver} . - ' | value: ' . $function->{last_update}->{value} ); + $self->{output}->output_add(severity => 'OK', long_msg => '[Function ' . $function->{id} . ']: label: ' . $function->{label} . '] [calls: ' . $function->{calls} . + '] [timestamp: ' . localtime(hex($function->{last_update}->{timestamp})) . '] [blockNumber: ' . $function->{last_update}->{blockNumber} . + '] [sender: ' . $function->{last_update}->{sender} . '] [receiver: ' . $function->{last_update}->{receiver} . + '] [value: ' . $function->{last_update}->{value} . ']'); } foreach my $event (@{$results->{Events}}) { @@ -116,9 +116,9 @@ sub manage_selection { next; } - $self->{output}->output_add(severity => 'OK', long_msg => '[Event ' . $event->{id} . ']: label: ' . $event->{label} . ' | calls: ' . $event->{calls} . - ' | timestamp: ' . localtime(hex($event->{last_update}->{timestamp})) . ' | blockNumber: ' . $event->{last_update}->{blockNumber} . - ' | sender: ' . $event->{last_update}->{sender} . ' | receiver: ' . $event->{last_update}->{receiver}); + $self->{output}->output_add(severity => 'OK', long_msg => '[Event ' . $event->{id} . ']: label: ' . $event->{label} . '] [calls: ' . $event->{calls} . + '] [timestamp: ' . localtime(hex($event->{last_update}->{timestamp})) . '] [blockNumber: ' . $event->{last_update}->{blockNumber} . + '] [sender: ' . $event->{last_update}->{sender} . '] [receiver: ' . $event->{last_update}->{receiver} . ']'); } } diff --git a/blockchain/parity/restapi/mode/eth.pm b/blockchain/parity/restapi/mode/eth.pm index fd819842a..63f7f435b 100644 --- a/blockchain/parity/restapi/mode/eth.pm +++ b/blockchain/parity/restapi/mode/eth.pm @@ -180,14 +180,14 @@ sub manage_selection { block_uncles => scalar(@{$$result[5]->{result}->{uncles}}), block_transactions => scalar(@{$$result[5]->{result}->{transactions}})}; - $self->{output}->output_add(severity => 'OK', long_msg => '[Node status] is_mining: ' . @{$result}[0]->{result} . ' | sync_start: ' . $res_startingBlock . - ' | sync_current: ' . $res_currentBlock . ' | sync_highest: ' . $res_highestBlock . ' | sync: ' . $res_sync . '%%'); - $self->{output}->output_add(severity => 'OK', long_msg => '[Client] coinbase: ' . @{$result}[1]->{result}); - $self->{output}->output_add(severity => 'OK', long_msg => '[Global] hashrate: ' . hex(@{$result}[3]->{result}) . - ' | block_number: ' . (defined @{$result}[4]->{result} ? hex(@{$result}[4]->{result}) : 0)); - $self->{output}->output_add(severity => 'OK', long_msg => '[Last block] block_time: ' . localtime(hex(@{$result}[5]->{result}->{timestamp})) . ' | block_gas_limit: ' . hex(@{$result}[5]->{result}->{gasLimit}) . - ' | block_miner: ' . @{$result}[5]->{result}->{miner} . ' | block_hash: ' . @{$result}[5]->{result}->{hash} . - ' | last_block_number: ' . hex(@{$result}[5]->{result}->{number})); + $self->{output}->output_add(severity => 'OK', long_msg => 'Node status: [is_mining: ' . @{$result}[0]->{result} . '] [sync_start: ' . $res_startingBlock . + '] [sync_current: ' . $res_currentBlock . '] [sync_highest: ' . $res_highestBlock . '] [sync: ' . $res_sync . '%%]'); + $self->{output}->output_add(severity => 'OK', long_msg => 'Client: [coinbase: ' . @{$result}[1]->{result} . ']'); + $self->{output}->output_add(severity => 'OK', long_msg => 'Global: [hashrate: ' . hex(@{$result}[3]->{result}) . + '] [block_number: ' . (defined @{$result}[4]->{result} ? hex(@{$result}[4]->{result}) : 0) . ']'); + $self->{output}->output_add(severity => 'OK', long_msg => 'Last block: [block_time: ' . localtime(hex(@{$result}[5]->{result}->{timestamp})) . '] [block_gas_limit: ' . hex(@{$result}[5]->{result}->{gasLimit}) . + '] [block_miner: ' . @{$result}[5]->{result}->{miner} . '] [block_hash: ' . @{$result}[5]->{result}->{hash} . + '] [last_block_number: ' . hex(@{$result}[5]->{result}->{number}) . ']'); } diff --git a/blockchain/parity/restapi/mode/net.pm b/blockchain/parity/restapi/mode/net.pm index b3d9fdd5a..2ad2ca153 100644 --- a/blockchain/parity/restapi/mode/net.pm +++ b/blockchain/parity/restapi/mode/net.pm @@ -109,7 +109,7 @@ sub manage_selection { $self->{network} = { peers => hex(@{$result}[1]->{result}) }; - $self->{output}->output_add(long_msg => "[Node] is_listening: " . $peer_count, severity => 'OK'); + $self->{output}->output_add(long_msg => "Node status: [is_listening: " . $peer_count . ']', severity => 'OK'); } 1; diff --git a/blockchain/parity/restapi/mode/parity.pm b/blockchain/parity/restapi/mode/parity.pm index f58e3234e..d3aad2c31 100644 --- a/blockchain/parity/restapi/mode/parity.pm +++ b/blockchain/parity/restapi/mode/parity.pm @@ -117,12 +117,12 @@ sub manage_selection { # use Data::Dumper; # print Dumper($result); - $self->{output}->output_add(long_msg => "[config] chain name: " . @{$result}[1]->{result} . " | parity version: " . $res_parity_version . " | version_hash: " - . @{$result}[0]->{result}->{hash}, severity => 'OK'); - $self->{output}->output_add(long_msg => "[Network] peers_connected: " . @{$result}[3]->{result}->{connected} . " | peers_max: " . @{$result}[3]->{result}->{max} . " | peers: " - . scalar(@{$$result[3]->{result}->{peers}}), severity => 'OK'); - $self->{output}->output_add(long_msg => "[Node] node_name: " . @{$result}[5]->{result} . " | enode: " . @{$result}[4]->{result} , severity => 'OK'); - $self->{output}->output_add(long_msg => "[Node] pending_transactions: " . scalar(@{$$result[2]->{result}}), severity => 'OK'); + $self->{output}->output_add(long_msg => "Config: [chain name: " . @{$result}[1]->{result} . "] [parity version: " . $res_parity_version . "] [version_hash: " + . @{$result}[0]->{result}->{hash} . "]", severity => 'OK'); + $self->{output}->output_add(long_msg => "Network: [peers_connected: " . @{$result}[3]->{result}->{connected} . "] [peers_max: " . @{$result}[3]->{result}->{max} . "] [peers: " + . scalar(@{$$result[3]->{result}->{peers}}) . "]", severity => 'OK'); + $self->{output}->output_add(long_msg => "Node: [node_name: " . @{$result}[5]->{result} . "] [enode: " . @{$result}[4]->{result} . "]", severity => 'OK'); + $self->{output}->output_add(long_msg => "Mempool: [pending_transactions: " . scalar(@{$$result[2]->{result}}) . "]", severity => 'OK'); $self->{mempool} = { mempool => scalar(@{$$result[2]->{result}}) / @{$result}[6]->{result} * 100 }; #TO CHECK division entière } From 4b51d50452c7195ed682e29f2da5393ea6bfcce2 Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Thu, 9 Apr 2020 10:14:28 +0000 Subject: [PATCH 245/283] add package bigint --- blockchain/parity/ethpoller/mode/watchlist.pm | 1 + blockchain/parity/restapi/mode/eth.pm | 1 + 2 files changed, 2 insertions(+) diff --git a/blockchain/parity/ethpoller/mode/watchlist.pm b/blockchain/parity/ethpoller/mode/watchlist.pm index 9ffb7fd85..78b577fee 100644 --- a/blockchain/parity/ethpoller/mode/watchlist.pm +++ b/blockchain/parity/ethpoller/mode/watchlist.pm @@ -24,6 +24,7 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; +use bigint; use Digest::MD5 qw(md5_hex); sub new { diff --git a/blockchain/parity/restapi/mode/eth.pm b/blockchain/parity/restapi/mode/eth.pm index 63f7f435b..6d7fbe78c 100644 --- a/blockchain/parity/restapi/mode/eth.pm +++ b/blockchain/parity/restapi/mode/eth.pm @@ -25,6 +25,7 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; use Digest::MD5 qw(md5_hex); +use bigint; use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); sub custom_status_output { From 078b9f1499b5b4d21cbb5a9c1856f20b5d6acf24 Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Mon, 13 Apr 2020 12:32:07 +0000 Subject: [PATCH 246/283] timestamp formating --- blockchain/parity/ethpoller/mode/fork.pm | 3 +- blockchain/parity/ethpoller/mode/stats.pm | 2 +- blockchain/parity/ethpoller/mode/watchlist.pm | 22 ++++++++++--- blockchain/parity/restapi/mode/eth.pm | 33 ++++++++++--------- blockchain/parity/restapi/mode/parity.pm | 2 +- 5 files changed, 38 insertions(+), 24 deletions(-) diff --git a/blockchain/parity/ethpoller/mode/fork.pm b/blockchain/parity/ethpoller/mode/fork.pm index 84b1d194f..5d53b223f 100644 --- a/blockchain/parity/ethpoller/mode/fork.pm +++ b/blockchain/parity/ethpoller/mode/fork.pm @@ -52,7 +52,8 @@ sub manage_selection { # print Dumper($result); # Unix time conversion - my $res_timestamp = localtime(hex($result->{last_update}->{timestamp})); + my $res_timestamp = $result->{last_update}->{timestamp} == 0 ? '': localtime($result->{last_update}->{timestamp}); + # Alerts management # my $cache = Cache::File->new( cache_root => './parity-eth-poller-cache' ); diff --git a/blockchain/parity/ethpoller/mode/stats.pm b/blockchain/parity/ethpoller/mode/stats.pm index 4844e9d6f..e6cbe1451 100644 --- a/blockchain/parity/ethpoller/mode/stats.pm +++ b/blockchain/parity/ethpoller/mode/stats.pm @@ -34,7 +34,7 @@ sub set_counters { ]; $self->{maps_counters}->{global} = [ - { label => 'stats_blockInterval', nlabel => 'parity.network.peers.count', set => { + { label => 'stats_blockInterval', nlabel => 'parity.stats.block.interval', set => { key_values => [ { name => 'stats_blockInterval' } ], output_template => "Block interval: %d ", perfdatas => [ diff --git a/blockchain/parity/ethpoller/mode/watchlist.pm b/blockchain/parity/ethpoller/mode/watchlist.pm index 78b577fee..2c4ed8304 100644 --- a/blockchain/parity/ethpoller/mode/watchlist.pm +++ b/blockchain/parity/ethpoller/mode/watchlist.pm @@ -53,6 +53,8 @@ sub manage_selection { # Alerts management # my $cache = Cache::File->new( cache_root => './parity-eth-poller-cache' ); + my $res_timestamp = 0; + foreach my $account (@{$results->{Accounts}}) { if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && $account->{id} !~ /$self->{option_results}->{filter_name}/) { @@ -60,8 +62,10 @@ sub manage_selection { next; } + $res_timestamp = $account->{last_update}->{timestamp} == 0 ? '': localtime($account->{last_update}->{timestamp}); + $self->{output}->output_add(severity => 'OK', long_msg => 'Account ' . $account->{id} . ': [label: ' . $account->{label} . '] [nonce: ' . $account->{nonce} . - '] [timestamp: ' . localtime(hex($account->{last_update}->{timestamp})) . '] [blockNumber: ' . $account->{last_update}->{blockNumber} . + '] [timestamp: ' . $res_timestamp . '] [blockNumber: ' . $account->{last_update}->{blockNumber} . '] [receiver: ' . $account->{last_update}->{receiver} . '] [value: ' . $account->{last_update}->{value} . ']' ); } @@ -72,8 +76,10 @@ sub manage_selection { next; } + $res_timestamp = $minner->{last_update}->{timestamp} == 0 ? '': localtime($minner->{last_update}->{timestamp}); + $self->{output}->output_add(severity => 'OK', long_msg => 'Minner ' . $minner->{id} . ': [label: ' . $minner->{label} . '] [blocks: ' . $minner->{blocks} . - '] [timestamp: ' . localtime(hex($minner->{last_update}->{timestamp})) . '] [blockNumber: ' . $minner->{last_update}->{blockNumber} . ']'); + '] [timestamp: ' . $res_timestamp . '] [blockNumber: ' . $minner->{last_update}->{blockNumber} . ']'); } foreach my $contract (@{$results->{Constracts}}) { @@ -83,8 +89,10 @@ sub manage_selection { next; } + $res_timestamp = $contract->{last_update}->{timestamp} == 0 ? '': localtime($contract->{last_update}->{timestamp}); + $self->{output}->output_add(severity => 'OK', long_msg => 'Contract ' . $contract->{id} . ': [label: ' . $contract->{label} . '] [balance: ' . $contract->{balance} . - '] [timestamp: ' . localtime(hex($contract->{last_update}->{timestamp})) . '] [blockNumber: ' . $contract->{last_update}->{blockNumber} . + '] [timestamp: ' . $res_timestamp . '] [blockNumber: ' . $contract->{last_update}->{blockNumber} . '] [sender: ' . $contract->{last_update}->{sender} . '] [value: ' . $contract->{last_update}->{value} . ']'); # if (my $cached_balance = $cache->get('contract_balance_' . $contract->{id})) { @@ -104,8 +112,10 @@ sub manage_selection { next; } + $res_timestamp = $function->{last_update}->{timestamp} == 0 ? '': localtime($function->{last_update}->{timestamp}); + $self->{output}->output_add(severity => 'OK', long_msg => '[Function ' . $function->{id} . ']: label: ' . $function->{label} . '] [calls: ' . $function->{calls} . - '] [timestamp: ' . localtime(hex($function->{last_update}->{timestamp})) . '] [blockNumber: ' . $function->{last_update}->{blockNumber} . + '] [timestamp: ' . $res_timestamp . '] [blockNumber: ' . $function->{last_update}->{blockNumber} . '] [sender: ' . $function->{last_update}->{sender} . '] [receiver: ' . $function->{last_update}->{receiver} . '] [value: ' . $function->{last_update}->{value} . ']'); } @@ -117,8 +127,10 @@ sub manage_selection { next; } + $res_timestamp = $event->{last_update}->{timestamp} == 0 ? '': localtime($event->{last_update}->{timestamp}); + $self->{output}->output_add(severity => 'OK', long_msg => '[Event ' . $event->{id} . ']: label: ' . $event->{label} . '] [calls: ' . $event->{calls} . - '] [timestamp: ' . localtime(hex($event->{last_update}->{timestamp})) . '] [blockNumber: ' . $event->{last_update}->{blockNumber} . + '] [timestamp: ' . $res_timestamp . '] [blockNumber: ' . $event->{last_update}->{blockNumber} . '] [sender: ' . $event->{last_update}->{sender} . '] [receiver: ' . $event->{last_update}->{receiver} . ']'); } diff --git a/blockchain/parity/restapi/mode/eth.pm b/blockchain/parity/restapi/mode/eth.pm index 6d7fbe78c..90f5a0ae8 100644 --- a/blockchain/parity/restapi/mode/eth.pm +++ b/blockchain/parity/restapi/mode/eth.pm @@ -81,15 +81,15 @@ sub set_counters { ], } }, - { label => 'block_difficulty', nlabel => 'parity.eth.block.difficulty', set => { - key_values => [ { name => 'block_difficulty' } ], - output_template => "Block difficulty: %f ", - perfdatas => [ - { label => 'block_difficulty', value => 'block_difficulty_absolute', template => '%f', min => 0 } - ], - } - }, - { label => 'block_uncles', nlabel => 'parity.eth.block.difficulty', set => { + # { label => 'block_difficulty', nlabel => 'parity.eth.block.difficulty', set => { + # key_values => [ { name => 'block_difficulty' } ], + # output_template => "Block difficulty: %f ", + # perfdatas => [ + # { label => 'block_difficulty', value => 'block_difficulty_absolute', template => '%f', min => 0 } + # ], + # } + # }, + { label => 'block_uncles', nlabel => 'parity.eth.block.uncles', set => { key_values => [ { name => 'block_uncles' } ], output_template => "Block uncles: %d ", perfdatas => [ @@ -143,10 +143,11 @@ sub manage_selection { my $result = $options{custom}->request_api(method => 'POST', query_form_post => $query_form_post); my $gas_price = hex(@{$result}[2]->{result}); - - # use Data::Dumper; - # my $length = scalar(@{$$result[5]->{result}->{transactions}}); - # print Dumper($result) ; + my $res_block_time = @{$result}[5]->{result}->{timestamp} == 0 ? '': localtime(hex(@{$result}[5]->{result}->{timestamp})); + + use Data::Dumper; + print Dumper($res_block_time) ; + print Dumper(@{$result}[5]->{result}->{timestamp}); # conditional formating: my $res_sync = @{$result}[6]->{result} ? hex((@{$result}[6]->{result}->{currentBlock} / @{$result}[6]->{result}->{highestBlock})) * 100 : 100; @@ -177,16 +178,16 @@ sub manage_selection { $self->{block} = { block_size => hex(@{$result}[5]->{result}->{size}), block_gas => hex(@{$result}[5]->{result}->{gasUsed}), - block_difficulty => hex(@{$result}[5]->{result}->{totalDifficulty}), + # block_difficulty => hex(@{$result}[5]->{result}->{totalDifficulty}), block_uncles => scalar(@{$$result[5]->{result}->{uncles}}), block_transactions => scalar(@{$$result[5]->{result}->{transactions}})}; $self->{output}->output_add(severity => 'OK', long_msg => 'Node status: [is_mining: ' . @{$result}[0]->{result} . '] [sync_start: ' . $res_startingBlock . - '] [sync_current: ' . $res_currentBlock . '] [sync_highest: ' . $res_highestBlock . '] [sync: ' . $res_sync . '%%]'); + '] [sync_current: ' . $res_currentBlock . '] [sync_highest: ' . $res_highestBlock . '] [sync: ' . $res_sync . '%]'); $self->{output}->output_add(severity => 'OK', long_msg => 'Client: [coinbase: ' . @{$result}[1]->{result} . ']'); $self->{output}->output_add(severity => 'OK', long_msg => 'Global: [hashrate: ' . hex(@{$result}[3]->{result}) . '] [block_number: ' . (defined @{$result}[4]->{result} ? hex(@{$result}[4]->{result}) : 0) . ']'); - $self->{output}->output_add(severity => 'OK', long_msg => 'Last block: [block_time: ' . localtime(hex(@{$result}[5]->{result}->{timestamp})) . '] [block_gas_limit: ' . hex(@{$result}[5]->{result}->{gasLimit}) . + $self->{output}->output_add(severity => 'OK', long_msg => 'Last block: [block_time: ' . $res_block_time . '] [block_gas_limit: ' . hex(@{$result}[5]->{result}->{gasLimit}) . '] [block_miner: ' . @{$result}[5]->{result}->{miner} . '] [block_hash: ' . @{$result}[5]->{result}->{hash} . '] [last_block_number: ' . hex(@{$result}[5]->{result}->{number}) . ']'); diff --git a/blockchain/parity/restapi/mode/parity.pm b/blockchain/parity/restapi/mode/parity.pm index d3aad2c31..aad3fb67c 100644 --- a/blockchain/parity/restapi/mode/parity.pm +++ b/blockchain/parity/restapi/mode/parity.pm @@ -122,7 +122,7 @@ sub manage_selection { $self->{output}->output_add(long_msg => "Network: [peers_connected: " . @{$result}[3]->{result}->{connected} . "] [peers_max: " . @{$result}[3]->{result}->{max} . "] [peers: " . scalar(@{$$result[3]->{result}->{peers}}) . "]", severity => 'OK'); $self->{output}->output_add(long_msg => "Node: [node_name: " . @{$result}[5]->{result} . "] [enode: " . @{$result}[4]->{result} . "]", severity => 'OK'); - $self->{output}->output_add(long_msg => "Mempool: [pending_transactions: " . scalar(@{$$result[2]->{result}}) . "]", severity => 'OK'); + $self->{output}->output_add(long_msg => "Mempool: [pending_transactions: " . scalar(@{$$result[2]->{result}}) . "] [transactions_limit: " . @{$result}[6]->{result} . "]", severity => 'OK'); $self->{mempool} = { mempool => scalar(@{$$result[2]->{result}}) / @{$result}[6]->{result} * 100 }; #TO CHECK division entière } From 0feb66d9c702630a4d9d48a13280208affd6aae8 Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Mon, 13 Apr 2020 15:41:39 +0000 Subject: [PATCH 247/283] default and configurable port support --- blockchain/parity/restapi/custom/api.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/blockchain/parity/restapi/custom/api.pm b/blockchain/parity/restapi/custom/api.pm index d792c57d8..a9e1866a5 100644 --- a/blockchain/parity/restapi/custom/api.pm +++ b/blockchain/parity/restapi/custom/api.pm @@ -41,7 +41,8 @@ sub new { if (!defined($options{noptions})) { $options{options}->add_options(arguments => { - "hostname:s" => { name => 'hostname' }, + "hostname:s" => { name => 'hostname' }, + "port:s" => { name => 'port' }, "timeout:s" => { name => 'timeout' }, "api-path:s" => { name => 'api_path' }, }); @@ -81,6 +82,7 @@ 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} : 8545; $self->{timeout} = (defined($self->{option_results}->{timeout})) ? $self->{option_results}->{timeout} : 10; $self->{api_path} = (defined($self->{option_results}->{api_path})) ? $self->{option_results}->{api_path} : '/'; @@ -102,7 +104,7 @@ sub build_options_for_httplib { $self->{option_results}->{hostname} = $self->{hostname}; $self->{option_results}->{timeout} = $self->{timeout}; - $self->{option_results}->{port} = 8545; + $self->{option_results}->{port} = $self->{port}; $self->{option_results}->{proto} = 'http'; } From 04619b99ce0d5b7e8d78e3d72f662888fd76d80e Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Tue, 14 Apr 2020 10:41:34 +0000 Subject: [PATCH 248/283] delete unnecessary print --- blockchain/parity/restapi/mode/eth.pm | 6 +++--- blockchain/parity/restapi/mode/parity.pm | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/blockchain/parity/restapi/mode/eth.pm b/blockchain/parity/restapi/mode/eth.pm index 90f5a0ae8..ac872603e 100644 --- a/blockchain/parity/restapi/mode/eth.pm +++ b/blockchain/parity/restapi/mode/eth.pm @@ -145,9 +145,9 @@ sub manage_selection { my $gas_price = hex(@{$result}[2]->{result}); my $res_block_time = @{$result}[5]->{result}->{timestamp} == 0 ? '': localtime(hex(@{$result}[5]->{result}->{timestamp})); - use Data::Dumper; - print Dumper($res_block_time) ; - print Dumper(@{$result}[5]->{result}->{timestamp}); + # use Data::Dumper; + # print Dumper($res_block_time) ; + # print Dumper(@{$result}[5]->{result}->{timestamp}); # conditional formating: my $res_sync = @{$result}[6]->{result} ? hex((@{$result}[6]->{result}->{currentBlock} / @{$result}[6]->{result}->{highestBlock})) * 100 : 100; diff --git a/blockchain/parity/restapi/mode/parity.pm b/blockchain/parity/restapi/mode/parity.pm index aad3fb67c..9da861cb1 100644 --- a/blockchain/parity/restapi/mode/parity.pm +++ b/blockchain/parity/restapi/mode/parity.pm @@ -89,7 +89,7 @@ sub manage_selection { my $result = $options{custom}->request_api(method => 'POST', query_form_post => $query_form_post); - use Data::Dumper; + # use Data::Dumper; # print Dumper($result); # Parity version construction From bce286b8ef6f8a52c7d75b99ce52d2aa7b35f107 Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Mon, 11 May 2020 15:50:37 +0000 Subject: [PATCH 249/283] Code to be completed --- blockchain/parity/ethpoller/mode/disk.pm | 135 +++++++++++ blockchain/parity/ethpoller/mode/stats.pm | 120 ++++++---- blockchain/parity/ethpoller/mode/tracking.pm | 221 +++++++++++++++++++ blockchain/parity/ethpoller/plugin.pm | 8 +- blockchain/parity/restapi/mode/eth.pm | 48 +++- blockchain/parity/restapi/mode/infos.pm | 121 ++++++++++ blockchain/parity/restapi/mode/net.pm | 2 +- blockchain/parity/restapi/mode/parity.pm | 65 +++++- blockchain/parity/restapi/plugin.pm | 3 +- 9 files changed, 666 insertions(+), 57 deletions(-) create mode 100644 blockchain/parity/ethpoller/mode/disk.pm create mode 100644 blockchain/parity/ethpoller/mode/tracking.pm create mode 100644 blockchain/parity/restapi/mode/infos.pm diff --git a/blockchain/parity/ethpoller/mode/disk.pm b/blockchain/parity/ethpoller/mode/disk.pm new file mode 100644 index 000000000..bd5158c28 --- /dev/null +++ b/blockchain/parity/ethpoller/mode/disk.pm @@ -0,0 +1,135 @@ +# +# Copyright 2020 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 blockchain::parity::ethpoller::mode::disk; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use bigint; +use Digest::MD5 qw(md5_hex); + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', cb_prefix_output => 'prefix_module_output', type => 0 }, + ]; + + $self->{maps_counters}->{global} = [ + { label => 'disk_free', nlabel => 'eth.poller.disk.free', set => { + key_values => [ { name => 'disk_free' } ], + output_template => "Disk free: %d ", + perfdatas => [ + { label => 'disk_free', value => 'disk_free_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'disk_available', nlabel => 'eth.poller.disk.free', set => { + key_values => [ { name => 'disk_available' } ], + output_template => "Disk available: %d ", + perfdatas => [ + { label => 'disk_available', value => 'disk_available_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'disk_size', nlabel => 'eth.poller.disk.size', set => { + key_values => [ { name => 'disk_size' } ], + output_template => "Disk size: %d ", + perfdatas => [ + { label => 'disk_size', value => 'disk_size_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'disk_used', nlabel => 'eth.poller.disk.used', set => { + key_values => [ { name => 'disk_used' } ], + output_template => "Disk used: %d ", + perfdatas => [ + { label => 'disk_used', value => 'disk_used_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'disk_usage', nlabel => 'eth.poller.disk.usage', set => { + key_values => [ { name => 'disk_usage' } ], + output_template => "Disk usage: %d %", + perfdatas => [ + { label => 'disk_usage', value => 'disk_usage_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'blockchain_dir', nlabel => 'eth.poller.blockchain.directory', set => { + key_values => [ { name => 'blockchain_dir' } ], + output_template => "Blockchain directory: %d", + perfdatas => [ + { label => 'blockchain_dir', value => 'blockchain_dir_absolute', template => '%d', min => 0 } + ], + } + } + ]; + +} + +sub prefix_output { + my ($self, %options) = @_; + + return "Disk '"; +} + +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' }, + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + my $result = $options{custom}->request_api(url_path => '/disk'); + + # use Data::Dumper; + # print Dumper($result); + + $self->{global} = { disk_free => $result->{free}, + disk_available => $result->{available}, + disk_size => $result->{size}, + disk_used => $result->{used}, + disk_usage => $result->{usage}, + blockchain_dir => $result->{dir} + }; + + $self->{output}->output_add(severity => 'OK', long_msg => 'Ledger: ' . $result->{dir} . ' (' . $result->{usage} . '%)'); +} + +1; + +__END__ + +=head1 MODE + +Check Parity eth-poller for disk monitoring + +=cut diff --git a/blockchain/parity/ethpoller/mode/stats.pm b/blockchain/parity/ethpoller/mode/stats.pm index e6cbe1451..10acb6bef 100644 --- a/blockchain/parity/ethpoller/mode/stats.pm +++ b/blockchain/parity/ethpoller/mode/stats.pm @@ -24,61 +24,61 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; +use bigint; use Digest::MD5 qw(md5_hex); sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ - { name => 'global', cb_prefix_output => 'prefix_module_output', type => 0 }, + { name => 'block', cb_prefix_output => 'prefix_output_block', type => 0 }, + { name => 'transaction', cb_prefix_output => 'prefix_output_transaction', type => 0 } ]; - $self->{maps_counters}->{global} = [ - { label => 'stats_blockInterval', nlabel => 'parity.stats.block.interval', set => { - key_values => [ { name => 'stats_blockInterval' } ], - output_template => "Block interval: %d ", + $self->{maps_counters}->{block} = [ + { label => 'block_freq', nlabel => 'parity.stats.block.frequency', set => { + key_values => [ { name => 'block_freq' } ], + output_template => "Block frequency: %d (block/min)", perfdatas => [ - { label => 'stats_blockInterval', value => 'stats_blockInterval_absolute', template => '%d', min => 0 } + { label => 'block_freq', value => 'block_freq_absolute', template => '%d', min => 0 } ], } - }, - { label => 'stats_contracts', nlabel => 'eth.poller.stats.contracts.number', set => { - key_values => [ { name => 'stats_contracts' } ], - output_template => "Cumulative contracts: %d ", - perfdatas => [ - { label => 'stats_contracts', value => 'stats_contracts_absolute', template => '%d', min => 0 } - ], - } - }, - { label => 'stats_blocks', nlabel => 'eth.poller.stats.blocks.number', set => { - key_values => [ { name => 'stats_blocks' } ], - output_template => "Cumulative blocks: %d ", - perfdatas => [ - { label => 'stats_blocks', value => 'stats_blocks_absolute', template => '%d', min => 0 } - ], - } - }, - { label => 'stats_transactions', nlabel => 'eth.poller.stats.transactions.number', set => { - key_values => [ { name => 'stats_transactions' } ], - output_template => "Cumulative transactions: %d ", - perfdatas => [ - { label => 'stats_transactions', value => 'stats_transactions_absolute', template => '%d', min => 0 } - ], - } - }, + } ]; + $self->{maps_counters}->{transaction} = [ + { label => 'transaction_freq', nlabel => 'parity.stats.transaction.frequency', set => { + key_values => [ { name => 'transaction_freq' } ], + output_template => "Transaction frequency: %d (tx/min)", + perfdatas => [ + { label => 'transaction_freq', value => 'transaction_freq_absolute', template => '%d', min => 0 } + ], + } + } + ]; } -sub prefix_output { +sub prefix_output_block { my ($self, %options) = @_; - return "Stats '"; + return "Block stats '"; +} + +sub prefix_output_fork { + my ($self, %options) = @_; + + return "Fork stats '"; +} + +sub prefix_output_transaction { + my ($self, %options) = @_; + + return "Transaction stats '"; } sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1, statefile => 1); bless $self, $class; $options{options}->add_options(arguments => { @@ -91,16 +91,52 @@ sub new { sub manage_selection { my ($self, %options) = @_; + $self->{cache_name} = "parity_ethpoller_" . $self->{mode} . '_' . (defined($self->{option_results}->{hostname}) ? $self->{option_results}->{hostname} : 'me') . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); + my $result = $options{custom}->request_api(url_path => '/stats'); - # use Data::Dumper; - # print Dumper($result); + my $old_block_timestamp = $self->{statefile_cache}->get(name => 'last_block_timestamp'); + my $old_block_count = $self->{statefile_cache}->get(name => 'last_block_count'); - $self->{global} = { stats_blockInterval => $result->{blockInterval}, - stats_contracts => $result->{cumulative}->{contracts}, - stats_blocks => $result->{cumulative}->{blocks}, - stats_transactions => $result->{cumulative}->{transactions} - }; + my $old_tx_timestamp = $self->{statefile_cache}->get(name => 'last_tx_timestamp'); + my $old_tx_count = $self->{statefile_cache}->get(name => 'last_tx_count'); + + my $datas = {}; + $datas->{last_block_timestamp} = time(); + $datas->{last_block_count} = $result->{block}->{count}; + + $datas->{last_tx_timestamp} = time(); + $datas->{last_tx_count} = $result->{block}->{count}; + + use Data::Dumper; + print Dumper($old_timestamp); + + my $res_timestamp = 0; + + if ($old_block_count && $old_block_timestamp) { + $res_timestamp = $result->{block}->{timestamp}) == 0 ? '' : $result->{block}->{timestamp})); + my $calculated_block_freq = ($result->{block}->{count} - $old_block_count) / (time() - $old_block_timestamp); + $self->{block} = { block_freq => $calculated_block_freq }; + $self->{output}->output_add(severity => 'OK', long_msg => 'Last block (#' . $result->{block}->{count} . ') was at ' . $res_timestamp); + } else { + $self->{output}->output_add(severity => 'OK', long_msg => 'Last block (#' . $result->{block}->{block} . ') was at ' . $res_timestamp . '. Block frequency is being calculated...'); + } + + if ($old_tx_count && $old_tx_timestamp) { + $res_timestamp = $result->{transaction}->{timestamp}) == 0 ? '' : $result->{transaction}->{timestamp})); + my $calculated_tx_freq = ($result->{transaction}->{count} - $old_tx_count) / (time() - $old_tx_timestamp); + $self->{transaction} = { transaction_freq => $calculated_tx_freq }; + $self->{output}->output_add(severity => 'OK', long_msg => 'Last transaction (#' . $result->{transaction}->{count} . ') was at ' . $res_timestamp); + } else { + $self->{output}->output_add(severity => 'OK', long_msg => 'Last transaction (#' . $result->{transaction}->{count} . ') was at ' . $res_timestamp . '. Transaction frequency is being calculated...'); + } + + if ($result->{fork}->{count} > 0) { + $self->{output}->output_add(severity => 'OK', long_msg => 'Last fork (#' . $result->{fork}->{count} . ') was at ' . $res_timestamp); + } else { + $self->{output}->output_add(severity => 'OK', long_msg => 'No fork occurence'); + } } 1; @@ -109,6 +145,6 @@ __END__ =head1 MODE -Check Parity eth-poller for accounts tracking +Check Parity eth-poller for stats =cut diff --git a/blockchain/parity/ethpoller/mode/tracking.pm b/blockchain/parity/ethpoller/mode/tracking.pm new file mode 100644 index 000000000..3fbb113dc --- /dev/null +++ b/blockchain/parity/ethpoller/mode/tracking.pm @@ -0,0 +1,221 @@ +# +# Copyright 2020 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 blockchain::parity::ethpoller::mode::tracking; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use bigint; +use Digest::MD5 qw(md5_hex); + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'events', cb_prefix_output => 'prefix_module_events', type => 1, message_multiple => 'All event metrics are ok' }, + { name => 'miners', cb_prefix_output => 'prefix_module_miners', type => 1, message_multiple => 'All miner metrics are ok' }, + { name => 'balances', cb_prefix_output => 'prefix_module_balances', type => 1, message_multiple => 'All balance metrics are ok' }, + ]; + + $self->{maps_counters}->{events} = [ + { label => 'event_frequency', nlabel => 'parity.tracking.event.frequency', set => { + key_values => [ { name => 'event_frequency' } ], + output_template => "Event's frequency: %d (evt/min)", + perfdatas => [ + { label => 'event_frequency', value => 'event_frequency_absolute', template => '%d', min => 0 } + ], + } + } + ]; + + $self->{maps_counters}->{miners} = [ + { label => 'mining_frequency', nlabel => 'parity.tracking.mining.frequency', set => { + key_values => [ { name => 'mining_frequency' } ], + output_template => "Mining frequency: %d (block/min)", + perfdatas => [ + { label => 'mining_frequency', value => 'mining_frequency_absolute', template => '%d', min => 0 } + ], + } + } + ]; + + $self->{maps_counters}->{balances} = [ + { label => 'balance_fluctuation', nlabel => 'parity.tracking.balances.fluctuation', set => { + key_values => [ { name => 'balance_fluctuation' } ], + output_template => "Balance fluctuation: %d (diff/min)", + perfdatas => [ + { label => 'balance_fluctuation', value => 'balance_fluctuation_absolute', template => '%d', min => 0 } + ], + } + } + ]; + +} + +sub prefix_output_events { + my ($self, %options) = @_; + + return "Event stats '"; +} + +sub prefix_output_miners { + my ($self, %options) = @_; + + return "Miner stats '"; +} + +sub prefix_output_balances { + my ($self, %options) = @_; + + return "Balance stats '"; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1, statefile => 1); + bless $self, $class; + + $options{options}->add_options(arguments => { + "filter-name:s" => { name => 'filter_name' }, + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + $self->{cache_name} = "parity_ethpoller_" . $self->{mode} . '_' . (defined($self->{option_results}->{hostname}) ? $self->{option_results}->{hostname} : 'me') . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); + + my $results = $options{custom}->request_api(url_path => '/tracking'); + + # use Data::Dumper; + # print Dumper($results); + + my $res_timestamp = 0; + my $calculated_frequency = 0; + + $self->{events} = {}; + $self->{miners} = {}; + $self->{balances} = {}; + + my $datas = {}; + + foreach my $event (@{$results->{events}}) { + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $event->{id} !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping '" . $event->{id} . "': no matching filter name.", debug => 1); + next; + } + + my $old_event_timestamp = $self->{statefile_cache}->get(name => 'last_event_timestamp'); #get the id last_event_timestamp + my $old_event_count = $self->{statefile_cache}->get(name => 'last_event_count'); #get the id last_event_count + + $datas->{$event->{id}}->{last_event_timestamp} = time(); + $datas->{$event->{id}}->{last_event_count} = $result->{block}->{count}; + + if ($old_event_count && $old_event_timestamp) { + $calculated_frequency = ($event->{count} - $old_event_count) / (time() - $old_event_timestamp); + + $self->{events}->{$event->{id}}->{display} = $event->{label}; + $self->{events}->{$event->{id}}->{event_frequency} = $calculated_frequency; + + $res_timestamp = $event->{timestamp} == 0 ? '': localtime($event->{timestamp}); + + if ($event->{count} > 0) { + $self->{output}->output_add(severity => 'OK', long_msg => 'Event ' . $event->{id} . ': Last Tx from "' . $event->{label} . '" (#' . $event->{count} . + ') was at ' . $res_timestamp . ' (block #' . $event->{block} . ')' ); + } else { + $self->{output}->output_add(severity => 'OK', long_msg => 'Event ' . $event->{id} . ': No Tx from "' . $event->{label} . '"'); + } + } else { + $self->{output}->output_add(severity => 'OK', long_msg => 'Event ' . $event->{id} . ': Building perfdata for "' . $event->{label} . '"...'); + } + } + + foreach my $miner (@{$results->{miners}}) { + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $miner->{id} !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping '" . $miner->{id} . "': no matching filter name.", debug => 1); + next; + } + + my $old_miner_timestamp = $self->{statefile_cache}->get(name => 'last_miner_timestamp'); #get the id last_miner_timestamp + my $old_miner_count = $self->{statefile_cache}->get(name => 'last_miner_count'); #get the id last_miner_count + + $datas->{$miner->{id}}->{last_miner_timestamp} = time(); + $datas->{$miner->{id}}->{last_miner_count} = $result->{block}->{count}; + + if ($old_miner_timestamp && $old_miner_timestamp) { + $calculated_frequency = ($miner->{count} - $old_miner_count) / (time() - $old_miner_timestamp); + + $self->{miners}->{$miner->{id}}->{display} = $miner->{label}; + $self->{miners}->{$miner->{id}}->{mining_frequency} = $calculated_frequency; + + $res_timestamp = $miner->{timestamp} == 0 ? '': localtime($miner->{timestamp}); + if ($miner->{count} > 0) { + $self->{output}->output_add(severity => 'OK', long_msg => 'Miner ' . $miner->{id} . ': Last block from label "' . $miner->{label} . '" (#' . $miner->{count} . + ') was at ' . $res_timestamp . ' (block #' . $miner->{block} . ')' ); + } else { + $self->{output}->output_add(severity => 'OK', long_msg => 'Miner ' . $miner->{id} . ': No validation from "' . $miner->{label} . '"'); + } + } else { + $self->{output}->output_add(severity => 'OK', long_msg => 'Miner ' . $miner->{id} . ': Building perfdata for "' . $miner->{label} . '"...'); + } + } + + foreach my $balance (@{$results->{balances}}) { + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $balance->{id} !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping '" . $balance->{id} . "': no matching filter name.", debug => 1); + next; + } + + my $old_balance = $self->{statefile_cache}->get(name => 'last_balance'); #get the id last_balance + + $datas->{$balance->{id}}->{last_balance} = $balance->{balance}; + + if ($old_balance) { + $calculated_diff = ($balance->{balance} - $old_balance) / ($old_balance); + + $self->{balances}->{$balance->{id}}->{display} = $balance->{label}; + $self->{balances}->{$balance->{id}}->{balance} = $calculated_diff; + + $self->{output}->output_add(severity => 'OK', long_msg => 'Balance ' . $balance->{id} . ': Balance of "' . $balance->{label} . '" is ' . $balance->{balance} . ' ether' ); + } else { + $self->{output}->output_add(severity => 'OK', long_msg => 'Balance ' . $balance->{id} . ': Balance fluctuation of "' . $balance->{label} . '" is being calculated...'); + } + } + + +} + +1; + +__END__ + +=head1 MODE + +Check Parity eth-poller for events, miners and balances tracking + +=cut diff --git a/blockchain/parity/ethpoller/plugin.pm b/blockchain/parity/ethpoller/plugin.pm index 77989acd3..48e08df5c 100644 --- a/blockchain/parity/ethpoller/plugin.pm +++ b/blockchain/parity/ethpoller/plugin.pm @@ -31,9 +31,11 @@ sub new { $self->{version} = '0.1'; %{$self->{modes}} = ( - 'watchlist' => 'blockchain::parity::ethpoller::mode::watchlist', - 'fork' => 'blockchain::parity::ethpoller::mode::fork', - 'stats' => 'blockchain::parity::ethpoller::mode::stats' + # 'watchlist' => 'blockchain::parity::ethpoller::mode::watchlist', + # 'fork' => 'blockchain::parity::ethpoller::mode::fork', + 'stats' => 'blockchain::parity::ethpoller::mode::stats', + 'disk' => 'blockchain::parity::ethpoller::mode::disk', + 'tracking' => 'blockchain::parity::ethpoller::mode::tracking' ); $self->{custom_modes}{api} = 'blockchain::parity::ethpoller::custom::api'; return $self; diff --git a/blockchain/parity/restapi/mode/eth.pm b/blockchain/parity/restapi/mode/eth.pm index ac872603e..08c7a8461 100644 --- a/blockchain/parity/restapi/mode/eth.pm +++ b/blockchain/parity/restapi/mode/eth.pm @@ -41,11 +41,23 @@ sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ - { name => 'global', cb_prefix_output => 'prefix_module_output', type => 0 }, + { name => 'gas', cb_prefix_output => 'prefix_module_output', type => 0 }, { name => 'block', cb_prefix_output => 'prefix_module_output', type => 0 }, + { name => 'sync', cb_prefix_output => 'prefix_module_output', type => 0 }, ]; - $self->{maps_counters}->{global} = [ + $self->{maps_counters}->{gas} = [ + { label => 'sync_status', nlabel => 'parity.eth.sync.status', set => { + key_values => [ { name => 'sync_status' } ], + output_template => "The gas price is: %d %% ", + perfdatas => [ + { label => 'sync_status', value => 'sync_status_absolute', template => '%d', min => 0 } + ], + } + } + ]; + + $self->{maps_counters}->{gas} = [ { label => 'gas_price', nlabel => 'parity.eth.gas.price', set => { key_values => [ { name => 'gas_price' } ], output_template => "The gas price is: %d wei ", @@ -53,6 +65,22 @@ sub set_counters { { label => 'gas_price', value => 'gas_price_absolute', template => '%d', min => 0 } ], } + }, + { label => 'gas_used', nlabel => 'parity.eth.gas.used', set => { + key_values => [ { name => 'gas_used' } ], + output_template => "The gas used is: %d", + perfdatas => [ + { label => 'gas_used', value => 'gas_used_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'gas_limit', nlabel => 'parity.eth.gas.limit', set => { + key_values => [ { name => 'gas_limit' } ], + output_template => "The gas limit is: %d", + perfdatas => [ + { label => 'gas_limit', value => 'gas_limit_absolute', template => '%d', min => 0 } + ], + } } ]; @@ -65,6 +93,14 @@ sub set_counters { ], } }, + { label => 'block_usage', nlabel => 'parity.eth.block.usage', set => { + key_values => [ { name => 'block_usage' } ], + output_template => "Block usage: %d %%", + perfdatas => [ + { label => 'block_usage', value => 'block_usage_absolute', template => '%d', min => 0 } + ], + } + }, { label => 'block_transactions', nlabel => 'parity.eth.block.transactions.number', set => { key_values => [ { name => 'block_transactions' } ], output_template => "Block transactions number: %d ", @@ -174,10 +210,16 @@ sub manage_selection { # $cache->set('gas_price', $gas_price); # } - $self->{global} = { gas_price => $gas_price }; + $self->{sync} = { sync_status => $res_sync }; + $self->{gas} = { gas_price => $gas_price, + gas_used => hex(@{$result}[5]->{result}->{gasLimit}), + gas_limit => hex(@{$result}[5]->{result}->{gasUsed}) }; + + my $calculated_block_usage = hex(@{$result}[5]->{result}->{gasUsed}) / hex(@{$result}[5]->{result}->{gasLimit}); $self->{block} = { block_size => hex(@{$result}[5]->{result}->{size}), block_gas => hex(@{$result}[5]->{result}->{gasUsed}), + block_usage => $calculated_block_usage, # block_difficulty => hex(@{$result}[5]->{result}->{totalDifficulty}), block_uncles => scalar(@{$$result[5]->{result}->{uncles}}), block_transactions => scalar(@{$$result[5]->{result}->{transactions}})}; diff --git a/blockchain/parity/restapi/mode/infos.pm b/blockchain/parity/restapi/mode/infos.pm new file mode 100644 index 000000000..c93eee5ab --- /dev/null +++ b/blockchain/parity/restapi/mode/infos.pm @@ -0,0 +1,121 @@ +# +# Copyright 2020 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 blockchain::parity::restapi::mode::infos; + +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 catalog_status_calc); + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1, statefile => 1); + bless $self, $class; + + $options{options}->add_options(arguments => { + 'unknown-status:s' => { name => 'unknown_status', default => '' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '%{listening} !~ /true/' }, + }); + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->change_macros(macros => ['unknown_status', 'warning_status', 'critical_status']); +} + +sub prefix_module_output { + my ($self, %options) = @_; + + return "Parity network module: "; +} + +sub manage_selection { + my ($self, %options) = @_; + + $self->{cache_name} = "parity_restapi_" . $self->{mode} . '_' . (defined($self->{option_results}->{hostname}) ? $self->{option_results}->{hostname} : 'me') . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); + + my $query_form_post = [ { method => 'parity_versionInfo', params => [], id => "1", jsonrpc => "2.0" }, + { method => 'parity_chain', params => [], id => "2", jsonrpc => "2.0" }, + { method => 'eth_mining', params => [], id => "3", jsonrpc => "2.0" }, + { method => 'parity_nodeName', params => [], id => "4", jsonrpc => "2.0" }, ]; + + my $result = $options{custom}->request_api(method => 'POST', query_form_post => $query_form_post); + + # use Data::Dumper; + # print Dumper($result); + + # Parity version construction + my $res_parity_version = @{$result}[0]->{result}->{version}->{major} . '.' . @{$result}[0]->{result}->{version}->{minor} . '.' . @{$result}[0]->{result}->{version}->{patch}; + + + # Alerts management + # my $cache = Cache::File->new( cache_root => './parity-restapi-cache' ); + + # if (my $cached_count = $cache->get('peers_count')) { + # if ($peer_count < $cached_count) { + # #alert + # } elsif ($peer_count > $cached_count) { + # #alert + # } + # } else { + # $cache->set('peers_count', $peer_count); + # } + + $self->{output}->output_add(long_msg => "Parity version: '" . $res_parity_version . "'. Chain name: '" . @{$result}[1]->{result} . + "'. Node name: '" . @{$result}[3]->{result} . "'. is_validator: '" . @{$result}[2]->{result} . "'.", severity => 'OK'); +} + +1; + +__END__ + +=head1 MODE + +Check parity network cross module metrics (parity_versionInfo, parity_chain, eth_mining, parity_nodeName) + +=over 8 + +=item B<--unknown-status> + +Set unknown threshold for listening status (Default: ''). + +=item B<--warning-status> + +Set warning threshold for listening status (Default: ''). + +=item B<--critical-status> + +Set critical threshold for listening status (Default: '%{listening} !~ /true/'). + +=item B<--warning-peers> B<--critical-peers> + +Warning and Critical threhsold on the number of peer + +=back + +=cut diff --git a/blockchain/parity/restapi/mode/net.pm b/blockchain/parity/restapi/mode/net.pm index 2ad2ca153..7bc65d3a8 100644 --- a/blockchain/parity/restapi/mode/net.pm +++ b/blockchain/parity/restapi/mode/net.pm @@ -109,7 +109,7 @@ sub manage_selection { $self->{network} = { peers => hex(@{$result}[1]->{result}) }; - $self->{output}->output_add(long_msg => "Node status: [is_listening: " . $peer_count . ']', severity => 'OK'); + $self->{output}->output_add(long_msg => "Node status: [is_listening: " . @{$result}[0]->{result} . ']', severity => 'OK'); } 1; diff --git a/blockchain/parity/restapi/mode/parity.pm b/blockchain/parity/restapi/mode/parity.pm index 9da861cb1..7e62fda50 100644 --- a/blockchain/parity/restapi/mode/parity.pm +++ b/blockchain/parity/restapi/mode/parity.pm @@ -31,15 +31,59 @@ sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ - { name => 'mempool', cb_prefix_output => 'prefix_module_output', type => 0 } + { name => 'mempool', cb_prefix_output => 'prefix_module_output', type => 0 }, + { name => 'peers', cb_prefix_output => 'prefix_module_output', type => 0 } ]; $self->{maps_counters}->{mempool} = [ - { label => 'mempool', nlabel => 'parity.mempol.usage', set => { - key_values => [ { name => 'mempool' } ], - output_template => "Mempool: %d %% ", + { label => 'tx_pending', nlabel => 'parity.pending.transactions', set => { + key_values => [ { name => 'tx_pending' } ], + output_template => "Pending transactions: %d", perfdatas => [ - { label => 'mempool', value => 'mempool_absolute', template => '%d', min => 0 } + { label => 'tx_pending', value => 'tx_pending_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'mempool_size', nlabel => 'parity.mempol.size', set => { + key_values => [ { name => 'mempool_size' } ], + output_template => "Mempool size: %d", + perfdatas => [ + { label => 'mempool_size', value => 'mempool_size_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'mempool_usage', nlabel => 'parity.mempol.usage', set => { + key_values => [ { name => 'mempool_usage' } ], + output_template => "Mempool usage: %d %% ", + perfdatas => [ + { label => 'mempool_usage', value => 'mempool_usage_absolute', template => '%d', min => 0 } + ], + } + }, + ]; + + $self->{maps_counters}->{peers} = [ + { label => 'peers_connected', nlabel => 'parity.peers.connected', set => { + key_values => [ { name => 'peers_connected' } ], + output_template => "Peers connected: %d", + perfdatas => [ + { label => 'peers_connected', value => 'peers_connected_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'peers_max', nlabel => 'parity.peers.max', set => { + key_values => [ { name => 'peers_max' } ], + output_template => "Peers max: %d", + perfdatas => [ + { label => 'peers_max', value => 'peers_max_absolute', template => '%d', min => 0 } + ], + } + }, + { label => 'peers_usage', nlabel => 'parity.peers.usage', set => { + key_values => [ { name => 'peers_usage' } ], + output_template => "Mempool usage: %d %% ", + perfdatas => [ + { label => 'peers_usage', value => 'peers_usage_absolute', template => '%d', min => 0 } ], } }, @@ -85,7 +129,8 @@ sub manage_selection { { method => 'parity_netPeers', params => [], id => "4", jsonrpc => "2.0" }, { method => 'parity_enode', params => [], id => "5", jsonrpc => "2.0" }, { method => 'parity_nodeName', params => [], id => "6", jsonrpc => "2.0" }, - { method => 'parity_transactionsLimit', params => [], id => "7", jsonrpc => "2.0" } ]; #TO CHECK parity_transactionsLimit could be done once, at the beginning of the process + { method => 'parity_transactionsLimit', params => [], id => "7", jsonrpc => "2.0" }, #TO CHECK parity_transactionsLimit could be done once, at the beginning of the process + { method => 'net_peerCount', params => [], id => "8", jsonrpc => "2.0" } ]; my $result = $options{custom}->request_api(method => 'POST', query_form_post => $query_form_post); @@ -124,7 +169,13 @@ sub manage_selection { $self->{output}->output_add(long_msg => "Node: [node_name: " . @{$result}[5]->{result} . "] [enode: " . @{$result}[4]->{result} . "]", severity => 'OK'); $self->{output}->output_add(long_msg => "Mempool: [pending_transactions: " . scalar(@{$$result[2]->{result}}) . "] [transactions_limit: " . @{$result}[6]->{result} . "]", severity => 'OK'); - $self->{mempool} = { mempool => scalar(@{$$result[2]->{result}}) / @{$result}[6]->{result} * 100 }; #TO CHECK division entière + $self->{mempool} = { mempool_usage => scalar(@{$$result[2]->{result}}) / @{$result}[6]->{result} * 100, #TO CHECK division entière + mempool_size => @{$result}[6]->{result}, + tx_pending => scalar(@{$$result[2]->{result}}) }; + + $self->{peers} = { peers_usage => @{$result}[3]->{result}->{connected} / @{$result}[3]->{result}->{max} * 100, #TO CHECK division entière + peers_max => @{$result}[3]->{result}->{max}, + peers_connected => @{$result}[3]->{result}->{connected} }; } 1; diff --git a/blockchain/parity/restapi/plugin.pm b/blockchain/parity/restapi/plugin.pm index 7cffb8686..b470c1666 100644 --- a/blockchain/parity/restapi/plugin.pm +++ b/blockchain/parity/restapi/plugin.pm @@ -33,7 +33,8 @@ sub new { %{$self->{modes}} = ( 'net' => 'blockchain::parity::restapi::mode::net', 'eth' => 'blockchain::parity::restapi::mode::eth', - 'parity' => 'blockchain::parity::restapi::mode::parity' + 'parity' => 'blockchain::parity::restapi::mode::parity', + 'infos' => 'blockchain::parity::restapi::mode::infos' ); $self->{custom_modes}{api} = 'blockchain::parity::restapi::custom::api'; return $self; From 18dbd5ed1482e1e745c34853da35d4df2c85b7c5 Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Mon, 11 May 2020 18:32:33 +0000 Subject: [PATCH 250/283] code to be completed 2/2 --- blockchain/parity/ethpoller/mode/disk.pm | 2 +- blockchain/parity/ethpoller/mode/stats.pm | 6 +++--- blockchain/parity/ethpoller/mode/tracking.pm | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/blockchain/parity/ethpoller/mode/disk.pm b/blockchain/parity/ethpoller/mode/disk.pm index bd5158c28..586d41da9 100644 --- a/blockchain/parity/ethpoller/mode/disk.pm +++ b/blockchain/parity/ethpoller/mode/disk.pm @@ -69,7 +69,7 @@ sub set_counters { }, { label => 'disk_usage', nlabel => 'eth.poller.disk.usage', set => { key_values => [ { name => 'disk_usage' } ], - output_template => "Disk usage: %d %", + output_template => "Disk usage: %d %%", perfdatas => [ { label => 'disk_usage', value => 'disk_usage_absolute', template => '%d', min => 0 } ], diff --git a/blockchain/parity/ethpoller/mode/stats.pm b/blockchain/parity/ethpoller/mode/stats.pm index 10acb6bef..e0cf28b7b 100644 --- a/blockchain/parity/ethpoller/mode/stats.pm +++ b/blockchain/parity/ethpoller/mode/stats.pm @@ -110,12 +110,12 @@ sub manage_selection { $datas->{last_tx_count} = $result->{block}->{count}; use Data::Dumper; - print Dumper($old_timestamp); + print Dumper($old_tx_timestamp); my $res_timestamp = 0; if ($old_block_count && $old_block_timestamp) { - $res_timestamp = $result->{block}->{timestamp}) == 0 ? '' : $result->{block}->{timestamp})); + $res_timestamp = $result->{block}->{timestamp} == 0 ? '' : $result->{block}->{timestamp}; my $calculated_block_freq = ($result->{block}->{count} - $old_block_count) / (time() - $old_block_timestamp); $self->{block} = { block_freq => $calculated_block_freq }; $self->{output}->output_add(severity => 'OK', long_msg => 'Last block (#' . $result->{block}->{count} . ') was at ' . $res_timestamp); @@ -124,7 +124,7 @@ sub manage_selection { } if ($old_tx_count && $old_tx_timestamp) { - $res_timestamp = $result->{transaction}->{timestamp}) == 0 ? '' : $result->{transaction}->{timestamp})); + $res_timestamp = $result->{transaction}->{timestamp} == 0 ? '' : $result->{transaction}->{timestamp}; my $calculated_tx_freq = ($result->{transaction}->{count} - $old_tx_count) / (time() - $old_tx_timestamp); $self->{transaction} = { transaction_freq => $calculated_tx_freq }; $self->{output}->output_add(severity => 'OK', long_msg => 'Last transaction (#' . $result->{transaction}->{count} . ') was at ' . $res_timestamp); diff --git a/blockchain/parity/ethpoller/mode/tracking.pm b/blockchain/parity/ethpoller/mode/tracking.pm index 3fbb113dc..49a927894 100644 --- a/blockchain/parity/ethpoller/mode/tracking.pm +++ b/blockchain/parity/ethpoller/mode/tracking.pm @@ -132,7 +132,7 @@ sub manage_selection { my $old_event_count = $self->{statefile_cache}->get(name => 'last_event_count'); #get the id last_event_count $datas->{$event->{id}}->{last_event_timestamp} = time(); - $datas->{$event->{id}}->{last_event_count} = $result->{block}->{count}; + $datas->{$event->{id}}->{last_event_count} = $event->{count}; if ($old_event_count && $old_event_timestamp) { $calculated_frequency = ($event->{count} - $old_event_count) / (time() - $old_event_timestamp); @@ -164,7 +164,7 @@ sub manage_selection { my $old_miner_count = $self->{statefile_cache}->get(name => 'last_miner_count'); #get the id last_miner_count $datas->{$miner->{id}}->{last_miner_timestamp} = time(); - $datas->{$miner->{id}}->{last_miner_count} = $result->{block}->{count}; + $datas->{$miner->{id}}->{last_miner_count} = $miner->{count}; if ($old_miner_timestamp && $old_miner_timestamp) { $calculated_frequency = ($miner->{count} - $old_miner_count) / (time() - $old_miner_timestamp); @@ -196,7 +196,7 @@ sub manage_selection { $datas->{$balance->{id}}->{last_balance} = $balance->{balance}; if ($old_balance) { - $calculated_diff = ($balance->{balance} - $old_balance) / ($old_balance); + my $calculated_diff = ($balance->{balance} - $old_balance) / ($old_balance); $self->{balances}->{$balance->{id}}->{display} = $balance->{label}; $self->{balances}->{$balance->{id}}->{balance} = $calculated_diff; From 045ac667d391bbe8b0667921b76775eb6cad45c6 Mon Sep 17 00:00:00 2001 From: Sims24 Date: Mon, 11 May 2020 22:32:12 +0200 Subject: [PATCH 251/283] enh(plugin)correct-cache-file-mgmt --- blockchain/parity/ethpoller/mode/tracking.pm | 122 +++++-------------- 1 file changed, 31 insertions(+), 91 deletions(-) diff --git a/blockchain/parity/ethpoller/mode/tracking.pm b/blockchain/parity/ethpoller/mode/tracking.pm index 49a927894..250383c55 100644 --- a/blockchain/parity/ethpoller/mode/tracking.pm +++ b/blockchain/parity/ethpoller/mode/tracking.pm @@ -31,40 +31,42 @@ sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ - { name => 'events', cb_prefix_output => 'prefix_module_events', type => 1, message_multiple => 'All event metrics are ok' }, - { name => 'miners', cb_prefix_output => 'prefix_module_miners', type => 1, message_multiple => 'All miner metrics are ok' }, - { name => 'balances', cb_prefix_output => 'prefix_module_balances', type => 1, message_multiple => 'All balance metrics are ok' }, + { name => 'events', cb_prefix_output => 'prefix_output_events', type => 1, message_multiple => 'Events metrics are ok' }, + { name => 'miners', cb_prefix_output => 'prefix_output_miners', type => 1, message_multiple => 'Miners metrics are ok' }, + { name => 'balances', cb_prefix_output => 'prefix_output_balances', type => 1, message_multiple => 'Balances metrics are ok' } ]; $self->{maps_counters}->{events} = [ - { label => 'event_frequency', nlabel => 'parity.tracking.event.frequency', set => { - key_values => [ { name => 'event_frequency' } ], - output_template => "Event's frequency: %d (evt/min)", - perfdatas => [ - { label => 'event_frequency', value => 'event_frequency_absolute', template => '%d', min => 0 } - ], + { label => 'event_frequency', nlabel => 'parity.tracking.event.persecond', set => { + key_values => [ { name => 'event_count', diff => 1 }, { name => 'display' } ], + per_second => 1, + output_template => " %.2f (events/s)", + perfdatas => [ + { label => 'events', template => '%.2f', value => 'event_count_per_second', + label_extra_instance => 1, instance_use => 'display_absolute' } + ], } } ]; $self->{maps_counters}->{miners} = [ - { label => 'mining_frequency', nlabel => 'parity.tracking.mining.frequency', set => { + { label => 'mining_frequency', nlabel => 'parity.tracking.mined.block.persecond', set => { key_values => [ { name => 'mining_frequency' } ], - output_template => "Mining frequency: %d (block/min)", - perfdatas => [ - { label => 'mining_frequency', value => 'mining_frequency_absolute', template => '%d', min => 0 } - ], + output_template => " %.2f (blocks/s)", + perfdatas => [ instance_use => 'display_absolute', label_extra_instance => 1 ], } } ]; $self->{maps_counters}->{balances} = [ - { label => 'balance_fluctuation', nlabel => 'parity.tracking.balances.fluctuation', set => { - key_values => [ { name => 'balance_fluctuation' } ], - output_template => "Balance fluctuation: %d (diff/min)", + { label => 'balance_fluctuation', nlabel => 'parity.tracking.balances.variation.persecond', set => { + key_values => [ { name => 'balance', diff => 1 } ], + per_second => 1, + output_template => " variation: %.2f (diff/sec)", perfdatas => [ - { label => 'balance_fluctuation', value => 'balance_fluctuation_absolute', template => '%d', min => 0 } - ], + { label => 'balances', template => '%.2f', value => 'balance_per_second', + label_extra_instance => 1, instance_use => 'display_absolute' } + ], } } ]; @@ -74,24 +76,24 @@ sub set_counters { sub prefix_output_events { my ($self, %options) = @_; - return "Event stats '"; + return "Event '" . $options{instance_value}->{display} . "' "; } sub prefix_output_miners { my ($self, %options) = @_; - return "Miner stats '"; + return "Miner '" . $options{instance_value}->{display} . "' ";; } sub prefix_output_balances { my ($self, %options) = @_; - return "Balance stats '"; + return "Balance '" . $options{instance_value}->{display} . "' "; } sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1, statefile => 1); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1, force_new_perfdata => 1); bless $self, $class; $options{options}->add_options(arguments => { @@ -109,48 +111,20 @@ sub manage_selection { my $results = $options{custom}->request_api(url_path => '/tracking'); - # use Data::Dumper; - # print Dumper($results); - - my $res_timestamp = 0; - my $calculated_frequency = 0; - $self->{events} = {}; $self->{miners} = {}; $self->{balances} = {}; - - my $datas = {}; foreach my $event (@{$results->{events}}) { if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && $event->{id} !~ /$self->{option_results}->{filter_name}/) { - $self->{output}->output_add(long_msg => "skipping '" . $event->{id} . "': no matching filter name.", debug => 1); + $self->{output}->output_add(long_msg => "skipping '" . $event->{label} . "': no matching filter name.", debug => 1); next; } - my $old_event_timestamp = $self->{statefile_cache}->get(name => 'last_event_timestamp'); #get the id last_event_timestamp - my $old_event_count = $self->{statefile_cache}->get(name => 'last_event_count'); #get the id last_event_count + $self->{events}->{lc($event->{label})} = { display => lc($event->{label}), + event_count => $event->{count} }; - $datas->{$event->{id}}->{last_event_timestamp} = time(); - $datas->{$event->{id}}->{last_event_count} = $event->{count}; - - if ($old_event_count && $old_event_timestamp) { - $calculated_frequency = ($event->{count} - $old_event_count) / (time() - $old_event_timestamp); - - $self->{events}->{$event->{id}}->{display} = $event->{label}; - $self->{events}->{$event->{id}}->{event_frequency} = $calculated_frequency; - - $res_timestamp = $event->{timestamp} == 0 ? '': localtime($event->{timestamp}); - - if ($event->{count} > 0) { - $self->{output}->output_add(severity => 'OK', long_msg => 'Event ' . $event->{id} . ': Last Tx from "' . $event->{label} . '" (#' . $event->{count} . - ') was at ' . $res_timestamp . ' (block #' . $event->{block} . ')' ); - } else { - $self->{output}->output_add(severity => 'OK', long_msg => 'Event ' . $event->{id} . ': No Tx from "' . $event->{label} . '"'); - } - } else { - $self->{output}->output_add(severity => 'OK', long_msg => 'Event ' . $event->{id} . ': Building perfdata for "' . $event->{label} . '"...'); - } } foreach my $miner (@{$results->{miners}}) { @@ -160,51 +134,17 @@ sub manage_selection { next; } - my $old_miner_timestamp = $self->{statefile_cache}->get(name => 'last_miner_timestamp'); #get the id last_miner_timestamp - my $old_miner_count = $self->{statefile_cache}->get(name => 'last_miner_count'); #get the id last_miner_count - - $datas->{$miner->{id}}->{last_miner_timestamp} = time(); - $datas->{$miner->{id}}->{last_miner_count} = $miner->{count}; - - if ($old_miner_timestamp && $old_miner_timestamp) { - $calculated_frequency = ($miner->{count} - $old_miner_count) / (time() - $old_miner_timestamp); - - $self->{miners}->{$miner->{id}}->{display} = $miner->{label}; - $self->{miners}->{$miner->{id}}->{mining_frequency} = $calculated_frequency; - - $res_timestamp = $miner->{timestamp} == 0 ? '': localtime($miner->{timestamp}); - if ($miner->{count} > 0) { - $self->{output}->output_add(severity => 'OK', long_msg => 'Miner ' . $miner->{id} . ': Last block from label "' . $miner->{label} . '" (#' . $miner->{count} . - ') was at ' . $res_timestamp . ' (block #' . $miner->{block} . ')' ); - } else { - $self->{output}->output_add(severity => 'OK', long_msg => 'Miner ' . $miner->{id} . ': No validation from "' . $miner->{label} . '"'); - } - } else { - $self->{output}->output_add(severity => 'OK', long_msg => 'Miner ' . $miner->{id} . ': Building perfdata for "' . $miner->{label} . '"...'); - } } foreach my $balance (@{$results->{balances}}) { if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && $balance->{id} !~ /$self->{option_results}->{filter_name}/) { - $self->{output}->output_add(long_msg => "skipping '" . $balance->{id} . "': no matching filter name.", debug => 1); + $self->{output}->output_add(long_msg => "skipping '" . $balance->{label} . "': no matching filter name.", debug => 1); next; } - my $old_balance = $self->{statefile_cache}->get(name => 'last_balance'); #get the id last_balance - - $datas->{$balance->{id}}->{last_balance} = $balance->{balance}; - - if ($old_balance) { - my $calculated_diff = ($balance->{balance} - $old_balance) / ($old_balance); - - $self->{balances}->{$balance->{id}}->{display} = $balance->{label}; - $self->{balances}->{$balance->{id}}->{balance} = $calculated_diff; - - $self->{output}->output_add(severity => 'OK', long_msg => 'Balance ' . $balance->{id} . ': Balance of "' . $balance->{label} . '" is ' . $balance->{balance} . ' ether' ); - } else { - $self->{output}->output_add(severity => 'OK', long_msg => 'Balance ' . $balance->{id} . ': Balance fluctuation of "' . $balance->{label} . '" is being calculated...'); - } + $self->{balances}->{lc($balance->{label})} = { display => lc($balance->{label}), + balance => $balance->{balance} }; } From a769bb453fa82347148ecf469ecd4d57330be7ac Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Tue, 12 May 2020 20:26:06 +0000 Subject: [PATCH 252/283] update frequency counters --- blockchain/parity/ethpoller/mode/stats.pm | 67 ++++++++------------ blockchain/parity/ethpoller/mode/tracking.pm | 11 +++- 2 files changed, 33 insertions(+), 45 deletions(-) diff --git a/blockchain/parity/ethpoller/mode/stats.pm b/blockchain/parity/ethpoller/mode/stats.pm index e0cf28b7b..a0c7f9687 100644 --- a/blockchain/parity/ethpoller/mode/stats.pm +++ b/blockchain/parity/ethpoller/mode/stats.pm @@ -36,22 +36,26 @@ sub set_counters { ]; $self->{maps_counters}->{block} = [ - { label => 'block_freq', nlabel => 'parity.stats.block.frequency', set => { - key_values => [ { name => 'block_freq' } ], - output_template => "Block frequency: %d (block/min)", + { label => 'block_frequency', nlabel => 'parity.stats.block.persecond', set => { + key_values => [ { name => 'block_count', diff => 1 }, { name => 'display' } ], + per_second => 1, + output_template => "Block frequency: %.2f (block/s)", perfdatas => [ - { label => 'block_freq', value => 'block_freq_absolute', template => '%d', min => 0 } + { label => 'block', value => 'block_count_per_second', template => ' %.2f', + label_extra_instance => 1, instance_use => 'display_absolute' } ], } } ]; $self->{maps_counters}->{transaction} = [ - { label => 'transaction_freq', nlabel => 'parity.stats.transaction.frequency', set => { - key_values => [ { name => 'transaction_freq' } ], - output_template => "Transaction frequency: %d (tx/min)", + { label => 'transaction_frequency', nlabel => 'parity.stats.transaction.persecond', set => { + key_values => [ { name => 'transaction_count', diff => 1 } ], + per_second => 1, + output_template => "Transaction frequency: %.2f (tx/s)", perfdatas => [ - { label => 'transaction_freq', value => 'transaction_freq_absolute', template => '%d', min => 0 } + { label => 'transaction', value => 'transaction_count_per_second', template => '%.2f', + label_extra_instance => 1, instance_use => 'display_absolute' } ], } } @@ -96,46 +100,25 @@ sub manage_selection { my $result = $options{custom}->request_api(url_path => '/stats'); - my $old_block_timestamp = $self->{statefile_cache}->get(name => 'last_block_timestamp'); - my $old_block_count = $self->{statefile_cache}->get(name => 'last_block_count'); + $self->{block} = { block_count => $result->{block}->{count} }; - my $old_tx_timestamp = $self->{statefile_cache}->get(name => 'last_tx_timestamp'); - my $old_tx_count = $self->{statefile_cache}->get(name => 'last_tx_count'); + $self->{transaction} = { transaction_count => $result->{transaction}->{count} }; - my $datas = {}; - $datas->{last_block_timestamp} = time(); - $datas->{last_block_count} = $result->{block}->{count}; + my $block_timestamp = $result->{block}->{timestamp} == 0 ? '' : localtime($result->{block}->{timestamp}); + $self->{output}->output_add(severity => 'OK', long_msg => 'Last block (#' . $result->{block}->{count} . ') was at ' . $block_timestamp); - $datas->{last_tx_timestamp} = time(); - $datas->{last_tx_count} = $result->{block}->{count}; - - use Data::Dumper; - print Dumper($old_tx_timestamp); - - my $res_timestamp = 0; - - if ($old_block_count && $old_block_timestamp) { - $res_timestamp = $result->{block}->{timestamp} == 0 ? '' : $result->{block}->{timestamp}; - my $calculated_block_freq = ($result->{block}->{count} - $old_block_count) / (time() - $old_block_timestamp); - $self->{block} = { block_freq => $calculated_block_freq }; - $self->{output}->output_add(severity => 'OK', long_msg => 'Last block (#' . $result->{block}->{count} . ') was at ' . $res_timestamp); + if ($result->{transaction}->{count} > 0) { + my $tx_timestamp = $result->{transaction}->{timestamp} == 0 ? '' : localtime($result->{transaction}->{timestamp}); + $self->{output}->output_add(severity => 'OK', long_msg => 'Last transaction (#' . $result->{transaction}->{count} . ') was at ' . $tx_timestamp); } else { - $self->{output}->output_add(severity => 'OK', long_msg => 'Last block (#' . $result->{block}->{block} . ') was at ' . $res_timestamp . '. Block frequency is being calculated...'); + $self->{output}->output_add(severity => 'OK', long_msg => 'No transaction...'); } - - if ($old_tx_count && $old_tx_timestamp) { - $res_timestamp = $result->{transaction}->{timestamp} == 0 ? '' : $result->{transaction}->{timestamp}; - my $calculated_tx_freq = ($result->{transaction}->{count} - $old_tx_count) / (time() - $old_tx_timestamp); - $self->{transaction} = { transaction_freq => $calculated_tx_freq }; - $self->{output}->output_add(severity => 'OK', long_msg => 'Last transaction (#' . $result->{transaction}->{count} . ') was at ' . $res_timestamp); + + if ($result->{transaction}->{count} > 0) { + my $fork_timestamp = $result->{fork}->{timestamp} == 0 ? '' : localtime($result->{fork}->{timestamp}); + $self->{output}->output_add(severity => 'OK', long_msg => 'Last fork (#' . $result->{fork}->{count} . ') was at ' . $fork_timestamp); } else { - $self->{output}->output_add(severity => 'OK', long_msg => 'Last transaction (#' . $result->{transaction}->{count} . ') was at ' . $res_timestamp . '. Transaction frequency is being calculated...'); - } - - if ($result->{fork}->{count} > 0) { - $self->{output}->output_add(severity => 'OK', long_msg => 'Last fork (#' . $result->{fork}->{count} . ') was at ' . $res_timestamp); - } else { - $self->{output}->output_add(severity => 'OK', long_msg => 'No fork occurence'); + $self->{output}->output_add(severity => 'OK', long_msg => 'No fork occurence...'); } } diff --git a/blockchain/parity/ethpoller/mode/tracking.pm b/blockchain/parity/ethpoller/mode/tracking.pm index 250383c55..e41d6d726 100644 --- a/blockchain/parity/ethpoller/mode/tracking.pm +++ b/blockchain/parity/ethpoller/mode/tracking.pm @@ -51,9 +51,11 @@ sub set_counters { $self->{maps_counters}->{miners} = [ { label => 'mining_frequency', nlabel => 'parity.tracking.mined.block.persecond', set => { - key_values => [ { name => 'mining_frequency' } ], + key_values => [ { name => 'mining_count', diff => 1 }, { name => 'display' } ], + per_second => 1, output_template => " %.2f (blocks/s)", - perfdatas => [ instance_use => 'display_absolute', label_extra_instance => 1 ], + perfdatas => [ { label => 'miners', template => '%.2f', value => 'mining_count_per_second', + label_extra_instance => 1, instance_use => 'display_absolute' } ], } } ]; @@ -130,10 +132,13 @@ sub manage_selection { foreach my $miner (@{$results->{miners}}) { if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && $miner->{id} !~ /$self->{option_results}->{filter_name}/) { - $self->{output}->output_add(long_msg => "skipping '" . $miner->{id} . "': no matching filter name.", debug => 1); + $self->{output}->output_add(long_msg => "skipping '" . $miner->{label} . "': no matching filter name.", debug => 1); next; } + $self->{miners}->{lc($miner->{label})} = { display => lc($miner->{label}), + mining_count => $miner->{count} }; + } foreach my $balance (@{$results->{balances}}) { From 6d0b3ef31e23928795da13446338a38379732e8b Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Wed, 13 May 2020 11:13:46 +0000 Subject: [PATCH 253/283] POC prct --- blockchain/parity/ethpoller/mode/prct.pm | 129 +++++++++++++++++++++++ blockchain/parity/ethpoller/plugin.pm | 3 +- 2 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 blockchain/parity/ethpoller/mode/prct.pm diff --git a/blockchain/parity/ethpoller/mode/prct.pm b/blockchain/parity/ethpoller/mode/prct.pm new file mode 100644 index 000000000..633c13b35 --- /dev/null +++ b/blockchain/parity/ethpoller/mode/prct.pm @@ -0,0 +1,129 @@ +# +# Copyright 2020 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 blockchain::parity::ethpoller::mode::prct; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use bigint; +use Digest::MD5 qw(md5_hex); + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'balances', cb_prefix_output => 'prefix_output_balances', type => 1, message_multiple => 'Balances metrics are ok' } + ]; + + $self->{maps_counters}->{balances} = [ + { label => 'balance-fluctuation-prct', nlabel => 'parity.tracking.balances.variation.persecond', display_ok => 0, set => { + key_values => [], + manual_keys => 1, + closure_custom_calc => $self->can('custom_loss_calc'), + closure_custom_output => $self->can('custom_loss_output'), + threshold_use => 'balance_fluctuation', + perfdatas => [ + { value => 'balance_fluctuation', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'display' }, + ], + } + } + ]; + +} + +sub custom_loss_output { + my ($self, %options) = @_; + + # use Data::Dumper; + # print Dumper('$total_balance'); + return sprintf( + "balance variation: %.2f%% ", + $self->{result_values}->{balance_fluctuation} + ); +} + +sub custom_loss_calc { + my ($self, %options) = @_; + + my $new_balance = $options{new_datas}->{$_}; + my $old_balance = $options{old_datas}->{$_}; + + # use Data::Dumper; + # print Dumper($total_balance); + + $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; + $self->{result_values}->{balance_fluctuation} = 0; + if ($old_balance > 0) { + $self->{result_values}->{balance_fluctuation} = ($new_balance - $old_balance) / $old_balance; + } + + +} + +sub prefix_output_balances { + my ($self, %options) = @_; + + return "Balance '" . $options{instance_value}->{display} . "' "; +} + +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 => { + "filter-name:s" => { name => 'filter_name' }, + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + $self->{cache_name} = "parity_ethpoller_" . $self->{mode} . '_' . (defined($self->{option_results}->{hostname}) ? $self->{option_results}->{hostname} : 'me') . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); + + my $result = $options{custom}->request_api(url_path => '/tracking'); + use Data::Dumper; + # print Dumper($result); + + foreach my $balance (@{$result->{balances}}) { + # print Dumper($balance); + $self->{balances}->{$balance->{label}} = { display => $balance->{label} }; + $self->{balances}->{$balance->{label}}->{'balance_fluctuation'} = $balance->{balance}; + } + +} + + + +1; + +__END__ + +=head1 MODE + +Check Parity eth-poller for events, miners and balances tracking + +=cut diff --git a/blockchain/parity/ethpoller/plugin.pm b/blockchain/parity/ethpoller/plugin.pm index 48e08df5c..d28ab211d 100644 --- a/blockchain/parity/ethpoller/plugin.pm +++ b/blockchain/parity/ethpoller/plugin.pm @@ -35,7 +35,8 @@ sub new { # 'fork' => 'blockchain::parity::ethpoller::mode::fork', 'stats' => 'blockchain::parity::ethpoller::mode::stats', 'disk' => 'blockchain::parity::ethpoller::mode::disk', - 'tracking' => 'blockchain::parity::ethpoller::mode::tracking' + 'tracking' => 'blockchain::parity::ethpoller::mode::tracking', + 'prct' => 'blockchain::parity::ethpoller::mode::prct' ); $self->{custom_modes}{api} = 'blockchain::parity::ethpoller::custom::api'; return $self; From 4eb67c696af4cca97990c5d6859fe437e0fc2ded Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Thu, 14 May 2020 05:40:48 +0000 Subject: [PATCH 254/283] prct improvments --- blockchain/parity/ethpoller/mode/prct.pm | 48 +++++++++++++++++------- 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/blockchain/parity/ethpoller/mode/prct.pm b/blockchain/parity/ethpoller/mode/prct.pm index 633c13b35..205feff6a 100644 --- a/blockchain/parity/ethpoller/mode/prct.pm +++ b/blockchain/parity/ethpoller/mode/prct.pm @@ -35,42 +35,62 @@ sub set_counters { ]; $self->{maps_counters}->{balances} = [ - { label => 'balance-fluctuation-prct', nlabel => 'parity.tracking.balances.variation.persecond', display_ok => 0, set => { + { label => 'balance-fluctuation-prct', nlabel => 'parity.tracking.balances.fluctuation', display_ok => 0, set => { key_values => [], manual_keys => 1, - closure_custom_calc => $self->can('custom_loss_calc'), - closure_custom_output => $self->can('custom_loss_output'), + closure_custom_calc => $self->can('custom_prct_calc'), + closure_custom_output => $self->can('custom_prct_output'), threshold_use => 'balance_fluctuation', perfdatas => [ - { value => 'balance_fluctuation', template => '%d', + { value => 'balance_fluctuation', template => '%.2f', min => 0, label_extra_instance => 1, instance_use => 'display' }, ], } + }, + { label => 'balance', nlabel => 'parity.tracking.balance', set => { + key_values => [ { name => 'balance' } ], + output_template => "%d (wei)", + perfdatas => [ + { label => 'balance', template => '%d', value => 'balance_absolute' } + ], + } } ]; } -sub custom_loss_output { +sub custom_prct_output { my ($self, %options) = @_; # use Data::Dumper; # print Dumper('$total_balance'); return sprintf( - "balance variation: %.2f%% ", + "balance variation: %.2f ", $self->{result_values}->{balance_fluctuation} ); } -sub custom_loss_calc { +sub custom_prct_calc { + use Data::Dumper; + my ($self, %options) = @_; - my $new_balance = $options{new_datas}->{$_}; - my $old_balance = $options{old_datas}->{$_}; + my ($old_balance, $new_balance) = (0, 0); + foreach (keys %{$options{new_datas}}) { + # print Dumper($self->{instance}); + # print Dumper($options{new_datas}); + # print Dumper($options{new_datas}->{$_}); + if (/\Q$self->{instance}\E_.*_balance/) { + # print Dumper($self->{instance}); + $new_balance = $options{new_datas}->{$_}; + $old_balance = $options{old_datas}->{$_}; + # print Dumper($old_balance); + # print Dumper($new_balance); + } + } + + - # use Data::Dumper; - # print Dumper($total_balance); - $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; $self->{result_values}->{balance_fluctuation} = 0; if ($old_balance > 0) { @@ -83,7 +103,7 @@ sub custom_loss_calc { sub prefix_output_balances { my ($self, %options) = @_; - return "Balance '" . $options{instance_value}->{display} . "' "; + return "Balance '" . $options{instance_value}->{display} . "': "; } sub new { @@ -111,7 +131,7 @@ sub manage_selection { foreach my $balance (@{$result->{balances}}) { # print Dumper($balance); $self->{balances}->{$balance->{label}} = { display => $balance->{label} }; - $self->{balances}->{$balance->{label}}->{'balance_fluctuation'} = $balance->{balance}; + $self->{balances}->{$balance->{label}}->{'balance'} = $balance->{balance}; } } From 519bc794948eb445356a674265bcf29445759841 Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Thu, 14 May 2020 14:06:40 +0000 Subject: [PATCH 255/283] typos in eth correction --- blockchain/parity/restapi/mode/eth.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/blockchain/parity/restapi/mode/eth.pm b/blockchain/parity/restapi/mode/eth.pm index 08c7a8461..edb5e571b 100644 --- a/blockchain/parity/restapi/mode/eth.pm +++ b/blockchain/parity/restapi/mode/eth.pm @@ -46,10 +46,10 @@ sub set_counters { { name => 'sync', cb_prefix_output => 'prefix_module_output', type => 0 }, ]; - $self->{maps_counters}->{gas} = [ + $self->{maps_counters}->{sync} = [ { label => 'sync_status', nlabel => 'parity.eth.sync.status', set => { key_values => [ { name => 'sync_status' } ], - output_template => "The gas price is: %d %% ", + output_template => "Syncing: %d %% ", perfdatas => [ { label => 'sync_status', value => 'sync_status_absolute', template => '%d', min => 0 } ], @@ -213,8 +213,8 @@ sub manage_selection { $self->{sync} = { sync_status => $res_sync }; $self->{gas} = { gas_price => $gas_price, - gas_used => hex(@{$result}[5]->{result}->{gasLimit}), - gas_limit => hex(@{$result}[5]->{result}->{gasUsed}) }; + gas_used => hex(@{$result}[5]->{result}->{gasUsed}), + gas_limit => hex(@{$result}[5]->{result}->{gasLimit}) }; my $calculated_block_usage = hex(@{$result}[5]->{result}->{gasUsed}) / hex(@{$result}[5]->{result}->{gasLimit}); $self->{block} = { block_size => hex(@{$result}[5]->{result}->{size}), From f03d1a7da008302a869e39dfd5660a849448e929 Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Thu, 14 May 2020 16:06:15 +0000 Subject: [PATCH 256/283] stats typos correction --- blockchain/parity/ethpoller/mode/stats.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blockchain/parity/ethpoller/mode/stats.pm b/blockchain/parity/ethpoller/mode/stats.pm index a0c7f9687..3431c9839 100644 --- a/blockchain/parity/ethpoller/mode/stats.pm +++ b/blockchain/parity/ethpoller/mode/stats.pm @@ -37,7 +37,7 @@ sub set_counters { $self->{maps_counters}->{block} = [ { label => 'block_frequency', nlabel => 'parity.stats.block.persecond', set => { - key_values => [ { name => 'block_count', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'block_count', diff => 1 } ], per_second => 1, output_template => "Block frequency: %.2f (block/s)", perfdatas => [ From 0a08b15805b16e4688e8d9a5c3f540ec76dad85e Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Mon, 18 May 2020 21:25:03 +0000 Subject: [PATCH 257/283] typos correction --- blockchain/parity/ethpoller/mode/disk.pm | 2 +- blockchain/parity/ethpoller/mode/stats.pm | 6 ++-- blockchain/parity/ethpoller/mode/tracking.pm | 32 ++++++++++---------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/blockchain/parity/ethpoller/mode/disk.pm b/blockchain/parity/ethpoller/mode/disk.pm index 586d41da9..cd06b13ba 100644 --- a/blockchain/parity/ethpoller/mode/disk.pm +++ b/blockchain/parity/ethpoller/mode/disk.pm @@ -43,7 +43,7 @@ sub set_counters { ], } }, - { label => 'disk_available', nlabel => 'eth.poller.disk.free', set => { + { label => 'disk_available', nlabel => 'eth.poller.disk.available', set => { key_values => [ { name => 'disk_available' } ], output_template => "Disk available: %d ", perfdatas => [ diff --git a/blockchain/parity/ethpoller/mode/stats.pm b/blockchain/parity/ethpoller/mode/stats.pm index 3431c9839..72fe40df8 100644 --- a/blockchain/parity/ethpoller/mode/stats.pm +++ b/blockchain/parity/ethpoller/mode/stats.pm @@ -105,18 +105,18 @@ sub manage_selection { $self->{transaction} = { transaction_count => $result->{transaction}->{count} }; my $block_timestamp = $result->{block}->{timestamp} == 0 ? '' : localtime($result->{block}->{timestamp}); - $self->{output}->output_add(severity => 'OK', long_msg => 'Last block (#' . $result->{block}->{count} . ') was at ' . $block_timestamp); + $self->{output}->output_add(severity => 'OK', long_msg => 'Last block (#' . $result->{block}->{count} . ') was on ' . $block_timestamp); if ($result->{transaction}->{count} > 0) { my $tx_timestamp = $result->{transaction}->{timestamp} == 0 ? '' : localtime($result->{transaction}->{timestamp}); - $self->{output}->output_add(severity => 'OK', long_msg => 'Last transaction (#' . $result->{transaction}->{count} . ') was at ' . $tx_timestamp); + $self->{output}->output_add(severity => 'OK', long_msg => 'Last transaction (#' . $result->{transaction}->{count} . ') was on ' . $tx_timestamp); } else { $self->{output}->output_add(severity => 'OK', long_msg => 'No transaction...'); } if ($result->{transaction}->{count} > 0) { my $fork_timestamp = $result->{fork}->{timestamp} == 0 ? '' : localtime($result->{fork}->{timestamp}); - $self->{output}->output_add(severity => 'OK', long_msg => 'Last fork (#' . $result->{fork}->{count} . ') was at ' . $fork_timestamp); + $self->{output}->output_add(severity => 'OK', long_msg => 'Last fork (#' . $result->{fork}->{count} . ') was on ' . $fork_timestamp); } else { $self->{output}->output_add(severity => 'OK', long_msg => 'No fork occurence...'); } diff --git a/blockchain/parity/ethpoller/mode/tracking.pm b/blockchain/parity/ethpoller/mode/tracking.pm index e41d6d726..4badb37de 100644 --- a/blockchain/parity/ethpoller/mode/tracking.pm +++ b/blockchain/parity/ethpoller/mode/tracking.pm @@ -32,36 +32,36 @@ sub set_counters { $self->{maps_counters_type} = [ { name => 'events', cb_prefix_output => 'prefix_output_events', type => 1, message_multiple => 'Events metrics are ok' }, - { name => 'miners', cb_prefix_output => 'prefix_output_miners', type => 1, message_multiple => 'Miners metrics are ok' }, - { name => 'balances', cb_prefix_output => 'prefix_output_balances', type => 1, message_multiple => 'Balances metrics are ok' } + { name => 'mining', cb_prefix_output => 'prefix_output_mining', type => 1, message_multiple => 'Mining metrics are ok' }, + { name => 'balance', cb_prefix_output => 'prefix_output_balance', type => 1, message_multiple => 'Balances metrics are ok' } ]; $self->{maps_counters}->{events} = [ - { label => 'event_frequency', nlabel => 'parity.tracking.event.persecond', set => { - key_values => [ { name => 'event_count', diff => 1 }, { name => 'display' } ], + { label => 'events_frequency', nlabel => 'parity.tracking.events.persecond', set => { + key_values => [ { name => 'events_count', diff => 1 }, { name => 'display' } ], per_second => 1, output_template => " %.2f (events/s)", perfdatas => [ - { label => 'events', template => '%.2f', value => 'event_count_per_second', + { label => 'events', template => '%.2f', value => 'events_count_per_second', label_extra_instance => 1, instance_use => 'display_absolute' } ], } } ]; - $self->{maps_counters}->{miners} = [ + $self->{maps_counters}->{mining} = [ { label => 'mining_frequency', nlabel => 'parity.tracking.mined.block.persecond', set => { key_values => [ { name => 'mining_count', diff => 1 }, { name => 'display' } ], per_second => 1, output_template => " %.2f (blocks/s)", - perfdatas => [ { label => 'miners', template => '%.2f', value => 'mining_count_per_second', + perfdatas => [ { label => 'mining', template => '%.2f', value => 'mining_count_per_second', label_extra_instance => 1, instance_use => 'display_absolute' } ], } } ]; - $self->{maps_counters}->{balances} = [ - { label => 'balance_fluctuation', nlabel => 'parity.tracking.balances.variation.persecond', set => { + $self->{maps_counters}->{balance} = [ + { label => 'balance_fluctuation', nlabel => 'parity.tracking.balance.variation.persecond', set => { key_values => [ { name => 'balance', diff => 1 } ], per_second => 1, output_template => " variation: %.2f (diff/sec)", @@ -81,13 +81,13 @@ sub prefix_output_events { return "Event '" . $options{instance_value}->{display} . "' "; } -sub prefix_output_miners { +sub prefix_output_mining { my ($self, %options) = @_; return "Miner '" . $options{instance_value}->{display} . "' ";; } -sub prefix_output_balances { +sub prefix_output_balance { my ($self, %options) = @_; return "Balance '" . $options{instance_value}->{display} . "' "; @@ -114,8 +114,8 @@ sub manage_selection { my $results = $options{custom}->request_api(url_path => '/tracking'); $self->{events} = {}; - $self->{miners} = {}; - $self->{balances} = {}; + $self->{mining} = {}; + $self->{balance} = {}; foreach my $event (@{$results->{events}}) { if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && @@ -125,7 +125,7 @@ sub manage_selection { } $self->{events}->{lc($event->{label})} = { display => lc($event->{label}), - event_count => $event->{count} }; + events_count => $event->{count} }; } @@ -136,7 +136,7 @@ sub manage_selection { next; } - $self->{miners}->{lc($miner->{label})} = { display => lc($miner->{label}), + $self->{mining}->{lc($miner->{label})} = { display => lc($miner->{label}), mining_count => $miner->{count} }; } @@ -148,7 +148,7 @@ sub manage_selection { next; } - $self->{balances}->{lc($balance->{label})} = { display => lc($balance->{label}), + $self->{balance}->{lc($balance->{label})} = { display => lc($balance->{label}), balance => $balance->{balance} }; } From 9e0248619e0c1b3c079d1799a79526144e9326ae Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Wed, 20 May 2020 09:14:58 +0000 Subject: [PATCH 258/283] change counter variation per_minute --- blockchain/parity/ethpoller/mode/stats.pm | 16 ++++++------- blockchain/parity/ethpoller/mode/tracking.pm | 24 ++++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/blockchain/parity/ethpoller/mode/stats.pm b/blockchain/parity/ethpoller/mode/stats.pm index 72fe40df8..dab08346b 100644 --- a/blockchain/parity/ethpoller/mode/stats.pm +++ b/blockchain/parity/ethpoller/mode/stats.pm @@ -36,12 +36,12 @@ sub set_counters { ]; $self->{maps_counters}->{block} = [ - { label => 'block_frequency', nlabel => 'parity.stats.block.persecond', set => { + { label => 'block_frequency', nlabel => 'parity.stats.block.perminute', set => { key_values => [ { name => 'block_count', diff => 1 } ], - per_second => 1, - output_template => "Block frequency: %.2f (block/s)", + per_minute => 1, + output_template => "Block frequency: %.2f (block/min)", perfdatas => [ - { label => 'block', value => 'block_count_per_second', template => ' %.2f', + { label => 'block', value => 'block_count_per_minute', template => ' %.2f', label_extra_instance => 1, instance_use => 'display_absolute' } ], } @@ -49,12 +49,12 @@ sub set_counters { ]; $self->{maps_counters}->{transaction} = [ - { label => 'transaction_frequency', nlabel => 'parity.stats.transaction.persecond', set => { + { label => 'transaction_frequency', nlabel => 'parity.stats.transaction.perminute', set => { key_values => [ { name => 'transaction_count', diff => 1 } ], - per_second => 1, - output_template => "Transaction frequency: %.2f (tx/s)", + per_minute => 1, + output_template => "Transaction frequency: %.2f (tx/min)", perfdatas => [ - { label => 'transaction', value => 'transaction_count_per_second', template => '%.2f', + { label => 'transaction', value => 'transaction_count_per_minute', template => '%.2f', label_extra_instance => 1, instance_use => 'display_absolute' } ], } diff --git a/blockchain/parity/ethpoller/mode/tracking.pm b/blockchain/parity/ethpoller/mode/tracking.pm index 4badb37de..001e33c42 100644 --- a/blockchain/parity/ethpoller/mode/tracking.pm +++ b/blockchain/parity/ethpoller/mode/tracking.pm @@ -37,12 +37,12 @@ sub set_counters { ]; $self->{maps_counters}->{events} = [ - { label => 'events_frequency', nlabel => 'parity.tracking.events.persecond', set => { + { label => 'events_frequency', nlabel => 'parity.tracking.events.perminute', set => { key_values => [ { name => 'events_count', diff => 1 }, { name => 'display' } ], - per_second => 1, - output_template => " %.2f (events/s)", + per_minute => 1, + output_template => " %.2f (events/min)", perfdatas => [ - { label => 'events', template => '%.2f', value => 'events_count_per_second', + { label => 'events', template => '%.2f', value => 'events_count_per_minute', label_extra_instance => 1, instance_use => 'display_absolute' } ], } @@ -50,23 +50,23 @@ sub set_counters { ]; $self->{maps_counters}->{mining} = [ - { label => 'mining_frequency', nlabel => 'parity.tracking.mined.block.persecond', set => { + { label => 'mining_frequency', nlabel => 'parity.tracking.mined.block.perminute', set => { key_values => [ { name => 'mining_count', diff => 1 }, { name => 'display' } ], - per_second => 1, - output_template => " %.2f (blocks/s)", - perfdatas => [ { label => 'mining', template => '%.2f', value => 'mining_count_per_second', + per_minute => 1, + output_template => " %.2f (blocks/min)", + perfdatas => [ { label => 'mining', template => '%.2f', value => 'mining_count_per_minute', label_extra_instance => 1, instance_use => 'display_absolute' } ], } } ]; $self->{maps_counters}->{balance} = [ - { label => 'balance_fluctuation', nlabel => 'parity.tracking.balance.variation.persecond', set => { + { label => 'balance_fluctuation', nlabel => 'parity.tracking.balance.variation.perminute', set => { key_values => [ { name => 'balance', diff => 1 } ], - per_second => 1, - output_template => " variation: %.2f (diff/sec)", + per_minute => 1, + output_template => " variation: %.2f (diff/min)", perfdatas => [ - { label => 'balances', template => '%.2f', value => 'balance_per_second', + { label => 'balances', template => '%.2f', value => 'balance_per_minute', label_extra_instance => 1, instance_use => 'display_absolute' } ], } From 24114cc7737d603f306903c05c27c3fccf0c8a68 Mon Sep 17 00:00:00 2001 From: Sims24 Date: Wed, 20 May 2020 15:11:04 +0200 Subject: [PATCH 259/283] workon parity bc --- blockchain/parity/ethpoller/mode/prct.pm | 53 ++-- blockchain/parity/ethpoller/mode/stats.pm | 281 ++++++++++--------- blockchain/parity/ethpoller/mode/tracking.pm | 18 +- 3 files changed, 174 insertions(+), 178 deletions(-) diff --git a/blockchain/parity/ethpoller/mode/prct.pm b/blockchain/parity/ethpoller/mode/prct.pm index 205feff6a..86939435a 100644 --- a/blockchain/parity/ethpoller/mode/prct.pm +++ b/blockchain/parity/ethpoller/mode/prct.pm @@ -40,18 +40,19 @@ sub set_counters { manual_keys => 1, closure_custom_calc => $self->can('custom_prct_calc'), closure_custom_output => $self->can('custom_prct_output'), - threshold_use => 'balance_fluctuation', + threshold_use => 'balance_fluctuation_prct', perfdatas => [ - { value => 'balance_fluctuation', template => '%.2f', - min => 0, label_extra_instance => 1, instance_use => 'display' }, + { value => 'balance_fluctuation_prct', template => '%.2f', unit => '%', + min => 0, label_extra_instance => 1, instance_use => 'display' } ], } }, { label => 'balance', nlabel => 'parity.tracking.balance', set => { key_values => [ { name => 'balance' } ], - output_template => "%d (wei)", + output_template => "%s (wei)", perfdatas => [ - { label => 'balance', template => '%d', value => 'balance_absolute' } + { label => 'balance', template => '%d', value => 'balance', + min => 0, label_extra_instance => 1, instance_use => 'display' } ], } } @@ -62,42 +63,24 @@ sub set_counters { sub custom_prct_output { my ($self, %options) = @_; - # use Data::Dumper; - # print Dumper('$total_balance'); return sprintf( "balance variation: %.2f ", - $self->{result_values}->{balance_fluctuation} + $self->{result_values}->{balance_fluctuation_prct} ); } + sub custom_prct_calc { - use Data::Dumper; - my ($self, %options) = @_; - my ($old_balance, $new_balance) = (0, 0); - foreach (keys %{$options{new_datas}}) { - # print Dumper($self->{instance}); - # print Dumper($options{new_datas}); - # print Dumper($options{new_datas}->{$_}); - if (/\Q$self->{instance}\E_.*_balance/) { - # print Dumper($self->{instance}); - $new_balance = $options{new_datas}->{$_}; - $old_balance = $options{old_datas}->{$_}; - # print Dumper($old_balance); - # print Dumper($new_balance); - } - } - - - $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; - $self->{result_values}->{balance_fluctuation} = 0; - if ($old_balance > 0) { - $self->{result_values}->{balance_fluctuation} = ($new_balance - $old_balance) / $old_balance; - } - + $self->{result_values}->{balance} = $options{new_datas}->{$self->{instance} . '_balance'}; + $self->{result_values}->{balance_old} = $options{old_datas}->{$self->{instance} . '_balance'}; + $self->{result_values}->{balance_fluctuation_prct} = (defined($self->{result_values}->{balance_old}) && $self->{result_values}->{balance_old} != 0) ? + ($self->{result_values}->{balance} - $self->{result_values}->{balance_old}) / + $self->{result_values}->{balance_old} : 0; + return 0; } sub prefix_output_balances { @@ -125,13 +108,11 @@ sub manage_selection { (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); my $result = $options{custom}->request_api(url_path => '/tracking'); - use Data::Dumper; - # print Dumper($result); foreach my $balance (@{$result->{balances}}) { - # print Dumper($balance); - $self->{balances}->{$balance->{label}} = { display => $balance->{label} }; - $self->{balances}->{$balance->{label}}->{'balance'} = $balance->{balance}; + $self->{balances}->{lc($balance->{label})} = { display => lc($balance->{label}), + balance => $balance->{balance} + }; } } diff --git a/blockchain/parity/ethpoller/mode/stats.pm b/blockchain/parity/ethpoller/mode/stats.pm index dab08346b..600b30c63 100644 --- a/blockchain/parity/ethpoller/mode/stats.pm +++ b/blockchain/parity/ethpoller/mode/stats.pm @@ -1,133 +1,148 @@ -# -# Copyright 2020 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 blockchain::parity::ethpoller::mode::stats; - -use base qw(centreon::plugins::templates::counter); - -use strict; -use warnings; -use bigint; -use Digest::MD5 qw(md5_hex); - -sub set_counters { - my ($self, %options) = @_; - - $self->{maps_counters_type} = [ - { name => 'block', cb_prefix_output => 'prefix_output_block', type => 0 }, - { name => 'transaction', cb_prefix_output => 'prefix_output_transaction', type => 0 } - ]; - - $self->{maps_counters}->{block} = [ - { label => 'block_frequency', nlabel => 'parity.stats.block.perminute', set => { - key_values => [ { name => 'block_count', diff => 1 } ], - per_minute => 1, - output_template => "Block frequency: %.2f (block/min)", - perfdatas => [ - { label => 'block', value => 'block_count_per_minute', template => ' %.2f', - label_extra_instance => 1, instance_use => 'display_absolute' } - ], - } - } - ]; - - $self->{maps_counters}->{transaction} = [ - { label => 'transaction_frequency', nlabel => 'parity.stats.transaction.perminute', set => { - key_values => [ { name => 'transaction_count', diff => 1 } ], - per_minute => 1, - output_template => "Transaction frequency: %.2f (tx/min)", - perfdatas => [ - { label => 'transaction', value => 'transaction_count_per_minute', template => '%.2f', - label_extra_instance => 1, instance_use => 'display_absolute' } - ], - } - } - ]; -} - -sub prefix_output_block { - my ($self, %options) = @_; - - return "Block stats '"; -} - -sub prefix_output_fork { - my ($self, %options) = @_; - - return "Fork stats '"; -} - -sub prefix_output_transaction { - my ($self, %options) = @_; - - return "Transaction stats '"; -} - -sub new { - my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1, statefile => 1); - bless $self, $class; - - $options{options}->add_options(arguments => { - "filter-name:s" => { name => 'filter_name' }, - }); - - return $self; -} - -sub manage_selection { - my ($self, %options) = @_; - - $self->{cache_name} = "parity_ethpoller_" . $self->{mode} . '_' . (defined($self->{option_results}->{hostname}) ? $self->{option_results}->{hostname} : 'me') . '_' . - (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); - - my $result = $options{custom}->request_api(url_path => '/stats'); - - $self->{block} = { block_count => $result->{block}->{count} }; - - $self->{transaction} = { transaction_count => $result->{transaction}->{count} }; - - my $block_timestamp = $result->{block}->{timestamp} == 0 ? '' : localtime($result->{block}->{timestamp}); - $self->{output}->output_add(severity => 'OK', long_msg => 'Last block (#' . $result->{block}->{count} . ') was on ' . $block_timestamp); - - if ($result->{transaction}->{count} > 0) { - my $tx_timestamp = $result->{transaction}->{timestamp} == 0 ? '' : localtime($result->{transaction}->{timestamp}); - $self->{output}->output_add(severity => 'OK', long_msg => 'Last transaction (#' . $result->{transaction}->{count} . ') was on ' . $tx_timestamp); - } else { - $self->{output}->output_add(severity => 'OK', long_msg => 'No transaction...'); - } - - if ($result->{transaction}->{count} > 0) { - my $fork_timestamp = $result->{fork}->{timestamp} == 0 ? '' : localtime($result->{fork}->{timestamp}); - $self->{output}->output_add(severity => 'OK', long_msg => 'Last fork (#' . $result->{fork}->{count} . ') was on ' . $fork_timestamp); - } else { - $self->{output}->output_add(severity => 'OK', long_msg => 'No fork occurence...'); - } -} - -1; - -__END__ - -=head1 MODE - -Check Parity eth-poller for stats - -=cut +# +# Copyright 2020 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 blockchain::parity::ethpoller::mode::stats; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use bigint; +use Digest::MD5 qw(md5_hex); + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'block', cb_prefix_output => 'prefix_output_block', type => 0 }, + { name => 'transaction', cb_prefix_output => 'prefix_output_transaction', type => 0 } + ]; + + $self->{maps_counters}->{block} = [ + { label => 'block-frequency', nlabel => 'parity.stats.block.perminute', set => { + key_values => [ { name => 'block_count', per_minute => 1 }, { name => 'last_block' }, { name => 'last_block_ts' } ], + per_minute => 1, + closure_custom_output => $self->can('custom_block_output'), + perfdatas => [ + { label => 'block', value => 'block_count', template => '%.2f' } + ], + } + } + ]; + + $self->{maps_counters}->{transaction} = [ + { label => 'transaction_frequency', nlabel => 'parity.stats.transaction.perminute', set => { + key_values => [ { name => 'transaction_count', per_minute => 1 } ], + per_minute => 1, + output_template => "Transaction frequency: %.2f (tx/min)", + perfdatas => [ + { label => 'transaction', value => 'transaction_count_per_minute', template => '%.2f' } + ], + } + } + ]; +} + +sub custom_block_output { + my ($self, %options) = @_; + + return sprintf( + "Count: '%.2f', Last block ID: '%s', Last block timestamp '%s' ", + $self->{result_values}->{block_count}, + $self->{result_values}->{last_block}, + $self->{result_values}->{last_block_ts} + ); +} + + +sub prefix_output_block { + my ($self, %options) = @_; + + return "Block stats '"; +} + +sub prefix_output_fork { + my ($self, %options) = @_; + + return "Fork stats '"; +} + +sub prefix_output_transaction { + my ($self, %options) = @_; + + return "Transaction stats '"; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1, statefile => 1); + bless $self, $class; + + $options{options}->add_options(arguments => { + "filter-name:s" => { name => 'filter_name' }, + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + $self->{cache_name} = "parity_ethpoller_" . $self->{mode} . '_' . (defined($self->{option_results}->{hostname}) ? $self->{option_results}->{hostname} : 'me') . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); + + my $result = $options{custom}->request_api(url_path => '/stats'); + + my $last_block = $result->{block}->{count}; + my $last_block_timestamp = (defined($result->{block}->{timestamp}) && $result->{block}->{timestamp} != 0) ? + localtime($result->{block}->{timestamp}) : + 'NONE'; + + $self->{block} = { block_count => $result->{block}->{count}, + last_block => $last_block, + last_block_ts => $last_block_timestamp }; + + $self->{transaction} = { transaction_count => $result->{transaction}->{count} }; + + if ($result->{transaction}->{count} > 0) { + my $tx_timestamp = $result->{transaction}->{timestamp} == 0 ? '' : localtime($result->{transaction}->{timestamp}); + $self->{output}->output_add(severity => 'OK', long_msg => 'Last transaction (#' . $result->{transaction}->{count} . ') was on ' . $tx_timestamp); + } else { + $self->{output}->output_add(severity => 'OK', long_msg => 'No transaction...'); + } + + if ($result->{transaction}->{count} > 0) { + my $fork_timestamp = $result->{fork}->{timestamp} == 0 ? '' : localtime($result->{fork}->{timestamp}); + $self->{output}->output_add(severity => 'OK', long_msg => 'Last fork (#' . $result->{fork}->{count} . ') was on ' . $fork_timestamp); + } else { + $self->{output}->output_add(severity => 'OK', long_msg => 'No fork occurence...'); + } +} + +1; + +__END__ + +=head1 MODE + +Check Parity eth-poller for stats + +=cut + diff --git a/blockchain/parity/ethpoller/mode/tracking.pm b/blockchain/parity/ethpoller/mode/tracking.pm index 001e33c42..e30e727f4 100644 --- a/blockchain/parity/ethpoller/mode/tracking.pm +++ b/blockchain/parity/ethpoller/mode/tracking.pm @@ -38,12 +38,12 @@ sub set_counters { $self->{maps_counters}->{events} = [ { label => 'events_frequency', nlabel => 'parity.tracking.events.perminute', set => { - key_values => [ { name => 'events_count', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'events_count', per_minute => 1 }, { name => 'display' } ], per_minute => 1, output_template => " %.2f (events/min)", perfdatas => [ - { label => 'events', template => '%.2f', value => 'events_count_per_minute', - label_extra_instance => 1, instance_use => 'display_absolute' } + { label => 'events', template => '%.2f', value => 'events_count', + label_extra_instance => 1, instance_use => 'display' } ], } } @@ -51,23 +51,23 @@ sub set_counters { $self->{maps_counters}->{mining} = [ { label => 'mining_frequency', nlabel => 'parity.tracking.mined.block.perminute', set => { - key_values => [ { name => 'mining_count', diff => 1 }, { name => 'display' } ], + key_values => [ { name => 'mining_count', per_minute => 1 }, { name => 'display' } ], per_minute => 1, output_template => " %.2f (blocks/min)", - perfdatas => [ { label => 'mining', template => '%.2f', value => 'mining_count_per_minute', - label_extra_instance => 1, instance_use => 'display_absolute' } ], + perfdatas => [ { label => 'mining', template => '%.2f', value => 'mining_count', + label_extra_instance => 1, instance_use => 'display' } ], } } ]; $self->{maps_counters}->{balance} = [ { label => 'balance_fluctuation', nlabel => 'parity.tracking.balance.variation.perminute', set => { - key_values => [ { name => 'balance', diff => 1 } ], + key_values => [ { name => 'balance', per_minute => 1 } ], per_minute => 1, output_template => " variation: %.2f (diff/min)", perfdatas => [ - { label => 'balances', template => '%.2f', value => 'balance_per_minute', - label_extra_instance => 1, instance_use => 'display_absolute' } + { label => 'balances', template => '%.2f', value => 'balance', + label_extra_instance => 1, instance_use => 'display' } ], } } From 3b5aa45bf3d460f4b6f71f62b1ba85cb59e969e4 Mon Sep 17 00:00:00 2001 From: Sims24 Date: Wed, 20 May 2020 15:19:05 +0200 Subject: [PATCH 260/283] workon blockchain --- blockchain/parity/restapi/mode/parity.pm | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/blockchain/parity/restapi/mode/parity.pm b/blockchain/parity/restapi/mode/parity.pm index 7e62fda50..96daf87c1 100644 --- a/blockchain/parity/restapi/mode/parity.pm +++ b/blockchain/parity/restapi/mode/parity.pm @@ -40,7 +40,7 @@ sub set_counters { key_values => [ { name => 'tx_pending' } ], output_template => "Pending transactions: %d", perfdatas => [ - { label => 'tx_pending', value => 'tx_pending_absolute', template => '%d', min => 0 } + { label => 'tx_pending', value => 'tx_pending', template => '%d', min => 0 } ], } }, @@ -48,7 +48,7 @@ sub set_counters { key_values => [ { name => 'mempool_size' } ], output_template => "Mempool size: %d", perfdatas => [ - { label => 'mempool_size', value => 'mempool_size_absolute', template => '%d', min => 0 } + { label => 'mempool_size', value => 'mempool_size', template => '%d', min => 0 } ], } }, @@ -56,7 +56,7 @@ sub set_counters { key_values => [ { name => 'mempool_usage' } ], output_template => "Mempool usage: %d %% ", perfdatas => [ - { label => 'mempool_usage', value => 'mempool_usage_absolute', template => '%d', min => 0 } + { label => 'mempool_usage', value => 'mempool_usage', template => '%d', min => 0 } ], } }, @@ -67,7 +67,7 @@ sub set_counters { key_values => [ { name => 'peers_connected' } ], output_template => "Peers connected: %d", perfdatas => [ - { label => 'peers_connected', value => 'peers_connected_absolute', template => '%d', min => 0 } + { label => 'peers_connected', value => 'peers_connected', template => '%d', min => 0 } ], } }, @@ -75,7 +75,7 @@ sub set_counters { key_values => [ { name => 'peers_max' } ], output_template => "Peers max: %d", perfdatas => [ - { label => 'peers_max', value => 'peers_max_absolute', template => '%d', min => 0 } + { label => 'peers_max', value => 'peers_max', template => '%d', min => 0 } ], } }, @@ -83,7 +83,7 @@ sub set_counters { key_values => [ { name => 'peers_usage' } ], output_template => "Mempool usage: %d %% ", perfdatas => [ - { label => 'peers_usage', value => 'peers_usage_absolute', template => '%d', min => 0 } + { label => 'peers_usage', value => 'peers_usage', template => '%d', min => 0 } ], } }, From 0e31ee7baa1071abc7bafee0fefacfd7b020abe6 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 20 May 2020 15:35:59 +0200 Subject: [PATCH 261/283] change some stuffs --- blockchain/parity/ethpoller/mode/tracking.pm | 43 +++++++++----------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/blockchain/parity/ethpoller/mode/tracking.pm b/blockchain/parity/ethpoller/mode/tracking.pm index e30e727f4..32c03e630 100644 --- a/blockchain/parity/ethpoller/mode/tracking.pm +++ b/blockchain/parity/ethpoller/mode/tracking.pm @@ -39,12 +39,10 @@ sub set_counters { $self->{maps_counters}->{events} = [ { label => 'events_frequency', nlabel => 'parity.tracking.events.perminute', set => { key_values => [ { name => 'events_count', per_minute => 1 }, { name => 'display' } ], - per_minute => 1, output_template => " %.2f (events/min)", perfdatas => [ - { label => 'events', template => '%.2f', value => 'events_count', - label_extra_instance => 1, instance_use => 'display' } - ], + { template => '%.2f', label_extra_instance => 1, instance_use => 'display' } + ] } } ]; @@ -52,27 +50,24 @@ sub set_counters { $self->{maps_counters}->{mining} = [ { label => 'mining_frequency', nlabel => 'parity.tracking.mined.block.perminute', set => { key_values => [ { name => 'mining_count', per_minute => 1 }, { name => 'display' } ], - per_minute => 1, output_template => " %.2f (blocks/min)", - perfdatas => [ { label => 'mining', template => '%.2f', value => 'mining_count', - label_extra_instance => 1, instance_use => 'display' } ], + perfdatas => [ + { template => '%.2f', label_extra_instance => 1, instance_use => 'display' } + ] } } ]; $self->{maps_counters}->{balance} = [ { label => 'balance_fluctuation', nlabel => 'parity.tracking.balance.variation.perminute', set => { - key_values => [ { name => 'balance', per_minute => 1 } ], - per_minute => 1, + key_values => [ { name => 'balance', per_minute => 1 }, { name => 'display' } ], output_template => " variation: %.2f (diff/min)", perfdatas => [ - { label => 'balances', template => '%.2f', value => 'balance', - label_extra_instance => 1, instance_use => 'display' } - ], + { template => '%.2f', label_extra_instance => 1, instance_use => 'display' } + ] } } ]; - } sub prefix_output_events { @@ -124,9 +119,10 @@ sub manage_selection { next; } - $self->{events}->{lc($event->{label})} = { display => lc($event->{label}), - events_count => $event->{count} }; - + $self->{events}->{lc($event->{label})} = { + display => lc($event->{label}), + events_count => $event->{count} + }; } foreach my $miner (@{$results->{miners}}) { @@ -136,9 +132,10 @@ sub manage_selection { next; } - $self->{mining}->{lc($miner->{label})} = { display => lc($miner->{label}), - mining_count => $miner->{count} }; - + $self->{mining}->{lc($miner->{label})} = { + display => lc($miner->{label}), + mining_count => $miner->{count} + }; } foreach my $balance (@{$results->{balances}}) { @@ -148,11 +145,11 @@ sub manage_selection { next; } - $self->{balance}->{lc($balance->{label})} = { display => lc($balance->{label}), - balance => $balance->{balance} }; + $self->{balance}->{lc($balance->{label})} = { + display => lc($balance->{label}), + balance => $balance->{balance} + }; } - - } 1; From e36b23d4c0fe9e73bdbe6facbbfa0675ce630355 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 20 May 2020 15:36:39 +0200 Subject: [PATCH 262/283] change some stuffs --- blockchain/parity/ethpoller/mode/tracking.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/blockchain/parity/ethpoller/mode/tracking.pm b/blockchain/parity/ethpoller/mode/tracking.pm index 32c03e630..9f986d71c 100644 --- a/blockchain/parity/ethpoller/mode/tracking.pm +++ b/blockchain/parity/ethpoller/mode/tracking.pm @@ -37,7 +37,7 @@ sub set_counters { ]; $self->{maps_counters}->{events} = [ - { label => 'events_frequency', nlabel => 'parity.tracking.events.perminute', set => { + { label => 'events-frequency', nlabel => 'parity.tracking.events.perminute', set => { key_values => [ { name => 'events_count', per_minute => 1 }, { name => 'display' } ], output_template => " %.2f (events/min)", perfdatas => [ @@ -48,7 +48,7 @@ sub set_counters { ]; $self->{maps_counters}->{mining} = [ - { label => 'mining_frequency', nlabel => 'parity.tracking.mined.block.perminute', set => { + { label => 'mining-frequency', nlabel => 'parity.tracking.mined.block.perminute', set => { key_values => [ { name => 'mining_count', per_minute => 1 }, { name => 'display' } ], output_template => " %.2f (blocks/min)", perfdatas => [ @@ -59,7 +59,7 @@ sub set_counters { ]; $self->{maps_counters}->{balance} = [ - { label => 'balance_fluctuation', nlabel => 'parity.tracking.balance.variation.perminute', set => { + { label => 'balance-fluctuation', nlabel => 'parity.tracking.balance.variation.perminute', set => { key_values => [ { name => 'balance', per_minute => 1 }, { name => 'display' } ], output_template => " variation: %.2f (diff/min)", perfdatas => [ From 756cbe5f96278867e1f085367f61e9d0948a93ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20Adri=C3=A1n=20Molina?= Date: Wed, 20 May 2020 13:06:26 +0200 Subject: [PATCH 263/283] Added hardware::server::sun::snmp::plugin --- hardware/server/sun/snmp/plugin.pm | 49 ++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 hardware/server/sun/snmp/plugin.pm diff --git a/hardware/server/sun/snmp/plugin.pm b/hardware/server/sun/snmp/plugin.pm new file mode 100644 index 000000000..06cbb04bf --- /dev/null +++ b/hardware/server/sun/snmp/plugin.pm @@ -0,0 +1,49 @@ +# +# Copyright 2020 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 hardware::server::sun::snmp::plugin; + + +use strict; +use warnings; +use base qw(centreon::plugins::script_snmp); + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.0'; + %{$self->{modes}} = ( + 'hardware' => 'centreon::common::sun::snmp::mode::hardware', + ); + + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Sun Hardware by SNMP. + +=cut From 3326202466424f4c8ea9a19d94144ebb11d72b10 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 20 May 2020 15:43:12 +0200 Subject: [PATCH 264/283] fix per_minute --- centreon/plugins/values.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/centreon/plugins/values.pm b/centreon/plugins/values.pm index f6645795d..741774561 100644 --- a/centreon/plugins/values.pm +++ b/centreon/plugins/values.pm @@ -241,7 +241,8 @@ sub execute { } if ((defined($value->{diff}) && $value->{diff} == 1) || - (defined($value->{per_second}) && $value->{per_second} == 1)) { + (defined($value->{per_minute}) && $value->{per_minute} == 1) || + (defined($value->{per_second}) && $value->{per_second} == 1)) { $options{new_datas}->{$self->{instance} . '_' . $value->{name}} = $options{values}->{$value->{name}}; $old_datas->{$self->{instance} . '_' . $value->{name}} = $self->{statefile}->get(name => $self->{instance} . '_' . $value->{name}); if (!defined($old_datas->{$self->{instance} . '_' . $value->{name}})) { From aa6afc913a7f039e54c4bbab850c0e6291fd6244 Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Wed, 20 May 2020 13:54:51 +0000 Subject: [PATCH 265/283] add per_hour option --- centreon/plugins/values.pm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/centreon/plugins/values.pm b/centreon/plugins/values.pm index 741774561..92d7968dd 100644 --- a/centreon/plugins/values.pm +++ b/centreon/plugins/values.pm @@ -93,6 +93,8 @@ sub calc { $self->{result_values}->{$value->{name}} = ($options{new_datas}->{$self->{instance} . '_' . $value->{name}} - $options{old_datas}->{$self->{instance} . '_' . $value->{name}}) / $options{delta_time}; } elsif (defined($value->{per_minute}) && $value->{per_minute} == 1) { $self->{result_values}->{$value->{name}} = ($options{new_datas}->{$self->{instance} . '_' . $value->{name}} - $options{old_datas}->{$self->{instance} . '_' . $value->{name}}) / ($options{delta_time} / 60); + } elsif (defined($value->{per_hour}) && $value->{per_hour} == 1) { + $self->{result_values}->{$value->{name}} = ($options{new_datas}->{$self->{instance} . '_' . $value->{name}} - $options{old_datas}->{$self->{instance} . '_' . $value->{name}}) / ($options{delta_time} / 3600); } else { $self->{result_values}->{$value->{name}} = $options{new_datas}->{$self->{instance} . '_' . $value->{name}}; } From 4233b497ef2eaf6ea86696bc72954346269a1889 Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Thu, 21 May 2020 22:10:32 +0000 Subject: [PATCH 266/283] custom outputs update --- blockchain/parity/ethpoller/mode/disk.pm | 12 +- blockchain/parity/ethpoller/mode/stats.pm | 346 +++++++++++-------- blockchain/parity/ethpoller/mode/tracking.pm | 111 +++++- blockchain/parity/restapi/mode/eth.pm | 44 +-- blockchain/parity/restapi/mode/net.pm | 2 +- blockchain/parity/restapi/mode/parity.pm | 24 +- 6 files changed, 332 insertions(+), 207 deletions(-) diff --git a/blockchain/parity/ethpoller/mode/disk.pm b/blockchain/parity/ethpoller/mode/disk.pm index cd06b13ba..12a953d49 100644 --- a/blockchain/parity/ethpoller/mode/disk.pm +++ b/blockchain/parity/ethpoller/mode/disk.pm @@ -39,7 +39,7 @@ sub set_counters { key_values => [ { name => 'disk_free' } ], output_template => "Disk free: %d ", perfdatas => [ - { label => 'disk_free', value => 'disk_free_absolute', template => '%d', min => 0 } + { label => 'disk_free', value => 'disk_free', template => '%d', min => 0 } ], } }, @@ -47,7 +47,7 @@ sub set_counters { key_values => [ { name => 'disk_available' } ], output_template => "Disk available: %d ", perfdatas => [ - { label => 'disk_available', value => 'disk_available_absolute', template => '%d', min => 0 } + { label => 'disk_available', value => 'disk_available', template => '%d', min => 0 } ], } }, @@ -55,7 +55,7 @@ sub set_counters { key_values => [ { name => 'disk_size' } ], output_template => "Disk size: %d ", perfdatas => [ - { label => 'disk_size', value => 'disk_size_absolute', template => '%d', min => 0 } + { label => 'disk_size', value => 'disk_size', template => '%d', min => 0 } ], } }, @@ -63,7 +63,7 @@ sub set_counters { key_values => [ { name => 'disk_used' } ], output_template => "Disk used: %d ", perfdatas => [ - { label => 'disk_used', value => 'disk_used_absolute', template => '%d', min => 0 } + { label => 'disk_used', value => 'disk_used', template => '%d', min => 0 } ], } }, @@ -71,7 +71,7 @@ sub set_counters { key_values => [ { name => 'disk_usage' } ], output_template => "Disk usage: %d %%", perfdatas => [ - { label => 'disk_usage', value => 'disk_usage_absolute', template => '%d', min => 0 } + { label => 'disk_usage', value => 'disk_usage', template => '%d', min => 0 } ], } }, @@ -79,7 +79,7 @@ sub set_counters { key_values => [ { name => 'blockchain_dir' } ], output_template => "Blockchain directory: %d", perfdatas => [ - { label => 'blockchain_dir', value => 'blockchain_dir_absolute', template => '%d', min => 0 } + { label => 'blockchain_dir', value => 'blockchain_dir', template => '%d', min => 0 } ], } } diff --git a/blockchain/parity/ethpoller/mode/stats.pm b/blockchain/parity/ethpoller/mode/stats.pm index 600b30c63..09cccdd5a 100644 --- a/blockchain/parity/ethpoller/mode/stats.pm +++ b/blockchain/parity/ethpoller/mode/stats.pm @@ -1,148 +1,198 @@ -# -# Copyright 2020 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 blockchain::parity::ethpoller::mode::stats; - -use base qw(centreon::plugins::templates::counter); - -use strict; -use warnings; -use bigint; -use Digest::MD5 qw(md5_hex); - -sub set_counters { - my ($self, %options) = @_; - - $self->{maps_counters_type} = [ - { name => 'block', cb_prefix_output => 'prefix_output_block', type => 0 }, - { name => 'transaction', cb_prefix_output => 'prefix_output_transaction', type => 0 } - ]; - - $self->{maps_counters}->{block} = [ - { label => 'block-frequency', nlabel => 'parity.stats.block.perminute', set => { - key_values => [ { name => 'block_count', per_minute => 1 }, { name => 'last_block' }, { name => 'last_block_ts' } ], - per_minute => 1, - closure_custom_output => $self->can('custom_block_output'), - perfdatas => [ - { label => 'block', value => 'block_count', template => '%.2f' } - ], - } - } - ]; - - $self->{maps_counters}->{transaction} = [ - { label => 'transaction_frequency', nlabel => 'parity.stats.transaction.perminute', set => { - key_values => [ { name => 'transaction_count', per_minute => 1 } ], - per_minute => 1, - output_template => "Transaction frequency: %.2f (tx/min)", - perfdatas => [ - { label => 'transaction', value => 'transaction_count_per_minute', template => '%.2f' } - ], - } - } - ]; -} - -sub custom_block_output { - my ($self, %options) = @_; - - return sprintf( - "Count: '%.2f', Last block ID: '%s', Last block timestamp '%s' ", - $self->{result_values}->{block_count}, - $self->{result_values}->{last_block}, - $self->{result_values}->{last_block_ts} - ); -} - - -sub prefix_output_block { - my ($self, %options) = @_; - - return "Block stats '"; -} - -sub prefix_output_fork { - my ($self, %options) = @_; - - return "Fork stats '"; -} - -sub prefix_output_transaction { - my ($self, %options) = @_; - - return "Transaction stats '"; -} - -sub new { - my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1, statefile => 1); - bless $self, $class; - - $options{options}->add_options(arguments => { - "filter-name:s" => { name => 'filter_name' }, - }); - - return $self; -} - -sub manage_selection { - my ($self, %options) = @_; - - $self->{cache_name} = "parity_ethpoller_" . $self->{mode} . '_' . (defined($self->{option_results}->{hostname}) ? $self->{option_results}->{hostname} : 'me') . '_' . - (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); - - my $result = $options{custom}->request_api(url_path => '/stats'); - - my $last_block = $result->{block}->{count}; - my $last_block_timestamp = (defined($result->{block}->{timestamp}) && $result->{block}->{timestamp} != 0) ? - localtime($result->{block}->{timestamp}) : - 'NONE'; - - $self->{block} = { block_count => $result->{block}->{count}, - last_block => $last_block, - last_block_ts => $last_block_timestamp }; - - $self->{transaction} = { transaction_count => $result->{transaction}->{count} }; - - if ($result->{transaction}->{count} > 0) { - my $tx_timestamp = $result->{transaction}->{timestamp} == 0 ? '' : localtime($result->{transaction}->{timestamp}); - $self->{output}->output_add(severity => 'OK', long_msg => 'Last transaction (#' . $result->{transaction}->{count} . ') was on ' . $tx_timestamp); - } else { - $self->{output}->output_add(severity => 'OK', long_msg => 'No transaction...'); - } - - if ($result->{transaction}->{count} > 0) { - my $fork_timestamp = $result->{fork}->{timestamp} == 0 ? '' : localtime($result->{fork}->{timestamp}); - $self->{output}->output_add(severity => 'OK', long_msg => 'Last fork (#' . $result->{fork}->{count} . ') was on ' . $fork_timestamp); - } else { - $self->{output}->output_add(severity => 'OK', long_msg => 'No fork occurence...'); - } -} - -1; - -__END__ - -=head1 MODE - -Check Parity eth-poller for stats - -=cut - +# +# Copyright 2020 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 blockchain::parity::ethpoller::mode::stats; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use bigint; +use Time::Seconds; +use Digest::MD5 qw(md5_hex); + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'block', cb_prefix_output => 'prefix_output_block', type => 0 }, + { name => 'transaction', cb_prefix_output => 'prefix_output_transaction', type => 0 }, + { name => 'fork', cb_prefix_output => 'prefix_output_fork', type => 0 } + ]; + + $self->{maps_counters}->{block} = [ + { label => 'block-frequency', nlabel => 'parity.stats.block.perminute', set => { + key_values => [ { name => 'block_count', per_minute => 1 }, { name => 'last_block' }, { name => 'last_block_ts' } ], + closure_custom_output => $self->can('custom_block_output'), + perfdatas => [ + { label => 'block', value => 'block_count', template => '%.2f' } + ], + } + } + ]; + + $self->{maps_counters}->{transaction} = [ + { label => 'transaction-frequency', nlabel => 'parity.stats.transaction.perminute', set => { + key_values => [ { name => 'transaction_count', per_minute => 1 }, { name => 'last_transaction' }, { name => 'last_transaction_ts' } ], + closure_custom_output => $self->can('custom_transaction_output'), + perfdatas => [ + { label => 'transaction', value => 'transaction_count', template => '%.2f' } + ], + } + } + ]; + + $self->{maps_counters}->{fork} = [ + { label => 'fork-frequency', nlabel => 'parity.stats.fork.perminute', set => { + key_values => [ { name => 'fork_count', per_minute => 1 }, { name => 'last_fork' }, { name => 'last_fork_ts' } ], + closure_custom_output => $self->can('custom_fork_output'), + perfdatas => [ + { label => 'fork', value => 'fork_count', template => '%.2f' } + ], + } + } + ]; +} + +sub custom_block_output { + my ($self, %options) = @_; + + if (0 eq $self->{result_values}->{block_count}) { + return sprintf("No block yet..."); + } else { + my $time_elapsed = time() - $self->{result_values}->{last_block_ts}; + my $t = Time::Seconds->new($time_elapsed); + + return sprintf( + "Block frequency: '%.2f/min', Last block (#%s) was %s ago", + $self->{result_values}->{block_count}, + $self->{result_values}->{last_block}, + $t->pretty + ); + } +} + +sub custom_transaction_output { + my ($self, %options) = @_; + + if (0 eq $self->{result_values}->{transaction_count}) { + return sprintf("No transaction yet..."); + } else { + my $time_elapsed = time() - $self->{result_values}->{last_transaction_ts}; + my $t = Time::Seconds->new($time_elapsed); + + return sprintf( + "Transaction frequency: '%.2f/min', Last transaction (#%s) was %s ago", + $self->{result_values}->{transaction_count}, + $self->{result_values}->{last_transaction}, + $t->pretty + ); + } +} + +sub custom_fork_output { + my ($self, %options) = @_; + + if (0 eq $self->{result_values}->{fork_count}) { + return sprintf("No fork occurred yet..."); + } else { + my $time_elapsed = time() - $self->{result_values}->{last_fork_ts}; + my $t = Time::Seconds->new($time_elapsed); + + return sprintf( + "Fork frequency: '%.2f/min', Last fork (#%s) was %s ago", + $self->{result_values}->{fork_count}, + $self->{result_values}->{last_fork}, + $t->pretty + ); + } +} + + +sub prefix_output_block { + my ($self, %options) = @_; + + return "Block stats '"; +} + +sub prefix_output_fork { + my ($self, %options) = @_; + + return "Fork stats '"; +} + +sub prefix_output_transaction { + my ($self, %options) = @_; + + return "Transaction stats '"; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1, statefile => 1); + bless $self, $class; + + $options{options}->add_options(arguments => { + "filter-name:s" => { name => 'filter_name' }, + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + $self->{cache_name} = "parity_ethpoller_" . $self->{mode} . '_' . (defined($self->{option_results}->{hostname}) ? $self->{option_results}->{hostname} : 'me') . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); + + my $result = $options{custom}->request_api(url_path => '/stats'); + + my $last_block_timestamp = (defined($result->{block}->{timestamp}) && $result->{block}->{timestamp} != 0) ? + $result->{block}->{timestamp} : + 'NONE'; + my $last_transaction_timestamp = (defined($result->{transaction}->{timestamp}) && $result->{transaction}->{timestamp} != 0) ? + $result->{transaction}->{timestamp} : + 'NONE'; + my $last_fork_timestamp = (defined($result->{fork}->{timestamp}) && $result->{fork}->{timestamp} != 0) ? + $result->{fork}->{timestamp} : + 'NONE'; + + $self->{block} = { block_count => $result->{block}->{count}, + last_block => $result->{block}->{count}, + last_block_ts => $last_block_timestamp }; + + $self->{transaction} = { transaction_count => $result->{transaction}->{count}, + last_transaction => $result->{transaction}->{count}, + last_transaction_ts => $last_transaction_timestamp }; + + $self->{fork} = { fork_count => $result->{fork}->{count}, + last_fork => $result->{fork}->{count}, + last_fork_ts => $last_fork_timestamp }; +} + +1; + +__END__ + +=head1 MODE + +Check Parity eth-poller for stats + +=cut diff --git a/blockchain/parity/ethpoller/mode/tracking.pm b/blockchain/parity/ethpoller/mode/tracking.pm index 9f986d71c..0fa2dfc51 100644 --- a/blockchain/parity/ethpoller/mode/tracking.pm +++ b/blockchain/parity/ethpoller/mode/tracking.pm @@ -25,6 +25,7 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; use bigint; +use Time::Seconds; use Digest::MD5 qw(md5_hex); sub set_counters { @@ -33,13 +34,14 @@ sub set_counters { $self->{maps_counters_type} = [ { name => 'events', cb_prefix_output => 'prefix_output_events', type => 1, message_multiple => 'Events metrics are ok' }, { name => 'mining', cb_prefix_output => 'prefix_output_mining', type => 1, message_multiple => 'Mining metrics are ok' }, - { name => 'balance', cb_prefix_output => 'prefix_output_balance', type => 1, message_multiple => 'Balances metrics are ok' } + { name => 'balance', cb_prefix_output => 'prefix_output_balances', type => 1, message_multiple => 'Balances metrics are ok' } ]; $self->{maps_counters}->{events} = [ { label => 'events-frequency', nlabel => 'parity.tracking.events.perminute', set => { - key_values => [ { name => 'events_count', per_minute => 1 }, { name => 'display' } ], - output_template => " %.2f (events/min)", + key_values => [ { name => 'events_count', per_minute => 1 }, { name => 'display' }, + { name => 'last_event' }, { name => 'last_event_block' }, { name => 'last_event_ts' } ], + closure_custom_output => $self->can('custom_event_output'), perfdatas => [ { template => '%.2f', label_extra_instance => 1, instance_use => 'display' } ] @@ -49,8 +51,9 @@ sub set_counters { $self->{maps_counters}->{mining} = [ { label => 'mining-frequency', nlabel => 'parity.tracking.mined.block.perminute', set => { - key_values => [ { name => 'mining_count', per_minute => 1 }, { name => 'display' } ], - output_template => " %.2f (blocks/min)", + key_values => [ { name => 'mining_count', per_minute => 1 }, { name => 'display' }, + , { name => 'last_mining' }, { name => 'last_mining_block' }, { name => 'last_mining_ts' } ], + closure_custom_output => $self->can('custom_miner_output'), perfdatas => [ { template => '%.2f', label_extra_instance => 1, instance_use => 'display' } ] @@ -59,17 +62,27 @@ sub set_counters { ]; $self->{maps_counters}->{balance} = [ - { label => 'balance-fluctuation', nlabel => 'parity.tracking.balance.variation.perminute', set => { - key_values => [ { name => 'balance', per_minute => 1 }, { name => 'display' } ], - output_template => " variation: %.2f (diff/min)", + { label => 'balance-fluctuation-prct', nlabel => 'parity.tracking.balances.fluctuation', display_ok => 0, set => { + key_values => [], + manual_keys => 1, + closure_custom_calc => $self->can('custom_prct_calc'), + closure_custom_output => $self->can('custom_balance_output'), + threshold_use => 'balance_fluctuation_prct', perfdatas => [ - { template => '%.2f', label_extra_instance => 1, instance_use => 'display' } - ] + { value => 'balance_fluctuation_prct', template => '%.2f', unit => '%', + min => 0, label_extra_instance => 1, instance_use => 'display' } + ], } } ]; } +sub prefix_output_balances { + my ($self, %options) = @_; + + return "*Balance* '" . $options{instance_value}->{display} . "' "; +} + sub prefix_output_events { my ($self, %options) = @_; @@ -79,13 +92,68 @@ sub prefix_output_events { sub prefix_output_mining { my ($self, %options) = @_; - return "Miner '" . $options{instance_value}->{display} . "' ";; + return "Miner '" . $options{instance_value}->{display} . "' "; } -sub prefix_output_balance { +sub custom_balance_output { + my ($self, %options) = @_; + + return sprintf( + "Balance: %s ether, Last fluctuation: %.2f ", + $self->{result_values}->{balance}, + $self->{result_values}->{balance_fluctuation_prct} + ); +} + +sub custom_prct_calc { my ($self, %options) = @_; - return "Balance '" . $options{instance_value}->{display} . "' "; + $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; + $self->{result_values}->{balance} = $options{new_datas}->{$self->{instance} . '_balance'}; + $self->{result_values}->{balance_old} = $options{old_datas}->{$self->{instance} . '_balance'}; + $self->{result_values}->{balance_fluctuation_prct} = (defined($self->{result_values}->{balance_old}) && $self->{result_values}->{balance_old} != 0) ? + ($self->{result_values}->{balance} - $self->{result_values}->{balance_old}) / + $self->{result_values}->{balance_old} * 100 : 0; + + return 0; +} + +sub custom_event_output { + my ($self, %options) = @_; + + if (0 eq $self->{result_values}->{last_event}) { + return sprintf("No event yet..."); + } else { + my $time_elapsed = time() - $self->{result_values}->{last_event_ts}; + my $t = Time::Seconds->new($time_elapsed); + + return sprintf( + "Event frequency: %.2f/min, Last event (#%s) was %s ago in block #%s", + $self->{result_values}->{event_count}, + $self->{result_values}->{last_event}, + $t->pretty, + $self->{result_values}->{last_event_block} + ); + } +} + +sub custom_miner_output { + my ($self, %options) = @_; + + if (0 eq $self->{result_values}->{last_mining}) { + return sprintf("No validation yet..."); + } else { + my $time_elapsed = time() - $self->{result_values}->{last_mining_ts}; + my $t = Time::Seconds->new($time_elapsed); + + return sprintf( + "Mining frequency: %.2f/min, Last validation (#%s) was %s ago for block #%s", + $self->{result_values}->{mining_count}, + $self->{result_values}->{last_mining}, + $t->pretty, + $self->{result_values}->{last_mining_block} + ); + } } sub new { @@ -119,9 +187,14 @@ sub manage_selection { next; } + my $last_event_timestamp = (defined($event->{timestamp}) && $event->{timestamp} != 0) ? $event->{timestamp} : 'NONE'; + $self->{events}->{lc($event->{label})} = { display => lc($event->{label}), - events_count => $event->{count} + events_count => $event->{count}, + last_event => $event->{count}, + last_event_block => $event->{block}, + last_event_ts => $last_event_timestamp }; } @@ -132,9 +205,14 @@ sub manage_selection { next; } + my $last_mining_timestamp = (defined($miner->{timestamp}) && $miner->{timestamp} != 0) ? $miner->{timestamp} : 'NONE'; + $self->{mining}->{lc($miner->{label})} = { display => lc($miner->{label}), - mining_count => $miner->{count} + mining_count => $miner->{count}, + last_mining => $miner->{count}, + last_mining_block => $miner->{block}, + last_mining_ts => $last_mining_timestamp }; } @@ -150,6 +228,7 @@ sub manage_selection { balance => $balance->{balance} }; } + } 1; @@ -160,4 +239,4 @@ __END__ Check Parity eth-poller for events, miners and balances tracking -=cut +=cut \ No newline at end of file diff --git a/blockchain/parity/restapi/mode/eth.pm b/blockchain/parity/restapi/mode/eth.pm index edb5e571b..5dba7d513 100644 --- a/blockchain/parity/restapi/mode/eth.pm +++ b/blockchain/parity/restapi/mode/eth.pm @@ -51,7 +51,7 @@ sub set_counters { key_values => [ { name => 'sync_status' } ], output_template => "Syncing: %d %% ", perfdatas => [ - { label => 'sync_status', value => 'sync_status_absolute', template => '%d', min => 0 } + { label => 'sync_status', value => 'sync_status', template => '%d', min => 0 } ], } } @@ -62,7 +62,7 @@ sub set_counters { key_values => [ { name => 'gas_price' } ], output_template => "The gas price is: %d wei ", perfdatas => [ - { label => 'gas_price', value => 'gas_price_absolute', template => '%d', min => 0 } + { label => 'gas_price', value => 'gas_price', template => '%d', min => 0 } ], } }, @@ -70,7 +70,7 @@ sub set_counters { key_values => [ { name => 'gas_used' } ], output_template => "The gas used is: %d", perfdatas => [ - { label => 'gas_used', value => 'gas_used_absolute', template => '%d', min => 0 } + { label => 'gas_used', value => 'gas_used', template => '%d', min => 0 } ], } }, @@ -78,7 +78,7 @@ sub set_counters { key_values => [ { name => 'gas_limit' } ], output_template => "The gas limit is: %d", perfdatas => [ - { label => 'gas_limit', value => 'gas_limit_absolute', template => '%d', min => 0 } + { label => 'gas_limit', value => 'gas_limit', template => '%d', min => 0 } ], } } @@ -87,9 +87,9 @@ sub set_counters { $self->{maps_counters}->{block} = [ { label => 'block_size', nlabel => 'parity.eth.block.size', set => { key_values => [ { name => 'block_size' } ], - output_template => "Most recent block size: %d ", + output_template => "Block size: %d ", perfdatas => [ - { label => 'block_size', value => 'block_size_absolute', template => '%d', min => 0 } + { label => 'block_size', value => 'block_size', template => '%d', min => 0 } ], } }, @@ -97,7 +97,7 @@ sub set_counters { key_values => [ { name => 'block_usage' } ], output_template => "Block usage: %d %%", perfdatas => [ - { label => 'block_usage', value => 'block_usage_absolute', template => '%d', min => 0 } + { label => 'block_usage', value => 'block_usage', template => '%d', min => 0 } ], } }, @@ -105,7 +105,7 @@ sub set_counters { key_values => [ { name => 'block_transactions' } ], output_template => "Block transactions number: %d ", perfdatas => [ - { label => 'block_transactions', value => 'block_transactions_absolute', template => '%d', min => 0 } + { label => 'block_transactions', value => 'block_transactions', template => '%d', min => 0 } ], } }, @@ -113,23 +113,15 @@ sub set_counters { key_values => [ { name => 'block_gas' } ], output_template => "Block gas: %d ", perfdatas => [ - { label => 'block_gas', value => 'block_gas_absolute', template => '%d', min => 0 } + { label => 'block_gas', value => 'block_gas', template => '%d', min => 0 } ], } }, - # { label => 'block_difficulty', nlabel => 'parity.eth.block.difficulty', set => { - # key_values => [ { name => 'block_difficulty' } ], - # output_template => "Block difficulty: %f ", - # perfdatas => [ - # { label => 'block_difficulty', value => 'block_difficulty_absolute', template => '%f', min => 0 } - # ], - # } - # }, { label => 'block_uncles', nlabel => 'parity.eth.block.uncles', set => { key_values => [ { name => 'block_uncles' } ], output_template => "Block uncles: %d ", perfdatas => [ - { label => 'block_uncles', value => 'block_uncles_absolute', template => '%d', min => 0 } + { label => 'block_uncles', value => 'block_uncles', template => '%d', min => 0 } ], } }, @@ -224,14 +216,14 @@ sub manage_selection { block_uncles => scalar(@{$$result[5]->{result}->{uncles}}), block_transactions => scalar(@{$$result[5]->{result}->{transactions}})}; - $self->{output}->output_add(severity => 'OK', long_msg => 'Node status: [is_mining: ' . @{$result}[0]->{result} . '] [sync_start: ' . $res_startingBlock . - '] [sync_current: ' . $res_currentBlock . '] [sync_highest: ' . $res_highestBlock . '] [sync: ' . $res_sync . '%]'); - $self->{output}->output_add(severity => 'OK', long_msg => 'Client: [coinbase: ' . @{$result}[1]->{result} . ']'); - $self->{output}->output_add(severity => 'OK', long_msg => 'Global: [hashrate: ' . hex(@{$result}[3]->{result}) . - '] [block_number: ' . (defined @{$result}[4]->{result} ? hex(@{$result}[4]->{result}) : 0) . ']'); - $self->{output}->output_add(severity => 'OK', long_msg => 'Last block: [block_time: ' . $res_block_time . '] [block_gas_limit: ' . hex(@{$result}[5]->{result}->{gasLimit}) . - '] [block_miner: ' . @{$result}[5]->{result}->{miner} . '] [block_hash: ' . @{$result}[5]->{result}->{hash} . - '] [last_block_number: ' . hex(@{$result}[5]->{result}->{number}) . ']'); + # $self->{output}->output_add(severity => 'OK', long_msg => 'Node status: [is_mining: ' . @{$result}[0]->{result} . '] [sync_start: ' . $res_startingBlock . + # '] [sync_current: ' . $res_currentBlock . '] [sync_highest: ' . $res_highestBlock . '] [sync: ' . $res_sync . '%]'); + # $self->{output}->output_add(severity => 'OK', long_msg => 'Client: [coinbase: ' . @{$result}[1]->{result} . ']'); + # $self->{output}->output_add(severity => 'OK', long_msg => 'Global: [hashrate: ' . hex(@{$result}[3]->{result}) . + # '] [block_number: ' . (defined @{$result}[4]->{result} ? hex(@{$result}[4]->{result}) : 0) . ']'); + # $self->{output}->output_add(severity => 'OK', long_msg => 'Last block: [block_time: ' . $res_block_time . '] [block_gas_limit: ' . hex(@{$result}[5]->{result}->{gasLimit}) . + # '] [block_miner: ' . @{$result}[5]->{result}->{miner} . '] [block_hash: ' . @{$result}[5]->{result}->{hash} . + # '] [last_block_number: ' . hex(@{$result}[5]->{result}->{number}) . ']'); } diff --git a/blockchain/parity/restapi/mode/net.pm b/blockchain/parity/restapi/mode/net.pm index 7bc65d3a8..ee06b150f 100644 --- a/blockchain/parity/restapi/mode/net.pm +++ b/blockchain/parity/restapi/mode/net.pm @@ -48,7 +48,7 @@ sub set_counters { key_values => [ { name => 'peers' } ], output_template => "connected peers: %s ", perfdatas => [ - { label => 'peer_count', value => 'peers_absolute', template => '%d', min => 0 } + { label => 'peer_count', value => 'peers', template => '%d', min => 0 } ], } }, diff --git a/blockchain/parity/restapi/mode/parity.pm b/blockchain/parity/restapi/mode/parity.pm index 96daf87c1..3c75c70de 100644 --- a/blockchain/parity/restapi/mode/parity.pm +++ b/blockchain/parity/restapi/mode/parity.pm @@ -36,7 +36,7 @@ sub set_counters { ]; $self->{maps_counters}->{mempool} = [ - { label => 'tx_pending', nlabel => 'parity.pending.transactions', set => { + { label => 'mempool_tx_pending', nlabel => 'parity.pending.transactions', set => { key_values => [ { name => 'tx_pending' } ], output_template => "Pending transactions: %d", perfdatas => [ @@ -65,7 +65,7 @@ sub set_counters { $self->{maps_counters}->{peers} = [ { label => 'peers_connected', nlabel => 'parity.peers.connected', set => { key_values => [ { name => 'peers_connected' } ], - output_template => "Peers connected: %d", + output_template => "Connected peers: %d", perfdatas => [ { label => 'peers_connected', value => 'peers_connected', template => '%d', min => 0 } ], @@ -81,7 +81,7 @@ sub set_counters { }, { label => 'peers_usage', nlabel => 'parity.peers.usage', set => { key_values => [ { name => 'peers_usage' } ], - output_template => "Mempool usage: %d %% ", + output_template => "Peers usage: %d %% ", perfdatas => [ { label => 'peers_usage', value => 'peers_usage', template => '%d', min => 0 } ], @@ -91,6 +91,16 @@ sub set_counters { } +sub custom_peers_output { + my ($self, %options) = @_; + + return sprintf( + "Connected peers: %d / %d", + $self->{result_values}->{peers_connected}, + $self->{result_values}->{peers_limit} + ); +} + sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1, statefile => 1); @@ -162,19 +172,13 @@ sub manage_selection { # use Data::Dumper; # print Dumper($result); - $self->{output}->output_add(long_msg => "Config: [chain name: " . @{$result}[1]->{result} . "] [parity version: " . $res_parity_version . "] [version_hash: " - . @{$result}[0]->{result}->{hash} . "]", severity => 'OK'); - $self->{output}->output_add(long_msg => "Network: [peers_connected: " . @{$result}[3]->{result}->{connected} . "] [peers_max: " . @{$result}[3]->{result}->{max} . "] [peers: " - . scalar(@{$$result[3]->{result}->{peers}}) . "]", severity => 'OK'); - $self->{output}->output_add(long_msg => "Node: [node_name: " . @{$result}[5]->{result} . "] [enode: " . @{$result}[4]->{result} . "]", severity => 'OK'); - $self->{output}->output_add(long_msg => "Mempool: [pending_transactions: " . scalar(@{$$result[2]->{result}}) . "] [transactions_limit: " . @{$result}[6]->{result} . "]", severity => 'OK'); - $self->{mempool} = { mempool_usage => scalar(@{$$result[2]->{result}}) / @{$result}[6]->{result} * 100, #TO CHECK division entière mempool_size => @{$result}[6]->{result}, tx_pending => scalar(@{$$result[2]->{result}}) }; $self->{peers} = { peers_usage => @{$result}[3]->{result}->{connected} / @{$result}[3]->{result}->{max} * 100, #TO CHECK division entière peers_max => @{$result}[3]->{result}->{max}, + peers_limit => @{$result}[3]->{result}->{max}, peers_connected => @{$result}[3]->{result}->{connected} }; } From bcf4e19365707de7922dc871b387a9c0c768a2c0 Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Tue, 26 May 2020 16:11:10 +0000 Subject: [PATCH 267/283] add unit to some perfdatas --- blockchain/parity/ethpoller/mode/disk.pm | 4 ++-- blockchain/parity/ethpoller/mode/tracking.pm | 2 +- blockchain/parity/ethpoller/plugin.pm | 2 +- blockchain/parity/restapi/mode/eth.pm | 2 +- blockchain/parity/restapi/mode/parity.pm | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/blockchain/parity/ethpoller/mode/disk.pm b/blockchain/parity/ethpoller/mode/disk.pm index 12a953d49..092ef0e41 100644 --- a/blockchain/parity/ethpoller/mode/disk.pm +++ b/blockchain/parity/ethpoller/mode/disk.pm @@ -63,7 +63,7 @@ sub set_counters { key_values => [ { name => 'disk_used' } ], output_template => "Disk used: %d ", perfdatas => [ - { label => 'disk_used', value => 'disk_used', template => '%d', min => 0 } + { label => 'disk_used', value => 'disk_used', template => '%d', unit => 'o', min => 0 } ], } }, @@ -71,7 +71,7 @@ sub set_counters { key_values => [ { name => 'disk_usage' } ], output_template => "Disk usage: %d %%", perfdatas => [ - { label => 'disk_usage', value => 'disk_usage', template => '%d', min => 0 } + { label => 'disk_usage', value => 'disk_usage', template => '%.2f', unit => '%', min => 0 } ], } }, diff --git a/blockchain/parity/ethpoller/mode/tracking.pm b/blockchain/parity/ethpoller/mode/tracking.pm index 0fa2dfc51..4d5309e9e 100644 --- a/blockchain/parity/ethpoller/mode/tracking.pm +++ b/blockchain/parity/ethpoller/mode/tracking.pm @@ -80,7 +80,7 @@ sub set_counters { sub prefix_output_balances { my ($self, %options) = @_; - return "*Balance* '" . $options{instance_value}->{display} . "' "; + return "Balance '" . $options{instance_value}->{display} . "' "; } sub prefix_output_events { diff --git a/blockchain/parity/ethpoller/plugin.pm b/blockchain/parity/ethpoller/plugin.pm index d28ab211d..ec1d68a16 100644 --- a/blockchain/parity/ethpoller/plugin.pm +++ b/blockchain/parity/ethpoller/plugin.pm @@ -36,7 +36,7 @@ sub new { 'stats' => 'blockchain::parity::ethpoller::mode::stats', 'disk' => 'blockchain::parity::ethpoller::mode::disk', 'tracking' => 'blockchain::parity::ethpoller::mode::tracking', - 'prct' => 'blockchain::parity::ethpoller::mode::prct' + # 'prct' => 'blockchain::parity::ethpoller::mode::prct' ); $self->{custom_modes}{api} = 'blockchain::parity::ethpoller::custom::api'; return $self; diff --git a/blockchain/parity/restapi/mode/eth.pm b/blockchain/parity/restapi/mode/eth.pm index 5dba7d513..923c2f916 100644 --- a/blockchain/parity/restapi/mode/eth.pm +++ b/blockchain/parity/restapi/mode/eth.pm @@ -97,7 +97,7 @@ sub set_counters { key_values => [ { name => 'block_usage' } ], output_template => "Block usage: %d %%", perfdatas => [ - { label => 'block_usage', value => 'block_usage', template => '%d', min => 0 } + { label => 'block_usage', value => 'block_usage', template => '%.2f', unit => '%', min => 0 } ], } }, diff --git a/blockchain/parity/restapi/mode/parity.pm b/blockchain/parity/restapi/mode/parity.pm index 3c75c70de..1e9206359 100644 --- a/blockchain/parity/restapi/mode/parity.pm +++ b/blockchain/parity/restapi/mode/parity.pm @@ -56,7 +56,7 @@ sub set_counters { key_values => [ { name => 'mempool_usage' } ], output_template => "Mempool usage: %d %% ", perfdatas => [ - { label => 'mempool_usage', value => 'mempool_usage', template => '%d', min => 0 } + { label => 'mempool_usage', value => 'mempool_usage', template => '%.2f', unit => '%', min => 0 } ], } }, @@ -83,7 +83,7 @@ sub set_counters { key_values => [ { name => 'peers_usage' } ], output_template => "Peers usage: %d %% ", perfdatas => [ - { label => 'peers_usage', value => 'peers_usage', template => '%d', min => 0 } + { label => 'peers_usage', value => 'peers_usage', template => '%.2f', unit => '%', min => 0 } ], } }, From cc39987318a6d4f2a425d89c913e78e81c7ab9f3 Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Tue, 26 May 2020 16:24:54 +0000 Subject: [PATCH 268/283] remove time elapsed --- blockchain/parity/ethpoller/mode/stats.pm | 26 ++++++++------------ blockchain/parity/ethpoller/mode/tracking.pm | 15 +++-------- 2 files changed, 14 insertions(+), 27 deletions(-) diff --git a/blockchain/parity/ethpoller/mode/stats.pm b/blockchain/parity/ethpoller/mode/stats.pm index 09cccdd5a..2da5bce2b 100644 --- a/blockchain/parity/ethpoller/mode/stats.pm +++ b/blockchain/parity/ethpoller/mode/stats.pm @@ -25,7 +25,7 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; use bigint; -use Time::Seconds; +# use Time::Seconds; use Digest::MD5 qw(md5_hex); sub set_counters { @@ -77,14 +77,14 @@ sub custom_block_output { if (0 eq $self->{result_values}->{block_count}) { return sprintf("No block yet..."); } else { - my $time_elapsed = time() - $self->{result_values}->{last_block_ts}; - my $t = Time::Seconds->new($time_elapsed); + # my $time_elapsed = time() - $self->{result_values}->{last_block_ts}; + # my $t = Time::Seconds->new($time_elapsed); return sprintf( - "Block frequency: '%.2f/min', Last block (#%s) was %s ago", + "Block frequency: '%.2f/min', Last block (#%s)",# was %s ago", $self->{result_values}->{block_count}, $self->{result_values}->{last_block}, - $t->pretty + # $t->pretty ); } } @@ -95,14 +95,11 @@ sub custom_transaction_output { if (0 eq $self->{result_values}->{transaction_count}) { return sprintf("No transaction yet..."); } else { - my $time_elapsed = time() - $self->{result_values}->{last_transaction_ts}; - my $t = Time::Seconds->new($time_elapsed); return sprintf( - "Transaction frequency: '%.2f/min', Last transaction (#%s) was %s ago", + "Transaction frequency: '%.2f/min', Last transaction (#%s)", $self->{result_values}->{transaction_count}, - $self->{result_values}->{last_transaction}, - $t->pretty + $self->{result_values}->{last_transaction} ); } } @@ -113,14 +110,11 @@ sub custom_fork_output { if (0 eq $self->{result_values}->{fork_count}) { return sprintf("No fork occurred yet..."); } else { - my $time_elapsed = time() - $self->{result_values}->{last_fork_ts}; - my $t = Time::Seconds->new($time_elapsed); - + return sprintf( - "Fork frequency: '%.2f/min', Last fork (#%s) was %s ago", + "Fork frequency: '%.2f/min', Last fork (#%s)", $self->{result_values}->{fork_count}, - $self->{result_values}->{last_fork}, - $t->pretty + $self->{result_values}->{last_fork} ); } } diff --git a/blockchain/parity/ethpoller/mode/tracking.pm b/blockchain/parity/ethpoller/mode/tracking.pm index 4d5309e9e..7a4db61e6 100644 --- a/blockchain/parity/ethpoller/mode/tracking.pm +++ b/blockchain/parity/ethpoller/mode/tracking.pm @@ -25,7 +25,6 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; use bigint; -use Time::Seconds; use Digest::MD5 qw(md5_hex); sub set_counters { @@ -124,14 +123,11 @@ sub custom_event_output { if (0 eq $self->{result_values}->{last_event}) { return sprintf("No event yet..."); } else { - my $time_elapsed = time() - $self->{result_values}->{last_event_ts}; - my $t = Time::Seconds->new($time_elapsed); - + return sprintf( - "Event frequency: %.2f/min, Last event (#%s) was %s ago in block #%s", + "Event frequency: %.2f/min, Last event (#%s) was in block #%s", $self->{result_values}->{event_count}, $self->{result_values}->{last_event}, - $t->pretty, $self->{result_values}->{last_event_block} ); } @@ -143,14 +139,11 @@ sub custom_miner_output { if (0 eq $self->{result_values}->{last_mining}) { return sprintf("No validation yet..."); } else { - my $time_elapsed = time() - $self->{result_values}->{last_mining_ts}; - my $t = Time::Seconds->new($time_elapsed); - + return sprintf( - "Mining frequency: %.2f/min, Last validation (#%s) was %s ago for block #%s", + "Mining frequency: %.2f/min, Last validation (#%s) ago for block #%s", $self->{result_values}->{mining_count}, $self->{result_values}->{last_mining}, - $t->pretty, $self->{result_values}->{last_mining_block} ); } From 44d3a0fec72864df4a9e9ef3257faf17765f1374 Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Tue, 26 May 2020 16:33:04 +0000 Subject: [PATCH 269/283] add disk size unit --- blockchain/parity/ethpoller/mode/disk.pm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/blockchain/parity/ethpoller/mode/disk.pm b/blockchain/parity/ethpoller/mode/disk.pm index 092ef0e41..e3b5a73f5 100644 --- a/blockchain/parity/ethpoller/mode/disk.pm +++ b/blockchain/parity/ethpoller/mode/disk.pm @@ -39,7 +39,7 @@ sub set_counters { key_values => [ { name => 'disk_free' } ], output_template => "Disk free: %d ", perfdatas => [ - { label => 'disk_free', value => 'disk_free', template => '%d', min => 0 } + { label => 'disk_free', value => 'disk_free', unit => 'B', template => '%d', min => 0 } ], } }, @@ -47,7 +47,7 @@ sub set_counters { key_values => [ { name => 'disk_available' } ], output_template => "Disk available: %d ", perfdatas => [ - { label => 'disk_available', value => 'disk_available', template => '%d', min => 0 } + { label => 'disk_available', value => 'disk_available', unit => 'B', template => '%d', min => 0 } ], } }, @@ -55,7 +55,7 @@ sub set_counters { key_values => [ { name => 'disk_size' } ], output_template => "Disk size: %d ", perfdatas => [ - { label => 'disk_size', value => 'disk_size', template => '%d', min => 0 } + { label => 'disk_size', value => 'disk_size', template => '%d', unit => 'B', min => 0 } ], } }, @@ -63,7 +63,7 @@ sub set_counters { key_values => [ { name => 'disk_used' } ], output_template => "Disk used: %d ", perfdatas => [ - { label => 'disk_used', value => 'disk_used', template => '%d', unit => 'o', min => 0 } + { label => 'disk_used', value => 'disk_used', template => '%d', unit => 'B', min => 0 } ], } }, @@ -79,7 +79,7 @@ sub set_counters { key_values => [ { name => 'blockchain_dir' } ], output_template => "Blockchain directory: %d", perfdatas => [ - { label => 'blockchain_dir', value => 'blockchain_dir', template => '%d', min => 0 } + { label => 'blockchain_dir', value => 'blockchain_dir', unit => 'B', template => '%d', min => 0 } ], } } From 1d8af71cd8a063ed26d1067464c381b90405b7db Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Tue, 26 May 2020 16:55:24 +0000 Subject: [PATCH 270/283] ratio update --- blockchain/parity/restapi/mode/eth.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blockchain/parity/restapi/mode/eth.pm b/blockchain/parity/restapi/mode/eth.pm index 923c2f916..8a97cfbec 100644 --- a/blockchain/parity/restapi/mode/eth.pm +++ b/blockchain/parity/restapi/mode/eth.pm @@ -208,7 +208,7 @@ sub manage_selection { gas_used => hex(@{$result}[5]->{result}->{gasUsed}), gas_limit => hex(@{$result}[5]->{result}->{gasLimit}) }; - my $calculated_block_usage = hex(@{$result}[5]->{result}->{gasUsed}) / hex(@{$result}[5]->{result}->{gasLimit}); + my $calculated_block_usage = hex(@{$result}[5]->{result}->{gasUsed}) / hex(@{$result}[5]->{result}->{gasLimit}) * 100; $self->{block} = { block_size => hex(@{$result}[5]->{result}->{size}), block_gas => hex(@{$result}[5]->{result}->{gasUsed}), block_usage => $calculated_block_usage, From fe62d9ea949a544563cc79a955f722205a6b15d1 Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Tue, 26 May 2020 17:09:02 +0000 Subject: [PATCH 271/283] debug output --- blockchain/parity/restapi/mode/eth.pm | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/blockchain/parity/restapi/mode/eth.pm b/blockchain/parity/restapi/mode/eth.pm index 8a97cfbec..00b4f3b8c 100644 --- a/blockchain/parity/restapi/mode/eth.pm +++ b/blockchain/parity/restapi/mode/eth.pm @@ -173,9 +173,7 @@ sub manage_selection { my $gas_price = hex(@{$result}[2]->{result}); my $res_block_time = @{$result}[5]->{result}->{timestamp} == 0 ? '': localtime(hex(@{$result}[5]->{result}->{timestamp})); - # use Data::Dumper; - # print Dumper($res_block_time) ; - # print Dumper(@{$result}[5]->{result}->{timestamp}); + # conditional formating: my $res_sync = @{$result}[6]->{result} ? hex((@{$result}[6]->{result}->{currentBlock} / @{$result}[6]->{result}->{highestBlock})) * 100 : 100; @@ -209,6 +207,12 @@ sub manage_selection { gas_limit => hex(@{$result}[5]->{result}->{gasLimit}) }; my $calculated_block_usage = hex(@{$result}[5]->{result}->{gasUsed}) / hex(@{$result}[5]->{result}->{gasLimit}) * 100; + + use Data::Dumper; + print Dumper($calculated_block_usage) ; + print Dumper(hex(@{$result}[5]->{result}->{gasUsed})); + print Dumper(hex(@{$result}[5]->{result}->{gasLimit})); + $self->{block} = { block_size => hex(@{$result}[5]->{result}->{size}), block_gas => hex(@{$result}[5]->{result}->{gasUsed}), block_usage => $calculated_block_usage, From c3da5a6927dd5f5a12e81bb7f2207a93ed858950 Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Tue, 26 May 2020 17:30:43 +0000 Subject: [PATCH 272/283] short_msg --- blockchain/parity/restapi/mode/infos.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blockchain/parity/restapi/mode/infos.pm b/blockchain/parity/restapi/mode/infos.pm index c93eee5ab..215f85550 100644 --- a/blockchain/parity/restapi/mode/infos.pm +++ b/blockchain/parity/restapi/mode/infos.pm @@ -86,7 +86,7 @@ sub manage_selection { # $cache->set('peers_count', $peer_count); # } - $self->{output}->output_add(long_msg => "Parity version: '" . $res_parity_version . "'. Chain name: '" . @{$result}[1]->{result} . + $self->{output}->output_add(short_msg => "Parity version: '" . $res_parity_version . "'. Chain name: '" . @{$result}[1]->{result} . "'. Node name: '" . @{$result}[3]->{result} . "'. is_validator: '" . @{$result}[2]->{result} . "'.", severity => 'OK'); } From 7cec98def0cd58a958f03244b2f207f9e320a9b7 Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Tue, 26 May 2020 17:31:23 +0000 Subject: [PATCH 273/283] remove print debug --- blockchain/parity/restapi/mode/eth.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/blockchain/parity/restapi/mode/eth.pm b/blockchain/parity/restapi/mode/eth.pm index 00b4f3b8c..4c5226ba2 100644 --- a/blockchain/parity/restapi/mode/eth.pm +++ b/blockchain/parity/restapi/mode/eth.pm @@ -208,10 +208,10 @@ sub manage_selection { my $calculated_block_usage = hex(@{$result}[5]->{result}->{gasUsed}) / hex(@{$result}[5]->{result}->{gasLimit}) * 100; - use Data::Dumper; - print Dumper($calculated_block_usage) ; - print Dumper(hex(@{$result}[5]->{result}->{gasUsed})); - print Dumper(hex(@{$result}[5]->{result}->{gasLimit})); + # use Data::Dumper; + # print Dumper($calculated_block_usage) ; + # print Dumper(hex(@{$result}[5]->{result}->{gasUsed})); + # print Dumper(hex(@{$result}[5]->{result}->{gasLimit})); $self->{block} = { block_size => hex(@{$result}[5]->{result}->{size}), block_gas => hex(@{$result}[5]->{result}->{gasUsed}), From 8434d52901060d0f28487bd157200783678ba165 Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Thu, 28 May 2020 13:22:20 +0000 Subject: [PATCH 274/283] change underscors to dash in counters --- blockchain/parity/ethpoller/mode/disk.pm | 12 ++++++------ blockchain/parity/restapi/mode/eth.pm | 18 +++++++++--------- blockchain/parity/restapi/mode/parity.pm | 12 ++++++------ 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/blockchain/parity/ethpoller/mode/disk.pm b/blockchain/parity/ethpoller/mode/disk.pm index e3b5a73f5..8d5c80884 100644 --- a/blockchain/parity/ethpoller/mode/disk.pm +++ b/blockchain/parity/ethpoller/mode/disk.pm @@ -35,7 +35,7 @@ sub set_counters { ]; $self->{maps_counters}->{global} = [ - { label => 'disk_free', nlabel => 'eth.poller.disk.free', set => { + { label => 'disk-free', nlabel => 'eth.poller.disk.free', set => { key_values => [ { name => 'disk_free' } ], output_template => "Disk free: %d ", perfdatas => [ @@ -43,7 +43,7 @@ sub set_counters { ], } }, - { label => 'disk_available', nlabel => 'eth.poller.disk.available', set => { + { label => 'disk-available', nlabel => 'eth.poller.disk.available', set => { key_values => [ { name => 'disk_available' } ], output_template => "Disk available: %d ", perfdatas => [ @@ -51,7 +51,7 @@ sub set_counters { ], } }, - { label => 'disk_size', nlabel => 'eth.poller.disk.size', set => { + { label => 'disk-size', nlabel => 'eth.poller.disk.size', set => { key_values => [ { name => 'disk_size' } ], output_template => "Disk size: %d ", perfdatas => [ @@ -59,7 +59,7 @@ sub set_counters { ], } }, - { label => 'disk_used', nlabel => 'eth.poller.disk.used', set => { + { label => 'disk-used', nlabel => 'eth.poller.disk.used', set => { key_values => [ { name => 'disk_used' } ], output_template => "Disk used: %d ", perfdatas => [ @@ -67,7 +67,7 @@ sub set_counters { ], } }, - { label => 'disk_usage', nlabel => 'eth.poller.disk.usage', set => { + { label => 'disk-usage', nlabel => 'eth.poller.disk.usage', set => { key_values => [ { name => 'disk_usage' } ], output_template => "Disk usage: %d %%", perfdatas => [ @@ -75,7 +75,7 @@ sub set_counters { ], } }, - { label => 'blockchain_dir', nlabel => 'eth.poller.blockchain.directory', set => { + { label => 'blockchain-dir', nlabel => 'eth.poller.blockchain.directory', set => { key_values => [ { name => 'blockchain_dir' } ], output_template => "Blockchain directory: %d", perfdatas => [ diff --git a/blockchain/parity/restapi/mode/eth.pm b/blockchain/parity/restapi/mode/eth.pm index 4c5226ba2..cac93b2df 100644 --- a/blockchain/parity/restapi/mode/eth.pm +++ b/blockchain/parity/restapi/mode/eth.pm @@ -47,7 +47,7 @@ sub set_counters { ]; $self->{maps_counters}->{sync} = [ - { label => 'sync_status', nlabel => 'parity.eth.sync.status', set => { + { label => 'sync-status', nlabel => 'parity.eth.sync.status', set => { key_values => [ { name => 'sync_status' } ], output_template => "Syncing: %d %% ", perfdatas => [ @@ -58,7 +58,7 @@ sub set_counters { ]; $self->{maps_counters}->{gas} = [ - { label => 'gas_price', nlabel => 'parity.eth.gas.price', set => { + { label => 'gas-price', nlabel => 'parity.eth.gas.price', set => { key_values => [ { name => 'gas_price' } ], output_template => "The gas price is: %d wei ", perfdatas => [ @@ -66,7 +66,7 @@ sub set_counters { ], } }, - { label => 'gas_used', nlabel => 'parity.eth.gas.used', set => { + { label => 'gas-used', nlabel => 'parity.eth.gas.used', set => { key_values => [ { name => 'gas_used' } ], output_template => "The gas used is: %d", perfdatas => [ @@ -74,7 +74,7 @@ sub set_counters { ], } }, - { label => 'gas_limit', nlabel => 'parity.eth.gas.limit', set => { + { label => 'gas-limit', nlabel => 'parity.eth.gas.limit', set => { key_values => [ { name => 'gas_limit' } ], output_template => "The gas limit is: %d", perfdatas => [ @@ -85,7 +85,7 @@ sub set_counters { ]; $self->{maps_counters}->{block} = [ - { label => 'block_size', nlabel => 'parity.eth.block.size', set => { + { label => 'block-size', nlabel => 'parity.eth.block.size', set => { key_values => [ { name => 'block_size' } ], output_template => "Block size: %d ", perfdatas => [ @@ -93,7 +93,7 @@ sub set_counters { ], } }, - { label => 'block_usage', nlabel => 'parity.eth.block.usage', set => { + { label => 'block-usage', nlabel => 'parity.eth.block.usage', set => { key_values => [ { name => 'block_usage' } ], output_template => "Block usage: %d %%", perfdatas => [ @@ -101,7 +101,7 @@ sub set_counters { ], } }, - { label => 'block_transactions', nlabel => 'parity.eth.block.transactions.number', set => { + { label => 'block-transactions', nlabel => 'parity.eth.block.transactions.number', set => { key_values => [ { name => 'block_transactions' } ], output_template => "Block transactions number: %d ", perfdatas => [ @@ -109,7 +109,7 @@ sub set_counters { ], } }, - { label => 'block_gas', nlabel => 'parity.eth.block.gas', set => { + { label => 'block-gas', nlabel => 'parity.eth.block.gas', set => { key_values => [ { name => 'block_gas' } ], output_template => "Block gas: %d ", perfdatas => [ @@ -117,7 +117,7 @@ sub set_counters { ], } }, - { label => 'block_uncles', nlabel => 'parity.eth.block.uncles', set => { + { label => 'block-uncles', nlabel => 'parity.eth.block.uncles', set => { key_values => [ { name => 'block_uncles' } ], output_template => "Block uncles: %d ", perfdatas => [ diff --git a/blockchain/parity/restapi/mode/parity.pm b/blockchain/parity/restapi/mode/parity.pm index 1e9206359..f62eb82e0 100644 --- a/blockchain/parity/restapi/mode/parity.pm +++ b/blockchain/parity/restapi/mode/parity.pm @@ -36,7 +36,7 @@ sub set_counters { ]; $self->{maps_counters}->{mempool} = [ - { label => 'mempool_tx_pending', nlabel => 'parity.pending.transactions', set => { + { label => 'mempool-tx-pending', nlabel => 'parity.pending.transactions', set => { key_values => [ { name => 'tx_pending' } ], output_template => "Pending transactions: %d", perfdatas => [ @@ -44,7 +44,7 @@ sub set_counters { ], } }, - { label => 'mempool_size', nlabel => 'parity.mempol.size', set => { + { label => 'mempool-size', nlabel => 'parity.mempol.size', set => { key_values => [ { name => 'mempool_size' } ], output_template => "Mempool size: %d", perfdatas => [ @@ -52,7 +52,7 @@ sub set_counters { ], } }, - { label => 'mempool_usage', nlabel => 'parity.mempol.usage', set => { + { label => 'mempool-usage', nlabel => 'parity.mempol.usage', set => { key_values => [ { name => 'mempool_usage' } ], output_template => "Mempool usage: %d %% ", perfdatas => [ @@ -63,7 +63,7 @@ sub set_counters { ]; $self->{maps_counters}->{peers} = [ - { label => 'peers_connected', nlabel => 'parity.peers.connected', set => { + { label => 'peers-connected', nlabel => 'parity.peers.connected', set => { key_values => [ { name => 'peers_connected' } ], output_template => "Connected peers: %d", perfdatas => [ @@ -71,7 +71,7 @@ sub set_counters { ], } }, - { label => 'peers_max', nlabel => 'parity.peers.max', set => { + { label => 'peers-max', nlabel => 'parity.peers.max', set => { key_values => [ { name => 'peers_max' } ], output_template => "Peers max: %d", perfdatas => [ @@ -79,7 +79,7 @@ sub set_counters { ], } }, - { label => 'peers_usage', nlabel => 'parity.peers.usage', set => { + { label => 'peers-usage', nlabel => 'parity.peers.usage', set => { key_values => [ { name => 'peers_usage' } ], output_template => "Peers usage: %d %% ", perfdatas => [ From 78e7a839e09ecf2b3534e881b55f10f3deb596b7 Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Sat, 30 May 2020 09:52:39 +0000 Subject: [PATCH 275/283] add tracking::mining-prct --- blockchain/parity/ethpoller/mode/tracking.pm | 53 +++++++++++++++++--- blockchain/parity/restapi/mode/eth.pm | 2 +- 2 files changed, 47 insertions(+), 8 deletions(-) diff --git a/blockchain/parity/ethpoller/mode/tracking.pm b/blockchain/parity/ethpoller/mode/tracking.pm index 7a4db61e6..0ba1bdc59 100644 --- a/blockchain/parity/ethpoller/mode/tracking.pm +++ b/blockchain/parity/ethpoller/mode/tracking.pm @@ -25,6 +25,7 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; use bigint; +use Math::BigFloat; use Digest::MD5 qw(md5_hex); sub set_counters { @@ -57,6 +58,18 @@ sub set_counters { { template => '%.2f', label_extra_instance => 1, instance_use => 'display' } ] } + }, + { label => 'mining-prct', nlabel => 'parity.tracking.mined.block.prct', display_ok => 0, set => { + key_values => [], + manual_keys => 1, + closure_custom_calc => $self->can('custom_mining_prct_calc'), + closure_custom_output => $self->can('custom_mining_prct_output'), + threshold_use => 'mining_prct', + perfdatas => [ + { value => 'mining_prct', template => '%.2f', unit => '%', + min => 0, label_extra_instance => 1, instance_use => 'display' } + ], + } } ]; @@ -64,8 +77,8 @@ sub set_counters { { label => 'balance-fluctuation-prct', nlabel => 'parity.tracking.balances.fluctuation', display_ok => 0, set => { key_values => [], manual_keys => 1, - closure_custom_calc => $self->can('custom_prct_calc'), - closure_custom_output => $self->can('custom_balance_output'), + closure_custom_calc => $self->can('custom_balance_prct_calc'), + closure_custom_output => $self->can('custom_balance_prct_output'), threshold_use => 'balance_fluctuation_prct', perfdatas => [ { value => 'balance_fluctuation_prct', template => '%.2f', unit => '%', @@ -94,7 +107,31 @@ sub prefix_output_mining { return "Miner '" . $options{instance_value}->{display} . "' "; } -sub custom_balance_output { +sub custom_mining_prct_output { + my ($self, %options) = @_; + + return sprintf( + "Mined: %d blocks, witch corresponds to %.2f %% of total validated block", + $self->{result_values}->{mined_block_count}, + $self->{result_values}->{mining_prct} + ); +} + +sub custom_mining_prct_calc { + my ($self, %options) = @_; + + $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; + $self->{result_values}->{mined_block_count} = Math::BigFloat->new($options{new_datas}->{$self->{instance} . '_mined_block_count'}); + $self->{result_values}->{total_block} = Math::BigFloat->new($options{new_datas}->{$self->{instance} . '_total_block'}); + $self->{result_values}->{mining_prct} = (defined($self->{result_values}->{total_block}) && $self->{result_values}->{total_block} != 0) ? + $self->{result_values}->{mined_block_count} / $self->{result_values}->{total_block} * 100 : 0; + use Data::Dumper; + print Dumper($self->{result_values}->{mined_block_count}); + print Dumper($self->{result_values}->{total_block}); + return 0; +} + +sub custom_balance_prct_output { my ($self, %options) = @_; return sprintf( @@ -104,12 +141,12 @@ sub custom_balance_output { ); } -sub custom_prct_calc { +sub custom_balance_prct_calc { my ($self, %options) = @_; $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; - $self->{result_values}->{balance} = $options{new_datas}->{$self->{instance} . '_balance'}; - $self->{result_values}->{balance_old} = $options{old_datas}->{$self->{instance} . '_balance'}; + $self->{result_values}->{balance} = Math::BigFloat->new($options{new_datas}->{$self->{instance} . '_balance'}); + $self->{result_values}->{balance_old} = Math::BigFloat->new($options{old_datas}->{$self->{instance} . '_balance'}); $self->{result_values}->{balance_fluctuation_prct} = (defined($self->{result_values}->{balance_old}) && $self->{result_values}->{balance_old} != 0) ? ($self->{result_values}->{balance} - $self->{result_values}->{balance_old}) / $self->{result_values}->{balance_old} * 100 : 0; @@ -205,7 +242,9 @@ sub manage_selection { mining_count => $miner->{count}, last_mining => $miner->{count}, last_mining_block => $miner->{block}, - last_mining_ts => $last_mining_timestamp + last_mining_ts => $last_mining_timestamp, + total_block => $miner->{currentBlock}, + mined_block_count => $miner->{count} }; } diff --git a/blockchain/parity/restapi/mode/eth.pm b/blockchain/parity/restapi/mode/eth.pm index cac93b2df..58a5a4e40 100644 --- a/blockchain/parity/restapi/mode/eth.pm +++ b/blockchain/parity/restapi/mode/eth.pm @@ -95,7 +95,7 @@ sub set_counters { }, { label => 'block-usage', nlabel => 'parity.eth.block.usage', set => { key_values => [ { name => 'block_usage' } ], - output_template => "Block usage: %d %%", + output_template => "Block usage: %.2f %%", perfdatas => [ { label => 'block_usage', value => 'block_usage', template => '%.2f', unit => '%', min => 0 } ], From 2c2a12c4773e9f4e890254f2cc3afdecf38c5f9b Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Sat, 30 May 2020 10:03:10 +0000 Subject: [PATCH 276/283] remove useless print --- blockchain/parity/ethpoller/mode/tracking.pm | 3 --- 1 file changed, 3 deletions(-) diff --git a/blockchain/parity/ethpoller/mode/tracking.pm b/blockchain/parity/ethpoller/mode/tracking.pm index 0ba1bdc59..72cdb5ff4 100644 --- a/blockchain/parity/ethpoller/mode/tracking.pm +++ b/blockchain/parity/ethpoller/mode/tracking.pm @@ -125,9 +125,6 @@ sub custom_mining_prct_calc { $self->{result_values}->{total_block} = Math::BigFloat->new($options{new_datas}->{$self->{instance} . '_total_block'}); $self->{result_values}->{mining_prct} = (defined($self->{result_values}->{total_block}) && $self->{result_values}->{total_block} != 0) ? $self->{result_values}->{mined_block_count} / $self->{result_values}->{total_block} * 100 : 0; - use Data::Dumper; - print Dumper($self->{result_values}->{mined_block_count}); - print Dumper($self->{result_values}->{total_block}); return 0; } From f7274f454b13e593bf46c20c16b2ded2bddb1bce Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Wed, 24 Jun 2020 16:04:38 +0000 Subject: [PATCH 277/283] remove useless unit --- blockchain/parity/ethpoller/mode/disk.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blockchain/parity/ethpoller/mode/disk.pm b/blockchain/parity/ethpoller/mode/disk.pm index 8d5c80884..52aa8d6e6 100644 --- a/blockchain/parity/ethpoller/mode/disk.pm +++ b/blockchain/parity/ethpoller/mode/disk.pm @@ -79,7 +79,7 @@ sub set_counters { key_values => [ { name => 'blockchain_dir' } ], output_template => "Blockchain directory: %d", perfdatas => [ - { label => 'blockchain_dir', value => 'blockchain_dir', unit => 'B', template => '%d', min => 0 } + { label => 'blockchain_dir', value => 'blockchain_dir', template => '%d', min => 0 } ], } } From 4a9efe8f490c1fc747ddfb15d4d8acec0a359564 Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Wed, 24 Jun 2020 16:55:20 +0000 Subject: [PATCH 278/283] change balance fluctuation to balance changes --- blockchain/parity/ethpoller/mode/tracking.pm | 47 +++++++++++++++----- 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/blockchain/parity/ethpoller/mode/tracking.pm b/blockchain/parity/ethpoller/mode/tracking.pm index 72cdb5ff4..0f47bef3b 100644 --- a/blockchain/parity/ethpoller/mode/tracking.pm +++ b/blockchain/parity/ethpoller/mode/tracking.pm @@ -74,18 +74,27 @@ sub set_counters { ]; $self->{maps_counters}->{balance} = [ - { label => 'balance-fluctuation-prct', nlabel => 'parity.tracking.balances.fluctuation', display_ok => 0, set => { - key_values => [], - manual_keys => 1, - closure_custom_calc => $self->can('custom_balance_prct_calc'), - closure_custom_output => $self->can('custom_balance_prct_output'), - threshold_use => 'balance_fluctuation_prct', + # { label => 'balance-fluctuation-prct', nlabel => 'parity.tracking.balances.fluctuation', display_ok => 0, set => { + # key_values => [], + # manual_keys => 1, + # closure_custom_calc => $self->can('custom_balance_prct_calc'), + # closure_custom_output => $self->can('custom_balance_prct_output'), + # threshold_use => 'balance_fluctuation_prct', + # perfdatas => [ + # { value => 'balance_fluctuation_prct', template => '%.2f', unit => '%', + # min => 0, label_extra_instance => 1, instance_use => 'display' } + # ], + # } + # } + { label => 'balance-changes', nlabel => 'parity.tracking.balance.changes.perminute', set => { + key_values => [ { name => 'balance_count', per_minute => 1 }, { name => 'display' }, + { name => 'last_balance' } ], + closure_custom_output => $self->can('custom_balance_output'), perfdatas => [ - { value => 'balance_fluctuation_prct', template => '%.2f', unit => '%', - min => 0, label_extra_instance => 1, instance_use => 'display' } - ], + { template => '%.2f', label_extra_instance => 1, unit => 'wei', instance_use => 'display' } + ] } - } + }, ]; } @@ -183,6 +192,21 @@ sub custom_miner_output { } } +sub custom_balance_output { + my ($self, %options) = @_; + + if (0 eq $self->{result_values}->{balance_count}) { + return sprintf("No change in balance. Balance still %s wei", + $self->{result_values}->{last_balance}); + } else { + return sprintf( + "Balance changes: %.2f/min. New balance: %s", + $self->{result_values}->{balance_count}, + $self->{result_values}->{last_balance} + ); + } +} + sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1, force_new_perfdata => 1); @@ -254,7 +278,8 @@ sub manage_selection { $self->{balance}->{lc($balance->{label})} = { display => lc($balance->{label}), - balance => $balance->{balance} + balance_count => $balance->{balance}, + last_balance => $balance->{balance} }; } From c0eafca4cb4a4928343d797b886ecf296e568abc Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Thu, 25 Jun 2020 07:50:03 +0000 Subject: [PATCH 279/283] restore unit --- blockchain/parity/ethpoller/mode/disk.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blockchain/parity/ethpoller/mode/disk.pm b/blockchain/parity/ethpoller/mode/disk.pm index 52aa8d6e6..8d5c80884 100644 --- a/blockchain/parity/ethpoller/mode/disk.pm +++ b/blockchain/parity/ethpoller/mode/disk.pm @@ -79,7 +79,7 @@ sub set_counters { key_values => [ { name => 'blockchain_dir' } ], output_template => "Blockchain directory: %d", perfdatas => [ - { label => 'blockchain_dir', value => 'blockchain_dir', template => '%d', min => 0 } + { label => 'blockchain_dir', value => 'blockchain_dir', unit => 'B', template => '%d', min => 0 } ], } } From 9f6a7e2472b6e265c2e0e6aac4bd3b0ccff3f7ba Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Thu, 25 Jun 2020 07:54:03 +0000 Subject: [PATCH 280/283] comment useless method and change balance output message --- blockchain/parity/ethpoller/mode/tracking.pm | 38 ++++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/blockchain/parity/ethpoller/mode/tracking.pm b/blockchain/parity/ethpoller/mode/tracking.pm index 0f47bef3b..652467f40 100644 --- a/blockchain/parity/ethpoller/mode/tracking.pm +++ b/blockchain/parity/ethpoller/mode/tracking.pm @@ -137,28 +137,28 @@ sub custom_mining_prct_calc { return 0; } -sub custom_balance_prct_output { - my ($self, %options) = @_; +# sub custom_balance_prct_output { +# my ($self, %options) = @_; - return sprintf( - "Balance: %s ether, Last fluctuation: %.2f ", - $self->{result_values}->{balance}, - $self->{result_values}->{balance_fluctuation_prct} - ); -} +# return sprintf( +# "Balance: %s ether, Last fluctuation: %.2f ", +# $self->{result_values}->{balance}, +# $self->{result_values}->{balance_fluctuation_prct} +# ); +# } -sub custom_balance_prct_calc { - my ($self, %options) = @_; +# sub custom_balance_prct_calc { +# my ($self, %options) = @_; - $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; - $self->{result_values}->{balance} = Math::BigFloat->new($options{new_datas}->{$self->{instance} . '_balance'}); - $self->{result_values}->{balance_old} = Math::BigFloat->new($options{old_datas}->{$self->{instance} . '_balance'}); - $self->{result_values}->{balance_fluctuation_prct} = (defined($self->{result_values}->{balance_old}) && $self->{result_values}->{balance_old} != 0) ? - ($self->{result_values}->{balance} - $self->{result_values}->{balance_old}) / - $self->{result_values}->{balance_old} * 100 : 0; +# $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; +# $self->{result_values}->{balance} = Math::BigFloat->new($options{new_datas}->{$self->{instance} . '_balance'}); +# $self->{result_values}->{balance_old} = Math::BigFloat->new($options{old_datas}->{$self->{instance} . '_balance'}); +# $self->{result_values}->{balance_fluctuation_prct} = (defined($self->{result_values}->{balance_old}) && $self->{result_values}->{balance_old} != 0) ? +# ($self->{result_values}->{balance} - $self->{result_values}->{balance_old}) / +# $self->{result_values}->{balance_old} * 100 : 0; - return 0; -} +# return 0; +# } sub custom_event_output { my ($self, %options) = @_; @@ -196,7 +196,7 @@ sub custom_balance_output { my ($self, %options) = @_; if (0 eq $self->{result_values}->{balance_count}) { - return sprintf("No change in balance. Balance still %s wei", + return sprintf("No change in balance in last minute. Balance still %s wei", $self->{result_values}->{last_balance}); } else { return sprintf( From 68764f9e0866189cdce1bac1b4ab3982ad98e2b7 Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Thu, 25 Jun 2020 08:41:45 +0000 Subject: [PATCH 281/283] exclude division by zero case --- blockchain/parity/restapi/mode/eth.pm | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/blockchain/parity/restapi/mode/eth.pm b/blockchain/parity/restapi/mode/eth.pm index 58a5a4e40..aca9d82b9 100644 --- a/blockchain/parity/restapi/mode/eth.pm +++ b/blockchain/parity/restapi/mode/eth.pm @@ -176,10 +176,18 @@ sub manage_selection { # conditional formating: - my $res_sync = @{$result}[6]->{result} ? hex((@{$result}[6]->{result}->{currentBlock} / @{$result}[6]->{result}->{highestBlock})) * 100 : 100; - my $res_startingBlock = $res_sync != 100 ? hex(@{$result}[6]->{result}->{startingBlock}) : 'none'; - my $res_currentBlock = $res_sync != 100 ? hex(@{$result}[6]->{result}->{currentBlock}) : 'none'; - my $res_highestBlock = $res_sync != 100 ? hex(@{$result}[6]->{result}->{highestBlock}) : 'none'; + my $res_sync = 100; + # my $res_startingBlock = 'none'; + # my $res_currentBlock = 'none'; + # my $res_highestBlock = 'none'; + + if (@{$result}[6]->{result}) { + my $res_sync = hex(@{$result}[6]->{result}->{highestBlock}) != 0 ? (hex(@{$result}[6]->{result}->{currentBlock}) * 100) / hex(@{$result}[6]->{result}->{highestBlock}) : 'none'; + # my $res_startingBlock = hex(@{$result}[6]->{result}->{startingBlock}); + # my $res_currentBlock = hex(@{$result}[6]->{result}->{currentBlock}); + # my $res_highestBlock = hex(@{$result}[6]->{result}->{highestBlock}); + } + # Alerts management # my $cache = Cache::File->new( cache_root => './parity-restapi-cache' ); From 27b35fce507e909f6f68bb3ded1c8d01bb15cdf0 Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Tue, 30 Jun 2020 10:30:24 +0000 Subject: [PATCH 282/283] add port number in cache file name to avoid conflicts --- blockchain/parity/ethpoller/mode/stats.pm | 1 + blockchain/parity/ethpoller/mode/tracking.pm | 3 ++- blockchain/parity/restapi/mode/eth.pm | 3 ++- blockchain/parity/restapi/mode/infos.pm | 3 ++- blockchain/parity/restapi/mode/parity.pm | 3 ++- 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/blockchain/parity/ethpoller/mode/stats.pm b/blockchain/parity/ethpoller/mode/stats.pm index 2da5bce2b..0037b4d8e 100644 --- a/blockchain/parity/ethpoller/mode/stats.pm +++ b/blockchain/parity/ethpoller/mode/stats.pm @@ -154,6 +154,7 @@ sub manage_selection { my ($self, %options) = @_; $self->{cache_name} = "parity_ethpoller_" . $self->{mode} . '_' . (defined($self->{option_results}->{hostname}) ? $self->{option_results}->{hostname} : 'me') . '_' . + (defined($self->{option_results}->{port}) ? $self->{option_results}->{port} : 'default') . '_' . (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); my $result = $options{custom}->request_api(url_path => '/stats'); diff --git a/blockchain/parity/ethpoller/mode/tracking.pm b/blockchain/parity/ethpoller/mode/tracking.pm index 652467f40..4304fb1e7 100644 --- a/blockchain/parity/ethpoller/mode/tracking.pm +++ b/blockchain/parity/ethpoller/mode/tracking.pm @@ -223,7 +223,8 @@ sub manage_selection { my ($self, %options) = @_; $self->{cache_name} = "parity_ethpoller_" . $self->{mode} . '_' . (defined($self->{option_results}->{hostname}) ? $self->{option_results}->{hostname} : 'me') . '_' . - (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); + (defined($self->{option_results}->{port}) ? $self->{option_results}->{port} : 'default') . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); my $results = $options{custom}->request_api(url_path => '/tracking'); diff --git a/blockchain/parity/restapi/mode/eth.pm b/blockchain/parity/restapi/mode/eth.pm index aca9d82b9..2e858b088 100644 --- a/blockchain/parity/restapi/mode/eth.pm +++ b/blockchain/parity/restapi/mode/eth.pm @@ -158,7 +158,8 @@ sub manage_selection { my ($self, %options) = @_; $self->{cache_name} = "parity_restapi_" . $self->{mode} . '_' . (defined($self->{option_results}->{hostname}) ? $self->{option_results}->{hostname} : 'me') . '_' . - (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); + (defined($self->{option_results}->{port}) ? $self->{option_results}->{port} : 'default') . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); my $query_form_post = [ { method => 'eth_mining', params => [], id => "1", jsonrpc => "2.0" }, { method => 'eth_coinbase', params => [], id => "2", jsonrpc => "2.0" }, diff --git a/blockchain/parity/restapi/mode/infos.pm b/blockchain/parity/restapi/mode/infos.pm index 215f85550..0721d8c75 100644 --- a/blockchain/parity/restapi/mode/infos.pm +++ b/blockchain/parity/restapi/mode/infos.pm @@ -57,7 +57,8 @@ sub manage_selection { my ($self, %options) = @_; $self->{cache_name} = "parity_restapi_" . $self->{mode} . '_' . (defined($self->{option_results}->{hostname}) ? $self->{option_results}->{hostname} : 'me') . '_' . - (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); + (defined($self->{option_results}->{port}) ? $self->{option_results}->{port} : 'default') . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); my $query_form_post = [ { method => 'parity_versionInfo', params => [], id => "1", jsonrpc => "2.0" }, { method => 'parity_chain', params => [], id => "2", jsonrpc => "2.0" }, diff --git a/blockchain/parity/restapi/mode/parity.pm b/blockchain/parity/restapi/mode/parity.pm index f62eb82e0..a0e18d0c3 100644 --- a/blockchain/parity/restapi/mode/parity.pm +++ b/blockchain/parity/restapi/mode/parity.pm @@ -131,7 +131,8 @@ sub manage_selection { my ($self, %options) = @_; $self->{cache_name} = "parity_restapi_" . $self->{mode} . '_' . (defined($self->{option_results}->{hostname}) ? $self->{option_results}->{hostname} : 'me') . '_' . - (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); + (defined($self->{option_results}->{port}) ? $self->{option_results}->{port} : 'default') . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); my $query_form_post = [ { method => 'parity_versionInfo', params => [], id => "1", jsonrpc => "2.0" }, { method => 'parity_chain', params => [], id => "2", jsonrpc => "2.0" }, From 1537b35d793c2e17962cf10478561b62495f5d6e Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Wed, 8 Jul 2020 15:45:04 +0000 Subject: [PATCH 283/283] prepare for pull request --- blockchain/parity/ethpoller/mode/disk.pm | 3 - blockchain/parity/ethpoller/mode/fork.pm | 103 ------------ blockchain/parity/ethpoller/mode/prct.pm | 130 ---------------- blockchain/parity/ethpoller/mode/stats.pm | 11 +- blockchain/parity/ethpoller/mode/watchlist.pm | 147 ------------------ blockchain/parity/ethpoller/plugin.pm | 7 +- blockchain/parity/restapi/mode/eth.pm | 71 +-------- blockchain/parity/restapi/mode/infos.pm | 42 +---- blockchain/parity/restapi/mode/net.pm | 37 +---- blockchain/parity/restapi/mode/parity.pm | 56 +------ 10 files changed, 13 insertions(+), 594 deletions(-) delete mode 100644 blockchain/parity/ethpoller/mode/fork.pm delete mode 100644 blockchain/parity/ethpoller/mode/prct.pm delete mode 100644 blockchain/parity/ethpoller/mode/watchlist.pm diff --git a/blockchain/parity/ethpoller/mode/disk.pm b/blockchain/parity/ethpoller/mode/disk.pm index 8d5c80884..bc65d1c28 100644 --- a/blockchain/parity/ethpoller/mode/disk.pm +++ b/blockchain/parity/ethpoller/mode/disk.pm @@ -110,9 +110,6 @@ sub manage_selection { my $result = $options{custom}->request_api(url_path => '/disk'); - # use Data::Dumper; - # print Dumper($result); - $self->{global} = { disk_free => $result->{free}, disk_available => $result->{available}, disk_size => $result->{size}, diff --git a/blockchain/parity/ethpoller/mode/fork.pm b/blockchain/parity/ethpoller/mode/fork.pm deleted file mode 100644 index 5d53b223f..000000000 --- a/blockchain/parity/ethpoller/mode/fork.pm +++ /dev/null @@ -1,103 +0,0 @@ -# -# Copyright 2020 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 blockchain::parity::ethpoller::mode::fork; - -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 catalog_status_calc); - -sub new { - my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1, statefile => 1); - bless $self, $class; - - $options{options}->add_options(arguments => { - 'unknown-status:s' => { name => 'unknown_status', default => '' }, - 'warning-status:s' => { name => 'warning_status', default => '' }, - 'critical-status:s' => { name => 'critical_status', default => '%{listening} !~ /true/' }, - }); - return $self; -} - -sub manage_selection { - my ($self, %options) = @_; - - $self->{cache_name} = "parity_ethpoller_" . $self->{mode} . '_' . (defined($self->{option_results}->{hostname}) ? $self->{option_results}->{hostname} : 'me') . '_' . - (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); - - my $result = $options{custom}->request_api(url_path => '/fork'); - - # use Data::Dumper; - # print Dumper($result); - - # Unix time conversion - my $res_timestamp = $result->{last_update}->{timestamp} == 0 ? '': localtime($result->{last_update}->{timestamp}); - - - # Alerts management - # my $cache = Cache::File->new( cache_root => './parity-eth-poller-cache' ); - - # if (my $cached_timestamp = $cache->get('fork_timestamp')) { - # if ($cached_timestamp ne $res_timestamp) { - # #alert - # } - # } else { - # $cache->set('fork_timestamp', $res_timestamp); - # } - - $self->{output}->output_add(severity => 'OK', long_msg => 'Fork: [fork_timestamp: ' . $res_timestamp . - '] [fork_occurence: ' . $result->{occurence} . '] [fork_blockNumber: ' . $result->{last_update}->{blockNumber} . - '] [fork_in: ' . $result->{last_update}->{in} . '] [fork_out: ' . $result->{last_update}->{out} . ']'); - -} - -1; - -__END__ - -=head1 MODE - -Check Parity eth-poller for forks details - -=over 8 - -=item B<--unknown-status> - -Set unknown threshold for listening status (Default: ''). - -=item B<--warning-status> - -Set warning threshold for listening status (Default: ''). - -=item B<--critical-status> - -Set critical threshold for listening status (Default: '%{is_mining} !~ /true/'). - -=item B<--warning-peers> B<--critical-peers> - -Warning and Critical threhsold on the number of peer - -=back - -=cut diff --git a/blockchain/parity/ethpoller/mode/prct.pm b/blockchain/parity/ethpoller/mode/prct.pm deleted file mode 100644 index 86939435a..000000000 --- a/blockchain/parity/ethpoller/mode/prct.pm +++ /dev/null @@ -1,130 +0,0 @@ -# -# Copyright 2020 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 blockchain::parity::ethpoller::mode::prct; - -use base qw(centreon::plugins::templates::counter); - -use strict; -use warnings; -use bigint; -use Digest::MD5 qw(md5_hex); - -sub set_counters { - my ($self, %options) = @_; - - $self->{maps_counters_type} = [ - { name => 'balances', cb_prefix_output => 'prefix_output_balances', type => 1, message_multiple => 'Balances metrics are ok' } - ]; - - $self->{maps_counters}->{balances} = [ - { label => 'balance-fluctuation-prct', nlabel => 'parity.tracking.balances.fluctuation', display_ok => 0, set => { - key_values => [], - manual_keys => 1, - closure_custom_calc => $self->can('custom_prct_calc'), - closure_custom_output => $self->can('custom_prct_output'), - threshold_use => 'balance_fluctuation_prct', - perfdatas => [ - { value => 'balance_fluctuation_prct', template => '%.2f', unit => '%', - min => 0, label_extra_instance => 1, instance_use => 'display' } - ], - } - }, - { label => 'balance', nlabel => 'parity.tracking.balance', set => { - key_values => [ { name => 'balance' } ], - output_template => "%s (wei)", - perfdatas => [ - { label => 'balance', template => '%d', value => 'balance', - min => 0, label_extra_instance => 1, instance_use => 'display' } - ], - } - } - ]; - -} - -sub custom_prct_output { - my ($self, %options) = @_; - - return sprintf( - "balance variation: %.2f ", - $self->{result_values}->{balance_fluctuation_prct} - ); -} - - -sub custom_prct_calc { - my ($self, %options) = @_; - - $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; - $self->{result_values}->{balance} = $options{new_datas}->{$self->{instance} . '_balance'}; - $self->{result_values}->{balance_old} = $options{old_datas}->{$self->{instance} . '_balance'}; - $self->{result_values}->{balance_fluctuation_prct} = (defined($self->{result_values}->{balance_old}) && $self->{result_values}->{balance_old} != 0) ? - ($self->{result_values}->{balance} - $self->{result_values}->{balance_old}) / - $self->{result_values}->{balance_old} : 0; - - return 0; -} - -sub prefix_output_balances { - my ($self, %options) = @_; - - return "Balance '" . $options{instance_value}->{display} . "': "; -} - -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 => { - "filter-name:s" => { name => 'filter_name' }, - }); - - return $self; -} - -sub manage_selection { - my ($self, %options) = @_; - - $self->{cache_name} = "parity_ethpoller_" . $self->{mode} . '_' . (defined($self->{option_results}->{hostname}) ? $self->{option_results}->{hostname} : 'me') . '_' . - (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); - - my $result = $options{custom}->request_api(url_path => '/tracking'); - - foreach my $balance (@{$result->{balances}}) { - $self->{balances}->{lc($balance->{label})} = { display => lc($balance->{label}), - balance => $balance->{balance} - }; - } - -} - - - -1; - -__END__ - -=head1 MODE - -Check Parity eth-poller for events, miners and balances tracking - -=cut diff --git a/blockchain/parity/ethpoller/mode/stats.pm b/blockchain/parity/ethpoller/mode/stats.pm index 0037b4d8e..51b96cac7 100644 --- a/blockchain/parity/ethpoller/mode/stats.pm +++ b/blockchain/parity/ethpoller/mode/stats.pm @@ -25,7 +25,6 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; use bigint; -# use Time::Seconds; use Digest::MD5 qw(md5_hex); sub set_counters { @@ -77,14 +76,10 @@ sub custom_block_output { if (0 eq $self->{result_values}->{block_count}) { return sprintf("No block yet..."); } else { - # my $time_elapsed = time() - $self->{result_values}->{last_block_ts}; - # my $t = Time::Seconds->new($time_elapsed); - return sprintf( - "Block frequency: '%.2f/min', Last block (#%s)",# was %s ago", + "Block frequency: '%.2f/min', Last block (#%s)", $self->{result_values}->{block_count}, - $self->{result_values}->{last_block}, - # $t->pretty + $self->{result_values}->{last_block} ); } } @@ -188,6 +183,6 @@ __END__ =head1 MODE -Check Parity eth-poller for stats +Check Parity eth-poller for statsitics about blocks, transactions and forks =cut diff --git a/blockchain/parity/ethpoller/mode/watchlist.pm b/blockchain/parity/ethpoller/mode/watchlist.pm deleted file mode 100644 index 2c4ed8304..000000000 --- a/blockchain/parity/ethpoller/mode/watchlist.pm +++ /dev/null @@ -1,147 +0,0 @@ -# -# Copyright 2020 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 blockchain::parity::ethpoller::mode::watchlist; - -use base qw(centreon::plugins::templates::counter); - -use strict; -use warnings; -use bigint; -use Digest::MD5 qw(md5_hex); - -sub new { - my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1, statefile => 1); - bless $self, $class; - - $options{options}->add_options(arguments => { - "filter-name:s" => { name => 'filter_name' }, - }); - - return $self; -} - -sub manage_selection { - my ($self, %options) = @_; - - $self->{cache_name} = "parity_ethpoller_" . $self->{mode} . '_' . (defined($self->{option_results}->{hostname}) ? $self->{option_results}->{hostname} : 'me') . '_' . - (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); - - my $results = $options{custom}->request_api(url_path => '/watchlist'); - - # use Data::Dumper; - # print Dumper($results); - - # Alerts management - # my $cache = Cache::File->new( cache_root => './parity-eth-poller-cache' ); - - my $res_timestamp = 0; - - foreach my $account (@{$results->{Accounts}}) { - if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && - $account->{id} !~ /$self->{option_results}->{filter_name}/) { - $self->{output}->output_add(long_msg => "skipping '" . $account->{id} . "': no matching filter name.", debug => 1); - next; - } - - $res_timestamp = $account->{last_update}->{timestamp} == 0 ? '': localtime($account->{last_update}->{timestamp}); - - $self->{output}->output_add(severity => 'OK', long_msg => 'Account ' . $account->{id} . ': [label: ' . $account->{label} . '] [nonce: ' . $account->{nonce} . - '] [timestamp: ' . $res_timestamp . '] [blockNumber: ' . $account->{last_update}->{blockNumber} . - '] [receiver: ' . $account->{last_update}->{receiver} . '] [value: ' . $account->{last_update}->{value} . ']' ); - } - - foreach my $minner (@{$results->{Miners}}) { - if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && - $minner->{id} !~ /$self->{option_results}->{filter_name}/) { - $self->{output}->output_add(long_msg => "skipping '" . $minner->{id} . "': no matching filter name.", debug => 1); - next; - } - - $res_timestamp = $minner->{last_update}->{timestamp} == 0 ? '': localtime($minner->{last_update}->{timestamp}); - - $self->{output}->output_add(severity => 'OK', long_msg => 'Minner ' . $minner->{id} . ': [label: ' . $minner->{label} . '] [blocks: ' . $minner->{blocks} . - '] [timestamp: ' . $res_timestamp . '] [blockNumber: ' . $minner->{last_update}->{blockNumber} . ']'); - } - - foreach my $contract (@{$results->{Constracts}}) { - if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && - $contract->{id} !~ /$self->{option_results}->{filter_name}/) { - $self->{output}->output_add(long_msg => "skipping '" . $contract->{id} . "': no matching filter name.", debug => 1); - next; - } - - $res_timestamp = $contract->{last_update}->{timestamp} == 0 ? '': localtime($contract->{last_update}->{timestamp}); - - $self->{output}->output_add(severity => 'OK', long_msg => 'Contract ' . $contract->{id} . ': [label: ' . $contract->{label} . '] [balance: ' . $contract->{balance} . - '] [timestamp: ' . $res_timestamp . '] [blockNumber: ' . $contract->{last_update}->{blockNumber} . - '] [sender: ' . $contract->{last_update}->{sender} . '] [value: ' . $contract->{last_update}->{value} . ']'); - - # if (my $cached_balance = $cache->get('contract_balance_' . $contract->{id})) { - # if ($cached_balance != $contract->{balance}) { - # #alert - # } - # } else { - # $cache->set('contract_balance_' . $contract->{id}, $contract->{balance}); - # } - - } - - foreach my $function (@{$results->{Functions}}) { - if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && - $function->{id} !~ /$self->{option_results}->{filter_name}/) { - $self->{output}->output_add(long_msg => "skipping '" . $function->{id} . "': no matching filter name.", debug => 1); - next; - } - - $res_timestamp = $function->{last_update}->{timestamp} == 0 ? '': localtime($function->{last_update}->{timestamp}); - - $self->{output}->output_add(severity => 'OK', long_msg => '[Function ' . $function->{id} . ']: label: ' . $function->{label} . '] [calls: ' . $function->{calls} . - '] [timestamp: ' . $res_timestamp . '] [blockNumber: ' . $function->{last_update}->{blockNumber} . - '] [sender: ' . $function->{last_update}->{sender} . '] [receiver: ' . $function->{last_update}->{receiver} . - '] [value: ' . $function->{last_update}->{value} . ']'); - } - - foreach my $event (@{$results->{Events}}) { - if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && - $event->{id} !~ /$self->{option_results}->{filter_name}/) { - $self->{output}->output_add(long_msg => "skipping '" . $event->{id} . "': no matching filter name.", debug => 1); - next; - } - - $res_timestamp = $event->{last_update}->{timestamp} == 0 ? '': localtime($event->{last_update}->{timestamp}); - - $self->{output}->output_add(severity => 'OK', long_msg => '[Event ' . $event->{id} . ']: label: ' . $event->{label} . '] [calls: ' . $event->{calls} . - '] [timestamp: ' . $res_timestamp . '] [blockNumber: ' . $event->{last_update}->{blockNumber} . - '] [sender: ' . $event->{last_update}->{sender} . '] [receiver: ' . $event->{last_update}->{receiver} . ']'); - } - -} - -1; - -__END__ - -=head1 MODE - -Check Parity eth-poller for accounts tracking - -=cut diff --git a/blockchain/parity/ethpoller/plugin.pm b/blockchain/parity/ethpoller/plugin.pm index ec1d68a16..bd0cdea97 100644 --- a/blockchain/parity/ethpoller/plugin.pm +++ b/blockchain/parity/ethpoller/plugin.pm @@ -31,12 +31,9 @@ sub new { $self->{version} = '0.1'; %{$self->{modes}} = ( - # 'watchlist' => 'blockchain::parity::ethpoller::mode::watchlist', - # 'fork' => 'blockchain::parity::ethpoller::mode::fork', 'stats' => 'blockchain::parity::ethpoller::mode::stats', 'disk' => 'blockchain::parity::ethpoller::mode::disk', - 'tracking' => 'blockchain::parity::ethpoller::mode::tracking', - # 'prct' => 'blockchain::parity::ethpoller::mode::prct' + 'tracking' => 'blockchain::parity::ethpoller::mode::tracking' ); $self->{custom_modes}{api} = 'blockchain::parity::ethpoller::custom::api'; return $self; @@ -48,6 +45,6 @@ __END__ =head1 PLUGIN DESCRIPTION -Check Parity blockchain accounts, contracts and forks from eth-poller with HTTP GET +Check Parity blockchain accounts, contracts and forks from eth-poller with HTTP GET requests =cut diff --git a/blockchain/parity/restapi/mode/eth.pm b/blockchain/parity/restapi/mode/eth.pm index 2e858b088..f4a9db8b0 100644 --- a/blockchain/parity/restapi/mode/eth.pm +++ b/blockchain/parity/restapi/mode/eth.pm @@ -174,40 +174,11 @@ sub manage_selection { my $gas_price = hex(@{$result}[2]->{result}); my $res_block_time = @{$result}[5]->{result}->{timestamp} == 0 ? '': localtime(hex(@{$result}[5]->{result}->{timestamp})); - - - # conditional formating: my $res_sync = 100; - # my $res_startingBlock = 'none'; - # my $res_currentBlock = 'none'; - # my $res_highestBlock = 'none'; if (@{$result}[6]->{result}) { my $res_sync = hex(@{$result}[6]->{result}->{highestBlock}) != 0 ? (hex(@{$result}[6]->{result}->{currentBlock}) * 100) / hex(@{$result}[6]->{result}->{highestBlock}) : 'none'; - # my $res_startingBlock = hex(@{$result}[6]->{result}->{startingBlock}); - # my $res_currentBlock = hex(@{$result}[6]->{result}->{currentBlock}); - # my $res_highestBlock = hex(@{$result}[6]->{result}->{highestBlock}); } - - - # Alerts management - # my $cache = Cache::File->new( cache_root => './parity-restapi-cache' ); - - # if (my $cached_sync = $cache->get('node_sync')) { - # if ($cached_sync == 100 && $res_sync < 100) { - # #alert - # } - # } else { - # $cache->set('node_sync', $res_sync); - # } - - # if (my $cached_price = $cache->get('gas_price')) { - # if ($cached_price != $gas_price) { - # #alert - # } - # } else { - # $cache->set('gas_price', $gas_price); - # } $self->{sync} = { sync_status => $res_sync }; @@ -217,27 +188,11 @@ sub manage_selection { my $calculated_block_usage = hex(@{$result}[5]->{result}->{gasUsed}) / hex(@{$result}[5]->{result}->{gasLimit}) * 100; - # use Data::Dumper; - # print Dumper($calculated_block_usage) ; - # print Dumper(hex(@{$result}[5]->{result}->{gasUsed})); - # print Dumper(hex(@{$result}[5]->{result}->{gasLimit})); - $self->{block} = { block_size => hex(@{$result}[5]->{result}->{size}), block_gas => hex(@{$result}[5]->{result}->{gasUsed}), block_usage => $calculated_block_usage, - # block_difficulty => hex(@{$result}[5]->{result}->{totalDifficulty}), block_uncles => scalar(@{$$result[5]->{result}->{uncles}}), - block_transactions => scalar(@{$$result[5]->{result}->{transactions}})}; - - # $self->{output}->output_add(severity => 'OK', long_msg => 'Node status: [is_mining: ' . @{$result}[0]->{result} . '] [sync_start: ' . $res_startingBlock . - # '] [sync_current: ' . $res_currentBlock . '] [sync_highest: ' . $res_highestBlock . '] [sync: ' . $res_sync . '%]'); - # $self->{output}->output_add(severity => 'OK', long_msg => 'Client: [coinbase: ' . @{$result}[1]->{result} . ']'); - # $self->{output}->output_add(severity => 'OK', long_msg => 'Global: [hashrate: ' . hex(@{$result}[3]->{result}) . - # '] [block_number: ' . (defined @{$result}[4]->{result} ? hex(@{$result}[4]->{result}) : 0) . ']'); - # $self->{output}->output_add(severity => 'OK', long_msg => 'Last block: [block_time: ' . $res_block_time . '] [block_gas_limit: ' . hex(@{$result}[5]->{result}->{gasLimit}) . - # '] [block_miner: ' . @{$result}[5]->{result}->{miner} . '] [block_hash: ' . @{$result}[5]->{result}->{hash} . - # '] [last_block_number: ' . hex(@{$result}[5]->{result}->{number}) . ']'); - + block_transactions => scalar(@{$$result[5]->{result}->{transactions}})}; } 1; @@ -246,26 +201,4 @@ __END__ =head1 MODE -Check eth module metrics parity (eth_mining, eth_coinbase, eth_gasPrice, eth_hashrate, eth_blockNumber, eth_getBlockByNumber::timestamp) - -=over 8 - -=item B<--unknown-status> - -Set unknown threshold for listening status (Default: ''). - -=item B<--warning-status> - -Set warning threshold for listening status (Default: ''). - -=item B<--critical-status> - -Set critical threshold for listening status (Default: '%{is_mining} !~ /true/'). - -=item B<--warning-peers> B<--critical-peers> - -Warning and Critical threhsold on the number of peer - -=back - -=cut +Check eth module metrics parity (Gas, blocks and syncing status) \ No newline at end of file diff --git a/blockchain/parity/restapi/mode/infos.pm b/blockchain/parity/restapi/mode/infos.pm index 0721d8c75..8fc9ae6f8 100644 --- a/blockchain/parity/restapi/mode/infos.pm +++ b/blockchain/parity/restapi/mode/infos.pm @@ -67,26 +67,8 @@ sub manage_selection { my $result = $options{custom}->request_api(method => 'POST', query_form_post => $query_form_post); - # use Data::Dumper; - # print Dumper($result); - - # Parity version construction my $res_parity_version = @{$result}[0]->{result}->{version}->{major} . '.' . @{$result}[0]->{result}->{version}->{minor} . '.' . @{$result}[0]->{result}->{version}->{patch}; - - # Alerts management - # my $cache = Cache::File->new( cache_root => './parity-restapi-cache' ); - - # if (my $cached_count = $cache->get('peers_count')) { - # if ($peer_count < $cached_count) { - # #alert - # } elsif ($peer_count > $cached_count) { - # #alert - # } - # } else { - # $cache->set('peers_count', $peer_count); - # } - $self->{output}->output_add(short_msg => "Parity version: '" . $res_parity_version . "'. Chain name: '" . @{$result}[1]->{result} . "'. Node name: '" . @{$result}[3]->{result} . "'. is_validator: '" . @{$result}[2]->{result} . "'.", severity => 'OK'); } @@ -97,26 +79,4 @@ __END__ =head1 MODE -Check parity network cross module metrics (parity_versionInfo, parity_chain, eth_mining, parity_nodeName) - -=over 8 - -=item B<--unknown-status> - -Set unknown threshold for listening status (Default: ''). - -=item B<--warning-status> - -Set warning threshold for listening status (Default: ''). - -=item B<--critical-status> - -Set critical threshold for listening status (Default: '%{listening} !~ /true/'). - -=item B<--warning-peers> B<--critical-peers> - -Warning and Critical threhsold on the number of peer - -=back - -=cut +Check parity network cross module metrics (Parity version, chain name and node name and type) diff --git a/blockchain/parity/restapi/mode/net.pm b/blockchain/parity/restapi/mode/net.pm index ee06b150f..00cf9217b 100644 --- a/blockchain/parity/restapi/mode/net.pm +++ b/blockchain/parity/restapi/mode/net.pm @@ -94,19 +94,6 @@ sub manage_selection { my $peer_count = hex(@{$result}[1]->{result}); - # Alerts management - # my $cache = Cache::File->new( cache_root => './parity-restapi-cache' ); - - # if (my $cached_count = $cache->get('peers_count')) { - # if ($peer_count < $cached_count) { - # #alert - # } elsif ($peer_count > $cached_count) { - # #alert - # } - # } else { - # $cache->set('peers_count', $peer_count); - # } - $self->{network} = { peers => hex(@{$result}[1]->{result}) }; $self->{output}->output_add(long_msg => "Node status: [is_listening: " . @{$result}[0]->{result} . ']', severity => 'OK'); @@ -118,26 +105,4 @@ __END__ =head1 MODE -Check network module metrics parity (net_isListening, net_peerCount) - -=over 8 - -=item B<--unknown-status> - -Set unknown threshold for listening status (Default: ''). - -=item B<--warning-status> - -Set warning threshold for listening status (Default: ''). - -=item B<--critical-status> - -Set critical threshold for listening status (Default: '%{listening} !~ /true/'). - -=item B<--warning-peers> B<--critical-peers> - -Warning and Critical threhsold on the number of peer - -=back - -=cut +Check network module metrics parity (net_isListening, net_peerCount) \ No newline at end of file diff --git a/blockchain/parity/restapi/mode/parity.pm b/blockchain/parity/restapi/mode/parity.pm index a0e18d0c3..ac277d591 100644 --- a/blockchain/parity/restapi/mode/parity.pm +++ b/blockchain/parity/restapi/mode/parity.pm @@ -140,44 +140,18 @@ sub manage_selection { { method => 'parity_netPeers', params => [], id => "4", jsonrpc => "2.0" }, { method => 'parity_enode', params => [], id => "5", jsonrpc => "2.0" }, { method => 'parity_nodeName', params => [], id => "6", jsonrpc => "2.0" }, - { method => 'parity_transactionsLimit', params => [], id => "7", jsonrpc => "2.0" }, #TO CHECK parity_transactionsLimit could be done once, at the beginning of the process + { method => 'parity_transactionsLimit', params => [], id => "7", jsonrpc => "2.0" }, { method => 'net_peerCount', params => [], id => "8", jsonrpc => "2.0" } ]; my $result = $options{custom}->request_api(method => 'POST', query_form_post => $query_form_post); - # use Data::Dumper; - # print Dumper($result); - - # Parity version construction my $res_parity_version = @{$result}[0]->{result}->{version}->{major} . '.' . @{$result}[0]->{result}->{version}->{minor} . '.' . @{$result}[0]->{result}->{version}->{patch}; - # Alerts management - # my $cache = Cache::File->new( cache_root => './parity-restapi-cache' ); - - # if (my $cached_version = $cache->get('parity_version')) { - # if ($res_parity_version ne $cached_version) { - # #alert - # } - # } else { - # $cache->set('parity_version', $res_parity_version); - # } - - # if (my $cached_name = $cache->get('chain_name')) { - # if ($cached_name ne @{$result}[1]->{result}) { - # #alert - # } - # } else { - # $cache->set('chain_name', @{$result}[1]->{result}); - # } - - # use Data::Dumper; - # print Dumper($result); - - $self->{mempool} = { mempool_usage => scalar(@{$$result[2]->{result}}) / @{$result}[6]->{result} * 100, #TO CHECK division entière + $self->{mempool} = { mempool_usage => scalar(@{$$result[2]->{result}}) / @{$result}[6]->{result} * 100, mempool_size => @{$result}[6]->{result}, tx_pending => scalar(@{$$result[2]->{result}}) }; - $self->{peers} = { peers_usage => @{$result}[3]->{result}->{connected} / @{$result}[3]->{result}->{max} * 100, #TO CHECK division entière + $self->{peers} = { peers_usage => @{$result}[3]->{result}->{connected} / @{$result}[3]->{result}->{max} * 100, peers_max => @{$result}[3]->{result}->{max}, peers_limit => @{$result}[3]->{result}->{max}, peers_connected => @{$result}[3]->{result}->{connected} }; @@ -189,26 +163,4 @@ __END__ =head1 MODE -Check parity module metrics parity (parity_versionInfo, parity_chain, parity_pendingTransactions, parity_netPeers, parity_enode, parity_nodeName, parity_transactionsLimit) - -=over 8 - -=item B<--unknown-status> - -Set unknown threshold for listening status (Default: ''). - -=item B<--warning-status> - -Set warning threshold for listening status (Default: ''). - -=item B<--critical-status> - -Set critical threshold for listening status (Default: '%{listening} !~ /true/'). - -=item B<--warning-peers> B<--critical-peers> - -Warning and Critical threhsold on the number of peer - -=back - -=cut +Check parity module metrics parity (Mempool and peers) \ No newline at end of file