Repository
Munin (contrib)
Last change
2020-10-05
Graph Categories
Capabilities
Keywords
Language
Shell
License
GPL-2.0-only
Authors

bbox

Name

bbox - parse bbox information - https://fr.wikipedia.org/wiki/Bbox

Configuration

The following default configuration is used:

[bbox]
env.IP 192.168.1.254

Authors

Copyright (C) 2018 Steve Schnepp steve.schnepp@pwkf.org

License

GNU Library General Public License v2 only

SPDX-License-Identifier: GPL-2.0-only

#! /bin/sh

: <<=cut

=head1 NAME

bbox - parse bbox information - https://fr.wikipedia.org/wiki/Bbox

=head1 CONFIGURATION

The following default configuration is used:

 [bbox]
 env.IP 192.168.1.254

=head1 AUTHORS

Copyright (C) 2018 Steve Schnepp <steve.schnepp@pwkf.org>


=head1 LICENSE

GNU Library General Public License v2 only

SPDX-License-Identifier: GPL-2.0-only

=cut


# fail on error
set -e

IP=${IP:-"192.168.1.254"}

if [ "$1" = "config" ]
then
	echo multigraph bbox_adsl_bw
	echo graph_title BBox Adsl Bandwidth
	echo graph_category network
	echo up.label UpStream
	echo down.label DownStream

	echo multigraph bbox_adsl_att
	echo graph_title BBox Adsl Attenuation
	echo graph_category network
	echo up.label UpStream
	echo down.label DownStream

	echo multigraph bbox_adsl_snr
	echo graph_title BBox Adsl SignalNoise Ratio
	echo graph_category network
	echo up.label UpStream
	echo down.label DownStream

	echo multigraph bbox_adsl_pkt
	echo graph_title BBox Adsl Packets
	echo graph_category network
	echo graph_order up down up_f down_f up_c down_c up_u down_u
	echo graph_vlabel packets/\${graph_period}
	echo graph_args --base 1000 --logarithmic --lower-limit 0.001
	echo up.label UpStream
	echo down.label DownStream
	echo up_f.label UpStream "(FEC)"
	echo down_f.label DownStream "(FEC)"
	echo up_c.label UpStream "(CRC)"
	echo down_c.label DownStream "(CEC)"
	echo up_u.label UpStream "(HEC)"
	echo down_u.label DownStream "(HEC)"
	echo up.type DERIVE
	echo down.type DERIVE
	echo up_f.type DERIVE
	echo down_f.type DERIVE
	echo up_c.type DERIVE
	echo down_c.type DERIVE
	echo up_u.type DERIVE
	echo down_u.type DERIVE
	echo up.min 0
	echo down.min 0
	echo up_f.min 0
	echo down_f.min 0
	echo up_c.min 0
	echo down_c.min 0
	echo up_u.min 0
	echo down_u.min 0

	echo multigraph bbox_adsl_bytes
	echo graph_title BBox Adsl Usage
	echo graph_category network
	echo graph_order up down
	echo graph_vlabel bytes/\${graph_period}
	echo graph_args --base 1024 --lower-limit 0
	echo up.label UpStream
	echo up.type DERIVE
	echo down.label DownStream
	echo down.type DERIVE
	echo up.min 0
	echo down.min 0

	echo multigraph bbox_adsl_uptime
	echo graph_title BBox Adsl Uptime
	echo graph_category network
	echo graph_vlabel days
	echo uptime.label Uptime
	echo uptime.cdef uptime,3600,/,24/

	exit 0
fi

TMPFILE="$(mktemp -d)"
trap 'rm -Rf "$TMPFILE"' EXIT

cd "$TMPFILE"

curl -s "http://$IP/api/v1/wan/ip" > "ip.json" &
curl -s "http://$IP/api/v1/wan/ip/stats" > "ip-stats.json" &
curl -s "http://$IP/api/v1/wan/xdsl" > "xdsl.json" &
curl -s "http://$IP/api/v1/wan/xdsl/stats" > "xdsl-stats.json" &

wait

if [ "$MUNIN_DEBUG" = 1 ]
then
	for i in *
	do
		echo "========= $i ========"
		cat "$i"
	done
fi

echo multigraph bbox_adsl_bw
echo up.value $(jq -r ".[].wan.xdsl.up.bitrates" < xdsl.json)
echo down.value $(jq -r ".[].wan.xdsl.down.bitrates" < xdsl.json)

echo multigraph bbox_adsl_att
echo up.value $(jq -r ".[].wan.xdsl.up.attenuation" < xdsl.json)
echo down.value $(jq -r ".[].wan.xdsl.down.attenuation" < xdsl.json)

echo multigraph bbox_adsl_snr
echo up.value $(jq -r ".[].wan.xdsl.up.noise" < xdsl.json)
echo down.value $(jq -r ".[].wan.xdsl.down.noise" < xdsl.json)

echo multigraph bbox_adsl_pkt
echo up.value $(jq -r ".[].wan.ip.stats.tx.packets" < ip-stats.json)
echo down.value $(jq -r ".[].wan.ip.stats.rx.packets" < ip-stats.json)
echo up_f.value $(jq -r ".[].wan.xdsl.stats.remote_fec" < xdsl-stats.json)
echo down_f.value $(jq -r ".[].wan.xdsl.stats.local_fec" < xdsl-stats.json)
echo up_c.value $(jq -r ".[].wan.xdsl.stats.remote_hec" < xdsl-stats.json)
echo down_c.value $(jq -r ".[].wan.xdsl.stats.local_hec" < xdsl-stats.json)
echo up_u.value $(jq -r ".[].wan.xdsl.stats.remote_crc" < xdsl-stats.json)
echo down_u.value $(jq -r ".[].wan.xdsl.stats.local_crc" < xdsl-stats.json)

echo multigraph bbox_adsl_bytes
echo up.value $(jq -r ".[].wan.ip.stats.tx.bytes" < ip-stats.json | tr -d '"')
echo down.value $(jq -r ".[].wan.ip.stats.rx.bytes" < ip-stats.json | tr -d '"')

echo multigraph bbox_adsl_uptime
echo uptime.value $(jq -r ".[].wan.xdsl.showtime" < xdsl.json)

exit 0