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}'

UserParameter=oracle[*],/opt/zabbix/scripts/zabora/zabora $1 $2

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');"

;;

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐