Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> 關於 Linux

Linux 安裝配置 MRTG 監控 Juniper 防火牆流量完整實作

編輯:關於 Linux

MRTG (Multi Router Traffic Grapher) 透過 SNMP 輪詢網路設備介面流量,生成即時圖表。本文以監控 Juniper 防火牆為例,涵蓋 SNMP 啟用、MRTG 安裝、cfgmaker 產生設定、關鍵參數調教、rrdtool 效能優化與 CGI 圖表呈現完整流程。

前置條件:Juniper 開啟 SNMP

set snmp community public authorization read-only
set snmp community public clients 192.168.1.100  # MRTG 伺服器 IP
set snmp location "Server Room"
set snmp contact "admin@example.com"

安裝 MRTG (CentOS/RHEL)

yum -y install mrtg mrtg-libs
# 官網:https://oss.oetiker.ch/mrtg/ 最新版 2.17.4

cfgmaker 產生初始設定檔

cfgmaker --global "WorkDir: /var/www/mrtg" \
         --output /etc/mrtg/mrtg.cfg \
         public@192.168.1.2

關鍵參數微調 /etc/mrtg/mrtg.cfg

# 時間軸左至右、單位 bits
Options[_]: growright, bits

# 重新整理頻率 300 秒 (5 分鐘)
Refresh: 300
Interval: 5

# 啟用 rrdtool 儲存(效能優於文字檔)
LogFormat: rrdtool
PathAdd: /usr/bin/

# 關閉 IPv6
EnableIPv6: no
WorkDir: /var/www/mrtg

常用 Target 區塊參數說明

參數用途
Target監控目標格式:port:community@router
MaxBytes介面最大頻寬(bps),超過值視為計數器歸零重算
YLegend / ShortLegendY 軸標題與單位標籤
Legend1-4四條曲線說明:平均入、平均出、最大入、最大出
WithPeak顯示峰值曲線:w(週)/m(月)/y(年)
PageTop自訂 HTML 頁首內容

rrdtool + CGI 圖表呈現

啟用 LogFormat: rrdtool 後,需 CGI 程式讀取 rrd 檔生成動態圖。常用插件:

  • 14all.cgi:經典、輕量
  • routers2.cgi:功能豐富、支援多裝置聚合
  • mrtg-rrd:官方提供

Apache 設定範例:

ScriptAlias /mrtg/ /var/www/mrtg/

    Options +ExecCGI
    AddHandler cgi-script .cgi
    Require all granted

排程輪詢

# /etc/cron.d/mrtg
*/5 * * * * root /usr/bin/mrtg /etc/mrtg/mrtg.cfg --logging /var/log/mrtg.log

Windows 版本

MRTG 亦有 Windows 原生版,安裝 ActivePerl 後可直接執行,設定檔格式相同。

Copyright © Windows教程網 All Rights Reserved