Skip to main content

Email Creation - Computer Failure Only

Summary

This script functions similarly to the CWM - Automate - Script - Ticket Creation - Computer script; however, instead of creating a ticket, it is designed to send the FAILED outcomes of a RAWSQL monitor to the email address provided in the system property.

This script sends emails to two different addresses:

  1. If the script is called by the alert template "△ Custom - Email RAWSQL Monitor set results to ProVal", it will send an email to the email address set at the system property "ProVal_Alerts_Email_Address", which is typically set to "alerts@provaltech.com".
    Note: If the property is missing, the script will automatically set it to "alerts@provaltech.com", but if it is set to a different email address, then it will not be modified.

  2. If the script is called by any other template, it will fetch the email address from the system property "_sysTicketDefaultEmail".

Note: The script is designed to send only failure messages/emails.

Sample Run

It's an Autofix script and is currently attached to the "△ Custom - Email RAWSQL Monitor set results to ProVal" alert template.

Sample Run

System Property

NameExampleRequiredDescription
_sysTicketDefaultEmailtest@test.comYesThis email address is used when the script is called from an alert template other than "△ Custom - Email RAWSQL Monitor set results to ProVal".
ProVal_Alerts_Email_Addressalerts@provaltech.comYesThis email address is used when the script is called from the alert template "△ Custom - Email RAWSQL Monitor set results to ProVal". Note: It is mandatory to use alerts@provaltech.com with this system property as it is intentionally created for alerts that need to be passed on to the ProVal support team from the partner environment.

Global Parameter

NameExampleRequiredDescription
EmailOnSuccess0True0 disables emailing a success email; 1 enables emailing a success email.

Variables

NameDescription
FIELDNAMEIdentity Field of the monitor set
TicketSubjectTicket Subject from the alerting tab of the monitor set
SuccessMSGSuccess Message from the alerting tab of the monitor set
FailedMSGFailure Message from the alerting tab of the monitor set
StatusFAILED/SUCCESS status of the monitor set
EmailEmail address of the contact/user used in the alert template
DataoutMonitor set's statement
DataoutlengthPosition of the last parentheses in the monitor set's query; this is calculated to remove (select computerid from tcomp) from the monitor set's statement. Keeping this statement will lead to the script's failure.
MonitorName of the monitor set

Process

  1. Check the status of the monitor set and do not act for Success.
  2. For failures, proceed accordingly.
  3. Store the SQL query used in the monitor set to the @Dataout@ variable. Also, replace 'from tcomp' with 'from computers', if it exists in the SQL query. To perform this replacement, convert the whole query to lowercase.
  4. Find the FieldName, TicketSubject, SuccessMSG, FailedMSG, and Email.
  5. Email the outcome to the email address of the user/contact of the alert template.

Output

Email