Rule Warning Level Deactivation - Foglight for Databases - Foglight for Databases - Dell Community

Rule Warning Level Deactivation

Rule Warning Level Deactivation

This question is answered

Hi, I'm looking to disable warning level notifications for any rules that are active. Given the thousand rules in the particular Foglight instance it is unfeasible to manually remove them, so I've approached the issue with a script. I'm able to locate all of the rules using the following code, however I'm not sure how to approach checking if a Warning level is active, and if so deactivating it.

def rs = server["RuleService"]
def rules = rs.getAllRules()

def sb = ''<<''
for (rule in rules){
        if (rule.isSuspended()){sb << rule.getName() << '\n'}
        else {
    
        }
}

return sb


I think I would need to use the setSeverityEnabled function, but I'm not sure how to check the warning level of each rule before doing so.


Thanks in advance

Verified Answer
  • Let me start with a warning.

    Whatever you do, please try all this in standalone Foglight server just to make sure this works correctly and works as planned (the script is from 2009). Keep in mind that once you run a script the changes stick so please test the results of scripts multiple times and test on a foglight server that you can delete/resintall until you make sure you got the right result.

    This is a script that came from Geoff Vona, thanks to Darren Mallette for finding this.

    Again,I can't emphasize enough,  please make sure you use this very carefully and test multiple times on a standalone server (crash test environment)  to verify it does what you want it to do. It should help you at least get to the right syntax.

     

    import com.quest.nitro.service.sl.interfaces.rule.*;

    def suspendRule(rule) {

      try {

          def ruleService = server.get("RuleService");

          print "Rule " + rule.getName() + " has only a WARNING condition, suspending the rule";

          ruleService.suspendRule(rule.getId())

      }

      catch (Exception e) {

        print e;

      }

    }

    def disableCondition(condition, rule) {

      try {

          def ruleService = server.get("RuleService");

          print "Disabling warning level rule for " + rule.getName();

          condition.setDisabled(true);

          ruleService.saveRule(rule);

      }

      catch (Exception e) {

        print e;

      }

    }

    def ruleService = server.get("RuleService");

    for (rule in ruleService.getAllRules()) {

        try {

            //print rule.getClass();

            //print rule.getName();

         if (rule instanceof SeverityFamilyRule) {

           //print "Severity Family Rule Found";

              ConditionalSeverity warning = ((SeverityFamilyRule)rule).getWarning();

              ConditionalSeverity critical = ((SeverityFamilyRule)rule).getCritical();

              ConditionalSeverity fatal = ((SeverityFamilyRule)rule).getFatal();

           if (warning) {

             if ((!critical && !fatal) ||

                 ((critical && critical.isDisabled()) && (fatal && fatal.isDisabled()))) {

               suspendRule(rule);

                }

             else {

               disableCondition(warning, rule);

                }

              }

            }

        }

        catch (ClassCastException cce) {

         print cce;

        }

    }

     

     

All Replies
  • Let me start with a warning.

    Whatever you do, please try all this in standalone Foglight server just to make sure this works correctly and works as planned (the script is from 2009). Keep in mind that once you run a script the changes stick so please test the results of scripts multiple times and test on a foglight server that you can delete/resintall until you make sure you got the right result.

    This is a script that came from Geoff Vona, thanks to Darren Mallette for finding this.

    Again,I can't emphasize enough,  please make sure you use this very carefully and test multiple times on a standalone server (crash test environment)  to verify it does what you want it to do. It should help you at least get to the right syntax.

     

    import com.quest.nitro.service.sl.interfaces.rule.*;

    def suspendRule(rule) {

      try {

          def ruleService = server.get("RuleService");

          print "Rule " + rule.getName() + " has only a WARNING condition, suspending the rule";

          ruleService.suspendRule(rule.getId())

      }

      catch (Exception e) {

        print e;

      }

    }

    def disableCondition(condition, rule) {

      try {

          def ruleService = server.get("RuleService");

          print "Disabling warning level rule for " + rule.getName();

          condition.setDisabled(true);

          ruleService.saveRule(rule);

      }

      catch (Exception e) {

        print e;

      }

    }

    def ruleService = server.get("RuleService");

    for (rule in ruleService.getAllRules()) {

        try {

            //print rule.getClass();

            //print rule.getName();

         if (rule instanceof SeverityFamilyRule) {

           //print "Severity Family Rule Found";

              ConditionalSeverity warning = ((SeverityFamilyRule)rule).getWarning();

              ConditionalSeverity critical = ((SeverityFamilyRule)rule).getCritical();

              ConditionalSeverity fatal = ((SeverityFamilyRule)rule).getFatal();

           if (warning) {

             if ((!critical && !fatal) ||

                 ((critical && critical.isDisabled()) && (fatal && fatal.isDisabled()))) {

               suspendRule(rule);

                }

             else {

               disableCondition(warning, rule);

                }

              }

            }

        }

        catch (ClassCastException cce) {

         print cce;

        }

    }

     

     

  • Thanks, this was exactly what I was looking for. Much appreciated!