root/hydranode/utils/commlog.pl

Revision 2616, 2.0 kB (checked in by chemical, 3 years ago)

Updated the copyright header

  • Property svn:executable set to *
Line 
1 #!/usr/bin/perl
2 #/*
3 # *  Copyright (C) 2005-2006 Roland Arendes <roland@arendes.de>
4 # *
5 # *  This program is free software; you can redistribute it and/or modify
6 # *  it under the terms of the GNU General Public License as published by
7 # *  the Free Software Foundation; either version 2 of the License, or
8 # *  (at your option) any later version.
9 # *
10 # *  This program is distributed in the hope that it will be useful,
11 # *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # *  GNU General Public License for more details.
14 # *
15 # *  You should have received a copy of the GNU General Public License
16 # *  along with this program; if not, write to the Free Software
17 # *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18 # *
19 # *  Credits go to Jonathan Middleton <jjm@ixtab.org.uk> and
20 # *  Paul Slootman <paul@debian.org>, for writing logtail (part of Logcheck)
21 # */
22
23 open(LOGFILE, '<', $ENV{HOME}."/.hydranode/hydranode.log") || die "Could not open file: $!\n";
24         while (<LOGFILE>) {
25                 # sample line
26                 # [2005-Oct-30 17:42:27] Trace(ed2k.client): [84.9.148.207:4662] Sending QueueRanking 925.
27                 # [2005-Oct-30 17:56:53] Trace(ed2k.client): [14913758:4662] 0x88026a8: Performing LowID callback...
28
29                 # from the tracemask "chunks"
30                 # [2006-Jan-27 01:36:57] Trace(chunks): [15557483:6346] eDonkey2000 chunkmap: 01
31                 # [2006-Jan-27 01:36:57] Trace(chunks): Failure to select chunk, did 1 hops
32
33                 if (m/^\[(.+)\] .+\[(.+:\d+)\] (.+)$/) {
34                         $datetime = $1; $ipport = $2; $logline = $3;
35                         $clientlog{"$ipport"} .= $datetime.": ".$logline."\n";
36                        
37                         if ($logline =~ m/eDonkey2000 chunkmap/) {
38                                 # next line is supposed to be the chunk selection, add it to the list of the last known ip/port
39                                 $_ = <LOGFILE>;
40                                 m/.+ Trace\(chunks\): (.+)$/;           
41                                 $clientlog{"$ipport"} .= $datetime.": eDonkey2000 chunkmap: ".$1."\n";
42                         }
43                 }
44         }
45 close(LOGFILE);
46
47 for $client (keys %clientlog) {
48                 print $client."\n".$clientlog{$client}."\n";
49 }
Note: See TracBrowser for help on using the browser.