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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sendmail of AIX Error Reports

Status
Not open for further replies.

olli2003

Technical User
Jan 31, 2003
93
DE
Dear All,

I've tried to send an Error Report, wich is generated from a machine, to an external E-Mail. So in this way I've tried to filter for some strange things at first, f. ex.

"errpt|grep UNABLE TO ALLOCATE SPACE >/tmp/errpt_pri1.lst"
(that file will create then). So now I want to send this file to an external Address after, using this command:

"more errpt_pri1 |senmail -v oliver.nelle@souls.de"

It's also ok, my problem now is, that if the file doesn't
exist, I'll also get a mail with a blank side, and that's what I don't want. I only will get a Mail, if this file was created, that's all! I think I've to write a Shell Script with If/Endif, must I? But I don't know how :eek:(
Thanks a lot to all can help me!!!:eek:)))

Regards
Oliver
 
the following script would fit your needs i guess:

# ! /bin/ksh
if [ -f /tmp/errpt_pri1.lst ]
then
more errpt_pri1 |senmail -v oliver.nelle@souls.de
fi

regards
Mark
 

One liner:

# if [ -f errpr_pri1 ]; then cat errpt_pri1 |sendmail -v oliver.nelle@souls.de; fi

Or a script:

#/bin/ksh

if [ -f errpt_pri1 ]
then
cat errpt_pri1 |sendmail -v oliver.nelle@souls.de
fi

exit 0 Henrik Morsing
Certified AIX 4.3 Systems Administration
& p690 Technical Support
 
Thanks for all replies guys, you're great!!!!



Best Regards

Oliver
 
Sorry, the next problem pops up...
If I use the "grep command" for the string I search for,
also a file will create if the string wasn't found.
So the result is, that every time there will be a file.
But I've just to want have the file create if the "grep" of a string was successful. Please can you help me one more time? Thanks a lot,

Regards
Oliver
 


#/bin/ksh

if errpt|grep "UNABLE TO ALLOCATE SPACE" >/tmp/errpt_pri1.lst
then
if [ -f errpt_pri1 ]
then
cat errpt_pri1 |sendmail -v oliver.nelle@souls.de
fi
fi

exit 0 Henrik Morsing
Certified AIX 4.3 Systems Administration
& p690 Technical Support
 

Oooopppssss....

Sorry about that. If you get a strange mail with and errpt list in it, it just me playing around :-O

Cheers Henrik Morsing
Certified AIX 4.3 Systems Administration
& p690 Technical Support
 
Hi Henrik!

if errpt |grep ALLOCATE > /tmp/errpt_pri1_saphir_d
if errpt |grep SHUTDOWN >> /tmp/errpt_pri1_saphir_d
if errpt |grep ERROR |grep LINK >> /tmp/errpt_pri1_saphir_d
if errpt |grep LOGGING |grep OFF >> /tmp/errpt_pri1_saphir_d
then
cd /tmp
if [ -f errpt_pri1_saphir_d ]; then cat errpt_pri1_saphir_d |sendmail -v oliver.nelle@souls.de; fi
fi fi
fi
fi
rm errpt_pri1_saphir_d
cd /

Something's wrong here. I'll fetch some different things in one file, this file I want to print then, but in this case NO FILE will create :eek:((( Something wrong on it?
Best Regards
Oliver
 

Yes. If just one of these IF statements fail, it will exit.
You need something like an ELIF statement.

Cheers Henrik Morsing
Certified AIX 4.3 Systems Administration
& p690 Technical Support
 
Hi Henrik,

why the program will abort then?
But how I can use the "elif" in my case?
Thanks again!

Best Regards
Oliver


 
Hi Freaks,

I'm not really satisfied with this solution.
Perhaps there's another possibility?
Thanks and have a nice weekend!

Best Regards
Oliver
 
This is a script will alert an error on an AIX:

#!/usr/bin/ksh
# Author: Hao Nguyen
#set -o xtrace

# You can put this script in CRON and have it run at 20,40,59 min.
PATH=/usr/bin:/usr/sbin:/usr/local/bin:.
export PATH

# This script will parse the error log (out put of errpt daemon) to notify
# the administrator if there are any errors. It only reports errors occured
# from the last 20 min. to current time of the day.
m=`date +"%m"`
d=`date +"%d"`
H=`date +"%H"`
M=`date +"%M"`
M1=`expr ${M} - 20 `
M1=`echo ${M1} | awk '{printf "%02d",$1}' `
y=`date +"%y"`
errpt -s ${m}${d}${H}${M1}${y} -e ${m}${d}${H}${M}${y} > /tmp/.error
#echo "ssadsadas" > /tmp/.error
STATUS=`wc /tmp/.error | awk '{ print $1}' `
if [[ ${STATUS} > 0 ]]; then
mail -s &quot;%ERROR on `hostname` &quot; unixsupport < /tmp/.error

fi # periodically.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top