top: expand this program to include namespaces support

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner
2013-11-11 00:00:00 -06:00
committed by Craig Small
parent 583cdaca1a
commit 2aa0951d1b
3 changed files with 49 additions and 2 deletions

View File

@ -254,6 +254,12 @@ SCB_NUM1(FV2, min_delta)
SCB_NUMx(GID, egid) SCB_NUMx(GID, egid)
SCB_STRS(GRP, egroup) SCB_STRS(GRP, egroup)
SCB_NUMx(NCE, nice) SCB_NUMx(NCE, nice)
SCB_NUM1(NS1, ns[IPCNS])
SCB_NUM1(NS2, ns[MNTNS])
SCB_NUM1(NS3, ns[NETNS])
SCB_NUM1(NS4, ns[PIDNS])
SCB_NUM1(NS5, ns[USERNS])
SCB_NUM1(NS6, ns[UTSNS])
#ifdef OOMEM_ENABLE #ifdef OOMEM_ENABLE
SCB_NUM1(OOA, oom_adj) SCB_NUM1(OOA, oom_adj)
SCB_NUM1(OOM, oom_score) SCB_NUM1(OOM, oom_score)
@ -1645,6 +1651,7 @@ end_justifies:
#define L_EGROUP PROC_FILLSTATUS | PROC_FILLGRP #define L_EGROUP PROC_FILLSTATUS | PROC_FILLGRP
#define L_SUPGRP PROC_FILLSTATUS | PROC_FILLSUPGRP #define L_SUPGRP PROC_FILLSTATUS | PROC_FILLSUPGRP
#define L_USED PROC_FILLSTATUS | PROC_FILLMEM #define L_USED PROC_FILLSTATUS | PROC_FILLMEM
#define L_NS PROC_FILLNS
// make 'none' non-zero (used to be important to Frames_libflags) // make 'none' non-zero (used to be important to Frames_libflags)
#define L_NONE PROC_SPARE_1 #define L_NONE PROC_SPARE_1
// from either 'stat' or 'status' (preferred), via bits not otherwise used // from either 'stat' or 'status' (preferred), via bits not otherwise used
@ -1735,10 +1742,16 @@ static FLD_t Fieldstab[] = {
{ 3, -1, A_right, SF(FV1), L_stat }, { 3, -1, A_right, SF(FV1), L_stat },
{ 3, -1, A_right, SF(FV2), L_stat }, { 3, -1, A_right, SF(FV2), L_stat },
#ifndef NOBOOST_MEMS #ifndef NOBOOST_MEMS
{ 6, SK_Kb, A_right, SF(USE), L_USED } { 6, SK_Kb, A_right, SF(USE), L_USED },
#else #else
{ 4, SK_Kb, A_right, SF(USE), L_USED } { 4, SK_Kb, A_right, SF(USE), L_USED },
#endif #endif
{ 10, -1, A_right, SF(NS1), L_NS }, // IPCNS
{ 10, -1, A_right, SF(NS2), L_NS }, // MNTNS
{ 10, -1, A_right, SF(NS3), L_NS }, // NETNS
{ 10, -1, A_right, SF(NS4), L_NS }, // PIDNS
{ 10, -1, A_right, SF(NS5), L_NS }, // USERNS
{ 10, -1, A_right, SF(NS6), L_NS } // UTSNS
#undef SF #undef SF
#undef A_left #undef A_left
#undef A_right #undef A_right
@ -2261,6 +2274,7 @@ static void zap_fieldstab (void) {
/* and accommodate optional wider non-scalable columns (maybe) */ /* and accommodate optional wider non-scalable columns (maybe) */
if (!AUTOX_MODE) { if (!AUTOX_MODE) {
int i;
Fieldstab[P_UED].width = Fieldstab[P_URD].width Fieldstab[P_UED].width = Fieldstab[P_URD].width
= Fieldstab[P_USD].width = Fieldstab[P_GID].width = Fieldstab[P_USD].width = Fieldstab[P_GID].width
= Rc.fixed_widest ? 5 + Rc.fixed_widest : 5; = Rc.fixed_widest ? 5 + Rc.fixed_widest : 5;
@ -2271,6 +2285,9 @@ static void zap_fieldstab (void) {
= Rc.fixed_widest ? 8 + Rc.fixed_widest : 8; = Rc.fixed_widest ? 8 + Rc.fixed_widest : 8;
Fieldstab[P_WCH].width Fieldstab[P_WCH].width
= Rc.fixed_widest ? 10 + Rc.fixed_widest : 10; = Rc.fixed_widest ? 10 + Rc.fixed_widest : 10;
for (i = P_NS1; i < P_NS1 + NUM_NS; i++)
Fieldstab[i].width
= Rc.fixed_widest ? 10 + Rc.fixed_widest : 10;
} }
/* plus user selectable scaling */ /* plus user selectable scaling */
@ -5227,6 +5244,17 @@ static const char *task_show (const WIN_t *q, const proc_t *p) {
case P_MEM: case P_MEM:
cp = scale_pcnt((float)pages2K(p->resident) * 100 / kb_main_total, W, Jn); cp = scale_pcnt((float)pages2K(p->resident) * 100 / kb_main_total, W, Jn);
break; break;
case P_NS1: // IPCNS
case P_NS2: // MNTNS
case P_NS3: // NETNS
case P_NS4: // PIDNS
case P_NS5: // USERNS
case P_NS6: // UTSNS
{ long ino = p->ns[i - P_NS1];
if (ino > 0) cp = make_num(ino, W, Jn, i);
else cp = make_str("-", W, Js, i);
}
break;
case P_NCE: case P_NCE:
cp = make_num(p->nice, W, Jn, AUTOX_NO); cp = make_num(p->nice, W, Jn, AUTOX_NO);
break; break;

View File

@ -194,6 +194,7 @@ enum pflag {
P_ENV, P_ENV,
P_FV1, P_FV2, P_FV1, P_FV2,
P_USE, P_USE,
P_NS1, P_NS2, P_NS3, P_NS4, P_NS5, P_NS6,
#ifdef USE_X_COLHDR #ifdef USE_X_COLHDR
// not really pflags, used with tbl indexing // not really pflags, used with tbl indexing
P_MAXPFLGS P_MAXPFLGS

View File

@ -259,6 +259,24 @@ static void build_two_nlstabs (void) {
/* Translation Hint: maximum 'USED' = 4 */ /* Translation Hint: maximum 'USED' = 4 */
Head_nlstab[P_USE] = _("USED"); Head_nlstab[P_USE] = _("USED");
Desc_nlstab[P_USE] = _("Res+Swap Size (KiB)"); Desc_nlstab[P_USE] = _("Res+Swap Size (KiB)");
/* Translation Hint: maximum 'nsIPC' = 10 */
Head_nlstab[P_NS1] = _("nsIPC");
Desc_nlstab[P_NS1] = _("IPC namespace Inode");
/* Translation Hint: maximum 'nsMNT' = 10 */
Head_nlstab[P_NS2] = _("nsMNT");
Desc_nlstab[P_NS2] = _("MNT namespace Inode");
/* Translation Hint: maximum 'nsNET' = 10 */
Head_nlstab[P_NS3] = _("nsNET");
Desc_nlstab[P_NS3] = _("NET namespace Inode");
/* Translation Hint: maximum 'nsPID' = 10 */
Head_nlstab[P_NS4] = _("nsPID");
Desc_nlstab[P_NS4] = _("PID namespace Inode");
/* Translation Hint: maximum 'nsUSER' = 10 */
Head_nlstab[P_NS5] = _("nsUSER");
Desc_nlstab[P_NS5] = _("USER namespace Inode");
/* Translation Hint: maximum 'nsUTS' = 10 */
Head_nlstab[P_NS6] = _("nsUTS");
Desc_nlstab[P_NS6] = _("UTS namespace Inode");
} }