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