CentOS 5.5 下開源的系統監控工具 cacti 的安裝

來源:互聯網
上載者:User

    cacti(英文意思:仙人掌)是一套開源的網路監控工具,可以監控主機的狀態和負載情況,添加相應的模板後,可以用來監控 Apache、MySQL 等伺服器的運行狀態。

    cacti 的官方網站:http://www.cacti.net/

    cacti 要求運行在 PHP、MySQL、Apache 環境。PHP 是它的資料擷取指令碼執行環境。MySQL 用來儲存資料。Apache 用來提供它的前端配置和監控介面。安裝時還會要求一些組件,比如 php-snmp,php-xml,php-ldap,rrdtool 等,這些軟體包在安裝 LAMP 環境的時候有可能也裝了一部分。即便沒有安裝,在使用 yum 命令的時候也會安裝一些依賴的組件。

    請記得給 MySQL 的 root 帳戶設定一個密碼,以保護資料庫的安全。可以使用如下的命令來更改root的密碼:
    mysqladmin -user=root password somepassword

    cacti安裝配置

    1.使用如下命令來安裝 cacti,這個會自動安裝需要的組件。
    # yum install cacti

    安裝的版本是 cacti-0.8.7g。
    還會建立使用者 cacti,使用者組 cacti。

    注意:本人的 cacti 是從 rpmforge 的 YUM 安裝源安裝的,你的機器可能需要首先配置這個安裝源。有關配置 rpmforge 安裝源的資料,請訪問 http://blog.why100000.com 裡博主網眼翻譯的一篇文章。

    2.建立 MySQL 資料庫 cacti
    # mysqladmin -uroot -pxxxxxx create cacti

    或:
    # mysql -uroot -p
    輸入密碼進入 MySQL 管理介面,再運行建立資料庫命令:
    > create database cacti;

    3.匯入預設的 cacti 資料庫的資料

    如果使用yum預設安裝,建立資料的指令碼預設在 /var/www/cacti-0.8.7g/cacti.sql。
    # cd /var/www/cacti-0.8.7g/

    # mysql -uroot -pxxxxxx cacti < cacti.sql

    4.編輯cacti配置,做資料連線設定

    # gedit /var/www/cacti-0.8.7g/include/config.php

    這裡有cacti串連使用的資料庫類型,使用者名稱,密碼資訊

    /* make sure these values refect your actual database/host/user/password */
    $database_type = "mysql";
    $database_default = "cacti";
    $database_hostname = "localhost";
    $database_username = "cactiuser";
    $database_password = "cactiuser";
    $database_port = "3306";
    /* Default session name - Session name must contain alpha characters */
    #$cacti_session_name = "Cacti";

    上述配置按照自己的環境設定。

    5.配置自動作業時間編輯 crontab。

    [root@tigertall log]# crontab -e

    增加如下內容,

    */5 * * * * php /var/www/cacti/poller.php > /dev/null 2>&1

    以上配置的意思是,每隔5分鐘,執行一次 PHP 指令碼 poller.php,統計和儲存一次資料。

    6.配置 Apache 的虛擬路徑

    在 /etc/httpd/conf/httpd.conf 檔案末尾加:

    Alias /cacti /var/www/cacti/
    <Directory "/var/www/cacti">
      Options Indexes Includes FollowSymLinks
      AllowOverride None
      Allow from all
      Order allow,deny
    </Directory>

    7.登入伺服器

    在安裝 cacti 的機器上,用瀏覽器登入 http://localhost/cacti。

    第一次運行,會進入 Install 介面,出現頁面:Cacti Installation Guide。
    點擊右下角的 Next 連結進入下一頁。

    出現頁面:Please select the type of installation
    選擇 “New Install”,再點擊右下角的 Next 連結。

    然後進入參數配置頁面:

    Make sure all of these values are correct before continuing.

    [FOUND] RRDTool Binary Path: The path to the rrdtool binary.
    /usr/bin/rrdtool
    [OK: FILE FOUND]

    [FOUND] PHP Binary Path: The path to your PHP binary file (may require a php recompile to get this file).
    /usr/bin/php
    [OK: FILE FOUND]

    [FOUND] snmpwalk Binary Path: The path to your snmpwalk binary.
    /usr/bin/snmpwalk
    [OK: FILE FOUND]

    [FOUND] snmpget Binary Path: The path to your snmpget binary.
    /usr/bin/snmpget
    [OK: FILE FOUND]

    [FOUND] snmpbulkwalk Binary Path: The path to your snmpbulkwalk binary.
    /usr/bin/snmpbulkwalk
    [OK: FILE FOUND]

    [FOUND] snmpgetnext Binary Path: The path to your snmpgetnext binary.
    /usr/bin/snmpgetnext
    [OK: FILE FOUND]

    [FOUND] Cacti Log File Path: The path to your Cacti log file.
    /var/www/cacti/log/cacti.log
    [OK: FILE FOUND]

    SNMP Utility Version: The type of SNMP you have installed. Required if you are using SNMP v2c or don't have embedded SNMP support in PHP.
    [NET-SNMP 5.x]

    RRDTool Utility Version: The version of RRDTool that you have installed.
    RRDTool 1.4.x

    NOTE: Once you click "Finish", all of your settings will be saved and your database will be upgraded if this is an upgrade. You can change any of the settings on this screen at a later time by going to "Cacti Settings" from within Cacti.

    點擊“finish”完成安裝,進入登入頁面。

    8.初始使用者和密碼均為 admin,輸入後登入。然後立即要求更改新密碼,更改後,就進入 cacti 的管理和檢測介面了。

    初始登入時,使用者名稱和密碼為admin,登入後,會要求立即切換密碼。

    儲存新密碼後,就進入了 cacti 的管理和檢測介面。

    也可以在同一網段的機器上運行瀏覽器登入。

    作者:張慶(網眼) 西安 PHP 教育培訓中心 2010-9-3
    來自“網眼視界”:http://blog.why100000.com
    作者微博:http://t.qq.com/zhangking
    “十萬個為什麼”電腦學習網:http://www.why100000.com

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.