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 {