MRTG導入 memo
参考 : http://vine.1-max.net/net-snmp+MRTG.html
aptでsmtpをインストール
#apt-get install net-snmp
NET-SNMP設定
# vi /etc/snmp/snmpd.conf
##### First, map the community name "public" into a "security name"# sec.name source community
#com2sec notConfigUser default public
com2sec local localhost private
com2sec mynetwork 192.168.1.0/24 public##### Second, map the security name into a group name:
# groupName securityModel securityName
#group notConfigGroup v1 notConfigUser
#group notConfigGroup v2c notConfigUser
group MyROGroup v1 mynetwork
group MyROGroup v2c mynetwork##### Third, create a view for us to let the group have rights to:
# 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
NET-SNMP自動起動設定
# /etc/init.d/snmpd start
snmpdを起動中: [ OK ]
# chkconfig snmpd on
# chkconfig --list snmpd
snmpd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
MRTG2のインストール
zlib-devel libpng-devel gd-develが必要なので入れる。
MRTGをインストール
落とす →
http://people.ee.ethz.ch/~oetiker/webtools/mrtg/pub/
解凍する。出来たディレクトリに入って
# ./configure
Config is Done を見たいもんだ。
# make
# make install
インストール終わり。
MRTG設定
設定ファイルディレクトリ作成
# mkdir /usr/local/mrtg-2/cfg
MRTG設定ファイル作成
設定ファイル作成 (cfgmaker使用)
# /usr/local/mrtg-2/bin/cfgmaker --ifref=descr --ifdesc=descr public@サーバIP > /usr/local/mrtg-2/cfg/mrtg.cfg
省略。
設定ファイルは参考サイトやfedorasrvを基に作る。
MRTG実行
# mkdir -p /home/httpd/html/mrtg/icons ← MRTGのディレクトリ作成
以下を三回繰り返してエラーのでないようにする。
# /usr/local/mrtg-2/bin/mrtg /usr/local/mrtg-2/cfg/mrtg.cfg
indexmakerでインデックスページを作成
# /usr/local/mrtg-2/bin/indexmaker --columns=1 --addhead="" /usr/local/mrtg-2/cfg/mrtg.cfg > /home/httpd/html/mrtg/index.html
# vi mrtg.sh ← viでMRTG起動スクリプト作成
#!/bin/sh
cronに登録
#vi /etc/cron.d/mrtg
*/5 * * * * root /root/mrtg.sh
#/etc/init.d/crond restart
MRTGでハードディスクの温度監視
aptでハードディスクの温度を調べられるhddtempをインストール
# apt-get install hddtemp
温度取得スクリプト作成
file: /root/temp_hda.sh
#!/bin/sh
/usr/sbin/hddtemp /dev/hda | \
/usr/bin/awk '{printf "%.2d\n0", $3}'
MRTGの設定
設定ファイルに書き足し
### Disk Temp ### Target[hddtemp]: `/root/temp_hda.sh` MaxBytes[hddtemp]: 100 Options[hddtemp]: gauge, absolute, growright, nopercent, noinfo YLegend[hddtemp]: Temperature ShortLegend[hddtemp]: ℃ LegendI[hddtemp]: Temp: LegendO[hddtemp]: Legend1[hddtemp]: HDD Temperature in Degrees Celcius Legend2[hddtemp]: Title[hddtemp]: ハードディスク温度 PageTop[hddtemp]: <h1>ハードディスク温度</h1>
MRTGを三回起動してよければ終了。