Skip to content

Instantly share code, notes, and snippets.

@squarewf
squarewf / !ZyXEL VGM1312-B30A DSL line statistics collectd exec script.txt
Last active Apr 3, 2021
ZyXEL VGM1312-B30A DSL line statistics collectd exec script
View !ZyXEL VGM1312-B30A DSL line statistics collectd exec script.txt
This script retrieves DSL line statistics from a ZyXEL VGM1312-B30A modem, reformats them into usable values and offers them to collectd. It can be directly executed by collectd-exec.
It uses nc (netcat) in lieu of telnet since OpenWrt does not come with a telnet client by default. Naturally it requires telnet access to be enabled on the modem, and the modem to be reachable from the router. Configuration of modem address and login credentials is at the top of the script.
Tested on OpenWrt 19.03.3 with, obviously, a ZyXEL VGM1312-B30A.
It may work with other broadcom-based modems, but may require adjusting the retrieval process.
# Updated 2020-08-21: - Replaced SNR with SNR *margin* (i.e. SNR - Attn)
# Updated 2020-09-24: - Reverted to directly use SNR value (Broadcom's nomenclature is a bit confusing)
@squarewf
squarewf / rrdbackup
Last active Jun 13, 2021
OpenWrt /etc/init.d/ script to backup and restore the rrd (collectd) database, to preserve data across reboots
View rrdbackup
#!/bin/sh /etc/rc.common
# OpenWrt /etc/init.d/ script to backup and restore the rrd (collectd) database, to preserve data across reboots
#
#
# howto:
# - upload this file as /etc/init.d/rrdbackup
# - (optional) adjust BACKUP_DIR below to point to a different target directory for the backup (e.g., a USB drive)
# - # chmod +x /etc/init.d/rrdbackup
# - # /etc/init.d/rrdbackup enable
@squarewf
squarewf / collectd-get-lantiqdsl-values
Last active May 7, 2021
set of scripts to collect Lantiq DSL line values via collectd-mod-exec
View collectd-get-lantiqdsl-values
#!/bin/sh
[ -f /lib/functions/lantiq_dsl.sh ] && . /lib/functions/lantiq_dsl.sh || exit 0
HOSTNAME=$(cat /proc/sys/kernel/hostname)
VALUESFILE=/tmp/collectd-lantiqdsl-values
dsl_val() {
echo $(expr "$1" : '.*'$2'=\([-\.[:alnum:]]*\).*')