刚开始的时候,在网上找了好多模板的参考文档,都不适合自己的环境,自己摸索来摸索去,终于弄成了。
在这里非常感谢51技术“yangzhimingg”提供的监控模板,适合自己。
首先,到“http://down.51cto.com/data/382105”下载模板,下载解压后,将“ss_get_mysql_stats.php”脚本上传到服务器的“/usr/share/cacti/site/”下面
sudo cp /tmp/ss_get_mysql_stats.php /usr/share/cacti/site/
登录cacti网页,console----import templates,将本地的“cacti_host_template_x_db_server_ht_0.8.6i。xml”模板导入。
导入后会显示如下等信息:
Cacti has imported the following items:
CDEF
[success] X Negate CDEF [new]
GPRINT Preset
[success] X Normal [new]
Data Input Method
[success] X Get MySQL Stats/MyISAM Indexes IM [new]
[success] X Get MySQL Stats/InnoDB Buffer Pool IM [new]
[success] X Get MySQL Stats/InnoDB I/O IM [new]
[success] X Get MySQL Stats/InnoDB Insert Buffer IM [new]
[success] X Get MySQL Stats/InnoDB Semaphores IM [new]
[success] X Get MySQL Stats/InnoDB Row Operations IM [new]
[success] X Get MySQL Stats/MySQL Table Locks IM [new]
[success] X Get MySQL Stats/MySQL Connections IM [new]
[success] X Get MySQL Stats/MySQL Replication IM [new]
[success] X Get MySQL Stats/MySQL Query Cache IM [new]
[success] X Get MySQL Stats/MySQL Query Cache Memory IM [new]
[success] X Get MySQL Stats/MySQL Command Counters IM [new]
[success] X Get MySQL Stats/MySQL Select Types IM [new]
[success] X Get MySQL Stats/MySQL Sorts IM [new]
[success] X Get MySQL Stats/MySQL Temporary Objects IM [new]
[success] X Get MySQL Stats/MySQL Network Traffic IM [new]
[success] X Get MySQL Stats/InnoDB Buffer Pool Activity IM [new]
[success] X Get MySQL Stats/InnoDB I/O Pending IM [new]
[success] X Get MySQL Stats/InnoDB Log IM [new]
[success] X Get MySQL Stats/MySQL Binary/Relay Logs IM [new]
[success] X Get MySQL Stats/InnoDB Transactions IM [new]
[success] X Get MySQL Stats/MySQL Files and Tables IM [new]
[success] X Get MySQL Stats/MySQL Threads IM [new]
[success] X Get MySQL Stats/MySQL Processlist IM [new]
[success] X Get MySQL Stats/MySQL Transaction Handler IM [new]
[success] X Get MySQL Stats/MySQL Handlers IM [new]
。。。。。。
添加divice时,模板选择“X DB Server HT”,snmp版本为2,其他不用修改,save保存
创建图形 :“Create Graphs for this Host”,你会看到有二三十个可以监控的选项。选中“create”后,等一会。看一下日志。
如果有如下类似报错,而且在“graph”下面还无图无数据的
05/02/2015 09:20:02 AM - CMDPHP: Poller[0] Host[4] DS[39] WARNING:
Result from CMD not valid. Partial Result: Could not open input
05/02/2015 09:20:02 AM - CMDPHP: Poller[0] Host[4] DS[40] WARNING:
Result from CMD not valid. Partial Result: Could not open input
点击"console"---"settings"----"path",查看下面的“Spine Poller File Path”是否为绿色,如果是红色的,是你没有安装相应的包,执行“sudo apt-get install cacti-spine” 安装spine。
安装后,点击"console"---"settings"----”poller“,找到”Poller Type“,选择”spine“,save保存一下。
过五分钟后就有图有数据了。