天天看點

linux配置Cacti

安裝并配置以Cacti套件為主的各種工具包括AMP平台、SNMP資料采集工具、RRDTool工具、安裝net-snmp軟體包

安裝依賴軟體

AMP平台httpd、mysql、mysql-server、mysql-connector-odbc

       php、php-mysql、php-common、php-pdo

SNMP資料采集工具

lm_sensors、net-snmp、net-snmp-utils 

RRDTool引擎

下載下傳軟體包:rrdtool-1.2.27.tar.gz

配置:./configure --prefix=/usr/local

編譯安裝: make && make install

rrdtool的編譯安裝可能需要較長時間,建議另開一個終端進行編譯

php-mysql軟體包用于支援連接配接MySQL資料庫

[root@localhost ~]# cd /var/www/html

[root@localhost html]# tar zxvf /dlpkgs/cacti-0.8.7b-cn-utf8.tar.gz解壓檔案包至網頁目錄,并調整權限

[root@localhost html]# mv cacti-0.8.7b-cn-utf8 cacti

[root@localhost html]# useradd cactiuser

[root@localhost html]# chown -R cactiuser.cactiuser cacti/rra/ cacti/log

[root@localhost html]# mysql -u root -p #建立監測資料庫

mysql> create database cactidb default character set utf8;

mysql> grant all on cactidb.* to cactiuser@localhost identified by '1234';

mysql> quit

[root@localhost html]# mysql -u cactiuser -p cactidb < cacti/cacti.sql

[root@localhost ~]# vi /var/www/html/cacti/include/config.php #修改cacti目錄中的include/config.php配置檔案

<?php

$database_type = "mysql";

$database_default = "cactidb";

$database_hostname = "localhost";

$database_username = "cactiuser";

$database_password = "1234";

$database_port = "3306";

$config['url_path'] = "/";

?>

[root@localhost ~]# vi /etc/httpd/conf/httpd.conf #調整httpd服務的配置

Listen 80

DocumentRoot "/var/www/html/cacti"

<Directory "/var/www/html/cacti">

  Options None

  AllowOverride None

  Order allow,deny

  Allow from all

</Directory>

DirectoryIndex index.php index.html

AddDefaultCharset utf-8 #确認網頁目錄及字元集設定,然後重新開機httpd服務

确認httpd服務的字元集支援為” AddDefaultCharset utf-8“,否則有可能導緻通路Cacti界面時網頁顯示為空白

1.登入Cacti管理平台(使用者名及密碼都是admin)

2.設定RRDtool工具的版本和中文字型路徑

/usr/share/fonts/zh_CN/TrueType/zysong.ttf

3.添加被監測的裝置或主機

指定被監測的主機位址等連接配接參數

指定需要監測的具體項目(CPU占用、記憶體使用等)

4.生成監測圖像

根據設定的監測項目建立圖像

将圖像添加到監測樹以友善檢視

5.添加cron計劃任務,以定期采集資料

以cactiuser使用者身份采集資料

執行指令:php /var/www/html/cacti/poller.php

通過crontab設定每5分鐘采集一次監測資料

6.檢視圖形化監測結果

按日、周、月、年等分别檢視監測圖像曲線

可以指定時間進行查詢

本文轉自 周小玉 51CTO部落格,原文連結:http://blog.51cto.com/maguangjie/1869990,如需轉載請自行聯系原作者