Skip to content

Commit

Permalink
ctop: Add NOREP options to remove useless info
Browse files Browse the repository at this point in the history
Signed-off-by: iipeace <[email protected]>
  • Loading branch information
iipeace committed Nov 23, 2023
1 parent 383fa12 commit 656b899
Showing 1 changed file with 25 additions and 17 deletions.
42 changes: 25 additions & 17 deletions guider/guider.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
__credits__ = "Peace Lee"
__license__ = "GPLv2"
__version__ = "3.9.8"
__revision__ = "231122"
__revision__ = "231123"
__maintainer__ = "Peace Lee"
__email__ = "[email protected]"
__repository__ = "https://github.com/iipeace/guider"
Expand Down Expand Up @@ -31062,7 +31062,7 @@ def _checkPerm(item):

# set report table #
SysMgr.reportEnable = True
if SysMgr.findOption("j"):
if SysMgr.findOption("j") and not SysMgr.environList.get("NOPROCRANK"):
SysMgr.rankProcEnable = True
else:
SysMgr.rankProcEnable = False
Expand Down Expand Up @@ -36604,8 +36604,8 @@ def _getDesc(s, t=0):

- {2:1} {3:1} and report in JSON format every interval
# {0:1} {1:1} -j -Q -q TEXTREPORT
# {0:1} {1:1} -j -o /tmp -q TEXTREPORT
# {0:1} {1:1} -C /tmp/guider.conf -j -o /tmp -q TEXTREPORT
# {0:1} {1:1} -j -o /tmp -q TEXTREPORT, NOPROCRANK
# {0:1} {1:1} -j -o /tmp -q TEXTREPORT -C /tmp/guider.conf

- {2:1} {3:1} and report in JSON format with contents of specific files or directories every interval
# {0:1} {1:1} -j -Q -q TEXTREPORT, RECFILE:/tmp/setting1, RECFILE:/tmp/setting2
Expand Down Expand Up @@ -36685,6 +36685,12 @@ def _getDesc(s, t=0):
- {2:1} without socket profiling
# {0:1} {1:1} -q NOSOCKPROF

- {2:1} without specific file report contents
# {0:1} {1:1} -J -q NOSTORAGEREP, NOGPUMEMREP

- {2:1} with optimized options
# {0:1} {1:1} -j /tmp/perf.report -i 3 -o /data -q TEXTREPORT, NOSOCKPROF, LIMITREPDIR:100M, LIMITDIRCNT:/data/mini:1, NOPROCRANK, NOSTORAGEREP, NOGPUMEMREP -b 3M -e dC

See the top COMMAND help for more examples.
""".format(
cmd,
Expand Down Expand Up @@ -137962,18 +137968,14 @@ def _setDefaultInfo(data, pid, comm, runtime=None):
self.reportData["gpumem"] = {"total": total, "procs": procs}

# remove not-mounted storage status #
if "storage" in self.reportData:
for item in list(self.reportData["storage"]):
try:
if (
self.reportData["storage"][item]["mount"]["path"]
== "-"
):
self.reportData["storage"].pop(item, None)
except SystemExit:
sys.exit(0)
except:
pass
for item, val in self.reportData["storage"].items():
try:
if val["mount"]["path"] == "-":
self.reportData["storage"].pop(item, None)
except SystemExit:
sys.exit(0)
except:
pass

# add task status #
if "task" in self.reportData:
Expand Down Expand Up @@ -138070,7 +138072,7 @@ def _setDefaultInfo(data, pid, comm, runtime=None):

# make output path #
filePath = os.path.dirname(SysMgr.inputFile) + "/guider"
for event in list(self.reportData["event"]):
for event in self.reportData["event"]:
filePath = "%s_%s" % (filePath, event)
filePath = "%s_%s.out" % (filePath, str(long(SysMgr.uptime)))

Expand All @@ -138096,6 +138098,12 @@ def _setDefaultInfo(data, pid, comm, runtime=None):
"failed to rename %s to %s" % SysMgr.inputFile, filePath
)

# remove useless info for file report #
if "NOSTORAGEREP" in SysMgr.environList:
self.reportData.pop("storage")
if "NOGPUMEMREP" in SysMgr.environList:
self.reportData.pop("gpumem")

# convert dict data to JSON string #
pretty = not SysMgr.streamEnable
jsonStr = UtilMgr.convDict2Str(
Expand Down

0 comments on commit 656b899

Please sign in to comment.