Corrective actions triggered from Foglight to address space alarms

Similar to what's been discussed in this post earlier -  How to configure corrective action against alarm
I am trying to implement a corrective action triggered via Foglight to auto-remediate SQL server space alarms e.g. increase max size of file and so on

I read the answer that was added to the post cited above but it seems the answer is incomplete.

1) Does RemoteCommandAction (rule recovery action) require FGLAM to be installed on the host where the command needs to be executed i.e. should the SQL DB monitored host have FGLAM installed? 
2) Scripting action pack - Can this be used to execute Powershell scripts on the SQL monitored host (no FGLAM installed)? If yes, are there any examples available ?

Any other suggestions on how I can go about implementing corrective action triggered via Foglight, keeping in mind action needs to be triggered on a remote monitored host (Windows) hosting a SQL instance and no FGLAM or FMS installed on the host?

Many Thanks

Parents
  • HI,

    To add I tried testing a RemoteCommandAction (rule action) on one of the Foglight rules.

     

    Instructions as per - https://www.quest.com/community/blogs/b/performance-monitoring/posts/foglight-play-some-funky-music

     

    When I try to save the rule action it doesn't allow me to save and pops up with an error message as follows:

     

    Error evaluating validation binding: com.quest.wcf.publicapi.code.FunctionInvocationException: Error executing script id=system:administration_rulesnotifications_rulemanagement_create20rule.validateAllRabs name="'Validate All Tabs' from the System module Administration/Rules & Notifications/Rules/Create Rule" message: com.quest.nitro.service.sl.interfaces.scripting.ScriptingException: com.quest.nitro.service.sl.interfaces.scripting.ScriptAbortException: com.quest.wcf.publicapi.code.FunctionInvocationException: Error executing script id=system:administration_rulesnotifications_rulemanagement_create20rule.validateTheConditionTab name="'Validate The Condition Tab' from the System module Administration/Rules & Notifications/Rules/Create Rule" message: com.quest.nitro.service.sl.interfaces.scripting.ScriptingException: com.quest.nitro.service.sl.interfaces.scripting.ScriptAbortException: java.lang.IllegalArgumentException: Type not found: core_commons:Result ----script start------ package system._administration_rulesnotifications_rulemanagement_create20rule.scripts; import com.quest.wcf.data.messages.ErrorMessage; def megs = []; if (!ruleObj) { return megs.add(new ErrorMessage("System Error: The Data Object of rule if not existing.")); } def ruleType = ruleObj.get("ruleType", specificTimeRange); def cartridgeName = ruleObj.get("cartridgeName", specificTimeRange); if (ruleType == "Simple Rule") { def fireSeverityLevelObj = ruleObj.get("fireSeverityLevelObj", specificTimeRange); def condition = fireSeverityLevelObj.get("condition", specificTimeRange); if (!condition || condition.length() <= 0) { megs.add(new ErrorMessage("Condition cannot be empty")); } else { def resultObj = functionHelper.createDataObject("core_commons:Result", "none", null); def result = functionHelper.invokeFunction("system:administration_rulesnotifications_rulemanagement_create20rule.validateCondation", condition, resultObj, cartridgeName); def type = result.get("resultType", specificTimeRange); ---- script end ------ ----script start------ package system._administration_rulesnotifications_rulemanagement_create20rule.scripts; def allMegs = []; def megsForDefinition = functionHelper.invokeFunction("system:administration_rulesnotifications_rulemanagement_create20rule.validateTheRuleDefinitionTab", ruleObj); if (megsForDefinition && megsForDefinition.size() > 0) { allMegs.addAll(megsForDefinition); } megsForCondition = functionHelper.invokeFunction("system:administration_rulesnotifications_rulemanagement_create20rule.validateTheConditionTab", ruleObj); if (megsForCondition && megsForCondition.size() > 0) { allMegs.addAll(megsForCondition); } megsForBehavior = functionHelper.invokeFunction("system:administration_rulesnotifications_rulemanagement_create20rule.validateTheBehaviorTab", ruleObj); if (megsForBehavior && megsForBehavior.size() > 0) { allMegs.addAll(megsForBehavior); } return allMegs; ---- script end ------ in view: 'system:administration_rulesnotifications_rulemanagement_create20rule.ruleEditor'

    Any help I can get on the error would be helpful.

    Thanks

  • not sure what you try to do with that code but

    functionHelper.createDataObject("core_commons:Result", "none", null)

    creates an object in Foglight, that seems to fail, maybe that dataobject is not defined in Foglight, never did that

    maybe try something simpler

    use groovy to write a file to disk or something, you an also use groovy to execute some external binary or script.

    	import java.io.File
    	org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog("TESTINGFOGLIGHT");
    	File dir = new File("my_directory");
    	dir.mkdirs();
    	File file = new File(dir.toString()+File.separator+ "my_file")
    	log.info("TEST CODE CALLED")
    	file.write "TEST FILE WRITTEN"

    code is untested (based off something else i've got running here) but this should appear in the foglight directory

    update: forgot an import

Reply
  • not sure what you try to do with that code but

    functionHelper.createDataObject("core_commons:Result", "none", null)

    creates an object in Foglight, that seems to fail, maybe that dataobject is not defined in Foglight, never did that

    maybe try something simpler

    use groovy to write a file to disk or something, you an also use groovy to execute some external binary or script.

    	import java.io.File
    	org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog("TESTINGFOGLIGHT");
    	File dir = new File("my_directory");
    	dir.mkdirs();
    	File file = new File(dir.toString()+File.separator+ "my_file")
    	log.info("TEST CODE CALLED")
    	file.write "TEST FILE WRITTEN"

    code is untested (based off something else i've got running here) but this should appear in the foglight directory

    update: forgot an import

Children
  • Thanks a lot for taking time to reply. I restarted FGLAM and hardcoded the agent FQDN in the Host Name parameter of the RemoteCommanAction (Foglight rule action), the error got resolved. I have attached a few screen shots to lend us an idea of what I am trying to achieve.

    Is there a way I can pass parameters to the Command Line specified in the RemoteCommandAction e.g. monitored host name, monitored agent name and scope.parent_node.name?

     

    My objective is to use the RemoteCommandAction specified command line which is executed on the FGLAM node (when the rule triggers) to fire up a powershell remoting command on the SQL node thus I need to pass the parameters (as stated above) to the commandline.