2014-08-18 Ramon Novoa <rnovoa@artica.es>
* Linux/pandora_agent.conf, pandora_agent: Added support to start and stop processes via the UDP server. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@10433 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
afded600f0
commit
911c92b2a8
|
@ -1,3 +1,9 @@
|
|||
2014-08-18 Ramon Novoa <rnovoa@artica.es>
|
||||
|
||||
* Linux/pandora_agent.conf,
|
||||
pandora_agent: Added support to start and stop processes via the UDP
|
||||
server.
|
||||
|
||||
2014-08-14 Ramon Novoa <rnovoa@artica.es>
|
||||
|
||||
* plugins/grep_log,
|
||||
|
|
|
@ -31,6 +31,9 @@ udp_server 0
|
|||
udp_server_port 41122
|
||||
udp_server_auth_address 0.0.0.0
|
||||
|
||||
#process_xeyes_start xeyes
|
||||
#process_xeyes_stop killall xeyes
|
||||
|
||||
# By default, agent takes machine name
|
||||
#agent_name adama
|
||||
|
||||
|
|
|
@ -1766,13 +1766,40 @@ sub udp_server ($$) {
|
|||
my($port, $ipaddr) = sockaddr_in($sock->peername);
|
||||
$hishost = gethostbyaddr($ipaddr, AF_INET);
|
||||
|
||||
log_message ('udp server', 'Received signal from '.$hishost);
|
||||
|
||||
if (($udp_auth_address eq "0.0.0.0") || ($hishost eq $udp_auth_address)){
|
||||
if ($newmsg =~ /REFRESH AGENT/){
|
||||
# Send signal to restart agent
|
||||
log_message ('udp server', 'Received signal from '.$hishost);
|
||||
kill 'SIGINT' , $parent_pid;
|
||||
}
|
||||
elsif ($newmsg =~ /PROCESS START (.*)/){
|
||||
my $process_name = $1;
|
||||
$process_name =~ s/^\s*//g;
|
||||
$process_name =~ s/\s*$//g;
|
||||
if (defined($Conf{"process_${process_name}_start"})) {
|
||||
log_message ('udp server', "Process $process_name started from $hishost");
|
||||
if (fork() == 0) {
|
||||
`$Conf{"process_${process_name}_start"} 2>$DevNull`;
|
||||
exit 0;
|
||||
}
|
||||
} else {
|
||||
log_message ('udp server', "Attempt to start unknown process $process_name from $hishost");
|
||||
}
|
||||
}
|
||||
elsif ($newmsg =~ /PROCESS STOP (.*)/){
|
||||
my $process_name = $1;
|
||||
$process_name =~ s/^\s*//g;
|
||||
$process_name =~ s/\s*$//g;
|
||||
if (defined($Conf{"process_${process_name}_stop"})) {
|
||||
log_message ('udp server', "Process $process_name stopped from $hishost");
|
||||
if (fork() == 0) {
|
||||
`$Conf{"process_${process_name}_stop"} 2>$DevNull`;
|
||||
exit 0;
|
||||
}
|
||||
} else {
|
||||
log_message ('udp server', "Attempt to stop unknown process $process_name from $hishost");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue