Fixed a bug with a off by one severity number in sicslogquery.c
Added a number of python utilities for querying the mongoDB
This commit is contained in:
@ -160,7 +160,7 @@ int sicslogQuery(int argc, char *argv[], ResultCallback_t func, void *userData)
|
||||
build the query
|
||||
*/
|
||||
snprintf(jsonQuery, sizeof(jsonQuery),"{ \"timestamp\" : {\"$gt\": %ld, \"$lt\": %ld}, \"severity\": {\"$lte\": %d}",
|
||||
from,to,severity-1);
|
||||
from,to,severity);
|
||||
if(sub != NULL){
|
||||
snprintf(subQuery,sizeof(subQuery),", \"sub\" : \"%s\"", sub);
|
||||
strncat(jsonQuery,subQuery,sizeof(jsonQuery));
|
||||
|
35
utils/pymongo/errorstatistics
Executable file
35
utils/pymongo/errorstatistics
Executable file
@ -0,0 +1,35 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import pymongo
|
||||
import datetime
|
||||
import time
|
||||
import sys
|
||||
|
||||
from pymongo import MongoClient
|
||||
from datetime import timedelta
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
print('Usage:\n\terrorstatistics instrument')
|
||||
sys.exit()
|
||||
|
||||
inst = sys.argv[1]
|
||||
|
||||
mongodb = MongoClient('mongodb://logwriter:sinqsics@mpc1965:27017/?authSource=admin')
|
||||
|
||||
totime = datetime.datetime.today()
|
||||
totime = datetime.datetime(totime.year,totime.month,totime.day)
|
||||
fromtime = totime - timedelta(1)
|
||||
|
||||
messagedict = {}
|
||||
db = mongodb[inst]
|
||||
for entry in db.log.find({"timestamp" : {"$gt": time.mktime(fromtime.timetuple()),
|
||||
"$lt" : time.mktime(totime.timetuple())}, "severity": {"$lte": 2} }):
|
||||
mes = entry['message']
|
||||
if messagedict.has_key(mes):
|
||||
messagedict[mes] = messagedict[mes] + 1
|
||||
else:
|
||||
messagedict[mes] = 1
|
||||
|
||||
|
||||
for mes in sorted(messagedict, key=messagedict.get):
|
||||
print('%8d %s' %(messagedict[mes], mes ))
|
24
utils/pymongo/errorsummary
Executable file
24
utils/pymongo/errorsummary
Executable file
@ -0,0 +1,24 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import pymongo
|
||||
import datetime
|
||||
import time
|
||||
|
||||
from pymongo import MongoClient
|
||||
from datetime import timedelta
|
||||
|
||||
mongodb = MongoClient('mongodb://logwriter:sinqsics@mpc1965:27017/?authSource=admin')
|
||||
|
||||
dblist = ['amor', 'boa', 'dmc', 'eiger', 'focus', 'hrpt', 'morpheus',
|
||||
'narziss', 'orion', 'poldi', 'rita2', 'sans', 'sans2', 'tasp']
|
||||
|
||||
totime = datetime.datetime.today()
|
||||
totime = datetime.datetime(totime.year,totime.month,totime.day)
|
||||
fromtime = totime - timedelta(1)
|
||||
|
||||
print('Error counts between ' + str(fromtime) + ' to ' + str(totime) )
|
||||
for inst in dblist:
|
||||
db = mongodb[inst]
|
||||
ct = db.log.find({"timestamp" : {"$gt": time.mktime(fromtime.timetuple()),
|
||||
"$lt" : time.mktime(totime.timetuple())}, "severity": {"$lte": 2} }).count()
|
||||
print(inst + ',' + str(ct))
|
15
utils/pymongo/makeindexes
Executable file
15
utils/pymongo/makeindexes
Executable file
@ -0,0 +1,15 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import pymongo
|
||||
|
||||
from pymongo import MongoClient
|
||||
|
||||
mongodb = MongoClient('mongodb://logwriter:sinqsics@mpc1965:27017/?authSource=admin')
|
||||
|
||||
dblist = ['amor', 'boa', 'dmc', 'eiger', 'focus', 'hrpt', 'morpheus',
|
||||
'narziss', 'orion', 'poldi', 'rita2', 'sans', 'sans2', 'tasp']
|
||||
|
||||
for inst in dblist:
|
||||
db = mongodb[inst]
|
||||
db.log.create_index([('timestamp',pymongo.ASCENDING)])
|
||||
|
Reference in New Issue
Block a user