Created
July 20, 2015 15:51
-
-
Save arttuladhar/19e6a0145417bf8e57bd to your computer and use it in GitHub Desktop.
Distcc HealthMonitor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Aayush Tuladhar | |
# v1.0 (2011) | |
# DistCC Monitor | |
# Performs Distcc On the Host Servers. Gets the compilation time and delivers email using sendmail. | |
HOSTFILE=/usr/local/itasca/buildtools/etc/lsdistcc_hosts | |
sendmailbin=/usr/sbin/sendmail | |
WORKING_DIR=`pwd` | |
MAIL_LIST_FILENAME=maillist.txt | |
REPORTFILENAME=$(date +"%b_%e_%Y"_report.txt) | |
REPORTFILE=$WORKING_DIR/$REPORTFILENAME | |
MAIL_LIST=$WORKING_DIR/$MAIL_LIST_FILENAME | |
SERVER_STATUS=0 #0 - No Server Down #1 - Server Down | |
#Mail Settings (FROM, SUBJECT, emailtarget, msgdate, daemail) | |
FROM="distcc_report.mailbot@distccmon.com" | |
function sendmail(){ | |
if [ -z $SERVER_STATUS ] | |
then | |
SUBJECT="Buildfarm Monitor : Server Up" | |
else | |
SUBJECT="Buildfarm Monitor : Server Down" | |
fi | |
msgdate='date+"%a, %e %Y %T %z"' | |
daemail=$(cat <> $REPORTFILE | |
SERVER_STATUS=1 | |
else | |
echo "Server : $1 [UP]" >> $REPORTFILE | |
fi | |
} | |
echo "$(date)" >> $REPORTFILE | |
echo "-------------------------------------" >> $REPORTFILE | |
if [ -r $HOSTFILE ] | |
then | |
#Reading Hosts | |
exec 9<$HOSTFILE | |
while read -u9 line | |
do | |
#Processing Hosts | |
check_status $line | |
done | |
else | |
echo "Error : HostFile ($HOSTFILE) not Found" | |
exit 111 #Exit 111 : Hostfile Not Found | |
fi | |
#Reading Maillist | |
if [ -r $MAIL_LIST ] | |
then | |
#Reading Maillist | |
exec 8<$MAIL_LIST | |
while read -u8 list | |
do | |
#Reading List | |
emailtarget=$list,$emailtarget | |
done | |
echo -e "\nSTATUS : Sending Mail to $emailtarget" | |
sendmail | |
else | |
echo "Error : Maillist ($MAIL_LIST) not Found" | |
exit 112 #Exit 112 : Maillist Not Found | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment