Jamyy's Weblog

在 CentOS 7 安裝 Cacti

by Jamyy on 十月.31, 2015, under Linux

環境: CentOS 7, httpd, mariadb

安裝需求套件

# yum install httpd mariadb-server php php-mysql php-pear php-gd php-mbstring net-snmp net-snmp-utils rrdtool
# yum install epel-release
# yum install cacti

建立資料庫

# systemctl enable mariadb
# systemctl start mariadb
# mysql_secure_installation
# mysql -u root -p -A mysql
MariaDB > create database cacti;
MariaDB > grant all privileges on cacti.* to cacti@localhost identified by 'cactipassword';
MariaDB > flush privileges;
MariaDB > exit
# mysql -u root -p -A cacti < /usr/share/doc/cacti-0.8.8b/cacti.sql

設定 httpd

# vi /etc/httpd/conf.d/cacti.conf

<Directory /usr/share/cacti/>
        <IfModule mod_authz_core.c>
                # httpd 2.4
                Require host localhost
                Require ip 192.168.1.0/24
        </IfModule>
        <IfModule !mod_authz_core.c>
                # httpd 2.2
                Order deny,allow
                Deny from all
                Allow from localhost
        </IfModule>
</Directory>

# vi /etc/cacti/db.php

$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "cactipassword";
$database_port = "3306";
$database_ssl = false;

# vi /etc/php.ini

date.timezone = Asia/Taipei

# sed -i 's/^/#/g' /etc/httpd/conf.d/welcome.conf
# systemctl enable httpd
# systemctl start httpd

進行 web 初始化作業

開啟瀏覽器, 連入 http://linux.host.ip/cacti/install → New Installation
完成後即可登入, 預設帳密皆為 admin

最終步驟

# vi /etc/cron.d/cacti

# 取消註解
*/5 * * * *	cacti	/usr/bin/php /usr/share/cacti/poller.php > /dev/null 2>&1

# systemctl enable snmpd
# systemctl start snmpd



新增 Device: 以 Cisco Switch 為例 (SNMPv3)

Step 1. 新增 Device

Management: Devices → Add

General Host Options
  Description: xxx
  Hostname: xxx
  Host Template: Generic SNMP-enabled Host

SNMP Options
  SNMP Version: Version 3
  SNMP Username (v3): xxx
  SNMP Password (v3): xxx
  SNMP Privacy Passphrase (v3): xxx

Associated Graph Templates
  Graph Template Name
    Add Graph Template: Cisco - CPU Usage → Add

Step 2. 新增 Graphs

Create Graphs for this Host

Graph Templates
  Create: Cisco - CPU Usage (勾選)

Data Query
  勾選需要繪製圖表的埠口



Ref:



:,