diff --git a/setup.py b/setup.py index ae3abf7..c794e24 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ def read(fname): return open(os.path.join(os.path.dirname(__file__), fname)).read() args = { "name":"smart-top", - "version":"1.0.2", + "version":"1.0.4", "author":"The Phi Technology LLC","author_email":"info@the-phi.com", "license":"MIT", "packages":["smart","smart.top","smart.folder","smart.logger"]} diff --git a/smart/top/__init__.py b/smart/top/__init__.py index b00eddd..521b566 100644 --- a/smart/top/__init__.py +++ b/smart/top/__init__.py @@ -74,6 +74,7 @@ def read(**args) : d = datetime.datetime.now().strftime('%m-%d-%Y') 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 = "\n".join(m[1:]) df = pd.read_csv(StringIO(m),sep=xchar) @@ -93,15 +94,17 @@ def read(**args) : r = pd.DataFrame() for name in names : tmp = df[df.name == name.strip()] - if tmp.shape[0] : - r = r.append(tmp) + if not tmp.shape[0] : + 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 # # For security reasons lets has the args columns with an MD5 or sha256 # - - df.args = [hashlib.md5(str(value).encode('utf-8')).hexdigest() for value in df.args.tolist()] + if 'args' in df : + 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'} df.status = df.status.apply(lambda value: STATUS.get(value,'UNKNOWN')) if 'cols' in args :