|
|
|
@ -1,15 +1,17 @@
|
|
|
|
|
import multiprocessing
|
|
|
|
|
#import multiprocessing
|
|
|
|
|
from threading import Thread, Lock
|
|
|
|
|
from utils import transport
|
|
|
|
|
import time
|
|
|
|
|
import monitor
|
|
|
|
|
import sys
|
|
|
|
|
import os
|
|
|
|
|
"""
|
|
|
|
|
This class is intended to collect data given a configuration
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
class Top(multiprocessing.Process):
|
|
|
|
|
class Top(Thread):
|
|
|
|
|
def __init__(self,_config,lock):
|
|
|
|
|
multiprocessing.Process.__init__(self)
|
|
|
|
|
Thread.__init__(self)
|
|
|
|
|
self.lock = lock
|
|
|
|
|
self.reader_class = _config['store']['class']['read']
|
|
|
|
|
self.write_class = _config['store']['class']['write']
|
|
|
|
@ -18,11 +20,6 @@ class Top(multiprocessing.Process):
|
|
|
|
|
|
|
|
|
|
self.name = 'Zulu-Top'
|
|
|
|
|
self.quit = False
|
|
|
|
|
print sys.argv
|
|
|
|
|
sys.argv[0] = self.name
|
|
|
|
|
print sys.argv
|
|
|
|
|
# multiprocessing.current_process().name = 'Zulu-Top'
|
|
|
|
|
self.exit = multiprocessing.Event()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
className = ''.join(['monitor.',_config['monitor']['processes']['class'],'()'])
|
|
|
|
@ -35,24 +32,29 @@ class Top(multiprocessing.Process):
|
|
|
|
|
for label in self.config :
|
|
|
|
|
self.lock.acquire()
|
|
|
|
|
gwriter = self.factory.instance(type=self.write_class,args=self.rw_args)
|
|
|
|
|
for app in self.config[label] :
|
|
|
|
|
self.handler.init(app)
|
|
|
|
|
r = self.handler.composite()
|
|
|
|
|
gwriter.write(label=label,row=r)
|
|
|
|
|
time.sleep(5)
|
|
|
|
|
apps = self.config[label]
|
|
|
|
|
self.handler.init(apps)
|
|
|
|
|
r = self.handler.composite()
|
|
|
|
|
gwriter.write(label=label,row=r)
|
|
|
|
|
time.sleep(5)
|
|
|
|
|
self.lock.release()
|
|
|
|
|
if 'MONITOR_CONFIG_PATH' in os.environ:
|
|
|
|
|
#
|
|
|
|
|
# This suggests we are in development mode
|
|
|
|
|
#
|
|
|
|
|
break
|
|
|
|
|
ELLAPSED_TIME = 60*30
|
|
|
|
|
time.sleep(ELLAPSED_TIME)
|
|
|
|
|
print "Exiting ",self.name
|
|
|
|
|
|
|
|
|
|
class Learner(multiprocessing.Process) :
|
|
|
|
|
class Learner(Thread) :
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
This function expects paltform config (store,learner)
|
|
|
|
|
It will leverage store and learner in order to operate
|
|
|
|
|
"""
|
|
|
|
|
def __init__(self,config,lock):
|
|
|
|
|
multiprocessing.Process.__init__(self)
|
|
|
|
|
Thread.__init__(self)
|
|
|
|
|
self.name='Zulu-Learner'
|
|
|
|
|
self.lock = lock
|
|
|
|
|
self.reader_class = config['store']['class']['read']
|
|
|
|
|