CLI: System Monitoring
From: Alan Connor (zzzzzz_at_xxx.invalid)
Date: 07/26/05
- Next message: stefan patric: "Re: 3 systems new user advice needed"
- Previous message: rkiesling_at_mainmatter.com: "Linux Frequently Asked Questions with Answers (Part 6 of 6)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: stefan patric: "Re: 3 systems new user advice needed"
- Previous message: rkiesling_at_mainmatter.com: "Linux Frequently Asked Questions with Answers (Part 6 of 6)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|