added Log Parsing
[spider.git] / perl / cluster.pl
index 8e88884214b0b3b239d003d31f2982cbb7b14265..666f4f87fd0b59d0b167b297f3ef11cbec3d454c 100755 (executable)
@@ -27,6 +27,7 @@ use Msg;
 use DXVars;
 use DXDebug;
 use DXLog;
+use DXLogPrint;
 use DXUtil;
 use DXChannel;
 use DXUser;
@@ -48,7 +49,8 @@ package main;
 @inqueue = ();                                 # the main input queue, an array of hashes
 $systime = 0;                                  # the time now (in seconds)
 $version = 1.5;                                        # the version no of the software
-
+$starttime = 0;                 # the starting time of the cluster   
 # handle disconnections
 sub disconnect
 {
@@ -148,7 +150,7 @@ sub process_inqueue
        
        my $data = $self->{data};
        my $dxchan = $self->{dxchan};
-       my ($sort, $call, $line) = $data =~ /^(\w)(\w+)\|(.*)$/;
+       my ($sort, $call, $line) = $data =~ /^(\w)(\S+)\|(.*)$/;
        
        # do the really sexy console interface bit! (Who is going to do the TK interface then?)
        dbg('chan', "<- $sort $call $line\n");
@@ -171,13 +173,23 @@ sub process_inqueue
        }
 }
 
+sub uptime
+{
+       my $t = $systime - $starttime;
+       my $days = int $t / 86400;
+       $t -= $days * 86400;
+       my $hours = int $t / 3600;
+       $t -= $hours * 3600;
+       my $mins = int $t / 60;
+       return sprintf "%d %02d:%02d", $days, $hours, $mins;
+}
 #############################################################
 #
 # The start of the main line of code 
 #
 #############################################################
 
-$systime = time;
+$starttime = $systime = time;
 
 # open the debug file, set various FHs to be unbuffered
 foreach (@debug) {