return to PRS Technologies website
#!/usr/bin/ksh
###############################################################################
#
# Module: onmode_f.sh
# Author: Peter R. Schmidt
# Description: Free up unused virtual memory segments
# using onmode -F
# Intended to be run in the cron
#
# Change Log
#
# Date Name Description.................
# 06/15/01 Peter R. Schmidt Start Program
#
###############################################################################
if [ "x$DBTEMP" = "x" ]
then
DBTEMP=/tmp
fi
BEFORE=$DBTEMP/onmode_f.1.$$.tmp
AFTER=$DBTEMP/onmode_f.2.$$.tmp
MESSAGE=$DBTEMP/onmode_f.3.$$.tmp
if [ "x$INFORMIXDIR" = "x" ]
then
. /db.env # Set the informix environment
fi
if [ "x$INFORMIXHOME" = "x" ]
then
echo "Error in onmode_f.sh: the INFORMIXHOME environmental has not been set"
exit 1
fi
LOGDIR=$INFORMIXHOME/logs
if [ ! -d $LOGDIR ]; then
mkdir $LOGDIR
fi
LOGFILE=$LOGDIR/onmode_f.log
################################################################################
onstat -g seg | grep -v "Informix Dynamic Server" > $BEFORE
CNT_BEFORE=`grep -c " V " $BEFORE`
onmode -F
if [ $? != 0 ]; then
echo "Error when running onmode -F"
exit 1
fi
onstat -g seg | grep -v "Informix Dynamic Server" > $AFTER
CNT_AFTER=`grep -c " V " $AFTER`
if [ $CNT_BEFORE != $CNT_AFTER ]; then
date >> $MESSAGE
echo "Informix virtual memory segments have been reduced from $CNT_BEFORE to $CNT_AFTER" >> $MESSAGE
echo >> $MESSAGE
echo " BEFORE:" >> $MESSAGE
cat $BEFORE >> $MESSAGE
echo >> $MESSAGE
echo " AFTER:" >> $MESSAGE
cat $AFTER >> $MESSAGE
echo >> $MESSAGE
echo "--------------------------------------------------------------------------------" >> $MESSAGE
echo >> $MESSAGE
cat $MESSAGE >> $LOGFILE
cat $MESSAGE
fi
rm -f $BEFORE
rm -f $AFTER
rm -f $MESSAGE
################################################################################