Notify Different Users Based on Job Severity

Follow

JAMS allows for notifying different users based on how a Job completes. Here is an example of this Notification Job:


The list of Parameters that can be parsed within a Notification Job can be found here.

param($JAMS_NOTIFY_JAMS_ENTRY, $JAMS_NOTIFY_JOB_NAME)

#
# Get SMTP Server
#
$smtpServer = "<<smtpServer>>"

#
# Get the entry that we are notifying about
#
$entry = Get-JAMSEntry $JAMS_NOTIFY_JAMS_ENTRY

if($entry.FinalSeverity -eq "success") #Successful
{
   $contact  = "<<contactSuccess>>"
   $msgSubject =  "$JAMS_NOTIFY_JOB_NAME, Entry $JAMS_NOTIFY_JAMS_ENTRY Completed Successfully!"
   $msgBody = "Job: $JAMS_NOTIFY_JOB_NAME`n
  Entry: $JAMS_NOTIFY_JAMS_ENTRY`n
  Final Status: Successful"
}
ElseIf($entry.FinalSeverity -eq "info") #Informational
{
   $contact  = "<<contactInfo>>"
   $msgSubject =  "$JAMS_NOTIFY_JOB_NAME, Entry $JAMS_NOTIFY_JAMS_ENTRY Completed with Informational!"
   $msgBody = "Job: $JAMS_NOTIFY_JOB_NAME`n
  Entry: $JAMS_NOTIFY_JAMS_ENTRY`n
  Final Status: Informational"
}
ElseIf($entry.FinalSeverity -eq "warning") #Warning
{
   $contact  = "<<contactWarning>>"
   $msgSubject =  "$JAMS_NOTIFY_JOB_NAME, Entry $JAMS_NOTIFY_JAMS_ENTRY Completed with Warning!"
   $msgBody = "Job: $JAMS_NOTIFY_JOB_NAME`n
  Entry: $JAMS_NOTIFY_JAMS_ENTRY`n
  Final Status: Warning"
}

#
# Send the message
#
if($contact)
{
   Send-MailMessage -To $contact -Subject $msgSubject  -Body $msgBody -From JAMS@mvpsi.com -SMTPServer $smtpServer
}
Have more questions? Submit a request

Comments