From 4b8e193dc49eccecbf45728100b026bd0224784c Mon Sep 17 00:00:00 2001 From: Florian Asche Date: Fri, 22 Jan 2016 21:42:16 +0100 Subject: [PATCH 1/5] Added new apcupsd format --- apps/apcupsd/local/mode/libgetdata.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/apcupsd/local/mode/libgetdata.pm b/apps/apcupsd/local/mode/libgetdata.pm index f82e703b9..0d9f3d4e1 100644 --- a/apps/apcupsd/local/mode/libgetdata.pm +++ b/apps/apcupsd/local/mode/libgetdata.pm @@ -41,7 +41,7 @@ sub getdata { my ($value); #print $stdout; foreach (split(/\n/, $stdout)) { - if (/^$searchpattern\s*:\s*(.*)\s(Percent Load Capacity|Percent|Minutes|Seconds|Volts|Hz|seconds|C|F Internal)/i) { + if (/^$searchpattern\s*:\s*(.*)\s(Percent Load Capacity|Percent|Minutes|Seconds|Volts|Hz|seconds|C|F Internal|C|F)/i) { $valueok = "1"; $value = $1; #print $value; From f600935b057cad2e9e32911ee0d1dfdbe81c11fa Mon Sep 17 00:00:00 2001 From: Florian Asche Date: Tue, 2 Feb 2016 15:06:06 +0100 Subject: [PATCH 2/5] Update libgetdata.pm --- apps/apcupsd/local/mode/libgetdata.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/apcupsd/local/mode/libgetdata.pm b/apps/apcupsd/local/mode/libgetdata.pm index 0d9f3d4e1..a3710515f 100644 --- a/apps/apcupsd/local/mode/libgetdata.pm +++ b/apps/apcupsd/local/mode/libgetdata.pm @@ -41,7 +41,7 @@ sub getdata { my ($value); #print $stdout; foreach (split(/\n/, $stdout)) { - if (/^$searchpattern\s*:\s*(.*)\s(Percent Load Capacity|Percent|Minutes|Seconds|Volts|Hz|seconds|C|F Internal|C|F)/i) { + if (/^$searchpattern\s*:\s*(.*)\s(Percent Load Capacity|Percent|Minutes|Seconds|Volts|Hz|seconds|C Internal|F Internal|C|F)/i) { $valueok = "1"; $value = $1; #print $value; From f8bf73bbcc81eb11593fa0da5e61b0dbb1bb6305 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 3 Feb 2016 10:32:12 +0100 Subject: [PATCH 3/5] + Remove dead code --- network/bluecoat/snmp/mode/hardware.pm | 4 ---- 1 file changed, 4 deletions(-) diff --git a/network/bluecoat/snmp/mode/hardware.pm b/network/bluecoat/snmp/mode/hardware.pm index 9ec141824..e96ca16e9 100644 --- a/network/bluecoat/snmp/mode/hardware.pm +++ b/network/bluecoat/snmp/mode/hardware.pm @@ -25,10 +25,6 @@ use base qw(centreon::plugins::templates::hardware); use strict; use warnings; -my $thresholds = { - -}; - sub set_system { my ($self, %options) = @_; From d27a95f8dabe9024bb3976a579ac736f1b4d3c28 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 3 Feb 2016 11:44:33 +0100 Subject: [PATCH 4/5] + use --dyn-mode option (Fix #313) --- apps/centreon/sql/mode/countservices.pm | 139 ++++++++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 apps/centreon/sql/mode/countservices.pm diff --git a/apps/centreon/sql/mode/countservices.pm b/apps/centreon/sql/mode/countservices.pm new file mode 100644 index 000000000..58e8fb1b7 --- /dev/null +++ b/apps/centreon/sql/mode/countservices.pm @@ -0,0 +1,139 @@ +# +# Copyright 2016 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::centreon::sql::mode::countservices; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'poller', type => 1, cb_prefix_output => 'prefix_poller_output', message_multiple => 'All poller hosts/services are ok' } + ]; + + $self->{maps_counters}->{poller} = [ + { label => 'host', set => { + key_values => [ { name => 'hosts' }, { name => 'display' } ], + output_template => 'Number of hosts : %s', + perfdatas => [ + { label => 'total_hosts', value => 'hosts_absolute', template => '%s', + min => 0, label_extra_instance => 1 }, + ], + } + }, + { label => 'service', set => { + key_values => [ { name => 'services' }, { name => 'display' } ], + output_template => 'Number of services : %s', + perfdatas => [ + { label => 'total_services', value => 'services_absolute', template => '%s', + min => 0, label_extra_instance => 1 }, + ], + } + }, + ]; +} + +sub prefix_poller_output { + my ($self, %options) = @_; + + return "Poller '" . $options{instance_value}->{display} . "' "; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '1.0'; + $options{options}->add_options(arguments => + { + "filter-poller:s" => { name => 'filter_poller' }, + "centreon-storage-database:s" => { name => 'centreon_storage_database', default => 'centreon_storage' }, + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + my $query = "SELECT instances.name, COUNT(DISTINCT hosts.host_id) as num_hosts, count(DISTINCT services.host_id, services.service_id) as num_services + FROM " . $self->{option_results}->{centreon_storage_database} . ".instances, " . $self->{option_results}->{centreon_storage_database} . ".hosts, " . $self->{option_results}->{centreon_storage_database} . ".services WHERE instances.running = '1' AND instances.instance_id = hosts.instance_id AND hosts.enabled = '1' AND hosts.host_id = services.host_id AND services.enabled = '1' GROUP BY hosts.instance_id"; + $options{sql}->connect(); + $options{sql}->query(query => $query); + + # check by ssid + $self->{poller} = {}; + while ((my $row = $options{sql}->fetchrow_hashref())) { + if (defined($self->{option_results}->{filter_poller}) && $self->{option_results}->{filter_poller} ne '' && + $row->{name} !~ /$self->{option_results}->{filter_poller}/) { + $self->{output}->output_add(long_msg => "Skipping '" . $row->{name} . "': no matching filter.", debug => 1); + next; + } + + $self->{poller}->{$row->{name}} = { display => $row->{name}, hosts => $row->{num_hosts}, services => $row->{num_services} }; + } + + if (scalar(keys %{$self->{poller}}) == 0) { + $self->{output}->add_option_msg(short_msg => "No poller found."); + $self->{output}->option_exit(); + } +} + +1; + +__END__ + +=head1 MODE + +Check the number of hosts/services by poller. + +=over 8 + +=item B<--centreon-storage-database> + +Centreon storage database name (default: 'centreon_storage'). + +=item B<--filter-counters> + +Only display some counters (regexp can be used). +Example: --filter-counters='^services$' + +=item B<--warning-*> + +Threshold warning. +Can be: 'host', 'service'. + +=item B<--critical-*> + +Threshold critical. +Can be: Can be: 'host', 'service'. + +=item B<--filter-poller> + +Filter by poller name (regexp can be used). + +=back + +=cut From 317edcdf721060b9592a08b411cbe59da0309f12 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 3 Feb 2016 16:19:30 +0100 Subject: [PATCH 5/5] + fix help --- network/juniper/trapeze/snmp/mode/memory.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/network/juniper/trapeze/snmp/mode/memory.pm b/network/juniper/trapeze/snmp/mode/memory.pm index f0e82d023..2fd4b6e99 100644 --- a/network/juniper/trapeze/snmp/mode/memory.pm +++ b/network/juniper/trapeze/snmp/mode/memory.pm @@ -155,7 +155,7 @@ Check memory usage =item B<--filter-counters> Only display some counters (regexp can be used). -Example: --filter-counters='^(1m|5m)$' +Example: --filter-counters='^(memory)$' =item B<--warning-*>