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图形显示,其他图形需要自己添加
*代表所有字段,比如select * from table是查询表中记录所有字段的内容,
%代表n个字符,n任意,
比如
select * from table where cl like 'a%'
是查询cl字段中所有以a开头的记录。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)