zabbix部署oracle模板,zabbix自定义模板监控oracle

[[email protected] ~]# /etc/init.d/zabbix_agentd status

● zabbix_agentd.service - SYSV: Starts and stops Zabbix Agent using chkconfig

Loaded: loaded (/etc/rc.d/init.d/zabbix_agentd; bad; vendor preset: disabled)

Active: active (running) since Thu 2018-07-12 10:11:14 CST; 1 months 22 days ago

Docs: man:systemd-sysv-generator(8)

CGroup: /system.slice/zabbix_agentd.service

├─791 /opt/zabbix/sbin/zabbix_agentd

├─796 /opt/zabbix/sbin/zabbix_agentd: collector [idle 1 sec]

├─797 /opt/zabbix/sbin/zabbix_agentd: listener #1 [waiting for connection]

├─798 /opt/zabbix/sbin/zabbix_agentd: listener #2 [waiting for connection]

├─799 /opt/zabbix/sbin/zabbix_agentd: listener #3 [waiting for connection]

└─800 /opt/zabbix/sbin/zabbix_agentd: active checks #1 [idle 1 sec]

Jul 12 10:11:14 10-10-15-71 systemd[1]: Starting SYSV: Starts and stops Zabbix Agent using chkconfig...

Jul 12 10:11:14 10-10-15-71 zabbix_agentd[754]: Starting zabbix_agentd: [ OK ]

Jul 12 10:11:14 10-10-15-71 systemd[1]: Started SYSV: Starts and stops Zabbix Agent using chkconfig.

[[email protected] zabbix]# netstat -ntlp |grep zabbix  #zabbix客户端使用1050端口

tcp 0 0 0.0.0.0:1050 0.0.0.0:* LISTEN 1615/zabbix_agentd

[[email protected] ~]# cd /opt/zabbix/

[[email protected] zabbix]# ll

total 4

drwxr-xr-x 2 zabbix zabbix 78 May 16 10:50 bin

drwxr-xr-x 2 zabbix zabbix 48 May 16 10:50 etc

drwxr-xr-x 2 zabbix zabbix 6 Jun 20 2017 lib

drwxr-xr-x 2 zabbix zabbix 26 May 16 10:50 sbin

drwxr-xr-x 2 zabbix zabbix 4096 May 16 10:50 scripts

drwxr-xr-x 3 zabbix zabbix 16 May 16 10:50 share

2.查看防火墙等配置,以及SELINUX策略等问题。

[[email protected] ]# cat /etc/selinux/config |grep SELINUX

# SELINUX= can take one of these three values:

SELINUX=disabled

# SELINUXTYPE= can take one of three two values:

SELINUXTYPE=targeted

[[email protected] ]#  systemctl status firewalld

● firewalld.service - firewalld - dynamic firewall daemon

Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)

Active: inactive (dead)

3.修改agent配置文件

[[email protected] ]#  cat /opt/zabbix/etc/zabbix_agentd.conf

PidFile=/var/run/zabbix_agentd.pid

LogFile=/var/log/zabbix_agentd.log

ListenPort=1050 #zabbix客户端端口号

EnableRemoteCommands=1

LogRemoteCommands=1

Server=100.150.10.10 #zabbix服务器地址

ServerActive=100.150.10.10:1051 #zabbix服务器地址及端口号

HostnameItem=system.hostname

Timeout=30

AllowRoot=1

DebugLevel=4

LogFileSize=128

Include=/opt/zabbix/etc/extra.conf

UnsafeUserParameters=1

UserParameter=findsock[*],/opt/zabbix/scripts/findsock.sh $1

UserParameter=net.tcp.listen.grep[*],grep -q $$(printf ‘%04X.00000000:0000.0A‘ $1) /proc/net/tcp && echo 1 || echo 0

UserParameter=net.tcp6.listen.grep[*], ss -nlt| grep "" >/dev/null && echo 1 || echo 0

UserParameter=finddisks,/opt/zabbix/scripts/finddisks.sh

UserParameter=disproc,/opt/zabbix/scripts/disproc.sh

UserParameter=disraid,/opt/zabbix/scripts/disraid.sh

UserParameter=raid,/opt/zabbix/scripts/checkraid.sh

UserParameter=iostats[*],/opt/zabbix/scripts/iostats.sh $1

UserParameter=bond[*],/usr/sbin/ethtool $1 | awk -F ":" ‘/Speed/ {print $NF}‘|sed ‘s/Mb.*$//g‘

LogFileSize=128

[[email protected] zabbix]# cat etc/extra.conf

#jmx

UserParameter=jmx.scan.tomcat[*],cat /opt/apache-tomcat/jmx.json

UserParameter=jmx.scan.tomcat2[*],cat /opt/apache-tomcat-2/jmx.json

UserParameter=jmx.tomcat[*],/opt/zabbix/scripts/jmx_status.sh $1 $2 $3 $4

UserParameter=jmx.tomcat2[*],/opt/zabbix/scripts/jmx_status.sh $1 $2 $3 $4

UserParameter=mysql[*],/opt/zabbix/scripts/mysql.sh $1

UserParameter=nginx[*],/opt/zabbix/scripts/nginx.sh $1

UserParameter=performance,/opt/zabbix/scripts/performance.sh

UserParameter=redis.info[*],/opt/zabbix/scripts/redis.sh $1

4.编写oracle client机器上的可执行脚本

[[email protected] ~]#cd /opt/zabbix/scripts/

[[email protected] ~]#vi oracle_status.sh

以监控oracle脚本的运行状态为例

#!/bin/bash

function active() {

ps -ef | grep pmon | grep -v grep | awk ‘{print $NF}‘ > /dev/null

if [ $? -eq 0 ]; then

echo 1

else

echo 0

fi

}

if [ $# -ne 1 ]; then

echo "the args is error."

else

$1

fi

[[email protected] ~]#chmod u+x oracle_status.sh

在目标机器上执行对应脚本

[[email protected] ~]# cd /opt/zabbix/scripts/

[[email protected] scripts]# ./oracle_status.sh active

1

参数为active,编辑zabbix_agentd.conf ,添加下列条目:

[[email protected] ~]#UserParameter=oracle_status[*],/usr/local/zabbix/script/oracle_status.sh $1

重启zabbix_agented

[[email protected] ~]#/etc/init.d/zabbix_agentd restart

5,zabbix服务器机器获取脚本数据,可使用zabbix-get

[[email protected] bin]# ./zabbix_get -s 100.10.93.18 -p 1050 -k "oracle_status[active]"

1

100.10.93.18 为zabbix client机器

到这一步证明zabbix-service已经获取到目标机器数据

6.在zabbix服务器的web配置,添加监控项

配置-->主机-->监控项-->创建监控项

名称:oracle_status 键值:oracle_status[active]主机接口:client地址及端口

20180903172613869531.png

7:添加图形

配置-->主机-->图形

添加监控项

20180903172614574609.png

8.添加触发器

20180903172614697656.png

9.查看最新数据的监控项

20180903172615207422.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值