Collectd-mod-exec script to retrieve DSL values from ZyXEL VMG1312 modem

Just out of curiosity, did you consider using snmp (that might be more widely available)?

It is mostly specific to the output of the Broadcom xdslctl utility which delivers a certain output. Chances are it will work for other Broadcom-based modems, but I have no way of knowing that.

To be clear: None of what I am doing here is rocket surgery, it's just a shell script retrieving the output from the modem and some parsing into usable values. The point of releasing it to the public is ... to save someone the time to do it themselves, or even just as a pointer how to parse values from a multi-line file.

xdslctl output is very standard (unless the oem modify it)
@slh snmp most of the time is bugged on this broadcom platform... (problem with driver updating the stats in the right time)

Honestly, I did not. Partly because I wanted to go about it with what is built into default OpenWrt (hence netcat and not some installable telnet client), partly because I am utterly unfamiliar with SMNP.

1 Like

Simple Network Management Protocol ( SNMP ) is one of the oldest (since the 80s) and most widely used Internet Standard protocol for collecting and organizing information about managed devices on IP networks.
With Openwrt you just have to install the SNMP package and you're in business.
Then use the SNMPWALK tool to find what metrics are provided by your device.


The graphs in the screenshot above were built years ago using SNMP metrics retrieved from an ancient Zhone 6211 DSL modem.

1 Like

In the meantime I tried. The ZyXEL VMG1312-B30A does not offer SNMP access (edit: at least not with my firmware, the "SNMP" config screen mentioned in the manual is simply missing, and there is no snmpd running or even to be found anywhere in the file system.)

And even if it did, the snmpwalk output of the related (but not identical) "B10A" variant suggests that it would only expose router-related statistics, not DSL modem statistic.

Also, there is a "dslstats" software to be used with Broadcom modems which ... does exactly what I do: retrieve statistics via telnet. However, the website has a compability list with a bunch of modems where my approach, inelegant as it is, might work too.

I don't own one myself so I can't offer any support for it.
I was just talking about SNMP in general, that it's preferred if available.

I completely understand what you mean, same case with Lantiq based routers with OpenWRT.
I can get the router-related stats via SNMP but not the DSL modem stats, need to use Prometheus node exporter for that.

1 Like

@Ansuel
Have you tried to use this script with a Techicolor (broadcom based) xdsl modem?

I might give it a try at some point but I would also prefer SSH support as my Techicolor modem has SSH running and I can execute xdslinfo commands via SSH...
How collectd needs to be setup or does the script everything on its own?

Then the biggest hurdle is taken. Modify the

xdslinfo=$( ( sleep 2; echo "$MODEM_LOGIN"; sleep 1; echo "$MODEM_PASSWORD"; sleep 1; echo "xdslctl info --stats"; sleep 2; echo "quit") | nc $MODEM_ADDR 23 2>&1 )

line so it receives the output of xdslctl info --stats and puts it into the $xdslinfo variable. The script can probably parse the output right away.

Really, I'm not doing any rocket surgery here, it's just parsing a string into variables that can be shoved into the rrd/collectd database. This is more of an "here's how I did it, it may save you some time, maybe you can use it directly, maybe you can learn from it and adapt it" kind of deal, it's not next-level magic.

As with all collectd-exec scripts: you need collectd-mod-exec installed and have it run the script. I just updated the Gist with a current version of the script, and the exec.lua you can use with luci-app-statistics.

1 Like

nice work. i have a few dlink 520B (broadcom based) and it doesn't seem to expose line stats via SNMP. commands are a bit different to get stats on this platform (adsl info --stats) but looks promising.
this could be a big time saver when troubleshooting multiple lines

edit: on the dlink 520 b, i took a different approach by using curl

curl --silent -v -u user:password http://192.168.0.1/statsadsl.html 2>&1 

this leaves you with html to parse, which might be a caveat of this approach

1 Like

For posterity and public amusement: There seems to be a weird bug in the Zyxel VMG1312 xdslctl tool. I got curious why my uptime graph plateaus like this:

It appears the function in xdslctl that tranforms line uptime seconds to a human-readable string wets the bed and is stuck at either 49 days 17 hours 2 min 45 sec (the value I read and re-parse to seconds) or rolls over zero (in the webstats). Which is ... weird because the device uptime string still updates completely fine. I suspect someone chose a really inappropriate data type somewhere in the postprocessing functions.

xdslctl stats --show still gives a sensible "available seconds" (AS) value, but I'm not sure how closely it relates to the actual line uptime (edit: it might not be related to the continuous uptime at all.) And right now I don't want to reset my line just to check. For the time being, I don't think I will rewrite the parser and I'll just read the graph as "line uptime is great thxbye."

1 Like

Well, that looks like 4 294 965 seconds, which makes me to think that it is a 2^32 overflow bug with milliseconds as the value.
2^32 = 4 294 967 296

2 Likes

hello

Please help me install it. I am noob in Linux
My pi4 is connected with modem in bridge mode and i want to see modem stats in the OpenWrt.

Thank you, :hugs:

I have been using dslstats using telnet in my PC to watch modem stats from time to time. Is this package similar to dslstats?

@anon50098793 this package may work with my modem
and it uses telnet

@takimata
Please add instructions for the noob like me. I have no idea how to add these scripts manually in the openwrt :worried:
Thank you,

any thoughts on making a repo for this?
could be nice to even have it as a .ipk? LuCI package would be nice maybe.

maybe figure out a way to avoid having credentials in plain text (not really an issue for me, but others might dislike)

No. That would involve creating a dedicated collecd plugin and upstreaming it, which is entirely out of the scope of this exercise, at least for me.

That is not possible, the credentials are needed in plain text to authenticate the telnet connection.

gotcha. no worries.

1 Like

After some time (after all it took another 50+ days to get to the point where I would care to look into it again) and observation, the "AS" value is indeed correctly reporting the line uptime. I switched the script to directly using that value now, without any workarounds and re-parsing. The Gist is updated.

Update: I sacrificed my 55+ day line uptime and confirmed that the "AS" value is properly reset when the line resyncs. I'm happy with this update.

So

ssh -oKexAlgorithms=+diffie-hellman-group1-sha1 -c 3des-cbc admin@192.168.10.1

works with open-ssh, and running sh first to start busybox gives a shell that seems to execute xdslctl.
I would not be amazed if the Zyxel actually would be overtaxed with doing ssh, and I do not want to imply ssh should be used instead of netcat; but it might be relevant information for readers of this topic.

1 Like