Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

errpt script

Status
Not open for further replies.

pctech321

IS-IT--Management
Oct 20, 2007
18
US
hai all,

can anyone have a script for reporting errpt everyday..
my mgt want a script, which will give us a email everyday that what errpt occured on that current day,like we can keep that script as a crontab job so that it runs everyday midnight thereby we get a mail at morning so we can remind previous day errpt and take conseq actions..
if u guys can help me in this.....i am so glad..
thank you....
 
This is doable using errnotify

Code:
errnotify - monitoring errpt 


A good technique is to create an errnotify ODM method that gets called when 
an errpt entry is created. 


This method can be used to send both an email and a page in real time as 
errors occur. 


This example in the AIX Survival Guide by Andreas Siegert, which send errpt 
entries to syslog. 


You need to create an ODM method as follows: 
# cat odm_errlog 
errnotify: 
  en_pid = 0 
  en_name = "syslog" 
  en_persistenceflg = 1 
  en_label = "" 
  en_crcid = 0 
  en_class = "" 
  en_type = "" 
  en_alertflg = "" 
  en_resource = "" 
  en_rtype = "" 
  en_rclass = "" 
  en_method = "/path/program $1" 



You then need to create an ODM update script as follows 
# cat updodm_errlog 
odmget -q"en_name=syslog" errnotify 
odmdelete -o errnotify -q"en_name=syslog" 
odmadd errsyslog 
odmget -q"en_name=syslog" errnotify 


Run this script to update the ODM. 


You then need to create /path/program as follows: 


#!/usr/bin/ksh 


emailids='user@system' 
pagerids='pager@system' 
title='Warning: Error Log Entry' 


errpt -l $1 -a | mail -s "$title" $emailids 


label=`errpt -l $1 -a | grep 'LABEL:' | awk '{print $2}'` 


errpt -l $1 -a | grep -v '\--.*' | sed \ 
               -e "s/ */ /g" \ 
               -e "s/ //g" \ 
               -e "/^$/d" \ 
               | mail -s $label $pagerids 
touch $dir/$errid 
exit



Regards,
Khalid
 
thanks a lot khalid,

the thing is my head don't want to make change in ODM
all he wants is a script that should be as simple as that
so if any other simple solution..suggest me
thank you...
 
Hi pctech,

we're using the following script to send an email every time an error is reported in errpt. But in this case the script would have to be running permanently (nohup scriptname &).

Crontab won't work here because every time the script starts or finds an error it overwrites the /tmp/errlog.1 file as a basis to compare whether a new error has occured or not.

Maybe you can change it a bit according to your needs (Longer sleep or so).

--------------------------------------------------------
#!/usr/bin/ksh

errpt > /tmp/errlog.1

while true
do
sleep 300 # Wait 5 Minutes

errpt > /tmp/errlog.2

cmp -s /tmp/errlog.1 /tmp/errlog.2 && continue

errpt -a > /tmp/errlog.output.tsi

mail -s "Server xyz: An error has occured. Please check!" receiver@company.de < /tmp/errlog.output.tsi

errpt > /tmp/errlog.1
done
--------------------------------------------------------

Regards
Thomas
 
Yeah as Thomas said, this script will be running permenantly but if you update the ODM then it will only send you an email if an error occured so it is less in overall resource usage!

If you hesitate to do it on a production, try it on test first! It should be safe!

Regards,
Khalid
 
Here's something to start:

Code:
#!/bin/ksh
# Generate an error report (overview only) for yesterday 0:00h until today 0:00h
# yesterday's date in a format understandable by errpt
YDAY=$(LANG='En_US' perl -e 'print scalar localtime (time() - 86400)'|\
awk 'BEGIN{
 mon["Jan"]=1;  mon["Feb"]=2;  mon["Mar"]=3;  mon["Apr"]=4
 mon["May"]=5;  mon["Jun"]=6;  mon["Jul"]=7;  mon["Aug"]=8
 mon["Sep"]=9;  mon["Oct"]=10; mon["Nov"]=11; mon["Dec"]=12
}
{
 print mon[$2] $3 "0000" substr($NF,3)
}')
# today's date in same format
TDAY=$(date +'%m%d0000%y')
# errpt call
echo errpt -s ${YDAY} -e ${TDAY}
errpt -s ${YDAY} -e ${TDAY}

You can build on this to get where/what you want. (There are numerous threads in these forums on how to email a script's output...)


HTH,

p5wizard
 
See thread52-1228919. It may not give you what you want exactly, but it may point you in the right direction.
 

i am so thankful to all of them ..

and hi tsch,

urs is too simple & nice i implemented urs and waiting for result

..
Regards,
pctech,



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top