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

[经验分享] cacti安装配置使用详结

[复制链接]

尚未签到

发表于 2019-1-11 07:10:52 | 显示全部楼层 |阅读模式
  最近有一个项目内服务器频繁出现问题,需要单独建立一套监控系统,暂使用cacti来监控,时间关系以后再考虑nagois+cacti结合或zabbix.
  所需软件包下载路径:
  http://packages.express.org/rrdtool/rrdtool-1.4.5-1.el5.wrl.x86_64.rpm
  http://packages.express.org/rrdtool/rrdtool-devel-1.4.5-1.el5.wrl.x86_64.rpm
  http://packages.express.org/rrdtool/rrdtool-perl-1.4.5-1.el5.wrl.x86_64.rpm
  http://www.cacti.net/downloads/cacti-0.8.7h.tar.gz
  ============
基础环境准备
============
1. 系统安装包环境:
base
editors
development librarys
development tools
x software development

yum groupinstall "develop tools"
yum install gcc gcc-c++   gcc编译环境必须有
  2. cacti的LAMP环境准备:
yum install httpd php php-mysql mysql mysql-server
  3. cacti的mysql环境准备:
启动mysql并添加开机启动:
chkconfig --add mysqld
chkconfig mysqld on
/etc/init.d/mysqld start
mysql_install_db
  cacti用户的创建:
useradd -s /sbin/nologin cactiuser
  4. 服务器端和客户端所需软件snmp安装,利用snmp协议(简单网络管理协议)获取数据:
unix系统安装的都是net-snmp或ucd-snmp(其实两个都是同一组人写的)。
这里说的安装SNMP服务并不是要求安装SNMPD,其实是Cacti需要用到net-snmp中的两个命令――snmpwalk和snmpget进行数据的采集。
yum  install  net-snmp-devel  net-snmp-perl  net-snmp-utils  php-snmp
  配置文件更改:/etc/snmp/snmpd.conf
1)查找字段更改代码.


  • #         sec.name       source   community  
  • com2sec   notConfigUser   default   public

  将"comunity"字段改为你要设置的密码.比如"public".
将“default”改为你想哪台机器可以看到你的snmp信息,授权cacti服务器IP如


  • #       sec.name  source          community  
  • com2sec notConfigUser  192.168.7.250       public  
  • com2sec notConfigUser  127.0.0.1       public

  也可以添加多台cacti-server的IP来监控
  2)查找以下字段将read对应权限none改为all


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

  3)查找以下字段去掉view前面的#号:


  • ##           incl/excl subtree                          mask  
  • view  all    included  .1                               80  
  • ## -or just the mib2 tree-  
  • view  mib2   included  .iso.org.dod.internet.mgmt.mib-2 fc

  启动net-snmp:
snmpd -d /etc/snmp/snmpd.conf或
/etc/init.d/snmpd start
/etc/init.d/snmptrapd start
snmpget -v 1 -c public localhost system.sysUpTime.0 测试
  
============
cacti-server的安装
============
1.安装rrdtool的支持
rrdtool处理rrd 数据库,它用向rrd数据库存储和读取数据来绘图生成输出结果
yum install php-snmp  php-mbstring gd-*x86_64 libart*x86_64
rpm -ivh rrdtool-perl-1.4.5-1.el5.wrl.x86_64.rpm rrdtool-1.4.5-1.el5.wrl.x86_64.rpm rrdtool-devel-1.4.5-1.el5.wrl.x86_64.rpm
  2.cacti的安装及导入数据库
#tar -zvxf cacti-0.8.7h.tar.gz -C  /var/www/html/
#cd /var/www/html/
#mv cacti-0.8.7h  cacti
#chown cactiuser.apache cacti –R
#chmod 775 cacti –R
#mysql -uroot -p cacti < cacti.sql     导入cacti数据库,这里无论是以cactiuser或root用户导入,只要数据库中赋予cactiuser对cacti数据库的all权限就好了
  创建cactiuser用户并授权cacti数据库all权限
# mysql


  • mysql>create database cacti;   
  • mysql> grant all on cacti.* to root;  
  • mysql> grant all privileges on cacti.* to root@localhost  
  • mysql> grant all on cacti.* to cactiuser;  
  • mysql> grant all privileges on cacti.* to cactiuser@localhost identified by 'cactiuser';  
  • mysql> flush privileges;

  cacti配置文件更改,设置连接数据库
#vi  /var/www/html/cacti/include/config.php


  • $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;

  注:倘若后面http://IP/cacti形式访问不了cacti,页面空白,需在include/global.php全局设置下定义URL path:


  • /* built-in snmp support */  
  • $config[&quot;php_snmp_support&quot;] = function_exists(&quot;snmpget&quot;);  
  • 后添加:  
  • /* set URL path */  
  • if (! isset($url_path)) {  
  •         $url_path = &quot;/cacti/&quot;;  
  • }  
  • $config['url_path'] = $url_path;  
  • define('URL_PATH', $url_path);

  测试定时收集数据的poller.php文件并将其加入crontab:
crontab -u cactiuser –e


  • */5 * * * * /usr/bin/php -f /var/www/html/cacti/poller.php >/dev/null 2>&1

  或先手动执行一下php  poller.php收集数据是否有报错
日志查看:tail –f /var/www/html/cacti/log/cacti.log
  ============
WEB管理界面访问
============
apache默认配置文件,开启httpd服务,访问页面http://IP/cacti
需要输入一些原始的信息:
NETXT-->rrdtool,php,snmpwalk,snmpget的路径,net-snmp等,确认路径信息-->设置原始的用户和密码:admin/admin-->更改admin用户密码-->save-->cacti安装完成
  测试:
cacti服务器上手工获取snmp命令:
snmpwalk -v 2c -c public 192.168.7.31:161 system
snmpwalk -v 版本号 -c 团体号 ip 类别
默认snmp协议udp端口161,tcp端口199(可以不用,关闭)
图形界面的添加管理见附件:cacti使用手册
  =============
cacti插件安装
============
详细cacti安装说明见相应版本的官方手册http://docs.cacti.net/manual:087
插件说明http://docs.cacti.net/plugins
插件下载地址:
cacti-plugin  http://www.cacti.net/downloads/pia/cacti-plugin-0.8.7h-PA-v3.0.tar.gz   支持插件管理的扩展包
thold   http://docs.cacti.net/_media/plugin:thold-v0.4.9-3.tgz          注:Thold requires the Settings plugin v0.71 to be installed.
settings  http://docs.cacti.net/_media/plugin:settings-v0.71-1.tgz
monitor  http://docs.cacti.net/_media/plugin:monitor-v1.3-1.tgz
  
tar zxvf cacti-plugin-0.8.7h-PA-v3.0.tar.gz
mv cacti-plugin-arch/*  /var/www/html/cacti/
cd /var/www/html/cacti/
patch -p1 -N < cacti-plugin-0.8.7h-PA-v3.0.diff
mysql -ucactiuser -pcactiuser cacti< pa.sql  
注意所有目录权限更改775,属主组cactiuser.apache
安装好cacti-plugin后,需要在web页面登陆cacti,然后点左侧菜单里的user managerment,点击admin账户,然后在下面把plugin managerment权限勾上,这样就在左侧console菜单里多了插件管理选项 plugin management
  把下载到的插件重命名后解压:
tar zxvf settings-v0.71-1.tgz
tar zxvf thold-v0.4.9-3.tgz
tar zxvf monitor-v1.3-1.tgz
然后把三个插件复制到…/cacti/plugin目录下,WEB界面里在plugin management中install和enable这三个插件就可以了。
注意:有些插件默认不显示在页面上,需要在user managerment里将View Thresholds或View minitore选择上。
  查看/var/www/html/cacti/include/config.php,默认插件装好后已添加:


  • #$cacti_session_name = &quot;Cacti&quot;;  
  • $plugins = array();  
  • $plugins[] = 'thold';  
  • $plugins[] = 'monitor';



附件:http://down.运维网.com/data/2362239


运维网声明 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-661773-1-1.html 上篇帖子: cacti批量添加主机(1) 下篇帖子: cacti模板使用管理及安装问题总结
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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