毕业设计之zabbix---自带模板监控mysql内容
作者:互联网
自带模板是不能直接建立连接就可以用的
必须经历一下几步:
建立用户权限:
[root@mysql.quan.bbs lib]$mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 105 Server version: 5.7.29-log Source distribution Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> grant all on *.* to zabbix@'localhost' identified by 'zabbix2004'; Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.02 sec)
我们先将参数文件复制到安装目录先
源码包复制到安装目录
[root@mysql.quan.bbs zabbix_agentd]$pwd /data/packages/zabbix-4.4.5/conf/zabbix_agentd [root@mysql.quan.bbs zabbix_agentd]$cp userparameter_mysql.conf /usr/local/zabbix/etc/zabbix_agentd.conf.d/
内容为:
#template_db_mysql.conf created by Zabbix for "Template DB MySQL" and Zabbix 4.2 #For OS Linux: You need create .my.cnf in zabbix-agent home directory (/var/lib/zabbix by default) #For OS Windows: You need add PATH to mysql and mysqladmin and create my.cnf in %WINDIR%\my.cnf,C:\my.cnf,BASEDIR\my.cnf https://dev.mysql.com/doc/refman/5.7/en/option-files.html #The file must have three strings: #[client] #user=zbx_monitor #password=<password> # UserParameter=mysql.ping[*], mysqladmin -h"$1" -P"$2" ping UserParameter=mysql.get_status_variables[*], mysql -h"$1" -P"$2" -sNX -e "show global status" UserParameter=mysql.version[*], mysqladmin -s -h"$1" -P"$2" version UserParameter=mysql.db.discovery[*], mysql -h"$1" -P"$2" -sN -e "show databases" UserParameter=mysql.dbsize[*], mysql -h"$1" -P"$2" -sN -e "SELECT SUM(DATA_LENGTH + INDEX_LENGTH) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='$3'" UserParameter=mysql.replication.discovery[*], mysql -h"$1" -P"$2" -sNX -e "show slave status" UserParameter=mysql.slave_status[*], mysql -h"$1" -P"$2" -sNX -e "show slave status" ~
修改mysql的配置文件即可:
[root@mysql.quan.bbs zabbix_agentd]$vim /usr/local/mysql/etc/my.cnf #[client] #port = 3306 #socket = /data/mysql/data/mysql.sock #default-character-set = utf8 [client] user='zabbix' password='zabbix2004' default-character-set=utf8 socket=/data/mysql/data/mysql.sock [mysqladmin] default-character-set=utf8 socket=/data/mysql/data/mysql.sock user='zabbix' password='zabbix2004' [mysql] default-character-set=utf8 socket=/data/mysql/data/mysql.sock user='zabbix' password='zabbix2004'
然后重启mygslq
重启zabbix_agentd
然后就可以了
标签:agentd,data,zabbix,UserParameter,毕业设计,mysql,my 来源: https://www.cnblogs.com/betterquan/p/12449123.html