mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-30 01:05:39 +02:00
2011-04-12 Dario Rodriguez <dario.rodriguez@artica.es>
* pandora_agent_daemon: Deleted code that kill tentacle server and replaced kill -9 to kill of agent stop command. * Linux/pandora_agent.conf, AIX/pandora_agent.conf, HP-UX/pandora_agent.conf,SunOS/pandora_agent.conf : Added parameters proxy_max_connection and proxy_timeout 1. * pandora_agent: Fixed problems launching tentacle_server and also added code to handle kill signal. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4191 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
7b9c8fa705
commit
c46c0d86dd
@ -85,9 +85,15 @@ transfer_mode tentacle
|
|||||||
# If set to 1 start babel agent in proxy mode
|
# If set to 1 start babel agent in proxy mode
|
||||||
# proxy_mode 1
|
# proxy_mode 1
|
||||||
|
|
||||||
# User which runs tentacle server in proxy mode. Required with if proxy mode is enable (by default babel)
|
# User which runs tentacle server in proxy mode. Required with if proxy mode is enable (by default pandora)
|
||||||
# proxy_user pandora
|
# proxy_user pandora
|
||||||
|
|
||||||
|
# Max number of simmultaneus connection for proxy (by default 10)
|
||||||
|
# proxy_max_connection 10
|
||||||
|
|
||||||
|
# Proxy timeout (by default 1s)
|
||||||
|
# proxy_timeout 1
|
||||||
|
|
||||||
# User the agent will run as
|
# User the agent will run as
|
||||||
#pandora_user root
|
#pandora_user root
|
||||||
|
|
||||||
|
@ -1,3 +1,18 @@
|
|||||||
|
2011-04-12 Dario Rodriguez <dario.rodriguez@artica.es>
|
||||||
|
|
||||||
|
* pandora_agent_daemon: Deleted code that kill tentacle server and
|
||||||
|
replaced kill -9 to kill of agent stop command.
|
||||||
|
* Linux/pandora_agent.conf, AIX/pandora_agent.conf,
|
||||||
|
HP-UX/pandora_agent.conf,SunOS/pandora_agent.conf : Added parameters
|
||||||
|
proxy_max_connection and proxy_timeout 1.
|
||||||
|
* pandora_agent: Fixed problems launching tentacle_server and also
|
||||||
|
added code to handle kill signal.
|
||||||
|
|
||||||
|
2011-04-11 Dario Rodriguez <dario.rodriguez@artica.es>
|
||||||
|
|
||||||
|
* pandora_agent: Fixed an error with command that launch tentacle server
|
||||||
|
when proxy mode is enable.
|
||||||
|
|
||||||
2011-04-11 Dario Rodriguez <dario.rodriguez@artica.es>
|
2011-04-11 Dario Rodriguez <dario.rodriguez@artica.es>
|
||||||
|
|
||||||
* pandora_agent_installer: Added code to install tentacle_server with
|
* pandora_agent_installer: Added code to install tentacle_server with
|
||||||
|
@ -85,9 +85,15 @@ transfer_mode tentacle
|
|||||||
# If set to 1 start babel agent in proxy mode
|
# If set to 1 start babel agent in proxy mode
|
||||||
# proxy_mode 1
|
# proxy_mode 1
|
||||||
|
|
||||||
# User which runs tentacle server in proxy mode. Required with if proxy mode is enable (by default babel)
|
# User which runs tentacle server in proxy mode. Required with if proxy mode is enable (by default pandora)
|
||||||
# proxy_user pandora
|
# proxy_user pandora
|
||||||
|
|
||||||
|
# Max number of simmultaneus connection for proxy (by default 10)
|
||||||
|
# proxy_max_connection 10
|
||||||
|
|
||||||
|
# Proxy timeout (by default 1s)
|
||||||
|
# proxy_timeout 1
|
||||||
|
|
||||||
# User the agent will run as
|
# User the agent will run as
|
||||||
#pandora_user root
|
#pandora_user root
|
||||||
|
|
||||||
|
@ -100,9 +100,15 @@ transfer_mode tentacle
|
|||||||
# If set to 1 start babel agent in proxy mode
|
# If set to 1 start babel agent in proxy mode
|
||||||
# proxy_mode 1
|
# proxy_mode 1
|
||||||
|
|
||||||
# User which runs tentacle server in proxy mode. Required with if proxy mode is enable (by default babel)
|
# User which runs tentacle server in proxy mode. Required with if proxy mode is enable (by default pandora)
|
||||||
# proxy_user pandora
|
# proxy_user pandora
|
||||||
|
|
||||||
|
# Max number of simmultaneus connection for proxy (by default 10)
|
||||||
|
# proxy_max_connection 10
|
||||||
|
|
||||||
|
# Proxy timeout (by default 1s)
|
||||||
|
# proxy_timeout 1
|
||||||
|
|
||||||
# Number of threads to execute modules in parallel
|
# Number of threads to execute modules in parallel
|
||||||
#agent_threads 1
|
#agent_threads 1
|
||||||
|
|
||||||
|
@ -85,9 +85,15 @@ transfer_mode tentacle
|
|||||||
# If set to 1 start babel agent in proxy mode
|
# If set to 1 start babel agent in proxy mode
|
||||||
# proxy_mode 1
|
# proxy_mode 1
|
||||||
|
|
||||||
# User which runs tentacle server in proxy mode. Required with if proxy mode is enable (by default babel)
|
# User which runs tentacle server in proxy mode. Required with if proxy mode is enable (by default pandora)
|
||||||
# proxy_user pandora
|
# proxy_user pandora
|
||||||
|
|
||||||
|
# Max number of simmultaneus connection for proxy (by default 10)
|
||||||
|
# proxy_max_connection 10
|
||||||
|
|
||||||
|
# Proxy timeout (by default 1s)
|
||||||
|
# proxy_timeout 1
|
||||||
|
|
||||||
# User the agent will run as
|
# User the agent will run as
|
||||||
#pandora_user root
|
#pandora_user root
|
||||||
|
|
||||||
|
@ -150,7 +150,9 @@ my %Conf = (
|
|||||||
'udp_server_auth_address' => '0.0.0.0',
|
'udp_server_auth_address' => '0.0.0.0',
|
||||||
'udp_server' => 0,
|
'udp_server' => 0,
|
||||||
'proxy_mode' => 0,
|
'proxy_mode' => 0,
|
||||||
'proxy_user' => 'pandora'
|
'proxy_user' => 'pandora',
|
||||||
|
'proxy_max_connection' => 10,
|
||||||
|
'proxy_timeout' => 1,
|
||||||
);
|
);
|
||||||
|
|
||||||
# Modules
|
# Modules
|
||||||
@ -190,6 +192,9 @@ my $DevNull = '/dev/null';
|
|||||||
# Shell command separator
|
# Shell command separator
|
||||||
my $CmdSep = ';';
|
my $CmdSep = ';';
|
||||||
|
|
||||||
|
# PID of tentacle proxy, used in proxy mode
|
||||||
|
my $tentacle_pid = undef;
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Print usage information and exit.
|
# Print usage information and exit.
|
||||||
################################################################################
|
################################################################################
|
||||||
@ -615,20 +620,26 @@ sub check_remote_config () {
|
|||||||
# Launchs tentacle server in proxy mode.
|
# Launchs tentacle server in proxy mode.
|
||||||
################################################################################
|
################################################################################
|
||||||
sub launch_tentacle_proxy () {
|
sub launch_tentacle_proxy () {
|
||||||
|
# Check if proxy server ip is right.
|
||||||
|
if ($Conf{'server_ip'} ne "localhost") {
|
||||||
|
|
||||||
# Check if proxy mode is enable.
|
#Create a new process and launch tentacle.
|
||||||
if ($Conf{'proxy_mode'}) {
|
$tentacle_pid = fork();
|
||||||
|
|
||||||
my $auxPid = fork();
|
|
||||||
|
|
||||||
if (! $auxPid) {
|
|
||||||
|
|
||||||
my $new_process = "sudo -u ".$Conf{'proxy_user'}." tentacle_server -b ".$Conf{'server_ip'}." -g ".$Conf{'server_port'};
|
|
||||||
|
|
||||||
log_message ('setup', 'Proxy mode enabled');
|
if ($tentacle_pid == 0) {
|
||||||
|
# Change the UID
|
||||||
|
my $proxy_user_id = getpwnam($Conf{'proxy_user'});
|
||||||
|
$< = $proxy_user_id;
|
||||||
|
$> = $proxy_user_id;
|
||||||
|
|
||||||
|
#Execute tentacle server as a daemon
|
||||||
|
my $new_process = "tentacle_server -b ".$Conf{'server_ip'}." -g ".$Conf{'server_port'}." -c ".$Conf{'proxy_max_connection'}." -t ".$Conf{'proxy_timeout'};
|
||||||
|
|
||||||
|
log_message ('setup', 'Proxy mode enabled');
|
||||||
exec ($new_process);
|
exec ($new_process);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
log_message ('error', 'You can not proxy to localhost');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1353,10 +1364,27 @@ sub exec_plugin ($) {
|
|||||||
$ThreadSem->up () if (defined ($ThreadSem) && $Conf{'agent_threads'} > 1);
|
$ThreadSem->up () if (defined ($ThreadSem) && $Conf{'agent_threads'} > 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# TERM Handler
|
||||||
|
################################################################################
|
||||||
|
sub kill_signal_handler (){
|
||||||
|
# Kill tentacle server if it was launched
|
||||||
|
|
||||||
|
if (defined ($tentacle_pid)) {
|
||||||
|
print "kill -9 $tentacle_pid\n";
|
||||||
|
`kill -9 $tentacle_pid`;
|
||||||
|
}
|
||||||
|
exit (0);
|
||||||
|
}
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Main.
|
# Main.
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
|
#Handler TERM signal.
|
||||||
|
$SIG{'TERM'} = \&kill_signal_handler;
|
||||||
|
|
||||||
|
|
||||||
# Check command line arguments
|
# Check command line arguments
|
||||||
print_usage unless ($#ARGV == 0);
|
print_usage unless ($#ARGV == 0);
|
||||||
$ConfDir = fix_directory ($ARGV[0]);
|
$ConfDir = fix_directory ($ARGV[0]);
|
||||||
@ -1403,8 +1431,10 @@ sleep ($Conf{'delayed_startup'});
|
|||||||
my $PID = $$;
|
my $PID = $$;
|
||||||
`renice "$Conf{'pandora_nice'}" "$PID"`;
|
`renice "$Conf{'pandora_nice'}" "$PID"`;
|
||||||
|
|
||||||
#Launch tentacle server in proxy mode if needed
|
#Launch tentacle server in proxy mode if configured
|
||||||
launch_tentacle_proxy();
|
if ($Conf{'proxy_mode'}) {
|
||||||
|
launch_tentacle_proxy();
|
||||||
|
}
|
||||||
|
|
||||||
# Add the plugins directory to the PATH
|
# Add the plugins directory to the PATH
|
||||||
$ENV{'PATH'} .= ":$ConfDir/plugins";
|
$ENV{'PATH'} .= ":$ConfDir/plugins";
|
||||||
@ -1423,8 +1453,8 @@ if ($Conf{'udp_server'} == 1){
|
|||||||
# Loop
|
# Loop
|
||||||
while (1) {
|
while (1) {
|
||||||
|
|
||||||
# Ignore signals from UDP server while processing execution
|
# Ignore signals from UDP and Tentacle server while processing execution
|
||||||
if ($Conf{'udp_server'} == 1){
|
if ($Conf{'udp_server'} == 1 || $Conf{'proxy_mode'}){
|
||||||
$SIG{'INT'} = 'DEFAULT';
|
$SIG{'INT'} = 'DEFAULT';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,19 +60,6 @@ pidof_pandora () {
|
|||||||
echo $PANDORA_PID
|
echo $PANDORA_PID
|
||||||
}
|
}
|
||||||
|
|
||||||
pidof_tentacle () {
|
|
||||||
COLUMNS=400
|
|
||||||
OS_NAME=`uname -s`
|
|
||||||
if [ $OS_NAME = "HP-UX" ]
|
|
||||||
then
|
|
||||||
TENTACLE_PID=`ps -ex | grep "$DAEMON_TENTACLE" | grep -v grep | head -1 | awk '{ print $1 }'`
|
|
||||||
else
|
|
||||||
TENTACLE_PID=`ps -Af | grep "$DAEMON_TENTACLE" | grep -v grep | head -1 | awk '{ print $2 }'`
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo $TENTACLE_PID
|
|
||||||
}
|
|
||||||
|
|
||||||
if [ ! -f $DAEMON ]
|
if [ ! -f $DAEMON ]
|
||||||
then
|
then
|
||||||
echo "Pandora FMS Agent not found at $DAEMON, please check setup"
|
echo "Pandora FMS Agent not found at $DAEMON, please check setup"
|
||||||
@ -102,15 +89,8 @@ case "$1" in
|
|||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
echo "Stopping Pandora Agent."
|
echo "Stopping Pandora Agent."
|
||||||
su $PANDORA_USER -c "kill -9 $PANDORA_PID >/dev/null 2>&1"
|
su $PANDORA_USER -c "kill $PANDORA_PID >/dev/null 2>&1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
TENTACLE_PID=`pidof_tentacle`
|
|
||||||
if [ ! -z "$TENTACLE_PID" ]
|
|
||||||
then
|
|
||||||
echo "Stopping Tentacle Server."
|
|
||||||
kill $TENTACLE_PID > /dev/null 2>&1
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
status)
|
status)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user