add kafka jmx plugin
This commit is contained in:
parent
0ed32ab511
commit
6c00926923
|
@ -0,0 +1,191 @@
|
|||
#
|
||||
# Copyright 2019 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 apps::java::kafka::jmx::mode::stats;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Digest::MD5 qw(md5_hex);
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'global', type => 0, skipped_code => { -10 => 1 } },
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{global} = [
|
||||
{ label => 'leader-count', set => {
|
||||
key_values => [ { name => 'leader_count' } ],
|
||||
output_template => 'Leaders : %s',
|
||||
perfdatas => [
|
||||
{ label => 'leader_count', value => 'leader_count_absolute', template => '%s', min => 0 },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'active-controller-count', set => {
|
||||
key_values => [ { name => 'active_controller_count' } ],
|
||||
output_template => 'Active Controllers : %s',
|
||||
perfdatas => [
|
||||
{ label => 'active_controller_count', value => 'active_controller_count_absolute', template => '%s', min => 0 },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'partition-count', set => {
|
||||
key_values => [ { name => 'partition_count' } ],
|
||||
output_template => 'Partitions : %s',
|
||||
perfdatas => [
|
||||
{ label => 'partition_count', value => 'partition_count_absolute', template => '%s', min => 0 },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'offline-partitions-count', set => {
|
||||
key_values => [ { name => 'offline_partitions_count' } ],
|
||||
output_template => 'Offline partitions : %s',
|
||||
perfdatas => [
|
||||
{ label => 'offline_partitions_count', value => 'offline_partitions_count_absolute', template => '%s',
|
||||
min => 0 },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'under-replicated-partitions', set => {
|
||||
key_values => [ { name => 'under_replicated_partitions' } ],
|
||||
output_template => 'Under replicated partitions : %s',
|
||||
perfdatas => [
|
||||
{ label => 'under_replicated_partitions', value => 'under_replicated_partitions_absolute', template => '%s',
|
||||
min => 0 },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'unclean-leader-elections', set => {
|
||||
key_values => [ { name => 'unclean_leader_elections', diff => 1 } ],
|
||||
output_template => 'Number of unclean leader elections : %s',
|
||||
perfdatas => [
|
||||
{ label => 'unclean_leader_elections', value => 'unclean_leader_elections_absolute', template => '%s', min => 0 },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'traffic-in', set => {
|
||||
key_values => [ { name => 'traffic_in', diff => 1 } ],
|
||||
output_template => 'Traffic In : %s %s/s',
|
||||
per_second => 1, output_change_bytes => 2,
|
||||
perfdatas => [
|
||||
{ label => 'traffic_in', value => 'traffic_in_per_second', template => '%.2f',
|
||||
min => 0, unit => 'b/s' },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'traffic-out', set => {
|
||||
key_values => [ { name => 'traffic_out', diff => 1 } ],
|
||||
output_template => 'Traffic Out : %s %s/s',
|
||||
per_second => 1, output_change_bytes => 2,
|
||||
perfdatas => [
|
||||
{ label => 'traffic_out', value => 'traffic_out_per_second', template => '%.2f',
|
||||
min => 0, unit => 'b/s' },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'total-fetch-requests', set => {
|
||||
key_values => [ { name => 'total_fetch_requests', diff => 1 } ],
|
||||
output_template => 'Number of total fetch requests : %s',
|
||||
perfdatas => [
|
||||
{ label => 'total_fetch_requests', value => 'total_fetch_requests_absolute', template => '%s', min => 0 },
|
||||
],
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{request} = [
|
||||
{ mbean => 'kafka.server:name=UnderReplicatedPartitions,type=ReplicaManager', attributes => [ { name => 'Value' } ] },
|
||||
{ mbean => 'kafka.server:name=PartitionCount,type=ReplicaManager', attributes => [ { name => 'Value' } ] },
|
||||
{ mbean => 'kafka.server:name=LeaderCount,type=ReplicaManager', attributes => [ { name => 'Value' } ] },
|
||||
{ mbean => 'kafka.controller:name=OfflinePartitionsCount,type=KafkaController', attributes => [ { name => 'Value' } ] },
|
||||
{ mbean => 'kafka.controller:name=ActiveControllerCount,type=KafkaController', attributes => [ { name => 'Value' } ] },
|
||||
{ mbean => 'kafka.controller:name=UncleanLeaderElectionsPerSec,type=ControllerStats', attributes => [ { name => 'Count' } ] },
|
||||
{ mbean => 'kafka.server:name=BytesInPerSec,type=BrokerTopicMetrics', attributes => [ { name => 'Count' } ] },
|
||||
{ mbean => 'kafka.server:name=BytesOutPerSec,type=BrokerTopicMetrics', attributes => [ { name => 'Count' } ] },
|
||||
{ mbean => 'kafka.server:name=TotalFetchRequestsPerSec,type=BrokerTopicMetrics', attributes => [ { name => 'Count' } ] },
|
||||
];
|
||||
my $result = $options{custom}->get_attributes(request => $self->{request}, nothing_quit => 1);
|
||||
$self->{global} = {
|
||||
under_replicated_partitions => $result->{'kafka.server:name=UnderReplicatedPartitions,type=ReplicaManager'}->{Value},
|
||||
offline_partitions_count => $result->{'kafka.controller:name=OfflinePartitionsCount,type=KafkaController'}->{Value},
|
||||
partition_count => $result->{'kafka.server:name=PartitionCount,type=ReplicaManager'}->{Value},
|
||||
leader_count => $result->{'kafka.server:name=LeaderCount,type=ReplicaManager'}->{Value},
|
||||
active_controller_count => $result->{'kafka.controller:name=ActiveControllerCount,type=KafkaController'}->{Value},
|
||||
unclean_leader_elections => $result->{'kafka.controller:name=UncleanLeaderElectionsPerSec,type=ControllerStats'}->{Value},
|
||||
traffic_in => $result->{'kafka.server:name=BytesInPerSec,type=BrokerTopicMetrics'}->{Value} * 8,
|
||||
traffic_out => $result->{'kafka.server:name=BytesOutPerSec,type=BrokerTopicMetrics'}->{Value} * 8,
|
||||
total_fetch_requests => $result->{'kafka.server:name=TotalFetchRequestsPerSec,type=BrokerTopicMetrics'}->{Value},
|
||||
};
|
||||
|
||||
$self->{cache_name} = "kafka_" . $self->{mode} . '_' . md5_hex($options{custom}->get_connection_info()) . '_' .
|
||||
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check kafka global statistics.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--filter-counters>
|
||||
|
||||
Only display some counters (regexp can be used).
|
||||
Example: --filter-counters='^traffic-in$'
|
||||
|
||||
=item B<--warning-*>
|
||||
|
||||
Threshold warning.
|
||||
Can be: 'under-replicated-partitions', 'offline-partitions-count', 'partition-count', 'leader-count',
|
||||
'active-controller-count', 'unclean-leader-elections', 'traffic-in', 'traffic-out', 'total-fetch-requests'.
|
||||
|
||||
=item B<--critical-*>
|
||||
|
||||
Threshold critical.
|
||||
Can be: 'under-replicated-partitions', 'offline-partitions-count', 'partition-count', 'leader-count',
|
||||
'active-controller-count', 'unclean-leader-elections', 'traffic-in', 'traffic-out', 'total-fetch-requests'.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,49 @@
|
|||
#
|
||||
# Copyright 2019 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 apps::java::kafka::jmx::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}} = (
|
||||
'global-stats' => 'apps::java::kafka::jmx::mode::globalstats',
|
||||
);
|
||||
|
||||
$self->{custom_modes}{jolokia} = 'centreon::common::protocols::jmx::custom::jolokia';
|
||||
return $self;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 PLUGIN DESCRIPTION
|
||||
|
||||
Check Kafka in JMX. Need Jolokia agent.
|
||||
|
||||
=cut
|
Loading…
Reference in New Issue