diff options
Diffstat (limited to 'zen/cmds/top.cpp')
| -rw-r--r-- | zen/cmds/top.cpp | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/zen/cmds/top.cpp b/zen/cmds/top.cpp index b0d684705..3ff7edcda 100644 --- a/zen/cmds/top.cpp +++ b/zen/cmds/top.cpp @@ -3,12 +3,16 @@ #include "top.h" #include <zencore/logging.h> -#include <zenserverprocess.h> +#include <zencore/uid.h> +#include <zencore/fmtutils.h> +#include <zenutil/zenserverprocess.h> #include <memory> ////////////////////////////////////////////////////////////////////////// +namespace zen { + TopCommand::TopCommand() { } @@ -28,7 +32,23 @@ TopCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) return 0; } - State.Snapshot([&](const ZenServerState::ZenServerEntry& Entry) { ZEN_INFO("Port {} : pid {}", Entry.ListenPort, Entry.Pid); }); + int n = 0; + const int HeaderPeriod = 20; + + for (;;) + { + if ((n++ % HeaderPeriod) == 0) + { + ZEN_CONSOLE("{:>5} {:>6} {:>24}", "port", "pid", "session"); + } + + State.Snapshot([&](const ZenServerState::ZenServerEntry& Entry) { ZEN_CONSOLE("{:5} {:6} {:24}", Entry.ListenPort, Entry.Pid, Entry.GetSessionId()); }); + + zen::Sleep(1000); + + State.Sweep(); + } + return 0; } @@ -58,3 +78,5 @@ PsCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) return 0; } + +} |