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

[经验分享] CentOS6.X上安装Cacti网络监控系统和Spine轮询

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2016-1-22 09:01:25 | 显示全部楼层 |阅读模式
Cacti工具是一套开源的基于Web的网络监控和系统监控的图形解决方案。Cacti通过SNMP服务获取数据,并使用RRDtool绘制图形,提供非常直观的数据和用户管理功能。Cacti需要Web、MySQL和PHP的支持。Cacti一般用于监控网络流量、CPU负载、磁盘空间等。 wKioL1agqMHSuWDVAAGQ-kNaHtY778.jpg
Cacti官网:http://www.cacti.net/


安装Cacti需要安装的软件包:Apache、MySQL、PHP、RRTool、PHP-SNMP、NET-SNMP

一、安装Cacti需要安装的软件包

1、安装扩展源
[iyunv@sh ~]# rpm -ivh http://mirrors.yun-idc.com/epel/ ... ease-6-8.noarch.rpm
2、安装Apache

[iyunv@sh ~]# yum -y install httpd httpd-devel
3、安装MySQL
[iyunv@sh ~]# yum -y install mysql mysql-server
4、安装PHP及相关软件
[iyunv@sh ~]# yum install php php-mysql php-gd php-pear php-devel php-common php-cli php-mbstring php-mcrypt
5、启动Apache、MySQL
1
2
3
4
5
6
[iyunv@sh ~]# chkconfig httpd on
[iyunv@sh ~]# chkconfig mysqld on
[iyunv@sh ~]# service httpd start
[iyunv@sh ~]# service mysqld start

[iyunv@sh ~]# mysqladmin -uroot password dbpasswd ;设置root用户密码



6、安装PHP-SNMP和NET-SNMP
[iyunv@sh ~]# yum -y install php-snmp net-snmp net-snmp-utils net-snmp-libs
7、安装RRDTool
[iyunv@sh ~]# yum -y install rrdtool
wKioL1agUPiRcShDAABcj__hdVY812.jpg
二、安装Cacti服务
1、下载cacti-0.8.8f.tar.gz
[iyunv@sh ~]# wget http://www.cacti.net/downloads/cacti-0.8.8f.tar.gz

2、解压到网站目录/var/www/html/下
[iyunv@sh ~]# tar zxf cacti-0.8.8f.tar.gz
[iyunv@sh ~]# mv cacti-0.8.8f /var/www/html/cacti
[iyunv@sh ~]# chown -R apache.apache /var/www/html/


3、创建Cacti数据库、用户和密码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
[iyunv@sh ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.1.73 Source distribution
Copyright (c) 2000, 2013, 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> create database cacti;
Query OK, 1 row affected (0.00 sec)
mysql> GRANT ALL ON cacti.* TO 'cacti'@'localhost' IDENTIFIED BY 'cactipass';
Query OK, 0 rows affected (0.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.04 sec)
mysql> quit
Bye



4、导入Cacti数据库文件
[iyunv@sh ~]# mysql -uroot -p cacti < /var/www/html/cacti/cacti.sql

5、修改Cacti相关的MySQL数据库配置文件
1
[iyunv@sh ~]# vim /var/www/html/cacti/include/config.php



1
2
3
4
5
6
7
8
/* make sure these values refect your actual database/host/user/password */
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "cactipass";
$database_port = "3306";
$database_ssl = false;




6、添加防火墙规则允许外部访问80端口
1
2
3
[iyunv@sh ~]# iptables -A INPUT -p udp --dport 80 -j ACCEPT
[iyunv@sh ~]# iptables -A INPUT -p tcp --dport 80 -j ACCEPT
[iyunv@sh ~]# service iptables save




7、配置Cacti虚拟主机文件,创建/etc/httpd/conf.d/cacti.conf,允许192.168.1.0的网段访问
1
2
3
4
5
6
7
[iyunv@sh ~]# vim /etc/httpd/conf.d/cacti.conf
Alias /cacti    /var/www/html/cacti
<Directory /var/www/html/cacti/>
        Order Deny,Allow
        Deny from all
        Allow from 192.168.1.0/24
</Directory>




8、调整系统时间,并且修改php.ini对应的时区为'Asia/Shanghai'
1
2
3
4
[iyunv@sh ~]# ntpdate time.nist.gov
[iyunv@sh ~]# hwclock    ;写入BIOS
#添加时间自动同步计划任务
0 11 * * * /usr/sbin/ntpdate time.nist.gov;hwclock -w



1
2
[iyunv@sh ~]# vim /etc/php.ini
date.timezone = 'Asia/Shanghai'



9、配置cacti轮询php脚本,添加cron计划任务,让它每五分钟执行一次以生成图像显示
1
*/5 * * * *  /usr/bin/php /var/www/html/cacti/poller.php



1
2
3
4
5
6
7
[iyunv@sh ~]# /usr/bin/php /var/www/html/cacti/poller.php
OK u:0.00 s:0.01 r:0.08
OK u:0.00 s:0.01 r:0.10
OK u:0.00 s:0.01 r:0.11
OK u:0.00 s:0.01 r:0.13
OK u:0.00 s:0.01 r:0.19
01/21/2016 03:15:01 PM - SYSTEM STATS: Time:0.3285 Method:cmd.php Processes:1 Threads:N/A Hosts:2 HostsPerProcess:2 DataSources:5 RRDsProcessed:5




10、重启服务
1
2
3
4
[iyunv@sh ~]# service httpd restart
[iyunv@sh ~]# service mysqld restart
[iyunv@sh ~]# service snmpd restart
[iyunv@sh ~]# service crond restart




11、浏览器登录http://IP/cacti/install/完成安装向导
wKioL1aggwnBNB_-AAFgGoHIBts880.jpg
Cacti默认登录用户和密码都是admin,根据提示修改,进入Cacti的Web界面

wKioL1agg5_i1dssAADKHJGyKBs790.jpg
安装完成

三、安装Cacti加速轮询器Spine
1、下载spine-0.8.8f,版本对应cacti的版本
[iyunv@sh ~]# wget http://www.cacti.net/downloads/spine/cacti-spine-0.8.8f.tar.gz
2、安装Spine依赖的包

[iyunv@sh ~]# yum -y install libtool net-snmp-devel mysql-devel
3、编译安装Spine
1
2
3
4
5
6
7
8
9
10
[iyunv@sh cacti-spine-0.8.8f]# ./configure
[iyunv@sh cacti-spine-0.8.8f]# make
[iyunv@sh cacti-spine-0.8.8f]# make install
make[1]: Entering directory `/root/cacti-spine-0.8.8f'
/bin/mkdir -p '/usr/local/spine/bin'
  /bin/sh ./libtool   --mode=install /usr/bin/install -c spine '/usr/local/spine/bin'
libtool: install: /usr/bin/install -c spine /usr/local/spine/bin/spine
/bin/mkdir -p '/usr/local/spine/etc'
/usr/bin/install -c -m 644 spine.conf.dist '/usr/local/spine/etc'
make[1]: Leaving directory `/root/cacti-spine-0.8.8f'



1
2
[iyunv@sh cacti-spine-0.8.8f]# ls /usr/local/spine/
bin  etc



4、配置spine.conf文件,指定cacti数据库、用户和密码
[iyunv@sh ~]# cp /usr/local/spine/etc/spine.conf.dist /etc/spine.conf
[iyunv@sh ~]# vim /etc/spine.conf
wKioL1ag5LXAX0rgAAAUaZVITj4400.jpg

5、执行Spine轮询脚本获取监测主机信息
1
2
3
4
[iyunv@sh ~]# /usr/local/spine/bin/spine
SPINE: Using spine config file [/etc/spine.conf]
SPINE: Version 0.8.8f starting
SPINE: Time: 0.2636 s, Threads: 5, Hosts: 2




6、在Cacti页面选择Spine为默认轮询方式

console--->Settings--->Paths--->Spine Poller File Path--->/usr/local/spine/bin/spine--->save
wKiom1ag5cHjUFGEAACBb3A_nS4105.jpg
Poller--->Poller Type--->spine--->save
wKioL1ag5pngKI3lAABp3QWA5Es787.jpg
Cacti配置完成




运维网声明 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-167811-1-1.html 上篇帖子: cacti忘记密码怎么办 下篇帖子: Cacti监控Linux主机 脚本 网络监控
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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