This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to Parse a string in a rule condition

I have the need to take a string that is used as a Display Name for a database instance in Foglight for SQL Server and parse it.  For instance, the Display name might be something like C-Tier1-DatabaseInstance.   I am building a rule where I have the need to split the string in separate variables to build conditional statements.  What is the syntax to do something like this?

Parents
  • I have this piece of code that I want to put into the rule condition that will dynamically determine information from the display name:

    def display_name= 'C-Tier2-DatabaseInstance'  <-------------------------  Needs to be dynamic

    def  portfolio = display_name.split("-")[0];

    def tier = display_name.split("-")[1];

    def instance = display_name.split("-")[2];

    def DBGroup = portfolio

    switch (DBGroup) {

     case "A": emailAddr = "DatabasePortfolioA"

     break

     case "B": emailAddr= "DatabasePortfolioB"

     break

     case "C": emailAddr= "DatabasePortfolioC"

     break

     case "D": emailAddr= "DatabasePortfolioD"

     break

     default: emailAddr= "SQLOperations@exchange.schwab.com"

    }

    def Priority = tier

    switch (Priority) {

     case "Tier1": Priority = 1

     break

     case "Tier2": Priority = 2

     break

     default: Priority = 3

    }

    def   urgency = Priority

    switch (urgency) {

     case  1: urgency = "High"

     break

     case  2: urgency = "Medium"

     break

     default: urgency = "Low"

    }

    Is there a way to add topology objects to the rule condition section to that I can pull the display name in?  Are the global variables?

     

Reply
  • I have this piece of code that I want to put into the rule condition that will dynamically determine information from the display name:

    def display_name= 'C-Tier2-DatabaseInstance'  <-------------------------  Needs to be dynamic

    def  portfolio = display_name.split("-")[0];

    def tier = display_name.split("-")[1];

    def instance = display_name.split("-")[2];

    def DBGroup = portfolio

    switch (DBGroup) {

     case "A": emailAddr = "DatabasePortfolioA"

     break

     case "B": emailAddr= "DatabasePortfolioB"

     break

     case "C": emailAddr= "DatabasePortfolioC"

     break

     case "D": emailAddr= "DatabasePortfolioD"

     break

     default: emailAddr= "SQLOperations@exchange.schwab.com"

    }

    def Priority = tier

    switch (Priority) {

     case "Tier1": Priority = 1

     break

     case "Tier2": Priority = 2

     break

     default: Priority = 3

    }

    def   urgency = Priority

    switch (urgency) {

     case  1: urgency = "High"

     break

     case  2: urgency = "Medium"

     break

     default: urgency = "Low"

    }

    Is there a way to add topology objects to the rule condition section to that I can pull the display name in?  Are the global variables?

     

Children
No Data