#!/bin/sh
#
# Script to monitor LRRD-graph
#
# Parameters understood:
#
# 	config   (required)
# 	autoconf (optional - used by lrrd-config)
#
# $Log: lrrd_graph.in,v $
# Revision 1.6  2003/11/10 18:13:46  jimmyo
# Revert changes done in 1.5
#
# Revision 1.5  2003/11/07 17:43:16  jimmyo
# Cleanups and log entries
#
#
#
# Magic markers (optional - used by lrrd-config and installation
# scripts):
#
#%# family=manual
#%# capabilities=autoconf

if [ ! "$GRAPH_STATSFILE" ] ; then
	GRAPH_STATSFILE=/var/lib/lrrd/lrrd-graph.stats
fi

if [ "$1" = "autoconf" ]; then
	echo no
	exit 1
fi

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

	echo 'graph_title LRRD-graph'
	echo 'graph_vlabel seconds'
	[ -f $GRAPH_STATSFILE ] || exit 0
	cat $GRAPH_STATSFILE | grep "GD" | while read i; do
		name=`echo $i | cut -d"|" -f2 |tr  '.-' '__'`
		echo -n "$name.label "
		echo $i | cut -d"|" -f2
		echo "$name.warning 100"
		echo "$name.critical 179"
	done
	exit 0
fi

[ -f $GRAPH_STATSFILE ] || exit 0
cat $GRAPH_STATSFILE | grep "GD" | while read i; do
        name=`echo $i | cut -d"|" -f2 | tr  '.-' '__'`
	echo -n "$name.value "
	echo $i | cut -d"|" -f3
done
