#!/bin/sh
#
# Folding@Home
#
# Parameters:
#
#   config   (required)
#   autoconf (optional - only used by munin-config)
#
# Magic markers (optional - used by munin-config and some installation
# scripts):
#%# family=contrib
#%# capabilities=autoconf

FOLDING_PATH=/usr/local/fah
data_filename=$FOLDING_PATH/${file:-unitinfo.txt}

if [ "$1" = "autoconf" ]; then
    if [ -r "$data_filename" ]; then
        echo yes
    else
        echo "no (F@H file '$data_filename' not found)"
    fi
    exit 0
fi

if [ "$1" = "config" ]; then

    echo 'graph_title Folding@Home'
    echo 'graph_args -l 0 --base 1000'
    echo 'graph_category htc'
    echo 'graph_vlabel % finished'
    echo 'done.label done folding'
    echo 'done.type GAUGE'
    echo 'done.max 100'
    exit 0
fi

grep "Progress" "$data_filename" | /bin/sed 's/^.*: \(.*\)%.*/done.value \1/'
