diff --git a/pandora_server/conf/pandora_server.conf.new b/pandora_server/conf/pandora_server.conf.new index 4a5b364e3e..3afb1b390e 100644 --- a/pandora_server/conf/pandora_server.conf.new +++ b/pandora_server/conf/pandora_server.conf.new @@ -734,3 +734,8 @@ alertserver_warn 180 #ha_max_resync_wait_retries 3 # Maximum number of seconds waiting while verifying resync status. #ha_resync_sleep 10 + +# Enable (1) or disable (0) the Tentacle Server watchdog (enabled by default). + +tentacle_service_watchdog 1 + diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm index 34658ba499..b1ab75a8f7 100644 --- a/pandora_server/lib/PandoraFMS/Config.pm +++ b/pandora_server/lib/PandoraFMS/Config.pm @@ -569,6 +569,10 @@ sub pandora_load_config { $pa_config->{'ncmserver_threads'} = 1; # 7.0 758 $pa_config->{'ncm_ssh_utility'} = '/usr/share/pandora_server/util/ncm_ssh_extension'; # 7.0 758 + $pa_config->{"pandora_service_cmd"} = 'service pandora_server'; # 7.0 761 + $pa_config->{"tentacle_service_cmd"} = 'service tentacle_serverd'; # 7.0 761 + $pa_config->{"tentacle_service_watchdog"} = 1; # 7.0 761 + # Check for UID0 if ($pa_config->{"quiet"} != 0){ if ($> == 0){ @@ -1314,6 +1318,12 @@ sub pandora_load_config { elsif ($parametro =~ m/^pandora_service_cmd\s(.*)/i) { $pa_config->{'pandora_service_cmd'} = clean_blank($1); } + elsif ($parametro =~ m/^tentacle_service_cmd\s(.*)/i) { + $pa_config->{'tentacle_service_cmd'} = clean_blank($1); + } + elsif ($parametro =~ m/^tentacle_service_watchdog\s([0-1])/i) { + $pa_config->{'tentacle_service_watchdog'} = clean_blank($1); + } elsif ($parametro =~ m/^splitbrain_autofix\s+([0-9]*)/i) { $pa_config->{'splitbrain_autofix'} = clean_blank($1); } diff --git a/pandora_server/util/pandora_ha.pl b/pandora_server/util/pandora_ha.pl index 59f51d2937..9e44812908 100755 --- a/pandora_server/util/pandora_ha.pl +++ b/pandora_server/util/pandora_ha.pl @@ -149,6 +149,9 @@ sub ha_load_pandora_conf($) { $conf->{'dbport'} = '3306' unless defined ($conf->{'dbport'}); $conf->{'ha_interval'} = 10 unless defined ($conf->{'ha_interval'}); $conf->{'ha_monitoring_interval'} = 60 unless defined ($conf->{'ha_monitoring_interval'}); + $conf->{'pandora_service_cmd'} = 'service pandora_server' unless defined($conf->{'pandora_service_cmd'}); + $conf->{'tentacle_service_cmd'} = 'service tentacle_serverd' unless defined ($conf->{'tentacle_service_cmd'}); + $conf->{'tentacle_service_watchdog'} = 1 unless defined ($conf->{'tentacle_service_watchdog'}); } ############################################################################## @@ -167,8 +170,6 @@ sub ha_keep_pandora_running($$) { my $OSNAME = $^O; my $control_command; - $conf->{'pandora_service_cmd'} = 'service pandora_server' unless defined($conf->{'pandora_service_cmd'}); - # Check if all servers are running # Restart if crashed or keep interval is over. my $component_last_contact = get_db_value( @@ -231,6 +232,25 @@ sub ha_keep_pandora_running($$) { } } +############################################################################## +# Keep the Tentacle server running +############################################################################## +sub ha_keep_tentacle_running($$) { + my ($conf, $dbh) = @_; + + return unless ($conf->{'tentacle_service_watchdog'} == 1); + + # Try to get the PID of the service. + my $pid = `$conf->{'tentacle_service_cmd'} status | awk '{print \$NF*1}' | tr -d '\.'`; + + # Not running. + if ($pid == 0) { + log_message($conf, 'LOG', 'Tentacle service not running.'); + print ">> service not running...\n"; + `$conf->{'tentacle_service_cmd'} start 2>/dev/null`; + } +} + ############################################################################### # Update pandora services. ############################################################################### @@ -273,8 +293,6 @@ sub ha_update_server($$) { rmtree($workDir); # Restart service - $config->{'pandora_service_cmd'} = 'service pandora_server' - unless defined($config->{'pandora_service_cmd'}); my $control_command = "restart-server"; if ($OSNAME eq "freebsd") { $control_command = "restart_server"; @@ -355,6 +373,9 @@ sub ha_main($) { # Keep pandora running ha_keep_pandora_running($conf, $dbh); + + # Keep Tentacle running + ha_keep_tentacle_running($conf, $dbh); # Are we the master? pandora_set_master($conf, $dbh);