counters split
This commit is contained in:
parent
42650ed68c
commit
f92d23fcce
|
@ -26,7 +26,7 @@ use strict;
|
|||
use warnings;
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc);
|
||||
|
||||
sub custom_mining_status_output {
|
||||
sub custom_status_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return sprintf(
|
||||
|
@ -39,30 +39,17 @@ sub set_counters {
|
|||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'eth', cb_prefix_output => 'prefix_module_output', type => 0 },
|
||||
{ name => 'global', cb_prefix_output => 'prefix_module_output', type => 0 },
|
||||
{ name => 'peer', 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}->{eth} = [
|
||||
{ label => 'is_mining', nlabel => 'parity.eth.peers.mining.status', set => {
|
||||
key_values => [ { name => 'is_mining' } ],
|
||||
output_template => "Client is mining: " . $self->can('custom_mining_status_output'),
|
||||
perfdatas => [
|
||||
{ label => 'is_mining', value => 'is_mining_absolute', template => '%s', min => 0 }
|
||||
],
|
||||
}
|
||||
},
|
||||
# { label => 'is_mining', nlabel => 'parity.eth.peers.mining.status', threshold => 0, set => {
|
||||
# key_values => [ { name => 'is_mining' } ],
|
||||
# output_template => "Client is mining: %s ",
|
||||
# closure_custom_calc => \&catalog_status_calc,
|
||||
# closure_custom_output => $self->can('custom_mining_status_output'),
|
||||
# closure_custom_perfdata => sub { return 0; },
|
||||
# closure_custom_threshold_check => \&catalog_status_threshold
|
||||
# }
|
||||
# },
|
||||
$self->{maps_counters}->{global} = [
|
||||
{ label => 'coinbase', nlabel => 'parity.eth.client.coinbase', set => {
|
||||
key_values => [ { name => 'coinbase' } ],
|
||||
output_template => "Client coinbase is: %s ",
|
||||
# closure_custom_perfdata => sub { return 0; }
|
||||
perfdatas => [
|
||||
{ label => 'client_coinbase', value => 'coinbase_absolute', template => '%s', min => 0 }
|
||||
],
|
||||
|
@ -75,6 +62,25 @@ sub set_counters {
|
|||
{ label => 'gas_price', value => 'gas_price_absolute', template => '%d', min => 0 }
|
||||
],
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{peer} = [
|
||||
# { label => 'status', nlabel => 'parity.eth.peers.mining.status', set => {
|
||||
# key_values => [ { name => 'is_mining' } ],
|
||||
# output_template => "Client is mining: " . $self->can('custom_mining_status_output'),
|
||||
# perfdatas => [
|
||||
# { label => 'is_mining', value => 'is_mining_absolute', template => '%s', min => 0 }
|
||||
# ],
|
||||
# }
|
||||
# },
|
||||
{ label => 'status', threshold => 0, set => {
|
||||
key_values => [ { name => 'is_mining' } ],
|
||||
closure_custom_calc => \&catalog_status_calc,
|
||||
closure_custom_output => $self->can('custom_status_output'),
|
||||
closure_custom_perfdata => sub { return 0; },
|
||||
closure_custom_threshold_check => \&catalog_status_threshold
|
||||
}
|
||||
},
|
||||
{ label => 'hashrate', nlabel => 'parity.eth.node.hashrate', set => {
|
||||
key_values => [ { name => 'hashrate' } ],
|
||||
|
@ -84,41 +90,52 @@ sub set_counters {
|
|||
],
|
||||
}
|
||||
},
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{block} = [
|
||||
{ label => 'block_number', nlabel => 'parity.eth.block.number', set => {
|
||||
key_values => [ { name => 'block_number' } ],
|
||||
output_template => "Most recent block number is: %d ",
|
||||
perfdatas => [
|
||||
{ label => 'block_number', value => 'block_number_absolute', template => '%d', min => 0 }
|
||||
],
|
||||
closure_custom_perfdata => sub { return 0; }
|
||||
# perfdatas => [
|
||||
# { label => 'block_number', value => 'block_number_absolute', template => '%d', min => 0 }
|
||||
# ],
|
||||
}
|
||||
},
|
||||
{ label => 'block_time', nlabel => 'parity.eth.block.time', set => {
|
||||
key_values => [ { name => 'block_time' } ],
|
||||
output_template => "Block time is: %s ",
|
||||
perfdatas => [
|
||||
{ label => 'block_time', value => 'block_time_absolute', template => '%s', min => 0 }
|
||||
],
|
||||
closure_custom_perfdata => sub { return 0; }
|
||||
# perfdatas => [
|
||||
# { label => 'block_time', value => 'block_time_absolute', template => '%s', min => 0 }
|
||||
# ],
|
||||
}
|
||||
},
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{sync} = [
|
||||
{ label => 'sync_start', nlabel => 'parity.eth.sync.start.block', set => {
|
||||
key_values => [ { name => 'sync_start' } ],
|
||||
output_template => "Sync start block number is: %d ",
|
||||
perfdatas => [
|
||||
{ label => 'sync_start', value => 'sync_start_absolute', template => '%d', min => 0 }
|
||||
],
|
||||
closure_custom_perfdata => sub { return 0; }
|
||||
# perfdatas => [
|
||||
# { label => 'sync_start', value => 'sync_start_absolute', template => '%d', min => 0 }
|
||||
# ],
|
||||
}
|
||||
},
|
||||
{ label => 'sync_current', nlabel => 'parity.eth.sync.current.block', set => {
|
||||
key_values => [ { name => 'sync_current' } ],
|
||||
output_template => "Sync current block number is: %d ",
|
||||
perfdatas => [
|
||||
{ label => 'sync_current', value => 'sync_current_absolute', template => '%d', min => 0 }
|
||||
],
|
||||
closure_custom_perfdata => sub { return 0; }
|
||||
# perfdatas => [
|
||||
# { label => 'sync_current', value => 'sync_current_absolute', template => '%d', min => 0 }
|
||||
# ],
|
||||
}
|
||||
},
|
||||
{ label => 'sync_highest', nlabel => 'parity.eth.sync.highest.block', set => {
|
||||
key_values => [ { name => 'sync_highest' } ],
|
||||
output_template => "Sync highest block number is: %d ",
|
||||
# closure_custom_perfdata => sub { return 0; }
|
||||
perfdatas => [
|
||||
{ label => 'sync_highest', value => 'sync_highest_absolute', template => '%d', min => 0 }
|
||||
],
|
||||
|
@ -131,7 +148,7 @@ sub set_counters {
|
|||
{ label => 'sync', value => 'sync_absolute', template => '%d', min => 0 }
|
||||
],
|
||||
}
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -169,31 +186,36 @@ sub manage_selection {
|
|||
{ 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","false"], id => "6", 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);
|
||||
|
||||
|
||||
# use Data::Dumper;
|
||||
# print Dumper($result);
|
||||
|
||||
# conditional formating:
|
||||
my $res_sync = @{$result}[6]->{result} ? hex((@{$result}[6]->{result}->{currentBlock} / @{$result}[6]->{result}->{highestBlock})) * 100 : 100;
|
||||
my $res_startingBlock = $res_sync != 100 ? @{$result}[6]->{result}->{startingBlock} : undef;
|
||||
my $res_currentBlock = $res_sync != 100 ? @{$result}[6]->{result}->{currentBlock} : undef;
|
||||
my $res_highestBlock = $res_sync != 100 ? @{$result}[6]->{result}->{highestBlock} : undef;
|
||||
my $res_startingBlock = $res_sync != 100 ? hex(@{$result}[6]->{result}->{startingBlock}) : undef;
|
||||
my $res_currentBlock = $res_sync != 100 ? hex(@{$result}[6]->{result}->{currentBlock}) : undef;
|
||||
my $res_highestBlock = $res_sync != 100 ? hex(@{$result}[6]->{result}->{highestBlock}) : undef;
|
||||
|
||||
# Unix time conversion
|
||||
my $res_timestamp = localtime(hex(@{$result}[5]->{result}->{timestamp}));
|
||||
|
||||
$self->{eth} = { is_mining => @{$result}[0]->{result},
|
||||
coinbase => @{$result}[1]->{result},
|
||||
gas_price => hex(@{$result}[2]->{result}),
|
||||
hashrate => hex(@{$result}[3]->{result}),
|
||||
block_number => hex(@{$result}[4]->{result}),
|
||||
block_time => $res_timestamp,
|
||||
sync_start => hex($res_startingBlock),
|
||||
sync_current => hex($res_currentBlock),
|
||||
sync_highest => hex($res_highestBlock),
|
||||
$self->{global} = { coinbase => @{$result}[1]->{result},
|
||||
gas_price => hex(@{$result}[2]->{result}) };
|
||||
|
||||
$self->{block} = { block_number => defined @{$result}[4]->{result} ? hex(@{$result}[4]->{result}) : 0,
|
||||
block_time => $res_timestamp };
|
||||
|
||||
$self->{sync} = { sync_start => $res_startingBlock,
|
||||
sync_current => $res_currentBlock,
|
||||
sync_highest => $res_highestBlock,
|
||||
sync => $res_sync };
|
||||
|
||||
$self->{peer} = { is_mining => @{$result}[0]->{result},
|
||||
hashrate => hex(@{$result}[3]->{result}) };
|
||||
}
|
||||
|
||||
1;
|
||||
|
@ -216,7 +238,7 @@ Set warning threshold for listening status (Default: '').
|
|||
|
||||
=item B<--critical-status>
|
||||
|
||||
Set critical threshold for listening status (Default: '%{listening} !~ /true/').
|
||||
Set critical threshold for listening status (Default: '%{is_mining} !~ /true/').
|
||||
|
||||
=item B<--warning-peers> B<--critical-peers>
|
||||
|
||||
|
|
|
@ -30,50 +30,64 @@ sub set_counters {
|
|||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'parity', cb_prefix_output => 'prefix_module_output', type => 0 },
|
||||
{ name => 'global', cb_prefix_output => 'prefix_module_output', type => 0 },
|
||||
{ name => 'node', cb_prefix_output => 'prefix_module_output', type => 0 },
|
||||
{ name => 'mempool', cb_prefix_output => 'prefix_module_output', type => 0 },
|
||||
{ name => 'network', cb_prefix_output => 'prefix_module_output', type => 0 }
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{parity} = [
|
||||
$self->{maps_counters}->{global} = [
|
||||
{ label => 'parity_version', nlabel => 'parity.version', set => {
|
||||
key_values => [ { name => 'parity_version' } ],
|
||||
output_template => "Parity version is: %s ",
|
||||
perfdatas => [
|
||||
{ label => 'parity_version', value => 'parity_version_absolute', template => '%s', min => 0 }
|
||||
],
|
||||
closure_custom_perfdata => sub { return 0; }
|
||||
# perfdatas => [
|
||||
# { label => 'parity_version', value => 'parity_version_absolute', template => '%s', min => 0 }
|
||||
# ],
|
||||
}
|
||||
},
|
||||
{ label => 'parity_version_hash', nlabel => 'parity.version.hash', set => {
|
||||
key_values => [ { name => 'parity_version_hash' } ],
|
||||
output_template => "Parity version hash is: %s ",
|
||||
perfdatas => [
|
||||
{ label => 'parity_version_hash', value => 'parity_version_hash_absolute', template => '%s', min => 0 }
|
||||
],
|
||||
closure_custom_perfdata => sub { return 0; }
|
||||
# perfdatas => [
|
||||
# { label => 'parity_version_hash', value => 'parity_version_hash_absolute', template => '%s', min => 0 }
|
||||
# ],
|
||||
}
|
||||
},
|
||||
{ label => 'chain_name', nlabel => 'parity.chain.name', set => {
|
||||
key_values => [ { name => 'chain_name' } ],
|
||||
output_template => "Chain name is: %s ",
|
||||
perfdatas => [
|
||||
{ label => 'chain_name', value => 'chain_name_absolute', template => '%s', min => 0 }
|
||||
],
|
||||
closure_custom_perfdata => sub { return 0; }
|
||||
# perfdatas => [
|
||||
# { label => 'chain_name', value => 'chain_name_absolute', template => '%s', min => 0 }
|
||||
# ],
|
||||
}
|
||||
},
|
||||
{ label => 'pending_transactions', nlabel => 'parity.pending.transactions', set => {
|
||||
key_values => [ { name => 'pending_transactions' } ],
|
||||
output_template => "Pending transactions: %d ",
|
||||
perfdatas => [
|
||||
{ label => 'pending_transactions', value => 'pending_transactions_absolute', template => '%d', min => 0 }
|
||||
],
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{node} = [
|
||||
{ label => 'enode', nlabel => 'parity.node.enode.uri', set => {
|
||||
key_values => [ { name => 'enode' } ],
|
||||
output_template => "Node enode URI: %s ",
|
||||
closure_custom_perfdata => sub { return 0; }
|
||||
# perfdatas => [
|
||||
# { label => 'enode', value => 'enode_absolute', template => '%s', min => 0 }
|
||||
# ],
|
||||
}
|
||||
},
|
||||
{ label => 'mempool', nlabel => 'parity.mempol.capacity', set => {
|
||||
key_values => [ { name => 'mempool' } ],
|
||||
output_template => "Mempool: %d % ",
|
||||
perfdatas => [
|
||||
{ label => 'mempool', value => 'mempool_absolute', template => '%d', min => 0 }
|
||||
],
|
||||
{ label => 'node_name', nlabel => 'parity.node.name', set => {
|
||||
key_values => [ { name => 'node_name' } ],
|
||||
output_template => "Node name: %s ",
|
||||
closure_custom_perfdata => sub { return 0; }
|
||||
# perfdatas => [
|
||||
# { label => 'node_name', value => 'node_name_absolute', template => '%s', min => 0 }
|
||||
# ],
|
||||
}
|
||||
},
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{network} = [
|
||||
{ label => 'peers_connected', nlabel => 'parity.peers.connected', set => {
|
||||
key_values => [ { name => 'peers_connected' } ],
|
||||
output_template => "Number of connected peers: %d ",
|
||||
|
@ -97,24 +111,28 @@ sub set_counters {
|
|||
{ label => 'peers', value => 'peers_absolute', template => '%d', min => 0 }
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'enode', nlabel => 'parity.node.enode.uri', set => {
|
||||
key_values => [ { name => 'enode' } ],
|
||||
output_template => "Node enode URI: %s ",
|
||||
perfdatas => [
|
||||
{ label => 'enode', value => 'enode_absolute', template => '%s', min => 0 }
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'node_name', nlabel => 'parity.node.name', set => {
|
||||
key_values => [ { name => 'node_name' } ],
|
||||
output_template => "Node name: %s ",
|
||||
perfdatas => [
|
||||
{ label => 'node_name', value => 'node_name_absolute', template => '%s', min => 0 }
|
||||
],
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{mempool} = [
|
||||
{ label => 'pending_transactions', nlabel => 'parity.pending.transactions', set => {
|
||||
key_values => [ { name => 'pending_transactions' } ],
|
||||
output_template => "Pending transactions: %d ",
|
||||
perfdatas => [
|
||||
{ label => 'pending_transactions', value => 'pending_transactions_absolute', template => '%d', min => 0 }
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'mempool', nlabel => 'parity.mempol.capacity', set => {
|
||||
key_values => [ { name => 'mempool' } ],
|
||||
output_template => "Mempool: %d % ",
|
||||
perfdatas => [
|
||||
{ label => 'mempool', value => 'mempool_absolute', template => '%d', min => 0 }
|
||||
],
|
||||
}
|
||||
},
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
sub new {
|
||||
|
@ -152,24 +170,32 @@ sub manage_selection {
|
|||
{ 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" } # could be done once, at the beginning of the process
|
||||
];
|
||||
{ method => 'parity_transactionsLimit', params => [], id => "7", jsonrpc => "2.0" } ]; # parity_transactionsLimit could be done once, at the beginning of the process
|
||||
|
||||
|
||||
my $result = $options{custom}->request_api(method => 'POST', query_form_post => $query_form_post);
|
||||
|
||||
# Parity version construction
|
||||
my $res_parity_version = @{$result}[0]->{result}->{version}->{major} . @{$result}[0]->{result}->{version}->{minor} . @{$result}[0]->{result}->{version}->{patch};
|
||||
my $res_parity_version = @{$result}[0]->{result}->{version}->{major} . '.' . @{$result}[0]->{result}->{version}->{minor} . '.' . @{$result}[0]->{result}->{version}->{patch};
|
||||
|
||||
$self->{eth} = { parity_version => $res_parity_version,
|
||||
parity_version_hash => @{$result}[0]->{result}->{hash},
|
||||
chain_name => @{$result}[1]->{result},
|
||||
pending_transactions => scalar @{$result}[2]->{result},
|
||||
mempool => @{$result}[2]->{result} / @{$result}[6]->{result} * 100,
|
||||
peers_connected => @{$result}[3]->{result}->{connected},
|
||||
peers_max => @{$result}[3]->{result}->{max},
|
||||
peers => scalar @{$result}[3]->{result}->{peers},
|
||||
enode => @{$result}[4]->{result},
|
||||
node_name => @{$result}[5]->{result} };
|
||||
|
||||
# use Data::Dumper;
|
||||
# print Dumper($res_parity_version);
|
||||
|
||||
|
||||
$self->{global} = { parity_version => $res_parity_version,
|
||||
parity_version_hash => @{$result}[0]->{result}->{hash},
|
||||
chain_name => @{$result}[1]->{result} };
|
||||
|
||||
$self->{node} = { enode => @{$result}[4]->{result},
|
||||
node_name => @{$result}[5]->{result} };
|
||||
|
||||
$self->{network} = { peers_connected => @{$result}[3]->{result}->{connected},
|
||||
peers_max => @{$result}[3]->{result}->{max},
|
||||
peers => length(@{$result}[3]->{result}->{peers}) };
|
||||
|
||||
$self->{mempool} = { pending_transactions => length(@{$result}[2]->{result}),
|
||||
mempool => @{$result}[2]->{result} / @{$result}[6]->{result} * 100 };
|
||||
|
||||
}
|
||||
|
||||
|
@ -179,7 +205,7 @@ __END__
|
|||
|
||||
=head1 MODE
|
||||
|
||||
Check parity module metrics parity (parity_versionInfo, )
|
||||
Check parity module metrics parity (parity_versionInfo, parity_chain, parity_pendingTransactions, parity_netPeers, parity_enode, parity_nodeName, parity_transactionsLimit)
|
||||
|
||||
=over 8
|
||||
|
||||
|
|
Loading…
Reference in New Issue