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

[经验分享] Cacti 配置测试

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2015-11-22 14:19:15 | 显示全部楼层 |阅读模式
Cacti 配置测试

  

  参考资料:
CentOS yum安装RRDtool
http://www.iyunv.com/Linux/2011-05/36338.htm

CentOS5.4(64bit)下安装配置Cacti----SNMP+RRDTool安装配置(RPM安装)
http://blog.iyunv.com/mintazoedeng/article/details/8542189

使用Cacti监控你的网络(二)- Cacti的安装
http://blog.sina.com.cn/s/blog_4e424e2101000b5y.html

Cacti中文版安装配置
http://blog.163.com/class5steven@126/blog/static/71962690201292083212805/

安装Cacti监控系统
https://wiki.freebsdchina.org/howto/c/cactiinit

cacti无图无数据等常见问题排查
http://www.cnblogs.com/taosim/articles/2557762.html

CACTI :有图无数据解决办法
http://blog.iyunv.com/kk185800961/article/details/45347501

cacti不能获取数据或者显示图经常碰到的问题
http://blog.iyunv.com/luckyboy008/article/details/12072647

用 Cacti 监视 Linux 服务器
http://www.vpsee.com/2009/08/use-cacti-to-monitor-servers/

Cacti突然获取不到数据一例的解决办法
http://www.iyunv.com/Linux/2012-09/71021.htm



系统环境:
[iyunv@localhost etc]# uname -a
Linux localhost.localdomain 2.6.18-194.el5 #1 SMP Fri Apr 2 14:58:35 EDT 2010 i686 athlon i386 GNU/Linux

[iyunv@localhost objects]# ifconfig
eth0:0     inet addr:192.168.3.133  Bcast:192.168.3.255  Mask:255.255.255.0


目标:
cacti安装虚拟机:192.168.3.133  
  被监视虚拟机:192.168.3.131 和 192.168.3.153


  通过测试了解安装和配置Cacti。


测试开始:
被监控主机安装snmp,并配置被监视虚拟机
192.168.3.131 和 192.168.3.153


#检查一下是否已安装,没有
[iyunv@localhost ~]# rpm -qa |grep  snmp

#安装net-snmp以及依赖包lm_sensors
[iyunv@localhost ~]# yum -y install net-snmp lm_sensors

#安装后检查一下
[iyunv@localhost ~]# rpm -qa |grep  snmp
net-snmp-libs-5.3.2.2-25.el5_11
net-snmp-5.3.2.2-25.el5_11

#修改配置
[iyunv@localhost ~]# vi /etc/snmp/snmpd.conf
# First, map the community name "public" into a "security name"
#       sec.name  source          community
#com2sec notConfigUser  default       public

#修改public为cacti123
com2sec notConfigUser  default       cacti123

#       group          context sec.model sec.level prefix read   write  notif
access  notConfigGroup ""      any       noauth    exact  systemview none none

#修改systemview为all
access  notConfigGroup ""      any       noauth    exact  all  none none
view all    included  .1                           80


#如果开了防火墙,则需要添加防火墙策略
[iyunv@localhost ~]# iptables -I INPUT -p udp --dport 161 -j ACCEPT
[iyunv@localhost ~]# iptables -I INPUT -p tcp --dport 199 -j ACCEPT
[iyunv@localhost ~]# service iptables save


#或者关闭防火墙
[iyunv@localhost nrpe-2.15]# vi /etc/selinux/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=permissive
SELINUX=disabled          #设置为disabled
# SELINUXTYPE= type of policy in use. Possible values are:
#       targeted - Only targeted network daemons are protected.
#       strict - Full SELinux protection.
SELINUXTYPE=targeted


"/etc/selinux/config" 11L, 467C written

#启动snmp服务
[iyunv@localhost ~]# service snmpd start
[iyunv@localhost ~]# chkconfig snmpd on

#重启snmpd服务
[iyunv@localhost ~]# service snmpd restart
Stopping snmpd:                                            [  OK  ]
Starting snmpd:                                            [  OK  ]


#测试snmp 192.168.3.131
[iyunv@localhost ~]# snmpwalk -v 1 192.168.3.131 -c cacti123 system
SNMPv2-MIB::sysDescr.0 = STRING: Linux localhost.localdomain 2.6.18-194.el5 #1 SMP Fri Apr 2 14:58:35 EDT 2010 i686
SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-MIB::netSnmpAgentOIDs.10
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (1166731) 3:14:27.31
SNMPv2-MIB::sysContact.0 = STRING: Root <root@localhost> (configure /etc/snmp/snmp.local.conf)
SNMPv2-MIB::sysName.0 = STRING: localhost.localdomain
SNMPv2-MIB::sysLocation.0 = STRING: Unknown (edit /etc/snmp/snmpd.conf)
SNMPv2-MIB::sysORLastChange.0 = Timeticks: (4) 0:00:00.04
SNMPv2-MIB::sysORID.1 = OID: SNMPv2-MIB::snmpMIB
SNMPv2-MIB::sysORID.2 = OID: TCP-MIB::tcpMIB
SNMPv2-MIB::sysORID.3 = OID: IP-MIB::ip
SNMPv2-MIB::sysORID.4 = OID: UDP-MIB::udpMIB
SNMPv2-MIB::sysORID.5 = OID: SNMP-VIEW-BASED-ACM-MIB::vacmBasicGroup
SNMPv2-MIB::sysORID.6 = OID: SNMP-FRAMEWORK-MIB::snmpFrameworkMIBCompliance
SNMPv2-MIB::sysORID.7 = OID: SNMP-MPD-MIB::snmpMPDCompliance
SNMPv2-MIB::sysORID.8 = OID: SNMP-USER-BASED-SM-MIB::usmMIBCompliance
SNMPv2-MIB::sysORDescr.1 = STRING: The MIB module for SNMPv2 entities
SNMPv2-MIB::sysORDescr.2 = STRING: The MIB module for managing TCP implementations
SNMPv2-MIB::sysORDescr.3 = STRING: The MIB module for managing IP and ICMP implementations
SNMPv2-MIB::sysORDescr.4 = STRING: The MIB module for managing UDP implementations
SNMPv2-MIB::sysORDescr.5 = STRING: View-based Access Control Model for SNMP.
SNMPv2-MIB::sysORDescr.6 = STRING: The SNMP Management Architecture MIB.
SNMPv2-MIB::sysORDescr.7 = STRING: The MIB for Message Processing and Dispatching.
SNMPv2-MIB::sysORDescr.8 = STRING: The management information definitions for the SNMP User-based Security Model.
SNMPv2-MIB::sysORUpTime.1 = Timeticks: (4) 0:00:00.04
SNMPv2-MIB::sysORUpTime.2 = Timeticks: (4) 0:00:00.04
SNMPv2-MIB::sysORUpTime.3 = Timeticks: (4) 0:00:00.04
SNMPv2-MIB::sysORUpTime.4 = Timeticks: (4) 0:00:00.04
SNMPv2-MIB::sysORUpTime.5 = Timeticks: (4) 0:00:00.04
SNMPv2-MIB::sysORUpTime.6 = Timeticks: (4) 0:00:00.04
SNMPv2-MIB::sysORUpTime.7 = Timeticks: (4) 0:00:00.04
SNMPv2-MIB::sysORUpTime.8 = Timeticks: (4) 0:00:00.04



#测试snmpd 192.168.3.153,没有成功。经查原因是192.168.3.153上防火墙的问题
[iyunv@localhost ~]# snmpwalk -v 1 192.168.3.153 -c cacti123 system
Timeout: No Response from 192.168.3.153

#虚拟机192.168.3.153上查看防火墙状态
[iyunv@localhost ~]# /etc/init.d/iptables status
Table: filter
Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination         
1    RH-Firewall-1-INPUT  all  --  0.0.0.0/0            0.0.0.0/0           


Chain FORWARD (policy ACCEPT)
num  target     prot opt source               destination         
1    RH-Firewall-1-INPUT  all  --  0.0.0.0/0            0.0.0.0/0           


Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination         


Chain RH-Firewall-1-INPUT (2 references)
num  target     prot opt source               destination         
1    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           
2    ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0           icmp type 255
3    ACCEPT     esp  --  0.0.0.0/0            0.0.0.0/0           
4    ACCEPT     ah   --  0.0.0.0/0            0.0.0.0/0           
5    ACCEPT     udp  --  0.0.0.0/0            224.0.0.251         udp dpt:5353
6    ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0           udp dpt:631
7    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:631
8    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED
9    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:22
10   ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:1158
11   ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0           state NEW udp dpt:1158
12   ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:1521
13   ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0           state NEW udp dpt:1521
14   ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:5501
15   ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0           state NEW udp dpt:5501
16   REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited


#虚拟机上192.168.3.153停用防火墙
[iyunv@localhost ~]# service iptables stop
Flushing firewall rules:                                   [  OK  ]
Setting chains to policy ACCEPT: filter                    [  OK  ]
Unloading iptables modules:                                [  OK  ]


[iyunv@localhost ~]# /etc/init.d/iptables status
Firewall is stopped.

#回到192.168.3.133上,测试snmp 192.168.3.153
[iyunv@localhost ~]# snmpwalk -v 1 192.168.3.153 -c cacti123 system
SNMPv2-MIB::sysDescr.0 = STRING: Linux localhost.localdomain 2.6.18-194.el5 #1 SMP Fri Apr 2 14:58:35 EDT 2010 i686
SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-MIB::netSnmpAgentOIDs.10
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (79336) 0:13:13.36
SNMPv2-MIB::sysContact.0 = STRING: Root <root@localhost> (configure /etc/snmp/snmp.local.conf)
SNMPv2-MIB::sysName.0 = STRING: localhost.localdomain
SNMPv2-MIB::sysLocation.0 = STRING: Unknown (edit /etc/snmp/snmpd.conf)
SNMPv2-MIB::sysORLastChange.0 = Timeticks: (3) 0:00:00.03
SNMPv2-MIB::sysORID.1 = OID: SNMPv2-MIB::snmpMIB
SNMPv2-MIB::sysORID.2 = OID: TCP-MIB::tcpMIB
SNMPv2-MIB::sysORID.3 = OID: IP-MIB::ip
SNMPv2-MIB::sysORID.4 = OID: UDP-MIB::udpMIB
SNMPv2-MIB::sysORID.5 = OID: SNMP-VIEW-BASED-ACM-MIB::vacmBasicGroup
SNMPv2-MIB::sysORID.6 = OID: SNMP-FRAMEWORK-MIB::snmpFrameworkMIBCompliance
SNMPv2-MIB::sysORID.7 = OID: SNMP-MPD-MIB::snmpMPDCompliance
SNMPv2-MIB::sysORID.8 = OID: SNMP-USER-BASED-SM-MIB::usmMIBCompliance
SNMPv2-MIB::sysORDescr.1 = STRING: The MIB module for SNMPv2 entities
SNMPv2-MIB::sysORDescr.2 = STRING: The MIB module for managing TCP implementations
SNMPv2-MIB::sysORDescr.3 = STRING: The MIB module for managing IP and ICMP implementations
SNMPv2-MIB::sysORDescr.4 = STRING: The MIB module for managing UDP implementations
SNMPv2-MIB::sysORDescr.5 = STRING: View-based Access Control Model for SNMP.
SNMPv2-MIB::sysORDescr.6 = STRING: The SNMP Management Architecture MIB.
SNMPv2-MIB::sysORDescr.7 = STRING: The MIB for Message Processing and Dispatching.
SNMPv2-MIB::sysORDescr.8 = STRING: The management information definitions for the SNMP User-based Security Model.
SNMPv2-MIB::sysORUpTime.1 = Timeticks: (2) 0:00:00.02
SNMPv2-MIB::sysORUpTime.2 = Timeticks: (2) 0:00:00.02
SNMPv2-MIB::sysORUpTime.3 = Timeticks: (2) 0:00:00.02
SNMPv2-MIB::sysORUpTime.4 = Timeticks: (2) 0:00:00.02
SNMPv2-MIB::sysORUpTime.5 = Timeticks: (2) 0:00:00.02
SNMPv2-MIB::sysORUpTime.6 = Timeticks: (3) 0:00:00.03
SNMPv2-MIB::sysORUpTime.7 = Timeticks: (3) 0:00:00.03
SNMPv2-MIB::sysORUpTime.8 = Timeticks: (3) 0:00:00.03


在虚拟机192.168.3.133上安装cacti

虚拟系统是直接拷贝上次做的LAMP虚拟环境,这边就不再重新安装apache,mysql,php了。

#tomcat版本
[iyunv@localhost objects]# rpm -qa |grep  httpd
httpd-2.2.3-91.el5.centos
#php版本
[iyunv@localhost objects]# rpm -qa |grep  php
php-mysql-5.1.6-45.el5_11
php-devel-5.1.6-45.el5_11
php-common-5.1.6-45.el5_11
php-5.1.6-45.el5_11
php-cli-5.1.6-45.el5_11
php-pdo-5.1.6-45.el5_11
#mysql版本
[iyunv@localhost objects]# rpm -qa |grep  mysql
php-mysql-5.1.6-45.el5_11
mysql-5.0.95-5.el5_9
mysql-server-5.0.95-5.el5_9

#先安装依赖包
[iyunv@localhost ~]# yum -y install net-snmp net-snmp-devel net-snmp-utils net-snmp-libs lm_sensors php-xml zlib libpng freetype cairo-devel pango-devel gd


#安装rrdtool
配安装源
[iyunv@localhost ~]# cd /etc/yum.repos.d/

[iyunv@localhost yum.repos.d]# vi CentOS-Base.repo
在文件的末尾,添加
--------------------------------
#20130128 insert
[dag]
name=Dag RPM Repostory for Red Hat Enterprise Linux
baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
gpgcheck=1
gpgkey=http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
enabled=1
--------------------------------
这样就可以用yum来安装了。这样就能一下安装相关的依赖包等内容了。

#安装相关依赖
[iyunv@localhost yum.repos.d]# yum install ntp vim-enhanced gcc gcc-c&#43;&#43; gcc-g77 flex bison autoconf automake bzip2-devel ncurses-devel zlib-devel libjpeg-devel libpng-devel libtiff-devel freetype-devel libXpm-devel gettext-devel  pam-devel
....
Installed:
  bzip2-devel.i386 0:1.0.3-6.el5_5                gettext-devel.i386 0:0.17-1.el5               
  libXpm-devel.i386 0:3.5.5-3                     libjpeg-devel.i386 0:6b-38                     
  libtiff-devel.i386 0:3.8.2-19.el5_10            ncurses-devel.i386 0:5.5-24.20060715           
  pam-devel.i386 0:0.99.6.2-14.el5_11             vim-enhanced.i386 2:7.0.109-7.2.el5            

Dependency Installed:
  vim-common.i386 2:7.0.109-7.2.el5                                                              

Updated:
  automake.noarch 0:1.9.6-3.el5       gcc.i386 0:4.1.2-55.el5    gcc-c&#43;&#43;.i386 0:4.1.2-55.el5   
  ntp.i386 0:4.2.2p1-18.el5.centos   

Dependency Updated:
  cpp.i386 0:4.1.2-55.el5                          gcc-gfortran.i386 0:4.1.2-55.el5            
  gettext.i386 0:0.17-1.el5                        libgcc.i386 0:4.1.2-55.el5                  
  libgfortran.i386 0:4.1.2-55.el5                  libstdc&#43;&#43;.i386 0:4.1.2-55.el5               
  libstdc&#43;&#43;-devel.i386 0:4.1.2-55.el5              libtiff.i386 0:3.8.2-19.el5_10               
  pam.i386 0:0.99.6.2-14.el5_11                  

  
  Complete!


#安装rrdtool
[iyunv@localhost yum.repos.d]# yum install -y rrdtool perl-rrdtool rrdtool-devel

......
Installed:
  perl-rrdtool.i386 0:1.4.7-1.el5.rf                 rrdtool.i386 0:1.4.7-1.el5.rf               
  rrdtool-devel.i386 0:1.4.7-1.el5.rf               

Dependency Installed:
  libdbi.i386 0:0.8.1-2.1            lua.i386 0:5.1.4-2.el5.rf    ruby.i386 0:1.8.5-31.el5_9   
  ruby-libs.i386 0:1.8.5-31.el5_9   

Complete!


#修改apache配置
[iyunv@localhost /]# cd /etc/httpd/conf
You have new mail in /var/spool/mail/root


  [iyunv@localhost conf]# ls
httpd.conf  httpd.conf~  magic

[iyunv@localhost conf]# vi httpd.conf
#
DirectoryIndex index.html index.html.var index.php
#在最后加上一段,注意路径

<VirtualHost *:80>
     ServerAdmin root@localhost
     DocumentRoot &quot;/var/www/html/cacti&quot;
     ServerName 192.168.3.133
</VirtualHost>


#修改php的配置文件,php的配置文件:/etc/php.ini
#修改时区参数
[Date]
; Defines the default timezone used by the date functions
;date.timezone = &quot;Asia/Shanghai&quot;


#安装cacti

  从cacti官网下载http://cacti.net/所需软件
  
[iyunv@localhost /]# cd /mnt/hgfs/sharefiles/cacti/

  
[iyunv@localhost cacti]# ls
cacti-0.8.8f.tar.gz  rrdtool-1.4.5.tar.gz

#通过yum安装的rrdtool版本还高一点
[iyunv@localhost cacti]# rpm -qa |grep rrdtool
perl-rrdtool-1.4.7-1.el5.rf
rrdtool-1.4.7-1.el5.rf
rrdtool-devel-1.4.7-1.el5.rf

#创建文件夹,解压缩文件
[iyunv@localhost cacti]# mkdir /usr/src/cacti
[iyunv@localhost cacti]# tar -xzf cacti-0.8.8f.tar.gz -C /usr/src/cacti

#移动文件至WEB根路径下,后面的试验表明文件拷贝错误了,

  #应该将/usr/src/cacti/cacti-0.8.8f/下的所有文件拷贝至/var/www/html/cacti目录下,
#而不是cacti-0.8.8f这个文件夹,请参考后面的修改操作
[iyunv@localhost httpd]# mkdir /var/www/html/cacti
[iyunv@localhost cacti]# mv /usr/src/cacti/cacti-0.8.8f/ /var/www/html/cacti


#补充:我想应该用cp命令可能会比较好一些
[iyunv@localhost cacti]# cp -r /usr/src/cacti/cacti-0.8.8f/ /var/www/html/cacti


#Apache默认以daemon用户及组身份启动,修改目录权限
[iyunv@localhost cacti]# chown -R daemon.daemon /var/www/html/cacti

#修改防火墙配置
[iyunv@localhost cacti]# iptables -I INPUT -p tcp --dport 80 -j ACCEPT
[iyunv@localhost cacti]# service iptables save
Saving firewall rules to /etc/sysconfig/iptables:          [  OK  ]

#重启apache
[iyunv@localhost sbin]# service httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]


#mysql配置
#mysql数据库中创建名为cacti的数据库,

  #创建cactiuser用户,并赋予其访问cacti数据库的所有权限,该账号密码为cacti123
[iyunv@localhost mysql]# /usr/bin/mysqladmin -u root -p create cacti
Enter password: 输入数据库root的密码

[iyunv@localhost mysql]# cd /var/www/html/cacti
[iyunv@localhost cacti]# cd cacti-0.8.8f/

[iyunv@localhost cacti-0.8.8f]# /usr/bin/mysql -u root -p cacti <cacti.sql
Enter password:

#登录mysql
[iyunv@localhost cacti-0.8.8f]# /usr/bin/mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.0.95 Source distribution

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'cacti123';
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye


#修改cacti配置文件中的数据库参数资料
[iyunv@localhost cacti-0.8.8f]# cd include/
[iyunv@localhost include]# pwd
/var/www/html/cacti/cacti-0.8.8f/include

[iyunv@localhost include]#  

[iyunv@localhost include]# vi config.php

  #找到下面的参数
/* make sure these values refect your actual database/host/user/password */
$database_type = &quot;mysql&quot;;
$database_default = &quot;cacti&quot;;
$database_hostname = &quot;localhost&quot;;
$database_username = &quot;cactiuser&quot;;
$database_password = &quot;cactiuser&quot;;
$database_port = &quot;3306&quot;;
$database_ssl = false;


#这里mysql用户cactiuser的密码不对,需修改
$database_password = &quot;cactiuser&quot;;
#改为
$database_password = &quot;cacti123&quot;;


重启apache服务看不到cacti页面
http://192.168.3.133/cacti

  

  #经查发现cacti的路径不对
[iyunv@localhost html]# ls
cacti  phpinfo.php  testdb.php

#将/usr/src/cacti/cacti-0.8.8f/下的所有文件拷贝至/var/www/html/cacti目录下
#修改后的路径
[iyunv@localhost ~]# cd /var/www/html/cacti
[iyunv@localhost cacti]# ls
about.php                gprint_presets.php          images               resource
auth_changepassword.php  graph_image.php             include              rra
auth_login.php           graph.php                   index.php            rra.php
cacti-0.8.8f             graph_settings.php          install              scripts
cacti.sql                graphs_items.php            lib                  script_server.php
cdef.php                 graphs_new.php              LICENSE              script_server.pl
cli                      graphs.php                  log                  settings.php
cmd.php                  graph_templates_inputs.php  logout.php           templates_export.php
color.php                graph_templates_items.php   plugins              templates_import.php
data_input.php           graph_templates.php         plugins.php          tree.php
data_queries.php         graph_view.php              poller_commands.php  user_admin.php
data_sources.php         graph_xport.php             poller_export.php    utilities.php
data_templates.php       host.php                    poller.php
docs                     host_templates.php          README


  启动服务,然后访问http://ip/cacti开始安装cacti
#service mysqld start
#service httpd start
#service snmpd start

  

  [iyunv@localhost cacti]# pwd
/var/www/html/cacti


#将/usr/src/cacti/cacti-0.8.8f/下的所有文件拷贝至/var/www/html/cacti目录下后
#重启apache服务就可以看到cacti页面了
http://192.168.3.133/cacti

#页面会跳转安装步骤
http://192.168.3.133/cacti/install/
DSC0000.jpg

DSC0001.jpg



































































































































DSC0002.jpg
DSC0003.jpg


  #第一次登录,cacti会强制修改密码
用户名:admin
密码:cacti123456
DSC0004.jpg

  #进入cacti管理界面
DSC0005.jpg

  Devices ADD 新的Graph
DSC0006.jpg

  

DSC0007.jpg

DSC0008.jpg

  Save
DSC0009.jpg

  ADD 第二个
DSC00010.jpg

DSC00011.jpg

DSC00012.jpg

  Create
DSC00013.jpg

  Create
DSC00014.jpg

  

DSC00015.jpg

DSC00016.jpg

  

DSC00017.jpg

DSC00018.jpg

  

  

  #一开始无图,然后处理后有无数据,后面开始查资料:
  

  cacti无图像或者无数据,网上查到的检查
1.system utilities –>Rebuild poller cache
2.系统时间不准确,重新设置时间
3.图像没有生成,运行#/usr/bin/php /srv/www/htdocs/cacti/poller.php –force
4.权限问题,修改权限#chmod 777 -R /srv/www/htdocs/cacti/rra
5.数据库表有损坏,修复#mysqlcheck -ao cacti –auto-repair -uroot -p
6.重启snmpd服务#service snmpd restart


[iyunv@localhost ~]# cd /var/www/html/cacti

[iyunv@localhost ~]# cd include

  

#解决cacti中无图或无数据的问题
snmpwalk -v 2c -c public yourIP if

#我的修改
snmpwalk -v 2c -c cacti123 192.168.3.131 if

snmpwalk -v 2c -c cacti123 192.168.3.153 if

#分别处理
[iyunv@localhost log]# snmpwalk -v 2c -c cacti123 192.168.3.131 if
IF-MIB::ifIndex.1 = INTEGER: 1
IF-MIB::ifIndex.2 = INTEGER: 2
IF-MIB::ifIndex.3 = INTEGER: 3
IF-MIB::ifDescr.1 = STRING: lo
IF-MIB::ifDescr.2 = STRING: eth0
IF-MIB::ifDescr.3 = STRING: sit0
IF-MIB::ifType.1 = INTEGER: softwareLoopback(24)
IF-MIB::ifType.2 = INTEGER: ethernetCsmacd(6)
IF-MIB::ifType.3 = INTEGER: tunnel(131)
IF-MIB::ifMtu.1 = INTEGER: 16436
IF-MIB::ifMtu.2 = INTEGER: 1500
IF-MIB::ifMtu.3 = INTEGER: 1480
IF-MIB::ifSpeed.1 = Gauge32: 10000000
IF-MIB::ifSpeed.2 = Gauge32: 1000000000
IF-MIB::ifSpeed.3 = Gauge32: 0
IF-MIB::ifPhysAddress.1 = STRING:
IF-MIB::ifPhysAddress.2 = STRING: 0:c:29:7f:b0:a4
IF-MIB::ifPhysAddress.3 = STRING:
IF-MIB::ifAdminStatus.1 = INTEGER: up(1)
IF-MIB::ifAdminStatus.2 = INTEGER: up(1)
IF-MIB::ifAdminStatus.3 = INTEGER: down(2)
IF-MIB::ifOperStatus.1 = INTEGER: up(1)
IF-MIB::ifOperStatus.2 = INTEGER: up(1)
IF-MIB::ifOperStatus.3 = INTEGER: down(2)
IF-MIB::ifLastChange.1 = Timeticks: (0) 0:00:00.00
IF-MIB::ifLastChange.2 = Timeticks: (0) 0:00:00.00
IF-MIB::ifLastChange.3 = Timeticks: (0) 0:00:00.00
IF-MIB::ifInOctets.1 = Counter32: 2761494
IF-MIB::ifInOctets.2 = Counter32: 513546
IF-MIB::ifInOctets.3 = Counter32: 0
IF-MIB::ifInUcastPkts.1 = Counter32: 1692
IF-MIB::ifInUcastPkts.2 = Counter32: 4678
IF-MIB::ifInUcastPkts.3 = Counter32: 0
IF-MIB::ifInNUcastPkts.1 = Counter32: 0
IF-MIB::ifInNUcastPkts.2 = Counter32: 0
IF-MIB::ifInNUcastPkts.3 = Counter32: 0
IF-MIB::ifInDiscards.1 = Counter32: 0
IF-MIB::ifInDiscards.2 = Counter32: 0
IF-MIB::ifInDiscards.3 = Counter32: 0
IF-MIB::ifInErrors.1 = Counter32: 0
IF-MIB::ifInErrors.2 = Counter32: 0
IF-MIB::ifInErrors.3 = Counter32: 0
IF-MIB::ifInUnknownProtos.1 = Counter32: 0
IF-MIB::ifInUnknownProtos.2 = Counter32: 0
IF-MIB::ifInUnknownProtos.3 = Counter32: 0
IF-MIB::ifOutOctets.1 = Counter32: 2761494
IF-MIB::ifOutOctets.2 = Counter32: 88383
IF-MIB::ifOutOctets.3 = Counter32: 0
IF-MIB::ifOutUcastPkts.1 = Counter32: 1692
IF-MIB::ifOutUcastPkts.2 = Counter32: 932
IF-MIB::ifOutUcastPkts.3 = Counter32: 0
IF-MIB::ifOutNUcastPkts.1 = Counter32: 0
IF-MIB::ifOutNUcastPkts.2 = Counter32: 0
IF-MIB::ifOutNUcastPkts.3 = Counter32: 0
IF-MIB::ifOutDiscards.1 = Counter32: 0
IF-MIB::ifOutDiscards.2 = Counter32: 0
IF-MIB::ifOutDiscards.3 = Counter32: 0
IF-MIB::ifOutErrors.1 = Counter32: 0
IF-MIB::ifOutErrors.2 = Counter32: 0
IF-MIB::ifOutErrors.3 = Counter32: 0
IF-MIB::ifOutQLen.1 = Gauge32: 0
IF-MIB::ifOutQLen.2 = Gauge32: 0
IF-MIB::ifOutQLen.3 = Gauge32: 0
IF-MIB::ifSpecific.1 = OID: SNMPv2-SMI::zeroDotZero
IF-MIB::ifSpecific.2 = OID: SNMPv2-SMI::zeroDotZero
IF-MIB::ifSpecific.3 = OID: SNMPv2-SMI::zeroDotZero  
[iyunv@localhost log]# snmpwalk -v 2c -c cacti123 192.168.3.153 if
IF-MIB::ifIndex.1 = INTEGER: 1
IF-MIB::ifIndex.2 = INTEGER: 2
IF-MIB::ifIndex.3 = INTEGER: 3
IF-MIB::ifDescr.1 = STRING: lo
IF-MIB::ifDescr.2 = STRING: eth0
IF-MIB::ifDescr.3 = STRING: sit0
IF-MIB::ifType.1 = INTEGER: softwareLoopback(24)
IF-MIB::ifType.2 = INTEGER: ethernetCsmacd(6)
IF-MIB::ifType.3 = INTEGER: tunnel(131)
IF-MIB::ifMtu.1 = INTEGER: 16436
IF-MIB::ifMtu.2 = INTEGER: 1500
IF-MIB::ifMtu.3 = INTEGER: 1480
IF-MIB::ifSpeed.1 = Gauge32: 10000000
IF-MIB::ifSpeed.2 = Gauge32: 1000000000
IF-MIB::ifSpeed.3 = Gauge32: 0
IF-MIB::ifPhysAddress.1 = STRING:
IF-MIB::ifPhysAddress.2 = STRING: 0:c:29:c5:f5:d
IF-MIB::ifPhysAddress.3 = STRING:
IF-MIB::ifAdminStatus.1 = INTEGER: up(1)
IF-MIB::ifAdminStatus.2 = INTEGER: up(1)
IF-MIB::ifAdminStatus.3 = INTEGER: down(2)
IF-MIB::ifOperStatus.1 = INTEGER: up(1)
IF-MIB::ifOperStatus.2 = INTEGER: up(1)
IF-MIB::ifOperStatus.3 = INTEGER: down(2)
IF-MIB::ifLastChange.1 = Timeticks: (0) 0:00:00.00
IF-MIB::ifLastChange.2 = Timeticks: (0) 0:00:00.00
IF-MIB::ifLastChange.3 = Timeticks: (0) 0:00:00.00
IF-MIB::ifInOctets.1 = Counter32: 3295661
IF-MIB::ifInOctets.2 = Counter32: 513787
IF-MIB::ifInOctets.3 = Counter32: 0
IF-MIB::ifInUcastPkts.1 = Counter32: 14736
IF-MIB::ifInUcastPkts.2 = Counter32: 4718
IF-MIB::ifInUcastPkts.3 = Counter32: 0
IF-MIB::ifInNUcastPkts.1 = Counter32: 0
IF-MIB::ifInNUcastPkts.2 = Counter32: 0
IF-MIB::ifInNUcastPkts.3 = Counter32: 0
IF-MIB::ifInDiscards.1 = Counter32: 0
IF-MIB::ifInDiscards.2 = Counter32: 0
IF-MIB::ifInDiscards.3 = Counter32: 0
IF-MIB::ifInErrors.1 = Counter32: 0
IF-MIB::ifInErrors.2 = Counter32: 0
IF-MIB::ifInErrors.3 = Counter32: 0
IF-MIB::ifInUnknownProtos.1 = Counter32: 0
IF-MIB::ifInUnknownProtos.2 = Counter32: 0
IF-MIB::ifInUnknownProtos.3 = Counter32: 0
IF-MIB::ifOutOctets.1 = Counter32: 3295661
IF-MIB::ifOutOctets.2 = Counter32: 113442
IF-MIB::ifOutOctets.3 = Counter32: 0
IF-MIB::ifOutUcastPkts.1 = Counter32: 14736
IF-MIB::ifOutUcastPkts.2 = Counter32: 1010
IF-MIB::ifOutUcastPkts.3 = Counter32: 0
IF-MIB::ifOutNUcastPkts.1 = Counter32: 0
IF-MIB::ifOutNUcastPkts.2 = Counter32: 0
IF-MIB::ifOutNUcastPkts.3 = Counter32: 0
IF-MIB::ifOutDiscards.1 = Counter32: 0
IF-MIB::ifOutDiscards.2 = Counter32: 0
IF-MIB::ifOutDiscards.3 = Counter32: 0
IF-MIB::ifOutErrors.1 = Counter32: 0
IF-MIB::ifOutErrors.2 = Counter32: 0
IF-MIB::ifOutErrors.3 = Counter32: 0
IF-MIB::ifOutQLen.1 = Gauge32: 0
IF-MIB::ifOutQLen.2 = Gauge32: 0
IF-MIB::ifOutQLen.3 = Gauge32: 0
IF-MIB::ifSpecific.1 = OID: SNMPv2-SMI::zeroDotZero
IF-MIB::ifSpecific.2 = OID: SNMPv2-SMI::zeroDotZero
IF-MIB::ifSpecific.3 = OID: SNMPv2-SMI::zeroDotZero

——后面有图,但是无数据,继续排查


  #有图无数据的处理
  /usr/bin/php /var/www/html/cacti/poller.php –force

[iyunv@localhost include]# /usr/bin/php /var/www/html/cacti/poller.php --force
OK u:0.01 s:0.02 r:0.60
OK u:0.01 s:0.02 r:0.61
OK u:0.01 s:0.02 r:0.70
OK u:0.01 s:0.02 r:0.70
OK u:0.01 s:0.02 r:0.73
OK u:0.01 s:0.02 r:0.73
OK u:0.01 s:0.02 r:0.80
OK u:0.01 s:0.03 r:0.80
OK u:0.01 s:0.03 r:1.00
OK u:0.01 s:0.03 r:1.00
OK u:0.01 s:0.03 r:1.78
OK u:0.01 s:0.03 r:1.78
OK u:0.01 s:0.03 r:1.93
OK u:0.01 s:0.03 r:1.93
OK u:0.01 s:0.03 r:2.03
OK u:0.01 s:0.03 r:2.03
OK u:0.01 s:0.03 r:2.26
OK u:0.01 s:0.03 r:2.26
OK u:0.01 s:0.03 r:2.38
OK u:0.01 s:0.03 r:2.38
OK u:0.01 s:0.03 r:2.56
OK u:0.01 s:0.03 r:2.56
OK u:0.01 s:0.03 r:2.63
OK u:0.01 s:0.03 r:2.63
OK u:0.01 s:0.03 r:2.74
OK u:0.01 s:0.03 r:2.74
OK u:0.01 s:0.03 r:2.80
OK u:0.01 s:0.03 r:2.80
OK u:0.01 s:0.03 r:2.91
OK u:0.01 s:0.03 r:3.01
OK u:0.01 s:0.03 r:3.08
OK u:0.01 s:0.03 r:3.13
OK u:0.01 s:0.03 r:3.29
OK u:0.01 s:0.04 r:3.50
OK u:0.01 s:0.04 r:3.97
OK u:0.01 s:0.04 r:3.97
OK u:0.01 s:0.04 r:4.04
OK u:0.01 s:0.04 r:4.04
OK u:0.01 s:0.04 r:4.30
OK u:0.01 s:0.04 r:4.30
OK u:0.01 s:0.04 r:4.61
OK u:0.01 s:0.04 r:4.61
OK u:0.02 s:0.04 r:4.71
OK u:0.02 s:0.04 r:4.71
OK u:0.02 s:0.04 r:4.82
OK u:0.02 s:0.04 r:4.82
OK u:0.02 s:0.05 r:4.94
OK u:0.02 s:0.05 r:4.94
OK u:0.02 s:0.05 r:5.10
OK u:0.02 s:0.05 r:5.10
OK u:0.02 s:0.05 r:5.21
OK u:0.02 s:0.05 r:5.23
OK u:0.02 s:0.05 r:5.32
OK u:0.02 s:0.05 r:5.39
OK u:0.02 s:0.05 r:5.51
OK u:0.02 s:0.05 r:5.65
OK u:0.02 s:0.05 r:5.71
OK u:0.02 s:0.05 r:5.78
10/28/2015 11:52:23 AM - SYSTEM STATS: Time:5.9279 Method:cmd.php Processes:1 Threads:N/A Hosts:4 HostsPerProcess:4 DataSources:35 RRDsProcessed:29



#书上抄的,大概意思是5分钟执行一次  crontab -e
*/5 * * * *  /usr/bin/php /var/www/html/cacti/poller.php

#登录mysql检查一下
  [iyunv@localhost log]# /usr/bin/mysql -u cactiuser -p
Enter password: cacti123
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 31
Server version: 5.0.95 Source distribution


  Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


mysql> select database();

&#43;------------&#43;
| database() |
&#43;------------&#43;
| NULL       |
&#43;------------&#43;
1 row in set (0.00 sec)


mysql> status;
--------------
/usr/bin/mysql  Ver 14.12 Distrib 5.0.95, for redhat-linux-gnu (i386) using readline 5.1


Connection id:          31
Current database:
Current user:           cactiuser@localhost
SSL:                    Not in use
Current pager:          stdout
Using outfile:          ''
Using delimiter:        ;
Server version:         5.0.95 Source distribution
Protocol version:       10
Connection:             Localhost via UNIX socket
Server characterset:    latin1
Db     characterset:    latin1
Client characterset:    latin1
Conn.  characterset:    latin1
UNIX socket:            /var/lib/mysql/mysql.sock
Uptime:                 1 hour 46 min 9 sec


Threads: 7  Questions: 22588  Slow queries: 0  Opens: 77  Flush tables: 1  Open tables: 64  Queries per second avg: 3.547
--------------


mysql> show tables;
ERROR 1046 (3D000): No database selected

#查一下数据库
mysql> show databases;
&#43;--------------------&#43;
| Database           |
&#43;--------------------&#43;
| information_schema |
| cacti              |
| test               |
&#43;--------------------&#43;
3 rows in set (0.01 sec)


#切换数据库至cacti
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> show tables;
&#43;---------------------------&#43;
| Tables_in_cacti           |
&#43;---------------------------&#43;
| cdef                      |
| cdef_items                |
| colors                    |
| data_input                |
| data_input_data           |
| data_input_fields         |
| data_local                |
| data_template             |
| data_template_data        |
| data_template_data_rra    |
| data_template_rrd         |
| graph_local               |
| graph_template_input      |
| graph_template_input_defs |
| graph_templates           |
| graph_templates_gprint    |
| graph_templates_graph     |
| graph_templates_item      |
| graph_tree                |
| graph_tree_items          |
| host                      |
| host_graph                |
| host_snmp_cache           |
| host_snmp_query           |
| host_template             |
| host_template_graph       |
| host_template_snmp_query  |
| plugin_config             |
| plugin_db_changes         |
| plugin_hooks              |
| plugin_realms             |
| poller                    |
| poller_command            |
| poller_item               |
| poller_output             |
| poller_reindex            |
| poller_time               |
| rra                       |
| rra_cf                    |
| settings                  |
| settings_graphs           |
| settings_tree             |
| snmp_query                |
| snmp_query_graph          |
| snmp_query_graph_rrd      |
| snmp_query_graph_rrd_sv   |
| snmp_query_graph_sv       |
| user_auth                 |
| user_auth_perms           |
| user_auth_realm           |
| user_log                  |
| version                   |
&#43;---------------------------&#43;
52 rows in set (0.01 sec)


#查看数据库记录poller的执行时间是空的
mysql> select * from poller_time;
Empty set (0.00 sec)



#执行[iyunv@localhost include]# /usr/bin/php /var/www/html/cacti/poller.php --force 后
  #再次查看数据库
[iyunv@localhost include]# /usr/bin/mysql -u cactiuser -p
Enter password: cacti123
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
  

  #查看数据库记录poller的执行时间
mysql> select * from poller_time;
&#43;----&#43;-------&#43;-----------&#43;---------------------&#43;---------------------&#43;
| id | pid   | poller_id | start_time          | end_time            |
&#43;----&#43;-------&#43;-----------&#43;---------------------&#43;---------------------&#43;
|  1 | 19470 |         0 | 2015-10-27 21:25:01 | 2015-10-27 21:25:05 |
&#43;----&#43;-------&#43;-----------&#43;---------------------&#43;---------------------&#43;
1 row in set (0.00 sec)

#过一会再查,增加了5分钟
mysql> select * from poller_time;
&#43;----&#43;-------&#43;-----------&#43;---------------------&#43;---------------------&#43;
| id | pid   | poller_id | start_time          | end_time            |
&#43;----&#43;-------&#43;-----------&#43;---------------------&#43;---------------------&#43;
|  1 | 19627 |         0 | 2015-10-27 21:30:02 | 2015-10-27 21:30:05 |
&#43;----&#43;-------&#43;-----------&#43;---------------------&#43;---------------------&#43;
1 row in set (0.00 sec)


#查看cacti日志
[iyunv@localhost log]# pwd
/var/www/html/cacti/log

[iyunv@localhost log]# cat cacti.log
10/28/2015 11:52:23 AM - SYSTEM STATS: Time:5.9279 Method:cmd.php Processes:1 Threads:N/A Hosts:4 HostsPerProcess:4 DataSources:35 RRDsProcessed:29
10/28/2015 12:25:01 PM - POLLER: Poller[0] WARNING: Cron is out of sync with the Poller Interval!  The Poller Interval is '300' seconds, with a maximum of a '300' second Cron, but 1964 seconds have passed since the last poll!
10/28/2015 12:25:05 PM - SYSTEM STATS: Time:3.6730 Method:cmd.php Processes:1 Threads:N/A Hosts:4 HostsPerProcess:4 DataSources:35 RRDsProcessed:29
10/28/2015 12:30:05 PM - SYSTEM STATS: Time:3.8174 Method:cmd.php Processes:1 Threads:N/A Hosts:4 HostsPerProcess:4 DataSources:35 RRDsProcessed:29
10/28/2015 12:35:06 PM - SYSTEM STATS: Time:4.2797 Method:cmd.php Processes:1 Threads:N/A Hosts:4 HostsPerProcess:4 DataSources:35 RRDsProcessed:29
10/28/2015 12:40:06 PM - SYSTEM STATS: Time:4.1686 Method:cmd.php Processes:1 Threads:N/A Hosts:4 HostsPerProcess:4 DataSources:35 RRDsProcessed:29
10/28/2015 12:45:05 PM - SYSTEM STATS: Time:4.2167 Method:cmd.php Processes:1 Threads:N/A Hosts:4 HostsPerProcess:4 DataSources:35 RRDsProcessed:29
You have new mail in /var/spool/mail/root

//-----------------------//

#添加中文字体支持,CentOS下直接yum安装中文支持
[iyunv@localhost conf]# yum install fonts-chinese
Installed:
  fonts-chinese.noarch 0:3.02-12.el5                                                            


Complete!
  
打开Cacti,控制面板->配置->设置->路径:
将RRDTool默认字体路径设为/usr/share/fonts/chinese/TrueType/ukai.ttf
配置无误,会显示文件已找到。
——没测试


设置计划任务
#crontab –e
追加以下内容
*/5 * * * * php /var/www/cacti/poller.php >/dev/null &2>1


#虚拟机上直接浏览
DSC00019.jpg
  

  #物理机上浏览
DSC00020.jpg
  

  #过一会的图
DSC00021.jpg


  

  

运维网声明 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-142192-1-1.html 上篇帖子: Linux---Cacti字体 下篇帖子: Cacti故障篇(补充中)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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