版本資訊
版本 | |
---|---|
OS | Ubuntu 16.04 LTS |
cacti | 0.8.8f |
PHP | 7 |
安裝步驟
- 安裝apache並設定開機自動啟用服務
sudo apt install apache2 -y sudo systemctl stop apache2.service sudo systemctl start apache2.service sudo systemctl enable apache2.service
- 安裝mariadb並設定開機自動啟用服務
sudo apt-get install mariadb-server mariadb-client -y sudo systemctl stop mysql.service sudo systemctl start mysql.service sudo systemctl enable mysql.service
- 確認mysql正常,確認正常即可輸入exit跳出
sudo mysql -u root -p
- 安裝PHP儲存庫
PS: Ubuntu 16.04 Xenial End of Standard Support 無法使用高於php7.0的版本sudo apt-get install software-properties-common sudo add-apt-repository ppa:ondrej/php sudo apt-get update
- 安裝PHP以及相依性套件
sudo apt install php7.0 libapache2-mod-php php7.0-common php7.0-mysql php7.0-gmp php7.0-curl php7.0-intl php7.0-mbstring php7.0-xmlrpc php7.0-gd php7.0-bcmath php7.0-snmp php7.0-xml php7.0-cli php7.0-zip dbconfig-mysql -y
- 備份設定檔並更改設定
更改檔案內的內容為下sudo cp /etc/php/7.0/apache2/php.ini /etc/php/7.0/apache2/php_backup.ini sudo vim /etc/php/7.0/apache2/php.ini
PS. 可以在vim底下使用/進行向下搜尋file_uploads = On allow_url_fopen = On short_open_tag = On memory_limit = 256M upload_max_filesize = 100M max_execution_time = 360 date.timezone = Asia/Taipei
- 重啟apache並修改phyinfo進行確認
新增以下資訊sudo systemctl restart apache2.service sudo vim /var/www/html/phpinfo.php
打開瀏覽器輸入 http://localhost/phpinfo.php 確認運作正常<?php phpinfo( ); ?>
- 設定mysql資訊(建立資料庫以及使用者)
sudo mysql -u root -p CREATE DATABASE cacti DEFAULT CHARACTER SET utf8; CREATE USER 'cactiuser'@'localhost' IDENTIFIED BY '<new_password>'; GRANT ALL ON cacti.* TO 'cactiuser'@'localhost' IDENTIFIED BY '<new_password>' WITH GRANT OPTION; GRANT SELECT ON `mysql`.`time_zone_name` TO 'cactiuser'@'localhost'; FLUSH PRIVILEGES; EXIT;
- 安裝cacti以及相依性套件
PS. 安裝前請確認Ubuntu本身的時間軸是否符合時區,不然之後畫出來的圖表時間軸會異常
選項 dbconfig-common 選擇 yessudo apt-get install cacti cacti-spine snmp snmpd snmp-mibs-downloader rrdtool -y
輸入mysql的密碼,注意這邊輸入的密碼在之後設定中會看到
再次確認密碼
選擇的Web server前面安裝的是apache,所以選擇apache
- 更改設定檔cacti config.php snmpd.conf
更改為以下內容 (password會是安裝前面cacti時輸入的password)sudo vim /usr/share/cacti/site/include/config.php
更改snmpd.conf$database_type = 'mysqli'; # 這項維持使用mysqli即可 $database_default = 'cacti'; $database_hostname = 'localhost'; $database_username = 'cacti'; $database_password = 'cacti'; $database_port = '3306'; # 主要是這項需要輸入 $database_ssl = false;
更改為以下內容,方便之後測試時可以使用localhost進行測試sudo cp /etc/snmp/snmpd.conf /etc/snmpd_backup.conf sudo vim /etc/snmp/snmpd.conf
#view systemonly included .1.3.6.1.2.1.1 #view systemonly included .1.3.6.1.2.1.25.1 view systemonly included .1
- 開啟web (http://localhost/cacti)進行確認
安裝順利地會依序看到以下
選擇 Next
選擇 Next
確認無異常訊息,click Finish - 登入cacti並更改密碼
登入會立即要求更改密碼,預設username以及password都是admin
修正異常設定
Technical Support異常顯示
在 Console -> Utilities -> Technical Support 內會發現因為setting內沒法設定我們安裝的rddtool版本1.5版,所以有報錯(但不影響使用)。
修正方式更改 utilities.php 以及 global_arrays.php
cd /usr/share/cacti/site
sudo vim utilities.php
將內容從
if (sizeof($out_array) > 0) {
if (preg_match("/^RRDtool 1\.4/", $out_array[0])) {
$rrdtool_version = "rrd-1.4.x";
}else if (preg_match("/^RRDtool 1\.3\./", $out_array[0])) {
$rrdtool_version = "rrd-1.3.x";
}else if (preg_match("/^RRDtool 1\.2\./", $out_array[0])) {
$rrdtool_version = "rrd-1.2.x";
}else if (preg_match("/^RRDtool 1\.0\./", $out_array[0])) {
$rrdtool_version = "rrd-1.0.x";
}
}
修改為
if (sizeof($out_array) > 0) {
if (preg_match("/^RRDtool 1\.5/", $out_array[0])){
$rrdtool_version = "rrd-1.5.x";
}else if (preg_match("/^RRDtool 1\.4/", $out_array[0])) {
$rrdtool_version = "rrd-1.4.x";
}else if (preg_match("/^RRDtool 1\.3\./", $out_array[0])) {
$rrdtool_version = "rrd-1.3.x";
}else if (preg_match("/^RRDtool 1\.2\./", $out_array[0])) {
$rrdtool_version = "rrd-1.2.x";
}else if (preg_match("/^RRDtool 1\.0\./", $out_array[0])) {
$rrdtool_version = "rrd-1.0.x";
}
}
sudo vim include/global_arrays.php
$rrdtool_versions = array(
"rrd-1.0.x" => "RRDTool 1.0.x",
"rrd-1.2.x" => "RRDTool 1.2.x",
"rrd-1.3.x" => "RRDTool 1.3.x",
"rrd-1.4.x" => "RRDTool 1.4.x");
修改為
$rrdtool_versions = array(
"rrd-1.0.x" => "RRDTool 1.0.x",
"rrd-1.2.x" => "RRDTool 1.2.x",
"rrd-1.3.x" => "RRDTool 1.3.x",
"rrd-1.4.x" => "RRDTool 1.4.x",
"rrd-1.5.x" => "RRDTool 1.5.x");
圖表無法使用zoom
圖表無法通過滑鼠拖拉至指定時間軸
更改graph_image.php ,方式如下
cd /usr/share/cacti/site/
sudo vim graph_image.php
更改內容
/* override: graph start time (unix time) */
if (!empty($_GET["graph_start"]) && $_GET["graph_start"] < 2600000000) {
$graph_data_array["graph_start"] = $_GET["graph_start"];
}
/* override: graph end time (unix time) */
if (!empty($_GET["graph_end"]) && $_GET["graph_end"] < 2600000000) {
$graph_data_array["graph_end"] = $_GET["graph_end"];
}
sudo vim graph_xport.php
更改內容如下
/* override: graph start time (unix time) */
if (!empty($_GET["graph_start"]) && is_numeric($_GET["graph_start"]) && $_GET["graph_start"] < 2600000000) {
$graph_data_array["graph_start"] = get_request_var("graph_start");
}
/* override: graph end time (unix time) */
if (!empty($_GET["graph_end"]) && is_numeric($_GET["graph_end"]) && $_GET["graph_end"] < 2600000000) {
$graph_data_array["graph_end"] = get_request_var("graph_end");
}
更改完成重啟apache
sudo service apache2 reload
重要檔案地點
安裝方式不同地點可能會有所差異
- /var/log/cacti/poller-error.log
-> poller的錯誤訊息 - /var/log/cacti/cacti.log
-> cacti系統log - /usr/share/cacti/
-> cacti程式資源位置 - /var/lib/cacti/rra/
-> rra檔
Reference:
- ubuntu 16 cacti spine setup (0.8.8f) for medium to large deployment
- Install Cacti Systems Monitoring Platform on Ubuntu 16.04 | 18.04 | 18.10
- cacti package in Ubuntu
- cacti.db import: ERROR 1071 (42000) at line 2560: Specified key was too long; max key length is 767 bytes
- 修改現成Cacti圖表範本 自訂網管數據監看不求人
- CentOS 7 安裝 Cacti Server