From 318919094d3f56fd707587679b503aac14151111 Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Wed, 18 Jun 2014 00:00:00 -0500 Subject: [PATCH] top: rearrange Mem & Swap lines and standardize 'used' In anticipation of upcoming memory graphing provisions the abbreviations 'Mem' and 'Swap' are being made into individual translatable strings in order to be reused. Additionally, the Mem 'used' amount will now no longer included the 'buffers' and 'cached' values. Thus, each Mem category becomes unique. This is the approach used by tools such as 'htop' or the gnome 'System Monitor'. Lastly, with that change to the 'used' category it has been repositioned after 'free' on the Mem & Swap lines making a comparison between 'total' and 'free' easier. Signed-off-by: Jim Warner --- top/top.c | 16 ++++++++++------ top/top_nls.c | 13 ++++++++----- top/top_nls.h | 8 ++++---- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/top/top.c b/top/top.c index e86e0dca..0fece2d1 100644 --- a/top/top.c +++ b/top/top.c @@ -5159,6 +5159,7 @@ numa_nope: // and prT macro might replace space at buf[8] with: ------> + char buf[10]; // MEMORY_lines_fmt provides for 8+1 bytes } buftab[8]; + unsigned long kb_main_my_used; if (!scaletab[0].label) { scaletab[0].label = N_txt(AMT_kilobyte_txt); @@ -5168,14 +5169,17 @@ numa_nope: scaletab[4].label = N_txt(AMT_petabyte_txt); scaletab[5].label = N_txt(AMT_exxabyte_txt); } - prT(bfT(0), mkM(total)); prT(bfT(1), mkM(used)); - prT(bfT(2), mkM(free)); prT(bfT(3), mkM(buffers)); - prT(bfT(4), mkS(total)); prT(bfT(5), mkS(used)); - prT(bfT(6), mkS(free)); prT(bfT(7), mkM(cached)); + kb_main_my_used = kb_main_used - kb_main_buffers - kb_main_cached; + + prT(bfT(0), mkM(total)); prT(bfT(1), mkM(free)); + prT(bfT(2), mkM(my_used)); prT(bfT(3), mkM(buffers)); + prT(bfT(4), mkS(total)); prT(bfT(5), mkS(free)); + prT(bfT(6), mkS(used)); prT(bfT(7), mkM(cached)); show_special(0, fmtmk(N_unq(MEMORY_lines_fmt) - , scT(label), bfT(0), bfT(1), bfT(2), bfT(3) - , scT(label), bfT(4), bfT(5), bfT(6), bfT(7))); + , scT(label), N_txt(WORD_abv_mem_txt), bfT(0), bfT(1), bfT(2), bfT(3) + , scT(label), N_txt(WORD_abv_swp_txt), bfT(4), bfT(5), bfT(6), bfT(7) + , N_txt(WORD_abv_mem_txt))); Msg_row += 2; #undef bfT #undef scT diff --git a/top/top_nls.c b/top/top_nls.c index ea1c0887..5ffe72e6 100644 --- a/top/top_nls.c +++ b/top/top_nls.c @@ -464,6 +464,12 @@ static void build_norm_nlstab (void) { Norm_nlstab[NUMA_nodeget_fmt] = _("expand which node (0-%d)"); Norm_nlstab[NUMA_nodebad_txt] = _("invalid node"); Norm_nlstab[NUMA_nodenot_txt] = _("sorry, NUMA extensions unavailable"); +/* Translation Hint: 'Mem ' is an abbreviation for physical memory/ram + ' 'Swap' represents the linux swap file -- + ' please make both translations the same length, + ' using extra spaces as necessary */ + Norm_nlstab[WORD_abv_mem_txt] = _("Mem "); + Norm_nlstab[WORD_abv_swp_txt] = _("Swap"); } @@ -631,12 +637,9 @@ static void build_uniq_nlstab (void) { Uniq_nlstab[STATE_lin2x7_fmt] = _("%%%s~3" "%#5.1f ~2us,~3%#5.1f ~2sy,~3%#5.1f ~2ni,~3%#5.1f ~2id,~3%#5.1f ~2wa,~3%#5.1f ~2hi,~3%#5.1f ~2si,~3%#5.1f ~2st~3\n"); -/* Translation Hint: Only the following need be translated - . abbreviations: Mem = physical memory/ram, Swap = the linux swap file - . words: total, used, free, buffers, cached */ Uniq_nlstab[MEMORY_lines_fmt] = _("" - "%s Mem: ~3 %9.9s~2total,~3 %9.9s~2used,~3 %9.9s~2free,~3 %9.9s~2buffers~3\n" - "%s Swap:~3 %9.9s~2total,~3 %9.9s~2used,~3 %9.9s~2free.~3 %9.9s~2cached Mem~3\n"); + "%s %s:~3 %9.9s~2total,~3 %9.9s~2free,~3 %9.9s~2used,~3 %9.9s~2buffers~3\n" + "%s %s:~3 %9.9s~2total,~3 %9.9s~2free,~3 %9.9s~2used.~3 %9.9s~2cached %s~3\n"); Uniq_nlstab[INSP_hdrsels_fmt] = _("" "Inspection~2 Pause at: pid ~1%d~6 running ~1%s~6 as user ~1%s~6\n" diff --git a/top/top_nls.h b/top/top_nls.h index 9010263e..9d880d17 100644 --- a/top/top_nls.h +++ b/top/top_nls.h @@ -81,10 +81,10 @@ enum norm_nls { OSEL_errvalu_fmt, OSEL_prompts_fmt, OSEL_statlin_fmt, RC_bad_entry_fmt, RC_bad_files_fmt, SCROLL_coord_fmt, SELECT_clash_txt, THREADS_show_fmt, TIME_accumed_fmt, UNKNOWN_cmds_txt, UNKNOWN_opts_fmt, USAGE_abbrev_txt, - WORD_allcpus_txt, WORD_another_txt, WORD_eachcpu_fmt, WORD_exclude_txt, - WORD_include_txt, WORD_noneone_txt, WORD_process_txt, WORD_threads_txt, - WRITE_rcfile_fmt, WRONG_switch_fmt, XTRA_badflds_fmt, XTRA_fixwide_fmt, - XTRA_warncfg_txt, XTRA_winsize_txt, + WORD_abv_mem_txt, WORD_abv_swp_txt, WORD_allcpus_txt, WORD_another_txt, + WORD_eachcpu_fmt, WORD_exclude_txt, WORD_include_txt, WORD_noneone_txt, + WORD_process_txt, WORD_threads_txt, WRITE_rcfile_fmt, WRONG_switch_fmt, + XTRA_badflds_fmt, XTRA_fixwide_fmt, XTRA_warncfg_txt, XTRA_winsize_txt, #ifndef INSP_OFFDEMO YINSP_demo01_txt, YINSP_demo02_txt, YINSP_demo03_txt, YINSP_deqfmt_txt, YINSP_deqtyp_txt, YINSP_dstory_txt,