Cacti 中的 Debugging 技巧

前一陣研究了一大頓 Cacti,遇到了很多大大小小的問題,而這些問題基本都讓我在 Cacti 的官方論壇裏找到了答案,我覺得 Cacti 手冊中的 Debugging 章節還是比較不錯的。我的總結如下:

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+02

In 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 了。


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