this group of metrics gives you the availability and status of the managed database. metrics include:database status、da
this group of metrics gives you the availability and status of the managed database. metrics include:database status、database process check、aximum # of sessions since startup and availability. 在oracle10g中引入了metric,,用来监控数据库表空间,如下实例:
1、确认现有的metric
sql> conn / as sysdba
已连接。
sql> select count(1) from dba_thresholds;
count(1)
----------
22
2、创建表空间
sql> select metric_id,metric_name from v$metricname where metric_name like'%space%'
2 ;
metric_id metric_name
---------- ----------------------------------------------------------------
9001 tablespace bytes space usage
9000 tablespace space usage
sql> create tablespace tbs_lw datafile '/opt/oracle/oradata/charge/tbs_lw01.dbf' size 10m;
表空间已创建。
3、创建新的metric
sql> begin dbms_server_alert.set_threshold (dbms_server_alert.tablespace_pct_full,null, null, null, null, 1, 1, null, dbms_server_alert.object_type_tablespace, 'tbs_lw');end;
2 /
pl/sql 过程已成功完成。
4、查看新创建的metric
sql> select count(1) from dba_thresholds;
count(1)
----------
23
sql> select warning_value, critical_value, status from dba_thresholds where metrics_name = 'tablespace space usage' and object_name = 'tbs_lw';
warning_value critical_value status
-------------------- -------------------- -------
80 95 valid
5、模拟一个表数据增长达到threshold
sql> create table t1 tablespace tbs_lw as select * from user_objects;
表已创建。
sql> select count(*) from t1;
count(*)
----------
30060
sql> insert into t1 select * from t1 where rownum
已创建4000行。
sql> insert into t1 select * from t1 where rownum
已创建4000行。
sql> commit;
提交完成。
6、查看是否生效
sql> select reason, message_level,decode(message_level, 5, 'warning', 1, 'critical') alert_level from dba_outstanding_alerts where object_name = 'tbs_lw';
reason message_level alert_le
-------------------------------------------------- ------------- --------
表空间 [tbs_lw] 已占用 [90 percent] 5 warning
7、停用metric
sql> begin dbms_server_alert.set_threshold (dbms_server_alert.tablespace_pct_full,dbms_server_alert.operator_do_not_check, '0',dbms_server_alert.operator_do_not_check, '0', 1, 1, null,dbms_server_alert.object_type_tablespace, 'tbs_lw');end;
2 /
pl/sql 过程已成功完成。
sql> select warning_value, critical_value, status from dba_thresholds where metrics_name = 'tablespace space usage' and object_name = 'tbs_lw';
warning_value critical_value status
-------------------- -------------------- -------
0 0 valid
8、取消metric
begin dbms_server_alert.set_threshold (dbms_server_alert.tablespace_pct_full,null, null, null, null, 1, 1, null, dbms_server_alert.object_type_tablespace, 'tbs_lw');end;
2 /
pl/sql 过程已成功完成。
sql> select warning_value, critical_value, status from dba_thresholds where metrics_name = 'tablespace space usage' and object_name = 'tbs_lw';
未选定行