|
|
@ -9,7 +9,7 @@ import requests
|
|
|
|
import pickle
|
|
|
|
import pickle
|
|
|
|
import json
|
|
|
|
import json
|
|
|
|
from threading import Thread, RLock
|
|
|
|
from threading import Thread, RLock
|
|
|
|
ENDPOINT="https://dev.the-phi.com/monitor"
|
|
|
|
ENDPOINT="https://the-phi.com/monitor"
|
|
|
|
class Collector(Thread) :
|
|
|
|
class Collector(Thread) :
|
|
|
|
def __init__(self):
|
|
|
|
def __init__(self):
|
|
|
|
Thread.__init__(self)
|
|
|
|
Thread.__init__(self)
|
|
|
@ -23,13 +23,14 @@ class Collector(Thread) :
|
|
|
|
for id in ['apps','folders']:
|
|
|
|
for id in ['apps','folders']:
|
|
|
|
if id in SYS_ARGS :
|
|
|
|
if id in SYS_ARGS :
|
|
|
|
SYS_ARGS[id] = SYS_ARGS[id].split(',')
|
|
|
|
SYS_ARGS[id] = SYS_ARGS[id].split(',')
|
|
|
|
scope=list(set(['apps','folders','sandbox'])& set(SYS_ARGS.keys()))
|
|
|
|
|
|
|
|
headers = {"key":SYS_ARGS["key"],"id":SYS_ARGS["id"],"scope":json.dumps(scope)}
|
|
|
|
|
|
|
|
|
|
|
|
headers = {"key":SYS_ARGS["key"],"id":SYS_ARGS["id"]} #,"scope":json.dumps(scope)}
|
|
|
|
headers['content-type'] = 'application/json'
|
|
|
|
headers['content-type'] = 'application/json'
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
r = requests.post("https://the-phi.com/monitor/init/collector",headers=headers,data=json.dumps(SYS_ARGS))
|
|
|
|
url = "/".join([ENDPOINT,"init/collector"])
|
|
|
|
|
|
|
|
r = requests.post(url,headers=headers,data=json.dumps(SYS_ARGS))
|
|
|
|
r = json.loads(r.text)
|
|
|
|
r = json.loads(r.text)
|
|
|
|
|
|
|
|
|
|
|
|
self.monitor = pickle.loads(r[0])
|
|
|
|
self.monitor = pickle.loads(r[0])
|
|
|
|
self.monitor.lock = RLock()
|
|
|
|
self.monitor.lock = RLock()
|
|
|
|