1 Reply Latest reply on Aug 16, 2014 6:19 PM by cgregors

    Retrieve trigger action variables

    dbai

      We have an app that integrates with SW NPM and SAM and pulls in alerts and events via SWIS. We are trying to add a feature to it where we automatically retrieve any Orion variables used in alert trigger definitions. So for example if the Orion alert will log a message of Alert: ${NodeName} rebooted at ${LastBoot} then in our app we want to see two data values, nodename and lastboot, both containing their relevant value.

       

      We think we can simply read the alert templates and parse out the variables with a simple regex to get anything that looks like ${}. Once we have this list of variables we can attempt to get the values from SW. The issue is how to get these values.. they seem to be properties that can be found in many different tables since some apply to a node, others to an interface etc. This would be too complex to do this way as we'd have to cater for every variable manually, and there are many. Perhaps there is an alternate way to get these values? Some query or API call that accepts the template and the alert or event and returns the computed variables?

        • Re: Retrieve trigger action variables
          cgregors

          Having been partly down this road when I built an alert validator, I think you could do the following:

           

          1. Retrieve the ObjectType from the Alert definition
          2. Retrieve the Trigger variables from the alert actions
          3. If the variable contains a "." (period) in it, assume it goes to another table.
            1. Parse apart the variable and use a switch / case statement to go back into the db and get the variable value from the other table.
          4. If the variable doesn't contain a ".", assume it comes from the table associated with the ObjectType from the Alert definition.

           

          Example:

           

          • Alert definition for my "MONITORING : Orion Application not UP" alert
            • ObjectType = APM: Application
            • pre-translate "APM: Application" into "APM_Application" (the actual table in the DB)
          • Trigger action linked to this alert = send email
            • email subject line is:
              • ${Name} on ${Node.Caption} is ${Availability}
          • ${Name} has no period in the name and therefore comes from Application  custom properties
          • ${Availability} has no period in the name and therefore comes from Application  custom properties
          • ${Node.Caption} has a period in it so go somewhere else
            • split apart the variable name into $table , $column
            • Goto $table and get value of $column

           

          Rinse and repeat for other variables and parts of the alert action.

           

          Sorry about the colouring of the text. I was doing copy-n-paste from my web-app.

           

          Chris.