8月31日の保守記録に書いたように、ログを編集してからwebalizerに食わせてますので、その編集時にMRTGとwebalizerへのアクセス記録を削除するようにしました。
#!/bin/sh
LOGDIR=/var/log/httpd
INFILE=tdiary_access.log
OUTFILE=tmp_access_log
CONF=/etc/webalizer.conf-tdiary
cat ${LOGDIR}/${INFILE}.1 ${LOGDIR}/${INFILE} | \
sed -e 's/] [^[:space:]]* "/] "/' \
-e '/\/mrtg/d' -e '/\/usage/d' \
> ${LOGDIR}/${OUTFILE}
webalizer -c ${CONF} ${LOGDIR}/${OUTFILE}
sedの使い方が未だにヘタクソだと思っているので、もっと綺麗な書き方があったら教えていただけると助かります。
手順を書こうかと思ったんですが、けっこー長くなっちゃいますので端折って書きます。
まずlm_sensorsの設定を行います。設定は/usr/sbin/sensors-detectってコマンドを実行すると、あれこれ質問されますので、デフォルトを答えてると終ります(をぃ)。で、その際にmodprobeで何をやっておけとか表示されるので、取り合えずそれらを/etc/rc.d/rc.localにでも放り込みます。
それと/etc/modules.confにこれを書いておけというのも出ますので、それもやっときます。
--- /etc/rc.d/rc.local-20030907 2003-09-02 16:02:14.000000000 +0900 +++ /etc/rc.d/rc.local 2003-09-07 11:21:41.000000000 +0900 @@ -8,3 +8,13 @@ # for tDiary su - tdiary /home/tdiary/bin/zebedee-client + +# for Hardware monitor +# I2C adapter drivers +modprobe i2c-viapro +modprobe i2c-isa +# I2C chip drivers +modprobe lm80 +modprobe eeprom +modprobe via686a + --- /etc/modules.conf-20030907 2003-08-23 23:52:18.000000000 +0900 +++ /etc/modules.conf 2003-09-07 11:22:34.000000000 +0900 @@ -3,3 +3,7 @@ post-install sound-slot-0 /bin/aumix-minimal -f /etc/.aumixrc -L >/dev/null 2>&1 || : pre-remove sound-slot-0 /bin/aumix-minimal -f /etc/.aumixrc -S >/dev/null 2>&1 || : alias usb-controller usb-uhci + +# I2C module options +alias char-major-89 i2c-dev +
次にNET-SNMP経由で実行するコマンド(スクリプト)の作成と、snmpdの設定を行います。MRTGは二つの整数値を読んでグラフ化しますので、最低二つの(二行の)整数値が返るコマンドを作ります。
温度を返却するコマンド(sensors_temp.sh)
#!/bin/sh
cd /proc/sys/dev/sensors/via686a-isa-0c00
set -- `cat temp1 temp2 temp3`
SYS_TEMP=${3}; shift 3
CPU_TEMP=${3}; shift 3
SBR_TEMP=${3}
echo -e "${SYS_TEMP}\n${CPU_TEMP}\n${SBR_TEMP}" | sed -e 's/\.//g'
ファン回転数を返却するコマンド(sensors_fan.sh)
#!/bin/sh
cd /proc/sys/dev/sensors/via686a-isa-0c00
set -- `cat fan1 fan2`
CPU_FAN=${2}; shift 2
P_S_FAN=${2}
echo -e "${CPU_FAN}\n${P_S_FAN}"
で、これらのコマンドを/etc/snmpd.confに仕込みます。
--- /etc/snmp/snmpd.conf-20030907 2003-09-02 02:00:16.000000000 +0900 +++ /etc/snmp/snmpd.conf 2003-09-07 22:27:59.000000000 +0900 @@ -357,6 +357,9 @@ # exec .1.3.6.1.4.1.2021.52 top /usr/local/bin/top # exec .1.3.6.1.4.1.2021.53 mailq /usr/bin/mailq +exec .1.3.6.1.4.1.2021.52 FanRotation /home/tdiary/bin/sensors_fan.sh +exec .1.3.6.1.4.1.2021.53 Temperature /home/tdiary/bin/sensors_temp.sh + # -----------------------------------------------------------------------------
次にsnmp経由でコマンドの実行結果が得られるかを確認してみます。確認にはsnmpwalkコマンドを使います。
[root@tdiary log]# snmpwalk -v2c -c private localhost .1.3.6.1.4.1.2021.52 UCD-SNMP-MIB::ucdavis.52.1.1 = INTEGER: 1 UCD-SNMP-MIB::ucdavis.52.2.1 = STRING: "FanRotation" UCD-SNMP-MIB::ucdavis.52.3.1 = STRING: "/home/tdiary/bin/sensors_fan.sh" UCD-SNMP-MIB::ucdavis.52.100.1 = INTEGER: 0 UCD-SNMP-MIB::ucdavis.52.101.1 = STRING: "3040" UCD-SNMP-MIB::ucdavis.52.101.2 = STRING: "2755" UCD-SNMP-MIB::ucdavis.52.102.1 = INTEGER: 0 [root@tdiary log]# snmpwalk -v2c -c private localhost .1.3.6.1.4.1.2021.53 UCD-SNMP-MIB::ucdavis.53.1.1 = INTEGER: 1 UCD-SNMP-MIB::ucdavis.53.2.1 = STRING: "Temperature" UCD-SNMP-MIB::ucdavis.53.3.1 = STRING: "/home/tdiary/bin/sensors_temp.sh" UCD-SNMP-MIB::ucdavis.53.100.1 = INTEGER: 0 UCD-SNMP-MIB::ucdavis.53.101.1 = STRING: "378" UCD-SNMP-MIB::ucdavis.53.101.2 = STRING: "346" UCD-SNMP-MIB::ucdavis.53.101.3 = STRING: "218" UCD-SNMP-MIB::ucdavis.53.102.1 = INTEGER: 0
次にMRTGの設定を行います。MRTGでsnmp.confで指定したOIDを取得させれば、グラフを書いてくれるわけです。というわけで、mrtg.cfgには次のような設定を追加します。
--- /etc/mrtg/mrtg.cfg-20030907 2003-09-03 00:29:42.000000000 +0900 +++ /etc/mrtg/mrtg.cfg 2003-09-07 22:57:02.000000000 +0900 @@ -98,4 +98,29 @@ LegendI[realmem]: OS+User+Cache LegendO[realmem]: OS+User +Target[temperture]: 1.3.6.1.4.1.2021.53.101.1&1.3.6.1.4.1.2021.53.101.2:private@localhost +MaxBytes1[temperture]: 800 +MaxBytes2[temperture]: 500 +Title[temperture]: Temperture +PageTop[temperture]: <h1>Temperture [/10 Celsius]</h1> +Options[temperture]: gauge,absolute,integer,nopercent,withzeroes +YLegend[temperture]: Temperture +ShortLegend[temperture]: /10 C +Legend1[temperture]: SYS +Legend2[temperture]: CPU +LegendI[temperture]: SYS +LegendO[temperture]: CPU + +Target[fan]: 1.3.6.1.4.1.2021.52.101.1&1.3.6.1.4.1.2021.52.101.2:private@localhost +MaxBytes1[fan]: 5000 +MaxBytes2[fan]: 4000 +Title[fan]: Fan Rotation +PageTop[fan]: <h1>Fan Rotation [RPM]</h1> +Options[fan]: gauge,absolute,integer,nopercent,withzeroes +YLegend[fan]: RPM +ShortLegend[fan]: RPM +Legend1[fan]: CPU +Legend2[fan]: P/S +LegendI[fan]: CPU +LegendO[fan]: P/S
#3 これで温度のグラフやファン回転数のグラフを表示できるようになりました。
これ、やってみたかったので、参考になります
参考にしていただけて幸いです。本当はrrdtoolsなんかを使ってみたかったんですが、早いところグラフが見たくて挫折しました(^^;
rrdtoolは私も理解することに挫折しました(^^;