BOINC

Author Andrew Rankin
Compatibility Xymon 4.2
Requirements Perl, Date::Format, Linux
Download http://eiknet.com/bb-boinc.pl.bz2
Last Update 2007-09-26

Boinc Monitoring script - This is for monitoring the boinc (Berkeley Open Infrastructure for Network Computing, http://boinc.berkeley.edu/). Assuming you have your client setup for RPC, you can use the boinc_cmd command to check current status. This script uses the output from that command to create output for hobbit.

Client side

- Install bb-boinc.pl into the <client_root>/ext/ directory - Modify bb-boinc.pl setting the hostname, domain, hobbit_server, boinc_passwd, bbtmp & bbhome variables - Modify your clientlaunch.cfg, adding:

  [boinc]
          ENVFILE $HOBBITCLIENTHOME/etc/hobbitclient.cfg
          CMD $HOBBITCLIENTHOME/ext/bb-boinc.pl
          LOGFILE $HOBBITCLIENTHOME/logs/hobbitclient.log
          INTERVAL 5m

Server side

- For NCV Graphs:

  1. hobbitgraph.cfg, add:
    [boinc]
            TITLE Average BOINC Credit for USER
            YAXIS Credit
            DEF:credit=boinc.rrd:userexpavgcredit:AVERAGE
            LINE2:credit#00CC00:Average User Credit
            GPRINT:credit:LAST: \: %5.1lf (cur)
            GPRINT:credit:MAX: \: %5.1lf (max)
            GPRINT:credit:MIN: \: %5.1lf (min)
            GPRINT:credit:AVERAGE: \: %5.1lf (avg)\n
    
    [boinc1]
            TITLE Total BOINC Credit for USER
            YAXIS Credit
            DEF:credit=boinc.rrd:usertotalcredit:AVERAGE
            LINE2:credit#00CC00:Total User Credit
            GPRINT:credit:LAST: \: %5.1lf (cur)
            GPRINT:credit:MAX: \: %5.1lf (max)
            GPRINT:credit:MIN: \: %5.1lf (min)
            GPRINT:credit:AVERAGE: \: %5.1lf (avg)\n
  2. hobbitserver.cfg, you'll be modifying TEST2RRD and GRAPHS and adding a variable named NCV_boinc:
    TEST2RRD="[...],boinc=ncv"
    GRAPHS="[...],boinc"
    NCV_boinc="*:GAUGE,name:NONE,masterURL:NONE,user_name:NONE,team_name:NONE"
  3. bb-hosts, add the following to add the boinc info to the trends coloumn:
    TRENDS:*,[...],boinc:boinc|boinc1

bb-boinc.pl

Show Code ⇲

Hide Code ⇱

#!/usr/bin/perl -w
#############################################################################
#
# Written by Andrew Rankin (andrew [at] eiknet.com)
# boinc client monitoring script
#
#############################################################################
use strict;
 
## variables 
##############################################################################
my $bbtmp = '/usr/lib64/hobbit/client/tmp';
my $bbhome = '/usr/lib64/hobbit/client';
my $bbtest = 'boinc';
my $boinc_passwd = 'PASSWD';
my $hobbit_server = 'server.domain.com';
my $machine = "machine,domain,com"; # Use commas not periods
my $boinc_path = "/usr/bin"; #path to your BOINC install
 
## BB and related test constants
#############################################################################
 
use constant GREEN  => 'green';
use constant YELLOW => 'yellow';
use constant RED    => 'red';
 
#############################################################################
{
    my $DATA = "";
    my $color = GREEN;
    my $status = 'boinc OK';
    my %project_info;
 
## Get Main Project Info
    my $boinc_output = `$boinc_path/boinc_cmd --passwd $boinc_passwd --get_state 2>&1`;
 
    if($boinc_output =~ m/Connection refused/g){
	$color = RED;
	$status = 'boinc NOT RUNNING';
    }
    elsif($boinc_output =~ m/Authorization failure/g){
	$color = RED;
        $status = 'boinc ERROR';
    }
    else {
	my @boinc_sections = split(/======== .* ========/, $boinc_output);
	my ($projects,$crap) = split(/GUI URL:/, $boinc_sections[1], 2);
	$projects =~ s/\'//g;
	$projects =~ s/1\) -----------\n//g;
 
	my @project_lines = split(/\n/,$projects);
	foreach my $line (@project_lines){
	    chomp($line);
	    my ($key,$value) = split /: /, $line,2;
	    next if !$key or !$value;
	    $key =~ s/ //g;
 
	    # rid us of horrid decimal places
	    if($key =~ m/(resourceshare|user_total_credit|user_expavg_credit|host_total_credit|host_expavg_credit|diskusage|lastRPC|projectfilesdownloaded)/){
		$value = int($value);
	    }
	    # change yes/no to 1/0
	    if($value =~ m/no/i){
		$value = 0;
	    }
	    if($value =~ m/yes/i){
		$value = 1;
	    }
 
	    $project_info{$key} = $value;
	    $DATA .= "$key: $value\n";
	}
    }
 
##########################################
    my $report_date = `date`;
 
    system("$bbhome/bin/bb $hobbit_server 'status $machine.$bbtest $color $report_date - $status\n\n$DATA'\n");
}
 
#############################################################################
  • Andrew Rankin
  • 2007-09-26
    • Initial release
  • monitors/boinc.txt
  • Last modified: 2009/11/23 05:36
  • (external edit)