custom outputs update

This commit is contained in:
Lotfi zaouche 2020-05-21 22:10:32 +00:00
parent aa6afc913a
commit 4233b497ef
6 changed files with 332 additions and 207 deletions

View File

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

View File

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

View File

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

View File

@ -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}) . ']');
}

View File

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

View File

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