Skip to content

Commit

Permalink
Merge pull request #4 from andrewmcgilvray/retentiondate
Browse files Browse the repository at this point in the history
Add timestamp to retention document so that orphaned data can be cleaned up.
  • Loading branch information
naparuba committed May 12, 2014
2 parents 5367dcd + 3f25b41 commit 1c47941
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions module/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

import time
import cPickle
import datetime

import base64
from multiprocessing import Process, cpu_count
Expand Down Expand Up @@ -119,6 +120,7 @@ def job(self, all_data, wid, offset):
# Reinit the mongodb connexion if need
self.init()
all_objs = {'hosts':{}, 'services':{}}
date = datetime.datetime.utcnow()

hosts = all_data['hosts']
services = all_data['services']
Expand All @@ -136,7 +138,7 @@ def job(self, all_data, wid, offset):
val = cPickle.dumps(h, protocol=cPickle.HIGHEST_PROTOCOL)
val2 = base64.b64encode(val)
# We save it in the Gridfs for hosts
all_objs['hosts'][key] = {'_id':key, 'value':val2}
all_objs['hosts'][key] = {'_id':key, 'value':val2, 'date':date}

i = -1
for (h_name, s_desc) in services:
Expand All @@ -151,7 +153,7 @@ def job(self, all_data, wid, offset):
key = key.replace(' ', 'SPACE')
val = cPickle.dumps(s, protocol=cPickle.HIGHEST_PROTOCOL)
val2 = base64.b64encode(val)
all_objs['services'][key] = {'_id':key, 'value':val2}
all_objs['services'][key] = {'_id':key, 'value':val2, 'date':date}

if len(all_objs['hosts']) != 0:
t2 = time.time()
Expand Down

0 comments on commit 1c47941

Please sign in to comment.