Super-sweet bash functions for condor
LIGHTGREEN='\033[1;32m'
LIGHTCYAN='\033[1;36m'
LIGHTRED='\033[1;31m'
NC='\033[0m'
condor_jobs()
{
printf "%12s %5s %5s %5s %5s\n" "user" "jobs" "idle" "run" "held"
all_results="all "
all_results+=$(condor_q | tail -1 | awk '{print $1" "$3" "$5" "$7}')
printf "%12s %5i %5i %5i %5i\n" $all_results
ihavejobs=false
for u in $(condor_users)
do
user_results="$u "
user_results+=$(condor_q $u | tail -1 | awk '{print $1" "$3" "$5" "$7}')
if [ "$u" = "$USER" ] ; then
n_my_condor_jobs=$(echo $user_results | awk '{print $2}')
n_my_condor_jobs_held=$(echo $user_results | awk '{print $5}')
if [ $n_my_condor_jobs_held -gt 0 ] ; then
my_color=${LIGHTRED}
else
my_color=${LIGHTCYAN}
fi
printf "${my_color}%12s %5i %5i %5i %5i\n${NC}" $user_results
ihavejobs=true
else
printf "%12s %5i %5i %5i %5i\n" $user_results
fi
done
if [ "$ihavejobs" = "false" ] ; then
n_my_condor_jobs=0
fi
}
condor_users()
{
condor_q | tail -n+5 | head -n-2 | awk '{print $2}' | sort | uniq | sed ':a;N;$!ba;s/\n/ /g'
}
condor_jobs_per_user()
{
condor_q -r | tail -n+5 | awk '{print $2}' | sort | uniq -c
}
watch_condor_q()
{
while true; do
echo `date`
condor_jobs
sleep 30
done
}
watch_my_jobs()
{
echo `date`
condor_jobs
while [[ $n_my_condor_jobs > 0 ]] ; do
sleep 30
echo `date`
condor_jobs
done
echo -e "${LIGHTGREEN}Your jobs have finished!${NC}"
}
alias condor_q_oldest="condor_q -r | head -20"
alias condor_q_newest="condor_q -r | tail -20"
--
RyanReece - 18-Jul-2012