Main Page | Report this Page
Computers Forum Index  »  Computer - Databases - Oracle (Misc)  »  adding counter...
Page 1 of 1    

adding counter...

Author Message
orion...
Posted: Thu Oct 29, 2009 2:04 am
Guest
Hi,
I need some help.
Shell script counter. i need to add condition to check if counter is
more than 10 and longer than 3 hours? it runs every 5 mins. it only
check count and send email right now.
it runs in cron as below
gregcount.ksh gregdb 10 > /tmp/gregcount.out 2> /tmp/gregcount.err

if [ $# -ne 2 ]
then echo "Usage: $0 DB MAX_ALLOWED "
exit
fi
DB=$1
MAX_ALLOWED=$2
MAIL_LIST=bob
CNT=`${ORACLE_HOME}/bin/sqlplus -s \/nolog << EOF | tail +1 2>/dev/
null
set pages 0
set head off
set feedback off
set termout off
set verify off
set echo off
connect system/${SYS_PWD} at (no spam) ${DB}
select count(*) from greg.counter;
EOF`
# echo $CNT

if [ $CNT -gt $MAX_ALLOWED ]
then mailx -s "too many ( ${CNT} ) in $1 !! " $MAIL_LIST < /dev/null
else
echo "All is well !! "
fi
 
Mark D Powell...
Posted: Thu Oct 29, 2009 2:53 pm
Guest
On Oct 28, 10:04 pm, orion <jack22... at (no spam) gmail.com> wrote:
Quote:
Hi,
I need some help.
Shell script counter. i need to add condition to check if counter is
more than 10 and longer than 3 hours? it runs every 5 mins. it only
check count and send email right now.
it runs in cron as below
gregcount.ksh gregdb 10 > /tmp/gregcount.out 2> /tmp/gregcount.err

if [ $# -ne 2 ]
then echo "Usage: $0 DB MAX_ALLOWED "
exit
fi
DB=$1
MAX_ALLOWED=$2
MAIL_LIST=bob
CNT=`${ORACLE_HOME}/bin/sqlplus -s \/nolog << EOF | tail +1 2>/dev/
null
set pages 0
set head off
set feedback off
set termout off
set verify off
set echo off
connect system/${SYS_PWD} at (no spam) ${DB}
select count(*) from greg.counter;
EOF`
# echo $CNT

if [ $CNT -gt $MAX_ALLOWED ]
then mailx -s "too many ( ${CNT} ) in $1 !! " $MAIL_LIST < /dev/null
else
echo "All is well !! "
fi

Here are two links that should be of interest. The first calculates
the seconds between to counters and the second has the C program
source for a time difference calculator.

http://www.askdavetaylor.com/date_math_in_linux_shell_script.html

http://www.unixtutorial.org/2008/06/unix-scripting-time-and-date/

HTH -- Mark D Powell --
 
 
Page 1 of 1    
All times are GMT
The time now is Mon Nov 30, 2009 8:33 am