#!/bin/bash
#
# toshiba_5520c_byfunction_fullcolor_ munin grabber script
# 2009.01 by steve@kosada.com

destination=`basename $0 | sed 's/^toshiba_5520c_byfunction_fullcolor_//g'`

if [ "$1" = "config" ]; then
	echo "graph_title Toshiba 5520C: Full Color Pages (by function)"
	echo 'graph_vlabel Pages'
	echo 'graph_args --lower-limit 0'
	echo 'graph_category printing'

	echo "fullColorPrintComputer.label Print from Computer"
	echo "fullColorPrintComputer.draw AREA"

	echo "fullColorScanNetwork.label Scan to Network"
	echo "fullColorScanNetwork.draw STACK"

	echo "fullColorPrintCopy.label Print: Copy"
	echo "fullColorPrintCopy.draw STACK"
else
	infopage=`wget -q -O - http://$destination:8080/TopAccess/Counter/TotalCount/List.htm | dos2unix | perl -p -e 's/\n/ /m'`

	echo fullColorPrintCopy.value		`echo $infopage | perl -p -e 's/^.+\<B\>Print Counter\<\/B\>.+?\{Full\ Color\,([0-9]+).+$/$1/'`
	echo fullColorPrintComputer.value	`echo $infopage | perl -p -e 's/^.+\<B\>Print Counter\<\/B\>.+?\{Full\ Color(\,[0-9\-]+){2}\,([0-9]+).+$/$2/'`
	echo fullColorScanNetwork.value		`echo $infopage | perl -p -e 's/^.+\<B\>Scan Counter\<\/B\>.+?\{Full\ Color\,[0-9]+\,([0-9]+).+$/$1/'`
fi
