Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Commit

Permalink
feat(engine/broker): allow to set action command for engine/broker (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
kduret authored Sep 23, 2019
1 parent 55a7cfa commit e3268d5
Show file tree
Hide file tree
Showing 41 changed files with 498 additions and 626 deletions.
28 changes: 18 additions & 10 deletions doc/en/api/clapi/objects/instances.rst
Original file line number Diff line number Diff line change
Expand Up @@ -97,25 +97,33 @@ Order Column description
Parameters that you may change are:

========================== =====================================================
Column Description
Column Description
========================== =====================================================
name
name Name of the poller

localhost *1* if it is the main poller, *0* otherwise
localhost *1* if it is the main poller, *0* otherwise

ns_ip_address IP address of the poller
ns_ip_address IP address of the poller

ns_activate *1* if poller is enabled, *0* otherwise
ns_activate *1* if poller is enabled, *0* otherwise

init_script Init script path
engine_start_command Command to start Centreon Engine process

nagios_bin Path of the Scheduler binary
engine_stop_command Command to stop Centreon Engine process

nagiostats_bin Path of the Nagios Stats binary
engine_restart_command Command to restart Centreon Engine process

ssh_port SSH Port
engine_reload_command Command to reload Centreon Engine process

centreonbroker_cfg_path Centreon Broker Configuration path
nagios_bin Path of the Scheduler binary

nagiostats_bin Path of the Nagios Stats binary

ssh_port SSH Port

broker_reload_command Command to reload Centreon Broker process

centreonbroker_cfg_path Centreon Broker Configuration path

centreonbroker_module_path Centreon Broker Module path
========================== =====================================================
Expand Down
7 changes: 0 additions & 7 deletions doc/en/api/clapi/objects/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ In order to list editable settings, use the **SHOW** action::

[root@centreon ~]# ./centreon -u admin -p centreon -o SETTINGS -a show
parameter;value
broker;ndo
broker_correlator_script;
centstorage;1
debug_auth;0
debug_ldap_import;0
Expand Down Expand Up @@ -58,11 +56,6 @@ Parameters that you may change are:
=========================== ===================================================== ================================================
Column Description Possible values and examples
=========================== ===================================================== ================================================
broker Broker engine 'broker' for Centreon Broker

broker_correlator_script This parameter is misleading (subject to changes) i.e: cbd
Refers to the Centreon Broker init script

centstorage Enable/disable CentStorage Enable: '1', Disable: '0'

debug_auth Enable/disable authentication debug Enable: '1', Disable: '0'
Expand Down
28 changes: 16 additions & 12 deletions doc/fr/api/clapi/objects/instances.rst
Original file line number Diff line number Diff line change
Expand Up @@ -102,29 +102,33 @@ Order Column description
Parameters that you may change are:

========================== =====================================================
Column Description
Column Description
========================== =====================================================
name
name Name of the poller

localhost *1* if it is the main poller, *0* otherwise
localhost *1* if it is the main poller, *0* otherwise

ns_ip_address IP address of the poller
ns_ip_address IP address of the poller

ns_activate *1* if poller is enabled, *0* otherwise
ns_activate *1* if poller is enabled, *0* otherwise

init_script Init script path
engine_start_command Command to start Centreon Engine process

monitoring_engine Engine used on poller: *NAGIOS*, *ICINGA*, *SHINKEN*
engine_stop_command Command to stop Centreon Engine process

nagios_bin Path of the Scheduler binary
engine_restart_command Command to restart Centreon Engine process

nagiostats_bin Path of the Nagios Stats binary
engine_reload_command Command to reload Centreon Engine process

nagios_perfdata Path of perfdata file
nagios_bin Path of the Scheduler binary

ssh_port SSH Port
nagiostats_bin Path of the Nagios Stats binary

centreonbroker_cfg_path Centreon Broker Configuration path
ssh_port SSH Port

broker_reload_command Command to reload Centreon Broker process

centreonbroker_cfg_path Centreon Broker Configuration path

centreonbroker_module_path Centreon Broker Module path
========================== =====================================================
Expand Down
7 changes: 0 additions & 7 deletions doc/fr/api/clapi/objects/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ In order to list editable settings, use the **SHOW** action::

[root@centreon ~]# ./centreon -u admin -p centreon -o SETTINGS -a show
parameter;value
broker;ndo
broker_correlator_script;
centstorage;1
debug_auth;0
debug_ldap_import;0
Expand Down Expand Up @@ -58,11 +56,6 @@ Parameters that you may change are:
=========================== ===================================================== ================================================
Column Description Possible values and examples
=========================== ===================================================== ================================================
broker Broker engine 'broker' for Centreon Broker, 'ndo' for NDOUtils

broker_correlator_script This parameter is misleading (subject to changes) i.e: cbd
Refers to the Centreon Broker init script

centstorage Enable/disable CentStorage Enable: '1', Disable: '0'

debug_auth Enable/disable authentication debug Enable: '1', Disable: '0'
Expand Down
1 change: 0 additions & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,6 @@ if [ "$PROCESS_CENTREON_WWW" -eq 1 ] ; then
[ -n "$NAGIOS_GROUP" ] && MONITORINGENGINE_GROUP=$NAGIOS_GROUP
[ -n "$NAGIOS_ETC" ] && MONITORINGENGINE_ETC=$NAGIOS_ETC
[ -n "$NAGIOS_BINARY" ] && MONITORINGENGINE_BINARY=$NAGIOS_BINARY
[ -n "$NAGIOS_INIT_SCRIPT" ] && MONITORINGENGINE_INIT_SCRIPT=$NAGIOS_INIT_SCRIPT
fi
fi
. $INSTALL_DIR/CentWeb.sh
Expand Down
50 changes: 39 additions & 11 deletions lib/perl/centreon/script/centcore.pm
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ sub new {
$self->{rsyncWT} = $self->{rsync};
$self->{sudo} = "sudo";
$self->{service} = "service";
$self->{engineInitScript} = 'centengine';
$self->{timeout} = 5;
$self->{cmd_timeout} = 5;
$self->{illegal_characters} = "";
Expand All @@ -69,7 +70,6 @@ sub new {
$self->{rsync} .= " --timeout=$self->{timeout} ";
$self->{scp} .= " -o ConnectTimeout=$self->{timeout} -o StrictHostKeyChecking=yes -o PreferredAuthentications=publickey -o ServerAliveInterval=10 -o ServerAliveCountMax=3 -o Compression=yes ";


$self->{timeBetween2SyncPerf} = 60;
$self->{perfdataSync} = 0;
$self->{logSync} = 0;
Expand Down Expand Up @@ -801,17 +801,17 @@ sub sendExportFile($){
}

##################################################
# Function for initialize Nagios :
# Function for initialize Centreon Engine :
# Parameters :
# - start
# - restart
# - stop
#
sub initEngine($$$){
sub initEngine($$$) {
my $self = shift;
my $id = $_[0];
my $options = $_[1];
my $action = $_[2];
my $id = $_[0]; # poller id
my $options = $_[1]; # restart, reload, stop...
my $action = $_[2]; # full command
my ($lerror, $cmd, $stdout);

# Get configuration
Expand All @@ -838,10 +838,13 @@ sub initEngine($$$){
'using remote server "' . $remote_server->{name} . '" (' . $remote_server->{id} . ')'
);
} else {
$cmd = "$self->{ssh} -p $port " . $conf->{ns_ip_address} . " $self->{sudo} $self->{service} "
. $conf->{init_script} . " " . $options;
$cmd = '';
if ($conf->{localhost} == 0) {
$cmd = "$self->{ssh} -p $port $conf->{ns_ip_address} ";
}
$cmd .= $self->getEngineCommand($conf, $options);
$self->{logger}->writeLogInfo(
'Init Script : "' . $self->{sudo} . ' ' . $self->{service} . ' ' . $conf->{init_script} . ' ' . $options . '" ' .
'Init Script : "' . $cmd . '" ' .
'on poller "' . $conf->{name} . '" (' . $id . ')'
);
}
Expand All @@ -861,6 +864,33 @@ sub initEngine($$$){
}
}

##################################################
# Function to generate Centreon Engine command :
# Arguments:
# $pollerConf: array Poller configuration get in database (nagios_server table)
# $action: string Name of the action (restart, reload, stop...)
#
sub getEngineCommand($$) {
my $self = shift;
my $pollerConf = $_[0];
my $action = $_[1];
my $command;

if ($action eq 'start') {
$command = "$self->{sudo} $pollerConf->{engine_start_command}";
} elsif ($action eq 'stop') {
$command = "$self->{sudo} $pollerConf->{engine_stop_command}";
} elsif ($action eq 'restart') {
$command = "$self->{sudo} $pollerConf->{engine_restart_command}";
} elsif ($action eq 'reload') {
$command = "$self->{sudo} $pollerConf->{engine_reload_command}";
} else {
$command = "$self->{sudo} $self->{service} $self->{engineInitScript} $action";
}

return $command;
}

##################################################
# Function for synchronize SNMP trap configuration
#
Expand Down Expand Up @@ -1076,8 +1106,6 @@ sub parseRequest($){
$self->initEngine($1, "restart", $action);
} elsif ($action =~ /^RELOAD\:([0-9]*)/){
$self->initEngine($1, "reload", $action);
} elsif ($action =~ /^FORCERELOAD\:([0-9]*)/){
$self->initEngine($1, "force-reload", $action);
} elsif ($action =~ /^START\:([0-9]*)/){
$self->initEngine($1, "start", $action);
} elsif ($action =~ /^STOP\:([0-9]*)/){
Expand Down
4 changes: 2 additions & 2 deletions libinstall/CentWeb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ check_php_version
check_composer_dependencies
[ "$?" -eq 1 ] && purge_centreon_tmp_dir && exit 1

## Check frontend application (if www/template directory exists)
## Check frontend application (if www/static directory exists)
check_frontend_application
[ "$?" -eq 1 ] && purge_centreon_tmp_dir && exit 1

Expand Down Expand Up @@ -163,7 +163,7 @@ cd "${OLDPATH}"
OLDPATH=$(pwd)
cd $TMP_DIR/src/
log "INFO" "$(gettext "Copying frontend application...")"
cp -Rf www/index.html www/template www/.htaccess $TMP_DIR/final/www/
cp -Rf www/index.html www/static www/.htaccess $TMP_DIR/final/www/
cd "${OLDPATH}"

## Create temporary directory
Expand Down
Loading

0 comments on commit e3268d5

Please sign in to comment.