本文只介绍安装mysql的模板(teMySQLcacti-20060810.tar.gz),其他的模板用户可以按此方式安装
按照官方文档中的3步
1. Put mysql_stats.php and dumpMemcachedStats.php in cacti/scripts/
本文只拷了mysql_stats
|
# cp teMySQLcacti/mysql_stats.php /var/www/html/cacti/scripts |
2. Either ensure your cacti poller is cron'd every 1 minute, or run the included BASH shell script to create a 300/600 step/heartbeat version of the XML file.
但其实tar本来就有cacti_host_template_temysql_host-step300-heartbeat600.xml
上面的步骤很多余
3. Import the .XML host using the cacti webinterface. Note,
上面3步安装好后,开始再按照官方文档产生图
GRAPH CREATION==============
0. Make sure you installed mysql_stats.php and dumpMemcachedStats.php.
1. Go to Management/Devices.
2. Add a new device.
3. Description can be whatever you want.
4. Hostname should resolve to IP of database machine.
5. Host template is teMySQL or memcached Host.
6. Now choose the "Create Graphs" link.
7. Highlight all graphs for the host (assuming you want them all).
8. Choose "Create"
9. A page will come up with several Password/Username pairs, fill them
all in with the cactipasswd/cactiuser you chose above. Hint: If you're
using Firefox, the second host you do this for you can just press down-
arrow twice, then tab, and the value will be filled in automatically
by the browser. The first time, I suggest typing in the username, copying
it, then doing a "paste-tab-tab-paste-tab-tab..." key combo until they're
all filled in, then repeat for the password. Painful, but doable.

需要在被检测的mysql库里添加检测机器的权限(仅需要process权限): # rrdtool fetch yourRRDfile.rrd AVERAGE 看该文件的采集的数据,如果都是“nan”,那就是没有取到数据。 # snmpwalk -c community -v 2c hostIP if
grant process on *.* to username@192.168.1.1 identified by ‘password’;
flush privileges;
六、常见问题
1、为什么图像不能显示?
先确定你的IP地址、snmp comunite、snmp version等信息配置没有错误。
如果是在linux下安装cacti的话,可以按以下步骤检测:
1.1、cacti的data sources和Graph Management均有debug。看是否有错误,比如rrd文件找不到等。
1.2、data sources里看rrd文件的名称,然后到/cacti/rra目录中看是否有该文件存在。
1.3、如果有rrd文件存在,则可以使用
1.4、有可能是snmpget、snmpwalk和rrdtool的路径错误。
1.5、排除错误后,需要重新建立该监测点(graph)。
提示:每一个图像的文件均会保存为rra目录里的一个rrd为后缀的文件(可以在“Data Sources”中看到)。“Data Sources”和“Graph Management”中均可以进行debug,可以从debug中得出错误信息。
2、为什么rra目录下什么都没有?
2.1、请查看该目录的权限。该目录的权限应为cactiuser可以读写。
2.2、如果目录的权限没有问题,那么可能是snmp的设置有问题,请手工测试一下:
# snmpwalk -v 2c -c public yourIP if
如果有数据返回,则snmp的数据没有问题。如果出现“Timeout: No Response from ...”之类的错误信息则是snmp设置的问题。
2.3、也可能是snmpwalk、snmpget和rrdtool的路径没有设置好在Settings-》Paths中检查设置是否正确。
修改后请重建该监测点!否则不生效。
3、可以取到本机(linux)的数据,但却不能取到远程主机的数据?
Cacti有很多模板,有的是用SNMP进行数据采集,有的是用shell脚本进行采集。如果没有特别的原因建议都使用SNMP的。
Associated Graph Templates
前面带“ucd/net”的就是能使用ucd-snmp和net-snmp的模板。如:ucd/net - CPU Usage
Associated Data Queries
前面带SNMP的就是能使用snmp的。如:SNMP - Interface Statistics
当然,你还可以从www.cacti.net上找到新的模板或添加自己的模板。
4、怎么备份Cacti和它的数据呀?
只需要备份rra目录和数据库就可以了。你喜欢也可以将log目录一起备份。
如果你自己添加了一些插件的话记得也拷过去。
5、新建的device的Data Query里面的状态总是“ Success [0 Items, 0 Rows]”?
请先确认你的snmpd.conf中的权限设置,是否允许cacti取这些OID的数据。可以使用snmpwalk命令来进行测试,比如:
如果你的snmpd.conf设置没有问题,那可能是下面这种情况:
旧版本的snmpwalk(比如RedHat默认安装的5.0.6)缺少一些参数,比如-O中的"U"参数.(可以用snmpwalk --help来查看是否有该参数)。
而cacti-0.86g或以上版本需要这些参数,解决办法是安装一个新的net-snmp包(如:net-snmp5.2.1),从而得到一个新snmpwalk的版本。
6、有图但图例文字不能显示

添加RRDTool默认字体路径
如下图中将路径设置成:/usr/local/rrdtool/share/rrdtool/fonts/DejaVuSansMono-Roman.ttf


