- 追加された行はこの色です。
- 削除された行はこの色です。
#contents
*net-snmp, mrtgをyumでインストール [#q561aa2f]
# yum install net-snmp
# yum install net-snmp-utils
# yum install mrtg
*net-snmpのセットアップ [#u26c7088]
# vi /etc/snmp/snmpd.conf
communityはパスワードみたいなものなので適宜変更すること
# sec.name source community
com2sec notConfigUser localhost public
# groupName securityModel securityName
group notConfigGroup v1 notConfigUser
group notConfigGroup v2c notConfigUser
view systemview included .1
# group context sec.model sec.level prefix read write notif
access notConfigGroup "" any noauth exact systemview none none
proc mountd
proc ntalkd 4
proc sendmail 10 1
proc httpd
disk / 10000
# /etc/rc.d/init.d/snmpd stop
# /etc/rc.d/init.d/snmpd start
確認~
すらずらっとデータが出力されればOK
# snmpwalk -c public -v 1 localhost .1
*トラフィック確認設定 [#v4934ee9]
# vi /etc/mrtg/traffic.cfg
WorkDir: /home/user/public_html/mrtg
RunAsDaemon: Yes
Interval: 5
Refresh: 300
Directory[_]: traffic
Target[index]: 2:public@localhost
MaxBytes[index]: 1250000
Title[index]: Traffic Analysis
PageTop[index]: <H1>Traffic Analysis</H1>
*CPU確認設定 [#g88a5722]
# vi /etc/mrtg/cpu.cfg
WorkDir: /home/user/public_html/mrtg
RunAsDaemon: Yes
Interval: 5
Refresh: 300
Options[_]: gauge,absolute,integer,nopercent
Directory[_]: cpu
MaxBytes[_]: 100
YLegend[_]: CPU Load Average (%)
Legend1[_]: 1 min CPU Load Avalage
Legend2[_]: 5 min CPU Load Avalage
LegendI[_]: 1min
LegendO[_]: 5min
ShortLegend[_]: percent (%)
Unscaled[_]: dwmy
Target[index]: .1.3.6.1.4.1.2021.10.1.5.1&.1.3.6.1.4.1.2021.10.1.5.1:public@localhost
Title[index]: CPU Load Average
PageTop[index]: <H1>CPU Load Average</H1>
*メモリ確認設定 [#ha49ed9c]
topコマンドでMem, Swapを調べ、それぞれMaxBytes1,MaxBytes2に設定
# vi /etc/mrtg/memory.cfg
WorkDir: /home/user/public_html/mrtg
RunAsDaemon: Yes
Interval: 5
Refresh: 300
Options[_]: gauge,absolute
Directory[_]: memory
YLegend[_]: Memory Used(Bytes)
ShortLegend[_]: (Bytes)
Legend1[_]: Real Memory
Legend2[_]: Swap Memory
LegendI[_]: Real
LegendO[_]: Swap
Unscaled[_]: dwmy
kMG[_]: k,M,G,T,P
Target[index]: 1.3.6.1.4.1.2021.4.6.0&1.3.6.1.4.1.2021.4.4.0:public@localhost
MaxBytes1[index]: 254468
MaxBytes2[index]: 257032
Title[index]: Memory Used
PageTop[index]: <H1>Memory Used</H1>
*ディスク容量確認設定 [#md390e2f]
# vi /etc/mrtg/disk.cfg
WorkDir: /home/user/public_html/mrtg
RunAsDaemon: Yes
Interval: 5
Refresh: 300
Options[_]: gauge,absolute,nopercent
Directory[_]: disk
MaxBytes[_]: 100
YLegend[_]: Disk Used (%)
LegendI[_]: / Disk used
LegendO[_]: / Disk Used
Legend1[_]: / Disk used
Legend2[_]: / Disk used
ShortLegend[_]: percent (%)
Unscaled[_]: dwmy
Target[index]: .1.3.6.1.4.1.2021.9.1.9.1&.1.3.6.1.4.1.2021.9.1.9.1:public@localhost
Title[index]: Disk Used
PageTop[index]: <H1>Disk Used</H1>
*httpプロセス確認設定 [#y7308c4e]
# vi /etc/mrtg/httpd.cfg
WorkDir: /home/user/public_html/mrtg
RunAsDaemon: Yes
Interval: 5
Refresh: 300
Options[_]: gauge,absolute,nopercent
Directory[_]: httpd
MaxBytes[_]: 150
YLegend[_]: Number of httpd
LegendI[_]: httpd
LegendO[_]: httpd
Legend1[_]: httpd
Legend2[_]: httpd
ShortLegend[_]: process
Unscaled[_]: dwmy
Target[index]: .1.3.6.1.4.1.2021.2.1.5.4&.1.3.6.1.4.1.2021.2.1.5.4:public@localhost
Title[index]: Number of httpd
PageTop[index]: <H1>Number of httpd</H1>
*自動起動の設定 [#wcfe9146]
# vi /etc/rc.d/rc.local
/usr/bin/mrtg /etc/mrtg/traffic.cfg
/usr/bin/mrtg /etc/mrtg/cpu.cfg
/usr/bin/mrtg /etc/mrtg/memory.cfg
/usr/bin/mrtg /etc/mrtg/disk.cfg
/usr/bin/mrtg /etc/mrtg/httpd.cfg
*エラーが出てアクセスできない [#yb60003e]
RPM形式でApacheをインストールしていて、mrtgを /var/www/html/mrtg とした場合、Forbiddenになります。
これは /etc/httpd/conf.d/ 以下に mrtg.conf が出来ていてAliasを張られているからです。コメントアウトしましょう。