Commit 6a03dea6 authored by koennecke's avatar koennecke
Browse files

Adapted makeindexes and messagecount scripts to the new MongoDB infrastructure

parent 7ac26714
#!/usr/bin/python
# virtualenv activation for the best and brightest pymongo version
# This version works on my Mac
activate_this = '/Users/konnecke/Envs/pymongo/bin/activate_this.py'
execfile(activate_this,dict(__file__=activate_this))
import pymongo
from pymongo import MongoClient
mongodb = MongoClient('mongodb://logwriter:sinqsics@mpc1965:27017/?authSource=admin')
mongodb = MongoClient('mongodb://sinqUserRW:8Mh7]YFUE6JP]dQ7@mgdbaas001:27017,mgdbaas002:27017,mgdbaas003:27017/sinqProdDB01?replicaSet=rs_prod-DataScience-01&connectTimeoutMS=300&authSource=sinqProdDB01')
dblist = ['amor', 'boa', 'dmc', 'eiger', 'focus', 'hrpt', 'morpheus',
'narziss', 'orion', 'poldi', 'rita2', 'sans', 'sans2', 'tasp']
'narziss', 'orion', 'poldi', 'rita2', 'sans', 'sans2', 'tasp','zebra']
#dblist = ['orion']
db = mongodb['sinqProdDB01']
for inst in dblist:
db = mongodb[inst]
db.log.create_index([('timestamp',pymongo.ASCENDING)])
com = "db.log_%s.create_index([('timestamp',pymongo.ASCENDING)])" % (inst)
print(com)
exec com
#!/usr/bin/python
import pymongo
# virtualenv activation for the best and brightest pymongo version
# This version works on rhel7
activate_this = '/afs/psi.ch/project/sinqdev/mksics/sicspsi/utils/pymongo/rhel7/bin/activate_this.py'
execfile(activate_this,dict(__file__=activate_this))
import datetime
import time
from pymongo import MongoClient
from datetime import timedelta
mongodb = MongoClient('mongodb://logwriter:sinqsics@mpc1965:27017/?authSource=admin')
mongodb = MongoClient('mongodb://sinqUserRW:8Mh7]YFUE6JP]dQ7@mgdbaas001:27017,mgdbaas002:27017,mgdbaas003:27017/sinqProdDB01?replicaSet=rs_prod-DataScience-01&connectTimeoutMS=300&authSource=sinqProdDB01')
dblist = ['amor', 'boa', 'dmc', 'eiger', 'focus', 'hrpt', 'morpheus',
'narziss', 'orion', 'poldi', 'rita2', 'sans', 'sans2', 'tasp', 'zebra']
......@@ -16,9 +19,15 @@ totime = datetime.datetime.today()
totime = datetime.datetime(totime.year,totime.month,totime.day)
fromtime = totime - timedelta(1)
db = mongodb['sinqProdDB01']
print('Message counts between ' + str(fromtime) + ' to ' + str(totime) )
#print('fromtime: ' + str(time.mktime(fromtime.timetuple())))
#print('totime: ' + str(time.mktime(totime.timetuple())))
for inst in dblist:
db = mongodb[inst]
ct = db.log.find({"timestamp" : {"$gt": time.mktime(fromtime.timetuple()),
"$lt" : time.mktime(totime.timetuple())} }).count()
com = 'ct = db.log_%s.find({"timestamp" : {"$gt": time.mktime(fromtime.timetuple()), "$lt" : time.mktime(totime.timetuple())} }).count()' % (inst)
# print(com)
exec com
print(inst + ',' + str(ct))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment