Benjamin Zhang

目前就职于中科院计算机网络信息中心,主要兴趣集中在数据库,操作系统,中间件。

【zabbix】zabora简化部署

13 Aug 2019 » zabbix

zabora简化部署

目的:简化部署zabora,批量监控数据库的常用指标

1 数据库用户赋权

上传cre_arp_monitor.sh ,并且部署用户。

[root@oradb ~]# chown -R 777 /tmp/cre_arp_monitor.sh 
[root@oradb ~]# su - oracle
[oracle@oradb ~]$ /tmp/cre_arp_monitor.sh

cre_arp_monitor.sh核心命令如下:

#!/bin/ksh

export ORACLE_BASE=/u01/app 
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export ORACLE_SID=oradb
export NLS_LANG="SIMPLIFIED CHINESE_CHINA.ZHS16GBK"

SQL_STATEMENT="
show user;
CREATE USER monitor IDENTIFIED BY newarp2019 DEFAULT TABLESPACE SYSTEM TEMPORARY TABLESPACE TEMP PROFILE DEFAULT ACCOUNT UNLOCK;
GRANT CONNECT TO monitor;
GRANT RESOURCE TO monitor;
ALTER USER monitor DEFAULT ROLE ALL;
GRANT SELECT ANY TABLE TO monitor;
GRANT CREATE SESSION TO monitor;
GRANT SELECT ANY DICTIONARY TO monitor;
GRANT UNLIMITED TABLESPACE TO monitor;
GRANT SELECT ANY DICTIONARY TO monitor;
GRANT SELECT ON V_\$SESSION TO monitor;
GRANT SELECT ON V_\$SYSTEM_EVENT TO monitor;
GRANT SELECT ON V_\$EVENT_NAME TO monitor;
GRANT SELECT ON V_\$RECOVERY_FILE_DEST TO monitor;
"

$ORACLE_HOME/bin/sqlplus / as sysdba << EOF
$SQL_STATEMENT
exit;
EOF

2 部署zabora的agent服务.

上传ora_agent.sh/root目录下.直接运行

[root@oradb ~]# ./ora_agent.sh 

ora_agent.sh核心命令如下:

#!/bin/bash
echo "---------getOraAgent----------"
wget http://172.31.1.6/update/tools/zabora.tar.gz
tar zxvf zabora.tar.gz

echo "--------deployOraAgent--------"
./zabora/deploy_zabbix.sh "monitor" "newarp2019"

echo "--------chmod 755 zabora.sh--------"
chmod 755 /etc/zabbix/scripts/agentd/zabora/zabora.sh

echo "-----restartZabbixAgent-------"
service zabbix-agent restart

3 验证部署效果

去zabbix-server,执行如下命令:

[root@localhost ~]# zabbix_get -s 172.31.xx.34 -k "zabora[oradb,db_active,1]"
1
[root@localhost ~]# zabbix_get -s 172.31.xx.34 -k "zabora[oradb,tb_size,SYSTEM]"
2.88

得到如上结果,说明数据库的agent监控安装成功。