`
xitonga
  • 浏览: 593720 次
文章分类
社区版块
存档分类
最新评论

Zabbix --> 客户端安装以及如何添加数据库的动态监控视图

 
阅读更多

前提条件:Zabbix服务器端已经安装好,并且运行正常。


1需要下载zabbix客户端,安装客户端,才能打开10050端口

wgethttp://www.zabbix.com/downloads/2.0.8/zabbix_agents_2.0.8.linux2_6.amd64.tar.gz

添加Zabbix用户和组。

groupaddzabbix

useraddzabbix-gzabbix-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

[root@db-m2-slave-1 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

[root@db-m2-slave-1 zabbix_2.0.8]#

3启动

[root@db-m2-slave-1 sbin]# nohup /usr/local/zabbix_2.0.8/sbin/zabbix_agentd start -c & > zabbix.log

[1] 18785

[root@db-m2-slave-1 sbin]# nohup: 忽略输入并把输出追加到"nohup.out"


[root@db-m2-slave-1 sbin]# more nohup.out

zabbix_agentd [18584]: cannot open config file [/usr/local/etc/zabbix_agentd.conf]: [2] No such file or directory

zabbix_agentd [18785]: zbx_option requires an argument -- c

usage: zabbix_agentd [-Vhp] [-c <config-file>] [-t <item key>]

报错加载不了配置文件,建立软连接

ln -s /usr/local/zabbix_2.0.8/conf/zabbix_agentd.conf /usr/local/etc/zabbix_agentd.conf


再次启动

[root@db-m2-slave-1 sbin]# nohup /usr/local/zabbix_2.0.8/sbin/zabbix_agentd start & > zabbix.log

[1] 18920

[root@db-m2-slave-1 sbin]# nohup: 忽略输入并把输出追加到"nohup.out"


[1]+ Done nohup /usr/local/zabbix_2.0.8/sbin/zabbix_agentd start

[root@db-m2-slave-1 sbin]#

4最终查看启动日志信息,没有最新记录,表示启动成功了。

[root@db-m2-slave-1 sbin]# more nohup.out

zabbix_agentd [18811]: zbx_option requires an argument -- c

usage: zabbix_agentd [-Vhp] [-c <config-file>] [-t <item key>]

zabbix_agentd [18826]: user zabbix does not exist

zabbix_agentd [18826]: cannot run as root!

5查看zabbix_agent启动后台进程

[root@db-m2-slave-1 sbin]# ps -eaf|grep zabbix

zabbix 18922 1 0 13:21 ? 00:00:00 /usr/local/zabbix_2.0.8/sbin/zabbix_agentd start

zabbix 18923 18922 0 13:21 ? 00:00:00 /usr/local/zabbix_2.0.8/sbin/zabbix_agentd start

zabbix 18924 18922 0 13:21 ? 00:00:00 /usr/local/zabbix_2.0.8/sbin/zabbix_agentd start

zabbix 18925 18922 0 13:21 ? 00:00:00 /usr/local/zabbix_2.0.8/sbin/zabbix_agentd start

zabbix 18926 18922 0 13:21 ? 00:00:00 /usr/local/zabbix_2.0.8/sbin/zabbix_agentd start

zabbix 18927 18922 0 13:21 ? 00:00:00 /usr/local/zabbix_2.0.8/sbin/zabbix_agentd start

root 18947 8652 0 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

[root@db-m2-slave-1 sbin]# chkconfig --add zabbix_agentd

zabbix_agentd 服务不支持 chkconfig


chkconfig -- level 345 zabbix_agentd on

[root@db-m2-slave-1 sbin]# chkconfig --level 345 zabbix_agentd on

zabbix_agentd 服务不支持 chkconfig

[root@db-m2-slave-1 sbin]#
​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服务

[root@cache-2 zabbix]# /usr/local/zabbix/bin/zabbix_get -s 10.254.3.72 -k mysql.ping_test['root','']

0

一直是0,但是在数据库服务器的机器上执行mysqladmin返回是1

[root@db-m2-slave-1 conf]# mysqladmin -uroot ping|grep alive|wc -l

1

[root@db-m2-slave-1 conf]#


查看zabbix报错日志信息如下:

[root@db-m2-slave-1 sbin]# tail -f zabbix_agentd.log

tail: 无法打开"zabbix_agentd.log" 读取数据: 没有那个文件或目录

[root@db-m2-slave-1 sbin]# 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状态


[root@cache-2 zabbix]# /usr/local/zabbix/bin/zabbix_get -s 10.254.3.72 -k mysql.ping_test['root','']

1

[root@cache-2 zabbix]#

9服务器网站上面配置Item

需要在监控的服务器列表的HOST上选择服务器,打开Items下面选项,点击进去,再点击右上角的Create item。

点击Items-create Itmes。




输入key值为mysql.ping_test[root,'']



输入完成,点击下面的Save按钮,保存。



10配置graph

点击graphs---create graph,在ADD处选择Items为mysql.ping_test--save,稍等会儿就出图




11 然后再去看zabbix的界面,就会发现图片能生成出来了:



分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics