Solved

unix shell scripting for alert log monitoring and sending mail

Posted on 2010-11-17
10
1,410 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
10 Comments
 
LVL 2

Expert Comment

by:ExpertSteve
ID: 34167030
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
ID: 34171652
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
ID: 34175885
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:bond7
ID: 34179746
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
ID: 34180283
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
 

Author Comment

by:bond7
ID: 34201640
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
ID: 34207951
Did you follow http://www.crypt.gen.nz/papers/logsurfer.html
How far did you get?
0
 

Author Comment

by:bond7
ID: 34238489
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
ID: 34427987
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
ID: 34439787
Cannot use the solution because of corporate restrcitions
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Over the years I've spent many an hour playing on hardened, DMZ'd servers, with only a sub-set of the usual GNU toy's to keep me company; frequently I've needed to save and send log or data extracts from these server back to my PC, or to others, and…
Utilizing an array to gracefully append to a list of EmailAddresses
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

740 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