Merge pull request #688 from Sims24/master
+ New component in hnas hw mode & Multiservice doc/samples
This commit is contained in:
commit
827f648308
|
@ -0,0 +1,79 @@
|
|||
#
|
||||
# Copyright 2017 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 centreon::common::bluearc::snmp::mode::components::battery;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my %map_status = (
|
||||
1 => 'ok',
|
||||
2 => 'fault',
|
||||
3 => 'notFitted',
|
||||
4 => 'initializing',
|
||||
5 => 'normalCharging',
|
||||
6 => 'discharged',
|
||||
7 => 'cellTesting',
|
||||
8 => 'notResponding',
|
||||
9 => 'low',
|
||||
10 => 'veryLow',
|
||||
11 => 'ignore'
|
||||
);
|
||||
|
||||
my $mapping = {
|
||||
batteryStatus => { oid => '.1.3.6.1.4.1.11096.6.1.1.1.2.1.17.1.3', map => \%map_status },
|
||||
};
|
||||
my $oid_batteryEntry = '.1.3.6.1.4.1.11096.6.1.1.1.2.1.17.1';
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
|
||||
push @{$self->{request}}, { oid => $oid_batteryEntry };
|
||||
}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking batteries");
|
||||
$self->{components}->{battery} = {name => 'battery', total => 0, skip => 0};
|
||||
return if ($self->check_filter(section => 'battery'));
|
||||
|
||||
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_batteryEntry}})) {
|
||||
next if ($oid !~ /^$mapping->{batteryStatus}->{oid}\.(.*)$/);
|
||||
my $instance = $1;
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_batteryEntry}, instance => $instance);
|
||||
|
||||
next if ($self->check_filter(section => 'battery', instance => $instance));
|
||||
$self->{components}->{battery}->{total}++;
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("Battery '%s' status is '%s' [instance: %s].",
|
||||
$instance, $result->{batteryStatus},
|
||||
$instance
|
||||
));
|
||||
my $exit = $self->get_severity(section => 'battery', value => $result->{batteryStatus});
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Battery '%s' status is '%s'",
|
||||
$instance, $result->{batteryStatus}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright 2017 Centreon (http://www.centreon.com/)
|
||||
# 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
|
||||
|
@ -27,14 +27,14 @@ use warnings;
|
|||
|
||||
sub set_system {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{regexp_threshold_overload_check_section_option} = '^(temperature|fan|psu|sysdrive)$';
|
||||
|
||||
$self->{regexp_threshold_overload_check_section_option} = '^(temperature|fan|psu|sysdrive|battery)$';
|
||||
$self->{regexp_threshold_numeric_check_section_option} = '^(temperature|fan)$';
|
||||
|
||||
|
||||
$self->{cb_hook2} = 'snmp_execute';
|
||||
|
||||
|
||||
$self->{thresholds} = {
|
||||
psu => [
|
||||
psu => [
|
||||
['ok', 'OK'],
|
||||
['failed', 'CRITICAL'],
|
||||
['notFitted', 'WARNING'],
|
||||
|
@ -45,7 +45,7 @@ sub set_system {
|
|||
['warning', 'WARNING'],
|
||||
['severe', 'CRITICAL'],
|
||||
['unknown', 'UNKNOWN'],
|
||||
],
|
||||
],
|
||||
temperature => [
|
||||
['ok', 'OK'],
|
||||
['tempWarning', 'WARNING'],
|
||||
|
@ -65,15 +65,28 @@ sub set_system {
|
|||
['formatting', 'OK'],
|
||||
['unknown', 'UNKNOWN'],
|
||||
],
|
||||
battery => [
|
||||
['ok', 'OK'],
|
||||
['fault', 'CRITICAL'],
|
||||
['notFitted', 'WARNING'],
|
||||
['initializing', 'OK'],
|
||||
['normalCharging', 'OK'],
|
||||
['discharged', 'CRITICAL'],
|
||||
['cellTesting', 'OK'],
|
||||
['notResponding', 'CRITICAL'],
|
||||
['low', 'WARNING'],
|
||||
['veryLow', 'CRITICAL'],
|
||||
['ignore', 'UNKNOWN'],
|
||||
],
|
||||
};
|
||||
|
||||
|
||||
$self->{components_path} = 'centreon::common::bluearc::snmp::mode::components';
|
||||
$self->{components_module} = ['temperature', 'fan', 'psu', 'sysdrive'];
|
||||
$self->{components_module} = ['temperature', 'fan', 'psu', 'sysdrive', 'battery' ];
|
||||
}
|
||||
|
||||
sub snmp_execute {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
||||
$self->{snmp} = $options{snmp};
|
||||
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request});
|
||||
}
|
||||
|
@ -82,12 +95,12 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1);
|
||||
bless $self, $class;
|
||||
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
{
|
||||
});
|
||||
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
|
@ -104,7 +117,7 @@ Check Hardware.
|
|||
=item B<--component>
|
||||
|
||||
Which component to check (Default: '.*').
|
||||
Can be: 'temperature', 'fan', 'psu', 'sysdrive'.
|
||||
Can be: 'temperature', 'fan', 'psu', 'sysdrive', 'battery'.
|
||||
|
||||
=item B<--filter>
|
||||
|
||||
|
@ -134,4 +147,4 @@ Example: --critical='temperature,.*,40'
|
|||
|
||||
=back
|
||||
|
||||
=cut
|
||||
=cut
|
||||
|
|
|
@ -1057,3 +1057,95 @@ The command result:
|
|||
$ perl centreon_plugins.pl --plugin=apps/protocols/modbus/plugin.pm --mode=numeric-value --tcp-host=10.0.0.1 --config=modbus.json --verbose
|
||||
OK: Metric 'avg' value is '3072.3' | 'avg'=3072.3con;;;;
|
||||
Metric 'avg' value is '3072.3'
|
||||
|
||||
--------------------
|
||||
Multi-service plugin
|
||||
--------------------
|
||||
|
||||
This mode allow you to concatenate several result of host and/or service check into one check. Can be used to make some aggregation into logical group or gather information from one Centreon to display in another without checking resources twice.
|
||||
|
||||
Design of configuration file
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
::
|
||||
|
||||
{
|
||||
"mode":"sqlmatching",
|
||||
"selection":{
|
||||
"ESX":{
|
||||
"host_name_filter":"%clus-esx-n%",
|
||||
"service_name_filter":"Esx-Status"
|
||||
},
|
||||
"XIVO":{
|
||||
"host_name_filter":"%xivo%",
|
||||
"service_name_filter":"Ping"
|
||||
}
|
||||
},
|
||||
"counters":{
|
||||
"totalservices":true,
|
||||
"totalhosts":true,
|
||||
"groups":true
|
||||
},
|
||||
"formatting":{
|
||||
"groups_global_msg":"Nothing special on groups",
|
||||
"host_service_separator":"/",
|
||||
"display_details":true
|
||||
}
|
||||
}
|
||||
|
||||
* mode (mandatory) : can be 'sqlmatching' or 'exactmatch'. Linked to the layout of "selection" bloc
|
||||
* selection (mandatory) : if we use sqlmatching, we define filters like above, if we use exact match, need to pass a key/value pair corresponding to host/service (example below with two "groups" esx-status/load)
|
||||
|
||||
::
|
||||
|
||||
"selection":{
|
||||
"esx-status":{
|
||||
"esx-n1":"Esx-Status",
|
||||
"esx-n2":"Esx-Status",
|
||||
"esx-n3":"Esx-Status"
|
||||
},
|
||||
"esx-load":{
|
||||
"esx-n1":"Esx-Memory",
|
||||
"esx-n2":"Esx-Memory",
|
||||
"esx-n3":"Esx-Memory",
|
||||
"esx-n1":"Esx-Cpu",
|
||||
"esx-n2":"Esx-Cpu",
|
||||
"esx-n3":"Esx-Cpu"
|
||||
}
|
||||
},
|
||||
|
||||
* counters (optionnal) : Contains three keys to choose which counters we should use and consider (totalservices, totalhosts, groups)
|
||||
* formatting (optionnal) : Contains three keys, 'groups_global_msg' to define a global OK status message, 'host_service_separator' to define separator used between host and service name in output, 'display_details' to config if plugin should display details of host/service name in the verbose output.
|
||||
|
||||
Command line, output, threshold ...
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Sample command :
|
||||
|
||||
::
|
||||
|
||||
/usr/lib/nagios/plugins/centreon_plugins.pl --plugin database::mysql::plugin --dyn-mode apps::centreon::sql::mode::multiservices --host localhost --username centreon --password c3ntreon --config-file '/root/global-services.json' --verbose
|
||||
|
||||
Sample output :
|
||||
|
||||
::
|
||||
|
||||
OK: Hosts state summary [up:4][down:2][unreachable:0] - Services state summary [ok:4][warning:0][critical:2][unknown:0] - Nothing special on groups |
|
||||
|
||||
Perfdatas :
|
||||
|
||||
::
|
||||
|
||||
'total_host_up'=4;;;0; 'total_host_down'=2;;;0; 'total_host_unreachable'=0;;;0; 'total_host_ok'=4;;;0; 'total_host_warning'=0;;;0; 'total_host_critical'=2;;;0; 'total_host_unknown'=0;;;0; 'host_up_ESX'=4;;;0; 'host_down_ESX'=0;;;0; 'host_unreachable_ESX'=0;;;0; 'service_ok_ESX'=4;;;0; 'service_warning_ESX'=0;;;0; 'service_critical_ESX'=0;;;0; 'service_unknown_ESX'=0;;;0; 'host_up_XIVO'=0;;;0; 'host_down_XIVO'=2;;;0; 'host_unreachable_XIVO'=0;;;0; 'service_ok_XIVO'=0;;;0; 'service_warning_XIVO'=0;;;0; 'service_critical_XIVO'=2;;;0; 'service_unknown_XIVO'=0;;;0;
|
||||
|
||||
Verbose mode (with display details set as true) :
|
||||
|
||||
::
|
||||
|
||||
Group 'ESX': HOSTS: [up: 4 (clus-esx-n1.com - clus-esx-n2.com - clus-esx-n3.com - clus-esx-n4.com)][down: 0][unreachable: 0] - SERVICES: [ok: 4 (clus-esx-n1.com/Esx-Status - clus-esx-n2.com/Esx-Status - clus-esx-n3.com/Esx-Status - clus-esx-n4.com/Esx-Status)][warning: 0][critical: 0][unknown: 0]
|
||||
Group 'XIVO': HOSTS: [up: 0][down: 2 (srvi-xivo-n1 - srvi-xivo-n2)][unreachable: 0] - SERVICES: [ok: 0][warning: 0][critical: 2 (srvi-xivo-n1/Ping - srvi-xivo-n2/Ping)][unknown: 0]
|
||||
|
||||
Concerning the threshold, you can use some example below :
|
||||
|
||||
::
|
||||
|
||||
--critical-total '%{total_down} > 4' --critical-groups '%{instance} eq 'ESX' && %{unknown} > 5'
|
||||
|
|
|
@ -1057,4 +1057,96 @@ Le résultat de la commande :
|
|||
|
||||
$ perl centreon_plugins.pl --plugin=apps/protocols/modbus/plugin.pm --mode=numeric-value --tcp-host=10.0.0.1 --config=modbus.json --verbose
|
||||
OK: Metric 'avg' value is '3072.3' | 'avg'=3072.3con;;;;
|
||||
Metric 'avg' value is '3072.3'
|
||||
Metric 'avg' value is '3072.3'
|
||||
|
||||
--------------------
|
||||
Multi-service plugin
|
||||
--------------------
|
||||
|
||||
Ce mode permet de compiler/aggréger le résultat de plusieurs checks dans un seul. Il peut aussi être utilisé pour réaliser des aggregation dans des groupes logiques, il a été pensé pour récupérer au travers de réseaux bas débit des résultats de contrôle sur des Centreon distants, mais il peut aussi permettre d'éviter de checker deux fois les ressources dans deux Centreon différents.
|
||||
|
||||
Format du fichier de configuration
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
::
|
||||
|
||||
{
|
||||
"mode":"sqlmatching",
|
||||
"selection":{
|
||||
"ESX":{
|
||||
"host_name_filter":"%clus-esx-n%",
|
||||
"service_name_filter":"Esx-Status"
|
||||
},
|
||||
"XIVO":{
|
||||
"host_name_filter":"%xivo%",
|
||||
"service_name_filter":"Ping"
|
||||
}
|
||||
},
|
||||
"counters":{
|
||||
"totalservices":true,
|
||||
"totalhosts":true,
|
||||
"groups":true
|
||||
},
|
||||
"formatting":{
|
||||
"groups_global_msg":"Nothing special on groups",
|
||||
"host_service_separator":"/",
|
||||
"display_details":true
|
||||
}
|
||||
}
|
||||
|
||||
* mode (obligatoire) : valeurs possibles: 'sqlmatching' or 'exactmatch'. Liés au format du bloc "selection" ;
|
||||
* selection (obligatoire) : Lorsque le mode 'sqlmatching' est choisis, on va alors définir les filtres comme ci-dessus (host/service_name_filter). Au contraire, si l'on utilise le mode "exactmatch", alors on passe des clés valeurs correspondant à la correspondant host/service. (Exemple avec deux aggregation logqies "groups" esx-status/load ci-dessous)
|
||||
|
||||
::
|
||||
|
||||
"selection":{
|
||||
"esx-status":{
|
||||
"esx-n1":"Esx-Status",
|
||||
"esx-n2":"Esx-Status",
|
||||
"esx-n3":"Esx-Status"
|
||||
},
|
||||
"esx-load":{
|
||||
"esx-n1":"Esx-Memory",
|
||||
"esx-n2":"Esx-Memory",
|
||||
"esx-n3":"Esx-Memory",
|
||||
"esx-n1":"Esx-Cpu",
|
||||
"esx-n2":"Esx-Cpu",
|
||||
"esx-n3":"Esx-Cpu"
|
||||
}
|
||||
},
|
||||
|
||||
* counters (optionnel) : Contiens trois booléens, à configurer en 'true' ou 'false' selon les compteurs que l'on veut utiliser et considérer (totalservices, totalhosts, groups).
|
||||
* formatting (optionnel) : Contiens trois clés/valeurs, 'groups_global_msg' pour définir un statut global lorsque tout va bien, 'host_service_separator' pour choisir le séparateur entre le nom de l'hôte et celui du service dans les éléments de l'output, 'display_details' afin de définir si le plugin doit détailler les hôtes et/ou services en erreur dans l'output étendu (mode verbose)
|
||||
|
||||
Ligne de commande, output, seuils
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Exemple de commande :
|
||||
|
||||
::
|
||||
|
||||
/usr/lib/nagios/plugins/centreon_plugins.pl --plugin database::mysql::plugin --dyn-mode apps::centreon::sql::mode::multiservices --host localhost --username centreon --password c3ntreon --config-file '/root/global-services.json' --verbose
|
||||
|
||||
Example de sortie :
|
||||
|
||||
::
|
||||
|
||||
OK: Hosts state summary [up:4][down:2][unreachable:0] - Services state summary [ok:4][warning:0][critical:2][unknown:0] - Nothing special on groups |
|
||||
|
||||
Données de performance :
|
||||
|
||||
::
|
||||
|
||||
'total_host_up'=4;;;0; 'total_host_down'=2;;;0; 'total_host_unreachable'=0;;;0; 'total_host_ok'=4;;;0; 'total_host_warning'=0;;;0; 'total_host_critical'=2;;;0; 'total_host_unknown'=0;;;0; 'host_up_ESX'=4;;;0; 'host_down_ESX'=0;;;0; 'host_unreachable_ESX'=0;;;0; 'service_ok_ESX'=4;;;0; 'service_warning_ESX'=0;;;0; 'service_critical_ESX'=0;;;0; 'service_unknown_ESX'=0;;;0; 'host_up_XIVO'=0;;;0; 'host_down_XIVO'=2;;;0; 'host_unreachable_XIVO'=0;;;0; 'service_ok_XIVO'=0;;;0; 'service_warning_XIVO'=0;;;0; 'service_critical_XIVO'=2;;;0; 'service_unknown_XIVO'=0;;;0;
|
||||
|
||||
Mode verbeux (avec l'affichage détaillé d'activé) :
|
||||
|
||||
::
|
||||
|
||||
Group 'ESX': HOSTS: [up: 4 (clus-esx-n1.com - clus-esx-n2.com - clus-esx-n3.com - clus-esx-n4.com)][down: 0][unreachable: 0] - SERVICES: [ok: 4 (clus-esx-n1.com/Esx-Status - clus-esx-n2.com/Esx-Status - clus-esx-n3.com/Esx-Status - clus-esx-n4.com/Esx-Status)][warning: 0][critical: 0][unknown: 0]
|
||||
Group 'XIVO': HOSTS: [up: 0][down: 2 (srvi-xivo-n1 - srvi-xivo-n2)][unreachable: 0] - SERVICES: [ok: 0][warning: 0][critical: 2 (srvi-xivo-n1/Ping - srvi-xivo-n2/Ping)][unknown: 0]
|
||||
|
||||
Voici la manière de définir les seuils (total_statut pour les warning/critical-total et définition de l'instance et du décompte du nombre de statut pour les seuils par "groupes logiques") :
|
||||
|
||||
::
|
||||
|
||||
--critical-total '%{total_down} > 4' --critical-groups '%{instance} eq 'ESX' && %{unknown} > 5'
|
||||
|
|
Loading…
Reference in New Issue