none
Overriding default email message of HPC

    Frage

  • 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

    Mittwoch, 21. März 2018 17:16

Antworten

  • 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>

    Montag, 26. März 2018 04:26

Alle Antworten

  • 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

    Freitag, 23. März 2018 03:09
  • 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

    Freitag, 23. März 2018 03:11
  • 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

    Freitag, 23. März 2018 19:39
  • 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>

    Montag, 26. März 2018 04:26
  • 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

    Montag, 26. März 2018 15:14
  • 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.


    Dienstag, 3. April 2018 15:38
  • Hi Puneet,

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


    Qiufang Shi

    Mittwoch, 4. April 2018 04:27