08 May 2020

Tablespace thresholds and alerts

การ monitor เกี่ยวกับการใช้งานพื้นที่ Database แล้วสามารถส่งการแจ้งเตือนได้

การกำหนดเงื่อนไขต่างๆ

- OBJECT_NAME คือ parameter สำหรับกำหนดชื่อของ Tablespace ที่ต้องการ ถ้ากำหนด NULL จะหมายถึงกำหนด thresholds ด้วยค่า default ให้กับทุก Tablespace

- TABLESPACE_PCT_FULL สำหรับกำหนดการแจ้งเตือนของ warning หรือ critical ด้วย threshold แบบ percent full
- TABLESPACE_BYT_FREE สำหรับกำหนดการแจ้งเตือนของ warning หรือ critical ด้วย threshold แบบ bytes free หน่วย KB
      กรณี Cloud Control จะแสดงหน่วย MB

- OPERATOR_LE คือ Less than หรือ equal
- OPERATOR_GE คือ Greater than หรือ equal

การกำหนด Thresholds
จาก https://oracle-base.com/articles/misc/tablespace-thresholds-and-alerts

ที่ tool EM จะแสดง Thresholds ที่ Menu "Metric and Policy Settings" > "Metric Thresholds"
หรือ Menu "All Metrics" ที่หน้าจอเลือก "Tablespaces Full" > "Tablespace Space Used (%)" จะพบ tablespace ต่างๆ เมื่อเลือก tablespace
ที่ต้องการจะเข้าหน้าจอแสดง Tablespace Space Used (%): Tablespace Name ชื่อTablespace: Last 24 hours ที่หน้าจอ Metric Value

SQL> BEGIN
  -- ตัวอย่าง Database-wide KB free threshold
  dbms_server_alert.set_threshold(
    metrics_id              => dbms_server_alert.tablespace_byt_free,
    warning_operator        => dbms_server_alert.operator_le,
    warning_value           => '1024000',
    critical_operator       => dbms_server_alert.operator_le,
    critical_value          => '102400',
    observation_period      => 1,
    consecutive_occurrences => 1,
    instance_name           => NULL,
    object_type             => dbms_server_alert.object_type_tablespace,
    object_name             => NULL);
 
  -- ตัวอย่าง Database-wide percent full threshold
  dbms_server_alert.set_threshold(
    metrics_id              => dbms_server_alert.tablespace_pct_full,
    warning_operator        => dbms_server_alert.operator_ge,
    warning_value           => '85',
    critical_operator       => dbms_server_alert.operator_ge,
    critical_value          => '97',
    observation_period      => 1,
    consecutive_occurrences => 1,
    instance_name           => NULL,
    object_type             => dbms_server_alert.object_type_tablespace,
    object_name             => NULL);

  -- ตัวอย่าง Tablespace-specific KB free threshold
  dbms_server_alert.set_threshold(
    metrics_id              => dbms_server_alert.tablespace_byt_free,
    warning_operator        => dbms_server_alert.operator_le,
    warning_value           => '1024000',
    critical_operator       => dbms_server_alert.operator_le,
    critical_value          => '102400',
    observation_period      => 1,
    consecutive_occurrences => 1,
    instance_name           => NULL,
    object_type             => dbms_server_alert.object_type_tablespace,
    object_name             => 'USERS');
 
  -- ตัวอย่าง Tablespace-specific percent full threshold
  dbms_server_alert.set_threshold(
    metrics_id              => dbms_server_alert.tablespace_pct_full,
    warning_operator        => dbms_server_alert.operator_ge,
    warning_value           => '90',
    critical_operator       => dbms_server_alert.operator_ge,
    critical_value          => '98',
    observation_period      => 1,
    consecutive_occurrences => 1,
    instance_name           => NULL,
    object_type             => dbms_server_alert.object_type_tablespace,
    object_name             => 'USERS');
 
  -- ตัวอย่าง Tablespace-specific reset to defaults
  -- Set warning and critical values to NULL.
  --dbms_server_alert.set_threshold(
  --  metrics_id              => dbms_server_alert.tablespace_pct_full,
  --  warning_operator        => dbms_server_alert.operator_ge,
  --  warning_value           => NULL,
  --  critical_operator       => dbms_server_alert.operator_ge,
  --  critical_value          => NULL,
  --  observation_period      => 1,
  --  consecutive_occurrences => 1,
  --  instance_name           => NULL,
  --  object_type             => dbms_server_alert.object_type_tablespace,
  --  object_name             => 'USERS');
END;
/

แสดง Thresholds
จาก https://oracle-base.com/articles/misc/tablespace-thresholds-and-alerts

ที่ tool EM จะแสดง Thresholds ที่ Menu "Metric and Policy Settings" > "Metric Thresholds"

set linesize 200
column tablespace_name format a30
column metrics_name format a30
column warning_value format a30
column critical_value format a15
SQL> select object_name as tablespace_name,
       metrics_name,
       warning_operator,
       warning_value,
       critical_operator,
       critical_value
from   dba_thresholds
where  object_type = 'TABLESPACE'
order by object_name;
TABLESPACE_NAME                METRICS_NAME                   WARNING_OPER WARNING_VALUE                  CRITICAL_OPE CRITICAL_VALUE
------------------------------ ------------------------------ ------------ ------------------------------ ------------ ---------------
TEMP                           Tablespace Space Usage         DO NOT CHECK    DO_NOT_CHECK 0
UNDOTBS1                       Tablespace Space Usage         DO NOT CHECK    DO_NOT_CHECK 0
UNDOTBS2                       Tablespace Space Usage         DO NOT CHECK    DO_NOT_CHECK 0
USERS                          Tablespace Bytes Space Usage   LE           1024000                        LE           102400
USERS                          Tablespace Space Usage         GE           90                             GE           98
                               Tablespace Space Usage         GE           85                             GE           97
                               Tablespace Bytes Space Usage   LE           1024000                        LE           102400
 
set linesize 200
column metrics_name format a30
column warning_value format a30
column critical_value format a15
SQL> select tablespace_name,
       contents,
       extent_management,
       threshold_type,
       metrics_name,
       warning_operator,
       warning_value,
       critical_operator,
       critical_value
from   dba_tablespace_thresholds
order by tablespace_name;
TABLESPACE_NAME                CONTENTS  EXTENT_MAN THRESHOL METRICS_NAME                   WARNING_OPER WARNING_VALUE                  CRITICAL_OPE CRITICAL_VALUE
------------------------------ --------- ---------- -------- ------------------------------ ------------ ------------------------------ ------------ ---------------
EXAMPLE                        PERMANENT LOCAL      DEFAULT  Tablespace Space Usage         GE           85                             GE           97
EXAMPLE                        PERMANENT LOCAL      DEFAULT  Tablespace Bytes Space Usage   LE           1024000                        LE           102400
SYSAUX                         PERMANENT LOCAL      DEFAULT  Tablespace Space Usage         GE           85                             GE           97
SYSAUX                         PERMANENT LOCAL      DEFAULT  Tablespace Bytes Space Usage   LE           1024000                        LE           102400
SYSTEM                         PERMANENT LOCAL      DEFAULT  Tablespace Bytes Space Usage   LE           1024000                        LE           102400
SYSTEM                         PERMANENT LOCAL      DEFAULT  Tablespace Space Usage         GE           85                             GE           97
TEMP                           TEMPORARY LOCAL      EXPLICIT Tablespace Space Usage         DO NOT CHECK    DO NOT CHECK 0
UNDOTBS1                       UNDO      LOCAL      EXPLICIT Tablespace Space Usage         DO NOT CHECK    DO NOT CHECK 0
USERS                          PERMANENT LOCAL      EXPLICIT Tablespace Bytes Space Usage   LE           1024000                        LE           102400
USERS                          PERMANENT LOCAL      EXPLICIT Tablespace Space Usage         GE           90                             GE           98

แสดง alert ที่เกิดขึ้น

แสดงประวัติของการแจ้งเตือนที่ผ่านมาทั้งหมด ที่กำหนดโดย DBMS_SERVER_ALERT
ที่ tool EM จะแสดงที่ Menu "Alert History"
หรือ Menu "All Metrics" ที่หน้าจอเลือก "Tablespaces Full" > "Tablespace Space Used (%)" จะพบ tablespace ต่างๆ เมื่อเลือก tablespace
ที่ต้องการจะเข้าหน้าจอแสดง Tablespace Space Used (%): Tablespace Name ชื่อTablespace: Last 24 hours ที่หน้าจอ Alert History
SQL> select reason_id, object_name, object_type, reason, time_suggested, suggested_action
from dba_alert_history
where object_name in ('USERS','USERS2');
order by time_suggested desc;
REASON_ID OBJECT_NAME OBJECT_TYPE REASON TIME_SUGGESTED SUGGESTED_ACTION
----------- --------------- -------------------------------------------------------------- ------------------------------------ -----------------------------
9 USERS TABLESPACE Tablespace [USERS] is [70 percent] full 2020-05-12 3:00:00 AM -08:00 Add space to the tablespace
9 USERS2 TABLESPACE Tablespace [USERS2] is [83 percent] full 2020-05-14 4:00:00 PM -08:00 Add space to the tablespace

แสดงการแจ้งเตือนที่กำลังเกิดขึ้นอยู่ทั้งหมด
ที่ tool EM จะแสดงที่หน้า Home ในหน้าจอ "Alert"
SQL> select creation_time, metric_value, message_type, reason, suggested_action
  from dba_outstanding_alerts
 where object_name in ('USERS','USERS2');