Passing corrective action status change attributes such as new status, job name, job type, notification rule, or rule owner to PL/SQL procedures or OS commands/scripts allows you to customize automated responses to status changes. For example, you many want to call an OS script to open a trouble ticket for an in-house support trouble ticket system if a critical corrective action fails to run. In this case you will want to pass status such as Problems or Aborted to the script to open a trouble ticket and escalate the problem. Corrective Actions can run in response to metric severities and policy violations.
The notification system passes corrective action status change information to a PL/SQL procedure via the MGMT_NOTIFY_CORRECTIVE_ACTION object. An instance of this object is created for every status change. When a corrective action changes status, the notification system calls the PL/SQL procedure associated with the notification rule and passes the populated object to the procedure. The procedure is then able to access the fields of the MGMT_NOTIFY_CORRECTIVE_ACTION object that has been passed to it.
The following table lists all job status change attributes that can be passed:
| Attribute |
Datatype |
Additional Information |
|---|---|---|
| job_name |
VARCHAR2(128) |
The job name |
| job_owner |
VARCHAR2(256) |
The owner of the job |
| job_type | VARCHAR2(32) | The type of the job |
| job_status |
NUMBER |
The new status of the job |
| state_change_guid |
RAW(16) |
The GUID of the state change record |
| job_guid |
RAW(16) |
The unique id of the job |
| execution_id |
RAW(16) |
The unique id of the execution |
| targets |
SMP_EMD_NVPAIR_ARRAY |
An array of the target name/target type
pairs that the job runs on |
| metric_name |
VARCHAR2(256) |
The name of the metric/policy rule in the
alert that caused the corrective action to run |
| metric_column |
VARCHAR2(64) |
The name of the metric column in the alert
that caused the corrective action to run. This is not used for policy
violations. |
| metric_value |
VARCHAR2(1024) |
The value of the metric column in the alert that caused the corrective action to run |
| severity_code |
NUMBER |
The severity code of the alert that caused the corrective action to run |
| key_value_name |
VARCHAR2(512) |
The name of the key value e.g. Mount Point |
| key_value |
VARCHAR2(1290) |
For table metrics, this column contains the value of the key column for the row in the table whose thresholds are being defined. If the thresholds are not for a table metric, or the thresholds apply for all rows in the metric column, then the value in this column will contain a single space. |
| key_value_guid |
RAW(16) |
GUID associated with a composite key value name. |
| ctxt_list |
MGMT_NOTIFY_COLUMNS |
Details of the alert context |
| rule_owner |
VARCHAR2(64) |
The name of the notification rule that cause
the notification to be sent |
| rule_name |
VARCHAR2(132) |
The owner of the notification rule that cause the notification to be sent |
When a status change occurs for the corrective action, the notification system creates an instance of the MGMT_NOTIFY_CORRECTIVE_ACTION object and populates it with values from the status change. The following status codes have been defined as constants in the MGMT_JOBS package and can be used to determine the type of status in the job_status field of the MGMT_NOTIFY_CORRECTIVE_ACTION object.
| Name |
Datatype |
Value |
|---|---|---|
| SCHEDULED_STATUS |
NUMBER(2) |
1 |
| EXECUTING_STATUS |
NUMBER(2) |
2 |
| ABORTED_STATUS |
NUMBER(2) |
3 |
| FAILED_STATUS |
NUMBER(2) |
4 |
| COMPLETED_STATUS |
NUMBER(2) |
5 |
| SUSPENDED_STATUS |
NUMBER(2) |
6 |
| AGENTDOWN_STATUS |
NUMBER(2) |
7 |
| STOPPED_STATUS |
NUMBER(2) |
8 |
| SUSPENDED_LOCK_STATUS |
NUMBER(2) |
9 |
| SUSPENDED_EVENT_STATUS |
NUMBER(2) |
10 |
| SUSPENDED_BLACKOUT_STATUS |
NUMBER(2) |
11 |
| STOP_PENDING_STATUS |
NUMBER(2) | 12 |
| SUSPEND_PENDING_STATUS |
NUMBER(2) | 13 |
| INACTIVE_STATUS |
NUMBER(2) | 14 |
| QUEUED_STATUS |
NUMBER(2) | 15 |
| FAILED_RETRIED_STATUS |
NUMBER(2) | 16 |
| WAITING_STATUS |
NUMBER(2) | 17 |
| SKIPPED_STATUS |
NUMBER(2) | 18 |
| REASSIGNED_STATUS |
NUMBER(2) | 20 |
CREATE TABLE ca_log (jobid RAW(16),
occured DATE);
CREATE OR REPLACE PROCEDURE LOG_PROBLEM_CAS(status_change IN MGMT_NOTIFY_CORRECTIVE_ACTION)
IS
BEGIN
-- Log all failed corrective actions
IF status_change.job_status = MGMT_JOBS.FAILED_STATUS
THEN
BEGIN
INSERT INTO ca_log (jobid, occured)
VALUES (status_change.job_guid, SYSDATE);
EXCEPTION
WHEN OTHERS
THEN
-- If there are any problems then get the notification retried
RAISE_APPLICATION_ERROR(-20000, 'Please retry');
END;
COMMIT;
END IF;
END LOG_PROBLEM_CAS;
Create the PL/SQL procedure on the repository database using the following procedure specification:
PROCEDURE p(status_change IN MGMT_NOTIFY_CORRECTIVE_ACTION)
If an error is encountered during the running of the procedure, the Notification System can be instructed to retry the sending of the notification to the procedure by raising a user defined exception that uses the error code -20000. See the example above. The procedure initially retried after one minute, then two minutes, then three minutes and so on, until the notification is a day old, at which point it will be purged.
Add this PLSQL procedure as a notification method that can be called in Notification Rules. See Adding a PLSQL Procedure.
Make sure to use a fully qualified name that includes the schema owner, package name and procedure name. The procedure will be executed by the repository owner and so the repository owner must have EXECUTE permission on the procedure.
Associate the PL/SQL procedure with a notification rule.
The notification system passes severity information to an OS script or executable via system environment variables. Conventions used to access environmental variables vary depending on the operating system:
UNIX: $ENV_VARIABLE
MS Windows: %ENV_VARIABLE%
The notification system sets the following environment variables before calling the script.
| Environment Variable |
Description |
|---|---|
| JOB_NAME |
The name of the job |
| JOB_OWNER |
The owner of the job |
| JOB_TYPE |
The type of job |
| JOB_STATUS |
The job status |
| TIMESTAMP |
Time when the severity occurred. |
| NUM_TARGETS |
The number of targets |
| TARGET_NAMEn |
The name of the nth target e.g. TARGET_NAME1,
TARGET_NAME2 |
| TARGET_TYPEn |
The type of the nth target e.g. TARGET_TYPE1, TARGET_TYPE2 |
| METRIC |
The name of the metric in the alert that
caused the corrective action to run. Not set for policy violations |
| POLICY_RULE |
The name of the policy rule in the alert
that caused the corrective action to run. Not set for metric severities |
| METRIC_VALUE |
The value of the metric column in the alert that caused the corrective action to run |
| VIOLATION_CONTEXT |
A comma-separated list of name-value pairs that show the alert context |
| KEY_VALUE_NAME |
Name of the key value. Example: Mount Point |
| KEY_VALUE |
For table metrics, this value represents the key column for the row in the table whose thresholds are being defined. This information is used to uniquely identify the specific value that is being collected. Together with the target name, target type, and metric name, the metric value can be uniquely identified. |
| SEVERITY |
Type of severity. For example, severity types that relate to a target's availability are:
Other metrics can have any of the following severities:
|
| RULE_NAME |
Name of the notification rule that resulted in the severity. |
| RULE_OWNER |
Name of the Enterprise Manager administrator who owns the rule. |
Your script may reference some or all of these variables.
Create an OS command on the repository host machine.
Create an OS Command on each Management Service machine that connects to the Management Repository. The OS Command should be an absolute pathname and must be the same on each Management Service host machine e.g. /u1/bin/logSeverity.sh. The command is run by the user who started the Management Service. If an error is encountered during the running of the OS Command, the Notification System can be instructed to retry the sending of the notification to the OS Command by returning an exit code of 100. The procedure is initially retried after one minute, then two minutes, then three minutes and so on, until the notification is a day old, at which point it will be purged.
The following parameter in emoms.properties controls how long the OS Command can execute without being killed by the Management Service. This is to prevent OS Commands from running for an inordinate length of time and blocking the delivery of other notifications. By default the command is allowed to run for 30 seconds before it is killed. See (add a pointer to the other doc that discusses all these parameters)
# The amount of time in seconds after which an OS Command started by the
# Notification System will be killed if it has not exited
# em.notification.os_cmd_timeout=30
Add this OS command as a notification method that can be called in Notification Rules. See Adding an OS Command.
Define a notification rule (choose the targets and conditions for which you want to be notified), and associate the OS command with the rule. See Defining Notification Rules.
Enterprise Manager Information Roadmap
Copyright © 1996, 2007, Oracle. All rights reserved.