Moogsoft Docs

Implement Situation Server Tools

Situation Server Tools in Moogsoft AIOps are tools that enable a user to execute a utility on a remote host. These tools specify a command and arguments that are run using the Tool Runner servlet, which is configured to connect to the remote host.

  • The command can be anything you can run on the host in a Linux terminal command line, such as an inbuilt part of the OS (for example, ping) or your own script.

  • The arguments are extracted from Situation attributes by prefixing the attribute name with '$', such as $description for the Situation description.

In Moogsoft AIOps, the Situation Server Tools managed here are only available from ChatOps in the Situation Room. See Take Additional Actions in the Operator Guide for more information.

The steps below describe how to create a Situation Server Tool, its availability filter, command and arguments. You can also create Situation Server Tools via a command prompt.

Manage Situation Server Tools

Go to System Settings > Tools > Situation Server Tools to open the configuration window:

  • Click the + to create a new tool

  • Fill in the available fields to define the tool. These are listed in the table below:

    Field

    Input

    Description

    Name

    String (Mandatory)

    The name for the Situation Server Tool (up to 100 characters). This appears in ChatOps when accessing the tool.

    Description

    String(Optional)

    The text description of the tool.

    Context Filter

    Filter(Optional)

    Click the pencil icon to create a filter for specific criteria which Situations must match for this tool to be available.

    Command

    String(Mandatory)

    This is the file path of the command.

    Please note: This command must be an accessible path on the host system. The host system and access information is defined in the Tool Runner servlet.

    Arguments

    String

    This is the specific input for the command, which can use Situation attributes. To use Situation attributes, type '$' as a prefix and enter the attribute you want from the drop down list.

    Run For

    Boolean +Integer

    If enabled, you can define the number of seconds the tool runs for. The minimum value for this field is 5 seconds.

    To prevent substitution with potentially malicious commands, arguments are escaped using a backslash.

    For example:

    Command: echo

    Argument: $args (where $args is echo_something; rm file.txt)

    This results in the following command being executed:

    echo echo_something\; rm file.txt

    The semi-colon is escaped to prevent the rm command from being run.

  • Click Save Changes to create the new tool. This appears in the list to the left of the screen.

  • To discard any changes, click Revert Changes and confirm when prompted.

Note

You can also create Situation Server Tools via a command prompt.

Example

The screenshot below shows a Situation Server Tool called 'LogSitnDetails' with the Command: /home/moog/bin/logger.sh.

SituationsServer1_FINAL.JPG

This tool runs the script logger.sh on the remote host which logs Situation details to a file. The details logged are the Situation ID, created time, description and total number of alerts, which are defined with the Arguments: ig_id $created_at $description $total_alerts.

Each Situation attribute name is prefixed with $. The Context Filter makes this tool available only for Closed Situations.

Create a Tool with a Command Prompt

You can create Situation Server Tools via a command prompt. This is useful for efficient creation of multiple tools using a scripted process, for example:

  • Open a new Terminal window on the Moogsoft AIOps system and type the following:

    moog_add_sitn_server_tool
  • Type any flags and arguments for the tool settings. See the examples below.

    Note

    Moogsoft AIOps command line tools are located here:

    $MOOGSOFT_HOME/utils

    To display the help information for this tool, type:

    moog_add_sitn_server_tool and press Enter.

    Use a double-dash prefix "--" to define all following text as arguments. This ensures arguments are not misinterpreted as flags.

    For example, "-- -c" to define the argument "-c", which would otherwise be interpreted as the command flag.

  • When you have defined the tool, press Enter. If successful, "Tool was added" appears.

    Note

    If there is a mistype, the help information appears.

    If the tool name already exists, the message "Error: A tool named: [toolname] already exists." appears.

    If a Run for time of less than 5 seconds is typed, the message "Error: The run_for value is too small. Please provide a value no smaller than 5 seconds." appears.

Once the UI is refreshed, newly created tools appear in the Situation Server Tools configuration window.

Examples

moog_add_sitn_server_tool --name "Sitn Id" --desc "Get the Situation ID" --cmd echo --args "Situation ID = \$sig_id" --run_for 42
  • Name: Sitn ID (--name "Sitn ID"). Quotes are required because there is a space in the name.

  • Description: Get the Situation ID (--desc "Get the Situation ID")

  • Context Filter: none

  • Command: echo (--cmd echo)

  • Arguments: display 'Situation ID = ID'

  • (--args "Situation ID = \$sig_id"). The backslash is required to escape the '$' because it is an environment variable.

  • Run for: 42 seconds (--run_for 42)

moog_add_sitn_server_tool -d "five pings" -m "sig_id<10" -c ping -a -- -c 5

This creates a tool with the following settings:

  • Description: five pings (-d "five pings")

  • Context Filter: ID < 10 (-m "sig_id<10")

  • Command: ping (-c ping)

  • Arguments: ping five times (-- -c 5). The argument starts with -c which is itself a tool flag. Therefore the "--" double-dash prefix is used to interpret -c 5 as an argument, and not a flag.

  • Run for: no time set (no -r flag and argument)

  • Name: ping. The name is not defined here (no -n flag and argument) so the Command is used as the name by default.

Available Situation Arguments

The available Situation arguments are as follows:

affected_entities

category

Created_at

delta_entities

delta_priority

description

first_event_time

internal_priority

last_event_time

last_state_change

moderator_id

participants

process_list

queue

rating.rating

service_list

sig_id

status

story_id

teams

total_alerts

user

user_comments

username