From fbabaed6991d7e8383e1020a4b47a886f6ca657c Mon Sep 17 00:00:00 2001 From: iipeace Date: Wed, 3 Jan 2024 00:45:34 +0900 Subject: [PATCH] top: Support per-node file report for remote monitoring Signed-off-by: iipeace --- guider/guider.py | 49 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 11 deletions(-) diff --git a/guider/guider.py b/guider/guider.py index b329beab..076ed88f 100755 --- a/guider/guider.py +++ b/guider/guider.py @@ -7,7 +7,7 @@ __credits__ = "Peace Lee" __license__ = "GPLv2" __version__ = "3.9.8" -__revision__ = "240101" +__revision__ = "240102" __maintainer__ = "Peace Lee" __email__ = "iipeace5@gmail.com" __repository__ = "https://github.com/iipeace/guider" @@ -34798,9 +34798,12 @@ def printHelp(force=False, isExit=True): # {0:1} {1:1} -e r -N PRINT@192.168.0.5:5555, PRINT@192.168.0.6:5555 # {0:1} {1:1} -e r -N REPORT@192.168.0.5:5555, REPORT@192.168.0.6:5555 - - Print monitoring data from remote server with host name filter + - Print monitoring data from remote servers with host name filter # {0:1} {1:1} -x 5555 -X -q HOSTFILTER:"*LINUX*" + - Save monitoring data from remote servers into a specific file + # {0:1} {1:1} -x 5555 -X -o . + - {3:1} {2:1} with sending signals to specific {2:1} # {0:1} {1:1} -k a.out:SIGKILL # {0:1} {1:1} -k a.out:SIGKILL:CONT @@ -45298,6 +45301,31 @@ def stopHandler(signum=None, frame=None): if SysMgr.pipeEnable: SysMgr.reloadFileBuffer() + # init summary variables # + current = True + + # handle reports based on remote monitoring data # + for n, v in SysMgr.hostList.items(): + buf = v["buffer"] + if not buf: + continue + + # create a summarizing process # + pid = SysMgr.createProcess() + if pid > 0: + continue + + # init environments # + current = False + SysMgr.procBuffer = buf + SysMgr.addEnvironVar("NOHEADER") + SysMgr.fileSuffix = "%s_%s_%s" % ( + v["hostname"], + n, + SysMgr.pid, + ) + break + SysMgr.printLogo(absolute=True, big=True) # save system info # @@ -45311,7 +45339,7 @@ def stopHandler(signum=None, frame=None): TaskAnalyzer.printFileInterval() SysMgr.printProcBuffer() else: - TaskAnalyzer.printIntervalUsage() + TaskAnalyzer.printIntervalUsage(current=current) # print output of last commands # if "PRINTCMD" in SysMgr.environList: @@ -135775,16 +135803,19 @@ def handleServerResponse(self, packet): return # save host data # - if hostaddr in SysMgr.hostList: - SysMgr.hostList[hostaddr]["hostname"] = hostname - else: + if not hostaddr in SysMgr.hostList: SysMgr.hostList[hostaddr] = { "hostname": hostname, "surface": "", + "buffer": [], } # save screen data # - SysMgr.hostList[hostaddr]["surface"] = data.rstrip().split("\n") + host = SysMgr.hostList[hostaddr] + host["hostname"] = hostname + host["surface"] = data.rstrip().split("\n") + if SysMgr.outPath: + host["buffer"].insert(0, UtilMgr.removeColor(data)) # init screen vars # nrLine = 0 @@ -135819,10 +135850,6 @@ def handleServerResponse(self, packet): fullSurface += "\n".join(window) + "\n\n" nrSurface += 1 - - # handle per-node output file # - if SysMgr.outPath: - pass except SystemExit: sys.exit(0) except KeyboardInterrupt: