- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: I need a script ....
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
Discussions
Discussions
Forums
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
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-04-2006 04:44 AM
тАО09-04-2006 04:44 AM
The log file looks like:
18:26:50 Maximum server connections 32...
and I want to compare it with the actual time and if it differ more than 5 minutes it sends me an email or a message to the screen. I have an HP-ux and Informix DB which the log is taken. It hangs every three weeks and it doesn't show nothing else that only stop to write on the log file. If you have another idea how to notice or you have a similar experience that the DB act like in this case you are pleased to help me on this.
I have tried everything like updating the DB, OS with no results.
Thank in advance to all who can help me
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-04-2006 05:55 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-04-2006 06:45 AM
тАО09-04-2006 06:45 AM
Re: I need a script ....
LOGF=/tmp/dbmon.log
if [ -s $LOGF ] ; then
PREV=$(cat $LOGF)
else
PREV=0
fi
CURR=$(cat /var/adm/syslog/syslog.log|
grep "Maximum server connections" |wc -l)
if [ $CURR -le $PREV ]; then
echo ALERT|mailx -s "DB HANGS" your@mail
fi
echo $CURR > $LOGF
Run this script from crontab each 5 minutes.
The script counts strings with the needed pattern. If this number does not differ in 5 minute, you receive mail
HTH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-04-2006 02:33 PM
тАО09-04-2006 02:33 PM
Re: I need a script ....
Your script will use the time from the 10th before last line, as that is the tail default.
Also, why not make awk do all the hard work while it has the data?!
eg:
TOTAL_LOG_SECONDS=$(tail -1 $1 | awk -F"[: ]" '{print $1*3600 + $2*60 + $3}')
or by having awk also find the end:
TOTAL_LOG_SECONDS=$(awk -F"[: ]" 'END{print $1*3600 + $2*60 + $3}' $1)
And finally here is a tweak which remembers the last piece of string that looked like a timestamp in the beginning of a line and then uses that at the END.
TOTAL_LOG_SECONDS=$(awk '/^..:..:/{t=$1} END{split(t,a,":"); print a[1]*3600 + a[2]*60 + a[3]}' $1)
awk could also do the current time, and perl even more easily so.
Cheers,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-04-2006 02:54 PM
тАО09-04-2006 02:54 PM
Re: I need a script ....
Voda,
Here is an other approach
You could create a reference file with the same time as last log file modification time.
Then when the script runs again you expect to see a more recent file.
If not, sound the bell.
In psuedo code:
touch -r $logdir/log $logdir/ref
while (1) {
wait 10 minutes
if (find $logdir -name log -newer ref)
then {
# all is well, update reference file
touch -r $logdir/log $logdir/ref
} else {
tail $logdir/log | mail ...
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-04-2006 07:20 PM
тАО09-04-2006 07:20 PM
Re: I need a script ....
you are absolutely right that my suggestion does not read the correct line - thanks for pointing that out: I feel embarrassed.
And if I could handle awk as well as you, I would probably have done that...
Voda,
you can remedy my prior suggestion by changing the line
tail $1 | read a b
to
tail -1 $1 | read a b
However, finding the root cause would be better.
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-05-2006 01:45 AM
тАО09-05-2006 01:45 AM
Re: I need a script ....
Thanks for your help. The script is working great.
Regards
Endrin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-05-2006 01:52 AM
тАО09-05-2006 01:52 AM