标签:cacti网络监控系统
Cacti工具是一套开源的基于Web的网络监控和系统监控的图形解决方案。Cacti通过SNMP服务获取数据,并使用RRDtool绘制图形,提供非常直观的数据和用户管理功能。Cacti需要Web、MySQL和PHP的支持。Cacti一般用于监控网络流量、使用率CPU负载、磁盘空间等。
Cacti官网:http://www.cacti.net/
安装Cacti需要安装的软件包:Apache、MySQL、PHP、RRTool、PHP-SNMP、NET-SNMP
一、安装Cacti需要安装的软件包
1、安装扩展源
[root@sh ~]# rpm -ivh http://mirrors.yun-idc.com/epel/6/i386/epel-release-6-8.noarch.rpm
2、安装Apache
[root@sh ~]# yum -y install httpd httpd-devel
3、安装MySQL
[root@sh ~]# yum -y install mysql mysql-server
4、安装PHP及相关软件
[root@sh ~]# yum install php php-mysql php-gd php-pear php-devel php-common php-cli php-mbstring php-mcrypt
5、启动Apache、MySQL
[root@sh ~]# chkconfig httpd on [root@sh ~]# chkconfig mysqld on [root@sh ~]# service httpd start [root@sh ~]# service mysqld start [root@sh ~]# mysqladmin -uroot password dbpasswd ;设置root用户密码
6、安装PHP-SNMP和NET-SNMP
[root@sh ~]# yum -y install php-snmp net-snmp net-snmp-utils net-snmp-libs
7、安装RRDTool
[root@sh ~]# yum -y install rrdtool
二、安装Cacti
1、下载cacti-0.8.8f.tar.gz
[root@sh ~]# wget http://www.cacti.net/downloads/cacti-0.8.8f.tar.gz
2、解压到网站目录/var/www/html/下
[root@sh ~]# tar zxf cacti-0.8.8f.tar.gz
[root@sh ~]# mv cacti-0.8.8f /var/www/html/cacti
[root@sh ~]# chown -R apache.apache /var/www/html/
3、创建Cacti数据库、用户和密码
[root@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数据库文件
[root@sh ~]# mysql -uroot -p cacti < /var/www/html/cacti/cacti.sql
5、修改Cacti相关的MySQL数据库配置文件
[root@sh ~]# vim /var/www/html/cacti/include/config.php
/* 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端口
[root@sh ~]# iptables -A INPUT -p udp --dport 80 -j ACCEPT [root@sh ~]# iptables -A INPUT -p tcp --dport 80 -j ACCEPT [root@sh ~]# service iptables save
7、配置Cacti虚拟主机文件,创建/etc/httpd/conf.d/cacti.conf,允许192.168.1.0的网段访问
[root@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‘
[root@sh ~]# vim /etc/php.ini date.timezone = ‘Asia/Shanghai‘ [root@sh ~]# ntpdate time.nist.gov
添加时间同步计划任务
0 11 * * * /usr/sbin/ntpdate time.nist.gov;hwclock -w
9、配置cacti轮询php脚本,添加cron计划任务,让它每五分钟执行一次以生成图像显示
*/5 * * * * /usr/bin/php /var/www/html/cacti/poller.php
[root@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、重启服务
[root@sh ~]# service httpd restart [root@sh ~]# service mysqld restart [root@sh ~]# service snmpd restart [root@sh ~]# service crond restart
11、浏览器登录http://IP/cacti/install/完成安装向导
Cacti默认登录用户和密码都是admin,根据提示修改,进入Cacti的Web界面
安装完成
标签:cacti网络监控系统
原文地址:http://7424593.blog.51cto.com/7414593/1737348