DC - updating, the data-collector handler, to work with an endpoint

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

@ -0,0 +1,39 @@
"""
This is a data-collector client, that is intended to perform data-collection operations and submit them to an endpoint
@required:
- key application/service key
- id node identifier
"""
from utils.params import PARAMS as SYS_ARGS
import requests
import pickle
from threading import Thread, RLock
ENDPOINT="https://dev.the-phi.com/monitor"
class Collector(Thread) :
def __init__(self):
Thread.__init__(self)
"""
This function initializes the data collector with critical information
The process will include validating the user's account and plan
@param key customer's key
@param id node identifier
"""
scope=list(set(['apps','folders','sandbox'])& set(SYS_ARGS.keys()))
headers = {"key":SYS_ARGS["key"],"id":SYS_ARGS["id"],"scope":scope}
r = requests.get("https://the-phi.com/monitor/init",headers=headers)
self.pool = pickle.loads(r.text)
def run(self):
for key in self.pool :
try:
p = self.pool[key]
p.init(SYS_ARGS[key])
p.start()
except Exception,e:
print e
if name == '__main__' :
thread = Collector()
thread.start()

@ -7,7 +7,7 @@ if len(sys.argv) > 1:
value = None
if sys.argv[i].startswith('--'):
key = sys.argv[i].replace('-','')
PARAMS[key] = 1
if i + 1 < N:
value = sys.argv[i + 1] = sys.argv[i+1].strip()
if key and value:

Loading…
Cancel
Save