$hostname=$default_hostname;
// locate hostname from DB based on this IP
$interfaces=$adm->GetInterfaces(array("ip"=>$ip));
+
+if (empty($interfaces) ) { // maybe its a node with a NAT'd IP addresses
+ // look up an interface tag using the public IP address value
+ $interfacetags=$adm->GetInterfaceTags(array("tagname"=>"public_ip_address","value"=>$ip));
+ if (! empty($interfacetags)) {
+ // using the interface_id now get the interface with the node_id information
+ $interface_id=$interfacetags[0]['interface_id'];
+ $interfaces=$adm->GetInterfaces($interface_id);
+ // fall thru to the conditional below ...
+ }
+ }
+
if (! empty($interfaces) ) {
$interface=$interfaces[0];
$node_id=$interface['node_id'];
$rawdir=$logdir . "/raw";
$date=strftime("%Y-%m-%d-%H-%M");
-$log_name=$rawdir . "/" . $date . "-" . $hostname . "-" . $ip . ".txt";
+$log_name=$date . "-" . $hostname . "-" . $ip . ".txt";
+$log_path=$rawdir . "/" . $log_name;
$month=strftime("%Y-%m");
$time=strftime("%d-%H-%M");
////////////////////////////////////////
-$log=fopen($log_name,"w") or die ("Cannot open logfile "+$log_name);
+$log=fopen($log_path,"w") or die ("Cannot open logfile "+$log_path);
$uploaded_name= $_FILES['log']['tmp_name'];
$uploaded_size=filesize($uploaded_name);
fprintf ( $log, "contents from an unrecognized IP address was truncated to %d bytes\n",$limit_bytes);
$truncated=TRUE;
$uploaded_size=$limit_bytes;
+ } else {
+ $truncated=FALSE;
}
fprintf( $log, "-----------------\n\n" );
fclose($uploaded);
fwrite($log,$contents);
if ($truncated)
- fwrite ($log, " ..<truncated>..\n");
+ fwrite ($log, " ..<" . "truncated" . ">..\n");
fclose($log);
////////////////////////////////////////
$linkdir = $linkdir . "/" . $hostname;
mkdir_if_needed ($linkdir);
$link = $linkdir . "/" . $time ;
-symlink ($log_name,$link);
+symlink ("../../../raw/".$log_name,$link);
# /var/log/bm/per-hostname/onelab1.inria.fr/2008-11-31-20-02.bmlog
$linkdir=$logdir;
$linkdir=$linkdir . "/" . $hostname;
mkdir_if_needed ($linkdir);
$link = $linkdir . "/" . $month . "-" . $time ;
-symlink ($log_name,$link);
+symlink ("../../raw/".$log_name,$link);
# /var/log/bm/per-ip/138.96.250.141/2008-11-31-20-02.bmlog
$linkdir=$logdir;
$linkdir=$linkdir . "/" . $ip;
mkdir_if_needed ($linkdir);
$link = $linkdir . "/" . $month . "-" . $time ;
-symlink ($log_name,$link);
+symlink ("../../raw/".$log_name,$link);
?>