Dontcheff

Remove old Grid Control warnings

In Grid Control, PL/SQL on July 21, 2010 at 08:09

If you use Grid Control and want to delete some old warning messages and the “clear alert” button does not help, then use the following PL/SQL block. Run it as SYSMAN. Depending on the number of alerts the cursor fetches, the delete might take up to a minute or so.

You can do masive deletes based on the message text, for example:


CREATE OR REPLACE PROCEDURE DELETE_ALERTS_LIKE(P_LIKE in varchar2)
is
V_LIKE varchar2(22);
   CURSOR c1 IS
     SELECT s.target_guid,
            s.metric_guid,
            s.key_value
       FROM mgmt_targets t JOIN mgmt_current_severity s
            ON s.target_guid = t.target_guid
      WHERE s.message LIKE '%'||v_like||'%'; 
BEGIN
V_LIKE := P_LIKE;
    FOR r IN c1 LOOP
       em_severity.delete_current_severity(r.target_guid,r.metric_guid,r.key_value);
       DELETE from sysman.mgmt_severity
       WHERE
         target_guid = r.target_guid AND
         metric_guid = r.metric_guid AND
         key_value = r.key_value;
       COMMIT;
    END LOOP;
END;
/

Now, let us remove all warnings about invalid objects:

DELETE_ALERTS_LIKE('invalid');

You can even make a procedure which will remove with just one command all old alerts having ‘job’,’invalid’,’status’ or ‘resource’ in the text message:

CREATE or REPLACE TYPE t_greshki IS TABLE OF VARCHAR2(22);
/

CREATE OR REPLACE PROCEDURE DELETE_ALERTS
is
l_greshki t_greshki := t_greshki(,'job','invalid','status','resource');
BEGIN
    FOR i IN l_greshki.first .. l_greshki.last LOOP
       DELETE_ALERTS_LIKE(l_greshki(i));
       COMMIT;
    END LOOP;
END;
/

exec DELETE_ALERTS;

Pretty useful for me at least.

Advertisements
  1. Great procedure. Works for Warnings and Criticals.
    Eric

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: