From 58d904a328c0d849769b483e901a0be9426b8209 Mon Sep 17 00:00:00 2001 From: liuxiaolong <liuxiaolong@aiotlink.com> Date: 星期二, 20 七月 2021 20:20:44 +0800 Subject: [PATCH] 调整Request C.BHFree的位置 --- box/status_main.cc | 19 +++++++++++++++---- 1 files changed, 15 insertions(+), 4 deletions(-) diff --git a/box/status_main.cc b/box/status_main.cc index 3f075fb..159e623 100644 --- a/box/status_main.cc +++ b/box/status_main.cc @@ -31,8 +31,19 @@ int status_main(int argc, char const *argv[]) { - auto &shm = BHomeShm(); + AppArg args(argc, argv); + auto shm_name = args.Get("shm", BHomeShm().name()); + auto shm_size = std::atol(args.Get("size", "").c_str()); + if (shm_size <= 0 || shm_size > 512) { + shm_size = 50; + } + auto DisplayName = [&]() -> std::string { + return shm_name; + }; + SharedMemory shm(shm_name, 1024 * 1024 * shm_size); + shm_size = shm.get_size() / 1024 / 1024; + printf("monitoring shm : %s, size : %ldM\n", DisplayName().c_str(), shm_size); std::atomic<bool> run(true); auto Now = []() { return steady_clock::now(); }; @@ -62,8 +73,8 @@ int nkb = left / Kb; int nb = left - nkb * Kb; char buf[64] = {0}; - int n = sprintf(buf, " %4dMb %4dKb %4dB", nmb, nkb, nb); - int start = (nmb > 0) ? 0 : ((nkb > 0) ? 7 : 14); + int n = sprintf(buf, " %4dM%4dK%4dB", nmb, nkb, nb); + int start = (nmb > 0) ? 0 : ((nkb > 0) ? 5 : 10); buf[start] = sign; return std::string(buf + start); }; @@ -74,7 +85,7 @@ printf("%s", buf); if (new_line) { auto diff = cur - last; - printf(" (%+ld = %s)\n", diff, Pretty(diff).c_str()); + printf(" (%+6ld = %s)\n", diff, Pretty(diff).c_str()); printf("%s", buf); } fflush(stdout); -- Gitblit v1.8.0