Skip to main content

Implement Situation Server Tools

Situation server tools in Moogsoft Onprem are tools that enable a user to execute a utility on a remote host.

These tools specify a command that is run using ToolRunner, which is configured to connect to the remote host. The command can be anything that is executable from the Linux command line. For example a ping or cat or a custom bash script. See Configure Tool Runner for more information.

  • The command can be anything you can run on the host in a Linux terminal command line, such as an inbuilt part of the operating system, such as 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 Onprem, 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.

You can make tools available to all users, specified teams, specified roles, or yourself only.

Create a new Situation server tool

To create a new Situation server tool:

  1. Click Situation Server Tools in the Tools section of the Settings tab.

  2. On the Tool tab, click the + to create a new tool.

  3. Fill in the available fields to define the tool:

    Field

    Input

    Description

    Name

    String (Required)

    Name for the Situation server tool (up to 100 characters). This appears in ChatOps when accessing the tool.

    Description

    String

    Text description of the Situation server tool.

    Context Filter

    Filter

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

    Command

    String (Required)

    File path of the command. 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

    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 you select this check box, 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.

  4. On the Shared With tab, select whether you want to share this tool with everyone, specific teams, specific roles or only yourself. You must have the permission share_filters_public to share a tool with all users. You must have the permission share_filters_teams to share a tool with specific teams. See Manage Roles for more information.

  5. If you select to share the tool with specific teams or specific roles, add the teams or roles you want to share the tool with to the list below.

  6. Click Save Changes to add the tool to the list of Situation server tools in the left hand pane.

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 Onprem 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 Onprem command line tools are located here:

    $MOOGSOFT_HOME/bin/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.

    If included, the Run For time must be 5 seconds or longer.

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

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

Examples

The following example creates a Situation server tool to return the Situation ID:

moog_add_sitn_server_tool --name "Sitn Id" --desc "Get the Situation ID" --cmd echo --args "Situation ID = \$sig_id" --run_for 42

This command creates a tool with the following settings:

  • Name: Sitn ID (--name "Sitn ID").

  • 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)

The following example creates a Situation server tool that pings the server five times:

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

This command 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.

To learn more, watch the Client and Server Tool Configuration training video at Moogsoft University. You will need access credentials to view it. Please contact your account manager to receive credentials.