前一阵研究了一大顿 Cacti,遇到了很多大大小小的问题,而这些问题基本都让我在 Cacti 的官方论坛里找到了答案,我觉得 Cacti 手册中的 章节还是比较不错的。我的总结如下:
1. Check Cacti Log File
检查Log文件,这可是最常用的一步了,文件在 /log/cacti.log,Host 后面的数字可以在 Devices 里面点 SNMP Agent 之后在URL的最后看到,常见的 Log 错误如下:CACTID: Host[...] DS[....] WARNING: SNMP timeout detected [500 ms], ignoring host ‘……..’
这个是说 SNMP 超时,可以更改 Settings->Poller 的时间来解决CACTID: Poller [...] Host[...] WARNING: Recache Event Detected for Host
如果老出现的话,在 System Utilities->Rebuild Poller Cache 里面重建下 poller,或用 php rebuild_poller_cache.php 命令也一样CACTID: Poller [...] Host[...] WARNING: Result from SNMP not valid. Partial Result: No Such Object avail
你的 SNMP Agent 不支持该类型的 OID 类型
2. Check Basic Data Gathering
这个好办,测试一下数据是否能够正常得到,SNMP Agent 代理是否工作正常,OID 是否能够或允许访问到,使用 SNMP 命令:$ snmpwalk -v 2c -c public target-host system
如果 Cacti 使用脚本文件获取状态信息,则使用如下命令:
$ su – cactiuser
$ /full/path/to/perl your-perl-script.pl p1 p2
3. Check cacti’s poller
用 cmd.php 来检查具体的 SNMP Agent 是否正常:$ php -q cmd.php
4. Check MySQL updating
这个我没有用过。5. Check rrd file updating
$ rrdtool update <filename> –template …
6. Check rrd file ownership
这个简单,看各个 rrd 文件的访问权限是否设置正确。7. Check rrd file numbers
用命令看看具体的 rrd 文件里面的数据是不是正常的,如果是NAN,返回上面具体检查。官方文档描述如下(我就不翻译了):$ rrdtool fetch <rrd file> AVERAGE
You’re perhaps wondering about this step, if the former was ok. But due to data sources MINIMUM and MAXIMUM definitions, it is possible, that valid updates for rrd files are suppressed, because MINIMUM was not reached or MAXIMUM was exceeded.
Assuming, you’ve got some valid rrdtool update in step 3, perform a
$ rrdtool fetch <rrd file> AVERAGE
and look at the last 10-20 lines. If you find NaN’s there, perform$ rrdtool info
and check the ds[...].min and ds[...].max entries, e.g.ds[loss].min = 0.0000000000e+00
ds[loss].max = 1.0000000000e+02In this example, MINIMUM = 0 and MAXIMUM = 100. For a ds.[...].type=GAUGE verify, that e.g. the number returned by the script does not exceed ds[...].MAX (same holds for MINIMUM, respectively).
If you run into this, please do not only update the data source definition within the Data Template, but perform a
$ rrdtool tune <rrd file> –maximum <ds-name>:<new ds maximum>
8. Check rrdtool graph statement
打开 Graph Management 里面具体的 SNMP Agent,并且打开 Debug 功能,具体看 DEF 的状态,它们指向具体的 rrd 文件。9. Miscellaneous
查看 MySQL 数据库里面记录的数据是否过大,如果过大可以在 php.ini 文件中的 Memory setting 选项更改,默认是8M。10. RPM Installation?
看看 RPM 是否安装完整。11. Not NaN, but 0 (zero) values?
这个问题我没遇到过,所以直接摘录原文:Pay attention to custom scripts. It is required, that external commands called from there are in the $PATH of the cactiuser running the poller. It is therefor recommended to provide /full/path/to/external/command
User “criggie” reported an issue with running smartctl. It was complaining “you are not root” so a quick chmod +s on the script fixed that problem.
Secondly, the script was taking several seconds to run. So cacti was logging a “U” for unparseable in the debug output, and was recording NAN. So my fix there was to make the script run faster, and the age of my box made it difficult to accomplish.
The timeout setting is governed by “Settings → Poller → Script and Script Server Timeout Value”. In general, it is recommended to make scripts faster to avoid that the poller does not finish in time.
12. Cacti 登录密码忘记的解决方法
如果是 admin 的密码丢失,id = 1;其他用户以此类推:mysql> show databases;
mysql> use cacti;mysql> show tables;mysql> update user_auth set password=md5(“newpassword”) where id=’1′;
新的 admin 用户密码就是 newpassword 了。