使用zabbix 2.4 监控mysql----自带模板
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用zabbix 2.4 监控mysql----自带模板相关的知识,希望对你有一定的参考价值。
环境:centos 6.5,mysql 5.6,zabbix 2.4.4
1、在mysql中添加zabbix用户
mysql -uroot -p -e
"GRANT USAGE ON *.* TO ‘zabbix‘@‘127.0.0.1‘ IDENTIFIED BY ‘zabbix‘"
;
mysql -uroot -p -e
"GRANT USAGE ON *.* TO ‘zabbix‘@‘localhost‘ IDENTIFIED BY ‘zabbix‘"
;
mysql -uroot -p -e
"flush privileges"
2、新建.my.cnf文件
vim
/usr/local/zabbix/etc/
.my.cnf
[mysql]
host=127.0.0.1
user=zabbix
password=zabbix
socket=
/tmp/mysql
.sock
[mysqladmin]
host=127.0.0.1
user=zabbix
password=zabbix
socket=
/tmp/mysql
.sock
3、复制并修改mysql的key值文件,将HOME指定到.my.cnf文件所在文件的路径,mysql和mysqladmin命令使用绝对路径
cp
/root/zabbix-2
.4.5
/conf/zabbix_agentd/userparameter_mysql
.conf
/usr/local/zabbix/etc/zabbix_agentd
.conf.d/
vim
/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
/usr/local/mysql/bin/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
/usr/local/mysql/bin/mysql
-N
UserParameter=mysql.
ping
,HOME=
/usr/local/zabbix/etc
/usr/local/mysql/bin/mysqladmin
ping
|
grep
-c alive
UserParameter=mysql.version,
/usr/local/mysql/bin/mysql
-V
4、修改agentd配置文件
vim
/usr/local/zabbix/etc/zabbix_agentd
.conf
LogFile=
/tmp/zabbix_agentd
.log
Server=192.168.100.161
ServerActive=192.168.100.161
Hostname=Zabbix server
Include=
/usr/local/zabbix/etc/zabbix_agentd
.conf.d/
EnableRemoteCommands=1
UnsafeUserParameters=1
5、使用zabbix_get获取key值,zabbix_get在zabbix server上使用有返回值,在zabbix agent使用无返回值,要查看agent的key值,可以把127.0.0.1改为agent的ip
zabbix_get -s 127.0.0.1 -p 10050 -k
"mysql.version"
本文出自 “系统网站运维” 博客,请务必保留此出处http://cgc243652136qq.blog.51cto.com/3989433/1744530
以上是关于使用zabbix 2.4 监控mysql----自带模板的主要内容,如果未能解决你的问题,请参考以下文章