Bug fix with monitoring

master
Steve L. Nyemba 8 years ago
parent 63a65a5b08
commit a1acc24da4

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

Loading…
Cancel
Save