CACTI :使用模板監控本地或其他服務器上的mysql
來源:程序員人生 發布時間:2015-07-24 09:50:59 閱讀次數:4754次
mysql 的模板,網上都在使用的這個地址http://mysql-cacti-templates.googlecode.com 已訪問不到了
Google找到這個網址:
介紹篇:
http://www.percona.com/doc/percona-monitoring-plugins/1.0/cacti/mysql-templates.html
下載頁:http://www.percona.com/downloads/percona-monitoring-plugins/
為了方便大家下載,上傳到csdn可供下載: http://download.csdn.net/detail/kk185800961/8651279
當前下載的文件:percona-cacti-templates⑴.1.4⑴.noarch.rpm
本地服務器監控本地mysql:
進入到cacti所在目錄
cd /var/www/html
將緊縮文件移到當前目錄(放那都行):
mv percona-cacti-templates⑴.1.4⑴.noarch.rpm .
解壓文件:
rpm2cpio percona-cacti-templates⑴.1.4⑴.noarch.rpm | cpio -div
在當前目錄下將生產以下目錄及文件:
./usr/share/cacti/resource/percona
./usr/share/cacti/resource/percona/bin
./usr/share/cacti/resource/percona/bin/pmp-cacti-extract-template
./usr/share/cacti/resource/percona/bin/pmp-cacti-graph-defs
./usr/share/cacti/resource/percona/bin/pmp-cacti-make-hashes
./usr/share/cacti/resource/percona/bin/pmp-cacti-template
./usr/share/cacti/resource/percona/definitions
./usr/share/cacti/resource/percona/definitions/apache.def
./usr/share/cacti/resource/percona/definitions/galera.def
./usr/share/cacti/resource/percona/definitions/gnu_linux.def
./usr/share/cacti/resource/percona/definitions/jmx.def
./usr/share/cacti/resource/percona/definitions/memcached.def
./usr/share/cacti/resource/percona/definitions/mongodb.def
./usr/share/cacti/resource/percona/definitions/mysql.def
./usr/share/cacti/resource/percona/definitions/nginx.def
./usr/share/cacti/resource/percona/definitions/openvz.def
./usr/share/cacti/resource/percona/definitions/rds.def
./usr/share/cacti/resource/percona/definitions/redis.def
./usr/share/cacti/resource/percona/misc
./usr/share/cacti/resource/percona/misc/jmx-monitor.xml
./usr/share/cacti/resource/percona/templates
./usr/share/cacti/resource/percona/templates/cacti_host_template_percona_apache_server_ht_0.8.6i-sver1.1.4.xml
./usr/share/cacti/resource/percona/templates/cacti_host_template_percona_galera_server_ht_0.8.6i-sver1.1.4.xml
./usr/share/cacti/resource/percona/templates/cacti_host_template_percona_gnu_linux_server_ht_0.8.6i-sver1.1.4.xml
./usr/share/cacti/resource/percona/templates/cacti_host_template_percona_jmx_server_ht_0.8.6i-sver1.1.4.xml
./usr/share/cacti/resource/percona/templates/cacti_host_template_percona_memcached_server_ht_0.8.6i-sver1.1.4.xml
./usr/share/cacti/resource/percona/templates/cacti_host_template_percona_mongodb_server_ht_0.8.6i-sver1.1.4.xml
./usr/share/cacti/resource/percona/templates/cacti_host_template_percona_mysql_server_ht_0.8.6i-sver1.1.4.xml
./usr/share/cacti/resource/percona/templates/cacti_host_template_percona_nginx_server_ht_0.8.6i-sver1.1.4.xml
./usr/share/cacti/resource/percona/templates/cacti_host_template_percona_openvz_server_ht_0.8.6i-sver1.1.4.xml
./usr/share/cacti/resource/percona/templates/cacti_host_template_percona_rds_server_ht_0.8.6i-sver1.1.4.xml
./usr/share/cacti/resource/percona/templates/cacti_host_template_percona_redis_server_ht_0.8.6i-sver1.1.4.xml
./usr/share/cacti/scripts/ss_get_by_ssh.php
./usr/share/cacti/scripts/ss_get_mysql_stats.php
./usr/share/cacti/scripts/ss_get_rds_stats.py
現在只要mysql的兩個文件:
ss_get_mysql_stats.php
cacti_host_template_percona_mysql_server_ht_0.8.6i-sver1.1.4.xml
拷貝ss_get_mysql_stats.php到cacti目錄中:
cp ./usr/share/cacti/scripts/ss_get_mysql_stats.php /var/www/html/cacti/scripts/
編輯文件,確認用戶名和密碼正確:
vi /var/www/html/cacti/scripts/ss_get_mysql_stats.php
$mysql_user = 'cacti';
$mysql_pass = 'cacti';
導入模板:打開cactiy頁面――>Console――>Import Templates――>閱讀添加

導入結果:
Import Results
Cacti has imported the following items:
CDEF
[success] Percona Turn Into Bits CDEF [new]
[success] Percona Negate CDEF [new]
GPRINT Preset
[success] Percona MySQL Server Checksum 523e4d8178a000df8df3a9825c4e7e1e [new]
[success] Percona MySQL Server Version t1.1.4:s1.1.4 [new]
[success] Percona Normal [new]
Data Input Method
[success] Percona Get MySQL Stats/MyISAM Indexes IM [new]
[success] Percona Get MySQL Stats/MyISAM Key Cache IM [new]
[success] Percona Get MySQL Stats/InnoDB Buffer Pool IM [new]
[success] Percona Get MySQL Stats/InnoDB I/O IM [new]
[success] Percona Get MySQL Stats/InnoDB Insert Buffer IM [new]
[success] Percona Get MySQL Stats/InnoDB Insert Buffer Usage IM [new]
[success] Percona Get MySQL Stats/InnoDB Semaphores IM [new]
[success] Percona Get MySQL Stats/InnoDB Row Operations IM [new]
[success] Percona Get MySQL Stats/MySQL Table Locks IM [new]
[success] Percona Get MySQL Stats/MySQL Connections IM [new]
[success] Percona Get MySQL Stats/MySQL Replication IM [new]
[success] Percona Get MySQL Stats/MySQL Query Cache IM [new]
[success] Percona Get MySQL Stats/MySQL Query Cache Memory IM [new]
[success] Percona Get MySQL Stats/MySQL Command Counters IM [new]
[success] Percona Get MySQL Stats/MySQL Select Types IM [new]
[success] Percona Get MySQL Stats/MySQL Sorts IM [new]
[success] Percona Get MySQL Stats/MySQL Temporary Objects IM [new]
[success] Percona Get MySQL Stats/MySQL Network Traffic IM [new]
[success] Percona Get MySQL Stats/InnoDB Buffer Pool Activity IM [new]
[success] Percona Get MySQL Stats/InnoDB I/O Pending IM [new]
[success] Percona Get MySQL Stats/InnoDB Log IM [new]
[success] Percona Get MySQL Stats/MySQL Binary/Relay Logs IM [new]
[success] Percona Get MySQL Stats/InnoDB Transactions IM [new]
[success] Percona Get MySQL Stats/InnoDB Transactions Active/Locked IM [new]
[success] Percona Get MySQL Stats/MySQL Files and Tables IM [new]
[success] Percona Get MySQL Stats/MySQL Threads IM [new]
[success] Percona Get MySQL Stats/InnoDB Memory Allocation IM [new]
[success] Percona Get MySQL Stats/InnoDB Adaptive Hash Index IM [new]
[success] Percona Get MySQL Stats/InnoDB Internal Hash Memory Usage IM [new]
[success] Percona Get MySQL Stats/InnoDB Tables In Use IM [new]
[success] Percona Get MySQL Stats/InnoDB Current Lock Waits IM [new]
[success] Percona Get MySQL Stats/InnoDB Lock Structures IM [new]
[success] Percona Get MySQL Stats/InnoDB Checkpoint Age IM [new]
[success] Percona Get MySQL Stats/InnoDB Row Lock Time IM [new]
[success] Percona Get MySQL Stats/InnoDB Row Lock Waits IM [new]
[success] Percona Get MySQL Stats/InnoDB Semaphore Waits IM [new]
[success] Percona Get MySQL Stats/InnoDB Semaphore Wait Time IM [new]
[success] Percona Get MySQL Stats/MySQL Processlist IM [new]
[success] Percona Get MySQL Stats/MySQL Transaction Handler IM [new]
[success] Percona Get MySQL Stats/MySQL Handlers IM [new]
[success] Percona Get MySQL Stats/MySQL Query Time Histogram (Count) IM [new]
[success] Percona Get MySQL Stats/MySQL Query Response Time (Microseconds) IM [new]
[success] Percona Get MySQL Stats/InnoDB Buffer Pool Efficiency IM [new]
Data Template
[success] Percona MyISAM Indexes DT [new]
[success] Percona MyISAM Key Cache DT [new]
[success] Percona InnoDB Buffer Pool DT [new]
[success] Percona InnoDB I/O DT [new]
[success] Percona InnoDB Insert Buffer DT [new]
[success] Percona InnoDB Insert Buffer Usage DT [new]
[success] Percona InnoDB Semaphores DT [new]
[success] Percona InnoDB Row Operations DT [new]
[success] Percona MySQL Table Locks DT [new]
[success] Percona MySQL Connections DT [new]
[success] Percona MySQL Replication DT [new]
[success] Percona MySQL Query Cache DT [new]
[success] Percona MySQL Query Cache Memory DT [new]
[success] Percona MySQL Command Counters DT [new]
[success] Percona MySQL Select Types DT [new]
[success] Percona MySQL Sorts DT [new]
[success] Percona MySQL Temporary Objects DT [new]
[success] Percona MySQL Network Traffic DT [new]
[success] Percona InnoDB Buffer Pool Activity DT [new]
[success] Percona InnoDB I/O Pending DT [new]
[success] Percona InnoDB Log DT [new]
[success] Percona MySQL Binary/Relay Logs DT [new]
[success] Percona InnoDB Transactions DT [new]
[success] Percona InnoDB Transactions Active/Locked DT [new]
[success] Percona MySQL Files and Tables DT [new]
[success] Percona MySQL Threads DT [new]
[success] Percona InnoDB Memory Allocation DT [new]
[success] Percona InnoDB Adaptive Hash Index DT [new]
[success] Percona InnoDB Internal Hash Memory Usage DT [new]
[success] Percona InnoDB Tables In Use DT [new]
[success] Percona InnoDB Current Lock Waits DT [new]
[success] Percona InnoDB Lock Structures DT [new]
[success] Percona InnoDB Checkpoint Age DT [new]
[success] Percona InnoDB Row Lock Time DT [new]
[success] Percona InnoDB Row Lock Waits DT [new]
[success] Percona InnoDB Semaphore Waits DT [new]
[success] Percona InnoDB Semaphore Wait Time DT [new]
[success] Percona MySQL Processlist DT [new]
[success] Percona MySQL Transaction Handler DT [new]
[success] Percona MySQL Handlers DT [new]
[success] Percona MySQL Query Time Histogram (Count) DT [new]
[success] Percona MySQL Query Response Time (Microseconds) DT [new]
[success] Percona InnoDB Buffer Pool Efficiency DT [new]
Graph Template
[success] Percona MyISAM Indexes GT [new]
[success] Percona MyISAM Key Cache GT [new]
[success] Percona InnoDB Buffer Pool GT [new]
[success] Percona InnoDB I/O GT [new]
[success] Percona InnoDB Insert Buffer GT [new]
[success] Percona InnoDB Insert Buffer Usage GT [new]
[success] Percona InnoDB Semaphores GT [new]
[success] Percona InnoDB Row Operations GT [new]
[success] Percona MySQL Table Locks GT [new]
[success] Percona MySQL Connections GT [new]
[success] Percona MySQL Replication GT [new]
[success] Percona MySQL Query Cache GT [new]
[success] Percona MySQL Query Cache Memory GT [new]
[success] Percona MySQL Command Counters GT [new]
[success] Percona MySQL Select Types GT [new]
[success] Percona MySQL Sorts GT [new]
[success] Percona MySQL Temporary Objects GT [new]
[success] Percona MySQL Network Traffic GT [new]
[success] Percona InnoDB Buffer Pool Activity GT [new]
[success] Percona InnoDB I/O Pending GT [new]
[success] Percona InnoDB Log GT [new]
[success] Percona MySQL Binary/Relay Logs GT [new]
[success] Percona InnoDB Transactions GT [new]
[success] Percona InnoDB Transactions Active/Locked GT [new]
[success] Percona MySQL Files and Tables GT [new]
[success] Percona MySQL Threads GT [new]
[success] Percona InnoDB Memory Allocation GT [new]
[success] Percona InnoDB Adaptive Hash Index GT [new]
[success] Percona InnoDB Internal Hash Memory Usage GT [new]
[success] Percona InnoDB Tables In Use GT [new]
[success] Percona InnoDB Current Lock Waits GT [new]
[success] Percona InnoDB Lock Structures GT [new]
[success] Percona InnoDB Checkpoint Age GT [new]
[success] Percona InnoDB Row Lock Time GT [new]
[success] Percona InnoDB Row Lock Waits GT [new]
[success] Percona InnoDB Semaphore Waits GT [new]
[success] Percona InnoDB Semaphore Wait Time GT [new]
[success] Percona MySQL Processlist GT [new]
[success] Percona MySQL Transaction Handler GT [new]
[success] Percona MySQL Handlers GT [new]
[success] Percona MySQL Query Time Histogram (Count) GT [new]
[success] Percona MySQL Query Response Time (Microseconds) GT [new]
[success] Percona InnoDB Buffer Pool Efficiency GT [new]
Host Template
[success] Percona MySQL Server HT [new]
打開Devices――>選擇主機(沒有則創建)――>下拉到底部
選擇相應的圖象模板添加到主機:
當前測試添加了3個:
Percona InnoDB Log GT
Percona MySQL Connections GT
Percona MySQL Threads GT

上拉到頁面頂部,點擊“為主機創建圖象(Create Graphs for this Host)”,選擇剛才的3個圖象模板,創建。

創建目錄樹并添加圖象到樹中:
點擊 “圖象樹(Graph Trees)”――>選擇 “默許樹(Default Tree)”――>添加子樹(Mysql_local)

點擊樹Mysql_local旁邊的“添加(Add)”,子樹類型為“圖象(Graph)”,將mysql的3個監控圖象放在該目錄結構中顯示:

幾分鐘后查看。圖象出現!

跨服務器監控centos中的mysql :
cacti監控服務器:192.168.1.151
被監控的客戶端:192.168.1.152
相互ping1下,確認網絡暢通。
在客戶端152中安裝snmp:
yum -y install net-snmp net-snmp-utils
#更改配置文件以下信息:第41行,第62行,第85行
vi /etc/snmp/snmpd.conf
#com2sec notConfigUser default public
com2sec notConfigUser 192.168.1.151 public
#
access notConfigGroup "" any noauth exact systemview none none
access notConfigGroup "" any noauth exact all none none
#將 #view all included .1 80 前面的 # 注釋去掉
view all included .1 80
最后啟動或重啟客戶端snmp服務:
service snmpd restart
在客戶端152的mysql添加cacti用戶允許151訪問:
grant process,super on *.* to 'cacti'@'192.168.1.151' identified by 'cacti';
flush privileges;
在服務端151履行,測試152的snmp是不是啟用成功:
snmpwalk -c public -v 2c 192.168.1.152
主要防火墻問題,把客戶端snmp服務也添加到自啟動中:ntsysv
點擊:裝備(Devices)――>add(右上角)

其他添加的步驟和方法,和本機使用的1樣。
沒有圖象是,注意cacti目錄下是不是有權限:
ll /var/www/html/cacti/rra
很快圖象數據距出現了:

生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈