Cacti安装配置

  • A+
所属分类:Linux

Cacti简介

cacti是用php语言实现的一个软件,它的主要功能是用snmp服务获取数据,snmp需要的变量数据是通过读取mysql数据库得到,然后用rrdtool储存和更新数据,当用户需要查看数据的时候用rrdtool生成图表呈现给用户。rrdtool对数据的更新和存储就是对rrd文件的处理,rrd文件是大小固定的档案文件,它能够存储的数据笔数在创建时就已经定义。

SNMP用来收集数据

Rrdtool用来存储数据和生成图表

MySQL用来配合PHP程序存储一些变量数据并对变量数据进行调用。

LAMP环境

参考《lnmp、lamp、lnmpa一键安装包

Caccti安装及配置

  1. #!/bin/bash
  2. #by LinuxEye
  3. #BLOG: https://blog.linuxeye.cn
  4. yum -y install cairo-devel libxml2-devel pango pango-devel net-snmp*
  5. cd /root/cacti
  6. tar xzf rrdtool-1.4.7.tar.gz
  7. cd rrdtool-1.4.7
  8. ./configure --prefix=/usr/local/rrdtool
  9. make && make install
  10. ln -s /usr/local/rrdtool/bin/* /usr/local/bin/
  11. cd ../
  12. cat >> /etc/snmp/snmpd.conf << EOF
  13. com2sec local     127.0.0.1      public
  14. com2sec local     192.168.22.0/24  public
  15. group MyROGroup v1         local
  16. group MyROGroup v2c        local
  17. group MyROGroup usm        local
  18. view all    included  .1                               80
  19. access MyROGroup ""      any       noauth    exact  all    none   nones
  20. yslocation (/etc/snmpd/snmpd.conf)
  21. syscontact Root <lj2007331@gmail.com>
  22. EOF
  23. tar xzf cacti-0.8.7i.tar.gz
  24. mv cacti-0.8.7i /usr/local/apache/htdocs/
  25. /usr/local/mysql/bin/mysql -uroot -padmin -e "create database cacti;"
  26. /usr/local/mysql/bin/mysql -uroot -padmin -e "grant all privileges on cacti.* to cacti@'localhost' identified by 'cacti123' with grant option;"
  27. /usr/local/mysql/bin/mysql -uroot -padmin -e "flush privileges;"
  28. /usr/local/mysql/bin/mysql -ucacti -pcacti123 --database cacti < /usr/local/apache/htdocs/cacti/cacti.sql
  29. sed -i 's@$database_username =.*$@$database_username = "cacti";@g' /usr/local/apache/htdocs/cacti/include/config.php
  30. sed -i 's@$database_password =.*$@$database_password = "cacti123";@g' /usr/local/apache/htdocs/cacti/include/config.php
  31. tar xzf cacti-spine-0.8.7i.tar.gz
  32. cd cacti-spine-0.8.7i
  33. ./configure --prefix=/usr/local/spine --with-mysql=/usr/local/mysql --with-snmp=/usr/local/net-snmp
  34. make && make install
  35. mv /usr/local/spine/etc/spine.conf.dist /usr/local/spine/etc/spine.conf
  36. sed -i 's@DB_User         cactiuser@DB_User         cacti@g' /usr/local/spine/etc/spine.conf
  37. sed -i 's@DB_Pass         cactiuser@DB_Pass         cacti123@g' /usr/local/spine/etc/spine.conf

#Console>Settings>Poller>PollerType,有两个选项:cmd.php和spine,选择[spine]。Console -> Configuration ->Settings -> Paths -> Alternate Poller Path -> Spine Poller File Path,将“/usr/local/spine/bin/spine”填入文本框,选择spine是为了加快速度,cmd.php是一个php写的调度程序,而
spine是用C写的,spine的性能远远优于cmd.php,当监控的设备有很多时,cmd.php的性能就跟不上

avatar

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: