设为首页 收藏本站
查看: 1515|回复: 0

[经验分享] 因为MySQL表损坏导致cacti报错,有图无数据的解决

[复制链接]

尚未签到

发表于 2015-9-7 13:00:31 | 显示全部楼层 |阅读模式
  ....
  http://wopliu.blog.163.com/blog/static/19390062011917101926278/
  f you can not fix the error with poller_output table not show:
  Just run mysql, use database "cacti" and
+ mySQL>select count(*) from poller_output;
If too much data, run query:
+ mysql> truncate table poller_output;
And it worked for my issue.
Good luck,
Manh Dung
  具体命令
  
[iyunv@monitor ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 97
Server version: 5.1.52 Source distribution
  Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license
  Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use "cacti"
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
  Database changed
mysql> select count(*) from poller_output;
ERROR 145 (HY000): Table './cacti/poller_output' is marked as crashed and should be repaired
mysql> truncate table poller_output;
Query OK, 0 rows affected (0.02 sec)
  mysql> select count(*) from poller_output;
+----------+
| count(*) |
+----------+
| 0 |
+----------+
1 row in set (0.00 sec)
  2、常见不出图或有图无数据解决办法之二:登录CactiEZ中文版V10,点击“工具”菜单中的“系统工具”,然后点击“重建采集器缓存”。几分钟之后再查看是否正常,该办法能解决大多数问题。
  http://hi.baidu.com/arongdy/blog/item/976582af9ce866c47cd92af6.html
  使用Cacti时常见的问题集
2009年05月21日 星期四 11:08
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,我修改成30就OK了。
  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 后面再添 几个0就OK了,同样 2: traffic_out也要修改哦,最好在使用new graph创建新的graph之前修改后,否则之后修改会有一定的麻烦,甚至无法正常工作。
  3、以前都是直接下载tar.gz源代码包安装的,按照readme就可以搞定一切。目前在FC4下可以直接通过yum instal cacti就安装完成,安装后却不知道怎么使用,也不知道安装到什么地方了,怎么让cacti工作。
  首先了解rpm包安装了那些有用的文件:
  rpm程序把cacit的php文件放到/usr/share/cacti目录下。
  在/etc/httpd/conf.d/cacit.conf
  ==============================
  #
  # Cacti: An rrd based graphing tool
  #
  Alias /cacti    /usr/share/cacti
  
  <Directory /usr/share/cacti/>
  Order Deny,Allow
  Deny from all
  Allow from 127.0.0.1
  </Directory>
  ==============================
  在apache的配置里面只允许localhost访问/cacti这个虚拟目录。
  [iyunv@elm ~]# cd /etc/cron.d
  [iyunv@elm cron.d]# more cacti
  */5 * * * *     cacti   /usr/bin/php /usr/share/cacti/poller.php > /dev/null 2>&1
  [iyunv@elm cron.d]#
  定期执行程序的cron配置。
  下面介绍如何让cacti工作:
  首先,配置数据库:
  
  [iyunv@elm local]# cd /usr/share/doc/cacti-0.8.6h/
  [iyunv@elm cacti-0.8.6h]# ls
  cacti.sql docs LICENSE README
  [iyunv@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
  [iyunv@elm cacti-0.8.6h]# mysql cacti_test < cacti.sql
  修改cacit的配置文件:
  [iyunv@elm cacti-0.8.6h]# cd /usr/share/cacti/include/
  [iyunv@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在地址栏输入: http://localhost/cacti进行配置。
  默认用户名密码:admin:admin
  5、如果在配置完毕后可以生成rrd文件,且里面有数据,但是在浏览器上无法看到png图片。现查看apache的log
  如果出现:
  ========================
  [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
  =======================
  [iyunv@elm ~]# cd /usr/share/cacti/rra
  [iyunv@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 ..
  [iyunv@elm rra]#
  
  Other也有R权限,那么请把机器的SElinux关闭,目前我不知道其他办法。
  [iyunv@elm rra]# cd /etc/selinux/
  [iyunv@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
  [iyunv@elm selinux]#
  注意红色部分,重新启动机器后就OK了。
  6、我只想显示整数怎么办?
  修改Graph Templates下的Graph Template Items的GPRINT 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的写权限。
  4,crontab –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.php和poller.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能支持php的snmp扩展、或者确认你有正确设置cactid。推荐使用cactid,效率比通过php高10~20倍。
  4。确认你的rrdtool的版本
rrdtool1.0.x版本和1.2.x版本有着比较大的差别,在cacti里面要正确设置你的rrdtool的版本。比较容易出现的错误就是你的rrdtool是1.2.x版本,而cacti默认的rrdtool版本为1.0.x版本,如果是这样的话,你的数据收集是正常的,不过由于rrdtool的版本变化导致的命令处理格式的一点差别,cacti的缩微图会画不出来的,而具体的图片时可以画出来,这个,大家要留神一下。
  5。当然了,要保证cacti收集的数据能被储藏在你的机器上,要保证收集的数据能被httpd服务读取
  以上是我个人对cacti的trouble shooting的一些认识,请各位补充指正。
  
  将cacti安装好按例子进行配置,想到得到第一个hellow world这样的例子时,常常也会遇到不少的问题,最可能的就是无图,或者有图无数据。
  先说无图吧,主要是检查先确定你的IP地址、snmp comunite、snmp version等信息配置没有错误,如果都没有错误,那么你确定才一个采集周期(一般默认采集周期300秒)以后去检查rra目录,看是否有相应的rra文件生成,如果是新安装,本来rra目录只有一个.placeholder文件。你只要关注以rra为文件后缀的文件即可。如果没有那么一是rra文件权限,windows是ntfs和linux等下有这个问题,其它就检查snmp的设置。
解决cacti中无图或无数据的问题
snmpwalk -v 2c -c public yourIP if
  
  如果有数据返回,则snmp的数据没有问题。如果出现“Timeout: No Response from ...”之类的错误信息则是snmp设置的问题。
  再说有图无数据吧,一般这样的情况就是snmp采集的结果有问题。这种情况下,一般也会出现新建的device的Data 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.
[iyunv@codfei rra]# pwd
/usr/local/apache2/htdocs/cacti/rra
[iyunv@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位系统,
用以下命令检查:
[iyunv@codfei rra]# snmpwalk -c public -v 2c 192.168.1.2 IF-MIB::ifHCInOctets
输出内容如下,表明不支持64位MIB库,终于找到原因了。
IF-MIB::ifHCInOctets = No Such Object available on this agent at this OID
  2,需要重新安装snmpd支持64位MIB库,不过正常用源码包安装时在make的时候会出现error,无法继续,
解决方法:
在源码包下config后,先不要make,请先修改以下两个文件。
  [iyunv@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
  [iyunv@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检测,支持64位MIB库了,过一会流量监视的图片也出来了!
[iyunv@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
  Cacti监控远程服务器问题解决
  使用模板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
  再访问页面终于图和数据出来了
  
  ##########################################
  http://forums.cacti.net/viewtopic.php?f=2&t=22743
  http://www.cisco-club.com.cn/space-104156-do-blog-id-6477.html
  http://bbs.linuxtone.org/thread-5922-1-1.html

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-110591-1-1.html 上篇帖子: 使用cacti 监控oracle 10g/snmp配置 下篇帖子: MRTG、Cacti、Rrdtool、Nagios、Zabbix比较
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表