Collector to Execute System Shell Commands

The technical name of the Collector to Execute System Shell Commands is /DVD/MON_CL_COL_SYS_CMD.

This collector can execute predefined or custom shell commands and extract any basic information from the output of the command execution. Note that this collector will not report a complete command output, but only a numerical value based on the defined KPI and its regular expression specified in the input table. There are two ways to define system commands in the input table:

  1. Use an existing SXPG command name as already defined in transactions SM49 or SM69.

    1. If the defined SXPG command needs to be executed on remote SAP system(s), it must also be created and defined on the monitored remote SAP system.

    2. SXPG commands provide a safer way of executing custom system commands. For example, a custom check module can be set for any additional checks before the execution.

  2. Use a custom command. The custom command string is directly defined in the collector input table.

    1. If this command needs to be executed on remote SAP system(s), it does not need to be defined on the monitored remote SAP system. It is directly executed on the remote SAP system.

    2. There is no possibility to define any other additional checks except the predefined collector checks. For example, authorization checks for executing system commands.

NOTE In both scenarios, the user who is executing this collector needs to have assigned authorizations for executing system commands.
NOTE This collector works for Linux-based and Windows-based systems, but system commands from Linux will not work on a Windows-based system. We recommend using predefined SXPG commands instead of custom commands because SXPG commands can be tested directly on the specific system in transaction SM49 or SM69.

Default KPIs Delivered with This Collector

The following default KPI is delivered with this collector. This KPI is not in the default monitoring scope and serves as a template KPI for creating a new custom KPI.

KPI name

Description

Unit

OS_RUN_PS_COUNT

Number of running processes on OS

Count

NOTE

If you want to calculate a custom KPI based on a system command, you must define a custom KPI starting with Y* or Z* first. You can use the template KPI OS_RUN_PS_COUNT to define a custom KPI.

When you create any custom KPI, you must assign it to this collector as described in the chapter Creating a Custom KPI via a Collector with a Custom KPI.

Input Table

The collector uses the input table /DVD/MON_SYSCMD1.

The rules in the input table define the list of system commands based on which the specified KPIs are calculated. It contains the following fields:

Technical name

Column name

Description

KPI

KPI

Specifies the name of the KPI to which the rule applies (custom Y* or Z* KPI created in previous step).

COMMAND_NAME

Command name

Specifies the SXPG command name. You must fill this field if you want to use an existing SXPG command defined in transaction SM49 or SM69.

If you do not want to use an SXPG command but rather use a custom command, leave this field empty.

COMMAND_TEXT

Command text

Specifies a custom system command definition. If you are already using an SXPG command, leave this field empty.

If you want to use a custom system command, enter the text of the command into this field. For example, the Linux command ps or the Windows command ipconfig.

Custom commands also support the pipe symbol | and quotation marks “”. However, we still recommend using predefined commands for longer and more complex command executions.

ADD_PARAMS

Additional parameters

Specifies additional parameters for the command execution. You can use this field for both command types: SXPG commands or custom commands.

REGEXP

Regular expression

Specifies a regular expression to be applied and matched in the executed command output. The command output is parsed, and every occurrence of the defined regex will be counted in the KPI calculation.

REQ_VALUE

Requested value

Defines the value for the KPI calculation. The KPI can only be only a numerical value. You can define the following requested values:

  • EXISTS: The KPI reports any occurrence of the regex that is found in the command output.

  • COUNT: The KPI calculates the number of regex occurrences in the command output.

  • NUMBER: The KPI reports the numerical index of the first regex occurrence in the command output. For example, if the command output is HELLO and the regex is supposed to match the character E, the KPI reports the value 2.

CHANGED_BY

Changed by user

Last changed by user [automatically filled]

CHANGED_AT

Change date

Last change date [automatically filled]

CREATED_BY

Created by

Created by user [automatically filled]

CREATED_AT

Created at

Creation time [automatically filled]

Examples

These examples explain how to format your system commands based on the script that you want to use. You can define either an entire command in the Command text field or split it into the fields Command text and Additional parameters. Note that you will not be able to extract the raw output of this command and report it as a KPI, but you must also enter a valid value in the Requested value field with a valid regular expression.

Linux-based system:

  • Basic shell command

    • ps -aux | grep "Java" – command counts how many processes run under Java

  • Bash

    • bash -c "echo $SAPSYSTEMNAME" – command prints the SAP system name

  • Perl

    • echo `perl -MPOSIX -le 'print strftime "%Y-%m-%d-%H.%M.%S",gmtime(1636897305)'` – command formats the Unix timestamp as a real timestamp

Windows-based system:

  • Basic CMD command

    • driverquery /FO list /v – command returns a list of installed drivers

  • PowerShell

    • powershell "Get-Service | Where-Object {$_.Status -match 'Running'}" – command prints all running services at the OS level

  • Perl

    • perl -e "print 55" – command prints the number 55