-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: iipeace <[email protected]>
- Loading branch information
Showing
1 changed file
with
37 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
__credits__ = "Peace Lee" | ||
__license__ = "GPLv2" | ||
__version__ = "3.9.8" | ||
__revision__ = "240613" | ||
__revision__ = "240614" | ||
__maintainer__ = "Peace Lee" | ||
__email__ = "[email protected]" | ||
__repository__ = "https://github.com/iipeace/guider" | ||
|
@@ -34317,7 +34317,7 @@ def clearCommCache(): | |
SysMgr.commCache = {} | ||
|
||
@staticmethod | ||
def getComm(pid, cache=False, save=False, commCache=True): | ||
def getComm(pid, cache=False, save=False, commCache=True, default=None): | ||
if commCache and pid in SysMgr.commCache: | ||
return SysMgr.commCache[pid] | ||
|
||
|
@@ -34348,7 +34348,7 @@ def getComm(pid, cache=False, save=False, commCache=True): | |
except: | ||
return None | ||
|
||
comm = None | ||
comm = default | ||
commPath = "%s/%s/comm" % (SysMgr.procPath, pid) | ||
|
||
try: | ||
|
@@ -44512,7 +44512,7 @@ def _checker(): | |
item.encode("latin-1"), | ||
) | ||
if ret < 0: | ||
SysMgr.printErr( | ||
SysMgr.printWarn( | ||
"failed to call fanotify_mark for '%s' because %s" | ||
% (item, SysMgr.getErrReason()) | ||
) | ||
|
@@ -62113,9 +62113,6 @@ def _printSummary(fileSummary={}, procSummary={}, final=False): | |
SysMgr.getAvailMemInfo(), | ||
) | ||
|
||
if not SysMgr.outPath and not SysMgr.streamEnable: | ||
SysMgr.clearScreen() | ||
|
||
if final: | ||
timename = "Runtime" | ||
runtime = SysMgr.getRuntime() | ||
|
@@ -62166,18 +62163,25 @@ def _printSummary(fileSummary={}, procSummary={}, final=False): | |
outStr += "{0:<32} {1:<32} {2:<32}\n{3:1}\n".format( | ||
"File", "Proc", "Attr", twoLine | ||
) | ||
|
||
watchList = SysMgr.fileWatchTotalList | ||
|
||
for path, vals in sorted( | ||
fileSummary.items(), key=lambda e: e[1]["TOTAL"], reverse=True | ||
): | ||
if not path: | ||
continue | ||
|
||
full = path.rsplit("/", 1) | ||
if len(full) == 2: | ||
path = full[0] + "/" + convColor(full[1], "GREEN") | ||
|
||
outStr += path + "\n" | ||
for proc, subvals in vals.items(): | ||
if proc == "TOTAL": | ||
continue | ||
|
||
outStr += "{0:32} {1:32}".format(" ", proc) | ||
outStr += "{0:32} {1:32} ".format(" ", proc) | ||
|
||
# merge events # | ||
evtList = [] | ||
|
@@ -62186,31 +62190,29 @@ def _printSummary(fileSummary={}, procSummary={}, final=False): | |
): | ||
evtList.append( | ||
"%s(%s)" | ||
% (attr, convColor(convNum(cnt), "YELLOW")) | ||
% (attr, convColor(convNum(cnt), "WARNING")) | ||
) | ||
|
||
# check skip condition for event merge # | ||
if final or not isTopMode or not SysMgr.outPath: | ||
continue | ||
|
||
try: | ||
SysMgr.fileWatchTotalList[path]["TOTAL"] += cnt | ||
watchList[path]["TOTAL"] += cnt | ||
except SystemExit: | ||
sys.exit(0) | ||
except: | ||
SysMgr.fileWatchTotalList.setdefault(path, {}) | ||
SysMgr.fileWatchTotalList[path]["TOTAL"] = cnt | ||
watchList.setdefault(path, {}) | ||
watchList[path]["TOTAL"] = cnt | ||
|
||
try: | ||
SysMgr.fileWatchTotalList[path][proc][attr] += cnt | ||
watchList[path][proc][attr] += cnt | ||
except SystemExit: | ||
sys.exit(0) | ||
except: | ||
SysMgr.fileWatchTotalList.setdefault(path, {}) | ||
SysMgr.fileWatchTotalList[path].setdefault( | ||
proc, {} | ||
) | ||
SysMgr.fileWatchTotalList[path][proc][attr] = cnt | ||
watchList.setdefault(path, {}) | ||
watchList[path].setdefault(proc, {}) | ||
watchList[path][proc][attr] = cnt | ||
|
||
evtStr = "|".join(evtList) | ||
outStr += "%s\n" % evtStr | ||
|
@@ -62227,6 +62229,13 @@ def _printSummary(fileSummary={}, procSummary={}, final=False): | |
else: | ||
SysMgr.addProcBuffer(outStr + "\n") | ||
else: | ||
# check user input # | ||
SysMgr.waitUserInput(0.000001, msg="DEFAULT") | ||
|
||
# clear screen # | ||
if not SysMgr.streamEnable: | ||
SysMgr.clearScreen() | ||
|
||
for line in outStr.split("\n"): | ||
if not SysMgr.addPrint(line + "\n"): | ||
break | ||
|
@@ -62243,6 +62252,7 @@ def _printSummary(fileSummary={}, procSummary={}, final=False): | |
fileSummary.clear() | ||
procSummary.clear() | ||
SysMgr.clearPrint() | ||
|
||
return | ||
|
||
outStr = "" | ||
|
@@ -62562,11 +62572,14 @@ def _alarmHandler(signum, frame): | |
# fanotify # | ||
elif len(item) in (4, 6): | ||
epath, events, epid, ecomm = item[:4] | ||
if not ecomm: | ||
ecomm = "?" | ||
|
||
if len(item) == 6: | ||
ppid, pcomm = item[4:6] | ||
else: | ||
ppid = pcomm = None | ||
ppid = SysMgr.getPpid(epid) | ||
pcomm = SysMgr.getComm(ppid) | ||
|
||
# check file condition # | ||
if targetInfo: | ||
|
@@ -62600,7 +62613,11 @@ def _alarmHandler(signum, frame): | |
else: | ||
procInfo = "%s(%s)" % (ecomm, epid) | ||
if ppid: | ||
procInfo += " in %s(%s)" % (pcomm, ppid) | ||
procInfo = "%s(%s)->%s" % ( | ||
pcomm, | ||
ppid, | ||
procInfo, | ||
) | ||
|
||
if top or SysMgr.outPath: | ||
# get event list # | ||
|