Bhee 2007-10-20 08:36 PM
[How-to] MRTG設定安裝
[free][color=red][size=5]I.安裝 snmp&snmpd&mrtg&mrtg-contrib[/size][/color]
[b]root [/usr/ports] # portupgrade -NfCcpy snmp snmpd mrtg mrtg-contrib[/b]
---> Session started at: Sat, 20 Oct 2007 17:40:14 +0800
** No such installed package or port: snmp
** No such installed package or port: snmpd
** No such installed package or port: mrtg-contrib
---> Fresh installation of net-mgmt/mrtg started at: Sat, 20 Oct 2007 17:40:40 +0800
---> Installing 'mrtg-2.15.2,1' from a port (net-mgmt/mrtg)
[color=red][size=5]II.建立/usr/local/share/snmp/snmpd.conf[/size][/color]
[b]root [/usr/ports] #ee /usr/local/share/snmp/snmpd.conf[/b]
---------------------------------------------
裡面加入
rocommunity public
---------------------------------------------
[color=red][size=5]III.測試 snmp[/size][/color]
[b]root [/usr/ports] # snmpwalk -c public -v 1 localhost[/b]
會有如這樣的訊息出現
DISMAN-EVENT-MIB::mteEventNotificationObjectsOwner."_snmpd".'_mteTriggerFired' = STRING: _snmpd
DISMAN-EVENT-MIB::mteEventNotificationObjectsOwner."_snmpd".'_mteTriggerRising' = STRING: _snmpd
DISMAN-EVENT-MIB::mteEventNotificationObjects."_snmpd".'_linkDown' = STRING: _linkUpDown
DISMAN-EVENT-MIB::mteEventNotificationObjects."_snmpd".'_linkUp' = STRING: _linkUpDown
DISMAN-EVENT-MIB::mteEventNotificationObjects."_snmpd".'_mteTriggerFailure' = STRING: _triggerFail
DISMAN-EVENT-MIB::mteEventNotificationObjects."_snmpd".'_mteTriggerFalling' = STRING: _triggerFire
DISMAN-EVENT-MIB::mteEventNotificationObjects."_snmpd".'_mteTriggerFired' = STRING: _triggerFire
DISMAN-EVENT-MIB::mteEventNotificationObjects."_snmpd".'_mteTriggerRising' = STRING: _triggerFire
NOTIFICATION-LOG-MIB::nlmConfigGlobalEntryLimit.0 = Gauge32: 1000
NOTIFICATION-LOG-MIB::nlmConfigGlobalAgeOut.0 = Gauge32: 1440 minutes
NOTIFICATION-LOG-MIB::nlmStatsGlobalNotificationsLogged.0 = Counter32: 0 notifications
NOTIFICATION-LOG-MIB::nlmStatsGlobalNotificationsBumped.0 = Counter32: 0 notifications
root [/usr/local/etc] #
表示正常。
[color=red][size=5]IV.使用cfgmaker來產生我們所要監控的設備組態檔[/size][/color]
[b]root [/usr/ports] # cfgmaker --global 'WorkDir: /www/mrtg' \
--global 'Options[_]: bits,growright' \
--global 'Language: big5' \
--output /etc/mrtg.cfg \
[color=red]public@domain.name[/color][/b]
*1. /www/mrtg 是將來看統計輸出的地方, 要檢查目錄是否存在, apache 是否可以知道這地方.
*2. [email=public@domain.name]public@domain.name[/email] 這裡要特別注意唷!
必須把 domain.name 換成您主機的 domain.name。
[color=yellow]
若是想要了解你的主機User CPU Load % CPU (user and system) Load % Active CPU Load %這一些資訊的話,可以自己編輯 mrtg.cfg 檔案在最後面加上這些設定
[/free]
LoadMIBs: /usr/local/share/snmp/mibs/UCD-SNMP-MIB.txt
Target[cupidl]:ssCpuRawUser.0&ssCpuRawIdle.0:public@127.0.0.1
RouterUptime[cupidl]: [email=public@127.0.0.1]public@127.0.0.1[/email]
MaxBytes[cupidl]: 100
Title[cupidl]: CPU LOAD
PageTop[cupidl]: <H1>User CPU Load %</H1>
Unscaled[cupidl]: ymwd
ShortLegend[cupidl]: %
YLegend[cupidl]: CPU Utilization
Legend1[cupidl]: User CPU in % (Load)
Legend2[cupidl]: Idle CPU in % (Load)
Legend3[cupidl]:
Legend4[cupidl]:
LegendI[cupidl]: User
LegendO[cupidl]: Idle
LoadMIBs: /usr/local/share/snmp/mibs/UCD-SNMP-MIB.txt
Target[cupuse]:ssCpuRawUser.0&ssCpuRawSystem.0:public@127.0.0.1
RouterUptime[cupuse]: [email=public@127.0.0.1]public@127.0.0.1[/email]
MaxBytes[cupuse]: 100
Title[cupuse]: CPU LOAD
PageTop[cupuse]: <H1>CPU (user and system) Load %</H1>
Unscaled[cupuse]: ymwd
ShortLegend[cupuse]: %
YLegend[cupuse]: CPU Utilization
Legend1[cupuse]: User CPU in % (Load)
Legend2[cupuse]: System CPU in % (Load)
Legend3[cupuse]:
Legend4[cupuse]:
LegendI[cupuse]: User
LegendO[cupuse]: System
LoadMIBs: /usr/local/share/snmp/mibs/UCD-SNMP-MIB.txt
Target[cpuactive]:ssCpuRawUser.0&ssCpuRawUser.0:public@127.0.0.1 + ssCpuRawSystem.0&ssCpuRawSystem.0:public@127.0.0.1 + ssCpuRawNice.0&ssCpuRawNice.0:public@127.0.0.1
RouterUptime[cpuactive]: [email=public@127.0.0.1]public@127.0.0.1[/email]
MaxBytes[cpuactive]: 100
Title[cpuactive]: CPU LOAD
PageTop[cpuactive]: <H1>Active CPU Load %</H1>
Unscaled[cpuactive]: ymwd
ShortLegend[cpuactive]: %
YLegend[cpuactive]: CPU Utilization
Legend1[cpuactive]: Active CPU in % (Load)
Legend2[cpuactive]:
Legend3[cpuactive]:
Legend4[cpuactive]:
LegendI[cpuactive]: Active
LegendO[cpuactive]:
[/color]
[free]
[color=red][size=5]V.執行產生的CFG檔[/size][/color]
[b]root [/usr/ports] # mrtg /etc/mrtg.cfg(連續三次)[/b]
[color=red][size=5]VI.用 indexmaker 就可以輕鬆的將MRTG 的結果產生相關的首頁供人連結
[/size][/color]
[b]root [/usr/ports] # indexmaker /etc/mrtg.cfg > /www/mrtg/index.html [/b]
連結看看可以看到結果
[color=red][size=5]VII.定時自動運行MRTG[/size][/color]
[b]root [/usr/ports] # ee /etc/crontab
*/5 * * * * root /usr/local/bin/mrtg /etc/mrtg.cfg
[/b]
結束[/free]
[[i] 本帖最後由 Bhee 於 2007-10-20 08:49 PM 編輯 [/i]]