code to be completed 2/2

This commit is contained in:
Lotfi zaouche 2020-05-11 18:32:33 +00:00
parent bce286b8ef
commit 18dbd5ed14
3 changed files with 7 additions and 7 deletions

View File

@ -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 }
],

View File

@ -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);

View File

@ -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;