Chinaunix首页 | 论坛 | 博客
  • 博客访问: 6886861
  • 博文数量: 3857
  • 博客积分: 6409
  • 博客等级: 准将
  • 技术积分: 15948
  • 用 户 组: 普通用户
  • 注册时间: 2008-09-02 16:48
个人简介

迷彩 潜伏 隐蔽 伪装

文章分类

全部博文(3857)

文章存档

2017年(5)

2016年(63)

2015年(927)

2014年(677)

2013年(807)

2012年(1241)

2011年(67)

2010年(7)

2009年(36)

2008年(28)

分类: LINUX

2014-12-04 16:28:03

原文地址:监控—Cacti 作者:silence0607

cacti简介:
cacti 是用 php 语言实现的一个软件,它的主要功能是用 snmp 服务获取数据, snmp 需要的变量数据是通过读取 mysql 数据库得到,
然后用 rrdtool 储存
和更新数据,当用户需要查看数据的时候用 rrdtool 生成图表呈现给用户。rrdtool 对数据的更新和存储就是对 rrd
文件的处理,
rrd 文件是大小固定的档
文件,它能够存储的数据笔数在创建时就已经定义。
1 . snmp 用来收集数据;
2 . rrdtool 用来存储数据和生成图表;
3 . mysql 用来配合 PHP 程序存储一些变量数据并对变量数据进行调用。

所需软件支持:
net-snmp   mysql   apache   php ( gd )   rrdtool  cacti   spine   cacti-plugin(0.8.8以上不需要)    
cacti 运行环境需要 php + mysql + rrdtool 以及 snmp 工具的支持。
软件安装

  1. [root@vm1 ~]# yum install httpd mysql mysql-server mysql-devel php php-mysql php-snmp \
  2. net-snmp net-snmp-utils net-snmp-libs net-snmp-devel libart_lgpl-devel libpng-devel \
  3. freetype-devel cairo-devel pango-devel gcc -y
  4. [root@vm1 ~]# rpm -qa | grep php
  5. php-5.3.3-22.el6.x86_64
  6. [root@vm1 ~]# yum localinstall php-snmp-5.3.3-22.el6.x86_64.rpm -y (与php版本一致)
  7. [root@vm1 ~]# /etc/init.d/mysqld start //初始化数据库
  8. [root@vm1 ~]# /etc/init.d/httpd start
  9.  建议修改 /etc/httpd/conf/httpd.conf   ServerName  yourip:80
    可以避免出现开启服务时的警告: httpd:httpd: apr_sockaddr_info_get() failed for vm1.example.com
    httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
配置snmp
  1. vi /etc/snmp/snmpd.conf
  2. #com2sec notConfigUser default public
  3. com2sec local localhost public
  4. com2sec nicknetwork 192.168.0.0/24 public
  5. #group notConfigGroup v1 notConfigUser
  6. #group notConfigGroup v2c notConfigUser
  7. group MyRWGroup v1 local
  8. group MyRWGroup v2c local
  9. group MyRWGroup usm local
  10. group MyROGroup v1 mynetwork
  11. group MyROGroup v2c mynetwork
  12. group MyROGroup usm mynetwork
  13. view systemview included .1.3.6.1.2.1.1
  14. view systemview included .1.3.6.1.2.1.25.1.1
  15. view all included .1 80
  16. #access notConfigGroup "" any noauth exact systemview none none
  17. access MyROGroup "" any noauth exact all none none
  18. access MyRWGroup "" any noauth exact all all none
  19. syslocation RHEL6.4
  20. syscontact Root
  21. disk / 10000    打开
[root@vm1 ~]# /etc/init.d/snmpd start
现在来测试一下snmp是否正确安装
[root@vm1 ~]# snmpwalk -v 1 -c public localhost IP-MIB::ipAdEntIfIndex
IP-MIB::ipAdEntIfIndex.127.0.0.1 = INTEGER: 1
IP-MIB::ipAdEntIfIndex.192.168.0.201 = INTEGER: 2       看到主机ip表明一切OK!
关于snmp的安装和配置可以参考:
安装rrdtool
  1. tar zxf rrdtool-1.4.4.tar.gz
  2. cd rrdtool-1.4.4
  3. ./configure 
  4. make && make install
  5. ln -s /opt/rrdtool-1.4.4/bin/rrdtool   /usr/local/bin/   
  6. 在configure和make的时候可能会出错  解决办法:yum  install  libxml*   perl-ExtUtils-Embed   -y
安装cacti
  1. tar zxf cacti-0.8.8b.tar.gz -C  /var/www/html   等下直接用web访问cacti
  2. cd /var/www/html
  3. mv cacti-0.8.8b/ cacti
  4. useradd cacti
  5. cd cacti
  6. chown -R cacti rra/ log/  
  7. mysqladmin create cact  创建cacti库i
  8. mysql cacti < cacti.sql 
  9. mysql 到数据库里去对cacti进行设置
  10. mysql> grant all on cacti.* to cacti@localhost identified by 'cacti';
  11. mysql> flush privileges;
  12. mysql>quit
  13. vi include/config.php
  14. $database_type = "mysql";
  15. $database_default = "cacti";
  16. $database_hostname = "localhost";
  17. $database_username = "cacti";
  18. $database_password = "cacti";
  19. $database_port = "3306";
  20. $database_ssl = false;
  21. $url_path = "/cacti/";
  22. $cacti_session_name = "Cacti";
  23. crontab -u cacti -e
        */5 * * * * php /var/www/html/cacti/poller.php    //以cacti身份运行
关于cacti的安装也可以参考官方步骤:
安装spine
(加速插件)
  1. yum install automake libtool -y
  2. tar zxf cacti-spine-0.8.8b.tar.gz
  3. cd cacti-spine-0.8.8b
  4. aclocal
  5. libtoolize --force
  6. autoheader
  7. autoconf
  8. automake
  9. ./configure
  10. make && make install
  11. cd /usr/local/spine/etc
  12. cp spine.conf.dist spine.conf
  13. vi spine.conf
  14. DB_Host         localhost
    DB_Database     cacti
    DB_User         cacti
    DB_Pass         cacti
    DB_Port         3306
    DB_PreG         1

cacti 0.8.8版本以后可以不用装plugin,所以我们直接装以下插件:
  1. tar -zxf monitor-0.8.2.tar.gz -C   /var/www/html/cacti/plugins/
  2. tar -zxf thold-0.4.2.tar.gz    -C    /var/www/html/cacti/plugins/
  3. tar -zxf settings-0.5.tar.g  z -C   /var/www/html/cacti/plugins/
OK,现在我们可以进入到web界面去设置cacti
进入cacti之后,首先设置安装好的spine
Console->Setting->Paths

save之后Poller->Poller Type选择spine最后save

还有monitor thold需要添加
Console->Plugin Management 安装插件
还有其他的一些设置就见仁见智了,So~现在就去定制自己的吧!
在cacti里面我碰到了一个小问题就是,在Graphs中,rrdtool可以绘图,但是表中有乱码,检查后发现系统没有安装任何字体,如果你的问题跟我一样
解决方法:yum install -y cjkuni-uming-fonts   乱码解决!
最后,奉上几张cacti绘制出来的炫酷图


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