zabbix监控mysql和apache

来源:互联网 发布:决斗知乎 编辑:程序博客网 时间:2024/05/21 11:02

参考:http://shugao.blog.51cto.com/2396914/702310

这里一个插件ztc来实现监控mysqlapache的:ztc

下载地址:https://bitbucket.org/rvs/ztc/wiki/Home

操作系统:CentOS 5.8 x64

一、zabbix使用ztc监控mysql的实现

安装python

因为ztc是使用python写的:
yum -y install  python

解压

tar zxvf ztc-12.02.1.tar.gz

3 安装ztc

cd ztc-12.02.1
python setup.py install

ztc目录结构:
/opt/ztc# ztc安装目录
/etc/ztc# ztc配置文件目录
/etc/zabbix-agent.d# ztc 设置 zabbixt agent 的UserParameter参数的目录

编辑/etc/ztc/mysql.conf

编辑mysql.conf文件写入访问mysql的用户和密码和主机,同时用户要授权的。

编辑zabbix-agentd.conf

加入:
Include=/etc/zabbix-agent.d/
重启agentd进程

安装MySQL-python

yum -y install MySQL-python

创建/var/log/zabbix/ztc.log

mkdir /var/log/zabbix
touch /var/log/zabbix/ztc.log
chmod 666 /var/log/zabbix/ztc.log

验证

/opt/ztc/bin/mysql.py status Connections 是否有数据产生

二 监控apache

apache版本: Apache/2.2.3 (CentOS)
首先使apache支持server-status功能:
ExtendedStatus On
<location /server-status>
SetHandler server-status
Order Deny,Allow
Deny from all
Allow from 192.168.3.60
Allow from 127.0.0.1
</location>

查看是否有这个模块:
httpd -M
status_module (shared)

可以在本地测试是否开启了该功能:http://ip/server-status
curl http://127.0.0.1/server-status
apache 的模板导入这时就可以监控了