CLI: System Monitoring

From: Alan Connor (zzzzzz_at_xxx.invalid)
Date: 07/26/05


Date: Tue, 26 Jul 2005 05:13:44 GMT

CLI - Command Line Interface System Monitoring.

The watch command (man watch) is useful for this. Here's an
example script, which I run in a seperate screen window (man
screen: a networking textmode window manager). It could also be
run an xterm.

("xterm" is used here to mean any x-terminal-emulator.)

watch -d watch.sh

As you can see below, it is just a list of commands that could
be entered on the command line. (for the for loop, just replace
the newlines with ";") The for loop is simply a more complex
command that keeps the command itself from running until the PPP
interface is up by grepping the output of /sbin/ifconfig. The
"&>" sends its output (stdout and stderr) to /dev/null so
that it doesn't clutter up the screen needlessly.

For the top command, the plain text output option "b" is chosen,
then sed is used to peel off and display just the 3rd and 4th
lines of output.

The ps utility has many options. Choose the ones that suit your
needs best.

comp.unix.shell & comp.unix.questions

--------

#!/bin/sh # top line, don't include the blank dashed lines
# watch.sh

/bin/ps aux
free
top b n 1 | sed -n '3,4p'
if /sbin/ifconfig | grep ppp0 &>/dev/null
then /usr/sbin/pppstats -w 2 -c 1
fi

------

Make the script executable with:

chmod +x watch.sh

As root, move it to a directory in your PATH.

echo $PATH

/usr/local/bin/ would be a common choice.

Call it manually as above, or like so for screen and xterm:

screen -t WA 7 watch -d watch.sh

"WA" is the window title and "7" is the window number.

xterm -title "System Watch" -rv -fn "-schumacher-clean-medium-r-normal--10-100-75-75-c-50-iso646.1991-irv" -geometry 152X59+0+0 -e "watch -d watch.sh"

You can change the title, font "-fn '-schumacher...' at will, and
the geometry may need tweaking for your screen. Play with the two
numbers on the left. The first one is the number of columns, and
the second one is the number of lines.

Most CLI people these days run from an x-terminal-emulator so
that the few X apps we need to use are handily available, rather
than running X in a seperate tty. Like graphical browsers (when
it is necesssary to see images. Most images on the Web are
garbage, and a textmode browser is faster and eliminates that
garbage.

AC

-- 
People who post through google take and take and never give
back. Ever seen one of them help anyone? If they are asking
about anything but how to use a real newsreader, PLEASE DON'T
HELP THEM.    ----------->    news.software.readers


Relevant Pages

  • Re: CSI Miami tonite
    ... >> Thanks for the reminder, ... you may not want to actually watch the whole Program on your PC ... > or look it up in the WinXP Help thingy)... ... > That should (as you can prolly see from the Command Line?), ...
    (uk.people.silversurfers)
  • Re: Disabling Shell Access in vi
    ... I'm developing a menu driven script, that is not to allow users to ... I'm going to have their shell, ... using the view command. ... to hire goofs to watch your back. ...
    (comp.unix.shell)
  • Falcon Command Chronograph - Replica Watch Fake
    ... Falcon Command Chronograph - Replica Watch Fake ... Falcon Command Chronograph Link: http://www.watchesprice.net/Replica-Chase-Durer-4883.html ...
    (rec.travel.misc)
  • Re: Confused by unexpected redirection behavior when using the watch command
    ... Pipe the output of watch through cat, ... Cool that that works(command is sadly not useful the way i thought it ...
    (comp.unix.shell)
  • Re: Split
    ... i use the split command to split my avi's if the run over 700 megs. ... i use the cat command to recombine them. ... I don't see the point in splitting up an avi file, as you won't be able to watch it in split form. ...
    (alt.linux)