授权zabbix连接MySQL数据库
zabbix客户端程序会以该用户的身份启动
mysql> GRANT USAGE ON *.* TO 'zabbix'@'localhost' IDENTIFIED BY '123@qwe';
mysql> flush privileges;
修改监控模板
将监控模板加入配置文件中
shell> cp conf/zabbix_agentd/userparameter_mysql.conf /usr/local/zabbix/etc/zabbix_agentd.conf.d/
修改配置文件HOME
shell> grep -v ^# /usr/local/zabbix/etc/zabbix_agentd.conf.d/userparameter_mysql.conf
=================================================================================================
UserParameter=mysql.status[*],echo "show global status where Variable_name='$1';" |
HOME=/usr/local/zabbix/etc mysql -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=/usr/local/zabbix/etc mysql -N
UserParameter=mysql.ping,HOME=/usr/local/zabbix/etc mysqladmin ping | grep -c alive
UserParameter=mysql.version,mysql -V
=================================================================================================
建立数据库连接信息
shell> cat /usr/local/zabbix/etc/.my.cnf
=================================================================================================
# Zabbix Agent
[mysql]
host=localhost
user=zabbix
password=123@qwe
socket=/tmp/mysql.sock
[mysqladmin]
host=localhost
user=zabbix
password=123@qwe
socket=/tmp/mysql.sock
=================================================================================================
启动zabbix自带模板
1、重启启动zabbix_agantd
2、host添加Template App MySQL模板,就可以看到图形
3、系统定义了流量及qps图形显示,其他图形需要自己添加
整理自网络
Svoid
2015-07-10
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29733787/viewspace-1735709/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/29733787/viewspace-1735709/