#! /bin/sh
# anders@fupp.net, 2007-09-19
# Shows the number of threads for the varnish child process

case $1 in
autoconf) echo yes;;
config)
	echo 'graph_title Varnish threads'
	echo 'graph_vlabel threads'
	echo 'graph_category varnish'
	echo 'graph_info This graph shows the number of threads for the varnish child process'

	echo 'threads.label threads'
	echo 'threads.type GAUGE'
	echo 'threads.graph yes'
	;;
*)
	vpid=`pgrep -f Varnish-Chld`
	printf "threads.value "
	if [ -z "$vpid" ]
	then
		echo 0
	else
		ps -H -p $vpid | tail +2 | wc -l | awk '{print $1}'
	fi
	;;
esac
