-
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
105 additions
and
78 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__ = "230928" | ||
__revision__ = "231001" | ||
__maintainer__ = "Peace Lee" | ||
__email__ = "[email protected]" | ||
__repository__ = "https://github.com/iipeace/guider" | ||
|
@@ -11026,14 +11026,12 @@ def __init__(self): | |
self.TICKS = 100 | ||
|
||
# set item filter # | ||
if "FILTER" in SysMgr.environList: | ||
self.FILTER = SysMgr.environList["FILTER"] | ||
self.FILTER = SysMgr.environList.get("FILTER", []) | ||
if self.FILTER: | ||
SysMgr.printInfo( | ||
"only specific items [ %s ] are drawn" | ||
% ", ".join(self.FILTER) | ||
) | ||
else: | ||
self.FILTER = [] | ||
|
||
# set label filter # | ||
if "LABELMIN" in SysMgr.environList: | ||
|
@@ -22070,7 +22068,6 @@ def __init__(self): | |
|
||
# set specific file # | ||
targetFiles = [] | ||
targetFilter = [] | ||
|
||
# convert target path to abspath # | ||
for item in SysMgr.customCmd: | ||
|
@@ -22109,8 +22106,7 @@ def __init__(self): | |
targetFiles = set(targetFiles) | ||
|
||
# add file filters # | ||
if "TARGETFILE" in SysMgr.environList: | ||
targetFilter = SysMgr.environList["TARGETFILE"] | ||
targetFilter = SysMgr.environList.get("TARGETFILE") | ||
|
||
# handle no target case # | ||
if SysMgr.filterGroup: | ||
|
@@ -34251,13 +34247,13 @@ def printHelp(force=False, isExit=True): | |
# {0:1} {1:1} {3:1} -q NOTIMEFORMAT | ||
|
||
- {2:1} with task life events for perf graph | ||
# {0:1} {1:1} {3:1} -q DRAWLIFE, LFONTSIZE:2 | ||
# {0:1} {1:1} {3:1} -q LIFEEVENT, LFONTSIZE:2 | ||
|
||
- {2:1} with specific task life events for perf graph | ||
# {0:1} {1:1} {3:1} -q DRAWLIFE, INEVENT:"*system*", INEVENT:"*cat*" | ||
# {0:1} {1:1} {3:1} -q LIFEEVENT, INEVENT:"*system*", INEVENT:"*cat*" | ||
|
||
- {2:1} with task life events except for specific ones for perf graph | ||
# {0:1} {1:1} {3:1} -q DRAWLIFE, EXEVENT:"*arp*", EXEVENT:"*pkill*" | ||
# {0:1} {1:1} {3:1} -q LIFEEVENT, EXEVENT:"*arp*", EXEVENT:"*pkill*" | ||
|
||
- {2:1} in us time-unit for timeline segments | ||
# {0:1} {1:1} {3:1} -q TIMEUNIT:us | ||
|
@@ -44329,6 +44325,10 @@ def stopHandler(signum=None, frame=None): | |
|
||
# submit summary report and details # | ||
if "NOINTSUMMARY" in SysMgr.environList: | ||
if "PRINTEVENTHIST" in SysMgr.environList: | ||
TaskAnalyzer.printEventInterval() | ||
if "PRINTFILEHIST" in SysMgr.environList: | ||
TaskAnalyzer.printFileInterval() | ||
SysMgr.printProcBuffer() | ||
else: | ||
TaskAnalyzer.printIntervalUsage() | ||
|
@@ -105788,6 +105788,7 @@ def getStatsFile( | |
chartStats = {} | ||
timeline = [] | ||
eventList = [] | ||
eventData = [] | ||
|
||
cpuUsage = [] | ||
nrCore = [] | ||
|
@@ -105863,11 +105864,15 @@ def getStatsFile( | |
totalRam = None | ||
startTime = 0 | ||
|
||
# get cgroup flags # | ||
nocgcpu = "NOCGCPU" in SysMgr.environList | ||
nocgthrottle = "NOCGTHROTTLE" in SysMgr.environList | ||
nocgmem = "NOCGMEM" in SysMgr.environList | ||
nocgblk = "NOCGBLK" in SysMgr.environList | ||
# get env flags # | ||
envList = SysMgr.environList | ||
nocgcpu = "NOCGCPU" in envList | ||
nocgthrottle = "NOCGTHROTTLE" in envList | ||
nocgmem = "NOCGMEM" in envList | ||
nocgblk = "NOCGBLK" in envList | ||
norecfile = "NORECFILE" in envList | ||
recfileFilter = envList.get("RECFILEFILTER") | ||
lifeEvent = "LIFEEVENT" in SysMgr.environList | ||
|
||
convSize = UtilMgr.convUnit2Size | ||
|
||
|
@@ -106513,21 +106518,17 @@ def getStatsFile( | |
continue | ||
|
||
try: | ||
time = long(float(sline[0])) | ||
ltime = long(float(sline[0])) | ||
utime = float(sline[1]) | ||
dtime = float(sline[2]) | ||
event = sline[3].strip() | ||
|
||
idx = timeline.index(time) | ||
eventList[idx].append( | ||
"%s [%.3f / +%.2fs]" % (event, utime, dtime) | ||
) | ||
eventData.append([ltime, utime, dtime, event]) | ||
except: | ||
pass | ||
|
||
# File # | ||
elif context == "File": | ||
if "NORECFILE" in SysMgr.environList: | ||
if norecfile: | ||
continue | ||
elif slen != 2: | ||
if line.startswith("[Top File"): | ||
|
@@ -106536,11 +106537,8 @@ def getStatsFile( | |
continue | ||
path = UtilMgr.lstrip(item, "Path: ").strip(")") | ||
continue | ||
elif ( | ||
"RECFILEFILTER" in SysMgr.environList | ||
and not UtilMgr.isValidStr( | ||
path, SysMgr.environList["RECFILEFILTER"] | ||
) | ||
elif recfileFilter and not UtilMgr.isValidStr( | ||
path, recfileFilter | ||
): | ||
continue | ||
|
||
|
@@ -106566,7 +106564,7 @@ def getStatsFile( | |
if slen != 8: | ||
continue | ||
|
||
if not "DRAWLIFE" in SysMgr.environList: | ||
if not lifeEvent: | ||
continue | ||
|
||
try: | ||
|
@@ -106590,6 +106588,17 @@ def getStatsFile( | |
except: | ||
pass | ||
|
||
# set event timeline # | ||
try: | ||
for evt in eventData: | ||
ltime, utime, dtime, event = evt | ||
idx = timeline.index(ltime) | ||
eventList[idx].append( | ||
"%s [%.3f / +%.2fs]" % (event, utime, dtime) | ||
) | ||
except: | ||
pass | ||
|
||
if curSize: | ||
UtilMgr.deleteProgress() | ||
|
||
|
@@ -106615,7 +106624,7 @@ def getStatsFile( | |
SysMgr.printWarn("failed to parse sysinfo", True, True) | ||
|
||
# get indexes for trim # | ||
if {"TRIM", "TRIMIDX"} & set(SysMgr.environList): | ||
if {"TRIM", "TRIMIDX"} & set(envList): | ||
imin, imax = SysMgr.getTrimVals(timeline) | ||
|
||
# trim intervals # | ||
|
@@ -134027,21 +134036,21 @@ def handleSaveCmd(self, cmd, event, form=None): | |
# disable report # | ||
SysMgr.reportEnable = False | ||
|
||
def _setMinRep(): | ||
SysMgr.logoEnable = False | ||
SysMgr.addEnvironVar("NOHEADER") | ||
SysMgr.addEnvironVar("NOINTSUMMARY") | ||
|
||
# disable interval summary # | ||
if form == "SAVERAW": | ||
SysMgr.addEnvironVar("NOINTSUMMARY") | ||
SysMgr.addEnvironVar("PRINTEVENTHIST") | ||
elif form == "SAVEMIN": | ||
SysMgr.logoEnable = False | ||
SysMgr.addEnvironVar("NOHEADER") | ||
SysMgr.addEnvironVar("NOINTSUMMARY") | ||
_setMinRep() | ||
elif form in ConfigMgr.RESSET: | ||
# clear buffer # | ||
SysMgr.clearPrint() | ||
SysMgr.clearProcBuffer() | ||
|
||
SysMgr.logoEnable = False | ||
SysMgr.addEnvironVar("NOHEADER") | ||
SysMgr.addEnvironVar("NOINTSUMMARY") | ||
_setMinRep() | ||
else: | ||
SysMgr.closePrintFd() | ||
|
||
|
@@ -135143,6 +135152,7 @@ def setThresholdEvent( | |
|
||
# set event name # | ||
ename = "%s_%s_%s" % (event, attr, item) | ||
eventList = [] | ||
|
||
# add task info # | ||
if addval: | ||
|
@@ -135188,6 +135198,7 @@ def setThresholdEvent( | |
), | ||
True, | ||
) | ||
eventList.append("EVENT_GONESHOT_%s" % event) | ||
# update apply flag for oneshot # | ||
elif oneshot: | ||
# define function for checking resources # | ||
|
@@ -135215,6 +135226,8 @@ def _checkResource(item): | |
if "apply" in comval: | ||
comval["apply"] = "false" | ||
|
||
eventList.append("EVENT_ONESHOT_%s" % event) | ||
|
||
# update threshold items # | ||
if refresh: | ||
SysMgr.thrRefreshList.append([refresh, ename, comval]) | ||
|
@@ -135274,6 +135287,20 @@ def _checkResource(item): | |
% (UtilMgr.convNum(skip), ename), | ||
True, | ||
) | ||
eventList.append("EVENT_SKIP_%s_TICK" % skip) | ||
|
||
# send events # | ||
try: | ||
SysMgr.sendEvents( | ||
SysMgr.localServObj.ip, | ||
SysMgr.localServObj.port, | ||
eventList, | ||
pid=SysMgr.pid, | ||
) | ||
except SystemExit: | ||
sys.exit(0) | ||
except: | ||
pass | ||
|
||
# handle oneshot command # | ||
if goneshot: | ||
|
@@ -136593,61 +136620,61 @@ def _searchTask(self, termCond, taskList, msg): | |
sys.exit(0) | ||
|
||
# terminated tasks # | ||
if "EXITCONDTERM" in SysMgr.environList: | ||
termCond = SysMgr.environList["EXITCONDTERM"] | ||
termCond = SysMgr.environList.get("EXITCONDTERM") | ||
if termCond: | ||
taskList = set(self.prevProcData) - set(self.procData) | ||
msg = "terminated" | ||
_searchTask(self, termCond, taskList, msg) | ||
|
||
# new tasks # | ||
if "EXITCONDNEW" in SysMgr.environList: | ||
termCond = SysMgr.environList["EXITCONDNEW"] | ||
termCond = SysMgr.environList.get("EXITCONDNEW") | ||
if termCond: | ||
taskList = set(self.procData) - set(self.prevProcData) | ||
msg = "executed" | ||
_searchTask(self, termCond, taskList, msg) | ||
|
||
# new files # | ||
if "EXITCONDFILE" in SysMgr.environList: | ||
for fpath in SysMgr.environList["EXITCONDFILE"]: | ||
fpath = SysMgr.convFullPath(fpath) | ||
if os.path.isfile(fpath): | ||
SysMgr.printInfo("'%s' is found" % fpath) | ||
sys.exit(0) | ||
termCond = SysMgr.environList.get("EXITCONDFILE", []) | ||
for fpath in termCond: | ||
fpath = SysMgr.convFullPath(fpath) | ||
if os.path.isfile(fpath): | ||
SysMgr.printInfo("'%s' is found" % fpath) | ||
sys.exit(0) | ||
|
||
# removed files # | ||
if "EXITCONDNOFILE" in SysMgr.environList: | ||
for fpath in SysMgr.environList["EXITCONDNOFILE"]: | ||
fpath = SysMgr.convFullPath(fpath) | ||
if not os.path.isfile(fpath): | ||
SysMgr.printInfo("no '%s'" % fpath) | ||
sys.exit(0) | ||
termCond = SysMgr.environList.get("EXITCONDNOFILE", []) | ||
for fpath in termCond: | ||
fpath = SysMgr.convFullPath(fpath) | ||
if not os.path.isfile(fpath): | ||
SysMgr.printInfo("no '%s'" % fpath) | ||
sys.exit(0) | ||
|
||
# check functions # | ||
if "EXITCONDFUNC" in SysMgr.environList: | ||
for item in SysMgr.environList["EXITCONDFUNC"]: | ||
# get function info # | ||
try: | ||
values = item.split(":") | ||
path, func = values[:2] | ||
if len(values) > 2: | ||
args = values[2:] | ||
else: | ||
args = [] | ||
except SystemExit: | ||
sys.exit(0) | ||
except: | ||
SysMgr.printErr( | ||
"failed to parse function info from '%s'" % item, True | ||
) | ||
sys.exit(0) | ||
termCond = SysMgr.environList.get("EXITCONDFUNC", []) | ||
for item in termCond: | ||
# get function info # | ||
try: | ||
values = item.split(":") | ||
path, func = values[:2] | ||
if len(values) > 2: | ||
args = values[2:] | ||
else: | ||
args = [] | ||
except SystemExit: | ||
sys.exit(0) | ||
except: | ||
SysMgr.printErr( | ||
"failed to parse function info from '%s'" % item, True | ||
) | ||
sys.exit(0) | ||
|
||
# call function # | ||
ret = UtilMgr.callPyFunc(path, func, args) | ||
if ret: | ||
SysMgr.printInfo( | ||
"%s(%s) in %s returned %s" % (func, args, path, ret) | ||
) | ||
sys.exit(0) | ||
# call function # | ||
ret = UtilMgr.callPyFunc(path, func, args) | ||
if ret: | ||
SysMgr.printInfo( | ||
"%s(%s) in %s returned %s" % (func, args, path, ret) | ||
) | ||
sys.exit(0) | ||
|
||
def printSystemStat(self, idIndex=False, targetList=["task"]): | ||
title = "[Top Info]" | ||
|