Top-like command configurable from command line The 2019 Stack Overflow Developer Survey Results Are InUNIX-, BSD-, GNU-options in Linux's ps command. Where are they from?Queries about top commandTool for viewing top N items in streamThe shell command “top” shows which processes from the /proc directory?Top forest view with filter, can I include all children?How do I control the cycle length of “top” commandProgrammatically get CPUs 'detailed' usage, like top/htopTop command strange CPU% usageFilter top(1) display by COMMAND=abc OR COMMAND=xyzExclude chrome/firefox from top command outputhtop / top with specifying process name filter on the command line - at program startup?
How can I add encounters in the Lost Mine of Phandelver campaign without giving PCs too much XP?
How to obtain a position of last non-zero element
If I score a critical hit on an 18 or higher, what are my chances of getting a critical hit if I roll 3d20?
Does HR tell a hiring manager about salary negotiations?
APIPA and LAN Broadcast Domain
Are spiders unable to hurt humans, especially very small spiders?
Mathematics of imaging the black hole
If my opponent casts Ultimate Price on my Phantasmal Bear, can I save it by casting Snap or Curfew?
Is it a good practice to use a static variable in a Test Class and use that in the actual class instead of Test.isRunningTest()?
Can you cast a spell on someone in the Ethereal Plane, if you are on the Material Plane and have the True Seeing spell active?
Did any laptop computers have a built-in 5 1/4 inch floppy drive?
Kerning for subscripts of sigma?
Loose spokes after only a few rides
Why can't devices on different VLANs, but on the same subnet, communicate?
Geography at the pixel level
Can an undergraduate be advised by a professor who is very far away?
Old scifi movie from the 50s or 60s with men in solid red uniforms who interrogate a spy from the past
How do PCB vias affect signal quality?
Star Trek - X-shaped Item on Regula/Orbital Office Starbases
Deal with toxic manager when you can't quit
How to support a colleague who finds meetings extremely tiring?
Dropping list elements from nested list after evaluation
Why doesn't shell automatically fix "useless use of cat"?
How come people say “Would of”?
Top-like command configurable from command line
The 2019 Stack Overflow Developer Survey Results Are InUNIX-, BSD-, GNU-options in Linux's ps command. Where are they from?Queries about top commandTool for viewing top N items in streamThe shell command “top” shows which processes from the /proc directory?Top forest view with filter, can I include all children?How do I control the cycle length of “top” commandProgrammatically get CPUs 'detailed' usage, like top/htopTop command strange CPU% usageFilter top(1) display by COMMAND=abc OR COMMAND=xyzExclude chrome/firefox from top command outputhtop / top with specifying process name filter on the command line - at program startup?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
For Ubuntu Bionic, is there a tool that will, like top
, show various data on processes and refresh automatically, but can be configured from the command line to specify what data (columns) to show?
ubuntu top
New contributor
add a comment |
For Ubuntu Bionic, is there a tool that will, like top
, show various data on processes and refresh automatically, but can be configured from the command line to specify what data (columns) to show?
ubuntu top
New contributor
@msp9011 like, only show theCOMMAND
column, which should be specified on the command line.
– Yuri Geinish
Apr 8 at 11:41
add a comment |
For Ubuntu Bionic, is there a tool that will, like top
, show various data on processes and refresh automatically, but can be configured from the command line to specify what data (columns) to show?
ubuntu top
New contributor
For Ubuntu Bionic, is there a tool that will, like top
, show various data on processes and refresh automatically, but can be configured from the command line to specify what data (columns) to show?
ubuntu top
ubuntu top
New contributor
New contributor
edited Apr 8 at 11:25
Kusalananda♦
141k17263439
141k17263439
New contributor
asked Apr 8 at 10:26
Yuri GeinishYuri Geinish
111
111
New contributor
New contributor
@msp9011 like, only show theCOMMAND
column, which should be specified on the command line.
– Yuri Geinish
Apr 8 at 11:41
add a comment |
@msp9011 like, only show theCOMMAND
column, which should be specified on the command line.
– Yuri Geinish
Apr 8 at 11:41
@msp9011 like, only show the
COMMAND
column, which should be specified on the command line.– Yuri Geinish
Apr 8 at 11:41
@msp9011 like, only show the
COMMAND
column, which should be specified on the command line.– Yuri Geinish
Apr 8 at 11:41
add a comment |
2 Answers
2
active
oldest
votes
procps
top
, the one found on Ubuntu is probably the most configurable of top
implementations.
To change the list of fields, press f and you can add remove fields, change their orders, etc.
There is a lot more you can change there, including colour, layout, including multi-pane views, the header at the top...
You can save those configuration by pressing W.
That will go to ~/.toprc
(or ~/.config/procps/toprc
in newer versions).
You can save them as a different profile by calling top
with a different name. For instance, if you make a mytop
symlink to the top
executable, and invoke it, or run top
as (exec -a mytop top)
, then W will save the configuration to ~/.mytoprc
instead, so you can define a variety of differently flavoured versions of top
that way.
add a comment |
It's a dilemma, isn't it?
top
has automatic refresh, but no way to specify the columns to display.ps
and its ilk can be told what columns to output, but do not continually update.
I am part of the way towards addressing this for myself.
I already have a tool that can take the data of a table input over a pipe, and display it full screen on a terminal in a scrollable columnar format. It is the console-flat-table-viewer
command from the nosh toolset. Feed it at intervals on its standard input a succession of tables, delimited by the relevant file separator character, and it will provide a continually updated display.
Note that this is not like watch
. watch
takes any old input. console-flat-table-viewer
expects its input to be a table, in one of the several well-known flat file encodings that one find on Unices and Linux operating systems, and its user interface presents it as a table, aligned into rows and columns and with headings and a cursor.
The other part of the mechanism is a tool that emits the process table in such a flat file form in the first place, repeatedly at intervals, interspersing its output with a file separator. We almost, but do not quite, have this.
One can feed it the output of the top
command in its "batch" mode:
while top -b all | sed -e '1,8s/^/#/' -e $'1i\n\f'
do
sleep 1
done |
console-flat-table-viewer --header-count 1
The sed
turns into comments the part of the top
output that is not actually the process table, which would otherwise confuse the table layout, and adds in the file separator. In the table encoding that matches what top
outputs, what the console-flat-table-viewer
manual calls the space
format, the file separator is the ␌ character, which has to be escaped for sed
to not strip it. (ASCII has a real ␜ character, which console-flat-table-viewer
understands for ascii
tables. This is not the encoding that top
outputs, though.)
I add the ␌ character with sed
to reduce display flicker, so that console-flat-table-viewer
does not receive it until immediately before the rest of the table data. An alternative, which flickers slightly more because there is an interval between the ␌ and the table data during which console-flat-table-viewer
displays a blank table, is to simply invoke printf
first.
Similarly, the commands that generate the output go in the condition of the while
loop, so that the broken pipe when I quit console-flat-table-viewer
causes the loop to gracefully terminate.
But this does not provide control over columns.
One can alternatively feed it the output of the FreeBSD procstat
command:
while printf 'f' ; procstat -a
do
sleep 1
done |
console-flat-table-viewer --header-count 1
This has a limited degree of control over columns with its various options, but not fine grained control. It is also somewhat problematic because several of its options cause it to break the tabular format by emitting unescaped whitespace in the middle of fields.
One could use the BSD ps
command:
while ps -a -x -o "pid,ppid,user,logname,time,state,wchan,start,comm" | sed -e $'1i\n\f'
do
sleep 1
done |
console-flat-table-viewer --header-count 1
The GNU-licensed ps
command on Ubuntu Linux has a different command-line syntax, which is several questions and answers in its own right, but one could employ it likewise.
Whilst this does have fine-grained control over the columns, it again does not properly escape whitespace within fields.
The BSDs have had a way of dealing with this since 4.4BSD in the 1990s. It is the vis()
encoding system, which various BSD flat tables (such as /etc/fstab
) already employ. console-flat-table-viewer
already knows how to decode it, too. It would be very welcome for ps
or procstat
, preferably both, to be able to vis
-encode their outputs.
The obvious next step for GUI users is to have a (currently hypothetical) utility that substitutes for console-flat-table-viewer
, taking the same input and leaving the input side of the pipeline the same, and displays continually updated tables with a GUI instead of a TUI.
Then we could have a flexible mechanism made of composable tools joined together with pipes. ☺
Further reading
- Jonathan de Boyne Pollard (2019).
console-flat-table-viewer
. nosh Guide. Softwares. - "Roadmap". The nosh project. FreeBSD Quarterly Status Update 2018Q4.
- Robert N M Watson (2017-01-14). procstat. FreeBSD General Commands Manual.
ps. FreeBSD General Commands Manual. 2018-03-13.
vis. FreeBSD General Commands Manual. 2013-02-19.- https://unix.stackexchange.com/a/511530/5132
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Yuri Geinish is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f511202%2ftop-like-command-configurable-from-command-line%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
procps
top
, the one found on Ubuntu is probably the most configurable of top
implementations.
To change the list of fields, press f and you can add remove fields, change their orders, etc.
There is a lot more you can change there, including colour, layout, including multi-pane views, the header at the top...
You can save those configuration by pressing W.
That will go to ~/.toprc
(or ~/.config/procps/toprc
in newer versions).
You can save them as a different profile by calling top
with a different name. For instance, if you make a mytop
symlink to the top
executable, and invoke it, or run top
as (exec -a mytop top)
, then W will save the configuration to ~/.mytoprc
instead, so you can define a variety of differently flavoured versions of top
that way.
add a comment |
procps
top
, the one found on Ubuntu is probably the most configurable of top
implementations.
To change the list of fields, press f and you can add remove fields, change their orders, etc.
There is a lot more you can change there, including colour, layout, including multi-pane views, the header at the top...
You can save those configuration by pressing W.
That will go to ~/.toprc
(or ~/.config/procps/toprc
in newer versions).
You can save them as a different profile by calling top
with a different name. For instance, if you make a mytop
symlink to the top
executable, and invoke it, or run top
as (exec -a mytop top)
, then W will save the configuration to ~/.mytoprc
instead, so you can define a variety of differently flavoured versions of top
that way.
add a comment |
procps
top
, the one found on Ubuntu is probably the most configurable of top
implementations.
To change the list of fields, press f and you can add remove fields, change their orders, etc.
There is a lot more you can change there, including colour, layout, including multi-pane views, the header at the top...
You can save those configuration by pressing W.
That will go to ~/.toprc
(or ~/.config/procps/toprc
in newer versions).
You can save them as a different profile by calling top
with a different name. For instance, if you make a mytop
symlink to the top
executable, and invoke it, or run top
as (exec -a mytop top)
, then W will save the configuration to ~/.mytoprc
instead, so you can define a variety of differently flavoured versions of top
that way.
procps
top
, the one found on Ubuntu is probably the most configurable of top
implementations.
To change the list of fields, press f and you can add remove fields, change their orders, etc.
There is a lot more you can change there, including colour, layout, including multi-pane views, the header at the top...
You can save those configuration by pressing W.
That will go to ~/.toprc
(or ~/.config/procps/toprc
in newer versions).
You can save them as a different profile by calling top
with a different name. For instance, if you make a mytop
symlink to the top
executable, and invoke it, or run top
as (exec -a mytop top)
, then W will save the configuration to ~/.mytoprc
instead, so you can define a variety of differently flavoured versions of top
that way.
edited 2 days ago
answered 2 days ago
Stéphane ChazelasStéphane Chazelas
314k57594952
314k57594952
add a comment |
add a comment |
It's a dilemma, isn't it?
top
has automatic refresh, but no way to specify the columns to display.ps
and its ilk can be told what columns to output, but do not continually update.
I am part of the way towards addressing this for myself.
I already have a tool that can take the data of a table input over a pipe, and display it full screen on a terminal in a scrollable columnar format. It is the console-flat-table-viewer
command from the nosh toolset. Feed it at intervals on its standard input a succession of tables, delimited by the relevant file separator character, and it will provide a continually updated display.
Note that this is not like watch
. watch
takes any old input. console-flat-table-viewer
expects its input to be a table, in one of the several well-known flat file encodings that one find on Unices and Linux operating systems, and its user interface presents it as a table, aligned into rows and columns and with headings and a cursor.
The other part of the mechanism is a tool that emits the process table in such a flat file form in the first place, repeatedly at intervals, interspersing its output with a file separator. We almost, but do not quite, have this.
One can feed it the output of the top
command in its "batch" mode:
while top -b all | sed -e '1,8s/^/#/' -e $'1i\n\f'
do
sleep 1
done |
console-flat-table-viewer --header-count 1
The sed
turns into comments the part of the top
output that is not actually the process table, which would otherwise confuse the table layout, and adds in the file separator. In the table encoding that matches what top
outputs, what the console-flat-table-viewer
manual calls the space
format, the file separator is the ␌ character, which has to be escaped for sed
to not strip it. (ASCII has a real ␜ character, which console-flat-table-viewer
understands for ascii
tables. This is not the encoding that top
outputs, though.)
I add the ␌ character with sed
to reduce display flicker, so that console-flat-table-viewer
does not receive it until immediately before the rest of the table data. An alternative, which flickers slightly more because there is an interval between the ␌ and the table data during which console-flat-table-viewer
displays a blank table, is to simply invoke printf
first.
Similarly, the commands that generate the output go in the condition of the while
loop, so that the broken pipe when I quit console-flat-table-viewer
causes the loop to gracefully terminate.
But this does not provide control over columns.
One can alternatively feed it the output of the FreeBSD procstat
command:
while printf 'f' ; procstat -a
do
sleep 1
done |
console-flat-table-viewer --header-count 1
This has a limited degree of control over columns with its various options, but not fine grained control. It is also somewhat problematic because several of its options cause it to break the tabular format by emitting unescaped whitespace in the middle of fields.
One could use the BSD ps
command:
while ps -a -x -o "pid,ppid,user,logname,time,state,wchan,start,comm" | sed -e $'1i\n\f'
do
sleep 1
done |
console-flat-table-viewer --header-count 1
The GNU-licensed ps
command on Ubuntu Linux has a different command-line syntax, which is several questions and answers in its own right, but one could employ it likewise.
Whilst this does have fine-grained control over the columns, it again does not properly escape whitespace within fields.
The BSDs have had a way of dealing with this since 4.4BSD in the 1990s. It is the vis()
encoding system, which various BSD flat tables (such as /etc/fstab
) already employ. console-flat-table-viewer
already knows how to decode it, too. It would be very welcome for ps
or procstat
, preferably both, to be able to vis
-encode their outputs.
The obvious next step for GUI users is to have a (currently hypothetical) utility that substitutes for console-flat-table-viewer
, taking the same input and leaving the input side of the pipeline the same, and displays continually updated tables with a GUI instead of a TUI.
Then we could have a flexible mechanism made of composable tools joined together with pipes. ☺
Further reading
- Jonathan de Boyne Pollard (2019).
console-flat-table-viewer
. nosh Guide. Softwares. - "Roadmap". The nosh project. FreeBSD Quarterly Status Update 2018Q4.
- Robert N M Watson (2017-01-14). procstat. FreeBSD General Commands Manual.
ps. FreeBSD General Commands Manual. 2018-03-13.
vis. FreeBSD General Commands Manual. 2013-02-19.- https://unix.stackexchange.com/a/511530/5132
add a comment |
It's a dilemma, isn't it?
top
has automatic refresh, but no way to specify the columns to display.ps
and its ilk can be told what columns to output, but do not continually update.
I am part of the way towards addressing this for myself.
I already have a tool that can take the data of a table input over a pipe, and display it full screen on a terminal in a scrollable columnar format. It is the console-flat-table-viewer
command from the nosh toolset. Feed it at intervals on its standard input a succession of tables, delimited by the relevant file separator character, and it will provide a continually updated display.
Note that this is not like watch
. watch
takes any old input. console-flat-table-viewer
expects its input to be a table, in one of the several well-known flat file encodings that one find on Unices and Linux operating systems, and its user interface presents it as a table, aligned into rows and columns and with headings and a cursor.
The other part of the mechanism is a tool that emits the process table in such a flat file form in the first place, repeatedly at intervals, interspersing its output with a file separator. We almost, but do not quite, have this.
One can feed it the output of the top
command in its "batch" mode:
while top -b all | sed -e '1,8s/^/#/' -e $'1i\n\f'
do
sleep 1
done |
console-flat-table-viewer --header-count 1
The sed
turns into comments the part of the top
output that is not actually the process table, which would otherwise confuse the table layout, and adds in the file separator. In the table encoding that matches what top
outputs, what the console-flat-table-viewer
manual calls the space
format, the file separator is the ␌ character, which has to be escaped for sed
to not strip it. (ASCII has a real ␜ character, which console-flat-table-viewer
understands for ascii
tables. This is not the encoding that top
outputs, though.)
I add the ␌ character with sed
to reduce display flicker, so that console-flat-table-viewer
does not receive it until immediately before the rest of the table data. An alternative, which flickers slightly more because there is an interval between the ␌ and the table data during which console-flat-table-viewer
displays a blank table, is to simply invoke printf
first.
Similarly, the commands that generate the output go in the condition of the while
loop, so that the broken pipe when I quit console-flat-table-viewer
causes the loop to gracefully terminate.
But this does not provide control over columns.
One can alternatively feed it the output of the FreeBSD procstat
command:
while printf 'f' ; procstat -a
do
sleep 1
done |
console-flat-table-viewer --header-count 1
This has a limited degree of control over columns with its various options, but not fine grained control. It is also somewhat problematic because several of its options cause it to break the tabular format by emitting unescaped whitespace in the middle of fields.
One could use the BSD ps
command:
while ps -a -x -o "pid,ppid,user,logname,time,state,wchan,start,comm" | sed -e $'1i\n\f'
do
sleep 1
done |
console-flat-table-viewer --header-count 1
The GNU-licensed ps
command on Ubuntu Linux has a different command-line syntax, which is several questions and answers in its own right, but one could employ it likewise.
Whilst this does have fine-grained control over the columns, it again does not properly escape whitespace within fields.
The BSDs have had a way of dealing with this since 4.4BSD in the 1990s. It is the vis()
encoding system, which various BSD flat tables (such as /etc/fstab
) already employ. console-flat-table-viewer
already knows how to decode it, too. It would be very welcome for ps
or procstat
, preferably both, to be able to vis
-encode their outputs.
The obvious next step for GUI users is to have a (currently hypothetical) utility that substitutes for console-flat-table-viewer
, taking the same input and leaving the input side of the pipeline the same, and displays continually updated tables with a GUI instead of a TUI.
Then we could have a flexible mechanism made of composable tools joined together with pipes. ☺
Further reading
- Jonathan de Boyne Pollard (2019).
console-flat-table-viewer
. nosh Guide. Softwares. - "Roadmap". The nosh project. FreeBSD Quarterly Status Update 2018Q4.
- Robert N M Watson (2017-01-14). procstat. FreeBSD General Commands Manual.
ps. FreeBSD General Commands Manual. 2018-03-13.
vis. FreeBSD General Commands Manual. 2013-02-19.- https://unix.stackexchange.com/a/511530/5132
add a comment |
It's a dilemma, isn't it?
top
has automatic refresh, but no way to specify the columns to display.ps
and its ilk can be told what columns to output, but do not continually update.
I am part of the way towards addressing this for myself.
I already have a tool that can take the data of a table input over a pipe, and display it full screen on a terminal in a scrollable columnar format. It is the console-flat-table-viewer
command from the nosh toolset. Feed it at intervals on its standard input a succession of tables, delimited by the relevant file separator character, and it will provide a continually updated display.
Note that this is not like watch
. watch
takes any old input. console-flat-table-viewer
expects its input to be a table, in one of the several well-known flat file encodings that one find on Unices and Linux operating systems, and its user interface presents it as a table, aligned into rows and columns and with headings and a cursor.
The other part of the mechanism is a tool that emits the process table in such a flat file form in the first place, repeatedly at intervals, interspersing its output with a file separator. We almost, but do not quite, have this.
One can feed it the output of the top
command in its "batch" mode:
while top -b all | sed -e '1,8s/^/#/' -e $'1i\n\f'
do
sleep 1
done |
console-flat-table-viewer --header-count 1
The sed
turns into comments the part of the top
output that is not actually the process table, which would otherwise confuse the table layout, and adds in the file separator. In the table encoding that matches what top
outputs, what the console-flat-table-viewer
manual calls the space
format, the file separator is the ␌ character, which has to be escaped for sed
to not strip it. (ASCII has a real ␜ character, which console-flat-table-viewer
understands for ascii
tables. This is not the encoding that top
outputs, though.)
I add the ␌ character with sed
to reduce display flicker, so that console-flat-table-viewer
does not receive it until immediately before the rest of the table data. An alternative, which flickers slightly more because there is an interval between the ␌ and the table data during which console-flat-table-viewer
displays a blank table, is to simply invoke printf
first.
Similarly, the commands that generate the output go in the condition of the while
loop, so that the broken pipe when I quit console-flat-table-viewer
causes the loop to gracefully terminate.
But this does not provide control over columns.
One can alternatively feed it the output of the FreeBSD procstat
command:
while printf 'f' ; procstat -a
do
sleep 1
done |
console-flat-table-viewer --header-count 1
This has a limited degree of control over columns with its various options, but not fine grained control. It is also somewhat problematic because several of its options cause it to break the tabular format by emitting unescaped whitespace in the middle of fields.
One could use the BSD ps
command:
while ps -a -x -o "pid,ppid,user,logname,time,state,wchan,start,comm" | sed -e $'1i\n\f'
do
sleep 1
done |
console-flat-table-viewer --header-count 1
The GNU-licensed ps
command on Ubuntu Linux has a different command-line syntax, which is several questions and answers in its own right, but one could employ it likewise.
Whilst this does have fine-grained control over the columns, it again does not properly escape whitespace within fields.
The BSDs have had a way of dealing with this since 4.4BSD in the 1990s. It is the vis()
encoding system, which various BSD flat tables (such as /etc/fstab
) already employ. console-flat-table-viewer
already knows how to decode it, too. It would be very welcome for ps
or procstat
, preferably both, to be able to vis
-encode their outputs.
The obvious next step for GUI users is to have a (currently hypothetical) utility that substitutes for console-flat-table-viewer
, taking the same input and leaving the input side of the pipeline the same, and displays continually updated tables with a GUI instead of a TUI.
Then we could have a flexible mechanism made of composable tools joined together with pipes. ☺
Further reading
- Jonathan de Boyne Pollard (2019).
console-flat-table-viewer
. nosh Guide. Softwares. - "Roadmap". The nosh project. FreeBSD Quarterly Status Update 2018Q4.
- Robert N M Watson (2017-01-14). procstat. FreeBSD General Commands Manual.
ps. FreeBSD General Commands Manual. 2018-03-13.
vis. FreeBSD General Commands Manual. 2013-02-19.- https://unix.stackexchange.com/a/511530/5132
It's a dilemma, isn't it?
top
has automatic refresh, but no way to specify the columns to display.ps
and its ilk can be told what columns to output, but do not continually update.
I am part of the way towards addressing this for myself.
I already have a tool that can take the data of a table input over a pipe, and display it full screen on a terminal in a scrollable columnar format. It is the console-flat-table-viewer
command from the nosh toolset. Feed it at intervals on its standard input a succession of tables, delimited by the relevant file separator character, and it will provide a continually updated display.
Note that this is not like watch
. watch
takes any old input. console-flat-table-viewer
expects its input to be a table, in one of the several well-known flat file encodings that one find on Unices and Linux operating systems, and its user interface presents it as a table, aligned into rows and columns and with headings and a cursor.
The other part of the mechanism is a tool that emits the process table in such a flat file form in the first place, repeatedly at intervals, interspersing its output with a file separator. We almost, but do not quite, have this.
One can feed it the output of the top
command in its "batch" mode:
while top -b all | sed -e '1,8s/^/#/' -e $'1i\n\f'
do
sleep 1
done |
console-flat-table-viewer --header-count 1
The sed
turns into comments the part of the top
output that is not actually the process table, which would otherwise confuse the table layout, and adds in the file separator. In the table encoding that matches what top
outputs, what the console-flat-table-viewer
manual calls the space
format, the file separator is the ␌ character, which has to be escaped for sed
to not strip it. (ASCII has a real ␜ character, which console-flat-table-viewer
understands for ascii
tables. This is not the encoding that top
outputs, though.)
I add the ␌ character with sed
to reduce display flicker, so that console-flat-table-viewer
does not receive it until immediately before the rest of the table data. An alternative, which flickers slightly more because there is an interval between the ␌ and the table data during which console-flat-table-viewer
displays a blank table, is to simply invoke printf
first.
Similarly, the commands that generate the output go in the condition of the while
loop, so that the broken pipe when I quit console-flat-table-viewer
causes the loop to gracefully terminate.
But this does not provide control over columns.
One can alternatively feed it the output of the FreeBSD procstat
command:
while printf 'f' ; procstat -a
do
sleep 1
done |
console-flat-table-viewer --header-count 1
This has a limited degree of control over columns with its various options, but not fine grained control. It is also somewhat problematic because several of its options cause it to break the tabular format by emitting unescaped whitespace in the middle of fields.
One could use the BSD ps
command:
while ps -a -x -o "pid,ppid,user,logname,time,state,wchan,start,comm" | sed -e $'1i\n\f'
do
sleep 1
done |
console-flat-table-viewer --header-count 1
The GNU-licensed ps
command on Ubuntu Linux has a different command-line syntax, which is several questions and answers in its own right, but one could employ it likewise.
Whilst this does have fine-grained control over the columns, it again does not properly escape whitespace within fields.
The BSDs have had a way of dealing with this since 4.4BSD in the 1990s. It is the vis()
encoding system, which various BSD flat tables (such as /etc/fstab
) already employ. console-flat-table-viewer
already knows how to decode it, too. It would be very welcome for ps
or procstat
, preferably both, to be able to vis
-encode their outputs.
The obvious next step for GUI users is to have a (currently hypothetical) utility that substitutes for console-flat-table-viewer
, taking the same input and leaving the input side of the pipeline the same, and displays continually updated tables with a GUI instead of a TUI.
Then we could have a flexible mechanism made of composable tools joined together with pipes. ☺
Further reading
- Jonathan de Boyne Pollard (2019).
console-flat-table-viewer
. nosh Guide. Softwares. - "Roadmap". The nosh project. FreeBSD Quarterly Status Update 2018Q4.
- Robert N M Watson (2017-01-14). procstat. FreeBSD General Commands Manual.
ps. FreeBSD General Commands Manual. 2018-03-13.
vis. FreeBSD General Commands Manual. 2013-02-19.- https://unix.stackexchange.com/a/511530/5132
edited 2 days ago
answered Apr 8 at 13:06
JdeBPJdeBP
38k478183
38k478183
add a comment |
add a comment |
Yuri Geinish is a new contributor. Be nice, and check out our Code of Conduct.
Yuri Geinish is a new contributor. Be nice, and check out our Code of Conduct.
Yuri Geinish is a new contributor. Be nice, and check out our Code of Conduct.
Yuri Geinish is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f511202%2ftop-like-command-configurable-from-command-line%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
@msp9011 like, only show the
COMMAND
column, which should be specified on the command line.– Yuri Geinish
Apr 8 at 11:41