2011-06-28 Sergio Martin <sergio.martin@artica.es>
* 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 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4490 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
6eb156ae54
commit
9e6ac827c8
|
@ -1,3 +1,11 @@
|
||||||
|
2011-06-28 Sergio Martin <sergio.martin@artica.es>
|
||||||
|
|
||||||
|
* 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 <vanessa.gil@artica.es>
|
2011-06-27 Vanessa Gil <vanessa.gil@artica.es>
|
||||||
|
|
||||||
* unix/pandora_agent: Create configuration file for drone agents in Unix.
|
* unix/pandora_agent: Create configuration file for drone agents in Unix.
|
||||||
|
|
|
@ -40,6 +40,9 @@ udp_server_auth_address 0.0.0.0
|
||||||
# Group assigned for this agent (descriptive, p.e: Servers)
|
# Group assigned for this agent (descriptive, p.e: Servers)
|
||||||
#group 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
|
# Autotime: Enforce to server to ignore timestamp coming from this
|
||||||
# agent, used when agents has no timer or it's inestable. 1 to enable
|
# agent, used when agents has no timer or it's inestable. 1 to enable
|
||||||
# this feature
|
# this feature
|
||||||
|
@ -51,6 +54,11 @@ udp_server_auth_address 0.0.0.0
|
||||||
# Agent position paramters
|
# Agent position paramters
|
||||||
# Those parameters define the geographical position of the agent
|
# 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
|
||||||
#latitude 0
|
#latitude 0
|
||||||
# longitude
|
# longitude
|
||||||
|
|
|
@ -484,7 +484,6 @@ sub read_config (;$) {
|
||||||
|
|
||||||
# Token not found
|
# Token not found
|
||||||
if (defined ($token)) {
|
if (defined ($token)) {
|
||||||
close (CONF_FILE);
|
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1587,16 +1586,55 @@ while (1) {
|
||||||
# Check file collections
|
# Check file collections
|
||||||
check_collections () unless ($Conf{'debug'} eq '1');
|
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 = "<?xml version='1.0' encoding='" . $Conf{'encoding'} . "'?>\n" .
|
$Xml = "<?xml version='1.0' encoding='" . $Conf{'encoding'} . "'?>\n" .
|
||||||
"<agent_data description='" . $Conf{'description'} ."' group='" . $Conf{'group'} .
|
"<agent_data description='" . $Conf{'description'} ."' group='" . $Conf{'group'} .
|
||||||
"' os_name='$OS' os_version='$OS_VERSION' interval='" . $Conf{'interval'} .
|
"' os_name='$OS' os_version='$OS_VERSION' interval='" . $Conf{'interval'} .
|
||||||
"' version='" . AGENT_VERSION . '(Build ' . AGENT_BUILD . ')' . ($Conf{'autotime'} eq '1' ? '' : "' timestamp='" . strftime ('%Y/%m/%d %H:%M:%S', localtime ())) .
|
"' version='" . AGENT_VERSION . '(Build ' . AGENT_BUILD . ')' . ($Conf{'autotime'} eq '1' ? '' : "' timestamp='" . strftime ('%Y/%m/%d %H:%M:%S', localtime ())) .
|
||||||
"' agent_name='" . $Conf{'agent_name'} . "' timezone_offset='". $Conf{'timezone_offset'};
|
"' agent_name='" . $Conf{'agent_name'} . "' timezone_offset='". $Conf{'timezone_offset'};
|
||||||
|
|
||||||
|
if (defined ($Conf{'ip_address'})) {
|
||||||
|
$Xml .= "' ip_address='" .$ip_address;
|
||||||
|
}
|
||||||
|
|
||||||
if (defined ($Conf{'parent_agent_name'})) {
|
if (defined ($Conf{'parent_agent_name'})) {
|
||||||
$Xml .= "' parent_agent_name='" .$Conf{'parent_agent_name'};
|
$Xml .= "' parent_agent_name='" .$Conf{'parent_agent_name'};
|
||||||
}
|
}
|
||||||
if (defined ($Conf{'longitude'}) && defined ($Conf{'latitude'})) {
|
|
||||||
|
# Check the gis mode (exec or manual). If exec script is defined, we execute it and get the coordenates
|
||||||
|
if (defined ($Conf{'gis_exec'}) && (-e $Conf{'gis_exec'})) {
|
||||||
|
my $coord_str = `$Conf{'gis_exec'}`;
|
||||||
|
chomp($coord_str);
|
||||||
|
my @coords = split(',',$coord_str);
|
||||||
|
# Check if lat and long are numeric
|
||||||
|
if (defined($coords[0]) && defined($coords[1]) && ($coords[0] =~ /^-?(\d+)\.(\d+)$|^-?(\d+)$/) && ($coords[1] =~ /^-?(\d+)\.(\d+)$|^-?(\d+)$/)) {
|
||||||
|
my $lat = $coords[0];
|
||||||
|
my $long = $coords[1];
|
||||||
|
|
||||||
|
$Xml .= "' longitude='" .$long . "' latitude='" .$lat;
|
||||||
|
|
||||||
|
if (defined ($coords[2])) {
|
||||||
|
my $alt = $coords[2];
|
||||||
|
$Xml .= "' altitude='" .$alt;
|
||||||
|
}
|
||||||
|
if (defined ($Conf{'position_description'})) {
|
||||||
|
$Xml .= "' position_description='" .$Conf{'position_description'};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elsif (defined ($Conf{'longitude'}) && defined ($Conf{'latitude'})) {
|
||||||
$Xml .= "' longitude='" .$Conf{'longitude'} . "' latitude='" .$Conf{'latitude'};
|
$Xml .= "' longitude='" .$Conf{'longitude'} . "' latitude='" .$Conf{'latitude'};
|
||||||
if (defined ($Conf{'altitude'})) {
|
if (defined ($Conf{'altitude'})) {
|
||||||
$Xml .= "' altitude='" .$Conf{'altitude'};
|
$Xml .= "' altitude='" .$Conf{'altitude'};
|
||||||
|
|
Loading…
Reference in New Issue