Cover V10, I09

Article
Figure 1
Figure 2
Figure 3
Figure 4
Figure 5
Figure 6
Figure 7
Figure 8
Figure 9
Figure 10
Figure 11
Listing 1
Listing 2
Listing 3
Listing 4
Sidebar 1
Sidebar 2
Sidebar 3
Table 1
Table 2
Table 3
Table 4

sep2001.tar


Listing 3 run_iostat_logging

#!/usr/bin/ksh
#
# Name: run_iostat_logging
#
# Purpose: to record iostat information to a database
#
# Date: Jan 2000
#
# Required Parameters:
# -------------------------------------------------------------------------
# host: the name of the UNIX machine to monitor
# database users: the name a user to log into the database with
# passfile: a file containing the password of the database user
# server: the name the Sybase database
# delay: the number of seconds to sleep between iostat reports
#
# Optional Parameters:
# -------------------------------------------------------------------------
# None.
#
# Change History:
#
# Date          Name            Comments
# _________________________________________________________________________
#

if [[ $# -ne 4 ]]
then
  echo
  echo usage: $0 user passfile server delay
  echo
  exit -1
fi

HOST=`hostname`
SQLUSER=$1
PASSFILE=$2
SERVER=$3
DELAY=$4

COUNT=`lspv | grep -c hdisk`
let "COUNT = COUNT + 1"
FILE1=/tmp/iostat.1.$$
FILE2=/tmp/iostat.2.$$
if [[ $HOST != 'none' ]]
then

   while [[ 1 -eq 1 ]]
   do
      iostat 1 2 > $FILE1
      D=`date +'%b %d %Y %I:%M%p`
      tail -$COUNT $FILE1 > $FILE2
      mv $FILE2 $FILE1

      while [[ `cat $FILE1 | grep -c "  "` -gt 0 ]]
      do
         cat $FILE1 | sed "s/  / /g" | sed "s/^ //g" > $FILE2
         mv $FILE2 $FILE1
      done

      cat $FILE1 | sed "s/ /,/g" > $FILE2
      mv $FILE2 $FILE1

      cat $FILE1 | sed "s/^/$D,$HOST,/g" > $FILE2
      mv $FILE2 $FILE1

      cat $FILE1 | grep -vE "Disks|0.0,0.0,0.0,0,0$" > $FILE2
      mv $FILE2 $FILE1

      if [[ -s $FILE1 ]]
      then
         $SYBASE/bin/bcp hismon..mntr_disk in $FILE1 -S$SERVER -U$SQLUSER \
-P`cat $PASSFILE` -c -t"," -b 1 fi sleep $DELAY done fi exit 0