リスト8-1 mrtg.cfg のサンプル WorkDir: /usr/local/www/data/Room
PageTop[^]:
Stats for
TimeZone[_]: Japan
Options[^]: gauge growright
kilo[_]: 1024
XSize[_]: 600
Target[thermo-hygro]: `/usr/local/etc/program/tr72u`
MaxBytes[thermo-hygro]: 100
MaxBytes2[thermo-hygro]: 100
Title[thermo-hygro]: Thermometer/Hygrometer
Options[thermo-hygro]: absolute, gauge
PageTop[thermo-hygro]:Thermometer/Hygrometer
AbsMax[thermo-hygro]: 100
Ylegend[thermo-hygro]: dig. / %
ShortLegend[thermo-hygro]: dig or %
Unscaled[thermo-hygro]: dmwy
LegendI[thermo-hygro]: dig.
LegendO[thermo-hygro]: %
Legend1[thermo-hygro]: Thermometer
Legend2[thermo-hygro]: Hygrometer
---
リスト8-2 crontab の記述(root 用)
#LANG=ja_JP.EUCP
######################################################
# minute 0-59
# hour 0-23
# day of month 1-31
# month 1-12 (or names, see below)
# day of week 0-7 (0 or 7 is Sun, or use names)
######################################################
# min hour day month week
*/5 * * * * /usr/local/bin/mrtg /usr/local/etc/mrtg/mrtg.cfg
---
リスト8-3 TR-72WのIPアドレスからwgetを使ってHTTPプロトコルでデータ入手
#! /bin/sh
# 計測ユニットの IP アドレス
unit=192.168.0.101
file=/usr/local/www/data/B/crrntdata/cdata-101.txt
data=/usr/local/www/data/B/crrntdata/mrtg-101.dat
sleep 10
rm -f $file
/usr/local/bin/wget -O $file http://$unit/B/crrntdata/cdata.txt
cat $file | /usr/bin/awk 'BEGIN{FS="="} /cTemperature1/ {print $2}' > $data
cat $file | /usr/bin/awk 'BEGIN{FS="="} /cHumidity/ {print $2}' >> $data
echo T >> $data
echo H >> $data
---
リスト8-4 温湿度データが格納されたファイルからデータを読むための mrtg.cfg の例
Target[thermo-hygro-101]: `cat /usr/local/www/data/B/crrntdata/mrtg-101.dat`