Moogsoft Docs

Invoking custom functionality

To invoke custom javascript for a particular set of actions related to Situations you can leverage the Empty Moolet to listen for these actions and use the data within the Situations involved. For example, when a Situation is closed you may want to notify an external entity via the REST.V2 module.

Create Moobot

  1. Edit moog_farmd.conf to associate a Moobot (CustomTaskRunner) with the EmptyMoolet, and listen for SigAction events:

        name               : "CustomTaskRunner",
        classname          : "CEmptyMoolet",
        run_on_startup     : true,
        metric_path_moolet : false,
        moobot             : "CustomTaskRunner.js",
        event_handlers     : [ 

Example of Moobot code that runs a function when a supported Situation action occurs in Moogsoft AIOps:

var events = MooBot.loadModule('Events');
var logger = MooBot.loadModule('Logger');
var constants = MooBot.loadModule('Constants');
logger.debug("Empty Moolet Started.");
 * ### situationAction
 * Listen for specific "sigAction"
 * @param {object} situation - A situation object from Events
function situationAction(situation) {
    logger.warning("Checking Action event...");
    var sitn_id = situation.value("situation_id");
    var action = situation.payload().valueOf("action");
    if (action !== null) {
        var details = situation.getActionDetails();
        // The name of the URL Tool has to match to trigger action
        if (action == "Ran Tool") {
            if (details.tool == urlToolName) {
 * ### runFunction
 * Run some function
 * @param {number} sitn_id - The Situation Id
function runFunction(sitn_id) {'Run some function for Situation Id ' + sitn_id);
// Listen for SigAction event to see if certain URL tool has been run

The urlToolName must match the name of the Situation URL Tool.  The Situation Id is available in the Event payload, because the tool is run in the context of a particular situation.