Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
MCX debug reporting script
PATH=/bin:/usr/bin:/sbin:/usr/sbin export PATH
# Define the recipient.
# That should be it for the necessary configuration part. The rest can be pretty much as-is.
HWLOGDATE=$(printf "`date "+%a %h %e"` \n")
# Activate MCX debug logging
/usr/bin/defaults write /Library/Preferences/ debugOutput -2
/usr/bin/defaults write /Library/Preferences/ collateLogs 1
# Now begin writing the daily report.
echo "From: MCX Debug Report <$SEND>" > $LOGS
echo "To: $RECIP" >> $LOGS
echo "Subject: $NAME MCX Debug Report Report" - `date` >> $LOGS
ADDY=`ifconfig eth1 |grep "inet addr" |awk '{print $2}' |awk -F: '{print $2}'`
# Give an introduction.
echo "***********************************************************************" >> $LOGS
echo "***** Hi. You're receiving this because you want MCX debug reports" >> $LOGS
echo "***** This is the report for `date "+%a %h %e"`. " >> $LOGS
echo "***** Report is for `hostname` ($ADDY). " >> $LOGS
echo "***********************************************************************" >> $LOGS
echo " " >> $LOGS
echo " " >> $LOGS
# This tails /Library/Logs/ManagedClient/ManagedClient.log and hopefully catches the errors
echo "Last 500 Lines of the ManagedClient log" >> $LOGS
echo "--------------------------------" >> $LOGS
tail -500 /Library/Logs/ManagedClient/ManagedClient.log >> $LOGS
echo " " >> $LOGS
echo " " >> $LOGS
# Read LOGS, pipe it to sendmail and fire off an email.
cat $LOGS | sendmail -f $RECIP -t
# Get rid of the files.
rm $LOGS
# Deactivate MCX debugging
/bin/rm /Library/Preferences/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment