iT邦幫忙

2

三分鐘學會安裝 LibreNMS SNMP Tools CentOS 7 (Apache)

三分鐘學會安裝 LibreNMS SNMP Tools CentOS 7 (Apache)

安裝前準備
CentOS 7 mini install 最小安裝就可以了
之後始用 Telnet 從 SSH 連入 CentOS

這邊的文件照做
要記得更改 Password
其他都複製貼上就可以了

LibreNMS 安裝文件說明
https://docs.librenms.org/Installation/Installation-CentOS-7-Apache/

簡單說明如下

CentOS 7 (Apache)

使用 root 如果不是 root 就要用 sudo

版本最低需求 PHP version is 7.1.3
安裝需要的套件
這些命令就點 Copy to clipboard
再貼到 Telnet console 的畫面執行就可以了
如圖
https://ithelp.ithome.com.tw/upload/images/20190704/20001416fljKnPXfA5.png

yum install epel-release

rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

yum install composer cronie fping git httpd ImageMagick jwhois mariadb mariadb-server mtr MySQL-python net-snmp net-snmp-utils nmap php72w php72w-cli php72w-common php72w-curl php72w-gd php72w-mbstring php72w-mysqlnd php72w-process php72w-snmp php72w-xml php72w-zip python-memcached rrdtool

新增 librenms 使用者

useradd librenms -d /opt/librenms -M -r
usermod -a -G librenms apache

下載 LibreNMS

cd /opt
git clone https://github.com/librenms/librenms.git

設定存取權限 Set permissions

chown -R librenms:librenms /opt/librenms
chmod 770 /opt/librenms
setfacl -d -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/
setfacl -R -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/

安裝 PHP 相關套件 Install PHP dependencies

su - librenms
./scripts/composer_wrapper.php install --no-dev
exit

資料庫 DB Server
設定資料庫 Configure MySQL

systemctl start mariadb
mysql -u root

備註 NOTE: Please change the 'password' below to something secure.
這邊的 password 可以更改成你要的密碼,當然你也可以直接用他當 password
在 WebUI install setup 步ˋ驟中如果有問到 DB 密碼
那麼就是使用你設定的這組密碼

CREATE DATABASE librenms CHARACTER SET utf8 COLLATE utf8_unicode_ci;
CREATE USER 'librenms'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON librenms.* TO 'librenms'@'localhost';
FLUSH PRIVILEGES;
exit

vi /etc/my.cnf

當還在mysql步驟時新增 Within the [mysqld] section please add:

innodb_file_per_table=1
lower_case_table_names=0

systemctl enable mariadb
systemctl restart mariadb

網頁伺服器 Web Server
設定 PHP Configure PHP

Ensure date.timezone is set in php.ini to your preferred time zone. See http://php.net/manual/en/timezones.php for a list of supported timezones. Valid examples are: "America/New_York", "Australia/Brisbane", "Etc/UTC".
php.ini 要設定時區

vi /etc/php.ini

下命令 / 搜尋 timezone = "Asia/Taipei" 我是設定台灣

設定 Apache Configure Apache

使用 vi 產生一個新的檔案 librenms.conf, Create the librenms.conf:

vi /etc/httpd/conf.d/librenms.conf

Add the following config, edit ServerName as required:
新增底下的內容
我還是最簡單的 copy paste
:wq 存檔離開

<VirtualHost *:80>
DocumentRoot /opt/librenms/html/
ServerName librenms.example.com

AllowEncodedSlashes NoDecode
<Directory "/opt/librenms/html/">
Require all granted
AllowOverride All
Options FollowSymLinks MultiViews

NOTE: If this is the only site you are hosting on this server (it should be :)) then you will need to disable the default site. rm -f /etc/httpd/conf.d/welcome.conf
提醒:如果你的Defualt 網頁有 welcome.conf 檔
你要下 rm -f /etc/httpd/conf.d/welcome.conf 刪除該檔

systemctl enable httpd
systemctl restart httpd

設定 SELinux

安裝管理 SELinux 工具 Install the policy tool for SELinux:

yum install policycoreutils-python

設定 LibreNMS 所需要的項目 Configure the contexts needed by LibreNMS:

semanage fcontext -a -t httpd_sys_content_t '/opt/librenms/logs(/.)?'
semanage fcontext -a -t httpd_sys_rw_content_t '/opt/librenms/logs(/.
)?'
restorecon -RFvv /opt/librenms/logs/
semanage fcontext -a -t httpd_sys_content_t '/opt/librenms/rrd(/.)?'
semanage fcontext -a -t httpd_sys_rw_content_t '/opt/librenms/rrd(/.
)?'
restorecon -RFvv /opt/librenms/rrd/
semanage fcontext -a -t httpd_sys_content_t '/opt/librenms/storage(/.)?'
semanage fcontext -a -t httpd_sys_rw_content_t '/opt/librenms/storage(/.
)?'
restorecon -RFvv /opt/librenms/storage/
semanage fcontext -a -t httpd_sys_content_t '/opt/librenms/bootstrap/cache(/.)?'
semanage fcontext -a -t httpd_sys_rw_content_t '/opt/librenms/bootstrap/cache(/.
)?'
restorecon -RFvv /opt/librenms/bootstrap/cache/
setsebool -P httpd_can_sendmail=1

設定 Allow fping

Create the file http_fping.tt with the following contents. You can create this file anywhere, as it is a throw-away file. The last step in this install procedure will install the module in the proper location.
新增 http_fping.tt 一個檔案
方法和 新增 librenms.conf 一樣
底下內容 copy paste 到 該檔內

module http_fping 1.0;

require {
type httpd_t;
class capability net_raw;
class rawip_socket { getopt create setopt write read };
}

#============= httpd_t ==============
allow httpd_t self:capability net_raw;
allow httpd_t self:rawip_socket { getopt create setopt write read };

檔案產生後執行底下命令 Then run these commands

checkmodule -M -m -o http_fping.mod http_fping.tt
semodule_package -o http_fping.pp -m http_fping.mod
semodule -i http_fping.pp

設定這些可以通過防火牆 Allow access through firewall

firewall-cmd --zone public --add-service http
firewall-cmd --permanent --zone public --add-service http
firewall-cmd --zone public --add-service https
firewall-cmd --permanent --zone public --add-service https

設定snmpd,Configure snmpd

拷貝範本過去 Copy the example snmpd.conf from the LibreNMS install.

cp /opt/librenms/snmpd.conf.example /etc/snmp/snmpd.conf

vi /etc/snmp/snmpd.conf

Edit the text which says RANDOMSTRINGGOESHERE and set your own community string.
設定 community string

curl -o /usr/bin/distro https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/distro
chmod +x /usr/bin/distro
systemctl enable snmpd
systemctl restart snmpd

克隆(拷貝,覆製)工作 Cron job

cp /opt/librenms/librenms.nonroot.cron /etc/cron.d/librenms

NOTE: Keep in mind that cron, by default, only uses a very limited set of environment variables. You may need to configure proxy variables for the cron invocation. Alternatively adding the proxy settings in config.php is possible too. The config.php file will be created in the upcoming steps. Review the following URL after you finished librenms install steps: https://docs.librenms.org/Support/Configuration/#proxy-support

Copy logrotate config

LibreNMS keeps logs in /opt/librenms/logs. Over time these can become large and be rotated out. To rotate out the old logs you can use the provided logrotate config file:

cp /opt/librenms/misc/librenms.logrotate /etc/logrotate.d/librenms

進入到網頁安裝 Web installer
記得你的主機 IP 吧
不記得就在 telnet console 輸入 ip a 查看自己的 CentOS IP

Now head to the web installer and follow the on-screen instructions.

http://librenms.example.com/install.php
這邊不是傻傻的 Copy 到你的瀏覽器
http://你的CentoS IP/
正常會自動跳到 install.php 那一頁
開始六個步驟填入相關設定
會要求你輸入剛剛的那個 db password
還有新增 WebUI 的管理帳號和密碼
Mail也要填
到第五步驟會跳出要求你產生一個 config.php 的檔

The web installer might prompt you to create a config.php file in your librenms install location manually, copying the content displayed on-screen to the file. If you have to do this, please remember to set the permissions on config.php after you copied the on-screen contents to the file. Run:

和新增前兩個檔的方式一樣
vi config.php
將 WebUI 上面的內容
覆製貼到該檔

chown librenms:librenms /opt/librenms/config.php

更改檔案權限

Final steps
好了,完成安裝了
已經可以開始新增 Device 了
如果測試有其他的 Error
就找相關的 Troubleshooting 處理即可

That's it! You now should be able to log in to http://librenms.example.com/. Please note that we have not covered HTTPS setup in this example, so your LibreNMS install is not secure by default. Please do not expose it to the public Internet unless you have configured HTTPS and taken appropriate web server hardening steps.
Add the first device

We now suggest that you add localhost as your first device from within the WebUI.
Troubleshooting

If you ever have issues with your install, run validate.php as root in the librenms directory:

在 Telnet console 下面執行

cd /opt/librenms
./validate.php

這邊的錯誤說明提示相當的清楚
照做就可以解決
常見的兩個問題
http://ns2.ublink.org/viewtopic.php?f=10&t=6369
http://ns2.ublink.org/viewtopic.php?f=10&t=6368

以上就是最簡單的 LibreNMS 安裝設定說明

LibreNMS 其他說明和簡報
可以參考 LibreNMS 繁體中文化 台灣作者 節省哥的工具箱 Jason Tools
http://blog.jason.tools/

常用 Command
cd /opt/librenms/
下面執行
./daily.sh
更新
./validate.php
檢查


0
就酷
iT邦新手 5 級 ‧ 2019-07-05 09:17:29

小的來拜神了!

你是 misol
專業喇賽老天使耶 XD

0
wlhfor1974
iT邦新手 5 級 ‧ 2019-07-05 14:27:47

小的來拜神了!

XD

小弟大概裝了3小時,終於裝起來,果然跟大神等級有差
看起來不錯用,感謝大神分享

有裝起來都 ok
文件 可能真的不到一分鐘就看完了

0
Anny
iT邦新手 5 級 ‧ 2019-07-05 17:27:44

終於安裝成功了,之前在SELinux那邊一直卡住

雖然安裝成功很多設備都能自動識別,但是Vigor2960跟3900似乎認不太出來

都是Linux的圖案,Port也有重複怪怪的@@這有解嗎?

看更多先前的回應...收起先前的回應...

貼一下畫面我看看

Anny iT邦新手 5 級‧ 2019-07-05 18:49:53 檢舉

https://ithelp.ithome.com.tw/upload/images/20190705/20092477LP6pxGH3Ul.png
https://ithelp.ithome.com.tw/upload/images/20190705/200924779xOKeOah0w.png
其他設備顯示都還正常,目前手頭設備只有Vigor跟NEC的識別有點怪怪的。

其他 mib 看是否正常
圖示應該是還好

圖示應該是沒抓錯
他的底層是 Linux

沒出現 Vigor 圖示表示 LibreNMS 目前還認不得這個型號

新的版本已經支援
感謝Jason哥提報修正
可以正確辨識出型出型號了

0
wlhfor1974
iT邦新手 5 級 ‧ 2019-07-05 18:56:16

大大有試New Device Group嗎?

https://ithelp.ithome.com.tw/upload/images/20190705/20036252a3hp4pQBpn.png
https://ithelp.ithome.com.tw/upload/images/20190705/20036252pZegdMsGS0.png

https://ithelp.ithome.com.tw/upload/images/20190705/20036252fyUjIgNOn4.png
https://ithelp.ithome.com.tw/upload/images/20190705/20036252VkoLMIHahh.png

看更多先前的回應...收起先前的回應...

要去看173行寫什麼,我在試試看我的

我應該知道問題在那,請將新增裝置群組時的畫面(已填入資料)貼上來我看看。

https://ithelp.ithome.com.tw/upload/images/20190707/20118848FmAQXJjYEE.png

Telnet CentOS Console
root 登入後 下 commnad

cd /opt/librenms/
./daily.sh

先做更新
更新完後做一次

./validate.php

檢查
出現
[FAIL] Some folders have incorrect file permissions, this may cause issues.
[FIX]:
sudo chown -R librenms:librenms /opt/librenms
sudo setfacl -d -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/
sudo chmod -R ug=rwX /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/
Files:
/opt/librenms/bootstrap/cache/packages.php

https://ithelp.ithome.com.tw/upload/images/20190708/20001416n0wtad1wE2.png
依上面敘述 直接 Telnet console 執行
sudo chown -R librenms:librenms /opt/librenms
sudo setfacl -d -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/
sudo chmod -R ug=rwX /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/

再做一次check
./validate.php
https://ithelp.ithome.com.tw/upload/images/20190708/20001416ljCfHVmMQF.png
通通 ok

Manager Groups
Device Groups
New Device Group

發現還是一樣
https://ithelp.ithome.com.tw/upload/images/20190708/20001416umlIzd2Tpr.png

cd /opt/librenms/logs/
vi libernms
發現
[2019-07-03 17:15:24] production.ERROR: Geocoding failed: Google Maps API key missing, set geoloc.api_key

節省哥出現了
這問題他一定可以解 ^^

TO 節省哥:
按New Device Group就出現錯誤了,所以沒新增裝置群組時的畫面

TO 門神大:
我也是看這篇做的..做完還是一樣,所以上來問看看大家的經驗,不過門神大的錯誤訊息跟小弟不一樣,等等來研究一下

[2019-07-08 13:54:39] production.ERROR: require_once(): Failed opening required '../includes/device-groups.inc.php' (include_path='.:/usr/share/pear:/usr/share/php') {"userId":1,"email":"abc@abc.com","exception":"[object] (Symfony\Component\Debug\Exception\FatalErrorException(code: 64): require_once(): Failed opening required '../includes/device-groups.inc.php' (include_path='.:/usr/share/pear:/usr/share/php') at /opt/librenms/html/includes/print-menubar.php:61)

我的完整錯誤的LOG....我發現沒有device-groups.inc.php

嗯 ! 比較偏向是版本錯誤
我們研究看看
再請節省哥上呈 Bug Report

剛在更中文化...結果發生問題,用./validate.php檢查問題後回復正常英文版,結果New Device Group就能用了QQ
https://ithelp.ithome.com.tw/upload/images/20190708/20036252TqgJXaBktm.png

TO 門神大
https://ithelp.ithome.com.tw/upload/images/20190708/20036252lrpAD7CV3V.png

[2019-07-03 17:15:24] production.ERROR: Geocoding failed: Google Maps API key missing, set geoloc.api_key
這錯誤訊息可能是這裡

geoloc.api_key 這問題 在查問題的時候就在了

wlhfor1974,請問你的中文化是指 daily.sh 更新到 1.53,還是去 https://github.com/jasoncheng7115/librenms-cpatch 下載的呢?

geoloc.api_key 這問題 在查問題的時候就在了

這個不影響

TO 節省哥:
去網址下載覆蓋原目錄

剛與門神測試,請先把 /opt/librenms/LibreNMS/DB/Schema.php 第 173 行給註解掉,可以改善這情況:

file_put_contents($cache_file, serialize($cache));
改為
// file_put_contents($cache_file, serialize($cache));

但還不確定是否有其它副作用,不知為何你們的情況會無法寫入這個 cache 檔,還要再研究看看。

wlhfor1974 不要去我的 github 下載中文化了,該github專案上面有說明已經是舊版 1.33,跟現行 1.53 版差很多了
1.53 版起已經我已經把中文直接提交回去內建了,請在功能表上的使用者 > My Settings > 裡面選擇為繁體中文,只是目前官方可以被翻譯的頁面還在一一進行中,中文程度有限。

補圖 ^^ 還是 Jason Cheng (節省哥) 厲害

https://ithelp.ithome.com.tw/upload/images/20190709/200014164fWxq2RJBN.jpg
可以新增了
https://ithelp.ithome.com.tw/upload/images/20190709/20001416poiJEuvxAD.jpg

早上還用 CentOS 7 (Nginx) 重裝了一次 XD
https://docs.librenms.org/Installation/Installation-CentOS-7-Nginx/

不愧是節省哥,拜...

執行(2019-07-14)
./daily.sh
更新
./validate.php
檢查
他們已經修正此問題

1

小弟來拜神了!

/images/emoticon/emoticon32.gif

就酷 iT邦新手 5 級‧ 2019-07-10 16:23:46 檢舉

JSJSS

0
badgirl
iT邦新手 5 級 ‧ 2019-07-08 03:22:05

天啊~謝謝你的神解說~

/images/emoticon/emoticon37.gif

0
門神JanusLin
iT邦超人 1 級 ‧ 2019-07-08 09:34:56

補上一個新增 Device 的錯誤
Already have host 192.168.254.7 (Vigor) due to duplicate sysName
https://ithelp.ithome.com.tw/upload/images/20190708/20001416UIJkaCmGhK.png

這意思是他已經有一個相同的名稱 sysName 叫做 Vigor 的
只需要在這地方把名稱改為不同就可以了
https://ithelp.ithome.com.tw/upload/images/20190708/20001416heZYKhF18L.png

0
門神JanusLin
iT邦超人 1 級 ‧ 2019-07-09 13:25:53

常用 Command
cd /opt/librenms/
下面執行
./daily.sh
更新
./validate.php
檢查

0
0
門神JanusLin
iT邦超人 1 級 ‧ 2019-07-16 13:18:54

改繁體中文 (節省哥的繁體中文版)
人的圖
My Settings
Language
改選繁體中文

https://ithelp.ithome.com.tw/upload/images/20190716/20001416gopZJyljwH.png

0
門神JanusLin
iT邦超人 1 級 ‧ 2019-07-16 13:22:11

地圖標示位置

https://ithelp.ithome.com.tw/upload/images/20190716/2000141663rZlJg3s5.png

https://ithelp.ithome.com.tw/upload/images/20190716/20001416lhjeuQrJuP.png

https://ithelp.ithome.com.tw/upload/images/20190716/20001416puoV7sZs3n.png

0
badboy01
iT邦新手 5 級 ‧ 2019-07-22 16:14:33

修正已經OK了~沒問題

看更多先前的回應...收起先前的回應...

他的前一動是加時區

感謝囉!

請問使用./validate.php 指令檢查出現下列訊息,該怎麼做呢?

[WARN] Your local git contains modified files, this could prevent automatic updates.
[FIX]:
You can fix this with ./scripts/github-remove
Modified Files:
bootstrap/cache/.gitignore
logs/.gitignore
rrd/.gitignore
storage/app/.gitignore
storage/app/public/.gitignore
storage/debugbar/.gitignore
storage/framework/cache/.gitignore
storage/framework/cache/data/.gitignore
storage/framework/sessions/.gitignore
storage/framework/testing/.gitignore
storage/framework/views/.gitignore
storage/logs/.gitignore

後來查了一下資料下
./scripts/github-remove -d 指令後就沒出現了

./scripts/github-remove -d 指令後就沒出現了

我文中都有提
http://ns2.ublink.org/viewtopic.php?f=10&t=6368

感謝!

Welcome

0
門神JanusLin
iT邦超人 1 級 ‧ 2019-08-02 10:56:32

UBS-5324z Giga Switch

可以秀出有沒有插網路線
和 LLDP 和 流量統計

https://ithelp.ithome.com.tw/upload/images/20190802/20001416RvaauN9sZq.jpg

https://ithelp.ithome.com.tw/upload/images/20190802/20001416sQZKPNJCxC.jpg

我要留言

立即登入留言