dbTalk Databases Forums  

adding counter

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss adding counter in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
orion
 
Posts: n/a

Default adding counter - 10-28-2009 , 08:04 PM






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}@${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

Reply With Quote
  #2  
Old   
Mark D Powell
 
Posts: n/a

Default Re: adding counter - 10-29-2009 , 08:53 AM






On Oct 28, 10:04*pm, orion <jack22... (AT) gmail (DOT) 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}@${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_ma...ll_script.html

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

HTH -- Mark D Powell --

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.