Miscellaneous Cleanup
Applicable to: FreeBSD 3.x, 4.x
Updated: January 1, 2001
This Sheet describes some additional housekeeping items that will make life under Unix a little more pleasant.
- Edit /etc/crontab to eliminate annoying e-mails:
MAILTO=""
- Create script files to easily mount and unmount the CDROM drive:
- Create /usr/local/bin/cdin:
#!/bin/sh
mount_cd9660 /dev/acd0c /cdrom - Create /usr/local/bin/cdout:
#!/bin/sh
umount /cdrom
cdcontrol -f /dev/acd0c ejectMake the scripts executable by root only:
# chown root:wheel /usr/local/bin/cd*
# chmod u+x /usr/local/bin/cd*
- Create /usr/local/bin/cdin:
- Create a nightly status report for some items that aren't part of the standard periodic reports.
- Create a mailable report script, /usr/local/bin/nitestat:
#! /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>" - Edit /etc/crontab:
# Nightly status report
59 23 * * * root /usr/local/bin/nitestat | sendmail root
- Create a mailable report script, /usr/local/bin/nitestat:
http://www.mostgraveconcern.com/freebsd/
Questions or Comments? Contact Us...




Post new comment