]> p2p-next.cs.pub.ro Git - cs-p2p-next.git/commitdiff
ppf/log-parser: script to parse an archive
authorp2p p2p-next-02 <p2p@p2p-next-02.grid.pub.ro>
Wed, 13 Apr 2011 14:40:38 +0000 (17:40 +0300)
committerp2p p2p-next-02 <p2p@p2p-next-02.grid.pub.ro>
Wed, 13 Apr 2011 14:40:38 +0000 (17:40 +0300)
ppf/log-parser/libtorrent/README
ppf/log-parser/libtorrent/log_parser [new file with mode: 0755]

index 3780f4ecc2e7b37d4b2f28e1e60b5112b3215301..a4f9f791fcd1772dc11dfd448ea1eb5ea761732a 100644 (file)
@@ -14,6 +14,10 @@ Basename must have ${IP_ADDRESS}_${LISTEN_PORT}.log syntax.
 The parser recognizes the message types as defined in the BitTorrent
 specification[1].
 
+== log_parser ==
+
+libtorrent log files script parser. Receives a .tar.gz archive as argument.
+
 == sample run ==
 
 In order to see the above modules at work, use the run_sample script. Just
diff --git a/ppf/log-parser/libtorrent/log_parser b/ppf/log-parser/libtorrent/log_parser
new file mode 100755 (executable)
index 0000000..627e4c4
--- /dev/null
@@ -0,0 +1,45 @@
+#!/bin/bash
+
+DB_NAME=test.db
+DIR_LOCAL="$(cd "$(dirname "$0")" && pwd)"
+ARCHIVE=$1
+
+# remove temp folder in case it exists
+rm -Rf temp
+
+# extract archive in folder ./temp
+mkdir temp
+echo -e "Extracting archive..."
+tar --transform='s,^,temp/,' -xzf "$ARCHIVE"
+echo -e "Archive extracted successfully."
+
+# remove database in case it exists
+rm -f $DIR_LOCAL/$DB_NAME
+
+# create database
+pushd $DIR_LOCAL/../../db/
+./db_init $DIR_LOCAL/$DB_NAME
+echo -e "Database created."
+
+# fill database with test data
+PYTHONPATH=$DIR/../../db/ python DatabaseAccess.py $DIR_LOCAL/$DB_NAME
+popd
+
+# fill logging information
+echo -e "Parsing log files"
+for folder in $(find $DIR_LOCAL/temp -type d -name 'libtorrent_logs*' | sort ); do
+    for log_file in $(find $folder -type f | sort); do
+        yes y | PYTHONPATH=$DIR_LOCAL/../../db/ python $DIR_LOCAL/LogParser.py -i 1 -f $log_file $DIR_LOCAL/$DB_NAME
+    done
+done
+echo -e "Log files parsed."
+
+# fill status information
+echo -e "Parsing status file."
+PYTHONPATH=$DIR_LOCAL/../../db/ python $DIR_LOCAL/StatusParser.py -i 1 -f $DIR_LOCAL/temp/status.log $DIR_LOCAL/$DB_NAME
+echo -e "Status file parsed."
+
+echo -e "DONE!"
+
+rm -Rf temp
+exit 0