#!/bin/sh

case $1 in
   config)
        cat <<'EOM'
graph_title Huawei B315s Signal strength
graph_info Huawei B315s Signal strength
graph_vlabel signal
graph_category huawei
rsrq.label rsrq
rsrq.type GAUGE
rsrq.min 0
rsrp.label rsrp
rsrp.type GAUGE
rsrp.min 0
rssi.label rssi
rssi.type GAUGE
rssi.min 0
sinr.label sinr
sinr.type GAUGE
sinr.min 0
EOM
        exit 0;;
esac

wget -q http://192.168.43.1/html/home.html -O /dev/null --save-cookies /tmp/cookie --keep-session-cookies
echo -n 'rsrq.value -'
wget -qO- http://192.168.43.1/api/device/signal --load-cookies /tmp/cookie |grep rsrq | grep -o '[0-9]*'
echo -n 'rsrp.value -'
wget -qO- http://192.168.43.1/api/device/signal --load-cookies /tmp/cookie |grep rsrp | grep -o '[0-9]*'
echo -n 'rssi.value -'
wget -qO- http://192.168.43.1/api/device/signal --load-cookies /tmp/cookie |grep rssi | grep -o '[0-9]*'
echo -n 'sinr.value '
wget -qO- http://192.168.43.1/api/device/signal --load-cookies /tmp/cookie |grep sinr  | grep -o '[0-9]*'