Zabbix获取oracle表空间步骤解析
前提:zabbix agent 安装在需要监控的服务器上
1、创建tablespace_check.sh脚本
(1)oracle用户创建tablespace_check脚本
#!/bin/bash # tablespace usagep check #source ~/.bash_profile function check { sqlplus -S "/ as sysdba" << EOF set linesize 200 set pagesize 200 spool /tmp/tablespace.log select a.tablespace_name, maxtotal as total, (maxtotal-total+free)as free,(total-free) as usage from (select tablespace_name, sum(bytes)/1024/1024 as total,sum(maxbytes)/1024/1024 as maxtotal from dba_data_files group by tablespace_name) a, (select tablespace_name, sum(bytes)/1024/1024 as free from dba_free_space group by tablespace_name) b where a.tablespace_name = b.tablespace_name; spool off set linesize 100 set pagesize 100 spool /tmp/autex.log select tablespace_name,autoextensible from dba_data_files; spool off quit EOF }; check &>/dev/null
(2)zabbix agent 会调用上述文件。
执行tablespace_check.sh(使用定时任务crontab执行脚本),获取表空间信息,并保存到/tmp/tablespace.log,/tmp/autex.log
输出:
二、Zabbix agent userparameter的用法
a) Zabbix 通过配置文件
路径:/usr/local/zabbix/etc/zabbix_agentd.conf.d/oracle_tablespace.conf
oracle_tablespace.conf中,配置UserParameter的值,并根据zabbix server端关联的键值,执行键值对应的脚本或命令:
两个键值:discovery.oracle.tablespace, tablespace.check[*],对应两个执行脚本;
(1)discovery.oracle.tablespace,/usr/local/zabbix/scripts/discovery_oracle_tablespace.sh
(2)tablespace.check[*],/usr/local/zabbix/scripts/tablespace_check.sh $1 $2
b) 脚本discovery_oracle_tablespace.sh,最终获取表空间名称
输出:
c) 脚本tablespace_check.sh,获取表空间百分比;
输出:
d) 使用zabbix_get 调用键值
文章评论