Operating System - HP-UX
1832328 Members
1897 Online
110041 Solutions
New Discussion

Email notification for Service Guard package

 
Ray Allen_1
Frequent Advisor

Email notification for Service Guard package

Hi All,

Thanks in advance for your help.
We recently had Service Guard implemented on two of our servers. The Engineer wrote a small script to send an email notification when a package is disabled, but we are not receiving the email when I disable the package and run the script to check for the disabled package.

Here's the script that was written.

export SAGPAGER="1234567@skytel.com"
export SAGMAIL="gerald.townes@cancer.org"
export SAGMAIL1="ken.lu@cancer.org"

TEST=`cmviewcl | grep nholwsn1 | grep up | grep running | grep disabled | wc -l`
if [ "$TEST" -gt "0" ]
then
for J in `cmviewcl | grep nholwsn1 | grep disabled | awk '{print $1}'`
do
PKG=$J
DATE=`date +%Y.%m.%d`
TIME=`date +%Xgmt`
MSG="$PKG is disabled on $SVR-$DATE-$TIME"
echo $MSG
#echo $MSG | mail $SAGPAGER
echo $MSG > /tmp/MSGFILE1
mailx -s `hostname` $SAGMAIL < /tmp/MSGFILE1
mailx -s `hostname` $SAGMAIL1 < /tmp/MSGFILE1
rm /tmp/MSGFILE1
done
fi



Is there something missing in the script, or do I need to configure something somewhere else?

Thanks
6 REPLIES 6
rariasn
Honored Contributor

Re: Email notification for Service Guard package

Hi Ray,

Execute the script with option,

# sh -x ./script_name

and view the execution to fine,

rgs,

ran
Darrel Louis
Honored Contributor

Re: Email notification for Service Guard package

Ray,

Have you tested if mail is working?

Test:
sendmail -v 1234567@skytel.com
test
.

The dot is needed on the next line.

Darrel
Ray Allen_1
Frequent Advisor

Re: Email notification for Service Guard package

Thanks guys,

I ran the sh -x on the script and tested sendmail.
Here's the output.

root@nholaw1:/usr/local/bin>sh -x ./checkcl.ksh
+ export SAGPAGER=1234567@skytel.com
+ export SAGMAIL=gerald.townes@cancer.org
+ export SAGMAIL1=ken.lu@cancer.org
+ + cmviewcl
+ grep nholwsn1
+ grep up
+ grep running
+ grep disabled
+ wc -l
TEST=1
+ [ 1 -gt 0 ]
+ cmviewcl
+ grep nholwsn1
+ grep disabled
+ awk {print $1}
+ PKG=nholwsn1
+ + date +%Y.%m.%d
DATE=2006.06.09
+ + date +%Xgmt
TIME=09:13:58gmt
+ MSG=nholwsn1 is disabled on -2006.06.09-09:13:58gmt
+ echo nholwsn1 is disabled on -2006.06.09-09:13:58gmt
nholwsn1 is disabled on -2006.06.09-09:13:58gmt
+ echo nholwsn1 is disabled on -2006.06.09-09:13:58gmt
+ 1> /tmp/MSGFILE1
+ hostname
+ mailx -s nholaw1 gerald.townes@cancer.org
+ 0< /tmp/MSGFILE1
+ hostname
+ mailx -s nholaw1 ken.lu@cancer.org
+ 0< /tmp/MSGFILE1
+ rm /tmp/MSGFILE1
root@nholaw1:/usr/local/bin>




root@nholaw1:/root>sendmail -v gerald.townes@cancer.org
test
.
gerald.townes@cancer.org... Connecting to mail.cancer.org. via esmtp...
220 SMTP Proxy Server Ready
>>> EHLO nholaw1.cancer.org
250-ESMTP Server Ready
250-SIZE 31457280
250 DSN
>>> MAIL From: SIZE=5
250 +OK Sender OK
>>> RCPT To:
250 +OK Recipient OK
>>> DATA
354 Start mail input, end with "."
>>> .
250 +OK message queued for delivery.
gerald.townes@cancer.org... Sent (+OK message queued for delivery.)
Closing connection to mail.cancer.org.
>>> QUIT
221 Service closing transmission channel closing connection
root@nholaw1:/root>


It looks like the mail is going out successfully, but I'm not receving the email. Perhaps it is being blocked by our
mail server. I will have to confirm this.


Darrel Louis
Honored Contributor

Re: Email notification for Service Guard package

Ray,

What's the output of the following command:
# mailq

Do you see any error messages in your mail.log file.

Darrel
Ray Allen_1
Frequent Advisor

Re: Email notification for Service Guard package

Guys,

I figured what the problem was. I had a mail rule setup to receive all my root messages, which I completely forgot about.

Thanks for all your help.

Ray Allen_1
Frequent Advisor

Re: Email notification for Service Guard package

Mail was going to rule setup for mail from root.