zabbix监控mysql-如何使用zabbix自带的模板监控-nagios监控mysql主从
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了zabbix监控mysql-如何使用zabbix自带的模板监控-nagios监控mysql主从相关的知识,希望对你有一定的参考价值。
用zabbix监控mysql(源码安装)安装位置在/usr/local/zabbix/
监控端(server):
在被监控端主机上关联该模板Template App MySQL
中文:组态->主机->名称一栏点击进去->模板,点击链接新模板->添加->Template App MySQL->存档
英文:Configuration->Hosts->Name->Templates,Link new templates->Add->Template App MySQL->Save
2. 被监控端(agent):
1)在源码包../zabbix-2.2.1/conf/zabbix_agentd/ 拷贝模板
cp zabbix-2.2.1/conf/zabbix_agentd/userparameter_mysql.conf /usr/local/zabbix/etc/zabbix_agentd.conf.d/
2)授予监控mysql信息的用户权限
mysql> grant usage on *.* to [email protected]‘localhost‘ identified by ‘zabbix‘;
3)修改my.cnf
[mysqladmin] host=localhost user=zabbix password=zabbix [mysql] host=localhost user=zabbix password=zabbix
4)修改
vim /usr/local/zabbix/etc/zabbix_agentd.conf.d/userparameter_mysql.conf UserParameter=mysql.status[*],echo "show global status where Variable_name=‘$1‘;" | HOME=/var/lib/zabbix mysql -uzabbix -pzabbix -hlocalhost -N | awk ‘{print $$2}‘ UserParameter=mysql.size[*],echo "select sum($(case "$3" in both|"") echo "data_length+index_length";; data|index) echo "$3_length";; free) echo "data_free";; esac)) from information_schema.tables$([[ "$1" = "all" || ! "$1" ]] || echo " where table_schema=‘$1‘")$([[ "$2" = "all" || ! "$2" ]] || echo "and table_name=‘$2‘");" | HOME=/var/lib/zabbix mysql -uzabbix -pzabbix -hlocalhost -N UserParameter=mysql.ping,HOME=/var/lib/zabbix mysqladmin -uzabbix -pzabbix -hlocalhost ping | grep -c alive UserParameter=mysql.version,mysql -uzabbix -pzabbix -hlocalhost -V
5)
# /etc/init.d/mysqld restart # /etc/init.d/zabbix_agentd restart
6)在server上的查看图像数据
Monitoring->Graphs->MySQL operations
nagios监控主从
ls /usr/local/nagios/etc/objects/commands.cfg # vim /usr/local/nagios/etc/objects/commands.cfg define command { command_name check_mysql_slave command_line $USER1$/check_mysql -H $HOSTADDRESS$ -S -uzabbix -pzabbix } 修改被监控端的配置文件 # vim zabbix_agent.cfg define service{ use local-service host_name zabbix_agent service_description MYSQL_SLAVE check_command check_mysql_slave } /etc/init.d/nagios restart
本文出自 “蚂蚱小子” 博客,请务必保留此出处http://zxlwz.blog.51cto.com/6952946/1853566
以上是关于zabbix监控mysql-如何使用zabbix自带的模板监控-nagios监控mysql主从的主要内容,如果未能解决你的问题,请参考以下文章
使用 Zabbix 监控 Nginx MySQL,以及自定义监控项