Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1156943
  • 博文数量: 150
  • 博客积分: 2739
  • 博客等级: 少校
  • 技术积分: 2392
  • 用 户 组: 普通用户
  • 注册时间: 2010-12-07 12:28
文章分类

全部博文(150)

文章存档

2015年(2)

2014年(16)

2013年(10)

2012年(58)

2011年(64)

分类: LINUX

2012-01-20 13:46:16

          公司的cacti绘不出流量图,找遍了Google。总结了一下,其实都是从网上直接copy的,凑在一起。

cacti登录密码忘记解决方法

如果是admin 的密码丢失,id = 1;其他用户以此类推。

进入mysql
mysql> show databases; 
mysql> use cacti;
mysql> show tables; 
mysql> update user_auth set password=md5("newpassword") where id='1';

新的cacti密码就是newpassword~~

以前自己曾经解决的,当时自己记住了,过了好长时间,重新在新的机器上安装cacti的时候,却忘记提前修改,导致一些不必要的麻烦。

1、一般说来,图片的流量统计描述都是 |host_description| - Traffic - |query_ifName| 按照这个形式来描述的,对于华为的设备,Gi显示成GigabitEthernet,可能导致后面的模块号,端口好无法显示。如 GigabitEthernet4/3/2显示成GigabitEthernet,

解决办法:

Console -> Settings -> Visual -> Maximum Field Length:
默认 15,我修改成30OK了。

The maximum number of characters to display for a data query field.


2、对于Traffic 大于800Mbits/s的无法显示问题:

在创建graph前修改 Data Templates -> Interface Traffic -> 1: traffic_in -> Maximum Value Use Per-Data Source Value 默认是100000000 后面再添 几个0OK了,同样 2: traffic_out也要修改哦,最好在使用new graph创建新的graph之前修改后,否则之后修改会有一定的麻烦,甚至无法正常工作。

3、以前都是直接下载tar.gz源代码包安装的,按照readme就可以搞定一切。目前在FC4下可以直接通过yum instal cacti就安装完成,安装后却不知道怎么使用,也不知道安装到什么地方了,怎么让cacti工作。

首先了解rpm包安装了那些有用的文件:

rpm
程序把cacitphp文件放到/usr/share/cacti目录下。

/etc/httpd/conf.d/cacit.conf

==============================

#

# Cacti: An rrd based graphing tool

#

Alias /cacti    /usr/share/cacti





        Order Deny,Allow

        Deny from all

        Allow from 127.0.0.1



==============================

apache的配置里面只允许localhost访问/cacti这个虚拟目录。

[root@elm ~]# cd /etc/cron.d

[root@elm cron.d]# more cacti

*/5 * * * *     cacti   /usr/bin/php /usr/share/cacti/poller.php > /dev/null 2>&1

[root@elm cron.d]#

定期执行程序的cron配置。

下面介绍如何让cacti工作:

首先,配置数据库:



[root@elm local]# cd /usr/share/doc/cacti-0.8.6h/

[root@elm cacti-0.8.6h]# ls

cacti.sql docs LICENSE README

[root@elm cacti-0.8.6h]# mysql

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 312 to server version: 4.1.16



Type 'help;' or '\h' for help. Type '\c' to clear the buffer.



mysql> create database cacti_test;

Query OK, 1 row affected (0.12 sec)



mysql> \q

Bye

[root@elm cacti-0.8.6h]# mysql cacti_test < cacti.sql

修改cacit的配置文件:

[root@elm cacti-0.8.6h]# cd /usr/share/cacti/include/

[root@elm include]# cat db.php


/* make sure these values refect your actual database/host/user/password */

$database_type = "mysql";

$database_default = "cacti_test";

$database_hostname = "localhost";

$database_username = "cactiuser";

$database_password = "cactipass";

$database_port = "3306";

?>

根据自己的需求修改。

OK,打开Firefox在地址栏输入: 进行配置。

默认用户名密码:admin:admin

5、如果在配置完毕后可以生成rrd文件,且里面有数据,但是在浏览器上无法看到png图片。现查看apachelog 

如果出现:

========================

[Thu Feb 09 15:12:24 2006] [error] [client 127.0.0.1] File does not exist: /var/www/html/favicon.ico

ERROR: opening '/usr/share/cacti/rra/localhost_mem_buffers_3.rrd': Permission denied

ERROR: opening '/usr/share/cacti/rra/localhost_mem_buffers_3.rrd': Permission denied

ERROR: opening '/usr/share/cacti/rra/localhost_mem_buffers_3.rrd': Permission denied

ERROR: opening '/usr/share/cacti/rra/localhost_mem_buffers_3.rrd': Permission denied

ERROR: opening '/usr/share/cacti/rra/localhost_mem_buffers_3.rrd': Permission denied

ERROR: opening '/usr/share/cacti/rra/localhost_mem_buffers_3.rrd': Permission denied

ERROR: opening '/usr/share/cacti/rra/localhost_mem_buffers_3.rrd': Permission denied

ERROR: opening '/usr/share/cacti/rra/localhost_mem_buffers_3.rrd': Permission denied

=======================

[root@elm ~]# cd /usr/share/cacti/rra

[root@elm rra]# ls -lat

总用量 572

-rw-r--r-- 1 cacti cacti 141484 2
9 19:15 localhost_load_1min_5.rrd

-rw-r--r-- 1 cacti cacti 47836 2
9 19:15 localhost_mem_buffers_3.rrd

-rw-r--r-- 1 cacti cacti 47836 2
9 19:15 localhost_mem_swap_4.rrd

-rw-r--r-- 1 cacti cacti 47836 2
9 19:15 localhost_proc_7.rrd

-rw-r--r-- 1 cacti cacti 47836 2
9 19:15 localhost_users_6.rrd

-rw-r--r-- 1 cacti cacti 94660 2
9 19:15 tplink_input_13.rrd

-rw-r--r-- 1 cacti cacti 94660 2
9 19:15 tplink_input_16.rrd

drwxr-xr-x 2 cacti root    4096 2
9 18:35 .

drwxr-xr-x 4 root root    4096 2
9 14:30 ..

[root@elm rra]#



Other
也有R权限,那么请把机器的SElinux关闭,目前我不知道其他办法。

[root@elm rra]# cd /etc/selinux/

[root@elm selinux]# more config

# This file controls the state of SELinux on the system.

# SELINUX= can take one of these three values:

#       enforcing - SELinux security policy is enforced.

#       permissive - SELinux prints warnings instead of enforcing.

#       disabled - SELinux is fully disabled.

SELINUX=disabled

# SELINUXTYPE= type of policy in use. Possible values are:

#       targeted - Only targeted network daemons are protected.

#       strict - Full SELinux protection.

SELINUXTYPE=targeted

[root@elm selinux]#

注意红色部分,重新启动机器后就OK了。

6、我只想显示整数怎么办?

修改Graph Templates下的Graph Template ItemsGPRINT Type,改成Exact Number

7、我原来使用的是rrdtool-1.0.x 升级到 1.2.x 后部分图像无法显示(Zoom)

修改Configuration -> Settings -> RRDTool Utility Version -> 1.2.x

个人总结cacti有图无数据解决办法

1,查看log下的日志文件。一般那里会有提示

2,测试SNMP是不是工作正常 snmpwalk -c community -v 2c hostIP if正常的话会出现一些数据。不正常会出现一些错误,也会有对应的错误提示。

3,自动运行poller.php没有。有没有加入cacti的的用户。。有没有给cacti用户写入rra/ log/的权限。对应的命令为:pw useradd cactiuser –d /www/htdocs/cacti(具体路径具体对待)命令作用。为cactiuser这个用户加上cacti这个文件夹的权限 cd /www/htdocs/cacti    chown -R cactiuser rra/ log/ cactiuser加到/rra /log的写权限。

4crontab –u cactiuser –e cactiuser加上自动运行poller.php的任务:

*/1     *       *       *       *       root    /usr/local/bin/php /usr/local/share/cacti/poller.php /dev/null 2>&1

1分钟刷新一次数据。你也可以根据需要还设置。

5。把cacti目录里的cmd.phppoller.php文件加下运行的权限。

 

测试办法:

zyangj

cacti 中的数据源里面没有内容啊?求远程协助

1
、我现在可以看到一些界面了,但是为什么不能加载RRA文件啊?
我执行 rrdtool fetch localhost_mem_swap_4.rrd AVERAGE 可以看到有内容

2# snmpget -v 2c -c public 192.168.1.4 .1.3.6.1.4.1.2021.11.52.0

3/usr/bin/php /www/htdocs/cacti/poller.php

zyangj

我终于找到原因了,我仅然装的是MYSQL5,同志们啊,这个戏CACTI不支持5啊,要记住了,搞了我半个月问题,其实就是自己的问题,多注意了,结稿了。多谢各位大侠指导,在此谢谢了!

coolzsb

                                                         cacti的排错经验

cacti
出不了数据,一般从以下几个方面入手解决问题

1
。确认你的cacti主机上能否得到目标机器上的snmp数据
cacti
得到目标机器上的统计数据分为两种方法,一种是远程通过snmp协议获取、一种是本地机器通过shell脚本获取。

2
。确认你的crontab计划任务有在正常运作
cacti
是通过crontab的定时作业每隔一段时间获取数据的,如果定时作业没有运作,肯定也是读取不到数据的

3
。确认你的crontab定时作业所执行的作业能获取信息
cacti
获取信息用的是poller.php定时运作,然后根据你设置的是用php脚本来执行snmp获取还是cactid来获取,所以,你必须确认你的php能支持phpsnmp扩展、或者确认你有正确设置cactid。推荐使用cactid,效率比通过php10~20倍。

4
。确认你的rrdtool的版本
rrdtool1.0.x
版本和1.2.x版本有着比较大的差别,在cacti里面要正确设置你的rrdtool的版本。比较容易出现的错误就是你的rrdtool1.2.x版本,而cacti默认的rrdtool版本为1.0.x版本,如果是这样的话,你的数据收集是正常的,不过由于rrdtool的版本变化导致的命令处理格式的一点差别,cacti的缩微图会画不出来的,而具体的图片时可以画出来,这个,大家要留神一下。

5
。当然了,要保证cacti收集的数据能被储藏在你的机器上,要保证收集的数据能被httpd服务读取

以上是我个人对cactitrouble shooting的一些认识,请各位补充指正。

  将cacti安装好按例子进行配置,想到得到第一个hellow world这样的例子时,常常也会遇到不少的问题,最可能的就是无图,或者有图无数据。
  先说无图吧,主要是检查先确定你的IP地址、snmp comunitesnmp version等信息配置没有错误,如果都没有错误,那么你确定才一个采集周期(一般默认采集周期300秒)以后去检查rra目录,看是否有相应的rra文件生成,如果是新安装,本来rra目录只有一个.placeholder文件。你只要关注以rra为文件后缀的文件即可。如果没有那么一是rra文件权限,windowsntfslinux等下有这个问题,其它就检查snmp的设置。

解决cacti中无图或无数据的问题

snmpwalk -v 2c -c public yourIP if


  如果有数据返回,则snmp的数据没有问题。如果出现“Timeout: No Response from ...”之类的错误信息则是snmp设置的问题。

  再说有图无数据吧,一般这样的情况就是snmp采集的结果有问题。这种情况下,一般也会出现新建的deviceData Query里面的状态总是“ Success [0 Items, 0 Rows]”。通过执行snmp命令来检查:

snmpwalk -c community -v 2c hostIP if


  通过结果可以看到是否允许cacti取这些OID的数据。
eg

snmpwalk -c public -v1 192.168.0.221 .1.3.6.1.2.1.2.2.1.16.2

cacti 有图没有数据时,而且状态为nan错误解决办法

解决办法:

   1.
[root@codfei rra]# pwd
/usr/local/apache2/htdocs/cacti/rra
[root@codfei rra]# rrdtool fetch fxd-mdl11_traffic_in_365.rrd AVERAGE
按照以上命令执行如果结果输出为:
1197990600:   nan   nan
1197990900:   nan   nan
1197991200:   nan   nan
1197991500:   nan   nan
1197991800:   nan   nan
1197992100:   nan   nan

则表示snmp获取数据有问题,经过仔细检查发现不能获取流量的主机都是64位系统,
用以下命令检查:
[root@codfei rra]# snmpwalk -c public -v 2c 192.168.1.2 IF-MIB::ifHCInOctets
输出内容如下,表明不支持64MIB库,终于找到原因了。
IF-MIB::ifHCInOctets = No Such Object available on this agent at this OID

2
,需要重新安装snmpd支持64MIB,不过正常用源码包安装时在make的时候会出现error,无法继续,
解决方法:
在源码包下config后,先不要make,请先修改以下两个文件。

[root@codfei net-snmp-5.3.1]# vi apps/Makefile
TRAPDWITHAGENT   = $(USETRAPLIBS) -ldl -lrpm -lrpmio -lpopt   -lz -lcrypto -lm
替换成:
TRAPDWITHAGENT   = $(USETRAPLIBS) -ldl -lrpm -lrpmio /usr/lib64/libpopt.so   -lz -lcrypto -lm

[root@codfei net-snmp-5.3.1]# vi agent/Makefile
LIBS          = ../snmplib/libnetsnmp.$(LIB_EXTENSION)$(LIB_VERSION) -ldl -lrpm -lrpmio -lpopt   -lz -lcrypto -lm   $(PERLLDOPTS)
替换成:
LIBS          = ../snmplib/libnetsnmp.$(LIB_EXTENSION)$(LIB_VERSION) -ldl -lrpm -lrpmio /usr/lib64/libpopt.so   -lz -lcrypto -lm 
然后在进行make && make install

3,
停止当前linux自带的snmpd,通过daemoonls启动新安装的snmpd就能了。
  
这时在用snmpwalk检测,支持64MIB库了,过一会流量监视的图片也出来了!
[root@codfei rra]# snmpwalk -c public -v 2c 192.168.1.2 IF-MIB::ifHCInOctets
IF-MIB::ifHCInOctets.1 = Counter64: 2400309170
IF-MIB::ifHCInOctets.2 = Counter64: 256326257624
IF-MIB::ifHCInOctets.3 = Counter64: 0
IF-MIB::ifHCInOctets.4 = Counter64: 624808037429
IF-MIB::ifHCInOctets.5 = Counter64: 0
IF-MIB::ifHCInOctets.6 = Counter64: 0
IF-MIB::ifHCInOctets.7 = Counter64: 0
IF-MIB::ifHCInOctets.8 = Counter64: 0

   

使用模板ucd/net - Memory Usage,检测局域网内别的机器发现有图,但是无数据,都是nan,
cacti log
有如下错误 
04/22/2009 02:10:08 AM - CMDPHP: Poller[0] Host[7] DS[44] WARNING: Result from SNMP not valid.   Partial Result: U
04/22/2009 02:10:08 AM - CMDPHP: Poller[0] Host[7] DS[43] WARNING: Result from SNMP not valid.   Partial Result: U
04/22/2009 02:10:08 AM - CMDPHP: Poller[0] Host[7] DS[42] WARNING: Result from SNMP not valid.   Partial Result: U
04/22/2009 02:10:08 AM - CMDPHP: Poller[0] Host[7] DS[41] WARNING: Result from SNMP not valid.   Partial Result: U
04/22/2009 02:10:08 AM - CMDPHP: Poller[0] Host[7] DS[40] WARNING: Result from SNMP not valid.   Partial Result: U
04/22/2009 02:10:08 AM - CMDPHP: Poller[0] Host[7] DS[39] WARNING: Result from SNMP not valid.   Partial Result: U

于是
wget ftp://mirror.switch.ch/pool/1/mirror/scientificlinux/5rolling/i386/SL/net-snmp-utils-5.3.1-24.el5_2.1.i386.rpm
安装获得snmpget snmpwalk snmpbulkwakl snmpgetnext

snmpwalk -v 2c -c public your_remote_ip if 
错误: 
Timeout: No Response from your_remote_ip 

于是修改snmpd配置 并启动snmpd
com2sec notConfigUser   default   public--->com2sec notConfigUser   your_snmpd_server_ip public 
#view all     included   .1   80---->view all     included   .1   80 

snmpwalk -v 2c -c public your_remote_ip system ok
 
snmpwalk -v 2c -c public your_remote_ip if 
错误: 
IF-MIB::ifTable = No Such Object available on this agent at this OID

于是再次修改snmpd.conf,并重启snmpd
access   notConfigGroup ""       any       noauth     exact   systemview none none-->
access   notConfigGroup ""       any       noauth     exact   all     none none

再次snmpwalk -v 2c -c public your_remote_ip if
ok

再访问页面终于图和数据出来了

阅读(2342) | 评论(1) | 转发(1) |
给主人留下些什么吧!~~

☆彼岸★花开2012-01-20 23:45:53

不错的经验,总结的挺好,学习了\(^o^)/~