Prechádzať zdrojové kódy

bugfix: fixed timestamp update in eye-statd

Roman Dmitriev 3 mesiacov pred
rodič
commit
17cae4a98b
1 zmenil súbory, kde vykonal 5 pridanie a 2 odobranie
  1. 5 2
      scripts/eye-statd.pl

+ 5 - 2
scripts/eye-statd.pl

@@ -192,7 +192,7 @@ sub refresh_config {
         $user_stats{$row->{ip}}{out}       = 0;
         $user_stats{$row->{ip}}{pkt_in}    = 0;
         $user_stats{$row->{ip}}{pkt_out}   = 0;
-        $user_stats{$row->{ip}}{last_found}= 0;
+        $user_stats{$row->{ip}}{last_found}= time();
     }
     log_verbose("Found " . $save_traf_count . " active ip-addresses with full save traffic log");
 
@@ -778,6 +778,7 @@ if (!$user_ip) {
     }
 
 $last_time = $traf_record->{starttime};
+if (!$last_time) { $last_time = time(); }
 
 $user_stats{$user_ip}{last_found} = $last_time;
 
@@ -862,10 +863,12 @@ log_debug("The user statistics calculation started");
 
 # update database
 foreach my $user_ip (keys %user_stats) {
-    next if (!exists $user_stats{$user_ip}{last_found});
+    next if (!exists $user_stats{$user_ip});
     my $user_ip_aton=StrToIp($user_ip);
     my $auth_id = $user_stats{$user_ip}{auth_id};
 
+    if (!$user_stats{$user_ip}{last_found}) { $user_stats{$user_ip}{last_found} = time(); }
+
     #last flow for user
     my ($sec,$min,$hour,$day,$month,$year) = (localtime($user_stats{$user_ip}{last_found}))[0,1,2,3,4,5];
     #flow time string