|
|
|
@ -15,6 +15,7 @@ from threading import Thread
|
|
|
|
|
import os
|
|
|
|
|
import shutil
|
|
|
|
|
import subprocess
|
|
|
|
|
|
|
|
|
|
from monitor import ProcessCounter
|
|
|
|
|
from utils.transport import QueueListener, QueueWriter, QueueReader
|
|
|
|
|
from utils.params import PARAMS
|
|
|
|
@ -39,13 +40,14 @@ class Actor():
|
|
|
|
|
print e
|
|
|
|
|
return o
|
|
|
|
|
def __init__(self):
|
|
|
|
|
pass
|
|
|
|
|
def getIdentifier(self):
|
|
|
|
|
return self.__class__.__name__.lower()
|
|
|
|
|
"""
|
|
|
|
|
Initializing the class with configuration. The configuration will be specific to each subclass
|
|
|
|
|
@param args arguments the class needs to be configured
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
pass
|
|
|
|
|
def getIdentifier(self):
|
|
|
|
|
return self.__class__.__name__.lower()
|
|
|
|
|
def init(self,args):
|
|
|
|
|
self.config = args
|
|
|
|
|
|
|
|
|
@ -57,17 +59,12 @@ class Actor():
|
|
|
|
|
def execute(self,cmd):
|
|
|
|
|
stream = None
|
|
|
|
|
try:
|
|
|
|
|
subprocess.call (cmd,shell=False)
|
|
|
|
|
# subprocess.call (cmd,shell=False)
|
|
|
|
|
out = subprocess.Popen(cmd,stdout=subprocess.PIPE)
|
|
|
|
|
print out
|
|
|
|
|
#stream = handler.communicate()[0]
|
|
|
|
|
except Exception,e:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
# def run(self):
|
|
|
|
|
# if self.item is not None:
|
|
|
|
|
# self.process(self.item)
|
|
|
|
|
"""
|
|
|
|
|
Sending a message to a queue with parameters to,from,content
|
|
|
|
|
"""
|
|
|
|
|
def post(self,**args):
|
|
|
|
|
pass
|
|
|
|
|
class Apps(Actor) :
|
|
|
|
@ -115,9 +112,10 @@ class Apps(Actor) :
|
|
|
|
|
kill processes given the name, The function will not be case sensitive and partial names are accepted
|
|
|
|
|
@NOTE: Make sure the reference to the app is not ambiguous
|
|
|
|
|
"""
|
|
|
|
|
args = "".join(["ps -eo pid,command|grep -E -i ",name.lower(),'|grep -E "^ {0,}[0-9]+" -o -m 1|xargs kill -9'])
|
|
|
|
|
self.execute([args ])
|
|
|
|
|
print args
|
|
|
|
|
args = "".join(['ps -eo pid,command|grep -E -i "',name.lower(),'"|grep -E "^ {0,}[0-9]+" -o|xargs kill -9'])
|
|
|
|
|
#self.execute([args])
|
|
|
|
|
subprocess.call([args],shell=True)
|
|
|
|
|
|
|
|
|
|
def analyze(self,logs) :
|
|
|
|
|
"""
|
|
|
|
|
This function is designed to analyze a few logs and take appropriate action
|
|
|
|
|