So what are Metric Extensions?
As the name implies metric extensions enables us to extend the out-of-the-box monitoring capabilities of Enterprise Manager and customize it according to the requirements of our specific environment.
Very often we may have some monitoring and alerting requirements for which metrics are not available in OEM and we are having to run external scripts outside OEM.
For example we would like to be alerted and notified via OEM in the following circumstances:
- Standby database lags behind the Primary database by more than 5 archive log files
- There are failed DBMS jobs
- In case some key program units become INVALID
- In case a very important index becomes unusable or is dropped ….. and so on.
We can achieve all of the above by creating metric extensions in EM 12c.
The EM 12c Metric Extensions note shows us how to create a metric extension to raise an incident and be notified if one of the critical DBMS_SCHEDULER_JOBS fails for any reason. The metric extension checks for the job status of ‘BROKEN’ to raise a critical event which will then send an email notification to the administrator.
We first create a metric extension as a deployable draft, test it, deploy it to required targets and also publish it. Metric extensions can also be part of a monitoring template.
The note shows the various screen shots of creating and deploying a metric extension in EM 12c.
Note – we can set up email notification for failed DBMS Scheduler Jobs outside of OEM as well using the DBMS_SCHEDULER package.
BEGIN DBMS_SCHEDULER.set_scheduler_attribute('email_server', 'mail.soorma.com:25'); DBMS_SCHEDULER.set_scheduler_attribute('email_sender', 'email@example.com'); END; /
job_name => ‘TEST_JOB’,
recipients => ‘firstname.lastname@example.org’,
sender => ‘email@example.com’,
subject => ‘Scheduler Job Notification-%job_owner%.%job_name%-%event_type%’,
body => ‘%event_type% occurred at %event_timestamp%. %error_message%’,
events => ‘JOB_FAILED, JOB_BROKEN’);
This is an example of the email alert we will be sent:
JOB_FAILED occurred at 05-JAN-15 01.32.22.808171 PM +08:00. ORA-01653: unable to extend table SYSTEM.MYOBJECTS by 128 in tablespace GAVIN
ORA-06512: at line 3