Merge pull request #2093 from centreon/(wip)parity-blockchain-monitoring
(wip)parity blockchain monitoring
This commit is contained in:
commit
d8969c48c8
|
@ -0,0 +1,204 @@
|
|||
#
|
||||
# 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::custom::api;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::http;
|
||||
use DateTime;
|
||||
use JSON::XS;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = {};
|
||||
bless $self, $class;
|
||||
|
||||
if (!defined($options{output})) {
|
||||
print "Class Custom: Need to specify 'output' argument.\n";
|
||||
exit 3;
|
||||
}
|
||||
if (!defined($options{options})) {
|
||||
$options{output}->add_option_msg(short_msg => "Class Custom: Need to specify 'options' argument.");
|
||||
$options{output}->option_exit();
|
||||
}
|
||||
|
||||
if (!defined($options{noptions})) {
|
||||
$options{options}->add_options(arguments => {
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"port:s" => { name => 'port' },
|
||||
"proto:s" => { name => 'proto' },
|
||||
"url-path:s" => { name => 'url_path' },
|
||||
"timeout:s" => { name => 'timeout' },
|
||||
});
|
||||
}
|
||||
$options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1);
|
||||
|
||||
$self->{output} = $options{output};
|
||||
$self->{mode} = $options{mode};
|
||||
$self->{http} = centreon::plugins::http->new(%options);
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub set_options {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{option_results} = $options{option_results};
|
||||
}
|
||||
|
||||
sub set_defaults {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
foreach (keys %{$options{default}}) {
|
||||
if ($_ eq $self->{mode}) {
|
||||
for (my $i = 0; $i < scalar(@{$options{default}->{$_}}); $i++) {
|
||||
foreach my $opt (keys %{$options{default}->{$_}[$i]}) {
|
||||
if (!defined($self->{option_results}->{$opt}[$i])) {
|
||||
$self->{option_results}->{$opt}[$i] = $options{default}->{$_}[$i]->{$opt};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{hostname} = (defined($self->{option_results}->{hostname})) ? $self->{option_results}->{hostname} : undef;
|
||||
$self->{port} = (defined($self->{option_results}->{port})) ? $self->{option_results}->{port} : 8000;
|
||||
$self->{proto} = (defined($self->{option_results}->{proto})) ? $self->{option_results}->{proto} : 'http';
|
||||
$self->{url_path} = (defined($self->{option_results}->{url_path})) ? $self->{option_results}->{url_path} : '';
|
||||
$self->{timeout} = (defined($self->{option_results}->{timeout})) ? $self->{option_results}->{timeout} : 10;
|
||||
|
||||
if (!defined($self->{hostname}) || $self->{hostname} eq '') {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify --hostname option.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub build_options_for_httplib {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{option_results}->{hostname} = $self->{hostname};
|
||||
$self->{option_results}->{timeout} = $self->{timeout};
|
||||
$self->{option_results}->{port} = $self->{port};
|
||||
$self->{option_results}->{proto} = $self->{proto};
|
||||
$self->{option_results}->{url_path} = $self->{url_path};
|
||||
$self->{option_results}->{warning_status} = '';
|
||||
$self->{option_results}->{critical_status} = '';
|
||||
}
|
||||
|
||||
sub settings {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->build_options_for_httplib();
|
||||
$self->{http}->add_header(key => 'Accept', value => 'application/json');
|
||||
$self->{http}->set_options(%{$self->{option_results}});
|
||||
}
|
||||
|
||||
sub get_connection_info {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return $self->{hostname} . ":" . $self->{port};
|
||||
}
|
||||
|
||||
sub get_hostname {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return $self->{hostname};
|
||||
}
|
||||
|
||||
sub get_port {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return $self->{port};
|
||||
}
|
||||
|
||||
sub request_api {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->settings;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Query URL: '" . $self->{proto} . "://" . $self->{hostname} .
|
||||
$self->{url_path} . $options{url_path} . "'", debug => 1);
|
||||
|
||||
my $content = $self->{http}->request(url_path => $self->{url_path} . $options{url_path});
|
||||
|
||||
my $decoded;
|
||||
eval {
|
||||
$decoded = JSON::XS->new->utf8->decode($content);
|
||||
};
|
||||
if ($@) {
|
||||
$self->{output}->add_option_msg(short_msg => "Cannot decode json response: $@");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
return $decoded;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Parity eth-poller Rest API
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
Parity eth-poller Rest API custom mode
|
||||
|
||||
=head1 REST API OPTIONS
|
||||
|
||||
Parity eth-poller Rest API
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--hostname>
|
||||
|
||||
Parity eth-poller API hostname.
|
||||
|
||||
=item B<--port>
|
||||
|
||||
API port (Default: 8000)
|
||||
|
||||
=item B<--proto>
|
||||
|
||||
Specify https if needed (Default: 'http')
|
||||
|
||||
=item B<--url-path>
|
||||
|
||||
API URL path (Default: '')
|
||||
|
||||
=item B<--timeout>
|
||||
|
||||
Set HTTP timeout
|
||||
|
||||
=back
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
B<custom>.
|
||||
|
||||
=cut
|
|
@ -0,0 +1,132 @@
|
|||
#
|
||||
# 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::disk;
|
||||
|
||||
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 => 'global', cb_prefix_output => 'prefix_module_output', type => 0 },
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{global} = [
|
||||
{ label => 'disk-free', nlabel => 'eth.poller.disk.free', set => {
|
||||
key_values => [ { name => 'disk_free' } ],
|
||||
output_template => "Disk free: %d ",
|
||||
perfdatas => [
|
||||
{ label => 'disk_free', value => 'disk_free', unit => 'B', template => '%d', min => 0 }
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'disk-available', nlabel => 'eth.poller.disk.available', set => {
|
||||
key_values => [ { name => 'disk_available' } ],
|
||||
output_template => "Disk available: %d ",
|
||||
perfdatas => [
|
||||
{ label => 'disk_available', value => 'disk_available', unit => 'B', template => '%d', min => 0 }
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'disk-size', nlabel => 'eth.poller.disk.size', set => {
|
||||
key_values => [ { name => 'disk_size' } ],
|
||||
output_template => "Disk size: %d ",
|
||||
perfdatas => [
|
||||
{ label => 'disk_size', value => 'disk_size', template => '%d', unit => 'B', min => 0 }
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'disk-used', nlabel => 'eth.poller.disk.used', set => {
|
||||
key_values => [ { name => 'disk_used' } ],
|
||||
output_template => "Disk used: %d ",
|
||||
perfdatas => [
|
||||
{ label => 'disk_used', value => 'disk_used', template => '%d', unit => 'B', min => 0 }
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'disk-usage', nlabel => 'eth.poller.disk.usage', set => {
|
||||
key_values => [ { name => 'disk_usage' } ],
|
||||
output_template => "Disk usage: %d %%",
|
||||
perfdatas => [
|
||||
{ label => 'disk_usage', value => 'disk_usage', template => '%.2f', unit => '%', min => 0 }
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'blockchain-dir', nlabel => 'eth.poller.blockchain.directory', set => {
|
||||
key_values => [ { name => 'blockchain_dir' } ],
|
||||
output_template => "Blockchain directory: %d",
|
||||
perfdatas => [
|
||||
{ label => 'blockchain_dir', value => 'blockchain_dir', unit => 'B', template => '%d', min => 0 }
|
||||
],
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
sub prefix_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Disk '";
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, 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) = @_;
|
||||
|
||||
my $result = $options{custom}->request_api(url_path => '/disk');
|
||||
|
||||
$self->{global} = { disk_free => $result->{free},
|
||||
disk_available => $result->{available},
|
||||
disk_size => $result->{size},
|
||||
disk_used => $result->{used},
|
||||
disk_usage => $result->{usage},
|
||||
blockchain_dir => $result->{dir}
|
||||
};
|
||||
|
||||
$self->{output}->output_add(severity => 'OK', long_msg => 'Ledger: ' . $result->{dir} . ' (' . $result->{usage} . '%)');
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check Parity eth-poller for disk monitoring
|
||||
|
||||
=cut
|
|
@ -0,0 +1,188 @@
|
|||
#
|
||||
# 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 },
|
||||
{ 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 {
|
||||
return sprintf(
|
||||
"Block frequency: '%.2f/min', Last block (#%s)",
|
||||
$self->{result_values}->{block_count},
|
||||
$self->{result_values}->{last_block}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
sub custom_transaction_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
if (0 eq $self->{result_values}->{transaction_count}) {
|
||||
return sprintf("No transaction yet...");
|
||||
} else {
|
||||
|
||||
return sprintf(
|
||||
"Transaction frequency: '%.2f/min', Last transaction (#%s)",
|
||||
$self->{result_values}->{transaction_count},
|
||||
$self->{result_values}->{last_transaction}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
sub custom_fork_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
if (0 eq $self->{result_values}->{fork_count}) {
|
||||
return sprintf("No fork occurred yet...");
|
||||
} else {
|
||||
|
||||
return sprintf(
|
||||
"Fork frequency: '%.2f/min', Last fork (#%s)",
|
||||
$self->{result_values}->{fork_count},
|
||||
$self->{result_values}->{last_fork}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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}->{port}) ? $self->{option_results}->{port} : 'default') . '_' .
|
||||
(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 statsitics about blocks, transactions and forks
|
||||
|
||||
=cut
|
|
@ -0,0 +1,297 @@
|
|||
#
|
||||
# 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::tracking;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use bigint;
|
||||
use Math::BigFloat;
|
||||
use Digest::MD5 qw(md5_hex);
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$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_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' },
|
||||
{ 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' }
|
||||
]
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{mining} = [
|
||||
{ label => 'mining-frequency', nlabel => 'parity.tracking.mined.block.perminute', set => {
|
||||
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' }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'mining-prct', nlabel => 'parity.tracking.mined.block.prct', display_ok => 0, set => {
|
||||
key_values => [],
|
||||
manual_keys => 1,
|
||||
closure_custom_calc => $self->can('custom_mining_prct_calc'),
|
||||
closure_custom_output => $self->can('custom_mining_prct_output'),
|
||||
threshold_use => 'mining_prct',
|
||||
perfdatas => [
|
||||
{ value => 'mining_prct', template => '%.2f', unit => '%',
|
||||
min => 0, label_extra_instance => 1, instance_use => 'display' }
|
||||
],
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{balance} = [
|
||||
# { label => 'balance-fluctuation-prct', nlabel => 'parity.tracking.balances.fluctuation', display_ok => 0, set => {
|
||||
# key_values => [],
|
||||
# manual_keys => 1,
|
||||
# closure_custom_calc => $self->can('custom_balance_prct_calc'),
|
||||
# closure_custom_output => $self->can('custom_balance_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-changes', nlabel => 'parity.tracking.balance.changes.perminute', set => {
|
||||
key_values => [ { name => 'balance_count', per_minute => 1 }, { name => 'display' },
|
||||
{ name => 'last_balance' } ],
|
||||
closure_custom_output => $self->can('custom_balance_output'),
|
||||
perfdatas => [
|
||||
{ template => '%.2f', label_extra_instance => 1, unit => 'wei', instance_use => 'display' }
|
||||
]
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
sub prefix_output_balances {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Balance '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
sub prefix_output_events {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Event '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
sub prefix_output_mining {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Miner '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
sub custom_mining_prct_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return sprintf(
|
||||
"Mined: %d blocks, witch corresponds to %.2f %% of total validated block",
|
||||
$self->{result_values}->{mined_block_count},
|
||||
$self->{result_values}->{mining_prct}
|
||||
);
|
||||
}
|
||||
|
||||
sub custom_mining_prct_calc {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'};
|
||||
$self->{result_values}->{mined_block_count} = Math::BigFloat->new($options{new_datas}->{$self->{instance} . '_mined_block_count'});
|
||||
$self->{result_values}->{total_block} = Math::BigFloat->new($options{new_datas}->{$self->{instance} . '_total_block'});
|
||||
$self->{result_values}->{mining_prct} = (defined($self->{result_values}->{total_block}) && $self->{result_values}->{total_block} != 0) ?
|
||||
$self->{result_values}->{mined_block_count} / $self->{result_values}->{total_block} * 100 : 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
# sub custom_balance_prct_output {
|
||||
# my ($self, %options) = @_;
|
||||
|
||||
# return sprintf(
|
||||
# "Balance: %s ether, Last fluctuation: %.2f ",
|
||||
# $self->{result_values}->{balance},
|
||||
# $self->{result_values}->{balance_fluctuation_prct}
|
||||
# );
|
||||
# }
|
||||
|
||||
# sub custom_balance_prct_calc {
|
||||
# my ($self, %options) = @_;
|
||||
|
||||
# $self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'};
|
||||
# $self->{result_values}->{balance} = Math::BigFloat->new($options{new_datas}->{$self->{instance} . '_balance'});
|
||||
# $self->{result_values}->{balance_old} = Math::BigFloat->new($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 {
|
||||
|
||||
return sprintf(
|
||||
"Event frequency: %.2f/min, Last event (#%s) was in block #%s",
|
||||
$self->{result_values}->{event_count},
|
||||
$self->{result_values}->{last_event},
|
||||
$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 {
|
||||
|
||||
return sprintf(
|
||||
"Mining frequency: %.2f/min, Last validation (#%s) ago for block #%s",
|
||||
$self->{result_values}->{mining_count},
|
||||
$self->{result_values}->{last_mining},
|
||||
$self->{result_values}->{last_mining_block}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
sub custom_balance_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
if (0 eq $self->{result_values}->{balance_count}) {
|
||||
return sprintf("No change in balance in last minute. Balance still %s wei",
|
||||
$self->{result_values}->{last_balance});
|
||||
} else {
|
||||
return sprintf(
|
||||
"Balance changes: %.2f/min. New balance: %s",
|
||||
$self->{result_values}->{balance_count},
|
||||
$self->{result_values}->{last_balance}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
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}->{port}) ? $self->{option_results}->{port} : 'default') . '_' .
|
||||
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
|
||||
|
||||
my $results = $options{custom}->request_api(url_path => '/tracking');
|
||||
|
||||
$self->{events} = {};
|
||||
$self->{mining} = {};
|
||||
$self->{balance} = {};
|
||||
|
||||
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->{label} . "': no matching filter name.", debug => 1);
|
||||
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},
|
||||
last_event => $event->{count},
|
||||
last_event_block => $event->{block},
|
||||
last_event_ts => $last_event_timestamp
|
||||
};
|
||||
}
|
||||
|
||||
foreach my $miner (@{$results->{miners}}) {
|
||||
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||
$miner->{id} !~ /$self->{option_results}->{filter_name}/) {
|
||||
$self->{output}->output_add(long_msg => "skipping '" . $miner->{label} . "': no matching filter name.", debug => 1);
|
||||
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},
|
||||
last_mining => $miner->{count},
|
||||
last_mining_block => $miner->{block},
|
||||
last_mining_ts => $last_mining_timestamp,
|
||||
total_block => $miner->{currentBlock},
|
||||
mined_block_count => $miner->{count}
|
||||
};
|
||||
}
|
||||
|
||||
foreach my $balance (@{$results->{balances}}) {
|
||||
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||
$balance->{id} !~ /$self->{option_results}->{filter_name}/) {
|
||||
$self->{output}->output_add(long_msg => "skipping '" . $balance->{label} . "': no matching filter name.", debug => 1);
|
||||
next;
|
||||
}
|
||||
|
||||
$self->{balance}->{lc($balance->{label})} = {
|
||||
display => lc($balance->{label}),
|
||||
balance_count => $balance->{balance},
|
||||
last_balance => $balance->{balance}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check Parity eth-poller for events, miners and balances tracking
|
||||
|
||||
=cut
|
|
@ -0,0 +1,50 @@
|
|||
#
|
||||
# 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::plugin;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use base qw(centreon::plugins::script_custom);
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
'stats' => 'blockchain::parity::ethpoller::mode::stats',
|
||||
'disk' => 'blockchain::parity::ethpoller::mode::disk',
|
||||
'tracking' => 'blockchain::parity::ethpoller::mode::tracking'
|
||||
);
|
||||
$self->{custom_modes}{api} = 'blockchain::parity::ethpoller::custom::api';
|
||||
return $self;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 PLUGIN DESCRIPTION
|
||||
|
||||
Check Parity blockchain accounts, contracts and forks from eth-poller with HTTP GET requests
|
||||
|
||||
=cut
|
|
@ -0,0 +1,189 @@
|
|||
#
|
||||
# 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::restapi::custom::api;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::http;
|
||||
use JSON;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = {};
|
||||
bless $self, $class;
|
||||
|
||||
if (!defined($options{output})) {
|
||||
print "Class Custom: Need to specify 'output' argument.\n";
|
||||
exit 3;
|
||||
}
|
||||
if (!defined($options{options})) {
|
||||
$options{output}->add_option_msg(short_msg => "Class Custom: Need to specify 'options' argument.");
|
||||
$options{output}->option_exit();
|
||||
}
|
||||
|
||||
if (!defined($options{noptions})) {
|
||||
$options{options}->add_options(arguments => {
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"port:s" => { name => 'port' },
|
||||
"timeout:s" => { name => 'timeout' },
|
||||
"api-path:s" => { name => 'api_path' },
|
||||
});
|
||||
}
|
||||
$options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1);
|
||||
|
||||
$self->{output} = $options{output};
|
||||
$self->{mode} = $options{mode};
|
||||
$self->{http} = centreon::plugins::http->new(%options);
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub set_options {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{option_results} = $options{option_results};
|
||||
}
|
||||
|
||||
sub set_defaults {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
foreach (keys %{$options{default}}) {
|
||||
if ($_ eq $self->{mode}) {
|
||||
for (my $i = 0; $i < scalar(@{$options{default}->{$_}}); $i++) {
|
||||
foreach my $opt (keys %{$options{default}->{$_}[$i]}) {
|
||||
if (!defined($self->{option_results}->{$opt}[$i])) {
|
||||
$self->{option_results}->{$opt}[$i] = $options{default}->{$_}[$i]->{$opt};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{hostname} = (defined($self->{option_results}->{hostname})) ? $self->{option_results}->{hostname} : undef;
|
||||
$self->{port} = (defined($self->{option_results}->{port})) ? $self->{option_results}->{port} : 8545;
|
||||
$self->{timeout} = (defined($self->{option_results}->{timeout})) ? $self->{option_results}->{timeout} : 10;
|
||||
$self->{api_path} = (defined($self->{option_results}->{api_path})) ? $self->{option_results}->{api_path} : '/';
|
||||
|
||||
if (!defined($self->{hostname})) {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify hostname option.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub get_connection_infos {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return $self->{hostname} . '_' . $self->{http}->get_port();
|
||||
}
|
||||
|
||||
sub build_options_for_httplib {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{option_results}->{hostname} = $self->{hostname};
|
||||
$self->{option_results}->{timeout} = $self->{timeout};
|
||||
$self->{option_results}->{port} = $self->{port};
|
||||
$self->{option_results}->{proto} = 'http';
|
||||
}
|
||||
|
||||
sub settings {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->build_options_for_httplib();
|
||||
$self->{http}->add_header(key => 'Accept', value => 'application/json');
|
||||
$self->{http}->add_header(key => 'Content-Type', value => 'application/json');
|
||||
$self->{http}->set_options(%{$self->{option_results}});
|
||||
}
|
||||
|
||||
sub request_api {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
||||
$self->settings();
|
||||
|
||||
my $encoded;
|
||||
eval {
|
||||
$encoded = encode_json($options{query_form_post});
|
||||
};
|
||||
if ($@) {
|
||||
$self->{output}->add_option_msg(short_msg => "Cannot encode json request");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
my $content = $self->{http}->request(method => $options{method}, url_path => '/', query_form_post => $encoded,
|
||||
critical_status => '', warning_status => '', unknown_status => '');
|
||||
|
||||
my $decoded;
|
||||
eval {
|
||||
$decoded = decode_json($content);
|
||||
};
|
||||
if ($@) {
|
||||
$self->{output}->output_add(long_msg => $content, debug => 1);
|
||||
$self->{output}->add_option_msg(short_msg => "Cannot decode json response");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if ($self->{http}->get_code() != 200) {
|
||||
$self->{output}->add_option_msg(short_msg => "Connection issue: " . $decoded->{msg});
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
return $decoded;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Parity node JSON WEBRPC
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
Parity node JSON RPC API custom mode
|
||||
|
||||
=head1 REST API OPTIONS
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--hostname>
|
||||
|
||||
Parity node hostname or IP
|
||||
|
||||
=item B<--timeout>
|
||||
|
||||
Set HTTP timeout in seconds (Default: '10').
|
||||
|
||||
=item B<--api-path>
|
||||
|
||||
API base url path (Default: '/').
|
||||
|
||||
=back
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
B<custom>.
|
||||
|
||||
=cut
|
|
@ -0,0 +1,204 @@
|
|||
#
|
||||
# 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::restapi::mode::eth;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Digest::MD5 qw(md5_hex);
|
||||
use bigint;
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc);
|
||||
|
||||
sub custom_status_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return sprintf(
|
||||
'Client mininig status: %s ',
|
||||
$self->{result_values}->{is_mining},
|
||||
);
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'gas', cb_prefix_output => 'prefix_module_output', type => 0 },
|
||||
{ name => 'block', cb_prefix_output => 'prefix_module_output', type => 0 },
|
||||
{ name => 'sync', cb_prefix_output => 'prefix_module_output', type => 0 },
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{sync} = [
|
||||
{ label => 'sync-status', nlabel => 'parity.eth.sync.status', set => {
|
||||
key_values => [ { name => 'sync_status' } ],
|
||||
output_template => "Syncing: %d %% ",
|
||||
perfdatas => [
|
||||
{ label => 'sync_status', value => 'sync_status', template => '%d', min => 0 }
|
||||
],
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{gas} = [
|
||||
{ label => 'gas-price', nlabel => 'parity.eth.gas.price', set => {
|
||||
key_values => [ { name => 'gas_price' } ],
|
||||
output_template => "The gas price is: %d wei ",
|
||||
perfdatas => [
|
||||
{ label => 'gas_price', value => 'gas_price', template => '%d', min => 0 }
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'gas-used', nlabel => 'parity.eth.gas.used', set => {
|
||||
key_values => [ { name => 'gas_used' } ],
|
||||
output_template => "The gas used is: %d",
|
||||
perfdatas => [
|
||||
{ label => 'gas_used', value => 'gas_used', template => '%d', min => 0 }
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'gas-limit', nlabel => 'parity.eth.gas.limit', set => {
|
||||
key_values => [ { name => 'gas_limit' } ],
|
||||
output_template => "The gas limit is: %d",
|
||||
perfdatas => [
|
||||
{ label => 'gas_limit', value => 'gas_limit', template => '%d', min => 0 }
|
||||
],
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{block} = [
|
||||
{ label => 'block-size', nlabel => 'parity.eth.block.size', set => {
|
||||
key_values => [ { name => 'block_size' } ],
|
||||
output_template => "Block size: %d ",
|
||||
perfdatas => [
|
||||
{ label => 'block_size', value => 'block_size', template => '%d', min => 0 }
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'block-usage', nlabel => 'parity.eth.block.usage', set => {
|
||||
key_values => [ { name => 'block_usage' } ],
|
||||
output_template => "Block usage: %.2f %%",
|
||||
perfdatas => [
|
||||
{ label => 'block_usage', value => 'block_usage', template => '%.2f', unit => '%', min => 0 }
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'block-transactions', nlabel => 'parity.eth.block.transactions.number', set => {
|
||||
key_values => [ { name => 'block_transactions' } ],
|
||||
output_template => "Block transactions number: %d ",
|
||||
perfdatas => [
|
||||
{ label => 'block_transactions', value => 'block_transactions', template => '%d', min => 0 }
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'block-gas', nlabel => 'parity.eth.block.gas', set => {
|
||||
key_values => [ { name => 'block_gas' } ],
|
||||
output_template => "Block gas: %d ",
|
||||
perfdatas => [
|
||||
{ label => 'block_gas', value => 'block_gas', template => '%d', 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', template => '%d', min => 0 }
|
||||
],
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
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 check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
$self->change_macros(macros => ['unknown_status', 'warning_status', 'critical_status']);
|
||||
}
|
||||
|
||||
sub prefix_module_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Parity Eth module: ";
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{cache_name} = "parity_restapi_" . $self->{mode} . '_' . (defined($self->{option_results}->{hostname}) ? $self->{option_results}->{hostname} : 'me') . '_' .
|
||||
(defined($self->{option_results}->{port}) ? $self->{option_results}->{port} : 'default') . '_' .
|
||||
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
|
||||
|
||||
my $query_form_post = [ { method => 'eth_mining', params => [], id => "1", jsonrpc => "2.0" },
|
||||
{ method => 'eth_coinbase', params => [], id => "2", jsonrpc => "2.0" },
|
||||
{ method => 'eth_gasPrice', params => [], id => "3", jsonrpc => "2.0" } ,
|
||||
{ method => 'eth_hashrate', params => [], id => "4", jsonrpc => "2.0" } ,
|
||||
{ method => 'eth_blockNumber', params => [], id => "5", jsonrpc => "2.0" },
|
||||
{ method => 'eth_getBlockByNumber', params => ["latest",\0], id => "6", jsonrpc => "2.0" },
|
||||
{ method => 'eth_syncing', params => [], id => "7", jsonrpc => "2.0" } ];
|
||||
|
||||
my $result = $options{custom}->request_api(method => 'POST', query_form_post => $query_form_post);
|
||||
|
||||
my $gas_price = hex(@{$result}[2]->{result});
|
||||
my $res_block_time = @{$result}[5]->{result}->{timestamp} == 0 ? '': localtime(hex(@{$result}[5]->{result}->{timestamp}));
|
||||
|
||||
my $res_sync = 100;
|
||||
|
||||
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';
|
||||
}
|
||||
|
||||
$self->{sync} = { sync_status => $res_sync };
|
||||
|
||||
$self->{gas} = { gas_price => $gas_price,
|
||||
gas_used => hex(@{$result}[5]->{result}->{gasUsed}),
|
||||
gas_limit => hex(@{$result}[5]->{result}->{gasLimit}) };
|
||||
|
||||
my $calculated_block_usage = hex(@{$result}[5]->{result}->{gasUsed}) / hex(@{$result}[5]->{result}->{gasLimit}) * 100;
|
||||
|
||||
$self->{block} = { block_size => hex(@{$result}[5]->{result}->{size}),
|
||||
block_gas => hex(@{$result}[5]->{result}->{gasUsed}),
|
||||
block_usage => $calculated_block_usage,
|
||||
block_uncles => scalar(@{$$result[5]->{result}->{uncles}}),
|
||||
block_transactions => scalar(@{$$result[5]->{result}->{transactions}})};
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check eth module metrics parity (Gas, blocks and syncing status)
|
|
@ -0,0 +1,82 @@
|
|||
#
|
||||
# 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::restapi::mode::infos;
|
||||
|
||||
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 check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
$self->change_macros(macros => ['unknown_status', 'warning_status', 'critical_status']);
|
||||
}
|
||||
|
||||
sub prefix_module_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Parity network module: ";
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{cache_name} = "parity_restapi_" . $self->{mode} . '_' . (defined($self->{option_results}->{hostname}) ? $self->{option_results}->{hostname} : 'me') . '_' .
|
||||
(defined($self->{option_results}->{port}) ? $self->{option_results}->{port} : 'default') . '_' .
|
||||
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
|
||||
|
||||
my $query_form_post = [ { method => 'parity_versionInfo', params => [], id => "1", jsonrpc => "2.0" },
|
||||
{ method => 'parity_chain', params => [], id => "2", jsonrpc => "2.0" },
|
||||
{ method => 'eth_mining', params => [], id => "3", jsonrpc => "2.0" },
|
||||
{ method => 'parity_nodeName', params => [], id => "4", jsonrpc => "2.0" }, ];
|
||||
|
||||
my $result = $options{custom}->request_api(method => 'POST', query_form_post => $query_form_post);
|
||||
|
||||
my $res_parity_version = @{$result}[0]->{result}->{version}->{major} . '.' . @{$result}[0]->{result}->{version}->{minor} . '.' . @{$result}[0]->{result}->{version}->{patch};
|
||||
|
||||
$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');
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check parity network cross module metrics (Parity version, chain name and node name and type)
|
|
@ -0,0 +1,108 @@
|
|||
#
|
||||
# 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::restapi::mode::net;
|
||||
|
||||
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 custom_status_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return sprintf(
|
||||
'Listening status: %s ',
|
||||
$self->{result_values}->{listening},
|
||||
);
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'network', cb_prefix_output => 'prefix_module_output', type => 0 },
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{network} = [
|
||||
{ label => 'peers', nlabel => 'parity.network.peers.count', set => {
|
||||
key_values => [ { name => 'peers' } ],
|
||||
output_template => "connected peers: %s ",
|
||||
perfdatas => [
|
||||
{ label => 'peer_count', value => 'peers', template => '%d', min => 0 }
|
||||
],
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
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 check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
$self->change_macros(macros => ['unknown_status', 'warning_status', 'critical_status']);
|
||||
}
|
||||
|
||||
sub prefix_module_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Parity network module: ";
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{cache_name} = "parity_restapi_" . $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 $query_form_post = [ { method => 'net_listening', params => [], id => "1", jsonrpc => "2.0" },
|
||||
{ method => 'net_peerCount', params => [], id => "2", jsonrpc => "2.0" } ];
|
||||
|
||||
my $result = $options{custom}->request_api(method => 'POST', query_form_post => $query_form_post);
|
||||
|
||||
my $peer_count = hex(@{$result}[1]->{result});
|
||||
|
||||
$self->{network} = { peers => hex(@{$result}[1]->{result}) };
|
||||
|
||||
$self->{output}->output_add(long_msg => "Node status: [is_listening: " . @{$result}[0]->{result} . ']', severity => 'OK');
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check network module metrics parity (net_isListening, net_peerCount)
|
|
@ -0,0 +1,166 @@
|
|||
#
|
||||
# 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::restapi::mode::parity;
|
||||
|
||||
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 set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'mempool', cb_prefix_output => 'prefix_module_output', type => 0 },
|
||||
{ name => 'peers', cb_prefix_output => 'prefix_module_output', type => 0 }
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{mempool} = [
|
||||
{ label => 'mempool-tx-pending', nlabel => 'parity.pending.transactions', set => {
|
||||
key_values => [ { name => 'tx_pending' } ],
|
||||
output_template => "Pending transactions: %d",
|
||||
perfdatas => [
|
||||
{ label => 'tx_pending', value => 'tx_pending', template => '%d', min => 0 }
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'mempool-size', nlabel => 'parity.mempol.size', set => {
|
||||
key_values => [ { name => 'mempool_size' } ],
|
||||
output_template => "Mempool size: %d",
|
||||
perfdatas => [
|
||||
{ label => 'mempool_size', value => 'mempool_size', template => '%d', min => 0 }
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'mempool-usage', nlabel => 'parity.mempol.usage', set => {
|
||||
key_values => [ { name => 'mempool_usage' } ],
|
||||
output_template => "Mempool usage: %d %% ",
|
||||
perfdatas => [
|
||||
{ label => 'mempool_usage', value => 'mempool_usage', template => '%.2f', unit => '%', min => 0 }
|
||||
],
|
||||
}
|
||||
},
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{peers} = [
|
||||
{ label => 'peers-connected', nlabel => 'parity.peers.connected', set => {
|
||||
key_values => [ { name => 'peers_connected' } ],
|
||||
output_template => "Connected peers: %d",
|
||||
perfdatas => [
|
||||
{ label => 'peers_connected', value => 'peers_connected', template => '%d', min => 0 }
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'peers-max', nlabel => 'parity.peers.max', set => {
|
||||
key_values => [ { name => 'peers_max' } ],
|
||||
output_template => "Peers max: %d",
|
||||
perfdatas => [
|
||||
{ label => 'peers_max', value => 'peers_max', template => '%d', min => 0 }
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'peers-usage', nlabel => 'parity.peers.usage', set => {
|
||||
key_values => [ { name => 'peers_usage' } ],
|
||||
output_template => "Peers usage: %d %% ",
|
||||
perfdatas => [
|
||||
{ label => 'peers_usage', value => 'peers_usage', template => '%.2f', unit => '%', min => 0 }
|
||||
],
|
||||
}
|
||||
},
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
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);
|
||||
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 check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
$self->change_macros(macros => ['unknown_status', 'warning_status', 'critical_status']);
|
||||
}
|
||||
|
||||
sub prefix_module_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Parity module: ";
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{cache_name} = "parity_restapi_" . $self->{mode} . '_' . (defined($self->{option_results}->{hostname}) ? $self->{option_results}->{hostname} : 'me') . '_' .
|
||||
(defined($self->{option_results}->{port}) ? $self->{option_results}->{port} : 'default') . '_' .
|
||||
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
|
||||
|
||||
my $query_form_post = [ { method => 'parity_versionInfo', params => [], id => "1", jsonrpc => "2.0" },
|
||||
{ method => 'parity_chain', params => [], id => "2", jsonrpc => "2.0" },
|
||||
{ method => 'parity_pendingTransactions', params => [], id => "3", jsonrpc => "2.0" } ,
|
||||
{ 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" },
|
||||
{ method => 'net_peerCount', params => [], id => "8", jsonrpc => "2.0" } ];
|
||||
|
||||
my $result = $options{custom}->request_api(method => 'POST', query_form_post => $query_form_post);
|
||||
|
||||
my $res_parity_version = @{$result}[0]->{result}->{version}->{major} . '.' . @{$result}[0]->{result}->{version}->{minor} . '.' . @{$result}[0]->{result}->{version}->{patch};
|
||||
|
||||
$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,
|
||||
peers_max => @{$result}[3]->{result}->{max},
|
||||
peers_limit => @{$result}[3]->{result}->{max},
|
||||
peers_connected => @{$result}[3]->{result}->{connected} };
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check parity module metrics parity (Mempool and peers)
|
|
@ -0,0 +1,51 @@
|
|||
#
|
||||
# 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::restapi::plugin;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use base qw(centreon::plugins::script_custom);
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
'net' => 'blockchain::parity::restapi::mode::net',
|
||||
'eth' => 'blockchain::parity::restapi::mode::eth',
|
||||
'parity' => 'blockchain::parity::restapi::mode::parity',
|
||||
'infos' => 'blockchain::parity::restapi::mode::infos'
|
||||
);
|
||||
$self->{custom_modes}{api} = 'blockchain::parity::restapi::custom::api';
|
||||
return $self;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 PLUGIN DESCRIPTION
|
||||
|
||||
Check Parity blockchain with JSON RPC
|
||||
|
||||
=cut
|
|
@ -93,6 +93,8 @@ sub calc {
|
|||
$self->{result_values}->{$value->{name}} = ($options{new_datas}->{$self->{instance} . '_' . $value->{name}} - $options{old_datas}->{$self->{instance} . '_' . $value->{name}}) / $options{delta_time};
|
||||
} elsif (defined($value->{per_minute}) && $value->{per_minute} == 1) {
|
||||
$self->{result_values}->{$value->{name}} = ($options{new_datas}->{$self->{instance} . '_' . $value->{name}} - $options{old_datas}->{$self->{instance} . '_' . $value->{name}}) / ($options{delta_time} / 60);
|
||||
} elsif (defined($value->{per_hour}) && $value->{per_hour} == 1) {
|
||||
$self->{result_values}->{$value->{name}} = ($options{new_datas}->{$self->{instance} . '_' . $value->{name}} - $options{old_datas}->{$self->{instance} . '_' . $value->{name}}) / ($options{delta_time} / 3600);
|
||||
} else {
|
||||
$self->{result_values}->{$value->{name}} = $options{new_datas}->{$self->{instance} . '_' . $value->{name}};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue