.igEND
.
.\" Setup ////////////////////////////////////////////////////////////////
-. \" ** Comment out 'll' to eliminate WIDTH fiddlin', 1 of 3
-. ll +8
+\# ** Comment out '.nr' or set to 0 to eliminate WIDTH fiddlin' !
+.nr half_xtra 4
+.
+. ll +(\n[half_xtra] + \n[half_xtra])
.
\# Special right justify macros ---------------------
\# - right justify start
. de Rjb
-. \" ** Comment out 'll' to eliminate WIDTH fiddlin', 2 of 3
-. ll -4
+. ll -\n[half_xtra]
. rj \\$1
..
\# - right justify end
. de Rje
-. \" ** Comment out 'll' to eliminate WIDTH fiddlin', 3 of 3
-. ll +4
+. ll +\n[half_xtra]
..
\# Jimmy's darn Bullet style ------------------------
. de Jbu
personal \*(CF, including any changes made on a per-window basis.
Thus, once you personalize things they\fB remain personalized\fR until
you decide to change them again.
-This \*(ME has been completely cured of:
+This \*(Me has been completely cured of:
.Rjb 2
i-cant-remember-so-please-do-that-all-over-again
( and again, and again ... )
.New
You have complete program\fB naming freedom\fR with no internal ties to a
-specific \*(CF.
-Thus, if you have permission to create symbolic links to /usr/bin (or can bribe
-the system administrator), these symlinks could be used to establish\fB
-different\fR \*(CFs reflecting the different\fB personalities\fR of your
-customized "\*(Mes", under whatever aliases you've used.
-
-Thus, you could have an alias for running \*(Me in 'Batch mode', another for when
-you work from the Linux console and maybe a third used with X-Windows.
+specific personal \*(CF.
+Symbolic links could be used to establish different \*(CFs reflecting
+the different personalities of your customized "\*(Mes", under whatever
+aliases you've used.
+
+Thus, you could have an alias for running \*(Me in 'Batch mode', another for
+when you work from the Linux console and maybe a third used with X-Windows.
All of that, yet still just a single binary image!
.\" ......................................................................
.I Columns_Header\fR:
Shows a\fB new\fR field and some\fB changed\fR labels (unseen to the right).
-Precious horizontal space is no longer squandered unlike your former top.
+Precious horizontal space is no longer squandered.
.Scr
All of that, however, is just the tip of the old iceberg.
( or windows &\fB each\fR )| 6725 root 9 0 0.0 0:00.03 :
( could be shown in )| 6232 root 7 -10 1.9 4:25.86 :
( this way, or show )| 5561 root 9 0 0.0 0:00.33 :
- ( \fBall concurrently\fR! )| 5560 xfs 9 0 0.0 0:00.01 :
+ (\fB all concurrently\fR! )| 5560 xfs 9 0 0.0 0:00.01 :
| 5325 root 9 0 0.0 0:00.05 :
( will\fI change\fR often )| 4634 root 9 0 0.0 0:04.23 :
-*-\fBRow hilites-->\fR |\fB 1803 jgnome 9 0 0.0 1:55.30\fR :
However, items shown with an \*(AS could be overridden through the\fB
command line\fR \*(EM a subject soon to be dealt with.
- \fISystem_defaults\fR
+ \fIGlobal_defaults\fR
'A' - Alt display \fBOff\fR (full-screen)
* 'd' - Delay time 3.0 seconds
'I' - Irix mode On\ \ (no, 'solaris' smp)
You need remember just the\fB help key\fR ('h' or '?') to survive
\*(EM nay, prosper!
What about quitting, you ask?
-Well, of course there's the 'Q' \*(CI, but then \*(ME does quite well
+Well, of course there's the 'Q' \*(CI, but then \*(Me does quite well
with\fB signals\fR.
So just zap him with the traditional \fI^C\fR when you're done.
.br
This will also be indicated by a leading \*(AS, as in this excerpt:
\fR...
\fR* J: %CPU = CPU usage
- \fR K: TIME = CPU Time
- \fR L: TIME+ = CPU Time, hundredths
+ \fR k: TIME = CPU Time
+ \fR l: TIME+ = CPU Time, hundredths
\fR* M: %MEM = Memory usage (RES)
\fR* N: VIRT = Virtual Image (kb)
\fR...
.SH 3. INTERACTIVE Commands
.\" ----------------------------------------------------------------------
Listed below is a brief index of commands within categories.
-Some commands appear more than once and, while their meaning is consistent,
-the scope may vary depending on the context in which they are issued.
+Some commands appear more than once \*(EM their meaning or scope may vary
+depending on the context in which they are issued.
3a.\fI GLOBAL_Commands\fR
?, ^L, <Sp>, =, A, d, F, h, O, I, k, Q, r, s, W, Z
3d.\fI COLOR_Mapping\fR
<Enter>, a, b, H, M, q, S, T, w, z, 0 - 7
4b.\fI COMMANDS_for_Windows\fR
- -, _, =, +, A, F, g, O
+ -, _, =, +, A, a, F, g, O, w
.\" ......................................................................
.SS 3a. GLOBAL Commands
.TP 7
\ \ \'\fBA\fR\' :\fIAlternate_Display_Mode_toggle\fR
-This command will switch between \*(FM and \*(AM
-(see 4. ALTERNATE\-DISPLAY Mode).
+This command will switch between \*(FM and \*(AM.
+See 4. ALTERNATE\-DISPLAY Mode and the 'F' or 'O' \*(CIs for insight into
+\*(CWs and field groups.
.TP 7
*\ \'\fBd\fR\' or \'\fBs\fR\' :\fIChange_Delay_Time_interval\fR
Otherwise, each \*(Pu is displayed separately as: 'cpu0, cpu1, ...'
.in +4
-\*(NT If you receive a fatal error message in response to this command,
-your version of the kernel does not provide summary \*(Pu data in '/proc/stat'.
+\*(NT If you receive a fatal error message in response to this command, your
+version of the kernel does not provide separate \*(Pu data in '/proc/stat'.
You can either avoid issuing this command or recompile \*(Me with the
appropriate #define enabled so the command will be restricted to SMP.
.in
\ \ \'\fBz\fR\' :\fIColor/Monochrome_toggle\fR
Switches the \*(CW between your last used color scheme and the older form
of black-on-white or white-on-black.
-It does not affect the state of the 'x', 'y' or 'b' toggles.
+This command will alter both the \*(SA and \*(TA but does not affect the
+state of the 'x', 'y' or 'b' toggles.
.PP
.\" .........................
.TP 7
\ \ \fB\ 7\fR\ \ upper case letters which \fISelect_a_Sort_Column\fR:
-\'C\fR\'\ \ :Sort by Command\fB line\fR or program\fB name\fR,
+\'\fBC\fR\'\ \ :Sort by Command\fB line\fR or program\fB name\fR,
.br
\ \ \ \ \ \ depending on the state of the 'c' toggle
.br
-\'E\'\ \ :Sort by USER
+\'\fBE\fR\'\ \ :Sort by USER
.br
-\'M\'\ \ :Sort by %MEM and/or RES
+\'\fBM\fR\'\ \ :Sort by %MEM and/or RES
.br
-\'P\'\ \ :Sort by PID
+\'\fBP\fR\'\ \ :Sort by PID
.br
-\'T\'\ \ :Sort by TIME and/or TIME+
+\'\fBT\fR\'\ \ :Sort by TIME and/or TIME+
.br
-\'U\'\ \ :Sort by %CPU
+\'\fBU\fR\'\ \ :Sort by %CPU
.br
-\'Y\'\ \ :Sort by TTY
+\'\fBY\fR\'\ \ :Sort by TTY
+
+.PP
+If you forget which field \*(Me is sorting, the '\fBR\fR' or '\fBx\fR'
+\*(CIs could be used for a quick visual reminder, without changing the
+selected sort column.
.\" ......................................................................
.SS 3d. COLOR Mapping
.TP 7
\ \ \'\fB-\fR\' or \'\fB_\fR\' :\fIShow/Hide_Window(s)_toggle\fR
The '-' (minus) key turns the \*(CW's \*(TD \*O and \*F.
-When \*O, that \*(TA will show a minimum of 1 task and the columns header
-you've established with the 'f' and 'o' commands.
-It will also reflect any other \*(TA options/toggles you've applied.
+When \*O, that \*(TA will show a minimum of the columns header you've
+established with the 'f' and 'o' commands.
+It will also reflect any other \*(TA options/toggles you've applied yielding
+zero or more tasks.
The '_' (upper case minus) key does the same for\fB all\fR \*(TDs.
In other words, it switches between the currently visible \*(TD(s) and any
.Img
1:Def\fI no\fR highlight, +\fB--------------------------------------\fR+
thus disabled cmds: |1:Def - 15:50:32 up 16:29, 9 users, :
- b,i,n,u,x,y,z, etc. |Tasks: \fB 75\fR total, \fB 2\fR running, \fB 73\fR sle:
+ b,i,n,u,x,y, etc. |Tasks: \fB 75\fR total, \fB 2\fR running, \fB 73\fR sle:
& m = lost Mem/Swap |Cpu(s) state: \fB 10.6%\fR user, \fB 0.0%\fR syst:
|______________________________________:
2:Job was very busy: |\fI2__PID__PPID_Command____________TIME+_\fR:
\fBs\fR or\fB d\fR Change\fB delay/update\fR interval
The system \*(CF is\fB not\fR created by \*(Me.
-Rather,\fB you create this file manually\fR and place it in the\fI /etc\fR directory.
-Its name must agree with 'your-name-for-top'\ +\ 'rc' and must have\fI
-no\fR leading '.' (period).
-It must have\fI only_two_lines\fR.
+Rather,\fB you create this file manually\fR and place it in the \fI/etc\fR
+directory.
+Its name must be 'toprc' and must have\fI no\fR leading '.' (period).
+It must have only\fI two lines\fR.
-Here is an example of a system \*(CF placed in\fI /etc\fR
-as\fI top\fBrc\fR:\ \ /etc/\fItop\fBrc\fR
+Here is an example of the contents of\fI /etc/toprc\fR:
\fBs\fR # line 1: 'secure' mode switch
- \fB5.0\fR # line 2: 'delay'\ \ interval (secs)
+ \fB5.0\fR # line 2: 'delay'\ \ interval in seconds
.\" ......................................................................
.SS 5b. PERSONAL Configuration File
Rawtty;
static int Ttychanged = 0;
- /* Program name used in error messages and 'rc' file names */
+ /* Program name used in error messages and local 'rc' file name */
static char *Myname;
- /* The Name of the config file(s), dynamically constructed */
-static char RCfile [OURPATHSZ],
- RCfile_Sys [SMLBUFSIZ];
+ /* The Name of the local config file, dynamically constructed */
+static char RCfile [OURPATHSZ];
/* The run-time acquired page size */
static int Page_size;
"\nbye_bye's Summary report:"
"\n\tProgram"
"\n\t Page_size = %d, Cpu_tot = %d"
- "\n\tTerminal: %s"
+ "\n\t %s, Hertz = %u (size %u bytes, %u-bit time)"
+ "\n\t sizeof(CPUS_t) = %u, sizeof(HIST_t) = %u (%u HIST_t's/Page)"
+ "\n\t CPU_FMTS_JUST1 = %s"
+ " \t CPU_FMTS_MULTI = %s"
+ " \tTerminal: %s"
"\n\t device = %s, ncurses = v%s"
"\n\t max_colors = %d, max_pairs = %d"
"\n\t Cap_can_goto = %s"
"\n\t Max_lines = %d"
"\n\tWindows and Curwin->"
"\n\t sizeof(WIN_t) = %u, GROUPSMAX = %d"
- "\n\t winname = %s, grpname = %s,"
+ "\n\t winname = %s, grpname = %s"
#ifdef CASEUP_HEXES
"\n\t winflags = %08X, maxpflgs = %d"
#else
"\n\t sorttype = %c"
"\n"
, Page_size, Cpu_tot
+ , procps_version, (unsigned)Hertz, sizeof(Hertz), sizeof(Hertz) * 8
+ , sizeof(CPUS_t), sizeof(HIST_t), Page_size / sizeof(HIST_t)
+ , CPU_FMTS_JUST1, CPU_FMTS_MULTI
#ifdef PRETENDNOCAP
, "dumb"
#else
/* try successively higher units until it fits */
t = tics / Hertz;
- sprintf(buf, "%d:%02d.%02d" /* minutes:seconds.tenths */
- , t/60, t%60, (int)((tics*100)/Hertz)%100);
+ sprintf(buf, "%u:%02u.%02u" /* minutes:seconds.hundredths */
+ , t/60, t%60, (unsigned)((tics*100)/Hertz)%100);
if (strlen(buf) <= width)
return buf;
- sprintf(buf, "%d:%02d", t/60, t%60); /* minutes:seconds */
+ sprintf(buf, "%u:%02u", t/60, t%60); /* minutes:seconds */
if (strlen(buf) <= width)
return buf;
/*
- * Build the two RC file names then try to read 'em. */
- /* '/etc/RCfile_Sys' contains two lines consisting of the secure
+ * Build the local RC file name then try to read both of 'em. */
+ /* 'SYS_RCFILE' contains two lines consisting of the secure
* mode switch and an update interval. It's presence limits what
* ordinary users are allowed to do. */
/* '$HOME/RCfile' contains multiple lines - 2 global + 3 per window.
char id;
int i;
- strcpy(RCfile_Sys, fmtmk("/etc/%src", Myname));
if (getenv("HOME"))
strcpy(RCfile, fmtmk("%s%c", getenv("HOME"), '/'));
strcat(RCfile, fmtmk(".%src", Myname));
- fp = fopen(RCfile_Sys, "r");
+ fp = fopen(SYS_RCFILE, "r");
if (fp) {
fbuf[0] = '\0';
fgets(fbuf, sizeof(fbuf), fp); /* sys rc file, line #1 */
if (cp[1]) cp++;
else if (*args) cp = *args++;
else std_err("-n requires argument");
- if (1 != sscanf(cp, "%d", &Loops) || 0 > Loops)
+ if (1 != sscanf(cp, "%d", &Loops) || 1 > Loops)
std_err(fmtmk("bad iterations arg '%s'", cp));
break;
case 'p':
} /* end: switch (*cp) */
/* advance cp and jump over any numerical args used above */
- if (*cp) cp += strspn(++cp, "- ,.1234567890");
+ if (*cp) cp += strspn(&cp[1], "- ,.1234567890") + 1;
} /* end: while (*cp) */
} /* end: while (*args) */
too lazy to handle his own asterisk (*) logic */
putp(Cap_bold);
for (i = 0; i < MAXtbl(Fieldstab); ++i) {
+ int b = (NULL != strchr(Curwin->fieldscur, i + 'A'));
/* advance past any leading spaces */
for (p = Fieldstab[i].head; ' ' == *p; ++p)
;
+
printf("%s%c %c: %-10s = %s"
, tg2((i / rmax) * cmax, (i % rmax) + yRSVD)
- , strchr(Curwin->fieldscur, i + 'A') ? '*' : ' '
- , i + 'A'
+ , b ? '*' : ' '
+ , b ? i + 'A' : i + 'a'
, p
, Fieldstab[i].desc);
}
{
/* we'll trim to zero if we get negative time ticks,
which has happened with some SMP kernels (pre-2.4?) */
-#define TRIMz(x) ((tz = (long)x) < 0 ? 0 : tz)
+#define TRIMz(x) ((tz = (STIC_t)x) < 0 ? 0 : tz)
TICS_t u_tics, s_tics, n_tics, i_tics;
- long u_frme, s_frme, n_frme, i_frme, tot_frme, tz;
+ STIC_t u_frme, s_frme, n_frme, i_frme, tot_frme, tz;
#ifdef PRETEND4CPUS
rewind(fp);
, (float)s_frme * 100 / tot_frme
, (float)n_frme * 100 / tot_frme
, (float)i_frme * 100 / tot_frme));
+ Msg_row += 1;
/* remember for next time around */
cpu->u = u_tics;
{
static HIST_t *hist_sav = NULL;
static unsigned hist_siz;
- static int viewsav;
static CPUS_t *smpcpu;
HIST_t *hist_new;
unsigned total, running, sleeping, stopped, zombie;
if (!hist_sav) {
Frame_maxtask = 0;
- /* room for 512 HIST_t's (if Page_size == 4k) */
hist_siz = (Page_size / sizeof(HIST_t));
hist_sav = alloc_c(hist_siz);
/* note: we allocate one more CPUS_t than Cpu_tot so that the last
slot can hold tics representing the /proc/stat cpu summary
(first line read) -- that slot supports summary cpu info */
smpcpu = alloc_c((1 + Cpu_tot) * sizeof(CPUS_t));
- viewsav = CHKw(Curwin, View_CPUSUM);
}
hist_new = alloc_c(hist_siz);
total = running = sleeping = stopped = zombie = 0;
, total, running, sleeping, stopped, zombie));
Msg_row += 1;
- /* clean old histories if we've changed modes */
- if (CHKw(Curwin, View_CPUSUM) != viewsav) {
- if (CHKw(Curwin, View_CPUSUM))
- /* fresh start for the last slot in the history area */
- memset(&smpcpu[Cpu_tot], '\0', sizeof(CPUS_t));
- else
- /* fresh start for the true smpcpu history area */
- memset(smpcpu, '\0', Cpu_tot * sizeof(CPUS_t));
- viewsav = CHKw(Curwin, View_CPUSUM);
- }
-
if (!(fp = fopen("/proc/stat", "r")))
std_err(fmtmk("Failed /proc/stat open: %s", strerror(errno)));
if (CHKw(Curwin, View_CPUSUM)) {
/* retrieve and display just the 1st /proc/stat line */
cpudo(fp, CPU_FMTS_JUST1, &smpcpu[Cpu_tot], "Cpu(s) state:");
- Msg_row += 1;
} else {
char tmp[SMLBUFSIZ];
/* skip the 1st line, which reflects total cpu states */
- if (!fgets(tmp, sizeof(tmp), fp))
- std_err("Failed /proc/stat read");
+ if (!fgets(tmp, sizeof(tmp), fp)) std_err("Failed /proc/stat read");
/* now do each cpu's states separately */
for (i = 0; i < Cpu_tot; i++) {
sprintf(tmp, "%-6scpu%-2d:" /* [ cpu states as ] */
, i ? " " : "State" /* 'State cpu0 : ... ' */
, Mode_irixps ? i : Cpu_map[i]); /* ' cpu1 : ... ' */
cpudo(fp, CPU_FMTS_MULTI, &smpcpu[i], tmp);
- Msg_row += 1;
}
}
fclose(fp);
case 'g':
if (Mode_altscr) {
char tmp[GETBUFSIZ];
- strcpy(tmp, ask4str(fmtmk("Rename window '%s' to (0-3 chars)"
+ strcpy(tmp, ask4str(fmtmk("Rename window '%s' to (1-3 chars)"
, Curwin->winname)));
if (tmp[0]) win_names(Curwin, tmp);
}
fprintf(fp, "RCfile for \"%s with windows\"\t\t# shameless braggin'\n"
, Myname);
fprintf(fp, "Id:%c, "
- "Mode_altscr=%d, Mode_irixps=%d, Delay_time=%.1f, Curwin=%d\n"
+ "Mode_altscr=%d, Mode_irixps=%d, Delay_time=%.3f, Curwin=%d\n"
, RCF_FILEID
, Mode_altscr, Mode_irixps, Delay_time, Curwin - Winstk[0]);
for (i = 0; i < GROUPSMAX; i++) {
* -- i swear that's the whole truth, so-help-me ! */
static void sohelpme (int wix, int max)
{
- WIN_t *w;
+ WIN_t *w = Winstk[wix];
int i, rsvd, size, wins;
/* calc remaining number of visible windows + total 'user' lines */
* it just SPLENDIDLY! You go right on doing it EXACTLY the SAME!
*/
int main (int dont_care_argc, char **argv)
-{ /*
+{
+ before(*argv);
+ /*
Ok, she's gone now. Don't you mind her, she means well but yes, she is
a bit of a busy-body. Always playing the matchmaker role, trying to do
away with unmarried windows and bachelors. So, back to business buddy!
Well then, here, try THIS sandwich...
+-------------+ */
windows_stage1(); /* top (sic) slice */
- before(*argv); /* > seasonings, < */
configs_read(); /* > spread etc, < */
parse_args(&argv[1]); /* > lean stuff, < */
whack_terminal(); /* > onions etc. < */
/* Defines intended to be experimented with ------------------------ */
//#define CASEUP_HEXES /* show any hex values in upper case */
-//#define CASEUP_SCALE /* show scaled times & memory upper case */
+//#define CASEUP_SCALE /* show scaled time/num suffix upper case */
//#define CASEUP_SUMMK /* show memory summary kilobytes with 'K' */
//#define QUIT_NORMALQ /* use 'q' to quit, not new default 'Q' */
//#define SORT_SUPRESS /* *attempt* to reduce qsort overhead */
+//#define TICS_64_BITS /* accommodate Linux 2.5.xx 64-bit jiffies */
//#define USE_LIB_STA3 /* use lib status (3 ch) vs. proc_t (1 ch) */
//#define WARN_NOT_SMP /* restrict '1' & 'I' commands to true smp */
/*###### Some Typedef's and Enum's #####################################*/
- /* This typedef attempts to ensure consistent 'ticks' handling. */
+ /* These typedefs attempt to ensure consistent 'ticks' handling */
+#ifdef TICS_64_BITS
+typedef unsigned long long TICS_t;
+typedef long long STIC_t;
+#else
typedef unsigned long TICS_t;
+typedef long STIC_t;
+#endif
/* This structure consolidates the information that's used
in a variety of display roles. */
/*###### Display Support *Data* ########################################*/
- /* An rcfile 'footprint' used to invalidate existing */
-#define RCF_FILEID 'e'
+ /* An rcfile 'footprint' used to invalidate existing local rcfile
+ and the global rcfile path + name */
+#define RCF_FILEID 'g'
+#define SYS_RCFILE "/etc/toprc"
/* The default fields displayed and their order,
if nothing is specified by the loser, oops user */
/* These are the possible fscanf formats used in /proc/stat
reads during history processing. */
+#ifdef TICS_64_BITS
+#define CPU_FMTS_MULTI "cpu%*d %Lu %Lu %Lu %Lu\n"
+#define CPU_FMTS_JUST1 "cpu %Lu %Lu %Lu %Lu\n"
+#else
#define CPU_FMTS_MULTI "cpu%*d %lu %lu %lu %lu\n"
#define CPU_FMTS_JUST1 "cpu %lu %lu %lu %lu\n"
+#endif
/* Summary Lines specially formatted string(s) --
see 'show_special' for syntax details + other cautions. */
"%s's - \01Help for Interactive Commands\02 - %s\n" \
"Window %s\06: \01Cumulative mode \03%s\02. \01System\06: \01Delay time \03%.1f secs\02; \01Secure mode \03%s\02.\n" \
" sp or ^L Redraw screen\n" \
- " o Rearrange current window's fields\n" \
- " f Add and remove current window's fields\n" \
+ " o . Rearrange current window's fields\n" \
+ " f . Add and remove current window's fields\n" \
" Z Change color mappings for any window\05\n" \
"\n" \
"(7 letters) . Sort: \01C\02) cmd; \01M\02) mem; \01P\02) pid; \01T\02) time; \01U\02) cpu; \01Y\02) tty; \01E\02) user\n" \
" 0x00040000 PF_KERNTHREAD (2.5)\n" \
" 0x00100000 PF_USEDFPU (thru 2.4)\n" \
" 0x00400000 PF_ATOMICALLOC\n" \
- "\n" \
- "Memory notes:\n" \
- " VIRT = SWAP + RES\n" \
- " RES = CODE + DATA\n" \
""
/* Windows/Field Group Help specially formatted string(s) --