Re: vmstat output to db

  • From: Jared.Still@xxxxxxxxxxx
  • To: oracle-l@xxxxxxxxxxxxx
  • Date: Wed, 28 Jul 2004 15:49:15 -0700

Comments inline:
> I'm startign to go bald tryign to figure out how to get this to work. 
Any
> insight, suggestions or solution is greatly appreciated.

Please accept this $50.00 coupon from Jared's Wig and Toupee Emporium.

> I'm simply trying to run vmstat on an interval, send the output to a 
file
> and then load the contents of that file into the database to be reported
> against:
> #!/usr/bin/ksh
> 
> # First, we must set the environment . . . .
> export ORAENV_ASK=NO
> ORACLE_SID=SDTEST01
> export ORACLE_SID
> . oraenv SDTEST01

This should be $ORACLE_SID rather than  SDTEST01.  Just a matter of form.

> export ORACLE_HOME

No need to do this.  oraenv does it.

> 
> SERVER_NAME=`uname -a|awk '{print $2}'`

uname -n would negate the need for awk

> typeset -u SERVER_NAME
> export SERVER_NAME
> 
> # sample every 15 minutes (900 seconds) . . . .
> SAMPLE_TIME=900
> 
> while true
> do
>    vmstat ${SAMPLE_TIME} > /tmp/msg$$

Here's where you run into trouble.

vmstat <N> runs forever, at an interval of N. 

ie. the rest of your script never runs.

You may want to try something along these lines:


FILE=/tmp/test$$.vmstat

vmstat 1 > $FILE &

tail -f $FILE | while read line
do
        ( egrep -v "procs|cache") && {
                echo $line
        }
done

This starts vmstat in the background.

tail -f will continue to read the file as it grows.

The egrep filters out the text lines.

A construct such as this would be more efficient:

tail -f $FILE | egrep -v "procs|cache" | while read line
do
    echo $line
done

... but I got tired of waiting for the buffer to fill.

Jared





----------------------------------------------------------------
Please see the official ORACLE-L FAQ: http://www.orafaq.com
----------------------------------------------------------------
To unsubscribe send email to:  oracle-l-request@xxxxxxxxxxxxx
put 'unsubscribe' in the subject line.
--
Archives are at //www.freelists.org/archives/oracle-l/
FAQ is at //www.freelists.org/help/fom-serve/cache/1.html
-----------------------------------------------------------------

Other related posts: