免費內容:
I.安裝 snmp&snmpd&mrtg&mrtg-contrib
root [/usr/ports] # portupgrade -NfCcpy snmp snmpd mrtg mrtg-contrib
---> 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)
II.建立/usr/local/share/snmp/snmpd.conf
root [/usr/ports] #ee /usr/local/share/snmp/snmpd.conf
---------------------------------------------
裡面加入
rocommunity public
---------------------------------------------
III.測試 snmp
root [/usr/ports] # snmpwalk -c public -v 1 localhost
會有如這樣的訊息出現
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] #
表示正常。
IV.使用cfgmaker來產生我們所要監控的設備組態檔
root [/usr/ports] # cfgmaker --global 'WorkDir: /www/mrtg' \
--global 'Options[_]: bits,growright' \
--global 'Language: big5' \
--output /etc/mrtg.cfg \
public@domain.name
*1. /www/mrtg 是將來看統計輸出的地方, 要檢查目錄是否存在, apache 是否可以知道這地方.
*2. public@domain.name 這裡要特別注意唷!
必須把 domain.name 換成您主機的 domain.name。
若是想要了解你的主機User CPU Load % CPU (user and system) Load % Active CPU Load %這一些資訊的話,可以自己編輯 mrtg.cfg 檔案在最後面加上這些設定
LoadMIBs: /usr/local/share/snmp/mibs/UCD-SNMP-MIB.txt
Target[cupidl]:ssCpuRawUser.0&ssCpuRawIdle.0:public@127.0.0.1
RouterUptime[cupidl]:
public@127.0.0.1
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]:
public@127.0.0.1
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]:
public@127.0.0.1
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]:
免費內容:
V.執行產生的CFG檔
root [/usr/ports] # mrtg /etc/mrtg.cfg(連續三次)
VI.用 indexmaker 就可以輕鬆的將MRTG 的結果產生相關的首頁供人連結
root [/usr/ports] # indexmaker /etc/mrtg.cfg > /www/mrtg/index.html
連結看看可以看到結果
VII.定時自動運行MRTG
root [/usr/ports] # ee /etc/crontab
*/5 * * * * root /usr/local/bin/mrtg /etc/mrtg.cfg
結束
[
本帖最後由 Bhee 於 2007-10-20 08:49 PM 編輯 ]