locked
Overriding default email message of HPC RRS feed

  • Question

  • Dear all,

    We want to use HPC provided email notification mechanism, however we want to customize email message, and add some more information details there. Can this be done? If not, what are the other potential ways to accomplish notification from HPC easily.

    Thanks,

    Puneet


    Puneet Sharma

    Wednesday, March 21, 2018 5:16 PM

Answers

  • Hi Puneet,<o:p></o:p>

    The doc has a mistype.

    "EmailBodyFilter.ps1 has 2 parameters $JobId and $JobState." should be "EmailSubjectFilter.ps1 has 2 parameters $JobId and $JobState.".

    And "EmailSubjectFilter.ps1 has 4 parameters $Cluster, $JobId, $JobName and $JobState." should be "EmailBodyFilter.ps1 has 4 parameters $Cluster, $JobId, $JobName and $JobState."

    Chenling<o:p></o:p>

    Monday, March 26, 2018 4:26 AM

All replies

  • yes, this can be done within HPC Pack 2016 Update 1. Here is the instruction

    1. Config E-mail Notifications in Job Scheduler Configuration

    Create EmailBodyFilter.ps1/EmailSubjectFilter.ps1 in %CCP_HOME%Bin

    -          EmailBodyFilter.ps1 has 2 parameters $JobId and $JobState. The output of the script will be the subject of the email. If the output is empty, the email will not be sent.

    -          param(

    -              [string] $JobId,

    -              [string] $JobState

    -          )

    -         

    -          if($JobId -eq 85)

    -          {

    -              "Job $JobId is in $JobState state"

    -          }

    -          EmailSubjectFilter.ps1 has 4 parameters $Cluster, $JobId, $JobName and $JobState. The output of the script will be the content of the email. If the output is empty, the email will not be sent.

    -          param(

    -              [string] $Cluster,

    -              [string] $JobId,

    -              [string] $JobName,

    -              [string] $JobState

    -          )

    -         

    -          if($JobState -eq "Running")

    -          {

    -              "This is a notification email from $Cluster.

    -              Job $JobName($JobId) is in running state."

    -          }

    -          Parameter $Cluster is the name of the cluster.

    -          Parameter $JobState could be one of “Running”, “Finished”, “Failed” or “Canceled”.

    Email received.



    Qiufang Shi

    Friday, March 23, 2018 3:09 AM
  • And within the powershell script body, you can do anything you want, for example, query the job, the number of failed task in the job, etc...; Or sending other messages

    Qiufang Shi

    Friday, March 23, 2018 3:11 AM
  • I tried the above approach and it's working fine. However,  I am unable to get the values of $Cluster and $JobName in EmailSubjectFilter.ps1 script. The contents of these parameters are coming empty. I wonder if there is anything else I need to do. Below is my script where $JobName and $Cluster values are empty:

     param( [string] $Cluster, [string] $JobId, [string] $JobName, [string] $JobState)
     
     "OptymHPC: Job $JobId, $JobName, $JobState completion notification from cluster $Cluster "

    Puneet Sharma

    Friday, March 23, 2018 7:39 PM
  • Hi Puneet,<o:p></o:p>

    The doc has a mistype.

    "EmailBodyFilter.ps1 has 2 parameters $JobId and $JobState." should be "EmailSubjectFilter.ps1 has 2 parameters $JobId and $JobState.".

    And "EmailSubjectFilter.ps1 has 4 parameters $Cluster, $JobId, $JobName and $JobState." should be "EmailBodyFilter.ps1 has 4 parameters $Cluster, $JobId, $JobName and $JobState."

    Chenling<o:p></o:p>

    Monday, March 26, 2018 4:26 AM
  • I tested and it works fine. So 

    • EmailBodyFilter.ps1 will have signature "param( [string] $Cluster, [string] $JobId, [string] $JobName, [string] $JobState)"
    • EmailSubjectFilter.ps1 will have signature "param( [string] $JobId, [string] $JobState)"

    Thanks for helping me out.


    Puneet Sharma

    Monday, March 26, 2018 3:14 PM
  • Dear all,

    We want to send well formatted html email messages via HPC email notification. I wonder how can we do that. Currently email messages are coming simply as text based messages and include all our html tags like below.

    <html>

    <body>

    ......

    </body>

    </html>

    Note: I believe we need to set IsBodyHTML = true for the given email messages when we send it via SMTP.  I wonder how can we do it.


    Tuesday, April 3, 2018 3:38 PM
  • Hi Puneet,

      We will take an investigation on this and reply this thread.


    Qiufang Shi

    Wednesday, April 4, 2018 4:27 AM