This Sheet describes some additional housekeeping items that will make life under Unix a little more pleasant.
MAILTO=""
#!/bin/sh
mount_cd9660 /dev/acd0c /cdrom
#!/bin/sh
umount /cdrom
cdcontrol -f /dev/acd0c eject
Make the scripts executable by root only:
# chown root:wheel /usr/local/bin/cd*
# chmod u+x /usr/local/bin/cd*
#! /bin/sh
#
# nitestat - Nightly Log Report
#
# Maintained by: D. O'Connor
# Modified: 7/22/2000.
#
MSG="/var/log/messages"
SEC="/var/log/security"
HTP="/var/log/httpd-error.log"
OLD="0"
ZIP="gz"
ZIPPROG="/usr/bin/gzip"
UNZIPPROG="/usr/bin/gunzip"
MM=`date | awk '{print $2}'`
DD=`date | awk '{printf "%3s", $3}'`
MSG_LFTO=`cat ${MSG} | grep -e "${MM}${DD}" | grep -e "logfile turned over" -c`
SEC_LFTO=`cat ${SEC} | grep -e "${MM}${DD}" | grep -e "logfile turned over" -c`
HTP_LFTO=`cat ${HTP} | grep -e "${MM}${DD}" | grep -e "logfile turned over" -c`
echo "Subject: `hostname` nightly log report"
echo "Content-type: text/html"
echo ""
echo ""
echo "<P>`date | awk '{print $1 ",", $2, $3 ",", $6, "at", $4, $5}'`"
echo "<P>System log messages for today:"
echo "<BLOCKQUOTE><PRE>"
if [ ${MSG_LFTO} -gt 0 ]; then
${UNZIPPROG} ${MSG}.${OLD}.${ZIP}
cat ${MSG}.${OLD} | grep -e "${MM}${DD}" | grep -e "last message repeated" -v
${ZIPPROG} ${MSG}.${OLD}
fi
cat ${MSG} | grep -e "${MM}${DD}" | grep -e "last message repeated" -v
echo "</PRE></BLOCKQUOTE>"
echo "Security log messages for today:"
CTR2=0
CTR4=0
if [ ${SEC_LFTO} -gt 0 ]; then
${UNZIPPROG} ${SEC}.${OLD}.${ZIP}
CTR2=`cat ${SEC}.${OLD} | grep -e "${MM}${DD}" | grep -e "255.255.255.255" -c`
CTR4=`cat ${SEC}.${OLD} | grep -e "${MM}${DD}" | grep -e "ICMP:8" -c`
fi
CTR1=`cat ${SEC} | grep -e "${MM}${DD}" | grep -e "255.255.255.255" -c`
CTR3=`cat ${SEC} | grep -e "${MM}${DD}" | grep -e "ICMP:8" -c`
echo "<BLOCKQUOTE><PRE>"
echo "<I> * $(( ${CTR1} + ${CTR2} )) broadcast messages not included</I>"
echo "<I> * $(( ${CTR3} + ${CTR4} )) inbound ping requests not included</I><BR>"
if [ ${SEC_LFTO} -gt 0 ]; then
cat ${SEC}.${OLD} | grep -e "${MM}${DD}" | grep -e "255.255.255.255" -v | grep -e "ICMP:8" -v | grep -e "last message repeated" -v
${ZIPPROG} ${SEC}.${OLD}
fi
cat ${SEC} | grep -e "${MM}${DD}" | grep -e "255.255.255.255" -v | grep -e "ICMP:8" -v | grep -e "last message repeated" -v
echo "</PRE></BLOCKQUOTE>"
echo "<P>Apache error messages for today:"
echo "<BLOCKQUOTE><PRE>"
if [ ${HTP_LFTO} -gt 0 ]; then
${UNZIPPROG} ${HTP}.${OLD}.${ZIP}
cat ${HTP}.${OLD} | grep -e "${MM}${DD}"
${ZIPPROG} ${HTP}.${OLD}
fi
cat ${HTP} | grep -e "${MM}${DD}"
echo "</PRE></BLOCKQUOTE>"
# Nightly status report
59 23 * * * root /usr/local/bin/nitestat | sendmail root