• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 307
  • Last Modified:

Automatic E-mail Notification

How will I'm going to configure my server, so that if it encounters a system error (especially those that are redirected to the system's console or those errors that is being appended in /var/adm/messages file), it will automatically sends me an e-mail ?  Can I also configure the messages that is being appended in /var/adm/sulog and /var/adm/lastlog to automatically redirected to my e-mail ?
0
encilar
Asked:
encilar
  • 6
  • 5
  • 3
1 Solution
 
jlevieCommented:
You do those things by modifying syslod.conf. It's responsible for directing the notices and error messages to various places, including /var/adm/messages, the console, and via email. You probably don't want everything sent to you by email, but if you read the manpages for syslogd and/or syslogd.conf you'll find that you've good pretty good control on what level of notice you simply log and what you email.
0
 
encilarAuthor Commented:
Can you Please give me an example syslog.conf entry where I want to redirect Warning Messages (grep Warning) from /var/adm/messages to my E-mail Address ?
0
 
jlevieCommented:
I may have spoken to quickly. I do this for certain things on Linux but I use a named pipe implemented by a perl script that mails the message. That might or might not be possible on your system, what Unix are you on?
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!

 
encilarAuthor Commented:
I'm working with SunOS / Solaris 7 (Unix System V)
0
 
sgoldgaberCommented:
For simple log filtering, check out Swatch:

  ftp://ftp.cert.dfn.de/pub/tools/audit/swatch/

If you want to get more sophisticated, LogSurfer should help:

  http://www.cert.dfn.de/eng/logsurf/

0
 
encilarAuthor Commented:
Thank you guys. As our system is concerned, as much as possible I have no plans of installing another third party software in our system just to do this task.  But If you can give me a sample of a short script that can do this, I would be very grateful.
0
 
jlevieCommented:
Are you adverse to perl? The solution that I'm playing with needs it to work. For what it's work Sun includes Perl5 in Solaris 8...
0
 
encilarAuthor Commented:
I'm sorry, but I can only work with Bourne and Korn Shell. The Solaris Version that we have is 2.6 and 7.
0
 
sgoldgaberCommented:
Well, to be really crude and ugly, you could create a crontab entry that runs every 5mins, and mails you the tail end of the log:

5 * * * * tail -f /var/adm/sulog | mailx you@your.domain.com
0
 
encilarAuthor Commented:
What I really want is an automatic e-mail notifcation.  For example if someone uses the su command, thats only the time the system will send me a notification.  Another example is, if During the week, our system encounters a Warning message in /var/adm/messages and it occurs only once, it will then sends me a notification once also, if twice occurence then twice notification also.
0
 
sgoldgaberCommented:
To modify the ugly crontab solution:

5 * * * * tail -f /var/adm/sulog | grep "Warning" | mailx you@your.domain.com


Also, to elaborate on the syslog suggestion, put in something like the following in to your syslog.conf:

*.err                         myfilter

NOTE: "err" refers to the actual severity level that you use for your logfiles.
NOTE2: make sure you use tabs, not spaces between the two fields

Create an account called myfilter.  Then, in ~myfilter/.forward put:

|grep "Warning" | mail you@your.domain.com

That's my last try to hack this.  Despite your reluctance to put yet another third party app "just for this", I strongly suggest you investigate swatch and/or logsurfer.  They were designed to do just what you want, and as your needs grow and the number and complexity of logfiles and patterns that you search for increases, you'll be grateful you've invested a little time/space to install a dedicated log filtering app.
0
 
sgoldgaberCommented:
To modify the ugly crontab solution:

5 * * * * tail -f /var/adm/sulog | grep "Warning" | mailx you@your.domain.com


Also, to elaborate on the syslog suggestion, put in something like the following in to your syslog.conf:

*.err                         myfilter

NOTE: "err" refers to the actual severity level that you use for your logfiles.
NOTE2: make sure you use tabs, not spaces between the two fields

Create an account called myfilter.  Then, in ~myfilter/.forward put:

|grep "Warning" | mail you@your.domain.com

That's my last try to hack this.  Despite your reluctance to put yet another third party app "just for this", I strongly suggest you investigate swatch and/or logsurfer.  They were designed to do just what you want, and as your needs grow and the number and complexity of logfiles and patterns that you search for increases, you'll be grateful you've invested a little time/space to install a dedicated log filtering app.
0
 
sgoldgaberCommented:
Sorry about the duplicate message.  I guess hitting "Reload" after submitting the comment wasn't such a good idea... **SHEEPISH GRIN**
0
 
encilarAuthor Commented:
Thank you for all your persistence in answering my  question... 'Till then...
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 6
  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now