- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Simple Unix script (bourne/Korne) Needed!
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
06-12-2003 05:39 AM
06-12-2003 05:39 AM
I need a simple UNIX script (Bourne/Korne/Tcsh) that someone might have already done or would know how to do with the following requirements:
The script would run every 10 or 15 minutes and look inside a certain application log for the following strings:
2003/06/08 20:08:52 :MGR ,26317:6501 [-07832 Incremental database backup completed successfully.] : Log :
2003/06/08 20:14:13 :MGR ,26317:6501 [-07832 Incremental database backup completed successfully.] : Log :
2003/06/08 20:19:44 :MGR ,26317:6501 [-07832 Incremental database backup completed successfully.] : Log :
I will also attach a sample of the log since the above does not show up on a single line.
The Incremental database backup completed successfully messages show up every 5 or 6 minute intervals as shown above which indicates that there are no problems.
The script will check the log file for the latest [-07832 Incremental database backup completed successfully.] & compare the message date and time time to the current date and time. If no new incremental successful message is in the log within a 10 minute period then it will send an opcmsg (ITO Alert) stating that the incremental backup failed.
I thought a command like this could be used somewhere in the script:
# cat oracle.log-0 | grep "Incremental database backup completed successfully" | tail -1
2003/06/08 20:19:44 :MGR ,26317:6501 [-07832 Incremental database backup completed successfully.] : Log :
Any help someone could provide would be greatly appreciated as I know there are individuals within the forums here who are very good at scripting.
Look forward to hearing from you.
Thanks...
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2003 05:44 AM
06-12-2003 05:44 AM
Re: Simple Unix script (bourne/Korne) Needed!
Is this a duplicated question or none of the answers given yesterday worked for you?
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x97ab44f56197d711abdc0090277a778c,00.html
Thx,
Dario
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2003 05:50 AM
06-12-2003 05:50 AM
Re: Simple Unix script (bourne/Korne) Needed!
http://bizforums.itrc.hp.com/cm/QuestionAnswer/1,,0x97ab44f56197d711abdc0090277a778c,00.html
in any case...
The following script may need some minor modifications to excape any special characters in the sed statements.
#! /usr/bin/ksh
x=1
while x=1
do
cat logfile | grep 07832 Incremental database backup completed successfully.] : Log : >> newlogfile
cat logfile | sed 's/07832 Incremental database backup completed successfully.] : Log : //#07832 Incremental database backup completed successfully.] : Log : /g' > logfile2
mv logfile2 logfile
sleep 600
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2003 06:19 AM
06-12-2003 06:19 AM
Re: Simple Unix script (bourne/Korne) Needed!
The actual script which would run in cron would check the log file for the latest [-07832 Incremental database backup completed successfully.] message & compare the message date and time time to the current sytem date and time. If no new incremental successful message is in the log within a 10 minute period then it will send an opcmsg (ITO Alert) stating that the incremental backup failed.
Thanks in advance for your help...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2003 06:31 AM
06-12-2003 06:31 AM
Re: Simple Unix script (bourne/Korne) Needed!
we gave you ideas on how to get started. If you wanted us to write the entire thing for you, then all you to do is ask.
there is a lot of nice people on the forum
peace
Donny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2003 06:50 AM
06-12-2003 06:50 AM
Re: Simple Unix script (bourne/Korne) Needed!
x=1
while x=1
do
time=$(date +'%Y/%m/%d %H:%M:%S')
min=$(echo $time | awk -F: '{print $2}'
((ttime=$min-10))
day=$(date +'%d')
year=$(date +'%Y')
month=$(date +'%m')
#bs gets all successful backups from today
bs=$(cat file | grep $year | grep $month | grep $day | grep "Incremental database backup completed successfully")
bstime=$(echo $bs | awk -F: '{print $2}')
#finds 10 or less time difference
((timediff=$time-$bstime))
if [ $timediff <= 10 then ]
echo $bs > logfile
else
#whatever actions to send alert
fi
sleep 600
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2003 07:10 AM
06-12-2003 07:10 AM
Re: Simple Unix script (bourne/Korne) Needed!
if [ $"timediff <= 10 then]
should be
if [$"timediff <= 10 ]
then
- i tend to think faster than I type sometimes.
Glad to see that this was helpful though
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2003 07:16 AM
06-12-2003 07:16 AM
Re: Simple Unix script (bourne/Korne) Needed!
Firs off, are you really looking for failures or only success? IMHO kind of silly to look for success, when the log already shows that. I guess you could want it for reporting, but what your getting out is not of much value to a report.
Second, you say you want it to run every 10 or 15 minutes in cron. How does your application schedule this? What happens if your app runs 2 increments in the time the cron job runs 1 time? Or what happens if the increment does not change within 2 cron jobs?
Backups are usually dependant on external issues themselves, so writing a time dependant script when you have an I/O dependant application is not the best way to handle tracking, logging, or reporting, and in fact depending on what your doing this could be a nice shot to the foot.
I'd recommend you make a wrapper for the backup script itself, intercept it's output and re-direct it where you need it to go.
Next step is to have someone code a daemon that monitors the log for changes, then acts on the changes only.
If neither of those 2 are possible, talk to the software vendor to see if there is any way you can control the output going to the log. Many 3rd party vendors are happy to work with you.
If none of the samples given work out of the site, it's because were here as students and teachers, not sub-contracters. Consider hiring a consultant for a day. Really, we need to eat too! ;)
Sincerely,
Shannon Petry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2003 07:24 AM
06-12-2003 07:24 AM
Re: Simple Unix script (bourne/Korne) Needed!
a very simple solution:
# --- start of the script here
#!/usr/bin/ksh
# first, let's count the number of times the log message appears in the log file
# don't forget to cd to the correct directory
let i=`/usr/bin/grep -c "[-07832 Incremental database backup completed successfully.]" oracle0.log`
# then let's sleep 10 minutes
sleep 600
# let's count the new number of occurences for the message
let j=`grep -c "[-07832 Incremental database backup completed successfully.]" oracle0.log`
# if j is not strictly greater than i, you have a problem...
if [ $j -le $i ]
do
# put your ITO alert here
done
# end of the script
Cheers,
FiX
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2003 07:31 AM
06-12-2003 07:31 AM
Re: Simple Unix script (bourne/Korne) Needed!
I will be testing the various scripts today.
Everyone in these forums is of great assistance. Scripting is my current weakness but an area which I am working on improving.
Regards,
Shaun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2003 07:52 AM
06-12-2003 07:52 AM
SolutionSorry, Shaun, I made quite a stoopid mistake in the script I wrote...
when I wrote:
---
if [ $j -le $i ]
do
# put your ITO alert here
done
---
I, of course, meant:
---
if [ $j -le $i ]
then
# put your ITO alert here
fi
---
It's, of course, "if [] then [] fi"...
Sorry about that...
FiX
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2003 09:45 AM
06-12-2003 09:45 AM