--- tags: linux,build --- # MRTG ## 規格 作業系統:Ubuntu 16.04 ___ ## 參考文章 >https://www.iceflatline.com/2009/08/how-to-install-and-configure-mrtg-on-ubuntu-server/ >http://vieriking.pixnet.net/blog/post/21568284-mrtg-for-ubuntu >http://jaklinux.blogspot.com/2014/06/linux-mrtg.html ## 安裝apache ```shell= sudo apt-get install apache2 ``` ## 下載SNMP ==MRTG是使用SNMP協定,所以要先裝snmpd== ```shell sudo apt-get install snmpd ``` ## 修改/etc/snmp/snmpd.conf 把 ```bash= com2sec paranoid default public #com2sec readonly default public #com2sec readwrite default private ``` 改成 ```bash= #com2sec paranoid default public com2sec readonly default public #com2sec readwrite default private ``` ## 重啟SNMP ```shell /etc/init.d/snmpd restart ``` ## 安裝MRTG ```shell sudo apt-get install mrtg ``` ## 先輸出本機資訊到~/mrtg.cfg ```shell cfgmaker public@localhost > ~/mrtg.cfg ``` 修改/etc/mrtg.cfg,新增以下內容到最底下 :::info 如果有出現ERROR: did not find any matching data in cfg file 才需要做 ::: ```bash= Target[127.0.0.1_1]: 1:public@127.0.0.1: SetEnv[127.0.0.1_1]: MRTG_INT_IP="127.0.0.1" MRTG_INT_DESCR="lo" MaxBytes[127.0.0.1_1]: 1250000 Title[127.0.0.1_1]: Traffic Analysis for local loopback PageTop[127.0.0.1_1]: <h1>Traffic Analysis for local loopback</h1> ``` 把mrtg.cfg整理進/etc/mrtg 資料夾 ```shell= sudo mkdir /etc/mrtg && sudo mv /etc/mrtg.cfg /etc/mrtg ``` 在/var/www/html資料夾下創建mrtg資料夾,並輸出html ```shell= sudo mkdir /var/www/html/mrtg sudo indexmaker --output=/var/www/html/mrtg/index.html /etc/mrtg/mrtg.cfg ``` 在/etc/apache2/apache.conf裡類似部分添加新網域 ```bash= Alias /mrtg "/var/www/mrtg/" <Directory "/var/www/mrtg/"> Options None AllowOverride None Require all granted </Directory> ``` 然後重啟 ```shell= sudo service apache2 restart ``` 如果出現警告,可再往裡面添加 ``` ServerName locahost:80 ``` 編輯/etc/mrtg.cfg檔案,加入「Language: big5」就能改成中文  更改環境變量LANG=C並啟動mrtg ```shell= sudo env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg ``` 
×
Sign in
Email
Password
Forgot password
or
Sign in via Google
Sign in via Facebook
Sign in via X(Twitter)
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
Continue with a different method
New to HackMD?
Sign up
By signing in, you agree to our
terms of service
.