zabbix客户端安装以及如何添加数据库的动态监控视图
前提条件:Zabbix服务器端已经安装好,并且运行正常。1 需要下载zabbix客户端,安装客户端,才能打开10050端口
wgethttp://www.zabbix.com/downloads/ ... nux2_6.amd64.tar.gz
添加Zabbix用户和组。
groupadd zabbix
useradd zabbix -g zabbix -s /sbin/nologin
2 解压缩
Tar –xvf zabbix_agents_2.0.8.linux2_6.amd64.tar.gz
Mv zabbix_agents_2.0.8.linux2_6.amd64 /usr/local/zabbix_2.0.8
# ll
总用量 296
drwxr-xr-x. 2 root root 4096 4月26 13:06 bin
drwxr-xr-x. 3 root root 4096 4月26 15:20 conf
drwxr-xr-x. 2 root root 4096 4月26 14:27 sbin
-rw-r--r--. 1 root root 288810 9月10 2013 zabbix_agents_2.0.8.linux2_6_23.amd64.tar.gz
#
3 启动
# nohup /usr/local/zabbix_2.0.8/sbin/zabbix_agentd start -c& > zabbix.log
18785
# nohup: 忽略输入并把输出追加到"nohup.out"
# more nohup.out
zabbix_agentd : cannot open config file : No such file or directory
zabbix_agentd : zbx_option requires an argument -- c
usage: zabbix_agentd [-Vhp] [-c ] [-t ]
报错加载不了配置文件,建立软连接
ln -s /usr/local/zabbix_2.0.8/conf/zabbix_agentd.conf /usr/local/etc/zabbix_agentd.conf
再次启动
# nohup /usr/local/zabbix_2.0.8/sbin/zabbix_agentd start & > zabbix.log
18920
# nohup: 忽略输入并把输出追加到"nohup.out"
+Done nohup /usr/local/zabbix_2.0.8/sbin/zabbix_agentd start
#
4 最终查看启动日志信息,没有最新记录,表示启动成功了。
# more nohup.out
zabbix_agentd : zbx_option requires an argument -- c
usage: zabbix_agentd [-Vhp] [-c ] [-t ]
zabbix_agentd : user zabbix does not exist
zabbix_agentd : cannot run as root!
5 查看zabbix_agent启动后台进程
# ps -eaf|grep zabbix
zabbix 18922 10 13:21 ? 00:00:00 /usr/local/zabbix_2.0.8/sbin/zabbix_agentd start
zabbix 18923 189220 13:21 ? 00:00:00 /usr/local/zabbix_2.0.8/sbin/zabbix_agentd start
zabbix 18924 189220 13:21 ? 00:00:00 /usr/local/zabbix_2.0.8/sbin/zabbix_agentd start
zabbix 18925 189220 13:21 ? 00:00:00 /usr/local/zabbix_2.0.8/sbin/zabbix_agentd start
zabbix 18926 189220 13:21 ? 00:00:00 /usr/local/zabbix_2.0.8/sbin/zabbix_agentd start
zabbix 18927 189220 13:21 ? 00:00:00 /usr/local/zabbix_2.0.8/sbin/zabbix_agentd start
root 1894786520 13:21 pts/0 00:00:00 grep zabbix
6 自动添加启动脚本
ln -s /usr/local/zabbix_2.0.8/sbin/zabbix_agentd /etc/init.d/zabbix_agentd
chmod 755 /etc/init.d/zabbix_agentd
# chkconfig--add zabbix_agentd
zabbix_agentd 服务不支持 chkconfig
chkconfig -- level 345 zabbix_agentd on
# chkconfig --level 345 zabbix_agentd on
zabbix_agentd 服务不支持 chkconfig
#
vi /etc/init.d/zabbix_agentd 头部加描述即可
#!/bin/sh
# chkconfig: 345 95 95
# description: zabbix_agentd
7 关闭zabbix_agentd进程
killall -9 zabbix_agentd
8添加自定义监控
8.1在数据库HOST上面,修改vi /usr/local/etc/zabbix_agentd.conf
UnsafeUserParameters=1 此处默认是0(不允许自定义脚本)
然后在后面添加UserParameter=key,command
key,command 为格式
此处key 是在创建item 的时候填写的
在这里面添加如下监控项:
UnsafeUserParameters=1
UserParameter=mysql.ping_test
,mysqladmin -u$1 -p$2 ping|grep alive|wc –l
8.2重新启动zabbix_agentd 服务。
8.3 check服务
# /usr/local/zabbix/bin/zabbix_get -s 10.254.3.72 -k mysql.ping_test['root','']
0
一直是0,但是在数据库服务器的机器上执行mysqladmin返回是1
# mysqladmin -urootping|grep alive|wc -l
1
#
查看zabbix报错日志信息如下:
# tail -f zabbix_agentd.log
tail: 无法打开"zabbix_agentd.log" 读取数据: 没有那个文件或目录
# tail -f /tmp/zabbix_agentd.log
sh: mysqladmin: command not found
sh: mysqladmin: command not found
sh: mysqladmin: command not found
重新设置mysqladmin的全路径,并重新启动zabbix_agentd服务,再check状态
# /usr/local/zabbix/bin/zabbix_get -s 10.254.3.72 -k mysql.ping_test['root','']
1
#
9 服务器网站上面配置Item
需要在监控的服务器列表的HOST上选择服务器,打开Items下面选项,点击进去,再点击右上角的Create item。
点击Items-create Itmes。
输入 key 值为 mysql.ping_test
输入完成,点击下面的Save按钮,保存。
10 配置graph
点击graphs---create graph,在ADD 处选择Items 为mysql.ping_test--save,稍等会儿就出图
11 然后再去看zabbix的界面,就会发现图片能生成出来了:
页:
[1]