數據庫監控:zabbix(actiontech)

[root@wallet01 ~]# yum install -y golang

[root@wallet01 ~]# go version
go version go1.11.2 linux/amd64

[root@wallet01 ~]# export GOPATH=/home/go

官網:https://github.com/go-sql-driver/mysql

[root@wallet01 ~]# go get -u github.com/go-sql-driver/mysql

官網:https://github.com/actiontech/actiontech_zabbix_mysql_monitor

percona monitoring plugins (zabbix)的GO語言版本,
由愛可生公司開源的MySQL監控插件和模板,整合上百個性能監控指標,
支持Low Level Discovery自動發現多實例環境。

[root@wallet01 ~]# git clone https://github.com/actiontech/actiontech_zabbix_mysql_monitor.git
Initialized empty Git repository in /root/actiontech_zabbix_mysql_monitor/.git/
remote: Enumerating objects: 193, done.
remote: Total 193 (delta 0), reused 0 (delta 0), pack-reused 193
Receiving objects: 100% (193/193), 10.78 MiB | 185 KiB/s, done.
Resolving deltas: 100% (115/115), done.

[root@wallet01 ~]# cd actiontech_zabbix_mysql_monitor
[root@wallet01 actiontech_zabbix_mysql_monitor]# chmod a+x *.sh
[root@wallet01 actiontech_zabbix_mysql_monitor]# ./build.sh 
[root@wallet01 actiontech_zabbix_mysql_monitor]# ls -l
total 7296
-rwxr-xr-x 1 root root 5972403 Jan 10 16:25 actiontech_mysql_monitor
-rw-r--r-- 1 root root   50120 Aug  8 15:12 actiontech_mysql_monitor.go
-rw-r--r-- 1 root root   20065 Aug  8 15:12 actiontech_mysql_monitor_test.go
-rw-r--r-- 1 root root  673006 Aug  8 15:12 actiontech_zbx_3.0_template_mysql_server.xml
-rw-r--r-- 1 root root  690284 Aug  8 15:12 actiontech_zbx_3.4_template_mysql_server.xml
-rwxr-xr-x 1 root root     122 Aug  8 15:12 build.sh
-rwxr-xr-x 1 root root     450 Aug  8 15:12 install.sh
-rw-r--r-- 1 root root   11358 Aug  8 15:12 LICENSE
-rw-r--r-- 1 root root   25165 Aug  8 15:12 README.md
-rw-r--r-- 1 root root     283 Aug  8 15:12 userparameter_actiontech_mysql.conf
        
[root@wallet01 actiontech_zabbix_mysql_monitor]# mkdir -p /var/lib/zabbix/actiontech/scripts
[root@wallet01 actiontech_zabbix_mysql_monitor]# cp actiontech_mysql_monitor /var/lib/zabbix/actiontech/scripts/
[root@wallet01 actiontech_zabbix_mysql_monitor]# cp userparameter_actiontech_mysql.conf /usr/local/etc/zabbix_agentd.conf.d/

[root@wallet01 ~]# cd /var/lib/zabbix/actiontech/scripts
[root@wallet01 scripts]# vi mysql.sh 
#!/bin/bash
sudo /var/lib/zabbix/actiontech/scripts/actiontech_mysql_monitor --host=localhost --port=$1 --user=root --pass=abcd.1234 --items=$2 | awk '{print $3}'

[root@wallet01 scripts]# chmod a+x mysql.sh 
[root@wallet01 scripts]# ./mysql.sh 3306 Aborted_clients
46

[root@wallet01 ~]# vim /etc/sudoers
Defaults:zabbix !requiretty
zabbix          ALL=(ALL) NOPASSWD: ALL

[root@wallet01 ~]# su - zabbix
[zabbix@wallet01 ~]$ cd /var/lib/zabbix/actiontech/scripts
[zabbix@wallet01 scripts]$ ./mysql.sh 3306 Aborted_clients
46

[root@wallet01 ~]# cd /usr/local/etc/zabbix_agentd.conf.d
[root@wallet01 zabbix_agentd.conf.d]# vi userparameter_actiontech_mysql.conf 
UserParameter=MySQL.[*],/var/lib/zabbix/actiontech/scripts/mysql.sh $1 $2
UserParameter=MySQL.port_discovery,/var/lib/zabbix/actiontech/scripts/actiontech_mysql_monitor --discovery_port true

[root@wallet01 ~]# vi /usr/local/etc/zabbix_agentd.conf
Server=192.168.1.200
Hostname=wallet
Include=/usr/local/etc/zabbix_agentd.conf.d/*.conf
[root@wallet01 ~]# /etc/init.d/zabbix_agentd restart

[root@zabbix ~]# zabbix_get -s 192.168.1.201 -k MySQL.[3306,Aborted_clients] 
46

部署zabbix
https://blog.51cto.com/13598811/2097609
一,導入模板
二,創建主機並關聯模板


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章