|
|
|
@ -13,7 +13,9 @@ import sys
|
|
|
|
|
import os
|
|
|
|
|
import re
|
|
|
|
|
import time
|
|
|
|
|
import numpy as np
|
|
|
|
|
# df = pd.DataFrame (smart.top.read(name='firefox,code'))
|
|
|
|
|
HOME_FOLDER = os.environ['HOME']
|
|
|
|
|
SYS_ARGS = {}
|
|
|
|
|
if len(sys.argv) > 1:
|
|
|
|
|
|
|
|
|
@ -32,7 +34,7 @@ if len(sys.argv) > 1:
|
|
|
|
|
i += 2
|
|
|
|
|
if __name__ == '__main__' :
|
|
|
|
|
try:
|
|
|
|
|
if 'help' in SYS_ARGS:
|
|
|
|
|
if 'help' in SYS_ARGS :
|
|
|
|
|
print (help_me)
|
|
|
|
|
sys.exit(0)
|
|
|
|
|
if 'watch' in SYS_ARGS :
|
|
|
|
@ -46,15 +48,34 @@ if __name__ == '__main__' :
|
|
|
|
|
print ("================================= SMART TOP ================================= ")
|
|
|
|
|
print ()
|
|
|
|
|
df = pd.DataFrame()
|
|
|
|
|
if 'name' in SYS_ARGS :
|
|
|
|
|
df = df.append(pd.DataFrame(smart.top.read(name=SYS_ARGS['name'])))
|
|
|
|
|
if 'folder' in SYS_ARGS :
|
|
|
|
|
for path in SYS_ARGS['folder'].split(',') :
|
|
|
|
|
df = df.append(smart.folder.read(path=path))
|
|
|
|
|
cols = df.columns.tolist()
|
|
|
|
|
else:
|
|
|
|
|
df = pd.DataFrame(smart.top.read())
|
|
|
|
|
df = smart.top.read()
|
|
|
|
|
cols = ['pid','name','user','cpu','mem','started','date','time','status']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for key in SYS_ARGS :
|
|
|
|
|
value = SYS_ARGS[key]
|
|
|
|
|
|
|
|
|
|
if not value or key not in df.columns:
|
|
|
|
|
continue
|
|
|
|
|
ii = df.apply(lambda row:re.match(value,str(row[key])) is not None,axis=1)
|
|
|
|
|
df = df[ii].copy()
|
|
|
|
|
|
|
|
|
|
df.index = np.arange(df.shape[0])
|
|
|
|
|
|
|
|
|
|
# df = pd.DataFrame(smart.top.read(name='fire'))
|
|
|
|
|
|
|
|
|
|
log = log.append(df)
|
|
|
|
|
|
|
|
|
|
print (df[['pid','name','user','cpu','mem','started','date','time','status']])
|
|
|
|
|
if not df.empty :
|
|
|
|
|
print (df[cols])
|
|
|
|
|
if 'watch' in SYS_ARGS :
|
|
|
|
|
time.sleep(SYS_ARGS['watch'])
|
|
|
|
|
|
|
|
|
|