Questions and Answers :
Unix/Linux :
BOINC stater (MRTG,...)
Message board moderation
Author | Message |
---|---|
shtrom Send message Joined: 16 Nov 00 Posts: 4 Credit: 90,509 RAC: 0 |
Hi ! I've just finished a general script to get information about the current slots status for any BOINC project (using client_state.xml). It has been designed for use with MRTG, but I hope it is clear enough to be easily adapted. The client_state.xml file is processed using xsltproc with a specific stylesheet to extract pertinent information. boinc-stat.sh -------------------->8----[ Cut Here ]---------------- #!/bin/bash # boinc-stat.sh # Copyright (C) 2005 Olivier Mehani # # This script uses a processed version (see boinc-stat.xsl) of the # client_stat.xml data file to report the current activity in one BOINC slot. # # Usage: boinc-stat.sh SLOT # Example: # $ ./boinc-stat.sh 2 # 29.381600 &2 exit 1 fi slot=$1 mydir=`dirname $0` function get_cpu() { sum="0" for pid in `ps --no-headers -o pid -C $1`; do if ls -l "/proc/$pid/cwd" 2>/dev/null | grep -q "slots/$slot"; then sum="$sum + `ps --noheaders -o %cpu --pid $pid`" fi done echo "scale=4; $sum" | $bc -q } if [ -e $boincdir/client_state.xml ]; then out=`$xsltproc --param slot $slot $mydir/boinc-stat.xsl $boincdir/client_state.xml` if echo $out | grep -q "master_url"; then prog=`echo $out | sed -e "s-.*\(.*\).*-scale=4;100*\1-" | bc -q` app=`echo $out | sed -e "s-.*\(.*\).*-\1-"` sched_state=`echo $out|sed -e "s-.*\(.*\).*-\1-"` cpu=`get_cpu $app` echo $prog echo $cpu else echo 0 echo 0 fi else echo 0 echo 0 fi $uptime | $sed -e "s/.*up *//" -e "s/, *[0-9]\+ user.*//" $hostname -------------------->8----[ Cut Here ]---------------- boinc-stat.xsl -------------------->8----[ Cut Here ]---------------- This stylesheet is intented to extract interesting information from BOINC's client_state.xml about one specific slot. example: $ xsltproc - param slot 0 boinc-stat.xsl /usr/local/boinc/client_state.xml http://setiathome.berkeley.edu/ setiathome_4.02_i686-pc-linux-gnu 0 1 0.669996 $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --> -------------------->8----[ Cut Here ]---------------- Enjoy ;) -- Olivier Mehani |
shtrom Send message Joined: 16 Nov 00 Posts: 4 Credit: 90,509 RAC: 0 |
OK... I think I is not possible to put XML into posts. I made the two files available here: http://shtrom.ssji.net/boinc/mrtg/ -- Olivier Mehani |
©2024 University of California
SETI@home and Astropulse are funded by grants from the National Science Foundation, NASA, and donations from SETI@home volunteers. AstroPulse is funded in part by the NSF through grant AST-0307956.