この日記にはツッコミを入れられます。 ツッコミを入れたい日付をクリックすると、フォームが現れます。
xreaでtDiaryを使う方法はxrea.com で tDiary を使う方法やインストールメモやXREA + tDiary + Namazuをどうぞ。
今は backports に dkms 2.1.1.2-2~bpo50+1 があるので /etc/apt/preferences に
Package: dkms Pin: release a=lenny-backports Pin-Priority: 999
と書いて dkms をインストール。
USBRH driver for Linux からドライバをとってきて /usr/src/usbrh-0.0.8 において「chown -R root:src」とかしておく。
以下の内容の /usr/src/usbrh-0.0.8/dkms.conf を設置。
PACKAGE_NAME="usbrh" PACKAGE_VERSION="0.0.8" BUILT_MODULE_NAME[0]="usbrh" BUILT_MODULE_LOCATION[0]="src/" MAKE[0]="make -C $kernel_source_dir M=$dkms_tree/$module/$module_version/build/src" DEST_MODULE_LOCATION[0]="/kernel/../extra/" AUTOINSTALL="yes" REMAKE_INITRD="yes"
$ sudo dkms add -m usbrh -v 0.0.8
Creating symlink /var/lib/dkms/usbrh/0.0.8/source ->
/usr/src/usbrh-0.0.8
DKMS: add Completed.
$ sudo dkms build -m usbrh -v 0.0.8
Kernel preparation unnecessary for this kernel. Skipping...
Building module:
cleaning build area....
make KERNELRELEASE=2.6.26-2-amd64 -C /lib/modules/2.6.26-2-amd64/build M=/var/lib/dkms/usbrh/0.0.8/build/src....
cleaning build area....
DKMS: build Completed.
$ sudo dkms install -m usbrh -v 0.0.8
usbrh.ko:
Running module version sanity check.
- Original module
- No original module exists within this kernel
- Installation
- Installing to /lib/modules/2.6.26-2-amd64/updates/dkms/
depmod....
Updating initrd
Making new initrd as /boot/initrd.img-2.6.26-2-amd64
(If next boot fails, revert to the .bak initrd image)
update-initramfs........
DKMS: install Completed.
$
/etc/initramfs-tools/modules に usbrh を追加し忘れていたので、一度 uninstall してから install し直した。
/etc/munin/plugins/usbrh 作成。 (2010-06-17 追記: ツッコミにある1行抜けていたのを修正。 最新は http://gist.github.com/441401 に置くことにした。)
#!/bin/sh
case "$1" in
autoconf)
if [ -r /proc/usbrh/0/status ]; then
echo yes
exit 0
else
echo no
exit 1
fi
;;
config)
echo 'graph_title USBRH'
echo 'graph_args -l 0 --base 1000'
echo 'graph_vlabel temperature(C) and humidity(%RH)'
echo 'graph_category sensors'
cd /proc/usbrh
for n in *; do
echo "humidity_$n.label humidity $n"
echo "humidity_$n.draw LINE2"
echo "humidity_$n.info humidity $n"
echo "temperature_$n.label temperature $n"
echo "temperature_$n.draw LINE2"
echo "temperature_$n.info temperature $n"
done
exit 0
;;
esac
for status in /proc/usbrh/*/status; do
n=$(basename $(dirname $status))
# retry when failed to get temperature/humidity
for i in 1 2 3 4 5; do
stat="$(cat $status)"
#mkdir /tmp/usbrh
#{ date; echo $stat; } >> /tmp/usbrh/usbrh-$$.log
if expr "$stat" : "^t">/dev/null; then
break
fi
sleep 1
done
#echo "$stat" | sed -e "s/t:([.0-9]*) h:([.0-9]*)/temperature_$n.value \$1\nhumidity_$n.value \$2/"
#echo $stat | sed -e "s/t:/temperature_$n.value /" -e "s/ h:/\nhumidity_$n.value /"
echo $stat | sed -e "s/t:\\([.0-9]*\\) h:\\([.0-9]*\\).*/temperature_$n.value \\1\nhumidity_$n.value \\2/"
done
Ubuntu 10.04 LTS だと udev で文句を言われたのでこう変更した。
% cat /etc/udev/rules.d/10-usbrh.rules
# USBRH (http://www2.strawberry-linux.com/products/usbrh/) rules
# written by Tetsuya KIMATA <kimata@acapulco.dyndns.org>
# $Id: 10-usbrh.rules 40 2009-09-04 16:13:44Z kimata $
#BUS=="usb", SYSFS{manufacturer}=="Strawberry Linux Co.,Ltd.", SYSFS{product}=="Hygrometer/Thermometer", NAME=="%k", RUN+="/sbin/modprobe usbrh"
ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="1774", ATTR{idProduct}=="1001", RUN+="/sbin/modprobe usbrh"
CentOS 5にてですが、メチャクチャ有難く使用させてもらってます。 <br> <br>/etc/munin/plugins/usbrh の 「autoconf)」 の前に <br>「case $1 in」 の行が足りないような気がします。 <br> <br>もひとつ、「expr "$stat" : "^t"」で <br>> expr: warning: unportable BRE: `^t': using `^' as the first character <br>> of the basic regular expression is not portable; it is being ignored <br>と怒られるので、他にうまい方法があるだろうけど、とりあえず <br>「[ '0' != "`echo $stat | grep '^t:' | wc -l`" ];」 <br>と書き換えてうまく動いています。 <br>wcしなくても、空文字列チェックでよかったかもしれません。
gistの方ではexprの代わりにcaseでチェックするようにしてみました。