#!/bin/sh


hostname="$(hostname)"

if [ "$1" = "config" ]; then
	echo "host_name $hostname"
	echo "graph_order down up"
	echo "graph_title ADSL Traffic"
	echo 'graph_args --base 1000'
	# shellcheck disable=SC2016
	echo 'graph_vlabel bits in (-) / out (+) per ${graph_period}'
	echo 'graph_category network'
	echo 'down.label received'
	echo 'down.type DERIVE'
	echo 'down.graph no'
	echo 'down.cdef down,8,*'
	echo "down.max $DOWNMAX"
	echo "down.min 0"
	echo 'up.label bps'
	echo 'up.type DERIVE'
	echo 'up.negative down'
	echo 'up.cdef up,8,*'
	echo "up.max $UPMAX"
	echo "up.min 0"
	exit 0
fi

printf "down.value "
snmpget -Ov "$hostname" "$COMMUNITY" interfaces.ifTable.ifEntry.ifInOctets.3 | sed 's/^.*: //'
printf "up.value "
snmpget -Ov "$hostname" "$COMMUNITY" interfaces.ifTable.ifEntry.ifOutOctets.3 | sed 's/^.*: //'
