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).
To use the auto-reaction method, ensure that you are using a current SAPXPG from the SAP Service Marketplace (http://service.sap.com/swdc ® Download ® Support Packages and Patches ® Entry by Application Group ® SAP NetWeaver ® SAP NETWEAVER ® SAP NETWEAVER 04 ® Entry by Component ® AS ABAP ®SAP KERNEL 6.40 32/64-BIT ®<Platform> ®Database independent).
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 COMMAND parameter is required, all other parameters are optional.
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 (YELLOW or RED) |
SEVERITY |
Severity of the alert |
DATE |
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-SYSLOG or SAP-T100) |
ID |
Class and number of the message (such as A04) |
ARG1 |
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 |
Note that parameters that are transferred to operating system commands must be separated by spaces. The following parts of the parameters, which may contain spaces, are therefore enclosed in single quotation marks ( ‘ ) for UNIX and quotation marks ( “ ) for Microsoft Windows:
· All arguments that were specified under MTENAME
· The argument MSG
· The argument TXT
In this way, all parts of the MTE name and the arguments MSG and TXT are each identified as one parameter.
Separate all other arguments in the method parameters by space, if these are to be recognized as independent parameters. A space is automatically inserted between the arguments of MTENAME and PARAMLIST_<n> (see also the example below). If two arguments are to be identified as one parameter, do not place a space between the arguments.
Note also, that an argument can only be specified once in MTENAME and in all PARAMLIST_* parameters.
You must define the desired operating system command in the External Operating System Commands transaction. To do this, follow the procedure below:
...
1. Choose CCMS ® Configuration ® External Commands, or call transaction SM69.
2. Choose change mode with the Display « Change () button, and choose Create ().
3. Now enter details about the desired operating system command, ensure that the Additional Parameters Allowed indicator is activated, and save your entries.
§ Note that during the definition of the auto-reaction method, you must no longer enter the name of the operating system command, but rather the name of the (logical) command.
§ If you are using operating system for the application servers in your monitoring system, create a logical command with the same name but different operating system for each operating system. You can specify different scripts or executables when doing so.
§ Ensure that the script or executable can be called by user <SID>adm from all hosts. You can perform this test using transaction SM49.
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.
For information about defining the command, see External Operating System Commands: Content.
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.
...
1. Choose CCMS ® Configuration ® Alert Monitor, or call transaction RZ21.
2. In the Methods group box, select Method Definitions and choose Display Overview.
3. Select the method CCMS_AUTO_REACT_OP_COMMAND and choose Copy ().
4. Enter the desired name and save your entries.
Adjust Method Parameters and Release Method
5. Select the copy of the method that you have just created and choose Edit Data ().
6. The Monitoring: Methods screen appears. Choose change mode with the Display « Change () button.
7. Choose the Parameters tab page, and set the logical command to be executed and the other method parameters (see above).
8. Choose the Release tab page and in the Execute Method as group box, select Auto-Reaction Method.
9. Save your entries.
By default, the operating system command is executed on the local server of the MTE that generated the alert. If the command is to be executed on a different server, change the execution location on the Execution tab page in the Execute Method On group box.
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:
10. Start the Alert Monitor using transaction RZ20 or choose CCMS ® Control/Monitoring ® Alert Monitor.
11. Start the desired monitor from the list by double-clicking it.
12. Select the desired node and choose Properties.
13. The system displays the Monitoring: Properties and Methods screen. Choose the Methods tab page and then choose the Method Assignment button.
14. 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.
15. 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.
16. In the Auto-Reaction Method group box, choose Method Name and, in the associated field, enter the method that you created as described above.
17. Save your entries.
18. Choose change mode with the Display « Change () button, and choose the Auto-Reaction tab page.
19. In the Method Assignment group box, choose Method Name and, in the associated field, enter the method that you created as described above.
20. Save your entries.
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.
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.'
...
1. 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 |
|
2. In transaction SM69, define the logical command Z_TEST for the Linux operating system; specify the Linux script test.sh in it (it must be possible for user <SID>adm to execute this script)
3. In transaction SM69, define the logical command Z_TEST for the Windows NT operating system; specify the Microsoft Windows script test.cmd in it.
Allow additional parameters for both logical commands.
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>
4. Create a script that generates a file with the name alert_<date>_<time>.txt:
¡ Linux script test.sh:
#!/usr/bin/sh
echo $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.