cacti是用php语言实现的一个软件,使用snmp服务获取数据,nnmp关系着数据的收集;使用rrdtool储存和更新数据;当用户需要查看数据的时候用rrdtool生成图表;mysql配合php程序存储一些变量数据并对变量数据进行调用,如:主机名、主机ip、端口号等变量。
cacti监控结构图
C/S模式,采集监测数据
B/S 模式,管理监测平台
mysql 保存模版、配置等信息
rrdtool 数据记录、图表绘制 绘图工具
net-snmp采集各种监测数据 简单网络管理协议(监控与被监控上都要有)
一、部署监控服务器运行环境 (LAMP平台)
1.1装运行环境
#yum -y install httpd php mariadb-server mariadb php-mysql
#systemctl restart httpd ;systemctl enable httpd
#systemctl start mariadb ;systemctl enable mariadb
# service httpd start;chkconfig httpd on
1.2测试运行环境(测php能否连上mysql)
vim /var/www/html/linkdb.php
<?php
$a=mysql_connect("localhost","chen","123456");
if($a){echo "ok";}else{echo "err";}
?>
# elinks --dump http://localhost/linkdb.php
二、部署Cacti监控服务器
2.1安装cacti
RRDTool 绘图工具
snmp 简单网络管理协议
# yum list | grep net-snmp
# yum -y install net-snmp net-snmp-devel net-snmp-utils rrdtool
#tar -zxvf cacti-0.8.8h.tar.gz -C /var/www/html/
#cd /var/www/html/
# mv cacti-0.8.8h/ cacti
# chown -R apache:apache cacti
2.2建立数据库表
#mysql
mysql> create database cactidb default character set utf8;
mysql> grant all on cactidb.* to chen@"localhost" identified by "123456";
#mysql -uchen -p123456 cactidb < /var/www/html/cacti/cacti.sql
#mysql -uchen -p123456 cactidb -e “ show tables;”
2.3 调整配置文件
# vim /var/www/html/cacti/include/config.php
$database_type = "mysql";
$database_default = "cactidb";
$database_hostname = "localhost";
$database_username = "chen";
$database_password = "123456";
三、登录web页面完成初始化安装
3.1 firefox http://192.168.4.13/cacti
用户名 admin
初始密码 admin
(首次登录强制修改登录密码)
使用Cacti
a 查看已经监控的主机 Devices
b 查看已有的监控模版 Graph Trees
c 查看对已监控主机创建的监控图片
3.2 安装高速采集器
安装cacti-spine
#rpm -q mariadb-devel gcc gcc-++
#tar -zxvf cacti-spine-0.8.8h.tar.gz
#cd cacti-spine-0.8.8h/
#./configure --with-mysql
#make && make install
# ls /usr/local/spine/
修改配置
#cp /usr/local/spine/bin/spine /usr/bin/
#cp /usr/local/spine/etc/spine.conf.dist /etc/spine.conf
#vim /etc/spine.conf
DB_Host localhost
DB_Database cactidb
DB_User chen
DB_Pass 123456
DB_Port 3306
登录管理页面设置采集数据频率(poller)和采集器程序(path)
# firefox http://192.168.4.13/cacti<