Linux scripts : boincstats
I wrote many bash, php and perl scripts for my haartsen.nl server (Fedora Core 6) and backup server (Fedora 14), which I would like to share. They are often not the most optimal scripts in terms of code or processing efficiency, but hey, they work :-). Most scripts are created because I could not find a similar script on the Internet.
Name: boincstatsDescription: A script to show the current status of running BOINC tasks
#!/bin/bash
#
# boincstats Shows the current status of running BOINC tasks
#
# Author: Peter Haartsen <peter@haartsen.nl>
#
# Set SLOTSDIR to the directory where your BOINC slots are located (without trailing slash)
# Typical locations are "/usr/local/BOINC/slots" or "/var/lib/boinc/slots"
SLOTSDIR="/var/lib/boinc/slots"
# No modifications needed below this line
echo -e "CPU Time\tProgress\tRemaining\tTask"
for PROC in `ls -1d $SLOTSDIR/*/ | xargs -l basename`
do
RESULTNAME=`grep result_name $SLOTSDIR/$PROC/boinc_task_state.xml | tr -d ' ' | sed 's/^<.*>\([^<].*\)<.*>$/\1/'`
CPUTIME=`printf "%.0f" $(grep checkpoint_cpu_time $SLOTSDIR/$PROC/boinc_task_state.xml | tr -d ' ' | sed 's/^<.*>\([^<].*\)<.*>$/\1/')`
ELAPSEDTIME=`printf "%.0f" $(grep checkpoint_elapsed_time $SLOTSDIR/$PROC/boinc_task_state.xml | tr -d ' ' | sed 's/^<.*>\([^<].*\)<.*>$/\1/')`
PROGRESS=$(echo "`grep fraction_done $SLOTSDIR/$PROC/boinc_task_state.xml | tr -d ' ' | sed 's/^<.*>\([^<].*\)<.*>$/\1/'` * 100" | bc)
REMAINING=`printf "%.0f" $(echo "scale=10;$ELAPSEDTIME * ( 100 / $PROGRESS - 1 )" | bc)`
printf "%02d:%02d:%02d\t" $((CPUTIME/3600)) $((CPUTIME/60%60)) $((CPUTIME%60))
printf "%7.2f%%\t" $PROGRESS
printf "%02d:%02d:%02d\t" $((REMAINING/3600)) $((REMAINING/60%60)) $((REMAINING%60))
echo $RESULTNAME
done
Example output:
> boincstat CPU Time Progress Remaining Task 01:07:34 4.00% 27:22:29 c4cw_target03_102181325_0 01:41:35 6.00% 26:51:08 c4cw_target03_102186623_0 00:58:19 10.53% 08:22:49 X0000085121331200703121820_0 01:47:01 19.48% 07:27:52 X0000085120824200703061109_0