≪ トップ |
2005年11月21日
NET-SNMP+MRTG インストール( UTF-8 化 )
これも、出力される HTML ファイルの文字コードが UTF-8 になるようにしてます。
net-snmp インストール
NET-SNMP設定ファイル編集
コメントアウト,追加
#com2sec notConfigUser default public
com2sec local localhost private
com2sec mynetwork 192.168.1.0/24 public
# groupName securityModel securityName
#group notConfigGroup v1 notConfigUser
#group notConfigGroup v2c notConfigUser
group MyROGroup v1 mynetwork
group MyROGroup v2c mynetwork
# Make at least snmpwalk -v 1 localhost -c public system fast again.
# name incl/excl subtree mask(optional)
#view systemview included .1.3.6.1.2.1.1
#view systemview included .1.3.6.1.2.1.25.1.1
view all included .1 80
# Finally, grant the group read-only access to the systemview view.
# group context sec.model sec.level prefix read write notif
#access notConfigGroup "" any noauth exact systemview none none
access MyROGroup "" any noauth exact all none none
access MyRWGroup "" any noauth exact all all none
# Check the / partition and make sure it contains at least 10 megs.
#disk / 10000
disk / 10000
NET-SNMP起動
自動起動設定,確認
[root@server ~]# chkconfig --list snmpd
MRTG インストール
MRTG 設定ファイル作成(サーバプライベートIPアドレスを192.168.1.30とすると)
--base: Vendor Id:
--base: Populating confcache
--snpo: confcache public@192.168.1.30: Descr lo --> 1
--snpo: confcache public@192.168.1.30: Descr eth0 --> 2
--snpo: confcache public@192.168.1.30: Descr sit0 --> 3
--snpo: confcache public@192.168.1.30: Type 24 --> 1
--snpo: confcache public@192.168.1.30: Type 6 --> 2
--snpo: confcache public@192.168.1.30: Type 131 --> 3
--snpo: confcache public@192.168.1.30: Ip 127.0.0.1 --> 1
--snpo: confcache public@192.168.1.30: Ip 192.168.1.30 --> 2
--snpo: confcache public@192.168.1.30: Eth --> 1
--snpo: confcache public@192.168.1.30: Eth 00-40-26-a7-ed-07 --> 2
--snpo: confcache public@192.168.1.30: Eth --> 3 (duplicate)
--base: Get Interface Info
--base: Walking ifIndex
--base: Walking ifType
--base: Walking ifAdminStatus
--base: Walking ifOperStatus
--base: Walking ifSpeed
MRTG 設定ファイル編集(NIC一枚挿しの場合)
追加(MRTGによる編集結果HTML格納先ディレクトリを指定)
# WorkDir: /home/http/mrtg
WorkDir: /var/www/mrtg
コメントアウト解除,変更(グラフの過去~未来への推移方向を左→右にする)
追加(日本語化)
Language:eucjp
編集(削除および変更)
Target[192.168.1.30_eth0]: \eth0:public@192.168.1.30:
SetEnv[192.168.1.30_eth0]: MRTG_INT_IP="192.168.1.30" MRTG_INT_DESCR="eth0"
MaxBytes[192.168.1.30_eth0]: 12500000
Title[192.168.1.30_eth0]: eth0トラフィック
PageTop[192.168.1.30_eth0]: <H1>eth0トラフィック</H1>
<TABLE>
<TR><TD>System:</TD> <TD>server.wave440.com in Unknown (edit /etc/snmp/snmpd.conf)</TD></TR>
<TR><TD>Maintainer:</TD> <TD>Root <root@localhost> (configure /etc/snmp/snmp.local.conf)</TD></TR>
<TR><TD>Description:</TD><TD>eth0 </TD></TR>
<TR><TD>ifType:</TD> <TD>ethernetCsmacd (6)</TD></TR>
<TR><TD>ifName:</TD> <TD></TD></TR>
<TR><TD>Max Speed:</TD> <TD>12.5 MBytes/s</TD></TR>
<TR><TD>Ip:</TD> <TD>192.168.1.30 ()</TD></TR>
</TABLE>
CPU使用率表示設定追加
MRTG設定ファイル編集(追加)
Target[cpu]: .1.3.6.1.4.1.2021.10.1.5.1&.1.3.6.1.4.1.2021.10.1.5.2:public@192.168.1.30
MaxBytes[cpu]: 100
Unscaled[cpu]: dwmy
Options[cpu]: gauge, absolute, growright, noinfo, nopercent
YLegend[cpu]: CPU Load(%)
ShortLegend[cpu]: (%)
LegendI[cpu]: 1分間平均
LegendO[cpu]: 5分間平均
Legend1[cpu]: 1分間平均(%)
Legend2[cpu]: 5分間平均(%)
Title[cpu]: CPU使用率
PageTop[cpu]: <H1>CPU使用率</H1>
空きメモリ量表示設定追加
メモリMAX値を確認する
total used free shared buffers cached
Mem: 320992 311116 9876 0 13092 129272
-/+ buffers/cache: 168752 152240
Swap: 655352 0 655352
MRTG設定ファイル編集(追加)
Target[mem]: .1.3.6.1.4.1.2021.4.6.0&.1.3.6.1.4.1.2021.4.4.0:public@192.168.1.30
MaxBytes1[mem]: 320992
MaxBytes2[mem]: 655352
Unscaled[mem]: dwmy
Options[mem]: gauge, absolute, growright, noinfo
YLegend[mem]: Mem Free(Bytes)
ShortLegend[mem]: Bytes
kilo[mem]: 1024
kMG[mem]: k,M,G,T,P
LegendI[mem]: Real
LegendO[mem]: Swap
Legend1[mem]: 空き物理メモリ[MBytes]
Legend2[mem]: 空きスワップメモリ[MBytes]
Title[mem]: 空きメモリ量
PageTop[mem]: <H1>空きメモリ量</H1>
ディスク使用率表示設定追加
MRTG設定ファイル編集(追加)
Target[disk]: .1.3.6.1.4.1.2021.9.1.9.1&.1.3.6.1.4.1.2021.9.1.9.1:public@192.168.1.30
MaxBytes[disk]: 100
Unscaled[disk]: dwmy
Options[disk]: gauge, absolute, growright, nopercent, noinfo
YLegend[disk]: Disk Used(%)
ShortLegend[disk]: (%)
LegendI[disk]: / Disk used
LegendO[disk]: / Disk Used
Legend1[disk]: / Disk used
Legend2[disk]: / Disk used
Title[disk]: ディスク使用率
PageTop[disk]: <H1>ディスク使用率</H1>
MRTG 起動(システムの文字コードがUTF-8の場合)
設定ファイルの文字コードをEUCに変換
[root@server ~]# nkf -e /etc/mrtg/mrtg.cfg.org > /etc/mrtg/mrtg.cfg
※以後、MRTG設定ファイルを編集する場合は/etc/mrtg/mrtg.cfg.orgを編集するようにし、編集後、nkfコマンドでEUCに変換するようにする
MRTG起動スクリプト作成
UTF-8 で出力するために、見よう見まねで追加してます。
LOCK=/var/lock/mrtg/mrtg_l
CONFCACHE=/var/lib/mrtg/mrtg.ok
export LANG=ja_JP.eucJP
mrtg /etc/mrtg/mrtg.cfg --lock-file $LOCK --confcache-file $CONFCACHE
CONF=/etc/mrtg/mrtg.cfg
OutputDir=`grep ^WorkDir $CONF | awk '{ print $2 }'`
for html in ${OutputDir}/*.html
do
nkf -w ${html} > ${html}.utf-8
/bin/mv -f ${html}.utf-8 ${html}
sed -i 's/euc-jp/UTF-8/g' ${html}
done
起動スクリプトへ実行権限付加
MRTG起動(3回する)
内部からのみアクセスできるようにする
mrtg 監視結果アクセス設定ファイル編集(追加)
# This configuration file maps the mrtg output (generated daily)
# into the URL space. By default these results are only accessible
# from the local host.
#
Alias /mrtg /var/www/mrtg
<Location /mrtg>
Order deny,allow
Deny from all
Allow from 127.0.0.1
Allow from 192.168.1
Allow from ::1
# Allow from .example.com
</Location>
Webサーバへ設定を反映
MRTG 自動起動設定
定期自動起動設定ファイル編集(作成したMRTG 起動スクリプトに変更する)
↓
*/5 * * * * root /root/mrtg.sh
MRTG インデックスページ作成
MRTG 付属の indexmaker というツールで作成する
http://サーバーIPアドレス/mrtg/ にアクセス
投稿者 ゆう : 2005年11月21日 10:23 | カテゴリー CentOS (27)
トラックバック
http://www.wave440.com/blog/mt-trbk.cgi/151
このリストは、次のエントリーを参照しています: NET-SNMP+MRTG インストール( UTF-8 化 ):
» MRTG インストール (サーバの統計情報をブラウザから監視) from Shoulder.jp
ネットワーク負荷、CPU使用率、空きメモリ量、ディスク使用率の統計について、ブラウザから管理・監視できるように自宅サーバにMRTGを入れることにした。ネットワーク負荷、CPU使用率、空きメモリ量、ディスク使用率の統計について、ブラウザから管理・監視できるように自宅サーバにMRTGを入れることにした。 [続きを読む]
トラックバック時刻: 2006年06月01日 14:52