Solved

unix shell scripting for alert log monitoring and sending mail

Posted on 2010-11-17
10
1,397 Views
Last Modified: 2012-05-10
Hello,

I need to create a unix shell script{HP UX B11.11} to monitor the alertlog in database.
Basically it should send a mail when ORA- error occures.

If any body has similar script please help.

Best
bond
0
Comment
Question by:bond7
  • 6
  • 4
10 Comments
 
LVL 2

Expert Comment

by:ExpertSteve
Comment Utility
There's several tools that do just this.
swatch, logwatch, and logsurfer are ones I'm familiar with.

Logsurfer is the most powerful (able to do conditional things, like send email if you see a line with this string - but not if you get some other string logged within N minutes). But consequently a bit more complex to learn.

there's also Splunk, for a more centralized thing. Commercial version can send alerts on strings.
0
 

Author Comment

by:bond7
Comment Utility
Thanks Steve for response.

I am looking for HP UX shell or something similar.
We cannot buy any commercial software for this.
Please let me know if you are aware of any script for monitoring.

Best
bond
0
 
LVL 2

Expert Comment

by:ExpertSteve
Comment Utility
Logsurfer (at least - haven't tried the others) compiles fine on HPUX.
It's free. As in beer.
http://www.crypt.gen.nz/logsurfer/#download
0
 

Author Comment

by:bond7
Comment Utility
Hello ,

i checked the site, have you loked at the code of logsurfer ?
How does it work based on your experience, could you please enlighten a bit ?
0
 
LVL 2

Accepted Solution

by:
ExpertSteve earned 500 total points
Comment Utility
I cant say I've review or contributed to the source code for this project.
I've used it a fair bit, though.

You create a config file, and start logsurfer saying "Watch this log file, using this config file", and it does what you tell it.

The way i usually use it is to email every log message that is not expected - but batch them together in blocks of 100 unexpected lines, or 10 minutes, which ever comes first, so you dont get lots of individual lines, and you can see the context.

So the below config:
- ignores a bunch of expected log messages
- opens a context for ssh sessions - if they log in sucessfully, even after failing once or twice, the context is destroyed, and no message sent. If they fail, it is sent (for an internal machine only, obviously)
- batches all other unexpceted log messages and sends.

in your case, you could trivially just use a single line like:

"ORA-.*" "" - - 0 open ".*" - 100 120 10 pipe "/usr/local/bin/start-mail log@company.com Oracle error on hp360g3-401.sjc"
as the entire config.

Sample config
"syslogd: restart" - - - 0 ignore
"newsyslog.*logfile turned over" - - - 0 ignore
"last message repeated" - - - 0 ignore
"su:.*succeeded for root" - - - 0 ignore
"sendmail.*accepted for delivery" - - - 0 ignore
"sendmail.*from=" - - - 0 ignore
"sendmail.*stat=queued" - - - 0 ignore
"sendmail.*stat=Sent" - - - 0 ignore
"sm-msp-queue" - - - 0 ignore
"sm-mta" - - - 0 ignore
"64.74.33.178" - - - 0 ignore
"sendmail.*descriptors missing" - - - 0 ignore
"sshd.*Generating new 768 bit RSA key" - - - 0 ignore
"sshd.*RSA key generation complete" - - - 0 ignore
"sshd.*Could not reverse map address" - - - 0 ignore
"sshd.*Closing connection " - - - 0 ignore
"sshd.*Connection closed by remote host " - - - 0 ignore
#Host specific rdist commands.

#SSH -  Open a context for each session. Need to continue so successful
login
#with this being the only message will not get reported.
'sshd\[([0-9][0-9]*)\]' - - - 0 CONTINUE open "sshd\\[$2\\]" - 100 9200
100 report "/usr/local/bin/start-mail log@company.com ssh
authentication error on hp360g3-401.sjc" "sshd\\[$2\\]"
#If there is a failed password authentication, send a report
#
#If some authentication method succeeds, destroy context so no report sent.
#Covers password,DSA and RSA authentication
'sshd\[([0-9][0-9]*)\].*[Aa]ccepted' - - - 0 CONTINUE delete "sshd\\[$2\\]"
#Given that session was accepted, we can also ignore any later messages,
such as it closing.
'sshd\[([0-9][0-9]*)\].*[Aa]ccepted' - - - 0 rule top "sshd\\[$2\\]" - -
- 2400 ignore
#Catchall for everything else
".*" "sshd" - - 0 open ".*" - 100 120 10 pipe "/usr/local/bin/start-mail
log@company.com Logged message on hp360g3-401.sjc"

0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:bond7
Comment Utility
Hello,
I understand that I need the following in configuration files
"ORA-.*" "" - - 0 open ".*" - 100 120 10 pipe "/usr/local/bin/start-mail log@company.com Oracle error on hp360g3-401.sjc"
And the basic set up of log surfer.
I am new to unix so could you please put the steps for setting up log surfer
Most humbly

Thanks again
0
 
LVL 2

Expert Comment

by:ExpertSteve
Comment Utility
Did you follow http://www.crypt.gen.nz/papers/logsurfer.html
How far did you get?
0
 

Author Comment

by:bond7
Comment Utility
Hello,

I will be workng on it in a few days.
It is scheduled

I will update progress.

best regards
bond
0
 

Author Comment

by:bond7
Comment Utility
Hello Steve,

I cannot use the log surfer, the instance where I need to deploy it is Production Server and we cannot put freeware there  {audit issues}.
Is there any other way..I am thiking in lines of crontab and creating a shell script.
0
 

Author Closing Comment

by:bond7
Comment Utility
Cannot use the solution because of corporate restrcitions
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Background Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc... As a "Unix" shop, our only readily …
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now