- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Where is this script failing?
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2003 06:38 PM
09-20-2003 06:38 PM
Part of the script should check for one system's Oracle listener (an AS/400) up status between Sunday 5 PM and Saturday 6 PM (Pretty much most of the week!).
The other part should check for a backup system (MS/SQL) Oracle listener up status between 5 PM Sat and 6 PM Sun.
The problem is that I was paged after the AS/400 listener was turned off on Sunday morning, sometime around 1 AM. This shouldn't happened, where did I go wrong in the attached script? Thanks!
It has to be something very simple... I am sure when told where the problem is I will be ready to bang my head on the wall. But I would appreciate the always wise advise given here.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2003 10:27 PM
09-20-2003 10:27 PM
Re: Where is this script failing?
I do not know tnsping, but could it have been momentarily unavailable at the time in question?
You might also consider changing your grep, as you will get $?=0 for e.g. "connection OK" as well as for "connection absolutely not OK".
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2003 02:26 AM
09-21-2003 02:26 AM
Re: Where is this script failing?
Thanks for your reply but neither of your two scenarios ocurred.
1. The listener in question (AS/400) was turned down when the email notification started. The thing is, no email notification should have gone out, because it should only send these if that listener is down and it is later than 6 PM on Sunday or earlier than 5 PM Saturday, or weekdays. It was around 1 AM Sunday when it did it.
1. tnsping will return something without the OK if the listener is not up, some TNS error, I can't remember exactly. So the grep should not matter, if the listener is not up, there will be no "OK".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2003 03:54 AM
09-21-2003 03:54 AM
Re: Where is this script failing?
spaces in the right places, e.g.
$DAYOFWK = Sat
$DAYOFWK = Sun
will probably work out miracles.
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2003 05:22 AM
09-21-2003 05:22 AM
Re: Where is this script failing?
second thoughts: spaces alone might not do it. I am not familiar with your if-syntax and would have preferred it differently. Please, try this small script out for yourself:
#if [ "$1" = Sat -a "$2" -lt 18 ] || [ "$1" = Sun -a "$2" -gt 17 ]
if [ $1 = Sat ] && [ $2 -lt 18 ] || [ $1 = Sun ] && [ $2 -gt 17 ]
then
echo true: $1 $2
else
echo par 1 not Sat combined with par 2 being smaller than 18
echo or par1 not Sun combined with par 2 being bigger than 17
fi
#end of script
Try running it with either the first or the second line uncommented and compare. There is a difference for e.g. par1=Sat and par2=17
Try also running it like this:
# sh -x <script> Sat 17
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2003 01:48 PM
09-21-2003 01:48 PM
Re: Where is this script failing?
If I understand correctly, you want to check the MS/SQL between 5 PM Sat and 6 PM Sun, and check the Oracle at other times.
So, why don't you use this algo:
if 'between 5 PM Sat and 6 PM Sun'
check MS/SQL
else
check Oracle
fi
Also, you may want to include more brackets in your "if" conditions to eliminate ambiguity.
Rgds,
Shahril
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2003 02:54 PM
09-21-2003 02:54 PM
Re: Where is this script failing?
Actually, I can't use an else. The reason is simple:
A. I want to check the MS/SQL Oracle listener between 5 PM Sat and 6 PM Sun, but also...
B. I want to check the AS/400 Oracle listener between 5 PM Sun and 6 PM Sat.
So, as you can see, there is a time on Saturday when both of them should be up, between 5 and 6 PM, that's why the two IF statements. Also, this window where both need to be up may have to increase.
What I would like to hear is for someone to explain why the statements I used are not working, where the error is, or if there is another way to write them that would work.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2003 06:19 PM
09-21-2003 06:19 PM
Re: Where is this script failing?
I think you should award the points to John. I tried his space tip, and it worked for me.
Your problem seems that the Oracle listener was checked on Sun 1am when it should not have. This was because your [ $HOUR -lt 18 ] condition resolved to TRUE.
With my system time as 8pm on Monday, I used:
if [ $DAYOFWK = Mon ] && [ $HOUR -lt 18 ] || [ $DAYOFWK = Tue ] && [ $HOUR -gt 17 ] || [ $DAYOFWK = Sat ] || [ $DAYOFWK = Sun ] || [ $DAYOFWK = Wed ] || [ $DAYOFWK = Thu ] || [ $DAYOFWK = Fri ]
This is similar to being 8pm on a Saturday based on your requirements.
And it did NOT run my TRUE statement as expected.
1. You can use the flwg substitution command to make it easier for you:
s/=/ = /g
2. Based on the script you uploaded, your Wednesday condition had a typo:
$DAYOFW=Wed should be $DAYOFWK = Wed
Rgds,
Shahril
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2003 08:59 PM
09-21-2003 08:59 PM
Re: Where is this script failing?
....
# Between Sun 5:00 PM on Sun and Sat 6:00 PM check Oracle AS/400 listener
if [ $DAYOFWK=Sat ] && [ $HOUR -gt 17 ] || [ $DAYOFWK=Sun ] && [ $HOUR -lt 18 ] || [ $DAYOFWK=Mon ] || [ $DAYOFWK=Tue ] || [ $DAYOFW=Wed ] || [ $DAYOFWK=Thu ] || [ $DAYOFWK=Fri ]
then ...
Change the statement four the $HOUR variable they are placed in your if statement in the wrong order.
Roland
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2003 09:15 PM
09-21-2003 09:15 PM
Re: Where is this script failing?
Correct is this:
# Between Sun 5:00 PM on Sun and Sat 6:00 PM check Oracle AS/400 listener
if [ $DAYOFWK=Sat ] && [ $HOUR -gt 16 ] || [ $DAYOFWK=Sun ] && [ $HOUR -lt 19 ] || [ $DAYOFWK=Mon ] || [ $DAYOFWK=Tue ] || [ $DAYOFW=Wed ] || [ $DAYOFWK=Thu ] || [ $DAYOFWK=Fri ]
....
HTH
Roland
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2003 09:28 PM
09-21-2003 09:28 PM
Re: Where is this script failing?
If you try the tester script, checkif, in my former posting, it will show this when the first line is used:
# sh -x ./checkif Sat 17
+ [ Sat = Sat -a 17 -lt 18 ]
+ echo true: Sat 17
true: Sat 17
Using the second line instead shows this:
# sh -x ./checkif Sat 17
+ [ Sat = Sat ]
+ [ 17 -lt 18 ]
+ [ 17 -gt 17 ]
+ echo par 1 not Sat combined with par 2 being smaller than 18
par 1 not Sat combined with par 2 being smaller than 18
+ echo or par1 not Sun combined with par 2 being bigger than 17
or par1 not Sun combined with par 2 being bigger than 17
it makes three evaluations, which I believe is unintended.
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2003 04:04 AM
09-23-2003 04:04 AM
Re: Where is this script failing?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2003 04:26 AM
09-23-2003 04:26 AM
Re: Where is this script failing?
Use lines in cron like:
# Check Sunday 5PM thru Saturday 6PM
00 17-23 * * 0 /script/to/run
00 0-23 * * 1-5 /script/to/run
00 0-18 * * 6 /script/to/run
# Check between 5PM Sat and 6PM Sun
00 17-23 * * 6 /script/to/run1
00 0-18 * * 0 /script/to/run1
You can change the minutes column (first column) to run however often you like.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2003 04:32 AM
09-23-2003 04:32 AM
Re: Where is this script failing?
Make sure you are not executing the wrong file by providing full path.
After you add missing spaces around '=' in 'if' statement conditions your script should work OK.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2003 04:51 AM
09-23-2003 04:51 AM
Re: Where is this script failing?
Also, thanks for noticing that error on the DAYOFWK for Wed Shahril.
John, if you post another message I'll give you the 10 after I finish running another few tests to make sure I do not run into more problems.
Oh, by the way, I am running within cron, and I do not want to split it into two scripts because there are already enough entries there to keep crowding it with more. If I can combine these two into one, I'll leave it that way, and if could integrate it into another script I also would do that; however, its frequency is not compatible with other entries I have there already. This check will run every 30 min.
Thanks everyone for you input! It's always appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2003 07:10 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2003 04:25 AM
09-24-2003 04:25 AM
Re: Where is this script failing?
By the way, I also ended up changing my statement from the form (This is only the AS/400 portion, which I want it to check between Sun 5 PM, the rest of the week, until Sat 6 PM):
if [ $DAYOFWK = Sat ] && [$HOUR -lt 19 ] || [ $DAYOFWK = Sun ] && [$HOUR -gt 16 ] || [ $DAYOFWK = Mon ] || [ $DAYOFWK = Tue ] || [ $DAYOFWK = Wed ] || [ $DAYOFWK = Thu ] || [ $DAYOFWK = Fri ]
To the following, also recommended by John:
if [ $DAYOFWK = Sat -a $HOUR -lt 19 ] || [ $DAYOFWK = Sun -a $HOUR -gt 16 ] || [ $DAYOFWK = Mon ] || [ $DAYOFWK = Tue ] || [ $DAYOFWK = Wed ] || [ $DAYOFWK = Thu ] || [ $DAYOFWK = Fri ]
For some reason, the script was still giving me false notifications with the first one, and I am still unsure as of why, maybe the syntax is totally wrong.