myorama
3/21/2016 - 4:06 PM

Alertlog monitoring with Nagios check_logfiles script

Alertlog monitoring with Nagios check_logfiles script

-- -------------------------------------------------
-- Standard Dataguard configuration (mounted)
-- -------------------------------------------------
 
CONNECT nagiosadm/a4itti4a@<STANDBY_TNS> AS sysdba
 
variable sty_bdumpdir varchar2(250);
EXEC SELECT VALUE INTO :sty_bdumpdir FROM v$parameter  WHERE name='background_dump_dest';
 
CONNECT / AS sysdba
DECLARE
  BDumpDir  VARCHAR2(200);
  SID       VARCHAR2(16);
  ObjectExists EXCEPTION;
  PRAGMA EXCEPTION_INIT(ObjectExists,-955);
BEGIN
  -- get the bdump dir
  SELECT VALUE
  INTO BDumpDir
  FROM v$parameter
  WHERE name='background_dump_dest';
  -- create the directories for the bdump dir
  EXECUTE IMMEDIATE 'CREATE OR REPLACE DIRECTORY bdump_dir AS '''||BDumpDir||'''';
  EXECUTE IMMEDIATE 'CREATE OR REPLACE DIRECTORY bdump_dir_standby AS '''||:sty_bdumpdir||'''';
  -- grant the necessary privileges
  EXECUTE IMMEDIATE 'GRANT READ ON DIRECTORY bdump_dir TO system';
  EXECUTE IMMEDIATE 'GRANT READ ON DIRECTORY bdump_dir TO nagios';
  EXECUTE IMMEDIATE 'GRANT READ ON DIRECTORY bdump_dir_standby TO system';
  EXECUTE IMMEDIATE 'GRANT READ ON DIRECTORY bdump_dir_standby TO nagiosadm';
  -- get the SID
  SELECT instance_name INTO SID FROM v$instance;
  -- create the external tables
  EXECUTE IMMEDIATE 'CREATE TABLE system.alert_log_primary
    (TEXT VARCHAR2(255)
    ) ORGANIZATION EXTERNAL
    (TYPE ORACLE_LOADER
     DEFAULT DIRECTORY BDUMP_DIR
     ACCESS PARAMETERS
     (RECORDS DELIMITED BY NEWLINE
      NOBADFILE
      NOLOGFILE
      FIELDS MISSING FIELD VALUES ARE NULL
     )
     LOCATION (''alert_'||SID||'.log'')
    )
    REJECT LIMIT UNLIMITED';
    EXECUTE IMMEDIATE 'GRANT SELECT ON system.alert_log_primary TO nagios';
  EXECUTE IMMEDIATE 'CREATE TABLE system.alert_log_standby
    (TEXT VARCHAR2(255)
    ) ORGANIZATION EXTERNAL
    (TYPE ORACLE_LOADER
     DEFAULT DIRECTORY BDUMP_DIR_STANDBY
     ACCESS PARAMETERS
     (RECORDS DELIMITED BY NEWLINE
      NOBADFILE
      NOLOGFILE
      FIELDS MISSING FIELD VALUES ARE NULL
     )
     LOCATION (''alert_'||SID||'.log'')
    )
    REJECT LIMIT UNLIMITED';
    EXECUTE IMMEDIATE 'GRANT SELECT ON system.alert_log_standby TO nagiosadm';
-- ignore ORA-955 errors (object already exists)
EXCEPTION WHEN ObjectExists THEN NULL;
END;
/
 
CREATE OR REPLACE FUNCTION system.alert_log_date( text IN VARCHAR2 )
  RETURN DATE
IS
  InvalidDate  EXCEPTION;
  PRAGMA EXCEPTION_INIT(InvalidDate, -1846);
BEGIN
  RETURN TO_DATE(text,'Dy Mon DD HH24:MI:SS YYYY'
    ,'NLS_DATE_LANGUAGE=AMERICAN');
EXCEPTION
  WHEN InvalidDate THEN RETURN NULL;
END;
/
 
CREATE OR REPLACE FUNCTION system.oracle_to_unix(in_date IN DATE)
RETURN NUMBER
IS
BEGIN
  RETURN (in_date -TO_DATE('19700101','yyyymmdd'))*86400 -
  TO_NUMBER(SUBSTR(TZ_OFFSET(sessiontimezone),1,3))*3600;
END;
/
 
 
GRANT EXECUTE ON system.oracle_to_unix TO nagios, nagiosadm;
GRANT EXECUTE ON system.alert_log_date TO nagios, nagiosadm;
 
CREATE OR REPLACE FORCE VIEW nagios.alert_log AS
SELECT row_num
      ,LAST_VALUE(low_row_num IGNORE NULLS)
         OVER(ORDER BY row_num ROWS BETWEEN UNBOUNDED PRECEDING
         AND CURRENT ROW) start_row
      ,LAST_VALUE(alert_date  IGNORE NULLS)
         OVER(ORDER BY row_num ROWS BETWEEN UNBOUNDED PRECEDING
         AND CURRENT ROW) alert_date
      ,LAST_VALUE(alert_timestamp  IGNORE NULLS)
         OVER(ORDER BY row_num ROWS BETWEEN UNBOUNDED PRECEDING
         AND CURRENT ROW) alert_timestamp
      ,alert_text
FROM (SELECT ROWNUM row_num
            ,NVL2(system.alert_log_date(text),ROWNUM,NULL) low_row_num
            ,system.alert_log_date(text) alert_date
            ,system.oracle_to_unix(system.alert_log_date(text))
                alert_timestamp
            ,text alert_text
      FROM system.alert_log_primary
     )
;
CREATE OR REPLACE FORCE VIEW nagiosadm.alert_log AS
SELECT row_num
      ,LAST_VALUE(low_row_num IGNORE NULLS)
         OVER(ORDER BY row_num ROWS BETWEEN UNBOUNDED PRECEDING
         AND CURRENT ROW) start_row
      ,LAST_VALUE(alert_date  IGNORE NULLS)
         OVER(ORDER BY row_num ROWS BETWEEN UNBOUNDED PRECEDING
         AND CURRENT ROW) alert_date
      ,LAST_VALUE(alert_timestamp  IGNORE NULLS)
         OVER(ORDER BY row_num ROWS BETWEEN UNBOUNDED PRECEDING
         AND CURRENT ROW) alert_timestamp
      ,alert_text
FROM (SELECT ROWNUM row_num
            ,NVL2(system.alert_log_date(text),ROWNUM,NULL) low_row_num
            ,system.alert_log_date(text) alert_date
            ,system.oracle_to_unix(system.alert_log_date(text))
                alert_timestamp
            ,text alert_text
      FROM system.alert_log_standby
     )
;
 
 
DECLARE
  ObjectExists EXCEPTION;
  PRAGMA EXCEPTION_INIT(ObjectExists,-955);
BEGIN
  EXECUTE IMMEDIATE
      'CREATE PUBLIC SYNONYM alert_log FOR nagiosadm.alert_log';
-- If the synonym exists, drop and recreate it
EXCEPTION WHEN ObjectExists THEN
  EXECUTE IMMEDIATE 'DROP PUBLIC SYNONYM alert_log';
  EXECUTE IMMEDIATE
      'CREATE PUBLIC SYNONYM alert_log FOR nagiosadm.alert_log';
 
END;
/
 
EXEC DBMS_STATS.LOCK_TABLE_STATS('SYSTEM', 'ALERT_LOG_PRIMARY');
EXEC DBMS_STATS.LOCK_TABLE_STATS('SYSTEM', 'ALERT_LOG_STANDBY');
-- -------------------------------------------------
-- Standalone configuration
-- -------------------------------------------------
 
CONNECT / AS sysdba
DECLARE
  BDumpDir  VARCHAR2(200);
  SID       VARCHAR2(16);
  ObjectExists EXCEPTION;
  PRAGMA EXCEPTION_INIT(ObjectExists,-955);
BEGIN
  -- get the bdump dir
  SELECT VALUE
  INTO BDumpDir
  FROM v$parameter
  WHERE name='background_dump_dest';
  -- create the directory for the bdump dir
  EXECUTE IMMEDIATE 'CREATE OR REPLACE DIRECTORY bdump_dir AS '''||BDumpDir||'''';
  -- grant the necessary privileges
  EXECUTE IMMEDIATE 'GRANT READ ON DIRECTORY bdump_dir TO system';
  EXECUTE IMMEDIATE 'GRANT READ ON DIRECTORY bdump_dir TO nagios';
  -- get the SID
  SELECT instance_name INTO SID FROM v$instance;
  -- create the external table
  EXECUTE IMMEDIATE 'CREATE TABLE system.alert_log_external
    (TEXT VARCHAR2(255)
    ) ORGANIZATION EXTERNAL
    (TYPE ORACLE_LOADER
     DEFAULT DIRECTORY BDUMP_DIR
     ACCESS PARAMETERS
     (RECORDS DELIMITED BY NEWLINE
      NOBADFILE
      NOLOGFILE
      FIELDS MISSING FIELD VALUES ARE NULL
     )
     LOCATION (''alert_'||SID||'.log'')
    )
    REJECT LIMIT UNLIMITED';
    EXECUTE IMMEDIATE 'GRANT SELECT ON system.alert_log_external TO nagios';
-- ignore ORA-955 errors (object already exists)
EXCEPTION WHEN ObjectExists THEN NULL;
END;
/
 
CREATE OR REPLACE FUNCTION system.alert_log_date( text IN VARCHAR2 )
  RETURN DATE
IS
  InvalidDate  EXCEPTION;
  PRAGMA EXCEPTION_INIT(InvalidDate, -1846);
BEGIN
  RETURN TO_DATE(text,'Dy Mon DD HH24:MI:SS YYYY'
    ,'NLS_DATE_LANGUAGE=AMERICAN');
EXCEPTION
  WHEN InvalidDate THEN RETURN NULL;
END;
/
 
CREATE OR REPLACE FUNCTION system.oracle_to_unix(in_date IN DATE)
RETURN NUMBER
IS
BEGIN
  RETURN (in_date -TO_DATE('19700101','yyyymmdd'))*86400 -
  TO_NUMBER(SUBSTR(TZ_OFFSET(sessiontimezone),1,3))*3600;
END;
/
 
CREATE OR REPLACE FORCE VIEW system.alert_log AS
SELECT row_num
      ,LAST_VALUE(low_row_num IGNORE NULLS)
         OVER(ORDER BY row_num ROWS BETWEEN UNBOUNDED PRECEDING
         AND CURRENT ROW) start_row
      ,LAST_VALUE(alert_date  IGNORE NULLS)
         OVER(ORDER BY row_num ROWS BETWEEN UNBOUNDED PRECEDING
         AND CURRENT ROW) alert_date
      ,LAST_VALUE(alert_timestamp  IGNORE NULLS)
         OVER(ORDER BY row_num ROWS BETWEEN UNBOUNDED PRECEDING
         AND CURRENT ROW) alert_timestamp
      ,alert_text
FROM (SELECT ROWNUM row_num
            ,NVL2(system.alert_log_date(text),ROWNUM,NULL) low_row_num
            ,system.alert_log_date(text) alert_date
            ,system.oracle_to_unix(system.alert_log_date(text))
                alert_timestamp
            ,text alert_text
      FROM system.alert_log_external
     )
;
 
DECLARE
  ObjectExists EXCEPTION;
  PRAGMA EXCEPTION_INIT(ObjectExists,-955);
BEGIN
  EXECUTE IMMEDIATE
      'CREATE PUBLIC SYNONYM alert_log FOR system.alert_log';
-- If the synonym exists, drop and recreate it
EXCEPTION WHEN ObjectExists THEN
  EXECUTE IMMEDIATE 'DROP PUBLIC SYNONYM alert_log';
  EXECUTE IMMEDIATE
      'CREATE PUBLIC SYNONYM alert_log FOR system.alert_log';
 
END;
/
 
EXEC DBMS_STATS.LOCK_TABLE_STATS('SYSTEM', 'ALERT_LOG_EXTERNAL');
 
GRANT SELECT ON alert_log TO nagios ;
GRANT EXECUTE ON system.oracle_to_unix TO nagios ;
GRANT EXECUTE ON system.alert_log_date TO nagios ;
-- -------------------------------------------------
-- Cluster configuration
-- -------------------------------------------------
 
CONNECT / AS sysdba
 
CREATE OR REPLACE FUNCTION system.alert_log_date( text IN VARCHAR2 )
  RETURN DATE
IS
  InvalidDate  EXCEPTION;
  PRAGMA EXCEPTION_INIT(InvalidDate, -1846);
BEGIN
  RETURN TO_DATE(text,'Dy Mon DD HH24:MI:SS YYYY'
    ,'NLS_DATE_LANGUAGE=AMERICAN');
EXCEPTION
  WHEN InvalidDate THEN RETURN NULL;
END;
/
 
CREATE OR REPLACE FUNCTION system.oracle_to_unix(in_date IN DATE)
RETURN NUMBER
IS
BEGIN
  RETURN (in_date -TO_DATE('19700101','yyyymmdd'))*86400 -
  TO_NUMBER(SUBSTR(TZ_OFFSET(sessiontimezone),1,3))*3600;
END;
/
 
 DECLARE
  BDumpDir  VARCHAR2(200);
  BDumpDirName  VARCHAR2(40);
  SID       VARCHAR2(16);
  ObjectExists EXCEPTION;
  inst_id VARCHAR2(16) ;
  PRAGMA EXCEPTION_INIT(ObjectExists,-955);
BEGIN
  -- get current instance number
  SELECT TRIM(to_char(INSTANCE_NUMBER))
  INTO inst_id
  FROM v$instance;
  -- Define bdump dir name
  BDumpDirName := 'bdump_dir_'||inst_id ;
  -- get the bdump dir
  SELECT VALUE
    INTO BDumpDir
    FROM v$parameter
   WHERE name='background_dump_dest';
  -- Create user
  BEGIN
    EXECUTE IMMEDIATE 'CREATE USER nagios'||inst_id||' identified by n4g10s';
    EXECUTE IMMEDIATE 'GRANT CREATE SESSION TO nagios'||inst_id ;
    EXECUTE IMMEDIATE 'GRANT RESOURCE,CONNECT TO nagios'||inst_id ;
    EXECUTE IMMEDIATE 'GRANT SELECT ANY DICTIONARY TO nagios'||inst_id ;
  exception
  WHEN others THEN NULL;
  END ;
    -- create the directory for the bdump dir
  EXECUTE IMMEDIATE 'CREATE OR REPLACE DIRECTORY '||BDumpDirName||' AS '''||BDumpDir||'''';
  -- grant the necessary privileges
  EXECUTE IMMEDIATE 'GRANT READ ON DIRECTORY '||BDumpDirName||' TO system';
  EXECUTE IMMEDIATE 'GRANT READ ON DIRECTORY '||BDumpDirName||' TO nagios'||inst_id;
  -- get the SID
  SELECT instance_name INTO SID FROM v$instance;
  -- create the external table
  EXECUTE IMMEDIATE 'CREATE TABLE system.alert_log_external_'||inst_id||'
    (TEXT VARCHAR2(255)
    ) ORGANIZATION EXTERNAL
    (TYPE ORACLE_LOADER
     DEFAULT DIRECTORY '||BDumpDirName||'
     ACCESS PARAMETERS
     (RECORDS DELIMITED BY NEWLINE
      NOBADFILE
      NOLOGFILE
      FIELDS MISSING FIELD VALUES ARE NULL
     )
     LOCATION (''alert_'||SID||'.log'')
    )
    REJECT LIMIT UNLIMITED';
    EXECUTE IMMEDIATE 'GRANT SELECT ON system.alert_log_external_'||inst_id||' TO nagios'||inst_id;
-- ignore ORA-955 errors (object already exists)
EXCEPTION WHEN ObjectExists THEN NULL;
END;
/
 
DECLARE
  inst_id VARCHAR2(16) ;
BEGIN
  -- get current instance number
  SELECT TRIM(to_char(INSTANCE_NUMBER))
  INTO inst_id
  FROM v$instance;
--
  EXECUTE IMMEDIATE 'CREATE OR REPLACE FORCE VIEW system.alert_log_'||inst_id||' as
SELECT row_num
      ,LAST_VALUE(low_row_num IGNORE NULLS)
         OVER(ORDER BY row_num ROWS BETWEEN UNBOUNDED PRECEDING
         AND CURRENT ROW) start_row
      ,LAST_VALUE(alert_date  IGNORE NULLS)
         OVER(ORDER BY row_num ROWS BETWEEN UNBOUNDED PRECEDING
         AND CURRENT ROW) alert_date
      ,LAST_VALUE(alert_timestamp  IGNORE NULLS)
         OVER(ORDER BY row_num ROWS BETWEEN UNBOUNDED PRECEDING
         AND CURRENT ROW) alert_timestamp
      ,alert_text
FROM (SELECT ROWNUM row_num
            ,NVL2(system.alert_log_date(text),ROWNUM,NULL) low_row_num
            ,system.alert_log_date(text) alert_date
            ,system.oracle_to_unix(system.alert_log_date(text))
                alert_timestamp
            ,text alert_text
      FROM system.alert_log_external_'||inst_id||'
     )' ;
 
END;
/
 
DECLARE
  ObjectExists EXCEPTION;
  PRAGMA EXCEPTION_INIT(ObjectExists,-955);
  inst_id VARCHAR2(16) ;
BEGIN
  -- get current instance number
  SELECT TRIM(to_char(INSTANCE_NUMBER))
  INTO inst_id
  FROM v$instance;
--
BEGIN
  EXECUTE IMMEDIATE
      'CREATE SYNONYM nagios'||inst_id||'.alert_log FOR system.alert_log_'||inst_id;
-- If the synonym exists, drop and recreate it
EXCEPTION WHEN ObjectExists THEN
  EXECUTE IMMEDIATE 'DROP SYNONYM nagios'||inst_id||'.alert_log';
  EXECUTE IMMEDIATE
      'CREATE SYNONYM nagios'||inst_id||'.alert_log FOR system.alert_log_'||inst_id;
END ;
 
EXECUTE IMMEDIATE 'GRANT SELECT ON system.alert_log_'||inst_id||' TO nagios'||inst_id ;
EXECUTE IMMEDIATE 'GRANT SELECT ON system.alert_log_external_'||inst_id||' TO nagios'||inst_id ;
EXECUTE IMMEDIATE 'GRANT EXECUTE ON system.oracle_to_unix TO nagios'||inst_id ;
EXECUTE IMMEDIATE 'GRANT EXECUTE ON system.alert_log_date TO nagios'||inst_id ;
 
END;
/
-- -------------------------------------------------
-- Active Dataguard configuration
-- -------------------------------------------------
 
CONNECT nagios/n4g10s@<STANDBY_TNS>
 
variable sty_bdumpdir varchar2(250);
EXEC SELECT VALUE INTO :sty_bdumpdir FROM v$parameter  WHERE name='background_dump_dest';
 
CONNECT / AS sysdba
DECLARE
  BDumpDir  VARCHAR2(200);
  SID       VARCHAR2(16);
  ObjectExists EXCEPTION;
  PRAGMA EXCEPTION_INIT(ObjectExists,-955);
BEGIN
  -- get the bdump dir
  SELECT VALUE
  INTO BDumpDir
  FROM v$parameter
  WHERE name='background_dump_dest';
  -- create the directories for the bdump dir
  EXECUTE IMMEDIATE 'CREATE OR REPLACE DIRECTORY bdump_dir AS '''||BDumpDir||'''';
  EXECUTE IMMEDIATE 'CREATE OR REPLACE DIRECTORY bdump_dir_standby AS '''||:sty_bdumpdir||'''';
  -- grant the necessary privileges
  EXECUTE IMMEDIATE 'GRANT READ ON DIRECTORY bdump_dir TO system';
  EXECUTE IMMEDIATE 'GRANT READ ON DIRECTORY bdump_dir TO nagios';
  EXECUTE IMMEDIATE 'GRANT READ ON DIRECTORY bdump_dir_standby TO system';
  EXECUTE IMMEDIATE 'GRANT READ ON DIRECTORY bdump_dir_standby TO nagios_dg';
  -- get the SID
  SELECT instance_name INTO SID FROM v$instance;
  -- create the external tables
  EXECUTE IMMEDIATE 'CREATE TABLE system.alert_log_primary
    (TEXT VARCHAR2(255)
    ) ORGANIZATION EXTERNAL
    (TYPE ORACLE_LOADER
     DEFAULT DIRECTORY BDUMP_DIR
     ACCESS PARAMETERS
     (RECORDS DELIMITED BY NEWLINE
      NOBADFILE
      NOLOGFILE
      FIELDS MISSING FIELD VALUES ARE NULL
     )
     LOCATION (''alert_'||SID||'.log'')
    )
    REJECT LIMIT UNLIMITED';
    EXECUTE IMMEDIATE 'GRANT SELECT ON system.alert_log_primary TO nagios';
  EXECUTE IMMEDIATE 'CREATE TABLE system.alert_log_standby
    (TEXT VARCHAR2(255)
    ) ORGANIZATION EXTERNAL
    (TYPE ORACLE_LOADER
     DEFAULT DIRECTORY BDUMP_DIR_STANDBY
     ACCESS PARAMETERS
     (RECORDS DELIMITED BY NEWLINE
      NOBADFILE
      NOLOGFILE
      FIELDS MISSING FIELD VALUES ARE NULL
     )
     LOCATION (''alert_'||SID||'.log'')
    )
    REJECT LIMIT UNLIMITED';
    EXECUTE IMMEDIATE 'GRANT SELECT ON system.alert_log_standby TO nagios_dg';
-- ignore ORA-955 errors (object already exists)
EXCEPTION WHEN ObjectExists THEN NULL;
END;
/
 
CREATE OR REPLACE FUNCTION system.alert_log_date( text IN VARCHAR2 )
  RETURN DATE
IS
  InvalidDate  EXCEPTION;
  PRAGMA EXCEPTION_INIT(InvalidDate, -1846);
BEGIN
  RETURN TO_DATE(text,'Dy Mon DD HH24:MI:SS YYYY'
    ,'NLS_DATE_LANGUAGE=AMERICAN');
EXCEPTION
  WHEN InvalidDate THEN RETURN NULL;
END;
/
 
CREATE OR REPLACE FUNCTION system.oracle_to_unix(in_date IN DATE)
RETURN NUMBER
IS
BEGIN
  RETURN (in_date -TO_DATE('19700101','yyyymmdd'))*86400 -
  TO_NUMBER(SUBSTR(TZ_OFFSET(sessiontimezone),1,3))*3600;
END;
/
 
 
GRANT EXECUTE ON system.oracle_to_unix TO nagios, nagios_dg;
GRANT EXECUTE ON system.alert_log_date TO nagios, nagios_dg;
 
CREATE OR REPLACE FORCE VIEW nagios.alert_log AS
SELECT row_num
      ,LAST_VALUE(low_row_num IGNORE NULLS)
         OVER(ORDER BY row_num ROWS BETWEEN UNBOUNDED PRECEDING
         AND CURRENT ROW) start_row
      ,LAST_VALUE(alert_date  IGNORE NULLS)
         OVER(ORDER BY row_num ROWS BETWEEN UNBOUNDED PRECEDING
         AND CURRENT ROW) alert_date
      ,LAST_VALUE(alert_timestamp  IGNORE NULLS)
         OVER(ORDER BY row_num ROWS BETWEEN UNBOUNDED PRECEDING
         AND CURRENT ROW) alert_timestamp
      ,alert_text
FROM (SELECT ROWNUM row_num
            ,NVL2(system.alert_log_date(text),ROWNUM,NULL) low_row_num
            ,system.alert_log_date(text) alert_date
            ,system.oracle_to_unix(system.alert_log_date(text))
                alert_timestamp
            ,text alert_text
      FROM system.alert_log_primary
     )
;
CREATE OR REPLACE FORCE VIEW nagios_dg.alert_log AS
SELECT row_num
      ,LAST_VALUE(low_row_num IGNORE NULLS)
         OVER(ORDER BY row_num ROWS BETWEEN UNBOUNDED PRECEDING
         AND CURRENT ROW) start_row
      ,LAST_VALUE(alert_date  IGNORE NULLS)
         OVER(ORDER BY row_num ROWS BETWEEN UNBOUNDED PRECEDING
         AND CURRENT ROW) alert_date
      ,LAST_VALUE(alert_timestamp  IGNORE NULLS)
         OVER(ORDER BY row_num ROWS BETWEEN UNBOUNDED PRECEDING
         AND CURRENT ROW) alert_timestamp
      ,alert_text
FROM (SELECT ROWNUM row_num
            ,NVL2(system.alert_log_date(text),ROWNUM,NULL) low_row_num
            ,system.alert_log_date(text) alert_date
            ,system.oracle_to_unix(system.alert_log_date(text))
                alert_timestamp
            ,text alert_text
      FROM system.alert_log_standby
     )
;
 
EXEC DBMS_STATS.LOCK_TABLE_STATS('SYSTEM', 'ALERT_LOG_PRIMARY');
EXEC DBMS_STATS.LOCK_TABLE_STATS('SYSTEM', 'ALERT_LOG_STANDBY');