Zabbix+Mysql Fpmmm(MPM)监控

2023年 7月 15日 124.9k 0

mysql Fpmmm是MPM的升级版,相对而言,fpmmm要比mpm使用起来更方便,但是需要开启相应的优化参数1,配置pid复制启动脚本

cp support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
service mysqld start
pid-file=/var/run/mysqld/mysqld.pid 

配置环境变量

vim /etc/profile.d/mysql.sh
export PATH=/usr/local/mysql/bin:$PATH
sh vim /etc/profile.d/mysql.sh

添加配置文件中的pid

[root@localhost mysql]# vim /etc/mysql/my.cnf 
pid-file=/var/run/mysqld/mysqld.pid
[root@localhost mysql]# mkdir /var/run/mysqld
[root@localhost mysql]# chown -R mysql.mysql /var/run/mysqld
[root@localhost mysql]# /etc/init.d/mysqld start

2,安装zabbx-agnet

rpm -ivh http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-1.el6.noarch.rpm
yum install -y zabbix-agent-2.4.7 zabbix-sender-2.4.7 zabbix-2.4.7  agent-2.4.7
vim /etc/zabbix/zabbix_server.conf
Server=192.168.128.128
erverActive=192.168.128.128
Hostname=Zabbix server

3,fpmmm监控

yum install php-cli php-process php-mysqli
cat << _EOF >/etc/php.d/fpmmm.ini
variables_order = "EGPCS"
date.timezone = 'Europe/Zurich'
_EOF

下载fpmmm

wget -P /usr/local/ https://support.fromdual.com/admin/download/fpmmm-0.10.5.tar.gz
cd /usr/local
tar xf fpmmm-0.10.5.tar.gz
ln -s fpmmm-0.10.5 fpmmm
cd fpmmm
mkdir /etc/fpmmm
cp /usr/local/fpmmm/tpl/fpmmm.conf.template /etc/fpmmm/fpmmm.conf
chown -R zabbix: /etc/fpmmm

授权fpmmm、

vim /etc/profile.d/mysql.sh
export PATH=/usr/local/mysql/bin:$PATH
sh vim /etc/profile.d/mysql.sh
mysql -e "GRANT ALL  ON *.* TO 'fpmmm'@'192.168.158.130' IDENTIFIED BY 'password';""
mysql -e "GRANT ALL  ON *.* TO 'fpmmm'@'127.0.0.1' IDENTIFIED BY 'password';"

添加zabbix用户到mysql

usermod -G mysql zabbix

修改fpmm配置文件

[root@localhost fpmmm]# egrep -v "^#|^$" /etc/fpmmm/fpmmm.conf
[default]
Type          = mysqld
LogLevel      = 2
LogFile       = /tmp/fpmmm/fpmmm.log
CacheFileBase = /tmp/fpmmm/fpmmmCache
AgentLockFile = /tmp/fpmmm/fpmmm.lock
Username      = fpmmm
Password      = password
MysqlHost     = 127.0.0.1
MysqlPort     = 3306
ZabbixServer  = 192.168.158.128
Disabled      = false
Modules       = innodb master myisam mysql process security
PidFile       = /var/lib/mysql/mysqld.pid
[mysql-master]          # This MUST match Hostname in Zabbix!
Type          = mysqld
Modules       = fpmmm server
[mysql-master]          # This MUST match Hostname in Zabbix!
Type          = mysqld
MysqlPort     = 3306
Modules       = process mysql myisam innodb master slave security
PidFile       = /var/run/mysqld/mysqld.pid

测试

[root@localhost fpmmm]# /usr/local/fpmmm/bin/fpmmm --config=/etc/fpmmm/fpmmm.conf 
1

添加mysql.check

vim /etc/zabbix/zabbix_agentd.conf
UserParameter=FromDual.MySQL.check,/usr/lcaol/fpmmm/bin/fpmmm --config=/etc/fpmmm/fpmmm.conf

计划任务

[root@localhost fpmmm]# crontab -l
* * * * * /usr/local/fpmmm/bin/fpmmm --config=/etc/fpmmm/fpmmm.conf >/dev/null

观察日志

96402:2016-05-10 12:09:02.338 - WARN:     Instance db2 seems not to be a Slave. (rc=1577).
96402:2016-05-10 12:09:02.373 - INFO: FromDual Performance Monitor for MySQL and MariaDB (fpmmm) run finished (rc=0).
96608:2016-05-10 12:10:01.438 - INFO: FromDual Performance Monitor for MySQL and MariaDB (fpmmm) (0.10.5) run started.
96608:2016-05-10 12:10:02.616 - WARN:     Instance db2 seems not to be a Slave. (rc=1577).
96608:2016-05-10 12:10:02.649 - INFO: FromDual Performance Monitor for MySQL and MariaDB (fpmmm) run finished (rc=0).
96808:2016-05-10 12:11:01.678 - INFO: FromDual Performance Monitor for MySQL and MariaDB (fpmmm) (0.10.5) run started.
96808:2016-05-10 12:11:02.823 - WARN:     Instance db2 seems not to be a Slave. (rc=1577).
96808:2016-05-10 12:11:02.866 - INFO: FromDual Performance Monitor for MySQL and MariaDB (fpmmm) run finished (rc=0).
97010:2016-05-10 12:12:01.891 - INFO: FromDual Performance Monitor for MySQL and MariaDB (fpmmm) (0.10.5) run started.
97010:2016-05-10 12:12:03.048 - WARN:     Instance db2 seems not to be a Slave. (rc=1577).
97010:2016-05-10 12:12:03.081 - INFO: FromDual Performance Monitor for MySQL and MariaDB (fpmmm) run finished (rc=0).
97210:2016-05-10 12:13:01.137 - INFO: FromDual Performance Monitor for MySQL and MariaDB (fpmmm) (0.10.5) run started.
97210:2016-05-10 12:13:02.322 - WARN:     Instance db2 seems not to be a Slave. (rc=1577).
97210:2016-05-10 12:13:02.355 - INFO: FromDual Performance Monitor for MySQL and MariaDB (fpmmm) run finished (rc=0).
97411:2016-05-10 12:14:01.380 - INFO: FromDual Performance Monitor for MySQL and MariaDB (fpmmm) (0.10.5) run started.
97411:2016-05-10 12:14:02.534 - WARN:     Instance db2 seems not to be a Slave. (rc=1577).
97411:2016-05-10 12:14:02.569 - INFO: FromDual Performance Monitor for MySQL and MariaDB (fpmmm) run finished (rc=0).
97611:2016-05-10 12:15:01.607 - INFO: FromDual Performance Monitor for MySQL and MariaDB (fpmmm) (0.10.5) run started.
97611:2016-05-10 12:15:02.765 - WARN:     Instance db2 seems not to be a Slave. (rc=1577).
97611:2016-05-10 12:15:02.799 - INFO: FromDual Performance Monitor for MySQL and MariaDB (fpmmm) run finished (rc=0).
97811:2016-05-10 12:16:01.846 - INFO: FromDual Performance Monitor for MySQL and MariaDB (fpmmm) (0.10.5) run started.
97811:2016-05-10 12:16:03.003 - WARN:     Instance db2 seems not to be a Slave. (rc=1577).
97811:2016-05-10 12:16:03.037 - INFO: FromDual Performance Monitor for MySQL and MariaDB (fpmmm) run finished (rc=0).
98011:2016-05-10 12:17:01.095 - INFO: FromDual Performance Monitor for MySQL and MariaDB (fpmmm) (0.10.5) run started.
98011:2016-05-10 12:17:02.263 - WARN:     Instance db2 seems not to be a Slave. (rc=1577).
98011:2016-05-10 12:17:02.304 - INFO: FromDual Performance Monitor for MySQL and MariaDB (fpmmm) run finished (rc=0).

查看图fpmmm1.pngmysqlisa.pngfpmmm3.png

Template_FromDual.MySQL.mpm.xml (监控mpm agent本身,这个必须导入)
Template_FromDual.MySQL.server.xml (监控Linux系统跟数据库使用相关的附加项)
Template_FromDual.MySQL.process.xml (监控各种Linux进程[比如:mysqld,ndbd])
Template_FromDual.MySQL.mysql.xml (监控MySQL常用状态变量)
Template_FromDual.MySQL.innodb.xml (监控InnoDB存储引擎状态变量)
Template_FromDual.MySQL.myisam.xml (监控MyISAM存储引擎状态变量)
Template_FromDual.MySQL.master.xml (监控MySQL主从复制的Master状态)
Template_FromDual.MySQL.slave.xml (监控MySQL主从复制的Slave状态)

MPM其它用途的模板:
Template_FromDual.MySQL.ndb.xml (监控MySQL Cluster)
Template_FromDual.MySQL.galera.xml (监控MySQL Galera Cluster)
Template_FromDual.MySQL.pbxt.xml (监控PBXT存储引擎状态变量)
Template_FromDual.MySQL.aria.xml (监控Aria存储引擎的状态变量)
Template_FromDual.MySQL.drbd.xml (监控DRBD设备状态信息

)

相关文章

对接alertmanager创建钉钉卡片(1)
手把手教你搭建OpenFalcon监控系统
无需任何魔法即可使用 Ansible 的神奇变量“hostvars”
openobseve HA本地单集群模式
基于k8s上loggie/vector/openobserve日志收集
openobseve单节点和查询语法

发布评论