Skip to content

Commit

Permalink
convert timestamps to human readable format
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinAzoff committed Jan 10, 2014
1 parent 56739e9 commit 5e8bd92
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion netflowindexer/bro/searcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from netflowindexer.base.searcher import BaseSearcher
from netflowindexer import util
import re
import datetime

class BroSearcher(BaseSearcher):
def docid_to_date(self, fn):
Expand All @@ -13,14 +14,19 @@ def docid_to_date(self, fn):
t = "%s.%s" % (d, h)
return util.strptime(t,'%Y-%m-%d.%H')

def fix_ts(self, line):
ts, rest = line.split("\t", 1)
ts = datetime.datetime.fromtimestamp(float(ts)).isoformat()
return '\t'.join((ts, rest))

def show(self, doc, ips):
ips = [ip.replace(".", "\.") for ip in ips]
inner = "|".join(ips)
rex = re.compile("\t(%s)\t" % inner)

for line in subprocess.Popen(["zcat", doc], stdout=subprocess.PIPE).stdout:
if rex.search(line):
yield line.rstrip()
yield self.fix_ts(line.rstrip())

def search(self, ips, dump=False, filter=None, mode=None):
docs = self.search_ips(ips)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import setup, find_packages

version = '0.1.37'
version = '0.1.38'
long_description = ""

setup(name='netflowindexer',
Expand Down

0 comments on commit 5e8bd92

Please sign in to comment.