|
All about the system administration and application development behind a local linux-based company
I’ve always been wary of automatic updates. Certainly, they give you the quickest response time, but at the price of stability. I’d rather know exactly what I’m updating when I’m updating it, so if I run into an issue it’s easier to backtrack where it came from. I find that a happy medium is email notification when updates become available. Since most of my servers are running the same distribution, I fire up clusterssh and update them all at once.
Here’s my yum email notification script (adapted from a script by Michael Heiming):
#!/bin/shmaila="email@address.com"yumdat="/tmp/yum-check-update.$$"yumb="/usr/bin/yum"CHECKWRK='no'#rm -f ${yumdat%%[0-9]*}*$yumb check-update >& $yumdatyumstatus="$?"case $yumstatus in100)cat $yumdat |\mail -s "Alert ${HOSTNAME} updates available!" $mailaexit 0;;0)# Only send mail if debug is turned onif [ ${CHECKWRK} = "yes" ];thencat $yumdat |\mail -s "Yum ${HOSTNAME} no patches available." $mailafiexit 0;;*)# Unexpected yum return status(echo "Undefined, yum return status: ${yumstatus}" && \[ -e "${yumdat}" ] && cat "${yumdat}" )|\mail -s "Alert ${HOSTNAME} problems running yum." $mailaesac# clean up[ -e "${yumdat}" ] && rm ${yumdat}One more thing is that it’s easy to forget to reboot after a kernel update, or put off rebooting because the time you update the RPMs isn’t the best time to update the kernel. To make sure that I do reboot, I’ve written added an email notification script that lets me know when the latest installed kernel is newer than the currently running kernel:
#!/bin/shCONTACTADDR=email@domain.comLATESTKERNEL=`rpm -q kernel |tail -n1|sed -e 's/kernel-//'`if uname -a | grep -qv $LATESTKERNEL; thenecho "Running Kernel is" `uname -r` "but latest installed rpm is ${LATESTKERNEL}" |\mail -s "${HOSTNAME} Reboot required" $CONTACTADDRfi;
Leave a Reply