Linux下使用Cacti監控流量狀況,linuxcacti監控流量
Cacti 在英文中的意思是仙人掌的意思,Cacti是一套基於PHP,MySQL,SNMP及RRDTool開發的網路流量監測圖形分析工具,使用PHP開發,它是由一些PHP頁面組成軟體,主要針對企業的大量網路裝置、伺服器主機***能監測服務,可提供對CPU負載、記憶體佔用、運行進程數、磁碟空間、網卡流量等各種資料資訊的監測,cacti注重的是狀態監控,警示和服務恢複功能比較差。
官方網站:
http://www.cacti.net
下載頁面:
http://www.cacti.net/downloads/cacti-0.8.8b.tar.gz
開始Cacti安裝部署
機器IP地址:192.168.1219.129
軟體下載:
[root@rhel64 ~]# wget http://www.cacti.net/downloads/cacti-0.8.8a.tar.gz
[root@rhel64 ~]# wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.4.5.tar.gz
[root@rhel64 ~]# wget http://www.cacti.net/downloads/spine/cacti-spine-0.8.8a.tar.gz
安裝lamp環境:
[root@rhel64 ~]# yum install -y httpd mysql mysql-server php php-mysql php-json php-pdo
安裝相關的lib庫:
[root@rhel64 ~]# yum install -y cairo-devel libxml2-devel pango pango-devel
安裝編譯器:
[root@rhel64 ~]# yum -y install gcc make gcc-c++
解壓編譯軟體:
[root@rhel64 ~]# tar -xzf rrdtool-1.4.5.tar.gz
[root@rhel64 ~]# cd rrdtool-1.4.5
[root@rhel64 rrdtool-1.4.5]# ./configure --prefix=/usr/local/rrdtool/
[root@rhel64 rrdtool-1.4.5]# make && make install
[root@rhel64 rrdtool-1.4.5]# ln -s /usr/local/rrdtool/bin/* /usr/local/bin/
安裝snmp服務:
[root@rhel64 rrdtool-1.4.5]# yum -y install net-snmp net-snmp-utils
安裝Cacti主程式:
[root@rhel64 ~]# tar xzf cacti-0.8.8a.tar.gz && mv cacti-0.8.8a /var/www/html/cacti
建立Cacti資料庫:
[root@rhel64 ~]# service mysqld start
[root@rhel64 ~]# /usr/bin/mysqladmin -u root -h rhel64 password '123456'
[root@rhel64 ~]# /usr/bin/mysqladmin -u root password '123456'
[root@rhel64 ~]# mysql -uroot -p
mysql> create database cacti;
Query OK, 1 row affected (0.00 sec)
mysql> grant all on cacti.* to cacti@'localhost' identified by "123456";
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql>
把Cacti資料匯入Cacti資料庫:
[root@rhel64 ~]# mysql -ucacti -p123456 cacti</var/www/html/cacti/cacti.sql
[root@rhel64 ~]# chmod -R 777 /var/www/html/cacti/rra
[root@rhel64 ~]# chmod -R 777 /var/www/html/cacti/log
[root@rhel64 ~]# vi /var/www/html/cacti/include/config.php
<?php
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2004-2012 The Cacti Group |
| |
| This program is free software; you can redistribute it and/or |
| modify it under the terms of the GNU General Public License |
| as published by the Free Software Foundation; either version 2 |
| of the License, or (at your option) any later version. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU General Public License for more details. |
+-------------------------------------------------------------------------+
| Cacti: The Complete RRDTool-based Graphing Solution |
+-------------------------------------------------------------------------+
| This code is designed, written, and maintained by the Cacti Group. See |
| about.php and/or the AUTHORS file for specific developer information. |
+-------------------------------------------------------------------------+
| http://www.cacti.net/ |
+-------------------------------------------------------------------------+
*/
/* 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 = "123456";
$database_port = "3306";
$database_ssl = false;
/*
Edit this to point to the default URL of your Cacti install
ex: if your cacti install as at http://serverip/cacti/ this
would be set to /cacti/
*/
//$url_path = "/cacti/";
/* Default session name - Session name must contain alpha characters */
//$cacti_session_name = "Cacti";
?>
[root@rhel64 ~]# setenforce 0
[root@rhel64 ~]# crontab -e
*/5 * * * * /usr/bin/php /var/www/html/cacti/poller.php >>/tmp/cacti_rrdtool.log 2>&1
http://192.168.1219.129/cacti/
一直點擊next下去即可,使用者名稱和密碼預設是admin.admin,第一次登陸需要修改密碼。
定義監控哪些裝置:
控制面版-->建立裝置-->定義裝置-->為裝置產生映像-->在映像樹中添加新裝置
console-->Devices-->add(左上方)-->define devices-->Create Graphs for this Host-->create
在被監控客戶機上要安裝net-snmp,41行那裡要填寫監控端的IP地址。
[root@rhel64 ~]# yum -y install net-snmp
[root@rhel64 ~]# vim /etc/snmp/snmpd.conf
62 access notConfigGroup "" any noauth exact all none none
41 com2sec notConfigUser 192.168.1219.129 public
85 view all included .1 80
[root@rhel64 ~]# service snmpd start
待續...
歡迎大家訪問我的個人網站 萌萌的IT人