BOINC and SETI@Home Data Output with Conky
Posted by Hodge on Mar 11, 2008 in Conky, Programming, Technology, Ubuntu • 5 comments •
Since my previous article about Conky, Conky on Ubunty 64 Bit – .conkyrc, I’ve been playing around with trying to get Conky to output some BOINC (SETI@Home data), and through a little digging, found a couple of very useful resources. The first being BOINC’s own client_status.xml file, located on Ubunutu in /var/lib/boinc-client/client_status.xml, which contains a lot of information about BOINC projects, Work Units, Status and so on. The second being a command line application, again built into BOINC – boinc_cmd. boinc_cmd can be executed with a bunch of parameters, such as –get_simple_gui_info and –get_project_status which output to the Terminal a lot of information about Projects and Work Units.
To output BOINC data via Conky, it’s possible to call the boinc_cmd in .conkyrc and strip down the information with grep and sed etc:
${execi 10 boinc_cmd --get_simple_gui_info | grep -m 1 "fraction done:" | tail -n 1 - | sed -e 's/ fraction done: //'}
${execi 10 boinc_cmd --get_simple_gui_info | grep -m 2 "fraction done:" | tail -n 1 - | sed -e 's/ fraction done: //'}
…and so on for each piece of data required for output, but this is pretty labourious, and makes for a rather ugly .conkyrc, so I’ve written a really quick and dirty Perl Script (it’s not pleasant to look at, and needs a LOT of work, so it’s more of a pre Alpha-Alpha! I’m not sure how, or if it will work with multiple projects, since I only have SETI@HOME installed…) – which actually retrieves all the data from the client_status.xml file. The (archived) script, boinc.pl can be downloaded here (and viewed below – just copy and paste the text into a file, and save it as “boinc.pl” if the download doesn’t work for you). It’s also posted over at the Ubuntu Forums. I’ve called it in .conkyrc by adding one simple line:
BOINC:
${color lightgrey}${execi 10 perl ~/ConkyScripts/boinc/boinc.pl}
OK, so that’s actually two lines, but the first line doesn’t really do anything except output the text “BOINC:” to Conky, so it doesn’t count – but it’s much cleaner than potentially dozens of lines, right? The script itself is in my ~/ConkyScripts/boinc directory and has been made executable:
sudo chmod a+x boinc.pl
Here’s the script so far – it’s VERY much Work In Progress, but it outputs the data as shown in the image above:
Edit 15/03/08: I’ve updated the code, so hopefully it’ll work with multiple projects:
#!/usr/bin/perl
$BoincStatePath="/var/lib/boinc-client";
$BoincClientStateFile="client_state.xml";
$StateFile="$BoincStatePath/$BoincClientStateFile";
open(INFO, $StateFile);
@lines = <INFO>;
close(INFO);
sub strip_tags($);
sub convert_time_to_string($);
sub estimate_time_remaining;
$projectCount = 0;
$wuCount = 0;
$wuActive = 0;
$wuActiveTask = 0;
foreach $line (@lines) {
if ($line =~ /<master_url>/) {
$projectMasterURL[$projectCount] = strip_tags($line);
}
if ($line =~ /<project_name>/) {
$projectName[$projectCount] = strip_tags($line);
$projectCount++;
}
if ($line =~ /<workunit>/) {
$wuCount++;
}
if ($line =~ /<active_task_state>1/) {
$wuActive++;
}
if ($line =~ /<active_task>/) {
$wuActiveTask++;
}
if ($line =~ /<result_name>/) {
$wuName[$wuActiveTask] = strip_tags($line);
}
if ($line =~ /<fraction_done>/) {
$wuPercent[$wuActiveTask] = strip_tags($line) * 100;
}
if ($line =~ /<project_master_url>/) {
$wuMasterURL[$wuActiveTask] = strip_tags($line);
}
if ($line =~ /<current_cpu_time>/) {
$wuCPUTime[$wuActiveTask] = convert_time_to_string(strip_tags($line));
$wuCPUTimeRaw[$wuActiveTask] = strip_tags($line);
}
}
print "No. Work Units: ".$wuCount.", Active WU: ".$wuActive."n";
for($i = 0; $i <= $projectCount; ++$i) {
print $projectName[$i];
for ($j = 1; $j <= $wuActiveTask; ++$j) {
if($projectMasterURL[$i] eq $wuMasterURL[$j]) {
print "WU ".$j.": ".$wuName[$j];
$estTime = convert_time_to_string(estimate_time_remaining($wuCPUTimeRaw[$j],$wuPercent[$j]));
print "CPU Time: ".$wuCPUTime[$j]." Time Remaining: ".$estTime."n";
print $wuPercent[$j]."% Completen";
}
}
}
sub strip_tags($) {
my $string = shift;
$string =~ s/<(.*?)>//gi;
$string =~ s/ //gi;
return $string;
}
sub convert_time_to_string($) {
$cpuTime = int($_[0]);
#Calculate the number of days
if ($cpuTime > 86400) {
$timeDays = $cpuTime/(24*60*60).":";
} else {
$timeDays = "";
}
#Calculate the number of hours and minutes
$timeHours = ($cpuTime/(60*60))%24;
$timeMinutes = ($cpuTime/60)%60;
$timeSeconds = $cpuTime%60;
$cpuTimeString = $timeDays.$timeHours.":".$timeMinutes.":".$timeSeconds;
return $cpuTimeString;
}
sub estimate_time_remaining {
$cpuTime = $_[0];
$currentPercent = $_[1];
$onePercentTime = $cpuTime/$currentPercent;
$totalTime = $onePercentTime * 100;
$estimatedTimeReminaing = $totalTime - $cpuTime;
return $estimatedTimeReminaing;
}
Something not quite right? Inaccuracies or invalid code? Didn’t work for you? Don’t like me using Ss instead of Zs? Add a comment below! All comments are welcome. Except spam, because spam is a bit crap.
|
|
Seis De Mayo $4.29 It wasn’t long after the recording of this, Trey Anastasio’s third–and most warmly idiosyncratic–solo album, that the Phish frontman/guitarist announced that his improvisation-fueled, cult-fave band would record no more. Longtime Phish-heads (or admirers of Anastasio’s previous free-form jazz excursions with Les Claypool and Stewart Copeland and more conventional solo work) may find this ambitio… |
|
|
Sapphire Video Card 100314-3l Hd 6870 1gb Ddr5 256bit Pci Express D-Dvi/Hdmi/Display Port Retail $222.69 PCI Express based PC is required with one X16 lane graphics slot available on the motherboard.4X75 Watt 6-pin PCI Express power connector is required for CrossFireX system.2X75 Watt 6-pin PCI Express power connector is required.1024MBMinimum of system memory.Installation software requires CD-ROM drive.DVD playback requires DVD drive.Blu-ray/HD DVD playback requires Blu-ray/HD DVD drive.Blu-ray/HD … |
|
|
Smallest Bluetooth 2.0 Adapter Dongle (Vista/Windows XP Compatible) $0.01 Synchronize wirelessly your Blackberry, iPhone, Palm, Razr, any other Bluetooth compatible cell phones and handheld devices…. |
|
|
Alfa 1000mW 1W 802.11b/g USB Wireless WiFi Network Adapter With Original Alfa Screw-On Swivel 9dBi Rubber Antenna $34.99 The Alfa AWUS036H is the latest version of the most powerful card available. This has a stunning 1000mW output power. So if you are looking for a device to connect to an outdoor 2.4 GHz antenna, such as on a boat or an RV, this is a perfect solution. It outperforms wireless cards that are built in to newer laptops. Adding this to your laptop or desktop computer will enhance range and signal qualit… |
|
|
Rocketfish Rf-Mrbtad Micro Bluetooth Adapter $7.99 Add Bluetooth compatibility to your laptop with this convenient and compact micro USB adapter. Connectivity: USB ; Colour: Black ; System Requirements: Window 2000, XP, Vista ; Included In Box: Manual, CD driver, Dongle ; Product Height: 0.2″ ; Product Width: 0.6″ ; Product Weight: 0.1 oz. ; Product Depth: 0.8″… |
No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.





Okay, first off, great script. Just thought you might like to know its behavior when you have multiple projects running. It works, and shows all running WUs, however the project name field is taken by whichever project is last in the client_state file. Thanks for the script (its a heck of a lot more then I could have done)
The update is PERFECT! Thank you very much, having conky monitor BOINC is a lot more convenient than keeping BOINC manager open.
Thanks for the feedback Revenant – I’m glad it helped you out!
[...] I’ve also recently written a Perl script, which allows BOINC data to be viewed via Conky. See my recent post on BOINC and SETI@Home with Conky, on Ubuntu. [...]
Hello,
Great idea, I posted suggestions on ubuntu forums. Take a look at it
Thanks for your work anyway.