Kitz ADSL Broadband Information
adsl spacer  
Support this site
Home Broadband ISPs Tech Routers Wiki Forum
 
     
   Compare ISP   Rate your ISP
   Glossary   Glossary
 
Please login or register.

Login with username, password and session length
Advanced search  

News:

Pages: [1] 2 3 4

Author Topic: Serving (slightly) better stats directly from Zyxel modems  (Read 11003 times)

johnson

  • Reg Member
  • ***
  • Posts: 838
Serving (slightly) better stats directly from Zyxel modems
« on: June 07, 2018, 01:04:47 AM »

Thought I should split this off from the other thread talking about firmware as its so off topic.

Have got a simple webserver compiled and working from boot on a 1312, uses the relatively small mongoose server (160K) with the simplest possible setup, running a script to gather stats and then serving a directory under /var/tmp (from ram).

Code: [Select]
#include "mongoose.h"

static const char *s_http_port = "8000";
static struct mg_serve_http_opts s_http_server_opts;

static void ev_handler(struct mg_connection *nc, int ev, void *p) {
  if (ev == MG_EV_HTTP_REQUEST) {
    system("/var/tmp/stats/./getstats.sh");
    mg_serve_http(nc, (struct http_message *) p, s_http_server_opts);
  }
}

int main(void) {
  struct mg_mgr mgr;
  struct mg_connection *nc;

  mg_mgr_init(&mgr, NULL);
  printf("Starting web server on port %s\n", s_http_port);
  nc = mg_bind(&mgr, s_http_port, ev_handler);
  if (nc == NULL) {
    printf("Failed to create listener\n");
    return 1;
  }

  // Set up HTTP server parameters
  mg_set_protocol_http_websocket(nc);
  s_http_server_opts.document_root = "/var/tmp/stats/";  // Serve current directory
  s_http_server_opts.enable_directory_listing = "yes";

  for (;;) {
    mg_mgr_poll(&mgr, 1000);
  }
  mg_mgr_free(&mgr);

  return 0;
}


Arbitrary commands can be placed in "getstats.sh" and their outputs are accessible on routerip:8000.

Not any better than the xDSL Statistics section of the normal GUI except for being able to gather SNR/QLN etc. These could be made into pretty graphs client side, but taking a stab with 5 minutes of googling javascript plotting has only resulted in ugly graphs covered in tooltips and other pointless stuff. If anyone knows of an ultra lightweight plotting library for js that would be great.


This is in no way meant to even remotely compete with the other excellent stats monitoring tools available, but I though it would be nice to be able to glance at things like SNR per tone, bitloading etc from a URL served by the modem itself. I guess a small log of other data could work, like the last 24 hours SNR graph or similar.

Totally stupid idea? Probably! But its fun to play with these things. 
« Last Edit: June 07, 2018, 01:06:49 AM by johnson »
Logged

banger

  • Kitizen
  • ****
  • Posts: 1186
  • TTB 80/20
Re: Serving (slightly) better stats directly from Zyxel modems
« Reply #1 on: June 07, 2018, 03:12:29 AM »

Good work. :)
Logged
Tim
talktalkbusiness.net & freenetname
Asus RT-AC68U and ZyXEL VMG1312-B10A Bridge on 80 Meg TTB Fibre

https://www.thinkbroadband.com/speedtest/1502566996147131655

burakkucat

  • Respected
  • Senior Kitizen
  • *
  • Posts: 38300
  • Over the Rainbow Bridge
    • The ELRepo Project
Re: Serving (slightly) better stats directly from Zyxel modems
« Reply #2 on: June 07, 2018, 05:14:07 PM »

Totally stupid idea? Probably! But its fun to play with these things.

No, not stupid by any means. Quite an interesting idea.

What might be worthwhile would be to "serve up" the data used to create the four snapshot plots (Bit Loading, Hlog, QLN & SNR) and the data returned by "info --pbParams" & "info --stats".
Logged
:cat:  100% Linux and, previously, Unix. Co-founder of the ELRepo Project.

Please consider making a donation to support the running of this site.

johnson

  • Reg Member
  • ***
  • Posts: 838
Re: Serving (slightly) better stats directly from Zyxel modems
« Reply #3 on: June 08, 2018, 02:45:03 AM »

Got to messing with chart.js this evening and have some reasonable looking graphs, was starting to try and implement a nice way of choosing ranges, pbParams should work well for selected a sensible range as well separating upload and download sections of SNR/bitloading. But it occurred to me, does pbParams even work with ADSL? How about lines without G.INP, are they missing the whole "Bearer 1" line? If so just using offsets to get to the right data isnt going to work.

So I guess I could go digging through posts to find examples of xdslctl output for various lines and probably should. But can anyone with an ADSL line or VDSL without G.INP provide a few outputs? E.g. --pbParams, the first 10 or so lines of --SNR or --Bits or --Hlog (I assume they are the same).

Much appreciated if anyone can be bothered!  :D
Logged

Weaver

  • Senior Kitizen
  • ******
  • Posts: 11459
  • Retd s/w dev; A&A; 4x7km ADSL2 lines; Firebrick
Re: Serving (slightly) better stats directly from Zyxel modems
« Reply #4 on: June 08, 2018, 11:12:28 AM »

pbParams does not work on my ADSL line that has no G.INP (but does we think have Broadcom PhyR their proprietary equivalent)
Logged

roseway

  • Administrator
  • Senior Kitizen
  • *
  • Posts: 43467
  • Penguins CAN fly
    • DSLstats
Re: Serving (slightly) better stats directly from Zyxel modems
« Reply #5 on: June 08, 2018, 11:36:20 AM »

For the various ADSL flavours there are only two sets of tones - a range for upstream starting at near to 0, and the remainder for downstream starting at different points depending on the spcific protocol. Look at this article for the details. In the UK only Annex A and Annex M need to be considered.
Logged
  Eric

johnson

  • Reg Member
  • ***
  • Posts: 838
Re: Serving (slightly) better stats directly from Zyxel modems
« Reply #6 on: June 08, 2018, 11:58:06 AM »

Input from the maestro! Thanks for the the links and info, sure I can concoct some ADSL detection and apply the right ranges then.

OT, but I'd really like to thank you for DSLstats, its an invaluable tool. 
Logged

spring

  • Reg Member
  • ***
  • Posts: 342
Logged
No one knows what is the taste of the void.

johnson

  • Reg Member
  • ***
  • Posts: 838
Re: Serving (slightly) better stats directly from Zyxel modems
« Reply #8 on: June 08, 2018, 06:16:22 PM »

pbParams does not work on my ADSL line that has no G.INP (but does we think have Broadcom PhyR their proprietary equivalent)

Thank you!

The output of xdslctl --SNR or --Bits would still be useful Weaver, only the first 10 or so lines down to where the tones/values start.
Logged

Weaver

  • Senior Kitizen
  • ******
  • Posts: 11459
  • Retd s/w dev; A&A; 4x7km ADSL2 lines; Firebrick
Re: Serving (slightly) better stats directly from Zyxel modems
« Reply #9 on: June 09, 2018, 04:59:35 PM »

@johnson no luck with xdslctl --SNR or -Bits on my VMG 1312-B10A with your second firmware - jumbo + updated low-level driver BLOB.
Logged

burakkucat

  • Respected
  • Senior Kitizen
  • *
  • Posts: 38300
  • Over the Rainbow Bridge
    • The ELRepo Project
Re: Serving (slightly) better stats directly from Zyxel modems
« Reply #10 on: June 09, 2018, 07:01:45 PM »

Here follows my list of "useful commands" for a VMG1312-B10A device --

xdslctl info --state
xdslctl info --show
xdslctl info --stats
xdslctl info --SNR
xdslctl info --QLN
xdslctl info --Hlog
xdslctl info --Hlin
xdslctl info --HlinS
xdslctl info --Bits
xdslctl info --pbParams
xdslctl info --linediag
xdslctl info --linediag1
xdslctl info --vendor
xdslctl info --cfg
xdslctl info --webstats
xdslctl info --vectoring
xdslctl profile --show
xdslctl --version


I have deliberately emboldened two of the lines . . .  ;)
Logged
:cat:  100% Linux and, previously, Unix. Co-founder of the ELRepo Project.

Please consider making a donation to support the running of this site.

Weaver

  • Senior Kitizen
  • ******
  • Posts: 11459
  • Retd s/w dev; A&A; 4x7km ADSL2 lines; Firebrick
Re: Serving (slightly) better stats directly from Zyxel modems
« Reply #11 on: June 09, 2018, 09:20:22 PM »

Ah, I got the syntax wrong: it requires the word "info" not just a -parameter. Bits and SNR are below:
Code: [Select]
VMG1312-B10A
Login: admin
Password:
 > xdslctl info --Bits
xdslctl: ADSL driver and PHY status
Status: Showtime
Last Retrain Reason:    8000
Last initialization procedure status:   0
Max:    Upstream rate = 440 Kbps, Downstream rate = 3152 Kbps
Bearer: 0, Upstream rate = 496 Kbps, Downstream rate = 2861 Kbps

Tone number      Bit Allocation
   0            0
   1            0
   2            0
   3            0
   4            0
   5            0
   6            0
   7            8
   8            9
   9            10
   10           10
   11           9
   12           9
   13           9
   14           9
   15           8
   16           8
   17           8
   18           8
   19           7
   20           7
   21           7
   22           7
   23           7
   24           6
   25           6
   26           6
   27           6
   28           5
   29           5
   30           5
   31           4
   32           0
   33           8
   34           8
   35           9
   36           10
   37           10
   38           11
   39           11
   40           11
   41           11
   42           11
   43           11
   44           11
   45           11
   46           11
   47           11
   48           11
   49           11
   50           2
   51           11
   52           11
   53           11
   54           11
   55           11
   56           11
   57           11
   58           11
   59           11
   60           11
   61           11
   62           11
   63           11
   64           11
   65           11
   66           11
   67           10
   68           10
   69           11
   70           10
   71           10
   72           10
   73           10
   74           8
   75           9
   76           9
   77           10
   78           9
   79           10
   80           10
   81           9
   82           9
   83           9
   84           9
   85           9
   86           9
   87           9
   88           9
   89           8
   90           8
   91           8
   92           8
   93           8
   94           8
   95           8
   96           7
   97           8
   98           7
   99           7
   100          7
   101          7
   102          7
   103          7
   104          7
   105          7
   106          6
   107          6
   108          6
   109          6
   110          6
   111          6
   112          6
   113          6
   114          5
   115          5
   116          5
   117          5
   118          5
   119          5
   120          4
   121          4
   122          4
   123          3
   124          0
   125          1
   126          0
   127          2
   128          2
   129          3
   130          3
   131          3
   132          3
   133          3
   134          3
   135          3
   136          3
   137          3
   138          3
   139          3
   140          3
   141          2
   142          2
   143          2
   144          2
   145          2
   146          1
   147          2
   148          2
   149          1
   150          1
   151          1
   152          1
   153          1
   154          1
   155          0
   156          0
   157          0
   158          0
   159          0
   160          0
   161          0
   162          0
   163          0
   164          0
   165          0
   166          0
   167          0
   168          0
   169          0
   170          0
   171          0
   172          0
   173          0
   174          0
   175          0
   176          0
   177          0
   178          0
   179          0
   180          0
   181          0
   182          0
   183          0
   184          0
   185          0
   186          0
   187          0
   188          0
   189          0
   190          0
   191          0
   192          0
   193          0
   194          0
   195          0
   196          0
   197          0
   198          0
   199          0
   200          0
   201          0
   202          0
   203          0
   204          0
   205          0
   206          0
   207          0
   208          0
   209          0
   210          0
   211          0
   212          0
   213          0
   214          0
   215          0
   216          0
   217          0
   218          0
   219          0
   220          0
   221          0
   222          0
   223          0
   224          0
   225          0
   226          0
   227          0
   228          0
   229          0
   230          0
   231          0
   232          0
   233          0
   234          0
   235          0
   236          0
   237          0
   238          0
   239          0
   240          0
   241          0
   242          0
   243          0
   244          0
   245          0
   246          0
   247          0
   248          0
   249          0
   250          0
   251          0
   252          0
   253          0
   254          0
   255          0
 > xdslctl info --QLN
xdslctl: ADSL driver and PHY status
Status: Showtime
Last Retrain Reason:    8000
Last initialization procedure status:   0
Max:    Upstream rate = 440 Kbps, Downstream rate = 3144 Kbps
Bearer: 0, Upstream rate = 496 Kbps, Downstream rate = 2861 Kbps

Tone number      QLN
   0            -150.5000
   1            -150.5000
   2            -150.5000
   3            -150.5000
   4            -150.5000
   5            -150.5000
   6            -150.5000
   7            -150.5000
   8            -150.5000
   9            -150.5000
   10           -150.5000
   11           -150.5000
   12           -150.5000
   13           -150.5000
   14           -150.5000
   15           -150.5000
   16           -150.5000
   17           -150.5000
   18           -150.5000
   19           -150.5000
   20           -150.5000
   21           -150.5000
   22           -150.5000
   23           -150.5000
   24           -150.5000
   25           -150.5000
   26           -150.5000
   27           -150.5000
   28           -150.5000
   29           -150.5000
   30           -150.5000
   31           -150.5000
   32           -150.5000
   33           -124.0000
   34           -127.5000
   35           -130.0000
   36           -132.0000
   37           -133.0000
   38           -135.0000
   39           -136.0000
   40           -136.0000
   41           -136.5000
   42           -136.5000
   43           -136.5000
   44           -137.5000
   45           -137.0000
   46           -137.0000
   47           -137.5000
   48           -137.5000
   49           -137.5000
   50           -137.5000
   51           -138.0000
   52           -138.5000
   53           -138.0000
   54           -138.5000
   55           -139.0000
   56           -140.0000
   57           -139.0000
   58           -137.5000
   59           -138.5000
   60           -140.0000
   61           -139.5000
   62           -140.5000
   63           -140.5000
   64           -141.0000
   65           -141.0000
   66           -141.5000
   67           -141.5000
   68           -142.0000
   69           -143.0000
   70           -142.5000
   71           -142.5000
   72           -142.0000
   73           -143.0000
   74           -137.5000
   75           -141.5000
   76           -142.5000
   77           -143.5000
   78           -144.5000
   79           -145.5000
   80           -145.5000
   81           -145.5000
   82           -145.0000
   83           -145.0000
   84           -145.5000
   85           -146.5000
   86           -146.0000
   87           -146.5000
   88           -146.0000
   89           -146.5000
   90           -146.0000
   91           -146.5000
   92           -146.5000
   93           -146.5000
   94           -147.0000
   95           -146.5000
   96           -147.0000
   97           -148.0000
   98           -147.0000
   99           -148.5000
   100          -148.0000
   101          -147.5000
   102          -148.0000
   103          -147.5000
   104          -147.0000
   105          -148.0000
   106          -148.0000
   107          -148.0000
   108          -148.0000
   109          -148.0000
   110          -147.5000
   111          -148.5000
   112          -148.0000
   113          -148.0000
   114          -148.0000
   115          -148.5000
   116          -148.0000
   117          -148.5000
   118          -148.5000
   119          -147.5000
   120          -147.5000
   121          -148.0000
   122          -146.5000
   123          -144.5000
   124          -143.0000
   125          -137.5000
   126          -136.5000
   127          -143.5000
   128          -145.0000
   129          -145.0000
   130          -146.0000
   131          -147.5000
   132          -148.0000
   133          -148.5000
   134          -149.0000
   135          -149.0000
   136          -148.0000
   137          -148.0000
   138          -148.5000
   139          -149.0000
   140          -149.5000
   141          -149.5000
   142          -149.5000
   143          -149.5000
   144          -149.0000
   145          -149.5000
   146          -149.0000
   147          -149.5000
   148          -149.5000
   149          -150.0000
   150          -149.5000
   151          -149.0000
   152          -149.5000
   153          -149.5000
   154          -149.0000
   155          -149.5000
   156          -150.0000
   157          -149.5000
   158          -149.5000
   159          -149.5000
   160          -149.0000
   161          -148.5000
   162          -149.0000
   163          -149.0000
   164          -149.5000
   165          -149.0000
   166          -149.5000
   167          -149.0000
   168          -149.5000
   169          -149.5000
   170          -150.0000
   171          -149.0000
   172          -149.5000
   173          -148.5000
   174          -150.0000
   175          -149.5000
   176          -149.5000
   177          -148.5000
   178          -149.5000
   179          -149.5000
   180          -149.5000
   181          -149.5000
   182          -149.5000
   183          -149.5000
   184          -149.0000
   185          -150.0000
   186          -149.0000
   187          -148.0000
   188          -142.5000
   189          -149.0000
   190          -150.0000
   191          -149.5000
   192          -149.0000
   193          -149.0000
   194          -149.0000
   195          -149.0000
   196          -147.5000
   197          -149.0000
   198          -149.0000
   199          -149.0000
   200          -149.5000
   201          -148.5000
   202          -148.5000
   203          -149.0000
   204          -148.0000
   205          -148.5000
   206          -148.0000
   207          -148.5000
   208          -149.0000
   209          -147.0000
   210          -148.5000
   211          -147.5000
   212          -148.0000
   213          -149.5000
   214          -150.0000
   215          -149.0000
   216          -146.5000
   217          -148.0000
   218          -149.0000
   219          -148.5000
   220          -148.5000
   221          -149.5000
   222          -149.5000
   223          -149.5000
   224          -148.0000
   225          -148.5000
   226          -146.0000
   227          -148.5000
   228          -149.5000
   229          -149.0000
   230          -149.0000
   231          -148.5000
   232          -148.0000
   233          -149.0000
   234          -148.0000
   235          -147.5000
   236          -144.5000
   237          -149.5000
   238          -149.0000
   239          -147.5000
   240          -149.5000
   241          -149.0000
   242          -148.5000
   243          -149.0000
   244          -149.0000
   245          -148.5000
   246          -147.5000
   247          -149.0000
   248          -149.0000
   249          -146.5000
   250          -148.0000
   251          -150.0000
   252          -149.5000
   253          -149.5000
   254          -148.0000
   255          -148.5000
 > xdslctl info --pbParams
xdslctl: ADSL driver and PHY status
Status: Showtime
Last Retrain Reason:    8000
Last initialization procedure status:   0
Max:    Upstream rate = 440 Kbps, Downstream rate = 3148 Kbps
Bearer: 0, Upstream rate = 496 Kbps, Downstream rate = 2861 Kbps

Currently not in VDSL modulation --pbParams is only for VDSL mode
 > xdslctl info --SNR     
xdslctl: ADSL driver and PHY status
Status: Showtime
Last Retrain Reason:    8000
Last initialization procedure status:   0
Max:    Upstream rate = 440 Kbps, Downstream rate = 3152 Kbps
Bearer: 0, Upstream rate = 496 Kbps, Downstream rate = 2861 Kbps

Tone number      SNR
   0            0.0000
   1            0.0000
   2            0.0000
   3            0.0000
   4            0.0000
   5            0.0000
   6            0.0000
   7            0.0000
   8            0.0000
   9            0.0000
   10           0.0000
   11           0.0000
   12           0.0000
   13           0.0000
   14           0.0000
   15           0.0000
   16           0.0000
   17           0.0000
   18           0.0000
   19           0.0000
   20           0.0000
   21           0.0000
   22           0.0000
   23           0.0000
   24           0.0000
   25           0.0000
   26           0.0000
   27           0.0000
   28           0.0000
   29           0.0000
   30           0.0000
   31           0.0000
   32           0.0000
   33           26.8750
   34           29.5625
   35           32.1875
   36           34.3750
   37           35.6250
   38           36.6250
   39           37.3125
   40           37.8125
   41           38.2500
   42           38.5625
   43           38.7500
   44           39.0000
   45           39.1875
   46           38.4375
   47           39.3125
   48           39.6875
   49           39.4375
   50           37.4375
   51           39.5000
   52           39.2500
   53           39.1875
   54           39.2500
   55           38.7500
   56           38.4375
   57           38.2500
   58           37.1875
   59           36.8125
   60           37.2500
   61           37.5000
   62           37.3750
   63           36.8750
   64           37.0625
   65           36.9375
   66           36.6875
   67           35.7500
   68           35.8750
   69           36.5625
   70           36.3750
   71           35.6250
   72           34.3125
   73           34.5625
   74           28.6875
   75           33.0000
   76           32.6875
   77           34.3750
   78           33.8125
   79           33.8750
   80           33.5625
   81           33.1250
   82           32.6250
   83           32.2500
   84           32.2500
   85           32.0000
   86           31.3750
   87           30.8750
   88           30.7500
   89           30.0625
   90           30.3125
   91           29.8750
   92           29.4375
   93           29.1875
   94           28.9375
   95           28.4375
   96           28.0000
   97           27.7500
   98           27.2500
   99           26.8125
   100          26.6250
   101          26.1875
   102          26.0625
   103          25.6875
   104          24.9375
   105          24.9375
   106          24.4375
   107          24.0000
   108          23.5625
   109          23.0625
   110          22.8750
   111          22.4375
   112          22.0000
   113          21.5625
   114          20.5625
   115          20.8125
   116          20.3750
   117          19.7500
   118          19.6250
   119          19.1875
   120          17.5000
   121          17.1875
   122          16.7500
   123          13.4375
   124          7.1875
   125          8.3750
   126          8.2500
   127          11.7500
   128          10.1250
   129          14.3125
   130          13.1875
   131          14.6250
   132          13.8750
   133          13.8750
   134          13.3125
   135          13.5625
   136          13.1250
   137          12.9375
   138          12.5625
   139          12.2500
   140          12.0000
   141          11.5625
   142          11.7500
   143          11.0625
   144          11.1250
   145          10.6875
   146          10.5625
   147          10.0000
   148          9.6250
   149          9.5625
   150          9.6250
   151          9.1250
   152          9.0000
   153          8.5625
   154          8.3125
   155          0.7500
   156          8.2500
   157          7.6875
   158          7.3750
   159          7.1250
   160          6.8125
   161          4.9375
   162          0.0000
   163          0.0000
   164          0.0000
   165          0.0000
   166          0.0000
   167          0.0000
   168          0.0000
   169          0.0000
   170          0.0000
   171          0.0000
   172          0.0000
   173          0.0000
   174          0.0000
   175          0.0000
   176          0.0000
   177          0.0000
   178          0.0000
   179          0.0000
   180          0.0000
   181          0.0000
   182          0.0000
   183          0.0000
   184          0.0000
   185          0.0000
   186          0.0000
   187          0.0000
   188          0.0000
   189          0.0000
   190          0.0000
   191          0.0000
   192          0.0000
   193          0.0000
   194          0.0000
   195          0.0000
   196          0.0000
   197          0.0000
   198          0.0000
   199          0.0000
   200          0.0000
   201          0.0000
   202          0.0000
   203          0.0000
   204          0.0000
   205          0.0000
   206          0.0000
   207          0.0000
   208          0.0000
   209          0.0000
   210          0.0000
   211          0.0000
   212          0.0000
   213          0.0000
   214          0.0000
   215          0.0000
   216          0.0000
   217          0.0000
   218          0.0000
   219          0.0000
   220          0.0000
   221          0.0000
   222          0.0000
   223          0.0000
   224          0.0000
   225          0.0000
   226          0.0000
   227          0.0000
   228          0.0000
   229          0.0000
   230          0.0000
   231          0.0000
   232          0.0000
   233          0.0000
   234          0.0000
   235          0.0000
   236          0.0000
   237          0.0000
   238          0.0000
   239          0.0000
   240          0.0000
   241          0.0000
   242          0.0000
   243          0.0000
   244          0.0000
   245          0.0000
   246          0.0000
   247          0.0000
   248          0.0000
   249          0.0000
   250          0.0000
   251          0.0000
   252          0.0000
   253          0.0000
   254          0.0000
   255          0.0000
 >
Logged

johnson

  • Reg Member
  • ***
  • Posts: 838
Re: Serving (slightly) better stats directly from Zyxel modems
« Reply #12 on: June 10, 2018, 08:26:12 AM »

Ah, I got the syntax wrong: it requires the word "info" not just a -parameter. Bits and SNR are below:

My bad, sorry for the incomplete command, and thank you for the example outputs.  ;D
Logged

johnson

  • Reg Member
  • ***
  • Posts: 838
Re: Serving (slightly) better stats directly from Zyxel modems
« Reply #13 on: June 14, 2018, 04:53:00 PM »

Bit of keyboard mashing today and have the graphs coming along.
Logged

johnson

  • Reg Member
  • ***
  • Posts: 838
Re: Serving (slightly) better stats directly from Zyxel modems
« Reply #14 on: June 30, 2018, 10:35:42 AM »

So have tried to come up with the most simple way of logging data over time, after getting reacquainted with awk and angry at different line endings:

Code: [Select]
#!/bin/bash

logSize=2879

logFile="/var/tmp/stats/logfile"

statsFile="/var/tmp/stats/varStats"

updateInterval=30


lastFecDown=0
lastFecUp=0
lastCrcDown=0
lastCrcUp=0


while [ 1 ]
do

    xdslctl info --stats > $statsFile

    lineActive=$(awk '/^Status/ {if ($2 == "Showtime") print "true";
                        else print "false";exit}' $statsFile)

    numlines=$(wc -l $logFile | awk '{ print $1 }')
    timeStamp=$(date +"%s")

    if [ $lineActive = "true" ]
    then
        #echo "Got showtime"

        snrValues=$(awk '/^SNR/ {print $3,$4; exit}' $statsFile)
        fecValues=$(awk '/^FEC/ {print $2,$3; exit}' $statsFile)
        crcValues=$(awk '/^CRC/ {print $2,$3; exit}' $statsFile)


        fecDown=$(echo $fecValues | awk '{ print $1 }')
        fecDownDiff=$((fecDown-lastFecDown))
        lastFecDown=$fecDown

        fecUp=$(echo $fecValues | awk -v RS='\r' '{ print $2 }')
        fecUpDiff=$((fecUp-lastFecUp))
        lastFecUp=$fecUp

        crcDown=$(echo $crcValues | awk '{ print $1 }')
        crcDownDiff=$((crcDown-lastCrcDown))
        lastCrcDown=$crcDown

        crcUp=$(echo $crcValues | awk -v RS='\r' '{ print $2 }')
        crcUpDiff=$((crcUp-lastCrcUp))
        lastCrcUp=$crcUp

        if [[ $numlines -gt $logSize ]]
        then
            tail -n +2 $logFile > "${logFile}Tmp" && mv "${logFile}Tmp" $logFile
        fi

        echo "$timeStamp $snrValues $fecValues $crcValues $fecDownDiff $fecUpDiff $crcDownDiff $crcUpDiff" >> $logFile


        sleep $updateInterval

    else

        if [[ $numlines -gt $logSize ]]
        then
            tail -n +2 $logFile > "${logFile}Tmp" && mv "${logFile}Tmp" $logFile
        fi

        echo "$timeStamp NOSYNC" >> $logFile

        sleep $updateInterval
    fi


done
 

Reads xdslctl stats into a file, checks for an active sync then parses out the goodies and writes them to a file. File grows to fixed size, well number of lines - 24hrs of data with 30s readings in this case, then starts removing oldest line and appending new.

Had thought I'd got clever using "sed -i" for inplace removal of the oldest line, but it turns out that it just uses temporary files anyway and its quicker to just use tail and manage the temp file yourself. Would really like to have it do it inplace, maybe something with some meta data at the start of the file with references to the start and end line, maybe something in a real language to make a proper circular buffer. But as this is all in memory copying 100K or so around every 30s doesnt seem like a huge problem.

This still has extraneous data in (the total FEC & CRC rather than just the difference) and a 24hr log sampled every 30s comes in at a smidge over 150K. I have successfully written 10Mbytes to the var/tmp folder on a 1312 with no negative results, so even with the stats server etc there is plenty of room for more monitored values and a longer time period.

Saving old logs to a USB drive is also an easy thing to do, so longer term persistent data could be gathered.

Have run this for 36 hours or so on an 8324 (lots more ram than a 1312) with no ill effects, even while still using DSLStats on another system with the same sample rate. Have just put it together with the stats server and javascript to make the graphs into a firmware and flashed to a 1312 and placed on a live line.

Heres some same output from connection:

Code: [Select]
1528004830 NOSYNC
1528004860 NOSYNC
1528004890 NOSYNC
1528004920 NOSYNC
1528004950 3.6 6.1 1442 0 0 0 1442 0 0 0
1528004981 3.6 6.7 5215 0 0 0 3773 0 0 0
1528005011 3.7 6.8 8394 0 0 0 3179 0 0 0
1528005041 3.7 6.7 12516 0 0 0 4122 0 0 0
1528005071 3.8 6.8 17640 0 0 0 5124 0 0 0
1528005102 3.6 6.8 21211 0 0 0 3571 0 0 0
1528005132 3.8 6.8 26134 0 0 0 4923 0 0 0
1528005162 3.6 6.8 30954 0 0 0 4820 0 0 0
1528005192 3.8 6.7 34950 0 0 0 3996 0 0 0
1528005222 3.6 6.6 38539 0 0 0 3589 0 0 0
1528005252 3.8 6.7 42789 0 0 0 4250 0 0 0
1528005283 3.8 6.7 47399 0 0 0 4610 0 0 0
1528005313 3.8 6.7 51470 0 0 0 4071 0 0 0
1528005343 3.8 6.8 55014 0 0 0 3544 0 0 0
1528005373 3.7 6.7 59714 0 0 0 4700 0 0 0
1528005403 3.8 6.8 64423 0 0 0 4709 0 0 0
1528005434 3.8 6.6 68081 0 0 0 3658 0 0 0
1528005464 3.8 6.8 72278 0 0 0 4197 0 0 0
Logged
Pages: [1] 2 3 4