|
运维监控之cacti
Cacti是一套基于PHP,MySQL,SNMP及RRDTool开发的网络流量监测图形分析工具。
首先我们需要搭建lamp环境和安装snmp
安装cacti所需要的软件包
[root@chh1 cacti]# ll
total 9064
-rw-r--r-- 1 root root 2236916 Oct 11 11:21 cacti-0.8.7g.tar.gz
-rw-r--r-- 1 root root 207069 Oct 11 11:21 cacti-plugin-0.8.7g-PA-v2.8.tar.gz
-rw-r--r-- 1 root root 4960221 Oct 11 11:21 feition.tar.bz2
-rw-r--r-- 1 root root 442525 Oct 11 11:21 monitor-latest.tgz
-rw-r--r-- 1 root root 1154026 Oct 11 11:21 rrdtool-1.4.4-1.el5.wrl.i386.rpm
-rw-r--r-- 1 root root 55839 Oct 11 11:21 rrdtool-perl-1.4.4-1.el5.wrl.i386.rpm
-rw-r--r-- 1 root root 18906 Oct 11 11:21 rrdtool-ruby-1.4.4-1.el5.wrl.i386.rpm
-rw-r--r-- 1 root root 6701 Oct 11 11:21 sendMsg.zip
-rw-r--r-- 1 root root 25570 Oct 11 11:21 settings-latest.tgz
-rw-r--r-- 1 root root 12114 Oct 11 11:21 test.png
-rw-r--r-- 1 root root 9091 Oct 11 11:21 test1.png
-rw-r--r-- 1 root root 90488 Oct 11 11:21 thold-latest.tgz
安装软件包
[root@chh1 cacti]# yum install httpd php php-mysql php-snmp mysql-server perl-DBD-MySQL php-pdo net-snmp net-snmp-libs net-snmp-utils net-snmp-devel ruby ruby-devel
启动apache和mysql并设为开机启动
[root@chh1 cacti]# service httpd start
Starting httpd: vh [ OK ]
[root@chh1 cacti]# chkconfig httpd on
[root@chh1 cacti]# service mysqld start
[root@chh1 cacti]# chkconfig mysqld on
cacti的架构示意图
最底层是数据采集层,我们可以通过snmp或者脚本来获取需要监控的对象的数据,中间是数据的存储型有环形数据库RRDtool和mysql构成,上层是展示层通过apache和php以及cacti来展示监控对象的状态。
安装cacti的软件包
给mysql的root用户设置口令
[root@chh1 cacti]# chkconfig mysqld on
[root@chh1 cacti]# mysqladmin -u root -p password '123'
Enter password:
安装rrd环装数据库
[root@chh1 cacti]# yum localinstall rrd* --nogpgcheck -y
解压cacti到/var/www/html/
[root@chh1 cacti]# tar -zxvf cacti-0.8.7g.tar.gz -C /var/www/html/
[root@chh1 html]# mv cacti-0.8.7g/ cacti
创建cacti账号
[root@chh1 html]# useradd cacti
[root@chh1 html]# passwd cacti
在mysql数据库中添加cacti数据库
mysql> create database cacti;
Query OK, 1 row affected (0.00 sec)
给数据库授权apache调用php访问cacti时对mysql可以访问
将cacti数据库授权给cacti用户
mysql> grant all privileges on cacti.* to catci@localhost identified by 'cacti';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on cacti.* to catci@127.0.0.1 identified by 'cacti';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on cacti.* to catci@192.168.1.0 identified by 'cacti';
Query OK, 0 rows affected (0.00 sec)
刷新一下
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
导入cacti中的表格
[root@chh1 html]# mysql -ucacti -pcacti cacti |
|
|