errpt alert mails

Is there some method when a error is logged in errpt an mail can be generated sending that error to the admin mail
LVL 1
bsa_jugAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
woolmilkporcConnect With a Mentor Commented:
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
 
dfkeCommented:
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
 
dfkeCommented:
Sorry I misread you asked for e-mail notification. This is for snmp sendtrap.
0
[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

 
madunixChief Information Security Officer Commented:
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
 
woolmilkporcCommented:
madunix,
is it really a good idea to send the complete errorlog once a day?
0
 
bsa_jugAuthor Commented:
Thx woolmilkporc , the suggestion worked good
0
All Courses

From novice to tech pro — start learning today.