EMS doesn’t allow to edit sender email address. All events are always sent out with sender id as root@hostname. Here is small script to change it.
Normally in Event monitoring system ( EMS ) 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 firstname.lastname@example.org
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 email@example.com) for your logged in account which works. Send a test email from server to verify using below command
# echo test |/usr/sbin/sendmail -v firstname.lastname@example.org
email@example.com... Connecting to smtpserver.xyz.com via relay...
220 smtpserver.xyz.com ESMTP Postfix
>>> EHLO xyz.com
>>> MAIL From:<firstname.lastname@example.org> SIZE=5
250 2.1.0 Ok
>>> RCPT To:<email@example.com>
250 2.1.5 Ok
354 End data with <CR><LF>.<CR><LF>
250 2.0.0 Ok: queued as 46466822F2
firstname.lastname@example.org... Sent (Ok: queued as 46466822F2)
Closing connection to smtpserver.xyz.com
221 2.0.0 Bye
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
Script code is as below.
Now you can test the script by generating test events in EMS. Generate test event with send_test_event command.
# send_test_event -v -a disk_em
Finding resource name associated with monitor disk_em.
Found resource name /storage/events/disks/default
associated with monitor disk_em.
Creating test file /var/stm/config/tools/monitor/disk_em.test
for monitor disk_em.
Making test file /var/stm/config/tools/monitor/disk_em.test
for monitor disk_em
indicate send test event for all resources.
Performing resls on resource name /storage/events/disks/default
for monitor disk_em to cause generation of test event.
Contacting Registrar on aprss006
DESCRIPTION: Disk Event Monitor
This resource monitors events for stand-alone disk drives. Event
monitoring requests are created using the Monitoring Request
Manager. Monitoring requests to detect changes in device status are
created using the Peripheral Status Monitor (psmmon(1m)) and Event
Monitoring Service (EMS).
For more information see the monitor man page, (disk_em(1m)).
TYPE: /storage/events/disks/default is a Resource Class.
There are 2 resources configured below /storage/events/disks/default:
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 email@example.com !!
I have tested this script and it works flawlessly. Please leave comments below if its helpful to you too.