Monday, September 26, 2016

How to change sender's email id in EMS HPUX

Requirement : Normally in Event monitoring system on HPUX send an emails with sender id as root@ hostnam e. Many organizations email serve... thumbnail 1 summary
Requirement :

Normally in Event monitoring system on HPUX send an emails with sender id as root@hostname. Many organizations email servers dont allow such email address in sender field. We need generic email id in sender field when EMS shoots an alert email something like notification@xyz.com

Workaround :

There is no provision to change this email id anywhere in HPUX or EMS configurations. You can use below workaround which works perfectly without any issues.

Step 1 :
Make sure you have valid email address (like notification@xyz.com) for your logged in account which works. Send a test email from server to verify using below command


# echo test | sendmail -v receiver_id@xyz.com


Image source : freeimages.com

Step 2 :
Setup crontab for above logged in account (for which email tested) which will execute EMS log scanner script every 30 minutes. As per your convenience you can even schedule it to run every 10 mins or even lower.


00,30 * * * * /scripts/ems_monitor.sh



Step 3:
Script code is as below.


# Script to scan EMS log file and email alert if any
# Author : Shrikant Lavhate
#! /bin/bash
if [ -f "/logs/event_monitor.log" ]
then
:
else
cp -p /var/opt/resmon/log/event.log /logs/event_monitor.log
fi
diff /logs/event_monitor.log /var/opt/resmon/log/event.log > /logs/logfile_difference
if [ -s "/logs/logfile_difference" ]
then
cat /logs/logfile_difference | grep  '^>'|cut -c 2-  | mailx -s "EMS monitor alert from `hostname`" receiver_id@xyz.com
fi
cp -p /var/opt/resmon/log/event.log /logs/event_monitor.log


Step 4:
Now you can test the script by generating test events in EMS. Generate test event with send_test_event command. You will receive test events from admin@hostname email id which is normal. Now run above script and you will receive same email with sender id as notification@xyz.com !!


No comments

Post a Comment

Any thoughts?