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

Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r2 - 2012-07-19 - RyanReece
 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    Main All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback