论坛风格切换切换到宽版
  • 1311阅读
  • 4回复

[问题求助][CentOS] 基于 Centos 5.2 的 Cacti 安装全攻略 [复制链接]

上一主题 下一主题
离线smrlgw.
 
发帖
2005
C币
-60682
威望
354
贡献值
1
银元
-2
铜钱
4395
人人网人气币
0
只看楼主 倒序阅读 使用道具 楼主  发表于: 2009-05-01
基于 Centos 5.2.. 的 Cacti 安装全攻略            杀毒
Author:liheng


Cacti 简介(来自Cacti 官方网站).:电影
   .     Cacti is a complete networ.k graphing solution designed to harness the powe.r of RRDTool's data storage and graphing functionality. Cacti provides a fast poller, adva.nced graph templating, multiple data acquisi.tion me.thods, and user management feature.s out of the box. All of this is wrapped in an intuitive, easy to use interface that makes sense for LAN-sized installations up to complex network.s with hun.dreds of devic.es.           女人
Data Sources
To handle data gathering., you can fe.ed cacti the paths to any external script/co.mmand along wit.h any data tha.t the user will need to "fill in", cacti will then gather this data in a cron-job and populate a MySQL databas.e/the round robin archives.          婚庆
Data Sources can also be created, which correspond to actual data on the graph. For instance, if a user would want. to. graph the ping times to a host, y.ou could crea.te a data .source utili.zing a script that pings a host and returns it's value in milliseconds. After .defining options for RRDTool such as how t.o store the data you will be able to d.efine any additional information that the data input source requires, such .as a host to ping in th.is case. Once a data source is created, it is automatically maintained at 5 m.inute intervals.             电子
Graphs
Once one or more data. sources are defined, an RRDTo.ol graph can be created using .the data. Cacti allows you to create almost any. imaginable RR.DTool graph using all of the. sta.ndard RRDTool graph types and consolidation functions. A color selection ar.ea and automatic text padding function also aid in the creation of graphs to make the process easier.    外汇
Not only can you create RRDTool based graphs in cacti, but there a.re many ways to display them. Along with a standard "list view" and a "preview .mode", which resembles th.e RRDTool fr.onte.nd 14all, there is a "tree view", which allows you to put graphs onto a hi.erarchical tree for organizati.onal purposes.电脑
User .Management学习
Due to the many functions of cacti, a user based management tool is built in so you can ad.d users and give them rights to certain area.s of cacti. This would allow someone to create some users that can c.hange graph param.eters,.. while .other.s can only view graphs. Each user also maintains their own settings when it comes to viewing graphs.外贸
Templating
Lastly, cacti is able to scale to a large number of data sources and grap.hs through the use of templates. This allows the creation of a single graph. or data s.ource template which defin.es any graph or data source associate.d with it. Host templates enable you to defin.e the capabilitie.s of a host so cacti can poll it for information upon the a.ddition of a new host.教育
一、Cacti 安装
测试的环境使用 VMWa.re Workstation 6.5.,网络环境介绍:             汽车
序号        IP地址    .    角色虚拟主机
1.        192.168.98.240        Cac.ti 服务器,安装CentOS5.2.
2        192..168.98.204        用于监控的W.indows 主机安装系统为 Windows Server 2003学习
3      .  192.168.98.241        用于监控的 Linux 主机,安装Cen.tOS5.2    健康

在确定你要安装 Cacti.之前,首先请确保你的系统已经安装了以下程序包:..
http
Php
Php-mysql
Php-snmp
Mysql
Mysql-server
Perl-DBD-MySQL
Php-pdo
Net-snmp
Net-snmp-libs
Net-snmp-utils
如果你不能确定你的系统中是否已经安装了以上软件程序包,.可以使用“ rpm -qa 程序包名称”,如查询 http ,使用“ rpm -qa htt.p ”命令查询,安装.了的话,就会显示已经安装的程序包名称,未安装,无显示。.
如http与mysql是已经安装好的,请确保http 与 mysql 服务是开机.自启动的。如果没有,请使用.以下命令使其开机自启动。学习
[root @heng ~] # chkconfig —level .35 mysqld. on    外汇
[root @.heng ~] # chkconfig —lev.el 35 httpd on电影

修改 apache 配置文件
[root @heng.. ~] # vi /etc/httpd/conf/httpd.conf服务器
# 找到 A.ddType 添加如下二行           鲜花
AddType a..pplication/x-httpd-php  .php学习
 AddType app.lication/x-httpd-ph.p-source  .phps.

# 定位至DirectoryIndex index.h..tml            建材
&nbs.p; 修改为:             汽车
   .DirectoryIndex  index.php&n.bsp; index.html            杀毒
启动 mysql .与 http 服务--------------彩票
[root @heng ~] #  se.rvice mysqld. start.
[ro.ot @heng ~] #  servi.ce httpd start外贸
安装 rrdtool
到rrdtool 网站:http://oss.oetiker.ch/rrdtool/ 下载安装文件,现最新的安装文件版本是:rrdtool-1.3.37外贸
[r.oot @heng ~] #  tar xvzf rrdtool-1.3.37.tar..gz.
[root @hen.g ~] # cd rr.dtool-1.3.37    外汇
[ro.ot @heng rrdtool] # ./configure —prefix=/usr/.local/rrdtool           鲜花
[root @heng .rrdtool] # .make.
[root @heng .rrdtool] # make install.    健康
[root. @heng rrdtool] # cd虚拟主机
[root @heng ~] # c.d--------------彩票
修改系统中的 snmp 设置
[r.oot @heng ~] #  vi. /etc/snmp/snmp.conf

com2secnotConfigU.ser default pu.blic(        游戏          )
改为:
c.om2secnotConfig.User 127.0.0.1 public .

access  notConfigGroup ""  any  &nbs.p;noauth    exact  systemvi.ew  none&nbs.p;no.ne(        游戏          )
改为:
ac..cessnotConfigGroup""anynoauthexact all none none学习
#view&n.bsp;all    included  .1&nbs.p;  &.nbsp;     80             汽车
将前面的 # 注释&nbs.p;去掉。.

重新启动 snmp 服务
[roo.t @heng. ~] #  service snmpd restart .
安装 cacti
[root @heng ~] # tar .xzvf cacti-0.8.7d..tar.gz.
[.root @heng ~] # mv cacti-0.8..7d /var/www/html/cacti          婚庆
设置目录权限 , 避免因权限.问题而导致目录无法写入.
[root @heng ~] # c.hmod. 777 -R /var/www/html/cacti             电子
在Mysql中创.建一个用于存储Cacti信息的数据库,这里我将数据库名称命名为cacti,新.建一个数据库用户cacti ,设置密码为 cacti ,并赋予该用户对数据库cacti完全控制权限.。导入    美容
/var/ww.w/html/cacti目录中cacti.sql 生成cacti 数据库结构,然后编辑 cacti 的数据库配.置文件。.
进入数据库
[root @.heng ~] # mysql<性病>
Mysql >. CREATE .DATABASE cacti;电脑
Mysql > insert into mysql.user(Ho.st,U.ser,Password) values(“localhost”,”cacti”,p.assword(“cacti”));.
Mysql > .flush privileges;.
Mysql > grant all .privileges on cacti.* to cacti@local.host. identified by ‘cacti’;--- 印刷
Mysql > grant all privileges on cacti..* to cacti@127.0..0.1 identified by ‘cact.i’;--- 印刷
Mysql .>flush privileges;           鲜花
Mysql > quit
导数据进数据库
[root @heng ~] # mys.ql -u cacti -p cacti < /var/ww/html./cacti/cacti.sql健康
Ent.er password:              乙肝
输入MyS.QL用户cacti 的密码 .
修改 cacti. 数据库配置文件.
[root @heng ~] # vi /var/ww/html/cacti/in..clude/config.php.

$data.base_type= “ mysql ” ; .电脑
$database_default .= “数据库名称.” ; (        游戏          )
$database_hostname&n.bsp;= “默认是 localhost. ” ; 外贸
$database_us.ername = “用户名.” ; (        游戏          )
$data.bas.e_password = “密码” ;电脑
修改成:
$database_type= “. .mysql ” ;              汽车
$databas.e_default&nb.sp;= “cacti” ;           婚庆
$database_hostname&n.bsp;= “. localhost ” ; 电影
$database_usernam.e =&nbsp.;“cacti” ;              汽车
$database_pas.sword =. “cacti” ;           鲜花
因为 cacti 在查找rrdtool 的 Binary path 时默认是在 /bin 、/sbin、/usr/bin、/usr/sbin、/u.sr/local/bin/ 、/usr/local/sbin 目录下查找的,而我的 rrdtool 是自己指定安装在 /usr/local/rrdtool 目录下,.并且我在安装的时候并没有指定 rrdtool的 Binary path 安装在 c.acti 默认查找的目录下.,由此在你第一次开始通过浏览器进入 cac.ti ,在设置 rrdtool、php、snmp工具路径时,你会发现 c.acti 提示 rrdtool 路径是没有找到的,就算你手工修改也一样提.示没有找到,如图:           女人
cacti-004.jpg. (83.67 KB) <性病>
下载次数:8
2009-05-1.3 12:30服务器

http://upload.bbs.csuboy.com/Mon_1004/126_6982_08471836913d2d2.jpg[/img].

评价一下你浏览此帖子的感受

精彩

感动

搞笑

开心

愤怒

无聊

灌水
离线qw2006.
发帖
1975
C币
-140433
威望
358
贡献值
1
银元
-1
铜钱
4396
人人网人气币
0
只看该作者 沙发  发表于: 2010-04-13
Re:[CentOS]
注:这里因为我之前没有安装 net-snmp-utils 所以提示很多 snmp 工具的路径也没有找到。
所以这里需要做一点小小的改动,不然 cacti 不能找到 rrdtool 的 Binary path,由此导致cacti无法正常画出监控图表。编辑 /var/www/html/cacti/install/index.php 文件,找到(大概在96行处) $search_paths =  array(“/bin”,”/sbin”,”/usr/bin”,”/usr/sbin”,”/usr/local/bin”,”/usr/local/sbin”) ,将其修改成如下
[root @heng ~] # vi /var/www/html/cactgi/install/index.php
找到以下内容,将其修改成如下内容
$search_paths =  array(“/bin”,”/sbin”,”/usr/bin”,”/usr/sbin”,”/usr/local/bin”,”/usr/local/sbin”,”/usr/local/rrdtool/bin”)
加入一个计划任务,使得 cacti 每五分钟生成一个监控图表。
[root @heng ~] # crontab -e
*/5 * * * * php /var/www/html/cacti/poller.php > /dev/null 2>&1
打开浏览器,在浏览器地址栏中输入 http://192.168.98.240/cacti ,在第一次使用 cacti 时会显示 cacti的安装指南,设置好一次后,以后就不会出现了。
  下载 (78.67 KB)

2009-05-13 12:34
点击 “Next”
  下载 (39.25 KB)

2009-05-13 12:34

由于是第一次安装,所以选择“New Install”,如果是升级安装,请选择升级安装,点击“Next”
  下载 (78.16 KB)

2009-05-13 12:34

指定 rrdtool、 php、 snmp 工具的 Binary 文件路径,确保所有的路径都是显示 FOUND,而不是 NOT FOUND,点击 Finish 完成安装。
  下载 (27.39 KB)

2009-05-13 12:34
Cacti 默认的用户名与密码是 admin,输入用户名与密码,点击 login
  下载 (29.12 KB)

2009-05-13 12:34
为了安全的原因,第一次登录成功后,cacti 会强制要求你更改一个新的 password ,输入新密码并确认密码,点击 save ,进入 cacti 控制台界面:
  下载 (65.06 KB)

2009-05-13 12:34
点击 graphs ,查看cacti 监控本机的图表:
  下载 (44.48 KB)

2009-05-13 12:34
内存使用图   下载 (44.74 KB)

2009-05-13 13:05
负载均值图
  下载 (37.02 KB)

2009-05-13 13:05
登录用户数图
  下载 (37.82 KB)

2009-05-13 13:05
CPU图


默认 cacti 并没有对主机网卡进行监控,这个需要手工添加,回到consloe ,点击 Device ,在右边点击 ADD 按钮
[img]attachment/Mon_1004/126_6986_9b620f33a380b5e.gif[/img]  [img]attachment/Mon_1004/126_6986_beb26559ff7b5d1.jpg[/img]下载 (83.68 KB)

2009-05-13 13:05
输入设备信息
[img]attachment/Mon_1004/126_6986_9b620f33a380b5e.gif[/img]  [img]attachment/Mon_1004/126_6986_af70ad7cdd478a5.jpg[/img]下载 (136.81 KB)

2009-05-13 13:05
Description 设备名称,可随便填写,最好是设置一个比较有意义的名称
Hostname   设置地址,如果是本机就填 127.0.0.1
HostTemplate                设备的类型,按照实际情况选择,这里是本机,选择 ucd/net SNMP Host
SNMP Version  选择 Version 1
其他的按默认设置即可,点击 Create 。
[img]attachment/Mon_1004/126_6986_9b620f33a380b5e.gif[/img]  [img]attachment/Mon_1004/126_6986_9d94ac57af34a98.jpg[/img]下载 (72.84 KB)

2009-05-13 13:05
[img]attachment/Mon_1004/126_6986_9b620f33a380b5e.gif[/img]  [img]attachment/Mon_1004/126_6986_32a89167e9bf3ca.jpg[/img]下载 (123.6 KB)

2009-05-13 13:05
在顶端显示了 SNMP Information ,表示保存成功,点击 Create Graphs for this Host 开始创建监控图表。

[ 本帖最后由 liheng 于 2009-5-13 13:05 编辑 ]
cacti-013.jpg (103.68 KB)
下载次数:8
2009-05-13 13:05

[img]attachment/Mon_1004/126_6986_cca648b1e59bde8.jpg[/img]

离线areyousure.
发帖
1992
C币
-199332
威望
360
贡献值
1
银元
-1
铜钱
4442
人人网人气币
0
只看该作者 板凳  发表于: 2010-04-13
Re:[CentOS]
备忘录:
在新建本地网卡监控的时候,遇到了一点波折,新建了很多次网卡Device,始终无法生成图表,后来查看Cacti 的Debug信息,提示错误如下:
  下载 (33.29 KB)

2009-05-13 13:11
后来到通过GOOGLE 搜索到了 Cacti BBS的一篇文章解决了此问题,文章地址:http://forums.cacti.net/about10396.html 内容如下:
I've spend about 3 hours trying to figure this out and I've seen alot of people with the same problem.

In cacti 0.8.6g (and perhaps f), using redhat (I've seen enterprise, RH9, Fedora 3 and 4 mentioned) there's a problem getting the list of interfaces to be detected, which allows you to graph traffic.

The typical problems involve the following errors:
"No SNMP data returned" (from verbose query in the devices detail)
No data returned while running snmpwalk -v 1 -c public localhost .1.3.6.1.2.1.2.2.1.1
General problems getting Interface - Traffic graphs to work

The problem resides in the permissions for SNMP version 1 users in the /etc/snmp/snmpd.conf file

You need to change the following limits:
view systemview included .1.3.6.1.2.1.1
view systemview included .1.3.6.1.2.1.25.1.1

to:
view systemview included .1.3.6.1.2.1
view systemview included .1.3.6.1.2.1.25.1.1

This reduces the limits to the pubic group's access using smtpwalk and allows cacti to get the list of interfaces.

  下载 (123.6 KB)

2009-05-13 13:11
在 Data Query [SNMP - Interface Statistics] 勾选需要监控的网卡,点击 Create 开始创建图表。点击 Management 中的 Graph Management
  下载 (88.67 KB)

2009-05-13 13:11
点击 Local NIC Monitior即可以开始浏览监控图表:
  下载 (130.19 KB)

2009-05-13 13:11
注:刚开始的时候,可能图表会无法显示,查看 Debug 信息的话,还会提示 rrdtool 找不到 /var/www/html/cacti/rra/local_nic_monitior_traffic_in_8.rrd 目录或文件。此时只要你确认在此目录或文件是存在的话,请稍待几分钟(或直接使用 php /var/www/html/cacti/poller.php > /dev/null 2>&1 生成图表)再来查看就可以显示啦。
此时这个监控图表在Graph 还不能显示,为了方便管理,统一查看监控图表,下面需要将此图表可以在 Graph 处显示。点击 Management 处的 Graph Trees

  下载 (59.06 KB)

2009-05-13 13:11
点击 Add 按钮,增加一个 Graph Tree
  下载 (50.37 KB)

2009-05-13 13:11
在 Name 处输入一个 Graph Tree 名称,点击 Create
  下载 (77.28 KB)

2009-05-13 13:11
在Tree Items 处点击 Add 添加一个 树成员
  下载 (70.78 KB)

2009-05-13 13:11
在 Tree Item Type 处选择 Host ,在 Host 处选择要添加监控图表,点击 Create ,现在就可以在 Graph 看查看监控图表啦。
  下载 (101.71 KB)

2009-05-13 13:11
二、Cacti 监控局域网内的网络设备
1、使用 Cacti 监控 Windows 主机
这里我以监控 Windows Server 2003 为例。Windows Server 2003 默认安装情况下并没有安装 SNMP 协议,而 Cacti 使用的就是 SNMP 协议,所以为了Cacti 可以正常监控 Windows Server 2003 主机,需要在Windows Server 2003 上安装 SNMP 协议。安装步骤如下:控制面板 | 添加/删除程序| 添加/删除组件 | 管理和监视工具 | 简单网络管理协议(SNMP)开始安装,SNMP安装好后,就需要对 SNMP 进行设置,不然 Cacti 无法接受到 Windows Server 2003 的SNMP 信息。打开 Services 窗口并找到SNMP 服务,双击 SNMP 服务,在打开的窗口中找到“安全”选项卡,
  下载 (35.48 KB)

2009-05-13 13:11
在此选项中有两部分设置,上半部分是指SNMP 服务接受哪种 Community 指示字,默认情况下 Windows Server 2003 不对任何指示字反馈,一般可设置为团体名称为:public,权限:只读。下半部分用来添加可信任的主机名称、IP名称、IPX名称,也就是添加 Cacti 服务器的地址,修改后的情况如下:
[img]attachment/Mon_1004/126_7011_9b620f33a380b5e.gif[/img]  [img]attachment/Mon_1004/126_7011_c4b314a469ee3c1.jpg[/img]下载 (36.16 KB)

2009-05-13 13:11
设置完成后,点击确定按钮,然后重启 SNMP 服务。如果安装了防火墙,记得将 UDP 61 端口打开。登录 Cacti 控制台添加Device,与添加上面添加网卡的操作相同,不过记得在选择 Host Template的时候,选择 Windows 2000/XP host 。从 Windows 上获取到的 SNMP 信息也挺多,CPU,内存,虚拟内存,硬盘空间使用,网卡流量,一应俱全。最后创建图表 , 完成。

2、使用 Cacti 监控 Linux 主机
如果需要使用 Cacti 来监控局域网中的Linux 主机,那么只需要修改被监控 Linux 主机的 SNMP 设置即可,如下:
[root @test ~] # vi /etc/snmp/snmpd.conf

Com2sec        notConfigUser default public
改为:
Com2sec        notConfigUser 192.168.98.240(Cacti 服务器地址) public

access  notConfigGroup ""  any   noauth    exact  systemview  none none
改为:
Access        notConfigGroup        ""        anynoauth        exact all none none
将前面的 # 注释 去掉。
#view all    included  .1         80
重新启动 snmp 服务
[root @test ~] #service snmpd restart
在 Cacti ,Devices中创建新设备,
填写被监控 Linux 主机 IP 地址,Host Template: ucd/net SNMP Host , 创建图表 , 完成。

3、使用 Cacti 监控网络设备
只要是支持SNMP的网络设备,都可以通过使用 Cacti 来对网络设备进行监控。在使用 Cacti 监控网络设备,请确保 SNMP协议是被启用的,并设置被监控的网络设备将 SNMP Trap 发送给 Cacti 主机,Get Community Name为 public 。设置好后,就可以在Cacti 主机上添加对该监控设备的Device 啦,设置基本上差不多,Host Template 选择ucd/net SNMP Host,如果是Cisco 的网络设置可以选择ucd/net SNMP Host 或 Cisco Router ,创建图表,完成。

发帖
2108
C币
-235176
威望
396
贡献值
1
银元
-2
铜钱
4672
人人网人气币
0
只看该作者 地板  发表于: 2010-04-13
Re:[CentOS]
支持下.
不过[root @heng ~] # chmod 777 -R /var/www/html/cacti不赞同,不安全

离线冰之心.
发帖
2128
C币
-198361
威望
377
贡献值
1
银元
-6
铜钱
4807
人人网人气币
0
只看该作者 4楼 发表于: 2010-04-13
Re:[CentOS]
其实不用[root @heng ~] # chmod 777 -R /var/www/html/cacti 也行
我后面做了几次就没有用这一步.

快速回复
限100 字节
批量上传需要先选择文件,再选择上传
 
上一个 下一个