orabbix插件监控oracle表空间问题

 我们安装好orabbix插件后,查看Tablespaces监控项是发项值为none,第一反应是没监控成功,其实不然。

1、我们打开orabbix监控项参数的路径,下面为Tablespaces的sql代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
[root@-svr1 ~]# vim /opt/orabbix/conf/query.props
 
select '- Tablespace ->',t.tablespace_name ktablespace, \
       '- Type->',substr(t.contents, 1, 1) tipo, \
       '- Used(MB)->',trunc((d.tbs_size-nvl(s.free_space, 0))/1024/1024) ktbs_em_uso, \
       '- ActualSize(MB)->',trunc(d.tbs_size/1024/1024) ktbs_size, \
       '- MaxSize(MB)->',trunc(d.tbs_maxsize/1024/1024) ktbs_maxsize, \
       '- FreeSpace(MB)->',trunc(nvl(s.free_space, 0)/1024/1024) kfree_space, \
       '- Space->',trunc((d.tbs_maxsize - d.tbs_size + nvl(s.free_space, 0))/1024/1024) kspace, \
       '- Perc->',decode(d.tbs_maxsize, 0, 0, trunc((d.tbs_size-nvl(s.free_space, 0))*100/d.tbs_maxsize)) kperc \
from \
  ( select SUM(bytes) tbs_size, \
           SUM(decode(sign(maxbytes - bytes), -1, bytes, maxbytes)) tbs_maxsize, tablespace_name tablespace \
    from ( select nvl(bytes, 0) bytes, nvl(maxbytes, 0) maxbytes, tablespace_name \
    from dba_data_files \
    union all \
    select nvl(bytes, 0) bytes, nvl(maxbytes, 0) maxbytes, tablespace_name \
    from dba_temp_files \
    ) \
    group by tablespace_name \
    ) d, \
    ( select SUM(bytes) free_space, \
    tablespace_name tablespace \
    from dba_free_space \
    group by tablespace_name \
    ) s, \
    dba_tablespaces t \
    where t.tablespace_name = d.tablespace(+) and \
    t.tablespace_name = s.tablespace(+) \
    order by 8) \
    where kperc > 93 \
    and tipo <>'T' \
    and tipo <>'U'
tbl_space.NoDataFound=none

这个SQL会返回93%满的表空间信息,而对应这个监控项,orabbix也定义了触发器,因为监控项的返回值是文本,而没有满足条件的记录时返回字符串“none“,所以监控项对应的触发器会检查返回值开头是不是none,如果不是,就报警,这样,用户除了收到预警信息,还能从返回值的具体值中看到具体时哪个表空间快满了。

改为3%后测试结果:

当然,大部分时间监控项会返回none,所以我们无法画出正常未满的表空间的空间占用时间曲线。只有超过93%慢时,我们才知道具体的占用情况。

如果想收集并保留更多信息,就需要使用自定义查询,方法就是在query.props文件中加入你想检查的SQL,比如我们想了解表空间信息,就加以下SQL:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
customtbl.Query=select 'TBL:'||a.tablespace_name||',' TBL, \
 
'Total Size:'||trunc(sum(a.tots) / 1024 / 1024, 2)||',' Tot_Size_mb, \
 
'Free MB:'||round(sum(a.sumb) / 1024 / 1024, 2)||',' Tot_Free_mb, \
 
'PCT Free:'||round(sum(a.sumb) * 100 / sum(a.tots), 2)||',' Pct_Free, \
 
'Max Free MB:'||round(sum(a.largest) / 1024 / 1024, 2)||',' Max_Free_mb, \
 
'Chunks Free:'||sum(a.chunks)||',' Chunks_Free \
 
from (select tablespace_name, \
 
0 tots, \
 
sum(bytes) sumb, \
 
max(bytes) largest, \
 
count(*) chunks \
 
from dba_free_space a \
 
group by tablespace_name \
 
union \
 
select tablespace_name, sum(bytes) tots, 0, 0, 0 \
 
from dba_data_files \
 
group by tablespace_name) a \
 
group by a.tablespace_name
 
customtbl.NoDataFound=none

 

 



 

posted @   西门运维  阅读(2135)  评论(0编辑  收藏  举报
编辑推荐:
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· AI与.NET技术实操系列(六):基于图像分类模型对图像进行分类
点击右上角即可分享
微信分享提示