用zabbix 监控 oracle


1、在oracle 数据库中创建用户并授权

create user monitor identified by monitor
default tablespace users
temporary tablespace TEMP
profile default
account unlock;

grant create session,alter session,connect,select any dictionary to monitor;


2、在zabbix 的配置文件中添加 


[root@orauatdb2 scripts]# vi /opt/zabbix/conf/zabbix_agentd.conf 
Server=zabbix.xxx.com
Hostname=xxx.800best.com
StartAgents=3
DebugLevel=3
PidFile=/opt/zabbix/pid/zabbix_agentd.pid
LogFile=/opt/zabbix/log/zabbix_agentd.log
Timeout=5
Include=/opt/zabbix/conf/conf.d
UserParameter=custom.disks.discovery_perl,/opt/zabbix/scripts/discovery_disks.perl
UserParameter=custom.vfs.dev.read.ops[*],cat /proc/diskstats | grep "$1" | head -1 | awk '{print $$4}'
UserParameter=custom.vfs.dev.read.ms[*],cat /proc/diskstats | grep "$1" | head -1 | awk '{print $$7}'
UserParameter=custom.vfs.dev.write.ops[*],cat /proc/diskstats | grep "$1" | head -1 | awk '{print $$8}'
UserParameter=custom.vfs.dev.write.ms[*],cat /proc/diskstats | grep "$1" | head -1 | awk '{print $$11}'
UserParameter=custom.vfs.dev.io.active[*],cat /proc/diskstats | grep "$1" | head -1 | awk '{print $$12}'
UserParameter=custom.vfs.dev.io.ms[*],cat /proc/diskstats | grep "$1" | head -1 | awk '{print $$13}'
UserParameter=custom.vfs.dev.read.sectors[*],cat /proc/diskstats | grep "$1" | head -1 | awk '{print $$6}'
UserParameter=custom.vfs.dev.write.sectors[*],cat /proc/diskstats | grep "$1" | head -1 | awk '{print $$10}'


<span style="color:#ff0000;"><span style="color:#ff0000;">UserParameter=oracle[*],/opt/zabbix/scripts/zabora/zabora $1 $2</span></span>

3、需要 三个可执行文件:
cont.sql 

oraenv :配置环境变量

zabora : zabbix 通过这个脚本取值

[root@orauatdb2 scripts]# cat cont.sql 
whenever sqlerror exit failure 
set verify off echo off feedback off heading off pagesize 0 trimout on trimspool on termout off 
conn monitor/monitor
column retvalue format a15 \n
[root@orauatdb2 scripts]# cat oraenv 
ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
ORACLE_SID=crmuat
PATH=/usr/bin:/usr/sbin/:$ORACLE_HOME/bin
export ORACLE_HOME ORACLE_SID PATH 



[root@orauatdb2 scripts]# more zabora 
#/bin/bash

. /opt/zabbix/scripts/zabora/oraenv
#set -x
zaboraver="1.2"
rval=0

if [ "$2" != "" ]
then
       export ORACLE_SID=$2
fi


case $1 in

'checkactive')
        sql="select to_char(case when inst_cnt > 0 then 1 else 0 end,'FM99999999999999990') retvalue
             from (select count(*) inst_cnt from v\$instance 
                   where status = 'OPEN' and logins = 'ALLOWED' and database_status = 'ACTIVE');"
        ;;





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

huangliang0703

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值