Merge branch 'ent-10228-tsessions_php-crece-indefinidamente' into 'develop'
Added cookie management to api curl and wget calls See merge request artica/pandorafms!5502
This commit is contained in:
commit
57dd29063c
|
@ -639,8 +639,8 @@ systemctl enable tentacle_serverd &>> $LOGFILE
|
||||||
execute_cmd "service tentacle_serverd start" "Starting Tentacle Server"
|
execute_cmd "service tentacle_serverd start" "Starting Tentacle Server"
|
||||||
|
|
||||||
# Enabling condole cron
|
# Enabling condole cron
|
||||||
execute_cmd "echo \"* * * * * root wget -q -O - --no-check-certificate http://127.0.0.1/pandora_console/enterprise/cron.php >> $PANDORA_CONSOLE/log/cron.log\" >> /etc/crontab" "Enabling Pandora FMS Console cron"
|
execute_cmd "echo \"* * * * * root wget -q -O - --no-check-certificate --load-cookies /tmp/cron-session-cookies --save-cookies /tmp/cron-session-cookies --keep-session-cookies http://127.0.0.1/pandora_console/enterprise/cron.php >> $PANDORA_CONSOLE/log/cron.log\" >> /etc/crontab" "Enabling Pandora FMS Console cron"
|
||||||
echo "* * * * * root wget -q -O - --no-check-certificate http://127.0.0.1/pandora_console/enterprise/cron.php >> $PANDORA_CONSOLE/log/cron.log" >> /etc/crontab
|
echo "* * * * * root wget -q -O - --no-check-certificate --load-cookies /tmp/cron-session-cookies --save-cookies /tmp/cron-session-cookies --keep-session-cookies http://127.0.0.1/pandora_console/enterprise/cron.php >> $PANDORA_CONSOLE/log/cron.log" >> /etc/crontab
|
||||||
## Enabling agent
|
## Enabling agent
|
||||||
systemctl enable pandora_agent_daemon &>> $LOGFILE
|
systemctl enable pandora_agent_daemon &>> $LOGFILE
|
||||||
execute_cmd "systemctl start pandora_agent_daemon" "Starting Pandora FMS Agent"
|
execute_cmd "systemctl start pandora_agent_daemon" "Starting Pandora FMS Agent"
|
||||||
|
|
|
@ -732,8 +732,8 @@ systemctl enable tentacle_serverd &>> "$LOGFILE"
|
||||||
execute_cmd "service tentacle_serverd start" "Starting Tentacle Server"
|
execute_cmd "service tentacle_serverd start" "Starting Tentacle Server"
|
||||||
|
|
||||||
# Enabling condole cron
|
# Enabling condole cron
|
||||||
execute_cmd "echo \"* * * * * root wget -q -O - --no-check-certificate http://127.0.0.1/pandora_console/enterprise/cron.php >> $PANDORA_CONSOLE/log/cron.log\" >> /etc/crontab" "Enabling Pandora FMS Console cron"
|
execute_cmd "echo \"* * * * * root wget -q -O - --no-check-certificate --load-cookies /tmp/cron-session-cookies --save-cookies /tmp/cron-session-cookies --keep-session-cookies http://127.0.0.1/pandora_console/enterprise/cron.php >> $PANDORA_CONSOLE/log/cron.log\" >> /etc/crontab" "Enabling Pandora FMS Console cron"
|
||||||
echo "* * * * * root wget -q -O - --no-check-certificate http://127.0.0.1/pandora_console/enterprise/cron.php >> $PANDORA_CONSOLE/log/cron.log" >> /etc/crontab
|
echo "* * * * * root wget -q -O - --no-check-certificate --load-cookies /tmp/cron-session-cookies --save-cookies /tmp/cron-session-cookies --keep-session-cookies http://127.0.0.1/pandora_console/enterprise/cron.php >> $PANDORA_CONSOLE/log/cron.log" >> /etc/crontab
|
||||||
## Enabling agent
|
## Enabling agent
|
||||||
systemctl enable pandora_agent_daemon &>> "$LOGFILE"
|
systemctl enable pandora_agent_daemon &>> "$LOGFILE"
|
||||||
execute_cmd "systemctl start pandora_agent_daemon" "Starting Pandora FMS Agent"
|
execute_cmd "systemctl start pandora_agent_daemon" "Starting Pandora FMS Agent"
|
||||||
|
|
|
@ -732,8 +732,8 @@ execute_cmd "service tentacle_serverd start" "Starting Tentacle Server"
|
||||||
systemctl enable tentacle_serverd &>> "$LOGFILE"
|
systemctl enable tentacle_serverd &>> "$LOGFILE"
|
||||||
|
|
||||||
# Enabling condole cron
|
# Enabling condole cron
|
||||||
execute_cmd "echo \"* * * * * root wget -q -O - --no-check-certificate http://127.0.0.1/pandora_console/enterprise/cron.php >> $PANDORA_CONSOLE/log/cron.log\" >> /etc/crontab" "Enabling Pandora FMS Console cron"
|
execute_cmd "echo \"* * * * * root wget -q -O - --no-check-certificate --load-cookies /tmp/cron-session-cookies --save-cookies /tmp/cron-session-cookies --keep-session-cookies http://127.0.0.1/pandora_console/enterprise/cron.php >> $PANDORA_CONSOLE/log/cron.log\" >> /etc/crontab" "Enabling Pandora FMS Console cron"
|
||||||
echo "* * * * * root wget -q -O - --no-check-certificate http://127.0.0.1/pandora_console/enterprise/cron.php >> $PANDORA_CONSOLE/log/cron.log" >> /etc/crontab
|
echo "* * * * * root wget -q -O - --no-check-certificate --load-cookies /tmp/cron-session-cookies --save-cookies /tmp/cron-session-cookies --keep-session-cookies http://127.0.0.1/pandora_console/enterprise/cron.php >> $PANDORA_CONSOLE/log/cron.log" >> /etc/crontab
|
||||||
|
|
||||||
## Enabling agent adn configuring Agente
|
## Enabling agent adn configuring Agente
|
||||||
sed -i "s/^remote_config.*$/remote_config 1/g" $PANDORA_AGENT_CONF &>> "$LOGFILE"
|
sed -i "s/^remote_config.*$/remote_config 1/g" $PANDORA_AGENT_CONF &>> "$LOGFILE"
|
||||||
|
|
|
@ -277,8 +277,8 @@ export ORACLE_HOME=/usr/lib/oracle/$VERSION/client64
|
||||||
EOF_ENV
|
EOF_ENV
|
||||||
|
|
||||||
echo ">> Enable discovery cron: "
|
echo ">> Enable discovery cron: "
|
||||||
#while true ; do wget -q -O - --no-check-certificate http://localhost/pandora_console/enterprise/cron.php >> /var/www/html/pandora_console/pandora_console.log && sleep 60 ; done &
|
#while true ; do wget -q -O - --no-check-certificate --load-cookies /tmp/cron-session-cookies --save-cookies /tmp/cron-session-cookies --keep-session-cookies http://localhost/pandora_console/enterprise/cron.php >> /var/www/html/pandora_console/pandora_console.log && sleep 60 ; done &
|
||||||
echo "*/5 * * * * wget -q -O - --no-check-certificate http://localhost/pandora_console/enterprise/cron.php >> /var/www/html/pandora_console/log/cron.log" >> /opt/pandora/crontasks
|
echo "*/5 * * * * wget -q -O - --no-check-certificate --load-cookies /tmp/cron-session-cookies --save-cookies /tmp/cron-session-cookies --keep-session-cookies http://localhost/pandora_console/enterprise/cron.php >> /var/www/html/pandora_console/log/cron.log" >> /opt/pandora/crontasks
|
||||||
|
|
||||||
echo ">> Enable pandora_db cron: "
|
echo ">> Enable pandora_db cron: "
|
||||||
/usr/bin/perl /usr/share/pandora_server/util/pandora_db.pl /etc/pandora/pandora_server.conf
|
/usr/bin/perl /usr/share/pandora_server/util/pandora_db.pl /etc/pandora/pandora_server.conf
|
||||||
|
|
|
@ -2379,7 +2379,7 @@ class ConsoleSupervisor
|
||||||
if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
|
if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
|
||||||
$message_conf_cron .= __('Discovery relies on an appropriate cron setup.');
|
$message_conf_cron .= __('Discovery relies on an appropriate cron setup.');
|
||||||
$message_conf_cron .= '. '.__('Please, add the following line to your crontab file:');
|
$message_conf_cron .= '. '.__('Please, add the following line to your crontab file:');
|
||||||
$message_conf_cron .= '<b><pre class=""ui-dialog>* * * * * <user> wget -q -O - --no-check-certificate ';
|
$message_conf_cron .= '<b><pre class=""ui-dialog>* * * * * <user> wget -q -O - --no-check-certificate --load-cookies /tmp/cron-session-cookies --save-cookies /tmp/cron-session-cookies --keep-session-cookies ';
|
||||||
$message_conf_cron .= str_replace(
|
$message_conf_cron .= str_replace(
|
||||||
ENTERPRISE_DIR.'/meta/',
|
ENTERPRISE_DIR.'/meta/',
|
||||||
'',
|
'',
|
||||||
|
|
|
@ -801,7 +801,7 @@ sub main() {
|
||||||
# Testing API url
|
# Testing API url
|
||||||
my $curl_execution = "'".$Config{'console_api_url'}."?op=get&op2=test&apipass=".$Config{"console_api_pass"}."&user=".$Config{"console_user"}."&pass=".$Config{"console_pass"}."'";
|
my $curl_execution = "'".$Config{'console_api_url'}."?op=get&op2=test&apipass=".$Config{"console_api_pass"}."&user=".$Config{"console_user"}."&pass=".$Config{"console_pass"}."'";
|
||||||
# More than 30 secs is highly unrecommendated
|
# More than 30 secs is highly unrecommendated
|
||||||
my $command = $Config{'plugin_exec'}.' 30 curl '.$curl_execution.' 2>/dev/null';
|
my $command = $Config{'plugin_exec'}.' 30 curl --cookie-jar /tmp/cron-session-cookies '.$curl_execution.' 2>/dev/null';
|
||||||
my $exe_testing_api = `$command`;
|
my $exe_testing_api = `$command`;
|
||||||
my @res_testing_api = split(',', $exe_testing_api);
|
my @res_testing_api = split(',', $exe_testing_api);
|
||||||
if ( $res_testing_api[0] ne 'OK' ) {
|
if ( $res_testing_api[0] ne 'OK' ) {
|
||||||
|
|
|
@ -1067,12 +1067,18 @@ sub pandora_delete_old_session_data {
|
||||||
|
|
||||||
$ulimit_timestamp = time() - $session_timeout;
|
$ulimit_timestamp = time() - $session_timeout;
|
||||||
|
|
||||||
log_message ('PURGE', "Deleting old session data from tsessions_php\n");
|
log_message ('PURGE', "Deleting old session data from tsessions_php");
|
||||||
while(db_delete_limit ($dbh, 'tsessions_php', 'last_active < ?', $SMALL_OPERATION_STEP, $ulimit_timestamp) ne '0E0') {
|
while(db_delete_limit ($dbh, 'tsessions_php', 'last_active < ?', $SMALL_OPERATION_STEP, $ulimit_timestamp) ne '0E0') {
|
||||||
usleep (10000);
|
usleep (10000);
|
||||||
};
|
};
|
||||||
|
|
||||||
db_do ($dbh, "DELETE FROM tsessions_php WHERE data IS NULL OR id_session REGEXP '^cron-'");
|
db_do ($dbh, "DELETE FROM tsessions_php WHERE data IS NULL OR id_session REGEXP '^cron-'");
|
||||||
|
|
||||||
|
# Delete cron cookies file
|
||||||
|
my $cookie_file = '/tmp/cron-session-cookies';
|
||||||
|
log_message ('PURGE', "Deleting cron session file");
|
||||||
|
unlink($cookie_file) or die log_message ('PURGE', "Could not delete session file");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
Loading…
Reference in New Issue