mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-28 08:04:36 +02:00
use diff in warp10 modes
This commit is contained in:
parent
a7393fe4b0
commit
d5dcba0fe3
@ -25,6 +25,7 @@ use base qw(centreon::plugins::templates::counter);
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use centreon::common::monitoring::openmetrics::scrape;
|
use centreon::common::monitoring::openmetrics::scrape;
|
||||||
|
use Digest::MD5 qw(md5_hex);
|
||||||
|
|
||||||
sub set_counters {
|
sub set_counters {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
@ -35,8 +36,8 @@ sub set_counters {
|
|||||||
];
|
];
|
||||||
|
|
||||||
$self->{maps_counters}->{fetchs} = [
|
$self->{maps_counters}->{fetchs} = [
|
||||||
{ label => 'calls', nlabel => 'fetch.calls.count', set => {
|
{ label => 'calls-count', nlabel => 'fetch.calls.count', set => {
|
||||||
key_values => [ { name => 'calls' }, { name => 'display' } ],
|
key_values => [ { name => 'calls', diff => 1 }, { name => 'display' } ],
|
||||||
output_template => 'Calls: %d',
|
output_template => 'Calls: %d',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ value => 'calls_absolute', template => '%d',
|
{ value => 'calls_absolute', template => '%d',
|
||||||
@ -44,8 +45,18 @@ sub set_counters {
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'bytes-values', nlabel => 'fetch.bytes.values.bytes', set => {
|
{ label => 'calls-persecond', nlabel => 'fetch.calls.persecond', set => {
|
||||||
key_values => [ { name => 'bytes_values' }, { name => 'display' } ],
|
key_values => [ { name => 'calls', diff => 1 }, { name => 'display' } ],
|
||||||
|
per_second => 1,
|
||||||
|
output_template => 'Calls (per second): %.2f',
|
||||||
|
perfdatas => [
|
||||||
|
{ value => 'calls_per_second', template => '%.2f',
|
||||||
|
min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'bytes-values-count', nlabel => 'fetch.bytes.values.bytes', set => {
|
||||||
|
key_values => [ { name => 'bytes_values', diff => 1 }, { name => 'display' } ],
|
||||||
output_template => 'Bytes Values: %s%s',
|
output_template => 'Bytes Values: %s%s',
|
||||||
output_change_bytes => 1,
|
output_change_bytes => 1,
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
@ -54,8 +65,18 @@ sub set_counters {
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'bytes-keys', nlabel => 'fetch.bytes.keys.bytes', set => {
|
{ label => 'bytes-values-persecond', nlabel => 'fetch.bytes.values.bytespersecond', set => {
|
||||||
key_values => [ { name => 'bytes_keys' }, { name => 'display' } ],
|
key_values => [ { name => 'bytes_values', diff => 1 }, { name => 'display' } ],
|
||||||
|
output_change_bytes => 1, per_second => 1,
|
||||||
|
output_template => 'Bytes Values (per second): %s%s/s',
|
||||||
|
perfdatas => [
|
||||||
|
{ value => 'bytes_values_per_second', template => '%s',
|
||||||
|
min => 0, unit => 'B/s', label_extra_instance => 1, instance_use => 'display_absolute' },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'bytes-keys-count', nlabel => 'fetch.bytes.keys.bytes', set => {
|
||||||
|
key_values => [ { name => 'bytes_keys', diff => 1 }, { name => 'display' } ],
|
||||||
output_template => 'Bytes Keys: %s%s',
|
output_template => 'Bytes Keys: %s%s',
|
||||||
output_change_bytes => 1,
|
output_change_bytes => 1,
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
@ -64,6 +85,16 @@ sub set_counters {
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{ label => 'bytes-keys-persecond', nlabel => 'fetch.bytes.keys.bytespersecond', set => {
|
||||||
|
key_values => [ { name => 'bytes_keys', diff => 1 }, { name => 'display' } ],
|
||||||
|
output_change_bytes => 1, per_second => 1,
|
||||||
|
output_template => 'Bytes Keys (per second): %s%s/s',
|
||||||
|
perfdatas => [
|
||||||
|
{ value => 'bytes_keys_per_second', template => '%s',
|
||||||
|
min => 0, unit => 'B/s', label_extra_instance => 1, instance_use => 'display_absolute' },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +106,7 @@ sub prefix_output {
|
|||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my ($class, %options) = @_;
|
my ($class, %options) = @_;
|
||||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1, force_new_perfdata => 1);
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
@ -88,6 +119,10 @@ sub new {
|
|||||||
sub manage_selection {
|
sub manage_selection {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->{cache_name} = "warp10_" . $self->{mode} . '_' .
|
||||||
|
(defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')) . '_' .
|
||||||
|
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
|
||||||
|
|
||||||
$self->{metrics} = centreon::common::monitoring::openmetrics::scrape::parse(%options);
|
$self->{metrics} = centreon::common::monitoring::openmetrics::scrape::parse(%options);
|
||||||
|
|
||||||
foreach my $fetch (@{$self->{metrics}->{'warp.fetch.count'}->{data}}) {
|
foreach my $fetch (@{$self->{metrics}->{'warp.fetch.count'}->{data}}) {
|
||||||
@ -134,12 +169,12 @@ Filter app name (can be a regexp).
|
|||||||
Only display some counters (regexp can be used).
|
Only display some counters (regexp can be used).
|
||||||
Example: --filter-counters='calls'
|
Example: --filter-counters='calls'
|
||||||
|
|
||||||
=item B<--warning-*>
|
=item B<--warning-*-count/persecond>
|
||||||
|
|
||||||
Threshold warning.
|
Threshold warning.
|
||||||
Can be: 'calls', 'bytes-values', 'bytes-keys'.
|
Can be: 'calls', 'bytes-values', 'bytes-keys'.
|
||||||
|
|
||||||
=item B<--critical-*>
|
=item B<--critical-*-count/persecond>
|
||||||
|
|
||||||
Threshold critical.
|
Threshold critical.
|
||||||
Can be: 'calls', 'bytes-values', 'bytes-keys'.
|
Can be: 'calls', 'bytes-values', 'bytes-keys'.
|
||||||
|
@ -25,6 +25,7 @@ use base qw(centreon::plugins::templates::counter);
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use centreon::common::monitoring::openmetrics::scrape;
|
use centreon::common::monitoring::openmetrics::scrape;
|
||||||
|
use Digest::MD5 qw(md5_hex);
|
||||||
|
|
||||||
sub set_counters {
|
sub set_counters {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
@ -37,7 +38,7 @@ sub set_counters {
|
|||||||
|
|
||||||
$self->{maps_counters}->{global} = [
|
$self->{maps_counters}->{global} = [
|
||||||
{ label => 'time-total', nlabel => 'time.total.microseconds', set => {
|
{ label => 'time-total', nlabel => 'time.total.microseconds', set => {
|
||||||
key_values => [ { name => 'time' } ],
|
key_values => [ { name => 'time', diff => 1 } ],
|
||||||
output_template => 'Time Spent: %d us',
|
output_template => 'Time Spent: %d us',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ value => 'time_absolute', template => '%d',
|
{ value => 'time_absolute', template => '%d',
|
||||||
@ -45,8 +46,8 @@ sub set_counters {
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'requests', nlabel => 'requests.count', set => {
|
{ label => 'requests-count', nlabel => 'requests.count', set => {
|
||||||
key_values => [ { name => 'requests' } ],
|
key_values => [ { name => 'requests', diff => 1 } ],
|
||||||
output_template => 'Requests: %d',
|
output_template => 'Requests: %d',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ value => 'requests_absolute', template => '%d',
|
{ value => 'requests_absolute', template => '%d',
|
||||||
@ -54,8 +55,18 @@ sub set_counters {
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'ops', nlabel => 'ops.count', set => {
|
{ label => 'requests-persecond', nlabel => 'requests.persecond', set => {
|
||||||
key_values => [ { name => 'ops' } ],
|
key_values => [ { name => 'requests', diff => 1 } ],
|
||||||
|
per_second => 1,
|
||||||
|
output_template => 'Requests (per second): %.2f',
|
||||||
|
perfdatas => [
|
||||||
|
{ value => 'requests_per_second', template => '%.2f',
|
||||||
|
min => 0 },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'ops-count', nlabel => 'ops.count', set => {
|
||||||
|
key_values => [ { name => 'ops', diff => 1 } ],
|
||||||
output_template => 'Ops: %d',
|
output_template => 'Ops: %d',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ value => 'ops_absolute', template => '%d',
|
{ value => 'ops_absolute', template => '%d',
|
||||||
@ -63,8 +74,18 @@ sub set_counters {
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'errors', nlabel => 'errors.count', set => {
|
{ label => 'ops-persecond', nlabel => 'ops.persecond', set => {
|
||||||
key_values => [ { name => 'errors' } ],
|
key_values => [ { name => 'ops', diff => 1 } ],
|
||||||
|
per_second => 1,
|
||||||
|
output_template => 'Ops (per second): %.2f',
|
||||||
|
perfdatas => [
|
||||||
|
{ value => 'ops_per_second', template => '%.2f',
|
||||||
|
min => 0 },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'errors-count', nlabel => 'errors.count', set => {
|
||||||
|
key_values => [ { name => 'errors', diff => 1 } ],
|
||||||
output_template => 'Errors: %d',
|
output_template => 'Errors: %d',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ value => 'errors_absolute', template => '%d',
|
{ value => 'errors_absolute', template => '%d',
|
||||||
@ -72,8 +93,18 @@ sub set_counters {
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'bootstrap-loads', nlabel => 'bootstrap.loads.count', set => {
|
{ label => 'errors-persecond', nlabel => 'errors.persecond', set => {
|
||||||
key_values => [ { name => 'bootstrap_loads' } ],
|
key_values => [ { name => 'errors', diff => 1 } ],
|
||||||
|
per_second => 1,
|
||||||
|
output_template => 'Errors (per second): %.2f',
|
||||||
|
perfdatas => [
|
||||||
|
{ value => 'errors_per_second', template => '%.2f',
|
||||||
|
min => 0 },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'bootstrap-loads-count', nlabel => 'bootstrap.loads.count', set => {
|
||||||
|
key_values => [ { name => 'bootstrap_loads', diff => 1 } ],
|
||||||
output_template => 'Bootstrap Loads: %d',
|
output_template => 'Bootstrap Loads: %d',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ value => 'bootstrap_loads_absolute', template => '%d',
|
{ value => 'bootstrap_loads_absolute', template => '%d',
|
||||||
@ -81,10 +112,20 @@ sub set_counters {
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{ label => 'bootstrap-loads-persecond', nlabel => 'bootstrap.loads.persecond', set => {
|
||||||
|
key_values => [ { name => 'bootstrap_loads', diff => 1 } ],
|
||||||
|
per_second => 1,
|
||||||
|
output_template => 'Bootstrap Loads (per second): %.2f',
|
||||||
|
perfdatas => [
|
||||||
|
{ value => 'bootstrap_loads_per_second', template => '%.2f',
|
||||||
|
min => 0 },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
];
|
];
|
||||||
$self->{maps_counters}->{functions} = [
|
$self->{maps_counters}->{functions} = [
|
||||||
{ label => 'time', nlabel => 'function.time.microseconds', set => {
|
{ label => 'time', nlabel => 'function.time.microseconds', set => {
|
||||||
key_values => [ { name => 'time' }, { name => 'display' } ],
|
key_values => [ { name => 'time', diff => 1 }, { name => 'display' } ],
|
||||||
output_template => 'Time Spent: %d us',
|
output_template => 'Time Spent: %d us',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ value => 'time_absolute', template => '%d',
|
{ value => 'time_absolute', template => '%d',
|
||||||
@ -92,8 +133,8 @@ sub set_counters {
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'uses', nlabel => 'function.uses.count', set => {
|
{ label => 'uses-count', nlabel => 'function.uses.count', set => {
|
||||||
key_values => [ { name => 'count' }, { name => 'display' } ],
|
key_values => [ { name => 'count', diff => 1 }, { name => 'display' } ],
|
||||||
output_template => 'Uses: %d',
|
output_template => 'Uses: %d',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ value => 'count_absolute', template => '%d',
|
{ value => 'count_absolute', template => '%d',
|
||||||
@ -101,6 +142,16 @@ sub set_counters {
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{ label => 'uses-persecond', nlabel => 'function.uses.persecond', set => {
|
||||||
|
key_values => [ { name => 'count', diff => 1 }, { name => 'display' } ],
|
||||||
|
per_second => 1,
|
||||||
|
output_template => 'Uses (per second): %.2f',
|
||||||
|
perfdatas => [
|
||||||
|
{ value => 'count_per_second', template => '%.2f',
|
||||||
|
min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,7 +163,7 @@ sub prefix_output {
|
|||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my ($class, %options) = @_;
|
my ($class, %options) = @_;
|
||||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1, force_new_perfdata => 1);
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
@ -125,6 +176,10 @@ sub new {
|
|||||||
sub manage_selection {
|
sub manage_selection {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->{cache_name} = "warp10_" . $self->{mode} . '_' .
|
||||||
|
(defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')) . '_' .
|
||||||
|
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
|
||||||
|
|
||||||
$self->{functions} = {};
|
$self->{functions} = {};
|
||||||
$self->{metrics} = centreon::common::monitoring::openmetrics::scrape::parse(%options);
|
$self->{metrics} = centreon::common::monitoring::openmetrics::scrape::parse(%options);
|
||||||
|
|
||||||
@ -176,17 +231,17 @@ Filter function name (can be a regexp).
|
|||||||
Only display some counters (regexp can be used).
|
Only display some counters (regexp can be used).
|
||||||
Example: --filter-counters='^time$|uses'
|
Example: --filter-counters='^time$|uses'
|
||||||
|
|
||||||
=item B<--warning-*>
|
=item B<--warning-*-count/persecond>
|
||||||
|
|
||||||
Threshold warning.
|
Threshold warning.
|
||||||
Can be: 'time-total', 'requests', 'ops',
|
Can be: 'time-total' (delta), 'requests', 'ops',
|
||||||
'errors', 'bootstrap-loads', 'time', 'uses'.
|
'errors', 'bootstrap-loads', 'time' (delta), 'uses'.
|
||||||
|
|
||||||
=item B<--critical-*>
|
=item B<--critical-*-count/persecond>
|
||||||
|
|
||||||
Threshold critical.
|
Threshold critical.
|
||||||
Can be: 'time-total', 'requests', 'ops',
|
Can be: 'time-total' (delta), 'requests', 'ops',
|
||||||
'errors', 'bootstrap-loads', 'time', 'uses'.
|
'errors', 'bootstrap-loads', 'time' (delta), 'uses'.
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user