summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntanas Uršulis <antanas.ursulis@gmail.com>2013-07-05 02:18:44 +0300
committerAntanas Uršulis <antanas.ursulis@gmail.com>2013-07-05 02:18:44 +0300
commitadecdbc1cd849ca19fbccf2c189f676d54b51e85 (patch)
tree2f7ba57579c82fea03b99bebf74c286ab629fc28
parent'clean' target update (diff)
downloadlog-analysis-adecdbc1cd849ca19fbccf2c189f676d54b51e85.tar.gz
log-analysis-adecdbc1cd849ca19fbccf2c189f676d54b51e85.tar.bz2
log-analysis-adecdbc1cd849ca19fbccf2c189f676d54b51e85.zip
Group logs by source hostname and add multiple-file submissions
-rw-r--r--flask_app.py11
-rw-r--r--simple_client.py15
-rw-r--r--submission.proto8
3 files changed, 20 insertions, 14 deletions
diff --git a/flask_app.py b/flask_app.py
index 87697e5..ce55c38 100644
--- a/flask_app.py
+++ b/flask_app.py
@@ -3,7 +3,7 @@ The web application built on Flask is contained within this file.
When run as a script, the Flask development server is started.
"""
-import os
+import os, socket
import submission_pb2, storage
from flask import Flask, request
@@ -16,13 +16,12 @@ def index():
@app.route('/submit', methods=['POST'])
def submit():
- """
- TODO:
- pass through all steps - input, analysis, storage
- """
submission = submission_pb2.Submission()
submission.ParseFromString(request.data)
- store.save_file(request.remote_addr, submission.filename, submission.data)
+ source = socket.getfqdn(request.remote_addr) # TODO: is this ok?
+ # TODO: pass through analyser
+ for f in submission.files:
+ store.save_file(source, f.filename, f.data)
return ''
if __name__ == '__main__':
diff --git a/simple_client.py b/simple_client.py
index bbd7835..0335260 100644
--- a/simple_client.py
+++ b/simple_client.py
@@ -4,16 +4,19 @@ Simple submission client that forms a correct protobuf message and performs a PO
import submission_pb2, sys, urllib
-def send_submission(filename):
+def send_submission(filenames):
submission = submission_pb2.Submission()
- submission.filename = filename
- submission.data = open(filename, 'rb').read()
+
+ for f in filenames:
+ new_file = submission.files.add()
+ new_file.filename = f
+ new_file.data = open(f, 'rb').read()
print urllib.urlopen('http://[::1]:5000/submit', submission.SerializeToString()).read()
if __name__ == '__main__':
- if len(sys.argv) != 2:
- sys.stderr.write('usage: ' + sys.argv[0] + ' FILENAME\n')
+ if len(sys.argv) < 2:
+ sys.stderr.write('usage: ' + sys.argv[0] + ' FILENAMES\n')
sys.exit(-1)
- send_submission(sys.argv[1])
+ send_submission(sys.argv[1:])
diff --git a/submission.proto b/submission.proto
index 70a60de..b06310f 100644
--- a/submission.proto
+++ b/submission.proto
@@ -1,4 +1,8 @@
message Submission {
- required string filename = 1;
- required bytes data = 2;
+ message File {
+ required string filename = 1;
+ required bytes data = 2;
+ }
+
+ repeated File files = 1;
}