bug fix: edge case, no processes

data-collector
Steve L. Nyemba 4 years ago
parent 941578993b
commit de829d7ffe

@ -7,7 +7,7 @@ def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read() return open(os.path.join(os.path.dirname(__file__), fname)).read()
args = { args = {
"name":"smart-top", "name":"smart-top",
"version":"1.0.2", "version":"1.0.4",
"author":"The Phi Technology LLC","author_email":"info@the-phi.com", "author":"The Phi Technology LLC","author_email":"info@the-phi.com",
"license":"MIT", "license":"MIT",
"packages":["smart","smart.top","smart.folder","smart.logger"]} "packages":["smart","smart.top","smart.folder","smart.logger"]}

@ -74,6 +74,7 @@ def read(**args) :
d = datetime.datetime.now().strftime('%m-%d-%Y') d = datetime.datetime.now().strftime('%m-%d-%Y')
t = datetime.datetime.now().strftime('%H:%M:%S') t = datetime.datetime.now().strftime('%H:%M:%S')
n = os.uname()[1]
m = [item for item in m if len(item) != len (m[0])] m = [item for item in m if len(item) != len (m[0])]
m = "\n".join(m[1:]) m = "\n".join(m[1:])
df = pd.read_csv(StringIO(m),sep=xchar) df = pd.read_csv(StringIO(m),sep=xchar)
@ -93,15 +94,17 @@ def read(**args) :
r = pd.DataFrame() r = pd.DataFrame()
for name in names : for name in names :
tmp = df[df.name == name.strip()] tmp = df[df.name == name.strip()]
if tmp.shape[0] : if not tmp.shape[0] :
r = r.append(tmp) tmp = {"pid":None,"user":None,"mem":0,"cpu":0,"status":"-100","started":None,"name":name,"cmd":None,"args":None,"date":d,"time":t,"node":n}
r = r.append(tmp)
df = r df = r
# #
# For security reasons lets has the args columns with an MD5 or sha256 # For security reasons lets has the args columns with an MD5 or sha256
# #
if 'args' in df :
df.args = [hashlib.md5(str(value).encode('utf-8')).hexdigest() for value in df.args.tolist()] df.args = [hashlib.md5(str(value).encode('utf-8')).hexdigest() for value in df.args.tolist()]
STATUS = {'R':'RUNNING','Z':'DEAD','D':'STASIS','S':'SLEEP','Sl':'SLEEP','Ss':'SLEEP','W':'PAGING','T':'DEAD'} STATUS = {'R':'RUNNING','Z':'DEAD','D':'STASIS','S':'SLEEP','Sl':'SLEEP','Ss':'SLEEP','W':'PAGING','T':'DEAD'}
df.status = df.status.apply(lambda value: STATUS.get(value,'UNKNOWN')) df.status = df.status.apply(lambda value: STATUS.get(value,'UNKNOWN'))
if 'cols' in args : if 'cols' in args :

Loading…
Cancel
Save