…生活與工作…個人的生活雜記….

Cacti on QNAP 4.2.3

Cacti是一個完整的網絡圖形解決方案,旨在利用RRDTool的數據存儲和圖形功能。

Cacti提供了一個快速輪詢器,高級圖表模板,多種數據採集方法和用戶管理功能。

所有這一切都被包裝在一個直觀的,易於使用的界面中,對於LAN大小的安裝以及有數千個設備的複雜網絡來說是非常有意義的。

安裝相關套件:

opkg install libnetsnmp
opkg install snmp-utils snmp-mibs
opkg install ttdtool

啟動SNMP

控制台 >網路服務 >SNMP

執行測試

snmpwalk -v 2c -c public localhost

如果順利的話就能看到如同下面的資訊

SNMPv2-MIB::sysDescr.0 = STRING: Linux TS-469 4.2.3
SNMPv2-MIB::sysORID.1 = OID: SNMP-MPD-MIB::snmpMPDMIBObjects.3.1.1
SNMPv2-MIB::sysORID.2 = OID: SNMP-USER-BASED-SM-MIB::usmMIBCompliance
SNMPv2-MIB::sysORID.3 = OID: SNMP-FRAMEWORK-MIB::snmpFrameworkMIBCompliance
SNMPv2-MIB::sysORID.4 = OID: SNMPv2-MIB::snmpMIB
SNMPv2-MIB::sysORID.5 = OID: TCP-MIB::tcpMIB
SNMPv2-MIB::sysORID.6 = OID: IP-MIB::ip
SNMPv2-MIB::sysORID.7 = OID: UDP-MIB::udpMIB
SNMPv2-MIB::sysORID.8 = OID: SNMP-VIEW-BASED-ACM-MIB::vacmBasicGroup
SNMPv2-MIB::sysORDescr.1 = STRING: The MIB for Message Processing and Dispatching.
SNMPv2-MIB::sysORDescr.2 = STRING: The MIB for Message Processing and Dispatching.
SNMPv2-MIB::sysORDescr.3 = STRING: The SNMP Management Architecture MIB.
SNMPv2-MIB::sysORDescr.4 = STRING: The MIB module for SNMPv2 entities
SNMPv2-MIB::sysORDescr.5 = STRING: The MIB module for managing TCP implementations
SNMPv2-MIB::sysORDescr.6 = STRING: The MIB module for managing IP and ICMP implementations
SNMPv2-MIB::sysORDescr.7 = STRING: The MIB module for managing UDP implementations
SNMPv2-MIB::sysORDescr.8 = STRING: View-based Access Control Model for SNMP.
SNMPv2-MIB::sysORUpTime.1 = Timeticks: (18) 0:00:00.18
SNMPv2-MIB::sysORUpTime.2 = Timeticks: (18) 0:00:00.18
SNMPv2-MIB::sysORUpTime.3 = Timeticks: (18) 0:00:00.18
SNMPv2-MIB::sysORUpTime.4 = Timeticks: (18) 0:00:00.18
SNMPv2-MIB::sysORUpTime.5 = Timeticks: (19) 0:00:00.19
SNMPv2-MIB::sysORUpTime.6 = Timeticks: (19) 0:00:00.19
SNMPv2-MIB::sysORUpTime.7 = Timeticks: (19) 0:00:00.19
SNMPv2-MIB::sysORUpTime.8 = Timeticks: (19) 0:00:00.19
IF-MIB::ifIndex.1 = INTEGER: 1
IF-MIB::ifIndex.2 = INTEGER: 2
IF-MIB::ifIndex.3 = INTEGER: 3
IF-MIB::ifIndex.4 = INTEGER: 4
IF-MIB::ifDescr.1 = STRING: lo
IF-MIB::ifDescr.2 = STRING: eth1
IF-MIB::ifDescr.3 = STRING: eth0
IF-MIB::ifDescr.4 = STRING: bond0
IF-MIB::ifType.1 = INTEGER: softwareLoopback(24)
IF-MIB::ifType.2 = INTEGER: ethernetCsmacd(6)
IF-MIB::ifType.3 = INTEGER: ethernetCsmacd(6)
IF-MIB::ifType.4 = INTEGER: ethernetCsmacd(6)
IF-MIB::ifMtu.1 = INTEGER: 16436
IF-MIB::ifMtu.2 = INTEGER: 1500
IF-MIB::ifMtu.3 = INTEGER: 1500
IF-MIB::ifMtu.4 = INTEGER: 1500
IF-MIB::ifSpeed.1 = Gauge32: 10000000
IF-MIB::ifSpeed.2 = Gauge32: 100000000
IF-MIB::ifSpeed.3 = Gauge32: 1000000000
IF-MIB::ifSpeed.4 = Gauge32: 0
IF-MIB::ifPhysAddress.1 = STRING:

增加使用者與群組

addgroup cactigrp
adduser -h /usr/local/www/cacti -s /bin/false -G cactigrp cacti
chown -R cacti /usr/local/www/cacti/rra/ /usr/local/www/cacti/log/

建議使用系統自帶的

控制台 >權限設定 >使用者群組 設定cactigrp
控制台 >權限設定 >使用者 設定cacti

下載CACTI

前往https://www.cacti.net下載最新版本的CACTI(目前是1.1.20版)

wget --no-check-certificate http://www.cacti.net/downloads/cacti-1.1.20.tar.gz

解壓縮並移至適當位置

tar zxvf cacti-1.1.20.tar.gz
mv cacti-1.1.20 cacti
mv cacti/* /share/homes/cacti -f
#建立網頁連結
ln -s /share/homes/cacti /var/www/cacti

下載Spine

前往https://www.cacti.net下載最新版本的Spine(目前是1.1.20版)

wget --no-check-certificate http://www.cacti.net/downloads/spine/cacti-spine-1.1.20.tar.gz

解壓縮並編譯

tar zxvf cacti-spine-1.1.20.tar.gz
cd cacti-spine-1.1.20

啟動SQL伺服器

控制台 >應用服務 >SQL伺服器 >啟動SQL伺服器

連線MySQL(用Shell或是phpMyAdmin皆可)

建立資料庫 cacti

mysqladmin --user=root -p create cacti

初始化資料庫

mysql cacti < cacti.sql

建立cacti專用SQL帳號

mysql -u root -p mysql
GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'somepassword';
flush privileges;

修正TimeZone問題

mysql -u root -p mysql
use mysql;
GRANT SELECT ON mysql.time_zone_name TO cactiuser@localhost;
flush privileges;

匯入Zoneinfo

opkg install mariadb-server
/share/CACHEDEV1_DATA/.qpkg/Entware-3x/bin/mysql_tzinfo_to_sql /usr/share/zoneinfo | /mnt/ext/opt/mariadb/bin/mysql -u root -p mysql
opkg remove mariadb-server

編輯global_constants.php

vi /share/CACHEDEV1_DATA/homes/cacti/include/global_constants.php

增加

date_default_timezone_set('Asia/Taipei');

編輯config.php

/* when the cacti server is a remote poller, then these entries point to
* the main cacti server. otherwise, these variables have no use.
* and must remain commented out. */

$rdatabase_type = 'mysql'; 
$rdatabase_default = 'cacti';
$rdatabase_hostname = 'localhost';
$rdatabase_username = 'cactiuser';
$rdatabase_password = 'cactiuser';
$rdatabase_port = '3306';
$rdatabase_ssl = false;

/* the poller_id of this system. set to '1' for the main cacti
* web server. otherwise, you this value should be the poller_id
* for the remote poller. */

$poller_id = 1;

/* set the $url_path 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/';

加入crontab

*/5 * * * * cacti /mnt/ext/opt/apache/bin/php /share/homes/cacti/poller.php > /dev/null 2>&1

初始設定CACTI

登入網址 http://ip/cacti/install/


Accept GPL License Agreement 打勾並按NEXT


系統會檢查相關安裝程序,沒問題就可以下一步。

修正相關程式路徑

RRDtool Path : /share/CACHEDEV1_DATA/.qpkg/Entware-3x/bin/rrdtool
PHP Path : /mnt/ext/opt/apache/bin/php
snmpwalk Path : /share/CACHEDEV1_DATA/.qpkg/Entware-3x/bin/snmpwalk
snmpget Path : /share/CACHEDEV1_DATA/.qpkg/Entware-3x/bin/snmpget
snmpbulkwalk Path : /share/CACHEDEV1_DATA/.qpkg/Entware-3x/bin/snmpbulkwalk
snmpgetnext Path : /share/CACHEDEV1_DATA/.qpkg/Entware-3x/bin/snmpgetnext
snmptrap Path : /share/CACHEDEV1_DATA/.qpkg/Entware-3x/bin/snmptrap
Spine Path : spine
Cacti Log Path: /share/CACHEDEV1_DATA/homes/cacti/log/cacti.log

改變檔案權限

chmod 777 /share/Web/cacti/resource/ -R
chmod 777 /share/Web/cacti/scripts/ -R
chmod 777 /share/Web/cacti/log/ -R
chmod 777 /share/Web/cacti/cache/ -R

下載Template

Generic SNMP Device
Local Linux Machine
Net-SNMP Device

完成!


預設密碼是 admin/admin
於第一次登入時會先要求變更密碼