#!/bin/sh

# Copyright (c) 2010 Bernd Zeimetz <bzed@debian.org>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.


PATH=/bin:/sbin:/usr/bin:/usr/sbin
export PATH

if [ "$1" = "config" ]; then
        echo graph_title cable modem signal to noise ratio
        echo 'graph_args --base 1000'
        echo 'graph_vlabel dB'
        echo 'graph_category network'
        echo 'graph_info This graph shows the signal to noise ratio of the Scientific-Atlanta cable modem.'
        echo "signalnoise.label ratio"
        echo "signalnoise.info Signal to noise ratio"
        echo 'signalnoise.draw LINE2'
        echo 'signalnoise.type GAUGE'
        exit 0
fi
wget -q -O - http://192.168.100.1/system.asp |\
     grep 'Signal to Noise' | \
     sed 's,.*&nbsp;,signalnoise.value ,;s, dB.*,,'