From d360716e62f385bcd27325f1e5026a51cf866619 Mon Sep 17 00:00:00 2001 From: Lotfi zaouche Date: Wed, 8 Jul 2020 15:45:04 +0000 Subject: [PATCH] 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 +- .../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 centreon-plugins/blockchain/parity/ethpoller/mode/fork.pm delete mode 100644 centreon-plugins/blockchain/parity/ethpoller/mode/prct.pm delete mode 100644 centreon-plugins/blockchain/parity/ethpoller/mode/watchlist.pm diff --git a/centreon-plugins/blockchain/parity/ethpoller/mode/disk.pm b/centreon-plugins/blockchain/parity/ethpoller/mode/disk.pm index 8d5c80884..bc65d1c28 100644 --- a/centreon-plugins/blockchain/parity/ethpoller/mode/disk.pm +++ b/centreon-plugins/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/centreon-plugins/blockchain/parity/ethpoller/mode/fork.pm b/centreon-plugins/blockchain/parity/ethpoller/mode/fork.pm deleted file mode 100644 index 5d53b223f..000000000 --- a/centreon-plugins/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/centreon-plugins/blockchain/parity/ethpoller/mode/prct.pm b/centreon-plugins/blockchain/parity/ethpoller/mode/prct.pm deleted file mode 100644 index 86939435a..000000000 --- a/centreon-plugins/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/centreon-plugins/blockchain/parity/ethpoller/mode/stats.pm b/centreon-plugins/blockchain/parity/ethpoller/mode/stats.pm index 0037b4d8e..51b96cac7 100644 --- a/centreon-plugins/blockchain/parity/ethpoller/mode/stats.pm +++ b/centreon-plugins/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/centreon-plugins/blockchain/parity/ethpoller/mode/watchlist.pm b/centreon-plugins/blockchain/parity/ethpoller/mode/watchlist.pm deleted file mode 100644 index 2c4ed8304..000000000 --- a/centreon-plugins/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/centreon-plugins/blockchain/parity/ethpoller/plugin.pm b/centreon-plugins/blockchain/parity/ethpoller/plugin.pm index ec1d68a16..bd0cdea97 100644 --- a/centreon-plugins/blockchain/parity/ethpoller/plugin.pm +++ b/centreon-plugins/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/centreon-plugins/blockchain/parity/restapi/mode/eth.pm b/centreon-plugins/blockchain/parity/restapi/mode/eth.pm index 2e858b088..f4a9db8b0 100644 --- a/centreon-plugins/blockchain/parity/restapi/mode/eth.pm +++ b/centreon-plugins/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/centreon-plugins/blockchain/parity/restapi/mode/infos.pm b/centreon-plugins/blockchain/parity/restapi/mode/infos.pm index 0721d8c75..8fc9ae6f8 100644 --- a/centreon-plugins/blockchain/parity/restapi/mode/infos.pm +++ b/centreon-plugins/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/centreon-plugins/blockchain/parity/restapi/mode/net.pm b/centreon-plugins/blockchain/parity/restapi/mode/net.pm index ee06b150f..00cf9217b 100644 --- a/centreon-plugins/blockchain/parity/restapi/mode/net.pm +++ b/centreon-plugins/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/centreon-plugins/blockchain/parity/restapi/mode/parity.pm b/centreon-plugins/blockchain/parity/restapi/mode/parity.pm index a0e18d0c3..ac277d591 100644 --- a/centreon-plugins/blockchain/parity/restapi/mode/parity.pm +++ b/centreon-plugins/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