Need opinions about scripting blackouts


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need opinions about scripting blackouts
# 1  
Old 11-10-2009
Need opinions about scripting blackouts

Hi All.
I am stuck and need some fresh ideas...

I am writing a script that checks to see if an Oracle db is available. The script reads an ini file to determine if there is a blackout period for certain db's... ie: we don't care if it's up or down 1700 - 700 the next morning.

The ini file looks like:

<db_name>:<priority>:<blackout_start>:<blackout_end>

so

dbs1:H:17:07 (Where 17 is 5 PM and 07 is 7 AM)

Now I have code that looks like:

Code:
 
BLACKOUT_START=`grep -i "$ORACLE_SID" $INIFILE | cut -d":" -f3`
BLACKOUT_END=`grep -i "$ORACLE_SID" $INIFILE | cut -d":" -f4`
CURRENT_HOUR=`date +%H`
if [[ $CURRENT_HOUR -ge $BLACKOUT_START || $CURRENT_HOUR -lt $BLACKOUT_END ]]; then
   if [[ $CURRENT_HOUR -ge $BLACKOUT_START && $CURRENT_HOUR -lt $BLACKOUT_END ]]; then

I can't get my head around the logic to check for the conditions when the blackout end is less then the current hour and greater then the current hour and so on...

If Anyone has any suggestions or a cool blackout processing script that I could look at I would greatly appreciate it.

Thanks.
# 2  
Old 11-10-2009
Something like that :
Code:
BLACKOUT_START=`grep -i "$ORACLE_SID" $INIFILE | cut -d":" -f3`
BLACKOUT_END=`grep -i "$ORACLE_SID" $INIFILE | cut -d":" -f4`
CURRENT_HOUR=`date +%H`

CHECK_BASE=YES
if (( BLACKOUT_START > BLACKOUT_END ))
then
   (( CURRENT_HOUR >= BLACKOUT_START ||  CURRENT_HOUR <= BLACKOUT_END )) && CHECK_BASE=
else
   (( CURRENT_HOUR >= BLACKOUT_START &&  CURRENT_HOUR <= BLACKOUT_END )) && CHECK_BASE=
fi

if [ -n "$CHECK_BASE" ]
then
   : Check database
fi

Jean-Pierre.
# 3  
Old 11-10-2009
If you need to make a lot of decisions like that, it can be easier to convert the time to absolute minutes: hours times 60 plus minutes. This lets you make direct greater than, less than tests.
# 4  
Old 11-10-2009
Thanks for the input guys.
I have it working the way I need it to now.
Login or Register to Ask a Question

Previous Thread | Next Thread

5 More Discussions You Might Find Interesting

1. UNIX and Linux Applications

opinions on video editors

What is everyones opinions on these video editors? PiTiVi Avidemux Cinelerra Kdenlive Kino Linux Video Editing: Top Five Linux Video Editors (0 Replies)
Discussion started by: cokedude
0 Replies

2. Shell Programming and Scripting

Opinions/Ideas/Suggestions needed

I'm currently developing a script to clean out certain directories based on age and name. Part of the assignment is to ensure that the cleaning of a directory is done under the user id of the owner (script is running as root). I have a few ideas on how to do this, but I'd like to hear your... (3 Replies)
Discussion started by: pludi
3 Replies

3. UNIX for Advanced & Expert Users

Opinions on db operating systems Wanted

I am interested in hearing anyones opinions on what OS they would choose to run a MySQl db and the reasons why, of course. I have a task to build a db server for a project that will be very busy if things work as the creative minds think that it will. I am running a FreeBSD box right now on... (0 Replies)
Discussion started by: smtpgeek
0 Replies

4. UNIX for Advanced & Expert Users

Opinions on memory increase

We are trying to tune a server which phsycially is maxed out on cpu. We are maxing out on memory and swapping at a rate of 20-43% of our swap space which is approx 45% of total ram. We "can" upgrade to twice the memory that we currently have but it will be costly as there are no more seats... (5 Replies)
Discussion started by: MizzGail
5 Replies

5. UNIX for Advanced & Expert Users

Runaway process. Opinions needed

not too long ago, i wrote a very short script that will bring up 4 customized xterms. The script went completely abnormal simply because of an error I had made in a while loop. This script took control of the system and rendered everything useless. The system admin team which i was part of... (4 Replies)
Discussion started by: TRUEST
4 Replies
Login or Register to Ask a Question