Passing Metric Severity/Policy Information

Passing metric severity attributes (severity level, type, notification rule, or rule owner, etc.)  to PL/SQL procedures or OS commands/scripts allows you to customize automated responses to alerts. For example, if an OS script opens a trouble ticket for an in-house support trouble ticket system, you will want to pass severity levels (critical, warning, etc.) to the script to open a trouble ticket and escalate the problem. Information on policy violations such as violation level,  notification rule, or rule owner can also be passed to PL/SQL procedures using the same mechanism as for metric severities.

Passing Information to a PLSQL Procedure

The notification system passes severity information to a PL/SQL procedure via the MGMT_NOTIFY_SEVERITY object. An instance of this object is created for every alert. When an alert occurs, 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_SEVERITY object that has been passed to it.

The following table lists all metric severity attributes that can be passed:

Attribute
Datatype
Additional Information

target_name

VARCHAR2(64)

The target name

target_type

VARCHAR2(64)

The target type
timezone VARCHAR2(64) The target's regional timezone.

host_name

VARCHAR2(128)

The name of the host on which the target resides

metric_name

VARCHAR2(64)

The name of the metric/policy that caused the alert

metric_description

VARCHAR2(128)

The description of the metric/policy

metric_column

VARCHAR2(64)

For table metrics, the metric column contains the name of the column in the table that is being defined. If the metric that is being defined is not a table metric, the value in this column is a single space. This is not used for policy violations.

metric_value
VARCHAR2(1024)
The value of the metric
key_value_name
VARCHAR2(512) Name of the key value. Example: Mount Point
key_value_guid
VARCHAR2(256) GUID associated with a composite key value name.

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.

ctxt_list
MGMT_NOTIFY_COLUMNS
Details of the alert context

collection_timestamp

DATE

The time when the target status change was last detected and logged in the management repository.

severity_code

NUMBER

Numeric code identifying the severity level. See Severity Code table below.

message

VARCHAR2(4000)

An optional message that is generated when the alert is created that provides additional information about the alert condition.

severity_guid

RAW(16)

The GUID of the severity/violation
metric_guid RAW(16) The GUID of the metric/policy
target_guid RAW(16) The GUID of the target

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 severity occurs for the target, the notification system creates an instance of the MGMT_NOTIFY_SEVERITY object and populates it with values from the severity. The following severity codes have been defined as constants in the MGMT_GLOBAL package and can be used to determine the type of severity in the severity_code field of the MGMT_NOTIFY_SEVERITY object.

Severity Codes

Name
Datatype
Value

G_SEVERITY_COMMENT

NUMBER(2)

10

G_SEVERITY_CLEAR

NUMBER(2)

15

G_SEVERITY_WARNING

NUMBER(2)

20

G_SEVERITY_CRITICAL

NUMBER(2)

25

G_SEVERITY_UNREACHABLE_CLEAR

NUMBER(3)

115

G_SEVERITY_UNREACHABLE_START

NUMBER(3)

125

G_SEVERITY_BLACKOUT_END

NUMBER(3)

215

G_SEVERITY_BLACKOUT_START

NUMBER(3)

225

G_SEVERITY_ERROR_END

NUMBER(3)

315

G_SEVERITY_ERROR_START

NUMBER(3)

325

G_SEVERITY_NO_BEACONS

NUMBER(3)

425

G_SEVERITY_UNKNOWN NUMBER(3) 515

Example: PL/SQL Procedure Using a Severity Code

CREATE TABLE alert_log (target_name VARCHAR2(64),
alert_msg VARCHAR2(4000),
occured DATE);

PL/SQL Procedure

CREATE OR REPLACE PROCEDURE LOG_CRITICAL_ALERTS(severity IN MGMT_NOTIFY_SEVERITY)
IS
BEGIN
-- Log all critical severities
IF severity.severity_code = MGMT_GLOBAL.G_SEVERITY_CRITICAL
THEN
BEGIN
INSERT INTO alert_log (target_name, alert_msg, occured)
VALUES (severity.target_name, severity.message,
severity.collection_timestamp);
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_CRITICAL_ALERTS;

Using a PL/SQL Procedure:

  1. Create the PL/SQL procedure on the repository database using the following procedure specification:

    PROCEDURE p(severity IN MGMT_NOTIFY_SEVERITY)

    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.

  2. 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.

  3. Associate the PL/SQL procedure with a notification rule.

Passing Information to an OS Script or Executable

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:

The notification system sets the following environment variables before calling the script.

Environment Variable
Description

TARGET_NAME

Name of the target on which the severity occurred.

TARGET_TYPE

Type of target on which the severity occurred. Targets are defined as any monitorable service.

HOST

Name of the machine on which the target resides.

METRIC

Metric generating the severity.

METRIC_VALUE
The value of the metric when threshold was execeeded. Not set for policy violations
POLICY_RULE
The name of the policy when threshold was exceeded. Not set for metric severities
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.

VIOLATION_CONTEXT
A comma-separated list of name-value pairs that show the alert context

TIMESTAMP

Time when the severity occurred.

SEVERITY

Type of severity. For example, severity types that relate to a target's availability are:

  • Up

  • Down

  • Unreachable Clear

  • Unreachable Start

  • Blackout End

  • Blackout Start

Other metrics can have any of the following severities:

  • Warning

  • Critical

  • Clear

  • Metric Error Clear

  • Metric Error Start

MESSAGE

Message for the alert that provides details about what triggered the condition.

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.

Using an OS Script or Executable

Related Topics

Enterprise Manager Information Roadmap