window # line b: winflags,sortindx,maxtasks,etc
" # line c: summclr,msgsclr,headclr,taskclr
global # line 15: additional miscellaneous settings
" # any remaining lines are devoted to optional
" # active ‘other filters’ discussed in section 5e above
" # plus ‘inspect’ entries discussed in section 6b below
If a valid absolute path to the rcfile cannot be established, customizations made to a running top will be impossible to preserve.
6b. ADDING INSPECT Entries
To exploit the ‘Y’ interactive command, you must add entries at the end of the top personal configuration file. Such entries simply reflect a file to be read or command/pipeline to be executed whose results will then
be displayed in a separate scrollable, searchable window.
If you don’t know the location or name of your top rcfile, use the ‘W’ interactive command to rewrite it and note those details.
Inspect entries can be added with a redirected echo or by editing the configuration file. Redirecting an echo risks overwriting the rcfile should it replace (>) rather than append (>>) to that file. Conversely, when
using an editor care must be taken not to corrupt existing lines, some of which could contain unprintable data or unusual characters depending on the top version under which that configuration file was saved.
Those Inspect entries beginning with a ‘#’ character are ignored, regardless of content. Otherwise they consist of the following 3 elements, each of which must be separated by a tab character (thus 2 ‘\t’ total):
.type: literal ‘file’ or ‘pipe’
.name: selection shown on the Inspect screen
.fmts: string representing a path or command
The two types of Inspect entries are not interchangeable. Those designated ‘file’ will be accessed using fopen and must reference a single file in the ‘.fmts’ element. Entries specifying ‘pipe’ will employ popen,
their ‘.fmts’ element could contain many pipelined commands and, none can be interactive.
If the file or pipeline represented in your ‘.fmts’ deals with the specific PID input or accepted when prompted, then the format string must also contain the ‘%d’ specifier, as these examples illustrate.
.fmts= /proc/%d/numa_maps
.fmts= lsof ‐P ‐p %d
For ‘pipe’ type entries only, you may also wish to redirect stderr to stdout for a more comprehensive result. Thus the format string becomes:
.fmts= pmap ‐x %d 2>&1
Here are examples of both types of Inspect entries as they might appear in the rcfile. The first entry will be ignored due to the initial ‘#’ character. For clarity, the pseudo tab depictions (^I) are surrounded by
an extra space but the actual tabs would not be.
# pipe ^I Sockets ^I lsof ‐n ‐P ‐i 2>&1
pipe ^I Open Files ^I lsof ‐P ‐p %d 2>&1
file ^I NUMA Info ^I /proc/%d/numa_maps
pipe ^I Log ^I tail ‐n100 /var/log/syslog | sort ‐Mr
Except for the commented entry above, these next examples show what could be echoed to achieve similar results, assuming the rcfile name was ‘.toprc’. However, due to the embedded tab characters, each of these lines
should be preceded by ‘/bin/echo -e’, not just a simple an ‘echo’, to enable backslash interpretation regardless of which shell you use.
"pipe\tOpen Files\tlsof ‐P ‐p %d 2>&1" >> ~/.toprc
"file\tNUMA Info\t/proc/%d/numa_maps" >> ~/.toprc
"pipe\tLog\ttail ‐n200 /var/log/syslog | sort ‐Mr" >> ~/.toprc
If any inspect entry you create produces output with unprintable characters they will be displayed in either the ^C notation or hexadecimal <FF> form, depending on their value. This applies to tab characters as well,
which will show as ‘^I’. If you want a truer representation, any embedded tabs should be expanded. The following