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 }