DC - working with remote object,configured on the basis of the plan

data-collector
Steve L. Nyemba 7 years ago
parent a8e6d23b64
commit 2e642bc848

@ -1,20 +1,26 @@
aniso8601==1.2.0 aniso8601==1.2.0
certifi==2017.7.27.1
chardet==3.0.4
click==6.6 click==6.6
couchdbkit==0.6.5 couchdbkit==0.6.5
Flask==0.11.1 Flask==0.11.1
Flask-Session==0.3.0 Flask-Session==0.3.0
Flask-SocketIO==2.8.2 Flask-SocketIO==2.8.2
http-parser==0.8.3 http-parser==0.8.3
idna==2.5
itsdangerous==0.24 itsdangerous==0.24
Jinja2==2.8 Jinja2==2.8
MarkupSafe==0.23 MarkupSafe==0.23
ngram==3.3.0
numpy==1.11.3 numpy==1.11.3
pika==0.10.0 pika==0.10.0
python-dateutil==2.6.0 python-dateutil==2.6.0
python-engineio==1.1.0 python-engineio==1.1.0
python-socketio==1.6.2 python-socketio==1.6.2
pytz==2016.10 pytz==2016.10
requests==2.18.3
restkit==4.2.2 restkit==4.2.2
six==1.10.0 six==1.10.0
socketpool==0.5.3 socketpool==0.5.3
urllib3==1.22
Werkzeug==0.11.11 Werkzeug==0.11.11

@ -7,9 +7,9 @@
from utils.params import PARAMS as SYS_ARGS from utils.params import PARAMS as SYS_ARGS
import requests import requests
import pickle import pickle
import json
from threading import Thread, RLock from threading import Thread, RLock
ENDPOINT="https://dev.the-phi.com/monitor" ENDPOINT="https://dev.the-phi.com/monitor"
class Collector(Thread) : class Collector(Thread) :
def __init__(self): def __init__(self):
Thread.__init__(self) Thread.__init__(self)
@ -20,20 +20,44 @@ class Collector(Thread) :
@param id node identifier @param id node identifier
""" """
for id in ['apps','folders']:
if id in SYS_ARGS :
SYS_ARGS[id] = SYS_ARGS[id].split(',')
scope=list(set(['apps','folders','sandbox'])& set(SYS_ARGS.keys())) scope=list(set(['apps','folders','sandbox'])& set(SYS_ARGS.keys()))
headers = {"key":SYS_ARGS["key"],"id":SYS_ARGS["id"],"scope":scope} headers = {"key":SYS_ARGS["key"],"id":SYS_ARGS["id"],"scope":json.dumps(scope)}
r = requests.get("https://the-phi.com/monitor/init",headers=headers) headers['content-type'] = 'application/json'
self.pool = pickle.loads(r.text)
def run(self):
for key in self.pool :
try: try:
p = self.pool[key] r = requests.post("https://the-phi.com/monitor/init/collector",headers=headers,data=json.dumps(SYS_ARGS))
p.init(SYS_ARGS[key])
p.start() r = json.loads(r.text)
self.monitor = pickle.loads(r[0])
self.monitor.lock = RLock()
#:w
#self.monitor.set('lock',RLock())
except Exception,e: except Exception,e:
print e print e.message
self.monitor = None
def run(self):
"""
This funtion runs the authorized features and
"""
#self.monitor.start()
thread = Thread(target=self.monitor.run)
thread.start()
# print self.monitor.config['store']
# for agent in self.pool :
# try:
# agent = pickle.loads(agent)
# agent.start()
# #p = pickle.loads(self.pool[key])
# #p.init(SYS_ARGS[key].split(','))
# #p.start()
# except Exception,e:
# print e
if name == '__main__' : if __name__ == '__main__' :
thread = Collector() thread = Collector()
thread.start() thread.start()

Binary file not shown.

Binary file not shown.
Loading…
Cancel
Save