Bug fix, for got to update new files

data-collector
Steve L. Nyemba 7 years ago
parent 9509c66973
commit a9574f741c

@ -19,7 +19,6 @@ import re
from monitor import ProcessCounter
from utils.transport import QueueListener, QueueWriter, QueueReader
from utils.params import PARAMS
from ngram import NGram as ng
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
@ -80,6 +79,7 @@ class Apps(Actor) :
def isValid(self,**args):
"""
We insure that the provided application exists and that the payload is correct
The class will only respond to reboot,kill,start actions
p validate the payload
q validate the app can be restarted
@ -100,27 +100,11 @@ class Apps(Actor) :
"""
self.action = action
self.params = params
# self.ng = ng(self.config.keys())
# def can_start(self,name):
# """
# This function is intended to determine if it is possible to boot an application
# """
# items = self.ng.search(name) if self.ng is not None else []
# if len(items) == 0 :
# return False
# else:
# return items[0][1] > 0.01
def startup(self,cmd) :
"""
This function is intended to start a program given the configuration
"""
# items = self.ng.search(name)[0]
# app = items[0]
# args = self.config[app]
try:
os.system(cmd +" &")
except Exception, e:
@ -132,36 +116,42 @@ class Apps(Actor) :
@NOTE: Make sure the reference to the app is not ambiguous
"""
try:
args = "".join(['ps -eo pid,command|grep -E -i "',name.lower(),'"|grep -E "^ {0,}[0-9]+" -o|xargs kill -9'])
args = "".join(['ps -eo pid,command|grep -Ei "',name.lower(),'"|grep -E "^ {0,}[0-9]+" -o|xargs kill -9'])
#self.execute([args])
subprocess.call([args],shell=True)
except Exception,e:
print e
def run(self):
__action = str(self.action)
__action = str(self.action).strip()
__params = dict(self.params)
if self.action == 'reboot' :
pointer = None
if __action == 'reboot' :
def pointer():
self.kill(__params['label'])
self.startup(__params['cmd'])
else:
elif __action == 'kill':
def pointer():
self.kill(__params['label'])
elif __action =='start':
def pointer() :
self.startup(__params['cmd'])
print __action,__params
print pointer
pointer()
# thread = Thread(target=pointer)
# thread.start()
if pointer :
thread = Thread(target=pointer)
thread.start()
# pointer()
def analyze(self,logs) :
"""
This function is designed to analyze a few logs and take appropriate action
@param logs logs of application/process data; folder analysis or sandbox analysis
"""
for item in logs :
name = item['label']
if self.can_start(name) :
self.startup(name)
#
pass
# for item in logs :
# name = item['label']
# if self.can_start(name) :
# self.startup(name)
# #
class Mailer (Actor):
@ -297,8 +287,8 @@ class Folders(Actor):
def analyze(self,logs):
r = {'clean':self.clean,'archive':self.archive}
self.lfolders = [ folder['label'] for folder in logs]
for item in logs :
#for item in logs :
if self.can_clean(item) :
self.archive(item)
#self.clean(item)
# if self.can_clean(item) :
# self.archive(item)
# self.clean(item)

@ -13,7 +13,7 @@ from datetime import datetime
from utils.transport import *
import monitor
import requests
from threading import Thread
class Manager() :
def version(self):
return 1.1
@ -44,7 +44,10 @@ class Manager() :
self.qlistener = self.factory.instance(type="QueueListener",args=_args)
self.qlistener.callback = self.callback
self.qlistener.init(self.id)
self.qlistener.read()
# self.qlistener.read()
thread = (Thread(target=self.qlistener.read))
thread.start()
def update(self) :
"""
This method inspect the plans for the current account and makes sure it can/should proceed
@ -190,7 +193,7 @@ class Manager() :
if type(row)==list and len(row) == 0 :
continue
print get.getName(),len(row)
#
#
index = self.agents.index(agent)

Loading…
Cancel
Save