簡報說明
在眾多裝置監視系統套件中,LibreNMS 是一款開源、功能豐富且容易使用的好工具。講者將由過去企業應用經驗中分享,如何以 LibreNMS 為中心,搭配週邊套件來達到多種異常檢測與預警系統建置。
勘誤:P.15 第二行字應為地理圖與「可用性地圖」資訊呈現。
議程介紹:http://2019.infosec.org.tw/agenda_0711.html#spkr_0711_c_04
逐頁文字
LibreNMS 資安應⽤用經驗分享
耀達電腦股份有限公司 / 鄭郁霖 Jason Cheng鄭郁霖 Jason Cheng
• 耀達電腦 / 技術總監
• 軟體⾃自由協會 / 理理事長
• 晟鑫科技 / 開源解決⽅方案顧問
• 資策會數位教育研究所 / 講師
• 國際資訊安全組織臺灣⾼高峰會 2018 / 講者
• 臺灣資安⼤大會 2019 / 講者
• 台中⾃自由軟體愛好者社群 (TFC) / 共同創辦⼈人⾯面臨臨困境
錢能解決的問題都不是問題
😭 問題是沒有錢 😭開源軟體
是另⼀一扇⾨門企業需要監測 如何⾃自動監測
之項⽬目眾多, 與立即警報?解決⽅方案
開源裝置與服務狀態監視系統
poller.1
poller-2
Welcome to LibreNMS, a fully featured network
monitoring system that provides a wealth of
poller-3
features and device support.
WHAT CAN IT DO?
rdcachad-1PHP
SNMP
MariaDB
RRDICMP
SNMP
AGENT
APPLICATION
SERVICE裝置資訊
網路與伺服器相關基本資訊%1
FreeBSD
GENERIC
GENERIC
Common
53m 485
Generic Device
SmartCell
12d 12h
41m 39s
39m 9sLibreNMS
地圖資訊
地理圖與可用性地圖資訊呈現Dashboard
(本頁無文字)
效能資訊
裝置效能數據資訊搜集RRDTOOL / TOBI OETIKER|
- CPU usage
RRDTOOL / TOBI OETIKER
RRDTOOL / TODI OETIKER.NETGEAR
2018-10-26
2018-10-26健康資訊
裝置健康狀況資訊搜集IPMI settings
* Fanspeed裝置事件
納管裝置異動事件記錄搜集DrayTek
09:51:03
01:14:36Software Version: 9.11(2.1) Series: S4048-ON Copyright (c) 1999-
(id=27) 11:54 AM
更新檢查
監測主機套件更新程度Apps: OS Updates
網頁監測
監測網站運作及內容異動Wireless Apps Routing Alerts
兹Services
% Ports
⑦ Inventory
SonarQube Web
HTTP OK: HTTP/1.1 200 - 1742 bytes in 0.014 second
response timeType:
http
Config
-P 9000 -s "SonarQube" -t 15
87 days 16
HTTP OK: HTTP/1.1 200 - 1742 bytes in 0.014 second域名時效
監測網域名稱有效期限%o Ports
菇 Services
ssl_cert 218 days 21 hours
Certificate will not expire
Certificate will not expire
Certificate will not expire
SSL_CERT OK - X.509 certificate for 'subject=OU = Domain
US, ST = Arizona, L = Scottsdale, O = "GoDaddy.com,
Inc.", OU = http://certs.godaddy.com/repository/, CN = Go
httpType:
耀達域名
ssl_cert 218 days 21 hours
US, ST = Arizona, L = Scottsdale, O = "GoDaddy.com,
Inc.", OU = http://certs.godaddy.com/repository/, CN =Go
(2025-02-24).憑證效期
監測 SSL 加密憑證有效期限%o Ports
菇 Services
ssl_cert 218 days 21 hours
Certificate will not expire
Certificate will not expire
SSL_CERT OK - X.509 certificate for 'subject=OU = Domain
US, ST = Arizona, L = Scottsdale, O = "GoDaddy.com,
Inc.", OU = http://certs.godaddy.com/repository/, CN = Go
http
211 days 5 hours 9耀達官網憑證
燊 Add Service
Control Validated, CN = *.youstar.com.tw' from "issuer=C =
US, ST = Arizona, L = Scottsdale, O = "GoDaddy.com,
Inc.", OU = http://certs.godaddy.com/repository/, CN = Go
http
耀達官網 (https)RBL 監測
監測郵件主機是否被列 RBL 清單<ip>
http
-t 60-c 1 -s cbl.anti-spam.org.cn -s cblplus.anti-spa
CHECK_RBL OK -
numoffileslbgsstour 47
外寄 Queue 檢查佇列監測
監測郵件主機發信佇列是否正常(本頁無文字)
服務
連接埠
5 days (2023-04-
Type:
numoffiles_byssh
外寄 Queue 檢查(>10)
http
second response
-d /opt/zimbra/data/postfix/spool/active/ -w 5 -c10
imap
4 days
9 days 8 hours 45
外寄 Queue 檢查
numoffiles_byssh
(>10)信箱監測
監測特定郵件信箱是否正常Wireless Apps Routing Alerts
Service
Last Changed
Description
Message
domain
3 days 21 hours 50
55 days 9 hours 25
55 days 9 hours 25
4 days 25 minutes
9 days 8 hours 55
IMAP RECEIVE OK - 0 seconds, 647 found, 0 captured
minutes 43 seconds 信箱狀態
4 days 25 minutesB74 days (2023-
Type:
imap_receive
Description:
.com.tw 信箱狀態
http
http
com.tw" -P "pwd" -s ALL --nodelete
Ignore:
imap
imap_receive
IMAP RECEIVE OK - 0 seconds, 676 found, 0 captured
numoffiles_byssh 21 days 1hour 13
外寄 Queue 檢查
minutes 9 seconds(>10)反解監測
監測 DNS 反解 IP 是否正常SOPHOS
Security made simple.
Memory Usage
CPU Usage
Y Overview
Graphs
Health
% Ports
Config
Basic
# Add Service
dhcp
74 days 8 hours
DHCP 檢測
OK: Received 1 DHCPOFFER(s), max lease time =
11 minutes 17
1228800 sec.
dns
35 days 23 hours
中華 DNS 測試
DNS OK: 0.016 seconds response time.
www.google.com.tw returns 216.58.200.35
secondsGlobal Search
SOPHOS
Security made simg
Type:
dns
Description:
中華 DNS 測試
? Overview
onfig
IP Address:
168.95.1.1
Performance
Parameters:
www.google.com.tw
Services 》
Basic
dhcp
74 days 8 hours
DHCP 檢測
OK: Received 1 DHCPOFFER(s), max lease time =
18 minutes 20
1228800 sec.
35 days 23 hours
中華 DNS 測試
DNS OK: 0.014 seconds response time.
dns
www.google.com.tw returns 216.58.200.227複寫監測
監測 ZFS 快照複寫最新版本Processor Usage
】 Processes
http
HTTP OK: HTTP/1.1 302 Redirect - 286 bytes in 0.002 second
freenasrefp days 3 hours 2
minutes 41 seconds
時間差(>24H)
freenasrepl days 17 hours 25
時間差(>24H)Description:
最新快照抄寫時間差(>24H)
Q Overview
Graphs
-W 22 -C 25 -P /mnt/$5/rpbak/vmi/.zfs/snapshot
http
16 days 47 minutes
Duplicati (jail)
HTTP OK: HTTP/1.1 302 Redirect - 286 bytes in 0.002 second
录新快照抄寫
ok-The latest snapshot was 3 hours ago.(2019/06/15
時間差(>24H)
12:15)
freenasrefl days 17 hours 25
ok - The latest snapshot was 3 hours ago. (2019/06/15
時間差(>24H)
12:45)GNU nano 2.5.3
File: check_freenasrep
Modified
error=""
# get lastest snapshot name to date
# ex. /mnt/S5/rpbak/S2/vmimage/.zfs/snapshot
getdate="/usr/bin/ssh Sssh_connect "1s Ssnapshot_path | grep auto | tail -n 1 | cut -d'-' -f 2"
getdate="/bin/echo Sgetdate | /bin/sed 's/V./ /g
getdate=Sgetdate
# debug msg
#echo "Sgetdate"
gethumandate="/bin/date -d "Sgetdate" "+%Y/%m/%d %R"
# convert date to unix date (timestaamp)
snapshotdate="/bin/date -d "Sgetdate" +%s
#echo "Ssnapshotdate"
# get now date
# debug msg
#echo "Snowdate"
Get Help
Justify
Prev Page
Read File
Replace
Next PageFile: check_freenasrep
# get user define date diff value (hours)
datediff=S((Snowdate Ssnapshotdate)):
datediff=S((Sdatediff/68/68)):
"Sdatediff"
exitstatus=SSTATE_OK
"Sthresh_warn”!=
if [ Sdatediff -ge Sthresh_warn ]:then
result="warning"
exitstatus=SSTATE_WARNING
"Sthresh_crit"!=
if [ Sdatediff -ge
Sthresh_crit l: then
result="critical"
“Sresult - The latest snapshot was Sdatediff hours ago. (Sgethumandate) Idiffhours=3datediff;Sthresh_warn;Sthresh.crit"
Where Is
Justify
Prev Page
Next Page流量帳單
依據流量狀況設定門檻值與報告Transferned
Bytes
Rolling Monthly View記錄監視
搜集裝置事件並用做警報條件LibreNMS
LibreNMS
組態備份
裝置設定檔自動排程備份系統LibreNMS
(本頁無文字)
圖表強化
搭配更強的套件客製專用圖表Grafana Labs
Grafana Enterprise
Plugins
The open platform for beautiful
Time range
analytics and monitoring
Get Grafana
The leading open source software for time series analyticsPrometheus
From metrics to insight
Power your metrics and alerting with a leading
open-source monitoring solution.
GET STARTED
DOWNLOAD
Efficient storage
Dimensional d..
Q Powerful queri..
Great visualiz.
modes for visualizing data: a設定 LibreNMS 對 Prometheus ⽀支援
/opt/librenms/config.php
$config['prometheus']['enable'] = true;
$config['prometheus']['url'] = "http://127.0.0.1:9091";
$config['prometheus']['job'] = "librenms"; # Optional安裝 Prometheus PushGateway
mkdir /opt/prometheus
cd /opt/prometheushttps://github.com/prometheus/pushgateway/releases/
download/v0.7.0/pushgateway-0.7.0.linux-amd64.tar.gztar -xvzf pushgateway-0.7.0.linux-amd64.tar.gz
cd pushgateway-0.7.0.linux-amd64
./pushgateway &驗證 Prometheus PushGateway
http://ip:9091設定 Prometheus Pull
/opt/promtheus/prometheus.yml
- job_name: 'librenms'
scrape_interval: 300s
honor_labels: true
static_configs:
- targets: [‘aaa.bbb.ccc.ddd:9091’]啟⽤用 Prometheus Pull
設定 Grafana 數據來來源與圖表
系統驗證
登入身份驗證及安全機制MySQL
Active Directory
LDAP
Radius
HTTP Auth
Single Sign-on雙因素驗證
雙因素驗證
警報發送
發送管道
由 LibreNMS 發送告警事件API Mail Rocket.chat
Boxcar MatterMost Slack
Canopsis Microsoft Teams SMSEagle
Cisco Spark Nagios Compatible Syslog
Clickatell OpsGenie Telegram
Discord osTicket Twilio SMS
Elasticsearch PagerDuty VictorOps
Gitlab Philips Hue Kayako Classic
HipChat PlaySMS SMSFeedback
IRC Pushbullet
JIRA PushoverTelegram
Telegram
ON
Chat ID:
Save TransportAlert Transport:: Docs B
Slack-Alert
Transport type:
https://hooks.slack.com/services
Slack Options:
Save TransportTransport type:
Default Alert:https://
Save Transport警報規則
警告發送條件與門檻設定bgpPeers.bgpPeerState != "established" AND
bgpPeers. bgpPeerFsm EstablishedTime < 300 AND Critical|
bgpPeers.bgpPeerState = “established"
macros.port_usage_perc >= 80 AND
ports.ifName NOT LIKE %tap%'
sensors.sensor_current > sensors.sensor_limit
AND sensors.sensor_alert = 20(本頁無文字)
裝置重啟
SELECT * FROM devices,Ports WHERE (devices.device_id = ? AND devices.device_id = ports.devic
bgpPeers.bgpPeerFsmEstablishedTime < 300 AND
macros.port_down = 1
= 1 AND macros.port = 1 AND ports.ifName NOT LIKEmacros.device_down = "1"
macros.port_down = "1"
sensors.sensor_current >'sensors.sensor _limit' && sensors.sensor_alert = "1"&&
services.service_status != "0" && macros.device_up = "1"OR
'macros.past_5m'
.*AUTH_FAILED.*警報發送樣式
實際警報推播發送範例X[警報]
主機:
說明:
規則:服務狀態異常程
系統(id=81)
系統(id=81)
string"請輸入帳號 not found(本頁無文字)
(本頁無文字)
(本頁無文字)
警報追蹤
警報事件處理狀況與追蹤「交換空間」使用率超過 80%
Os-Updates 可用更新數>10(本頁無文字)
)設備故障,送修中
Tue, 18 Jun 2019 17:42:24 +0800 - Ack (
)設備故障,送修中(本頁無文字)
參參考資料
考參
LibreNMS
https://www.librenms.org/LibreNMS GitHub
https://github.com/librenms/librenmsLibreNMS Docs
https://docs.librenms.org/Nagios Plugins
https://exchange.nagios.org/directory/PluginsLibreNMS 中⽂文使⽤用者社團
https://facebook.com/groups/lnms.tw1 2
節省⼯工具箱 簡報集中處
blog.jason.tools slide.jason.tools謝謝