boot up notification

Walter Hop freebsd at walter.transip.nl
Fri Jan 14 13:57:26 PST 2005


[in reply to fquest at ccstores.com, 14-1-2005]

> I would like one of my servers to send me an email when
> it boots. I envision a script in rc.conf to do this.
>
> Is there an easier way, or an automatic system which can do this?


        We  are  using  a  simple  shell  script that can be placed in
        /usr/local/etc/rc.d/bootreport.sh.  It  sends  out an email to
        root  with  the dmesg output, and also sends an email when the
        system is being shut down.
        

#!/bin/sh

HOSTNAME=`/bin/hostname`;

case "$1" in
        start)
                (echo $HOSTNAME was booted at `/bin/date` ; echo ''; echo '--'; echo ''; echo 'dmesg output:' ; /sbin/dmesg) | mail -s "$HOSTNAME boot" root
                ;;
        stop)
                echo $HOSTNAME was shut down on user request at `/bin/date` | mail -s "$HOSTNAME shutdown" root
                ;;
        *)
                echo ""
                echo "Usage: `basename $0` { start | stop }"
                echo ""
                exit 64
                ;;
esac
        


-- 
 Walter Hop <freebsd at walter.transip.nl> | TransIP | http://www.transip.nl/



More information about the freebsd-questions mailing list