iDash Workload Automation

 View Only

Tuesday Tips : How to Send & Set Environment Variables

  • 1.  Tuesday Tips : How to Send & Set Environment Variables

    Broadcom Employee
    Posted Jul 30, 2019 02:13 PM
    Edited by Samuel Thomas Jul 30, 2019 02:15 PM
    The following below is and example of a shell & powershell script, that will send an email to the administrator that contain values of CA Workload Automation iDash environment variables:

    Example: Shell Script

    mail -s"iDash SLA alarm" admin01@xyz_company.com  <<END

    SLA name: $IDASH_SLA_NAME
    SLA status: $IDASH_SLA_STATUS
    Alarm type: $IDASH_SLA_ALARM
    Forecast start: $IDASH_SLA_FORECAST_TIME_START
    Forecast end: $IDASH_SLA_FORECAST_TIME_END
    Instance: $IDASH_SLA_JOB_INSTANCE
    Job name: $IDASH_SLA_JOB_NAME

    END



    Example: PowerShell

    $SMTPServer = "smtp.gmail.com"
    $smtpclient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)
    $smtpClient.EnableSsl = $True
    $smtpClient.Credentials = New-Object System.Net.NetworkCredential("username", "passwword");
    $emailFrom = "your_email"
    $emailTo= "your_email"
    $Subject = "just a test"
    $Body = "
    SLA name: $env:IDASH_SLA_NAME
    Display Name: $env:IDASH_SLA_DISPLAY_NAME
    Alarm type: $env:IDASH_HOME
    Forecast start: $env:IDASH_SLA_FORECAST_TIME_START
    Forecast end: $env:IDASH_SLA_FORECAST_TIME_END
    Instance: $env:IDASH_SLA_JOB_INSTANCE
    Job name: $env:IDASH_SLA_JOB_NAME"
    $SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)


    The script should reside on the iDash Server machine.

    Specify the full path to the script in the SLA Definition – Script Execution section, as shown in the following examples:

    Linux:
    $DASH_HOME/etc/script_name

    Windows:
    Powershell.exe -executionpolicy remotesigned -File C:\Progra~1\CA\idash\etc\script_name

    To see additional CA Workload Automation iDash environment variables click the following link below:
    https://docops.ca.com/ca-workload-automation-idash/12-0/en/administrating/configure-slas/sla-definitions/alarm-script-reference