diff --git a/pandora_agents/ChangeLog b/pandora_agents/ChangeLog index f1553344ed..f9fe68443b 100644 --- a/pandora_agents/ChangeLog +++ b/pandora_agents/ChangeLog @@ -1,3 +1,11 @@ +2011-06-28 Sergio Martin + + * unix/Linux/pandora_agent.conf + unix/pandora_agent: Added ip_address token to conf file and + auto and manual mode into agent script. + Added gis_exec token to obtain gis coordinates executing a + script + 2011-06-27 Vanessa Gil * unix/pandora_agent: Create configuration file for drone agents in Unix. diff --git a/pandora_agents/unix/Linux/pandora_agent.conf b/pandora_agents/unix/Linux/pandora_agent.conf index 280efaee0d..7546adf981 100755 --- a/pandora_agents/unix/Linux/pandora_agent.conf +++ b/pandora_agents/unix/Linux/pandora_agent.conf @@ -40,6 +40,9 @@ udp_server_auth_address 0.0.0.0 # Group assigned for this agent (descriptive, p.e: Servers) #group Servers +# ip_address: Enforce to server a ip address to this agent +#ip_address 192.168.36.73 + # Autotime: Enforce to server to ignore timestamp coming from this # agent, used when agents has no timer or it's inestable. 1 to enable # this feature @@ -51,6 +54,11 @@ udp_server_auth_address 0.0.0.0 # Agent position paramters # Those parameters define the geographical position of the agent +# gis_exec: Call a script that returns a string with "latitude,longitude,altitude" +# i.e.: 41.377,-5.105,2.365 + +#gix_exec /tmp/gis.sh + # latitude #latitude 0 # longitude diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 2a9a8c5ff3..0141af1d80 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -484,7 +484,6 @@ sub read_config (;$) { # Token not found if (defined ($token)) { - close (CONF_FILE); return undef; } @@ -1587,16 +1586,55 @@ while (1) { # Check file collections check_collections () unless ($Conf{'debug'} eq '1'); + my $ip_address; + + if(defined($Conf{'ip_address'})) { + # Check if ip_address is auto to get the local ip + if ($Conf{'ip_address'} eq 'auto') { + $ip_address = `ifconfig -a | grep -v '127.0.0' | grep '[0-9]*\\.[0-9]*\\.[0-9]*' | awk '{ print \$2 }' | head -1 | sed -e 's/addr\\://' | sed -e 's/inet\\://'`; + chomp($ip_address); + } + else { + $ip_address = $Conf{'ip_address'}; + } + } + $Xml = "\n" . "