差異處
這裏顯示兩個版本的差異處。
| 下次修改 | 前次修改 | ||
| tech:mrtg [2007/02/05 18:04] – 建立 jonathan | tech:mrtg [2023/06/27 09:07] (目前版本) – jonathan | ||
|---|---|---|---|
| 行 1: | 行 1: | ||
| + | ====== MRTG 安裝與應用 ====== | ||
| + | ===== Alpine ===== | ||
| + | * 安裝套件 <cli> | ||
| + | apk add mrtg net-snmp | ||
| + | </ | ||
| + | * 設定 snmpd.conf | ||
| + | * 啟動 snmpd 服務 <cli> | ||
| + | rc-update add snmpd | ||
| + | rc-service snmpd start | ||
| + | </ | ||
| + | ===== CentOS ===== | ||
| + | ==== - 確認是否已經安裝 mrtg 套件 ==== | ||
| + | <cli> | ||
| + | rpm -q mrtg | ||
| + | |||
| + | [docsrv@ed ~]$ rpm -q mrtg | ||
| + | mrtg-2.10.15-1 | ||
| + | </ | ||
| + | * 如果沒有安裝, | ||
| + | |||
| + | ===== - 使用 snmpd 來讓 MRTG 監看網路流量 ==== | ||
| + | ==== - 安裝 snmpd ==== | ||
| + | <cli> | ||
| + | rpm -q net-snmp | ||
| + | |||
| + | [root@pd920 ~]# rpm -q net-snmp | ||
| + | net-snmp-5.1.2-11.EL4.7 | ||
| + | </ | ||
| + | * 如果沒有安裝, | ||
| + | |||
| + | |||
| + | ==== - 設定 snmpd ==== | ||
| + | <cli> | ||
| + | vi / | ||
| + | </ | ||
| + | < | ||
| + | com2sec notConfigUser | ||
| + | |||
| + | group | ||
| + | group | ||
| + | |||
| + | view systemview | ||
| + | view systemview | ||
| + | view systemview | ||
| + | view systemview | ||
| + | |||
| + | access | ||
| + | |||
| + | syslocation Taipei | ||
| + | syscontact Admin < | ||
| + | </ | ||
| + | <cli> | ||
| + | service snmpd restart | ||
| + | chkconfig snmpd on | ||
| + | chkconfig --list | grep snmpd | ||
| + | </ | ||
| + | |||
| + | ===== - 使用簡單 script 來讓 MRTG 監看硬碟空間, | ||
| + | <note important> | ||
| + | * 可直接下載 trysrvtool 使用, 請參考 **[[tech: | ||
| + | </ | ||
| + | |||
| + | ===== - 設定 mrtg.cfg ===== | ||
| + | * 假設已經安裝 [[http:// | ||
| + | |||
| + | * 先使用 [[http:// | ||
| + | <cli> | ||
| + | cd /etc/mrtg | ||
| + | / | ||
| + | cat localhost.cfg >> mrtg.cfg | ||
| + | vi / | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | : | ||
| + | ### Global Defaults | ||
| + | |||
| + | # to get bits instead of bytes and graphs growing to the right | ||
| + | Options[_]: growright, bits | ||
| + | : | ||
| + | : | ||
| + | |||
| + | Target[eth1]: | ||
| + | SetEnv[eth1]: | ||
| + | MaxBytes[eth1]: | ||
| + | Options[eth1]: | ||
| + | Title[eth1]: | ||
| + | PageTop[eth1]: | ||
| + | # | ||
| + | # | ||
| + | |||
| + | Target[disk_root]: | ||
| + | MaxBytes[disk_root]: | ||
| + | Options[disk_root]: | ||
| + | YLegend[disk_root]: | ||
| + | ShortLegend[disk_root]: | ||
| + | LegendO[disk_root]: | ||
| + | LegendI[disk_root]: | ||
| + | Title[disk_root]: | ||
| + | PageTop[disk_root]: | ||
| + | |||
| + | Target[disk_boot]: | ||
| + | MaxBytes[disk_boot]: | ||
| + | Options[disk_boot]: | ||
| + | YLegend[disk_boot]: | ||
| + | ShortLegend[disk_boot]: | ||
| + | LegendO[disk_boot]: | ||
| + | LegendI[disk_boot]: | ||
| + | Title[disk_boot]: | ||
| + | PageTop[disk_boot]: | ||
| + | |||
| + | Target[disk_data]: | ||
| + | MaxBytes[disk_data]: | ||
| + | Options[disk_data]: | ||
| + | YLegend[disk_data]: | ||
| + | ShortLegend[disk_data]: | ||
| + | LegendO[disk_data]: | ||
| + | LegendI[disk_data]: | ||
| + | Title[disk_data]: | ||
| + | PageTop[disk_data]: | ||
| + | |||
| + | Target[disk_backup]: | ||
| + | MaxBytes[disk_backup]: | ||
| + | Options[disk_backup]: | ||
| + | YLegend[disk_backup]: | ||
| + | ShortLegend[disk_backup]: | ||
| + | LegendO[disk_backup]: | ||
| + | LegendI[disk_backup]: | ||
| + | Title[disk_backup]: | ||
| + | PageTop[disk_backup]: | ||
| + | |||
| + | Target[cpuload]: | ||
| + | MaxBytes[cpuload]: | ||
| + | Options[cpuload]: | ||
| + | YLegend[cpuload]: | ||
| + | ShortLegend[cpuload]: | ||
| + | LegendO[cpuload]: | ||
| + | LegendI[cpuload]: | ||
| + | Title[cpuload]: | ||
| + | PageTop[cpuload]: | ||
| + | |||
| + | Target[cpuio]: | ||
| + | MaxBytes[cpuio]: | ||
| + | Options[cpuio]: | ||
| + | YLegend[cpuio]: | ||
| + | ShortLegend[cpuio]: | ||
| + | LegendO[cpuio]: | ||
| + | LegendI[cpuio]: | ||
| + | Title[cpuio]: | ||
| + | PageTop[cpuio]: | ||
| + | |||
| + | Target[memswap]: | ||
| + | MaxBytes[memswap]: | ||
| + | Options[memswap]: | ||
| + | YLegend[memswap]: | ||
| + | ShortLegend[memswap]: | ||
| + | LegendO[memswap]: | ||
| + | LegendI[memswap]: | ||
| + | Title[memswap]: | ||
| + | PageTop[memswap]: | ||
| + | |||
| + | Target[sensors]: | ||
| + | MaxBytes[sensors]: | ||
| + | Options[sensors]: | ||
| + | YLegend[sensors]: | ||
| + | ShortLegend[sensors]: | ||
| + | LegendO[sensors]: | ||
| + | LegendI[sensors]: | ||
| + | Title[sensors]: | ||
| + | PageTop[sensors]: | ||
| + | |||
| + | Target[ups]: | ||
| + | MaxBytes[ups]: | ||
| + | Options[ups]: | ||
| + | YLegend[ups]: | ||
| + | ShortLegend[ups]: | ||
| + | LegendO[ups]: | ||
| + | LegendI[ups]: | ||
| + | Title[ups]: UPS Temperature | ||
| + | PageTop[ups]: | ||
| + | |||
| + | Target[sata_dev_sda]: | ||
| + | MaxBytes[sata_dev_sda]: | ||
| + | Options[sata_dev_sda]: | ||
| + | YLegend[sata_dev_sda]: | ||
| + | ShortLegend[sata_dev_sda]: | ||
| + | LegendO[sata_dev_sda]: | ||
| + | LegendI[sata_dev_sda]: | ||
| + | Title[sata_dev_sda]: | ||
| + | PageTop[sata_dev_sda]: | ||
| + | |||
| + | Target[sata_dev_sdb]: | ||
| + | MaxBytes[sata_dev_sdb]: | ||
| + | Options[sata_dev_sdb]: | ||
| + | YLegend[sata_dev_sdb]: | ||
| + | ShortLegend[sata_dev_sdb]: | ||
| + | LegendO[sata_dev_sdb]: | ||
| + | LegendI[sata_dev_sdb]: | ||
| + | Title[sata_dev_sdb]: | ||
| + | PageTop[sata_dev_sdb]: | ||
| + | |||
| + | Target[smtp]: | ||
| + | MaxBytes[smtp]: | ||
| + | Options[smtp]: | ||
| + | YLegend[smtp]: | ||
| + | ShortLegend[smtp]: | ||
| + | LegendO[smtp]: | ||
| + | LegendI[smtp]: | ||
| + | Title[smtp]: | ||
| + | PageTop[smtp]: | ||
| + | |||
| + | Target[pop3]: | ||
| + | MaxBytes[pop3]: | ||
| + | Options[pop3]: | ||
| + | YLegend[pop3]: | ||
| + | ShortLegend[pop3]: | ||
| + | LegendO[pop3]: | ||
| + | LegendI[pop3]: | ||
| + | Title[pop3]: | ||
| + | PageTop[pop3]: | ||
| + | |||
| + | Target[imap]: | ||
| + | MaxBytes[imap]: | ||
| + | Options[imap]: | ||
| + | YLegend[imap]: | ||
| + | ShortLegend[imap]: | ||
| + | LegendO[imap]: | ||
| + | LegendI[imap]: | ||
| + | Title[imap]: | ||
| + | PageTop[imap]: | ||
| + | |||
| + | Target[mail_queue]: | ||
| + | MaxBytes[mail_queue]: | ||
| + | Options[mail_queue]: | ||
| + | YLegend[mail_queue]: | ||
| + | ShortLegend[mail_queue]: | ||
| + | LegendO[mail_queue]: | ||
| + | LegendI[mail_queue]: | ||
| + | Title[mail_queue]: | ||
| + | PageTop[mail_queue]: | ||
| + | |||
| + | Target[http]: | ||
| + | MaxBytes[http]: | ||
| + | Options[http]: | ||
| + | YLegend[http]: | ||
| + | ShortLegend[http]: | ||
| + | LegendO[http]: | ||
| + | LegendI[http]: | ||
| + | Title[http]: | ||
| + | PageTop[http]: | ||
| + | |||
| + | Target[ssh]: | ||
| + | MaxBytes[ssh]: | ||
| + | Options[ssh]: | ||
| + | YLegend[ssh]: | ||
| + | ShortLegend[ssh]: | ||
| + | LegendO[ssh]: | ||
| + | LegendI[ssh]: | ||
| + | Title[ssh]: SSH Connections | ||
| + | PageTop[ssh]: | ||
| + | |||
| + | Target[postgres]: | ||
| + | MaxBytes[postgres]: | ||
| + | Options[postgres]: | ||
| + | YLegend[postgres]: | ||
| + | ShortLegend[postgres]: | ||
| + | LegendO[postgres]: | ||
| + | LegendI[postgres]: | ||
| + | Title[postgres]: | ||
| + | PageTop[postgres]: | ||
| + | |||
| + | Target[mysql]: | ||
| + | MaxBytes[mysql]: | ||
| + | Options[mysql]: | ||
| + | YLegend[mysql]: | ||
| + | ShortLegend[mysql]: | ||
| + | LegendO[mysql]: | ||
| + | LegendI[mysql]: | ||
| + | Title[mysql]: | ||
| + | PageTop[mysql]: | ||
| + | |||
| + | Target[domain]: | ||
| + | MaxBytes[domain]: | ||
| + | Options[domain]: | ||
| + | YLegend[domain]: | ||
| + | ShortLegend[domain]: | ||
| + | LegendO[domain]: | ||
| + | LegendI[domain]: | ||
| + | Title[domain]: | ||
| + | PageTop[domain]: | ||
| + | |||
| + | Target[ntp]: | ||
| + | MaxBytes[ntp]: | ||
| + | Options[ntp]: | ||
| + | YLegend[ntp]: | ||
| + | ShortLegend[ntp]: | ||
| + | LegendO[ntp]: | ||
| + | LegendI[ntp]: | ||
| + | Title[ntp]: NTP Connections | ||
| + | PageTop[ntp]: | ||
| + | |||
| + | Target[upsload]: | ||
| + | MaxBytes[upsload]: | ||
| + | Options[upsload]: | ||
| + | YLegend[upsload]: | ||
| + | ShortLegend[upsload]: | ||
| + | LegendI[upsload]: | ||
| + | LegendO[upsload]: | ||
| + | Title[upsload]: | ||
| + | PageTop[upsload]: | ||
| + | |||
| + | Target[upsvolts]: | ||
| + | MaxBytes[upsvolts]: | ||
| + | Options[upsvolts]: | ||
| + | YLegend[upsvolts]: | ||
| + | ShortLegend[upsvolts]: | ||
| + | LegendI[upsvolts]: | ||
| + | LegendO[upsvolts]: | ||
| + | Title[upsvolts]: | ||
| + | PageTop[upsvolts]: | ||
| + | |||
| + | Target[upsother]: | ||
| + | MaxBytes[upsother]: | ||
| + | Options[upsother]: | ||
| + | YLegend[upsother]: | ||
| + | ShortLegend[upsother]: | ||
| + | LegendI[upsother]: | ||
| + | LegendO[upsother]: | ||
| + | Title[upsother]: | ||
| + | PageTop[upsother]: | ||
| + | |||
| + | </ | ||
| + | |||
| + | ===== - 啟動 mrtgd ===== | ||
| + | ==== - 確認 / | ||
| + | <cli> | ||
| + | cd / | ||
| + | chmod a+x * | ||
| + | </ | ||
| + | * 測試執行兩次 / | ||
| + | <cli> | ||
| + | / | ||
| + | / | ||
| + | </ | ||
| + | |||
| + | ==== - 設定每五分鐘執行一次 ==== | ||
| + | <cli> | ||
| + | vi / | ||
| + | </ | ||
| + | < | ||
| + | */5 * * * * root LANG=C LC_ALL=C / | ||
| + | </ | ||
| + | <cli> | ||
| + | service crond restart | ||
| + | </ | ||
| + | |||
| + | |||
| + | ==== - 設定透過 web 可以看到結果 ==== | ||
| + | <cli> | ||
| + | vi / | ||
| + | </ | ||
| + | < | ||
| + | Alias /mrtg / | ||
| + | |||
| + | < | ||
| + | # Order deny,allow | ||
| + | # Deny from all | ||
| + | # Allow from 127.0.0.1 | ||
| + | # Allow from ::1 | ||
| + | # Allow from .example.com | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | <cli> | ||
| + | service httpd restart | ||
| + | </ | ||
| + | |||
| + | * 在 / | ||
| + | <cli> | ||
| + | / | ||
| + | </ | ||
| + | |||
| + | |||
| + | {{tag> | ||