Home Explore Blog CI



man-pages

34th chunk of `top.man`
c87d3e88afc75d7f7af46732c7971982b32709800cf1a9300000000100001002
 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 example takes what could have been a ‘file’ entry but employs a ‘pipe’ instead so  as  to  expand  the
       embedded tabs.

         # next would have contained ‘\t’ ...
         # file ^I <your_name> ^I /proc/%d/status
         # but this will eliminate embedded ‘\t’ ...
         pipe ^I <your_name> ^I cat /proc/%d/status | expand -

       Note:  Some  programs might rely on SIGINT to end.  Therefore, if a ‘pipe’ such as the following is established, one must use Ctrl‐C to terminate it in order to review the results.  This is the single occasion where a
       ‘^C’ will not also terminate top.

         pipe ^I Trace ^I /usr/bin/strace ‐p %d 2>&1

       Lastly, while ‘pipe’ type entries have been discussed in terms of pipelines and commands, there is nothing to prevent you  from  including   shell  scripts  as  well.   Perhaps  even  newly  created  scripts  designed
       specifically for the ‘Y’ interactive command.

       For  example,  as  the  number of your Inspect entries grows over time, the ‘Options:’ row will be truncated when screen width is exceeded.  That does not affect operation other than to make some selections invisible.
       However, if some choices are lost to truncation but you want to see more options, there is an easy solution hinted at below.

         Inspection Pause at pid ...
         Use:  left/right then <Enter> ...
         Options:  help  1  2  3  4  5  6  7  8  9  10  11 ...

       The entries in the top rcfile would have a number for the ‘.name’ element and the ‘help’ entry would identify a shell script you’ve written explaining what those numbered selections actually mean.  In that  way,  many
       more choices can be made visible.

   6c. SYSTEM Configuration File
       This  configuration  file  represents defaults for users who have not saved their own configuration file.  The format mirrors exactly the personal configuration file and can also include ‘inspect’ entries as explained
       above.

       Creating it is a simple process.

       1. Configure top appropriately for your installation and preserve that configuration with the ‘W’ interactive command.

       2. Add and test any desired ‘inspect’ entries.

       3. Copy that configuration file to the /etc/ directory as ‘topdefaultrc’.

   6d. SYSTEM Restrictions File
       The presence of this file will influence which version of the help screen is shown to an ordinary user.

       More importantly, it will limit what ordinary users are allowed to do when top is running.  They will not be able to issue the following commands.
           k        Kill a task
           r        Renice a task
           d or s   Change delay/sleep interval

       This configuration file is not created by top.  Rather, it is created manually and placed it in the /etc/ directory as ‘toprc’.

       It should have exactly two lines, as shown in this example:
           s        # line 1: secure mode switch
           5.0      # line 2: delay interval

Title: Top Command: Inspect Entries, System Configuration and Restrictions Files
Summary
This section continues discussing Inspect entries in the 'top' command, focusing on handling tab characters, using 'pipe' entries for tab expansion, and mentioning the potential need for Ctrl-C to terminate certain 'pipe' entries. It also suggests using shell scripts for Inspect entries. Then it describes the system configuration file ('topdefaultrc') as defaults for users without personal configurations. It details how to create this file by configuring top, adding Inspect entries, and copying the file to '/etc/'. Finally, it covers the system restrictions file ('toprc'), which limits actions for ordinary users, like killing or renicing tasks and changing the delay interval. The file should contain a secure mode switch and a delay interval.