cacti文档
cacti文檔
簡介: cacti是用php語言實現的一個軟件,它的主要功能是用snmp服務獲取數據,然后用rrdtool(Round Robin Database,環形數據庫),儲存和更新數據,當用戶需要查看數據的時候用rrdtool生成圖表呈現給用戶。 Mysql配合PHP程序存儲一些變量數據并對變量數據進行調用,如:主機名、主機ip、snmp團體名、端口號、模板信息等變量。 snmp抓到數據不是存儲在mysql中,而是存在rrdtool生成的rrd文件中(在cacti根目錄的rra文件夾下)。rrdtool對數據的更新和存儲就是對rrd文件的處理,rrd文件是大小固定的檔案文件(Round Robin Archive),它能夠存儲的數據筆數在創建時就已經定義。
cacti架構(cacti的英文意思是仙人掌) ?
Cacti是一個c/s架構的,他主要監網絡接口流量,監控CPU的負載,內存使用,磁盤空間等,還監控服務器中的WEB、mail、ftp、數據庫等,當然還能監控網絡設備性能,配置文件,路由數,以及機房溫度,電壓,濕度,風扇,電源,等運行狀態。 安裝步驟: 一.需要安裝的包: yum install ?net-snmp net-snmp-utils net-snmp-devel net-snmp-libs php-mysql mysql-devel rrdtool-php php-snmp lib-tool autoconf ? automake make libxml2-devel ?php-gd php-xml net-snmp-utils httpd (呵呵,有點多啊,但是這總比在安裝時遇到蛋疼的依賴和報各種錯好得多)
二.配置snmp 參考文檔地址:http://www.cyberciti.biz/nixcraft/linux/docs/uniqlinuxfeatures/mrtg/ /etc/init.d/snmpd start? snmpwalk -v 1 -c public localhost IP-MIB::ipAdEntIfIndex #若沒有snmpwalk命令,則yum install net-snmp-utils Timeout: No Response from localhost ?#若輸出結果為此則對snmp進行配置 vim ?/etc/snmp/snmpd.conf Find line: com2sec notConfigUser ?default ? ? ? public替代為: com2sec local ? ? localhost ? ? ? ? ? public com2sec mynetwork 192.168.0.0/24 ? ? ?public
Find lines: ? group ? notConfigGroup v1 ? ? ? ? ? notConfigUser ? group ? notConfigGroup v2c ? ? ? ? ? notConfigUser Replace with: group MyRWGroup v1 ? ? ? ? local group MyRWGroup v2c ? ? ? ?local group MyRWGroup usm ? ? ? ?local group MyROGroup v1 ? ? ? ? mynetwork group MyROGroup v2c ? ? ? ?mynetwork group MyROGroup usm ? ? ? ?mynetwork
Find line: ?view ? ?systemview ? ? included ? ? ?system Replace with: view all ? ?included ?.1 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 80
Find line: ?access ?notConfigGroup "" ? ? ?any ? ? ? noauth ? ?exact ?systemview none none Replace with: access MyROGroup "" ? ? ?any ? ? ? noauth ? ?exact ?all ? ?none ? none access MyRWGroup "" ? ? ?any ? ? ? noauth ? ?exact ?all ? ?all ? ?none
/etc/init.d/snmpd reload ? ?
snmpwalk -v 1 -c public localhost IP-MIB::ipAdEntIfIndex 會得到如下結果: IP-MIB::ipAdEntIfIndex.127.0.0.1 = INTEGER: 1 IP-MIB::ipAdEntIfIndex.192.168.0.46 = INTEGER: 6
三.安裝cacti tar -zxf cacti-0.8.7h.tar.gz ?-C ?/var/www/html/cacti 1.配置mysql /etc/init.d/mysqld start shell>mysqladmin create cacti cd /var/www/html/cacti ? ? ? ?? shell>mysql cacti < cacti.sql ? #導入數據庫 2.創建用戶cactiuser shell>mysql -uroot -ppassword? mysql>grant all on cacti.* to cactiuser@localhost identified by "cacti"; mysql>flush privileges; ? 3.編輯include/config.php指定數據庫類型、名字、主機、用戶、和密碼 cd /var/www/html/cacti/include vim config.php $database_type = "mysql"; $database_default = "cacti"; $database_hostname = "localhost"; $database_username = "cactiuser"; $database_password = "cacti"; $database_port = "3306"; $database_ssl = false; 4.設置權限 chown -R cactiuser.cactiuser rra/ log/ 5.在/etc/crontab中添加一行 */5 ?* ?* ?* ?* ?cactiuser ?php ?/var/www/html/cacti/poller.php 6.用browser瀏覽 http://ip/cacti/ ?
登錄,默認用戶名和密碼均為admin ?
四.spine的安裝 Spine is a very fast poller engine, written in C. It is an optional replacement for cmd.php. If you decide to use it, you?will have to install it explicitely. It does not come with cacti itself. The easiest way is to install Spine using rpm or ports. You will find packages for Spine at the main cacti site or from?your distribution.To compile Spine, please download it to any location of your liking. Then, please issue from the downloaded directory?following commands
spine 是一個由C語言編寫的非常快的輪詢引擎。它是cmd.php的可選替代。使用需要安裝,cacti本身不附帶。cmd.php采集數據存在很大的延遲,執行效率很低。從添加設備到是被up,spine只需不到一分鐘,而cmd等的時間較長,超過10分鐘。當設備down后2分鐘之內spine可以發出alert,而cmd可能需要10分鐘以上。
shell>aclocal shell>libtoolize --force (glibtoolize --force on Max OS) shell>autoheader shell>autoconf shell>automake shell>./configure shell>make shell>make install
cd /usr/local/spine/etc cp -p spine.conf.dist spine.conf.dist vim spine.conf ?#根據實際情況配置spine DB_Host ? ? ? ? localhost DB_Database ? ? cacti DB_User ? ? ? ? cactiuser DB_Pass ? ? ? ? cacti ? ?? DB_Port ? ? ? ? 3306 DB_PreG ? ? ? ? 0 在瀏覽器中cacti界面 console--Settings--Paths 在Spine Poller File Path后填上“/usr/local/spine/bin/spine”,點擊保存
點擊上面的Poller選項 Poller Type后選擇spine
五.安裝插件管理補丁 0.8.8a版本及其以上不用安裝此補丁,解壓安裝包后已有plugins目錄 tar -zxf cacti-plugin-0.8.7h-PA-v3.0.tar.gz -C /var/www/html/cacti cd /var/www/html/cacti patch -p1 -N < cacti-plugin-0.8.7h-PA-v3.0.diff 會產生一個plugin目錄 mysql cacti < pa.sql #導入數據庫文件 在瀏覽器中操作 在左邊欄選擇User Management,勾選最下方的Plugin Management,點擊save 左邊欄的Plugin Management就能使用了 六.插件的安裝 #安裝settings tar -zxf settings-v0.71-1.tgz -C /var/www/html/cacti/plugins #安裝插件均解壓到這個目錄里 瀏覽器console界面,點擊Plugin Management,然后一次點擊安裝、激活插件 安裝monitor,thold過程和上面相同。 ?
七.添加監控設備 虛擬機中的cacti監控宿主機ip為:192.168.0.46 配置46的snmp,配置文件cacti服務器一樣,可以拷貝一份 然后開啟snmpd服務, 在cacti服務器上檢測能否取到數據, snmpwalk -v 1 -c public 192.168.0.46 IP-MIB::ipAdEntIfIndexIP-MIB::ipAdEntIfIndex.127.0.0.1 = INTEGER: 1 IP-MIB::ipAdEntIfIndex.192.168.0.46 = INTEGER: 6 若為如上結果,則能取到數據。 瀏覽器管理界面—console—Devices,點擊右上角Add ?
填入Description,Hostname;Host Template選擇ucd/net SNMP Host,其余默認 點擊create 上部出現 SNMP information則創建成功,點擊右邊的? Create Graphs for this Host ?
然后勾選所需要監控的系統信息及網卡,點create。這樣就完成了所指定設備統計圖的創建。 ?
點擊左邊欄的Graph Management即可瀏覽剛才所創建的圖表。 勾選需要顯示graphs的條目,在右下方chose an action:選擇 place on a tree(physical host)這樣就就能把該圖表類似快捷方式的樣子粘貼到Graphs,physical(被監控主機的描述)欄目中。 ?
?
轉載于:https://blog.51cto.com/kaixinbocai/943396
總結
- 上一篇: Delphi 2007体验!
- 下一篇: 微软编程题:寻找最小的k个值