Auto-Reaction Method: Execute Operating System Command
Use
You can execute any operating system command as an auto-reaction to a monitoring architecture alert. The auto-reaction method CCMS_AUTO_REACT_OP_COMMAND is available to you for this purpose. For security reasons, this does, however, apply only for those commands that have previously been defined in External Operating System Commands (transaction SM69).
The key feature of this auto-reaction method is that you can transfer details about the alert to the operating system command as parameters. Use method parameters to do this, which can contain arguments that are in turn replaced by the relevant alert data at runtime.
In detail, the auto-reaction method has the following method parameters:
| Method Parameter | Meaning |
|---|---|
|
COMMAND |
Logical command that is to be executed in the case of an alert |
|
PARAMETERS |
Static parameter to which you transfer the logical command |
|
REACT_ON_ALERTS |
Alert color at which the auto-reaction method is to be started YELLOW: Only start the method for yellow alerts RED: Only start the method for red alerts <anything else>: Start the method for all alerts |
|
MTENAME |
SID/SEGMENT/CONTEXT/OBJECT/ATTRIBUTE; if an alert occurs, the arguments are filled with the relevant values (see below) |
|
PARAMLIST_1 |
Additional parameters that are transferred to the operating system command; these can contain arguments in addition to normal text (see below) |
|
PARAMLIST_2 |
|
|
PARAMLIST_3 |
|
|
PARAMLIST_4 |
The following arguments in the method parameters MTENAME and PARAMLIST_<n> are replaced by the relevant values at runtime:
| Argument | Meaning |
|---|---|
|
SID |
System ID of the system in which the alert occurred |
|
CONTEXT |
Monitoring context of the MTE |
|
OBJECT |
Monitoring object of the MTE |
|
ATTRIBUTE |
Monitoring attribute of the MTE |
|
SEGMENT |
Monitoring segment of the MTE |
|
COLOR |
Color of the alert (YELLOWor RED) |
|
SEVERITY |
Severity of the alert |
|
DATE TIME |
Date and time of the alert (system date and system time) |
|
CLIENT |
Client of the user under which the alert was generated |
|
USER |
User under which the alert was generated (this information is not always available) |
|
REPORTER |
Function or C source that is responsible for the creation of the alert |
|
CLASS |
Message class (such as SAP-SYSLOGor SAP-T100) |
|
ID |
Class and number of the message (such as A04) |
|
ARG1 ARG2 ARG3 ARG4 |
Arguments of the message |
|
TXT |
Text of the message without arguments (in system language) |
|
MSG |
Expanded message with arguments (in system language) |
|
MSCGL |
global external line ID |
Prerequisites
You must define the desired operating system command in the External Operating System Commands transaction. To do this, proceed as follows:
- Choose CCMS → Configuration → External Commands, or call transaction SM69.
- Choose change mode with the Display «Change (
) button, and choose Create (
). - Now enter details about the desired operating system command, ensure that the Additional Parameters Allowed indicator is activated, and save your entries.
The optional static parameter, which you defined in the input field Parameter for Operating System Command in transaction SM69, is first transferred to the operating system command. Which other parameters are additionally transferred to the command depends on the configuration of the corresponding auto-reaction method.
Procedure
Copy Method
We recommend that you leave the original method CCMS_AUTO_REACT_OP_COMMAND unchanged and use it only as a template for your methods. In this way, you can set up as many logical commands as you wish as auto-reactions.
- Choose CCMS → Configuration → Alert Monitor, or call transaction RZ21.
- In the Methods group box, select Method Definitions and choose Display Overview.
- Select the method CCMS_AUTO_REACT_OP_COMMAND and choose Copy (
). - Enter the desired name and save your entries.
Adjust Method Parameters and Release Method
- Select the copy of the method that you have just created and choose Edit Data (
). - The Monitoring: Methods screen appears. Choose change mode with the Display «Change (
) button. - Choose the Parameters tab page, and set the logical command to be executed and the other method parameters (see above).
- Choose the Release tab page and in the Execute Method as group box, select Auto-Reaction Method.
- Save your entries.
Assigning the Method to the Desired Node
You must now assign the method to the desired MTEs or MTE classes. You can use either transaction RZ20 (only for the active properties variant) or transaction RZ21 to do this (see also Changing Properties and Method Assignments). Assignment using transaction RZ20 is described below:
- Start the Alert Monitor using transaction RZ20 or choose CCMS → Control/Monitoring → Alert Monitor.
- Start the desired monitor from the list by double-clicking it.
- Select the desired node and choose Properties.
- The Monitoring: Properties and Methods screen appears. Choose the Methods tab page and then choose the Method Assignmentbutton.
- The Monitoring: Methods screen appears. The rest of the procedure depends on whether you want to assign the analysis method only to this node or to the entire MTE class.
Assign Analysis Method to the Selected MTE Class
- Choose the name of the MTE class in the header data of the screen by double-clicking it, and then choose the change mode with the Display «Change (
) button. - In the Auto-Reaction Method group box, choose Method Name and, in the associated field, enter the method that you created as described above.
- Save your entries.
Assign Analysis Method to Only this MTE
- Choose change mode with the Display «Change (
) button, and choose the Auto-Reaction tab page. - In the Method Assignment group box, choose Method Name and, in the associated field, enter the method that you created as described above.
- Save your entries.
Result
If an alert is triggered for one of the MTEs to which you have assigned this auto-reaction method, the monitoring architecture will automatically execute the corresponding logical command.
Example
Alerts are to be logged. To do this, a file with the name alert_<date>_<time>.txt is to be created, which contains information about the alert, such as:
yellow alert from 'PDR/SAP_CCMS_pdrhost_PRD_00/prdhost_PRD_00/R3Syslog/BasisSystem' A04 'Load format of SAPLQDIS abload1 0413 invalid.'
- Use the method CCMS_AUTO_REACT_OP_COMMAND as a template for your own method. The parameters MTENAME and PARAMLIST_1 are already filled by default. Add the command Z_TEST and the parameter ID under PARAMLIST_2:
Parameter Parameter Value COMMAND
Z_TEST
PARAMETERS
REACT_ON_ALERTS
MTENAME
SID/SEGMENT/CONTEXT/OBJECT/ATTRIBUTE
PARAMLIST_1
COLOR DATE_TIME MSG
PARAMLIST_2
ID
PARAMLIST_3
PARAMLIST_4
- In transaction SM69, define the logical command Z_TESTfor the Linux operating system; specify the Linux script test.sh in it (it must be possible for user <SID>adm to execute this script)
- In transaction SM69, define the logical command Z_TEST for the Windows NT operating system; specify the Microsoft Windows script test.cmd in it.
With the settings that you have just adjusted, the following command is executed if an alert occurs:
- Linux:
test.sh '<SID>/<SEGMENT>/<CONTEXT>/<OBJECT>/<ATTRIBUTE>' <COLOR> <DATE>_<TIME> '<MSG>' <ID>
- Microsoft Windows:
test.cmd '<SID>/<SEGMENT>/<CONTEXT>/<OBJECT>/<ATTRIBUTE>' <COLOR>
<DATE>_<TIME> '<MSG>' <ID>
- Linux:
- Create a script that generates a file with the name alert_<date>_<time>.txt:
- Linux script test.sh:
#!/usr/bin/shecho $2 alert from $1 Message $5 $4 > alert_$3.txt
- Microsoft Windows script test.cmd:
echo %2 alert from %1 Message %5 %4 > alert_%3.txt
If you are not using absolute path specifications, the file is stored in the DIR_HOME directory.
- Linux script test.sh: