- My Lab Environment
OS = rhel 6.2
SFHA = 6.0
- Introduction to SSMTP utility:
SSMTP is a program to deliver an email from a local computer to a configured mailhost (mailhub)/gmail. One of its primary uses is for forwarding automated email (like system alerts) off your machine and to an external email address.
- Installation:
#yum install ssmtp
- Configuration file:
/etc/ssmtp/ssmtp.conf
- Configuration:
To configure SSMTP, you will have to edit its configuration file (/etc/ssmtp/ssmtp.conf) and enter your account settings:
# The user account that sends all the mails root=username@gmail.com # The mail server (where the mail is sent to), usually on port 587 mailhub=smtp.gmail.com:587 # Use SSL/TLS before starting negotiation UseSTARTTLS=Yes # Username/Password AuthUser=username of gmail account AuthPass=password of gmail account
- Creating Aliases:
Create aliases for local user-names in /etc/ssmtp/revaliases configuration file:
root:username@gmail.com:smtp.gmail.com:587 - Sending mails: A simple method to send emails is to create a text file(filename.txt) containing the following: To: username@somedomain.com From: youraccount@gmail.com Subject: Test This is a test mail. Now execute the following command from Linux shell : #ssmtp address@domain.com< filename.txt - POSTOFFLINE script in VCS: This event trigger is invoked on the system where the group went offline from a partial or fully online state. This trigger is invoked when the group faults, or is taken offline manually. In the properties of ClusterServiceGroup, set the TriggersEnabled attribute to “POSTOFFLINE” This will trigger the POSTOFFLINE trigger of VCS whenever the ClusterServiceGroup gets faulted or goes offline. - Editing the POSTOFFLINE script: Copy the postoffline script from /opt/VRTSvcs/bin/sample_triggers to /opt/VRTSvcs/bin/triggers #vi /opt/VRTSvcs/bin/triggers/postoffline Append the following line at the end of the script: system("/opt/VRTSvcs/bin/triggers/mailtrigger.sh"); which is a Perl system call that further executes a Linux Bash script “mailtrigger.sh” mailtrigger.sh is a single statement bash script containing the ssmtp command: ssmtp address@domain.com< file.txt This shell script sends emails to all the recipients listed in the file.txt Whenever the notifier resource is turned off or gets faulted, POSTOFFLINE trigger is executed that sends email to designated recipients. - What happen if you did not configure the alias ( Please Note: At this point I am confident that my trigger was executing. See a snapshot of engine log:INFO V-16-6-15002 (node1) hatrigger:hatrigger executed /opt/VRTSvcs/bin/triggers/postoffline node1 successfully ) The flow of emails from the postoffline trigger is like this Cluster Node => Gmail => domain account where you are willing the user receive email. So If you did not configure the alias when happens that the gmail will receive a request to send an email to username@Clusternodename. At this pointthe mail will be bounce back as the ClusterNodeName will not be the valid host name. This clue I found when my gmail account receive a Delivery failed message. See the below for your reference: