Message boards : GPUGRID CAFE : Small Bash script to check tasks from Linux console
Author | Message |
---|---|
Hi all, #! /bin/bash # Name: taskinfo # Purpose: Bash script to report information about running BOINC tasks # Creator: Vagelis Giannadakis # Created: 2013-06-04 # I hereby release this script in the Public Domain, you are free to copy, # change, enhance, cripple and distribute in any way you see fit. # Have a sip of your favorite ice-cold Pils / Lager to me, if you find this # script useful! # BOINC home - substitute with your own boincHome="$HOME/BOINC" if [ $# -eq 0 ]; then tasks=`find "$boincHome" -name boinc_task_state.xml` else while [ $# -gt 0 ]; do tasks="$tasks $boincHome/slots/$1/boinc_task_state.xml" shift done fi for task in $tasks; do # Read task info slot=`expr match "$task" "$boincHome/slots/\([0-9]\+\)/boinc_task_state.xml"` taskInfo=`cat $task` # Read task name taskName=`echo $taskInfo|grep -Eo '<result_name>[^<]+</result_name>'|sed -r 's/<result_name>|<\/result_name>//g'` # Parse elapsed time and completion fraction elapsed=`echo $taskInfo|grep -Eo '<checkpoint_elapsed_time>[0-9.]+</checkpoint_elapsed_time>'|grep -Eo '[0-9.]+'` fraction=`echo $taskInfo|grep -Eo '<fraction_done>[0-9.]+</fraction_done>'|grep -Eo '[0-9.]+'` totalH=`echo "scale=2; $elapsed / $fraction / 60 / 60"|bc -l` elapsedH=`echo "scale=2; $elapsed / 60 / 60"|bc -l` percentDone=`echo "scale=2; $fraction * 100"|bc -l` remaining=`echo "scale=2; ($elapsed / $fraction - $elapsed) / 60 / 60"|bc -l` echo "Slot: $slot" echo "Task: $taskName" echo "Elapsed: $elapsedH hours" echo "Percent done: $percentDone" echo "Estimated: $totalH hours" echo "Remaining: $remaining hours" echo "--------------" done You have two ways to use it:
2. With slot numbers separated by spaces ($ taskinfo 1 2). This way, it only prints information about the slots you specified.
vagelis@vgserver:~$ taskinfo Slot: 1 Task: qv143_00076_3 Elapsed: .42 hours Percent done: 12.500000 Estimated: 3.41 hours Remaining: 2.98 hours -------------- Slot: 3 Task: E213664_798_A.33.C26H12OS4Se2.49.3.set1d06_7 Elapsed: 3.61 hours Percent done: 28.700600 Estimated: 12.60 hours Remaining: 8.98 hours -------------- Slot: 0 Task: faah40488_ZINC08739801_1_xPR_wC6_11_1ref9_00_0 Elapsed: .93 hours Percent done: 27.277100 Estimated: 3.43 hours Remaining: 2.49 hours -------------- Slot: 2 Task: I87R7-NATHAN_KIDc22_3-3-8-RND4522_0 Elapsed: 6.94 hours Percent done: 30.834000 Estimated: 22.51 hours Remaining: 15.57 hours -------------- vagelis@vgserver:~$ vagelis@vgserver:~$ taskinfo 2 3 Slot: 2 Task: I87R7-NATHAN_KIDc22_3-3-8-RND4522_0 Elapsed: 7.05 hours Percent done: 31.334000 Estimated: 22.51 hours Remaining: 15.46 hours -------------- Slot: 3 Task: E213664_798_A.33.C26H12OS4Se2.49.3.set1d06_7 Elapsed: 3.61 hours Percent done: 28.700600 Estimated: 12.60 hours Remaining: 8.98 hours -------------- To use, create a new text file with an editor and copy-paste the above into it. Remember to change your BOINC home directory in line 13! Then save (I suggest the file name taskinfo) and make executable (command: chmod +x taskinfo). In my environment, I've placed it in ~/bin/taskinfo. This automatically adds it in the PATH, so I don't have to write its complete name to execute it. The script uses the BOINC file boinc_task_state.xml in the slots to get information about the running tasks. Sometimes, if the task has just started and not recorded its state yet, the file may not be there, so the task won't be reported by the script. Just run the script again in a couple of minutes. The script assumes a linear relationship between elapsed time and percent done, in order to calculate the estimated total time for a task. This doesn't always work correctly for all tasks, so the reported estimated and remaining times may not always be correct. Feel free to enhance the script if you know how to handle such cases! I hope you find this useful and enjoy using! Cheers! Vagelis ____________ | |
ID: 30652 | Rating: 0 | rate: / Reply Quote | |
I've done some enhancements since I first released this and thought I should bring it up to date. So, here goes: #! /bin/bash # Creator: Vagelis Giannadakis # Created: 2013-06-04 # I hereby release this script in the Public Domain, you are free to copy, # change, enhance, cripple and distribute in any way you see fit. # Have a sip of your favorite ice-cold Pils / Lager to me, if you find this # script useful! # BOINC home - substitute with your own boincHome="$HOME/BOINC" if [ $# -eq 0 ]; then tasks=`find "$boincHome" -name boinc_task_state.xml|sort` else while [ $# -gt 0 ]; do tasks="$tasks $boincHome/slots/$1/boinc_task_state.xml" shift done fi for task in $tasks; do # Read task info slot=`expr match "$task" "$boincHome/slots/\([0-9]\+\)/boinc_task_state.xml"` taskInfo=`cat $task` # Read task name taskName=`echo $taskInfo|grep -Eo '<result_name>[^<]+</result_name>'|sed -r 's/<result_name>|<\/result_name>//g'` # Parse elapsed time and completion fraction elapsed=`echo $taskInfo|grep -Eo '<checkpoint_elapsed_time>[0-9.]+</checkpoint_elapsed_time>'|grep -Eo '[0-9.]+'` cpu=`echo $taskInfo|grep -Eo '<checkpoint_cpu_time>[0-9.]+</checkpoint_cpu_time>'|grep -Eo '[0-9.]+'` fraction=`echo $taskInfo|grep -Eo '<fraction_done>[0-9.]+</fraction_done>'|grep -Eo '[0-9.]+'` totalS=`echo "scale=0; $elapsed / $fraction"|bc -l` totalH=`expr $totalS / 60 / 60` totalM=`expr $totalS / 60 - $totalH \* 60` elapsedS=`echo "scale=0; $elapsed / 60 * 60"|bc -l` elapsedH=`expr $elapsedS / 60 / 60` elapsedM=`expr $elapsedS / 60 - $elapsedH \* 60` cpuS=`echo "scale=0; $cpu / 60 * 60"|bc -l` cpuH=`expr $cpuS / 60 / 60` cpuM=`expr $cpuS / 60 - $cpuH \* 60` percentDone=`echo "scale=2; $fraction * 100"|bc -l` remainingS=`echo "scale=0; $elapsedS / $fraction - $elapsedS"|bc -l` remainingH=`expr $remainingS / 60 / 60` remainingM=`expr $remainingS / 60 - $remainingH \* 60` echo "Slot: $slot" echo "Task: $taskName" [ $elapsedH -lt 10 ] && elapsedH="0$elapsedH" [ $elapsedM -lt 10 ] && elapsedM="0$elapsedM" echo "Elapsed: $elapsedH:$elapsedM" [ $cpuH -lt 10 ] && cpuH="0$cpuH" [ $cpuM -lt 10 ] && cpuM="0$cpuM" echo "CPU time: $cpuH:$cpuM" echo "Percent done: $percentDone" [ $totalH -lt 10 ] && totalH="0$totalH" [ $totalM -lt 10 ] && totalM="0$totalM" echo "Estimated: $totalH:$totalM" [ $remainingH -lt 10 ] && remainingH="0$remainingH" [ $remainingM -lt 10 ] && remainingM="0$remainingM" echo "Remaining: $remainingH:$remainingM" echo "--------------" done Example output: vagelis@vgserver:~$ taskinfo 4 Slot: 4 Task: I25R7-NATHAN_KIDKIXc22_1-0-41-RND9457_0 Elapsed: 03:39 CPU time: 03:34 Percent done: 20.416700 Estimated: 17:54 Remaining: 14:13 -------------- vagelis@vgserver:~$ PS: The "code" tag in this forum really sucks! It trims whitespace not only from the beginning / ending of a line, but also from within the line! ____________ | |
ID: 31037 | Rating: 0 | rate: / Reply Quote | |
PS: The "code" tag in this forum really sucks! It trims whitespace not only from the beginning / ending of a line, but also from within the line! I'd go even further and say that this forum software sucks in general. Can't see names of last posts in the forum overview, if there are any new unread posts (you have to go into each sub-forum separately). You cannot delete posts, only hide them, etc. etc. I was thinking of suggesting a switch to another forum software but there is really no-one with the time or willingness to do it at this moment :/ Actually now that I check it looks like it is used by BOINC and provides quite some integration for it so I am guessing it's never going to change :P Good job on the script though! | |
ID: 31038 | Rating: 0 | rate: / Reply Quote | |
I'd go even further and say that this forum software sucks in general. Can't see names of last posts in the forum overview, if there are any new unread posts (you have to go into each sub-forum separately). You cannot delete posts, only hide them, etc. etc. I was thinking of suggesting a switch to another forum software but there is really no-one with the time or willingness to do it at this moment :/ Actually now that I check it looks like it is used by BOINC and provides quite some integration for it so I am guessing it's never going to change :P Yes, unfortunately changing forum software isn't easy.. Just imagine importing all accounts and all posts and all images and, and... At the very least, it's fast! Which is a very important thing! Good job on the script though! Thanks! :) ____________ | |
ID: 31039 | Rating: 0 | rate: / Reply Quote | |
I use to use a square box to represent a space, □, but most people wouldn't get it. | |
ID: 31042 | Rating: 0 | rate: / Reply Quote | |
Message boards : GPUGRID CAFE : Small Bash script to check tasks from Linux console