?
Solved

errpt alert mails

Posted on 2010-01-10
6
Medium Priority
?
1,059 Views
Last Modified: 2013-11-17
Is there some method when a error is logged in errpt an mail can be generated sending that error to the admin mail
0
Comment
Question by:bsa_jug
[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 Comments
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 1000 total points
ID: 26281575
Hi,
yes, there is such a technique. It's called the "Concurrent Error Notify Facility", controlled by a method in the "errnotify" ODM database.
The available parameters are
$1 Sequence number from the error log entry
$2 Error ID from the error log entry
$3 Class from the error log entry
$4 Type from the error log entry
$5 Alert flags value from the error log entry
$6 Resource name from the error log entry
$7 Resource type from the error log entry
$8 Resource class from the error log entry
$9 Error label from the error log entry  
Now you have two possibilities, depending on how detailed the generated email should be.
If you only need a notification that an error has occurred (without detail) you could do this
Create a file with the following content -

errnotify:
en_name = "errptmail1"
en_persistenceflg = 1
en_method = "echo Error has occurred - Resource $6 has generated an event of type $4, Logsequence is $1 | mailx -s 'Error from errpt' recipient@domain.tld"
Name the file e.g. /tmp/errnotify.add and issue
odmadd  /tmp/errnotify.add  
Now you will get an email each time an errorlog entry is generated.
You can restrict this by adding more descriptors to the method, e.g. to get only hardware errors add  en_class =  "H"
The available descriptors are
en_pid =
 en_name =
 en_persistenceflg =
 en_label =
 en_crcid =
 en_class =
 en_type =
 en_alertflg =
 en_resource =
 en_rtype =
 en_rclass =
 en_symptom =
 en_err64 =
 en_dup =
 en_method =
The second possibility, if you want to work extensively with the obtained information, would be defining a homemade script as the method, giving it all the parameters and work with them inside the script
en_method = "/usr/local/scripts/my_errpt_mailmethod $1 $2 $3 $4 $5 $6 $7 $8 $9"
I could assist you in writing such a script, if you wish.
Find details to the above technique here -
http://publib.boulder.ibm.com/infocenter/aix/v6r1/index.jsp?topic=/com.ibm.aix.genprogc/doc/genprogc/error_notice.htm 
Good luck!
wmp

 
0
 
LVL 10

Expert Comment

by:dfke
ID: 26281659
From the Managing AIX Server Farms redbook: http://www.redbooks.ibm.com/redbooks/pdfs/sg246606.pdf


#!/bin/ksh
#################################################################
#
# Program : hwalert
#
# Function : Send alerts for hardware Errors using the sendtrap script.
# This Program, once enabled, is called automatically every time
# a Permanent H/W Error is logged. This is achieved by inserting
# an entry into the odm which tells the system to run this script
# every time a particular error occurs.
#
# Parameters : hwalert {ENABLE | DISABLE | $* from odm}
#
# If you wish to exclude certain hardware alerts add the Error Label
# in the /etc/hwalert.exclude file.
# Any errors with that label will be ignored.
#################################################################
# This function actually changes the ODM entry.
# The ENABLE option will not remove any currently, then add the entry in.
function manipulate_odm
{
export ODMDIR="/etc/objrepos"
if [[ $1 = "ENABLE" ]] ; then
odmdelete -q "en_name=hwalert" -o errnotify > /dev/null
odmdelete -q "en_name=OPMSG" -o errnotify > /dev/null
odmdelete -q "en_name=custom" -o errnotify > /dev/null
# Add an ODM entry for PERM errors - this is a default entry
odmadd <<END__OF__ODM
errnotify:
en_pid = 0
en_name = "hwalert"
en_persistenceflg = 1
en_label = ""
en_crcid = 0
en_class = "H"
en_type = "PERM"
en_alertflg = ""
en_resource = ""
en_rtype = ""
en_rclass = ""
en_method = "$ROOT_PATH/hwalert \$1 \$2 \$3 \$4 \$5 \$6 \$7 \$8 \$9 \$10 \$11"
END__OF__ODM
errors=$(($errors+$?))
# Now add entries for other errpt events specified in config
if [[ -f /etc/errpt.alert ]] ; then
cat /etc/errpt.alert | \
# The following awk command must be one contiguous line.
awk -F: '!/^([ ]*#.*|[ ]*)$/{printf("errnotify:\nen_pid = 0\nen_name =\"custom\"\nen_persistenceflg = 1\nen_label = \"\"\nen_crcid = \"\"\nen_class =\"%s\"\nen_type = \"%s\"\nen_alertflg= \"\"\nen_resource = \"%s\"\nen_rtype =\"\"\nen_rclass = \"\"\nen_method = \"'$ROOT_PATH'/hwalert \$1 \$2 \$3 \$4 \$5\$6 \$7 \$8 \$9 \$10 \$11\"\n\n",$1,$2,$3);}' |\odmadd
fi
if [[ $errors -ne 0 ]] ; then
/usr/local/bin/sendtrap 4 "Failed to enable errpt /hardware
alerting - errpt/hardware alerting inoperable!"
fi
else
# Remove all errpt alerting
odmdelete -q"en_name=hwalert" -o errnotify > /dev/null 2>&1
odmdelete -q"en_name=custom" -o errnotify > /dev/null 2>&1
fi
}
# Main routine.
ROOT_PATH="/usr/local/bin"
if [[ $# -eq 0 ]] ; then
print "Usage: ${0} ENABLE | DISABLE"
exit 0
fi
# Check if it is running as root user.
if [[ $(id -u) -ne 0 ]] ; then
print "$0 must be run as root"
exit
fi
if [[ $1 = +(ENABLE|DISABLE) ]] ; then
manipulate_odm $1
exit 0
fi
Error_Seq=$1
Appendix B. Example scripts 317
Identifier=$2
Device=$6
Label=$9
# There may be some hardware errors we wish to exclude. Therefore,
# check that the error type received does not exist in the hwalert.exclude.
if [[ -e /etc/hwalert.exclude ]] && grep -q "^$Label$" /etc/hwalert.exclude
then
exit 0
fi
print "1 is $1 2 is $2 3 is $3 4 is $4 5 is $5 6 is $6 7 is $7" > /tmp/ping
Message="System error $Label on $Device - please investigate errpt for details"
# Send alert via sendtrap.
/usr/local/bin/sendtrap 2 "$Message"

Open in new window

0
 
LVL 10

Expert Comment

by:dfke
ID: 26281790
Sorry I misread you asked for e-mail notification. This is for snmp sendtrap.
0
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 
LVL 25

Expert Comment

by:madunix
ID: 26291571
I have it this way a script
#!/bin/ksh
errpt | pg > errpt.txt
mail -s "errpt output" mel@mail < errpt.txt
Then save the script,  then added to crontab
0 8 * * * /error.sh

madunix
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 26292693
madunix,
is it really a good idea to send the complete errorlog once a day?
0
 
LVL 1

Author Comment

by:bsa_jug
ID: 26293834
Thx woolmilkporc , the suggestion worked good
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses

777 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