ピリオディックとわたくし

ずっと以前、MRTGの設定をしたときに、Charlieのメールにも載せてもらえるように頼んだときのことを書くのを忘れていたのでいまさらメモ。
まず/etc/periodic.confを下記の内容で作成

# 600.status-temperature
daily_status_temperature_enable="YES"                   # Check temperature
daily_status_temperature_command="/usr/local/bin/mbmon" # Command
daily_status_temperature_flags="-I -c 1"                # Conbind fmt, once

# 610.status-ups
daily_status_ups_enable="YES"                           # Check UPS
daily_status_ups_command="/usr/local/sbin/apcaccess status"

次に/usr/local/etc/periodic/daily/600.status-temperatureを作成して

#!/bin/sh
if [ -r /etc/defaults/periodic.conf ]
then
    . /etc/defaults/periodic.conf
    source_periodic_confs
fi
case "$daily_status_temperature_enable" in
    [Yy][Ee][Ss])
    if [ -x /usr/local/bin/mbmon ]
    then
        echo ""
        echo "Temperature status:"
        $daily_status_temperature_command \
        $daily_status_temperature_flags && rc=1 || rc=3
    else
        rc=2
    fi;;
    *)  rc=0;;
esac
exit $rc

同様に/usr/local/etc/periodic/daily/610.status-upsを作成して

#!/bin/sh
if [ -r /etc/defaults/periodic.conf ]
then
    . /etc/defaults/periodic.conf
    source_periodic_confs
fi
case "$daily_status_ups_enable" in
    [Yy][Ee][Ss])
    if [ -r /var/run/apcupsd.pid ]
    then
        echo ""
        echo "UPS status:"
        $daily_status_ups_command | grep -e 'LINEV'   \
                                         -e 'LOADPCT' \
                                         -e 'BCHARGE' \
                                         -e 'TIMELEFT' && rc=1 || rc=3
    else
        rc=2
    fi;;
    *)  rc=0;;
esac
exit $rc

これで、毎朝のメールにM/B温度とUPSの状況が追加されます。