|
|
|
@ -10,13 +10,14 @@
|
|
|
|
|
from flask import Flask, session, request, redirect, Response
|
|
|
|
|
from flask.templating import render_template
|
|
|
|
|
from flask_session import Session
|
|
|
|
|
|
|
|
|
|
import time
|
|
|
|
|
import sys
|
|
|
|
|
import os
|
|
|
|
|
import json
|
|
|
|
|
import re
|
|
|
|
|
import monitor
|
|
|
|
|
import Queue
|
|
|
|
|
from utils.transport import *
|
|
|
|
|
PARAMS = {'context':''}
|
|
|
|
|
if len(sys.argv) > 1:
|
|
|
|
|
|
|
|
|
@ -54,10 +55,14 @@ f.close()
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
#
|
|
|
|
|
from threading import Timer,Thread
|
|
|
|
|
ProcessQueue = Queue.LifoQueue()
|
|
|
|
|
mthread = monitor.Monitor(HANDLERS,ProcessQueue,'processes')
|
|
|
|
|
from threading import Thread, RLock
|
|
|
|
|
p = {'uri':'http://dev.the-phi.com:5984','dbname':'monitor','uid':'logs','filename':'logs.JSON'}
|
|
|
|
|
factory = DataSourceFactory()
|
|
|
|
|
gWriter = factory.instance(type='CouchdbWriter',args=p)
|
|
|
|
|
gReader = factory.instance(type='CouchdbReader',args=p)
|
|
|
|
|
mthread = monitor.Monitor(HANDLERS,gWriter,'processes',)
|
|
|
|
|
mthread.start()
|
|
|
|
|
|
|
|
|
|
#(Timer(10,mthread.run)).start()
|
|
|
|
|
#mthread = Process(target=monitor.Monitor,args=(HANDLERS,ProcessQueue,'processes'))
|
|
|
|
|
#mthread.start()
|
|
|
|
@ -76,14 +81,21 @@ def procs(id):
|
|
|
|
|
def trends ():
|
|
|
|
|
id = request.args.get('id')
|
|
|
|
|
# key = request.args.get('key')
|
|
|
|
|
global mthread
|
|
|
|
|
# mLock.acquire()
|
|
|
|
|
|
|
|
|
|
time.sleep(2)
|
|
|
|
|
doc = gReader.read()
|
|
|
|
|
doc['row']
|
|
|
|
|
handler = monitor.mapreducer()
|
|
|
|
|
r = handler.filter(id,mthread.logs)
|
|
|
|
|
print r
|
|
|
|
|
if 'kate' in r:
|
|
|
|
|
for item in r['kate']:
|
|
|
|
|
print item['hour'],item['minute']
|
|
|
|
|
r = handler.filter(id,logs)
|
|
|
|
|
r = handler.run(r,handler.mapper,handler.reducer)
|
|
|
|
|
|
|
|
|
|
# mLock.release()
|
|
|
|
|
if 'Google Chrome' in r:
|
|
|
|
|
for item in r['Google Chrome']:
|
|
|
|
|
print item['hour'],item['minute']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return json.dumps(r)
|
|
|
|
|
@app.route('/dashboard')
|
|
|
|
|
def dashboard():
|
|
|
|
|