|
|
@ -15,6 +15,7 @@ from threading import Thread
|
|
|
|
import os
|
|
|
|
import os
|
|
|
|
import shutil
|
|
|
|
import shutil
|
|
|
|
import subprocess
|
|
|
|
import subprocess
|
|
|
|
|
|
|
|
|
|
|
|
from monitor import ProcessCounter
|
|
|
|
from monitor import ProcessCounter
|
|
|
|
from utils.transport import QueueListener, QueueWriter, QueueReader
|
|
|
|
from utils.transport import QueueListener, QueueWriter, QueueReader
|
|
|
|
from utils.params import PARAMS
|
|
|
|
from utils.params import PARAMS
|
|
|
@ -39,13 +40,14 @@ class Actor():
|
|
|
|
print e
|
|
|
|
print e
|
|
|
|
return o
|
|
|
|
return o
|
|
|
|
def __init__(self):
|
|
|
|
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
|
|
|
|
Initializing the class with configuration. The configuration will be specific to each subclass
|
|
|
|
@param args arguments the class needs to be configured
|
|
|
|
@param args arguments the class needs to be configured
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
def getIdentifier(self):
|
|
|
|
|
|
|
|
return self.__class__.__name__.lower()
|
|
|
|
def init(self,args):
|
|
|
|
def init(self,args):
|
|
|
|
self.config = args
|
|
|
|
self.config = args
|
|
|
|
|
|
|
|
|
|
|
@ -57,17 +59,12 @@ class Actor():
|
|
|
|
def execute(self,cmd):
|
|
|
|
def execute(self,cmd):
|
|
|
|
stream = None
|
|
|
|
stream = None
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
subprocess.call (cmd,shell=False)
|
|
|
|
# subprocess.call (cmd,shell=False)
|
|
|
|
|
|
|
|
out = subprocess.Popen(cmd,stdout=subprocess.PIPE)
|
|
|
|
|
|
|
|
print out
|
|
|
|
#stream = handler.communicate()[0]
|
|
|
|
#stream = handler.communicate()[0]
|
|
|
|
except Exception,e:
|
|
|
|
except Exception,e:
|
|
|
|
pass
|
|
|
|
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):
|
|
|
|
def post(self,**args):
|
|
|
|
pass
|
|
|
|
pass
|
|
|
|
class Apps(Actor) :
|
|
|
|
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
|
|
|
|
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
|
|
|
|
@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'])
|
|
|
|
args = "".join(['ps -eo pid,command|grep -E -i "',name.lower(),'"|grep -E "^ {0,}[0-9]+" -o|xargs kill -9'])
|
|
|
|
self.execute([args ])
|
|
|
|
#self.execute([args])
|
|
|
|
print args
|
|
|
|
subprocess.call([args],shell=True)
|
|
|
|
|
|
|
|
|
|
|
|
def analyze(self,logs) :
|
|
|
|
def analyze(self,logs) :
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
This function is designed to analyze a few logs and take appropriate action
|
|
|
|
This function is designed to analyze a few logs and take appropriate action
|
|
|
|