- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- automate monitoring script in hpux. promise of goo...
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
03-26-2008 02:27 AM
03-26-2008 02:27 AM
/disc01/script/monitor_oracle.sh
what is the best to put inside my crontab:
1. 15 * * * * * /disc01/script/monitor_oracle.sh >> /appl/oraclestatus.txt
2. 0 7 * * * /disc01/script/monitor_oracle.sh
but for option 2, where is the output will be directed to?
the script that we would like to run is more less like the attachment.
hope to hear from you. thanks a lot
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2008 02:53 AM
03-26-2008 02:53 AM
Re: automate monitoring script in hpux. promise of good points
ps -eaf | grep ora
command in u shell script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2008 03:06 AM
03-26-2008 03:06 AM
Solution>but for option 2, where is the output will be directed to?
There is no way log of your script will be saved in some location as it is not mentioned in script or in command of crontab entry. Only way out is you can redirect output as in entry 1 or else redirect output under shell script only so there is no need of redirection in crontab entry.
-=ShRi=-
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2008 04:06 AM
03-26-2008 04:06 AM
Re: automate monitoring script in hpux. promise of good points
TIME=$(date %.%.%) (* see man pages for % arguements *)
echo "Starting IQ" "\t" $TIME
####
2. 0 7 * * * /disc01/script/monitor_oracle.sh >> /dir/logfile.txt 2>&1
You want 2>&1 to capture output and errors and redirect them into the same file. So you should also add 2>&1 to the first entry.
1. 15 * * * * * /disc01/script/monitor_oracle.sh >> /appl/oraclestatus.txt 2>&1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2008 04:14 AM
03-26-2008 04:14 AM
Re: automate monitoring script in hpux. promise of good points
Line 1 - You are running the script at 15 minutes after every hour of every day of every month....
Line 2 - You are running the SAME script at 7am everyday of every month....
>>>>>>> If that is what you want, then ok. But looks like you got alot of time between checking. And for the second line, why not just append it to the same file as line one. It's the same script.
Next let's look at your script:
Your grep entries are specific to your environment, but you seem to do a basic check to see if the oracle process is running. Now I've seen where the database went down, but oracle processes got left up and hung, so that doesn't really mean the the database is up and working properly.
And your hourly script only sends results to a file. Guess I might tend to send some kind of email alert if you don't have a good result & append to the logfile. You might consider adding this to your script. Cause when you monitor (even hourly) you want alerted as soon as it detects anything that might be a problem.
Just a couple thoughts,
Regards,
Rita
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2008 04:31 AM
03-26-2008 04:31 AM
Re: automate monitoring script in hpux. promise of good points
> PS=`ps -eaf | grep asiqsrv12 | grep inside | grep -v grep | wc -l`
Never, ever use grep to find programs by name. grep has no concept of where the program's name is located and will anywhere on the command line. If the program's name is asiqsrv12 then tell ps to find the exact match(es) for you:
UNIX95=1 ps -C asiqsrv12
This eliminates the extra grep -v and also eliminates mistakes like finding asiqsrv123 or ABasiqsrv12 (which grep will do). ps knows the exact process name. There is no need to use extra options (-eaf) since all you want is a process count. Now if there are multiple copies of asiqsrv12 running and you need to refine the list by searching for inside (insides.cfg? maybe /SYB_02/db/insides.cfg) then using grep is OK. But use the largest pattern string to avoid mistakes. And also use grep to count for you:
PS=$(UNIX95=1 ps -C asiqsrv12 | grep -c asiqsrv12)
Note also that back ticks (reverse apostrophes or grave accent marks) are deprecated. Use $(...) instead (see the man page for sh-posix or ksh)
For cron (and at and batch), always use a redirect of the output in order to put the details into a logfile. And sometimes, error messages are sent to stderr so redirect both stdout and stderr to a file:
15 * * * * * /disc01/script/monitor_oracle.sh >> /appl/oraclestatus.txt 2>&1
0 7 * * * /disc01/script/monitor_oracle.sh >> /appl/oraclestatus.txt 2>&1
The construct: 2>&1 means: take stderr (2) and redirect it into file 1 (&1) which is stdout. As mentioned before, always use a timestamp so you can tell when the message occurred. Using YYYYMMDD.HHMM will allow exact searches:
echo "$(date +%Y%m%d.%H%M%S) IQ is running, not restarting"
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2008 04:37 AM
03-26-2008 04:37 AM
Re: automate monitoring script in hpux. promise of good points
Would it be more wise to make the script push the status to a mailbox instead?
Also, as Rita mentioned, you have decide on a right frequency for the collection of the monitoring status.
revert.
kind regards
yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2008 10:30 PM
03-26-2008 10:30 PM
Re: automate monitoring script in hpux. promise of good points
Alternately if you want to run it every 15 minutes, you should use:
0,15,30,45 * * * * * /disc01/script/monitor_oracle.sh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2008 10:48 PM
03-26-2008 10:48 PM
Re: automate monitoring script in hpux. promise of good points
below something you can try and see if it meets your requirements:
todo: Add a similar entry in your crontab
#*******************************************************************************
# min|hour |day |month|day |script
# | |of mo| |of wk|
#----|-----|-----|-----|-----|--------------------------------------------------
#*******************************************************************************
00,15,30,45 * * * * /disc01/script/monitor_oracle.sh | /bin/mailx -s "Oracle Monitor:: DB Status ($(date +\%H\%M)) " youremailaddress@mydomain.mu >/dev/null 2>&1
#*******************************************************************************
# END OF TABLE day0->Sunday day6->Saturday
#*******************************************************************************
hope this helps!
kind regards
yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2008 12:49 AM
03-27-2008 12:49 AM
Re: automate monitoring script in hpux. promise of good points
take care that if your script will run when the backup of teh database or backup of the whole server you will log a ot of message about "database not running".
To avoid this in the script that will perform the backup touch a flag file 'backup-is-running' and in your monitor script check the existence of teh same.
Just my .02$
HTH,
Art
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2008 01:09 AM
03-27-2008 01:09 AM
Re: automate monitoring script in hpux. promise of good points
if you want to implement the steps as mentioned by Arturo above, then modify your script as follows:
#*******************************************************************************
# min|hour |day |month|day |script
# | |of mo| |of wk|
#----|-----|-----|-----|-----|--------------------------------------------------
#*******************************************************************************
00,15,30,45 * * * * [ ! -f /disc01/status/donotmonitor ] && /disc01/script/monitor_oracle.sh | /bin/mailx -s "Oracle Monitor:: DB Status ($(date +\%H:\%M)) " youremailaddress@mydomain.mu >/dev/null 2>&1
#*******************************************************************************
# END OF TABLE day0->Sunday day6->Saturday
#*******************************************************************************
Explanation:
When you dont want the script to run, just create an empty file (touch /disc01/status/donotmonitor)
hope this helps!
kind regards
yogeeraj