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:

Author Topic: Line stats monitoring - DrayTek Vigor 130?  (Read 6648 times)

hyeung

  • Member
  • **
  • Posts: 20
Line stats monitoring - DrayTek Vigor 130?
« on: November 18, 2017, 12:45:58 PM »

Hi,

Anyone help advise me on the monitoring of line stats for the Vigor 130? Is it possible?
Previously used RouterStats on Netgears router/modem without issue. But having a hard time figuring out how to do the same on a DrayTek Vigor 130?

Any advice?

Cheers
Logged

smf22

  • Member
  • **
  • Posts: 48
Re: Line stats monitoring - DrayTek Vigor 130?
« Reply #1 on: November 18, 2017, 12:54:52 PM »

Not being able to easily monitor is one of the reasons I moved away from the Draytek. Whilst I was using it I wrote some plugins for munin so if you've a host, munin is one option.

I'd posted some comments on this recently from Reply #156 of My line might have issues?
Logged
BT FTTC 80/20 Huawei Cab - Zyxel VMG8924-B10A bridge mode + Ubiquiti EdgeRouter X

adrianw

  • Reg Member
  • ***
  • Posts: 163
Re: Line stats monitoring - DrayTek Vigor 130?
« Reply #2 on: February 26, 2020, 03:04:56 PM »

I have written a Perl script (attached) which interrogates my Draytek Vigor 130 every minute and dumps information from vdsl stats and vdsl stats more into a .csv file.
It runs on FreeBSD, invoked every minute via a cron job as vigor_stats.pl --auto. This writes a header line if the daily .csv file does not yet exist, and always writes a data line.
It will probably run on any UNIX-like system.
It might run on Cygwin.
It might even run with Strawberry Perl on Windows.
You will probably need to install some CPAN modules - trying to run the script or compile it with perl -wc will fail when a used module is missing.
The first bit of Perl I have written in 4 years!

Darn, can't attach a .pl file, so here it is inline.

Code: [Select]
#!/usr/bin/env perl
use Modern::Perl '2020';
use autodie;
use Getopt::Long qw(HelpMessage);
use DateTime    ();
use Net::Telnet ();

GetOptions(
    "debug"    => \( my $debug  = 0 ),
    'modem=s'  => \( my $modem  = '192.168.0.1' ),
    'user=s'   => \( my $user   = 'admin' ),
    'passwd=s' => \( my $passwd = 'admin' ),
    "auto"     => \( my $auto   = 0 ),
    "prefix=s" => \( my $prefix = '~/vigor_stats/' ),
    "fields"   => \( my $fields = 0 ),
    "header"   => \( my $header = 0 ),
    "data"     => \( my $data   = 0 ),
    'help' => sub { HelpMessage(0) },
) or HelpMessage(0);
HelpMessage(1) unless ( $modem && $user && $passwd );
HelpMessage(1) unless ( $auto || $fields || $data || $header );
HelpMessage(1) if ( $fields && ( $data || $header || $auto ) );
HelpMessage(1) if ( $auto   && !$prefix );

my @wanted = (    # fields output in this order

    'Running Mode',
    'State',
    'DS Actual Rate',
    'US Actual Rate',
    'DS Attainable Rate',
    'US Attainable Rate',
    'DS Path Mode',
    'US Path Mode',
    'DS Interleave Depth',
    'US Interleave Depth',
    'NE Current Attenuation',
    'Cur SNR Margin',
    'NE CRC Count',
    'FE CRC Count',
    'NE ES Count',
    'FE ES Count',
    'Xdsl Reset Times',
    'Xdsl Link Times',
    'Far Current Attenuation',
    'Far SNR Margin',
    'NE_ReTxEnable',
    'FE_ReTxEnable',
    'NE_LOS',
    'FE_LOS',
    'NE_LOF',
    'FE_LOF',
    'NE_LPR',
    'FE_LPR',
    'NE_LOM',
    'FE_LOM',
    'NE_NCD',
    'FE_NCD',
    'NE_LCD',
    'FE_LCD',
    'NE_FECS',
    'FE_FECS',
    'NE_ES',
    'FE_ES',
    'NE_SES',
    'FE_SES',
    'NE_LOSS',
    'FE_LOSS',
    'NE_UAS',
    'FE_UAS',
    'NE_HECError',
    'FE_HECError',
    'NE_CRC',
    'FE_CRC',
    'NE_INP',
    'FE_INP',
    'NE_InterleaveDelay',
    'FE_InterleaveDelay',
    'DSLAM CHIPSET VENDOR',
    'NE_Trellis',
    'FE_Trellis',
    'NE_Bitswap',
    'FE_Bitswap',
    'NE_20BitSupport',
    'FE_20BitSupport',
    'NE_LatencyPath',
    'FE_LatencyPath',
    'NE_VirtualNoise',
    'FE_VirtualNoise',
    'NE_SosSuccess',
    'FE_SosSuccess',
    'NE_RsCorrection',
    'FE_RsCorrection',
    'DS actual PSD',
    'US actual PSD',
    'NE_NFEC',
    'FE_NFEC',
    'NE_RFEC',
    'FE_RFEC',
    'NE_LSYMB',
    'FE_LSYMB',
    'NE_INTLVBLOCK',
    'FE_INTLVBLOCK',
    'NE_AELEM',
    'CO ITU Version[0]',
    'CO ITU Version[1]',
    'ITU Version[0]',
    'ITU Version[1]',
    'VDSL Firmware Version',
    'Power Management Mode',
    'Test Mode',

    #   'FE_AELEM',

);

my $dt  = DateTime->now;
my $now = $dt->datetime . "Z";    # ISO GMT date
my $ymd = $dt->ymd;               # date

my %data;                         # key field name value field content
my @fields;                       # field names found in input

my $t = new Net::Telnet(
    Prompt  => '/> /',
    Timeout => 10,
);
$t->open($modem);
$t->waitfor('/account:/i');
$t->print($user);
$t->waitfor('/password:/i');
$t->print($passwd);
$t->waitfor('/> /');

foreach my $section ( 'vdsl status', 'vdsl status more' ) {
    foreach my $line ( $t->cmd($section) ) {
        $line =~ s/\s+/ /g;                   # compress white space
        $line =~ s/ (bps|dB|\(.*\))//g;       # simplify
        $line =~ s/( \d+)\. +(\d+)/$1.$2/g;   # remove spaces in numbers
        $line =~ s/^ *(.*) $/$1/;             # remove white space start and end
        next unless $line =~ m/:/;
        ($debug) && say( STDERR "$section: '$line'" );
        if ( $section eq "vdsl status" ) {
            if ( $line =~ m/^(.*) : (\S*) *(.*) : (.*)$/ ) {
                ($debug) && say( STDERR "'$1' = '$2'" );
                $data{$1} = $2;
                ($debug) && say( STDERR "'$3' = '$4'" );
                $data{$3} = $4;
                push( @fields, $1, $3 );
            }
            elsif ( $line =~ m/^(.*) : (.*)$/ ) {
                ($debug) && say( STDERR "'$1' = '$2'" );
                $data{$1} = $2;
                push( @fields, $1 );
            }
            next;
        }
        if ( $section eq "vdsl status more" ) {
            if ( $line =~ m/^(.*) : (\S*) *(\S*)$/ ) {
                ($debug) && say( STDERR "'NE_$1' = '$2'" );
                $data{"NE_$1"} = $2;
                ($debug) && say( STDERR "'FE_$1' = '$3'" );
                $data{"FE_$1"} = $3;
                push( @fields, "NE_$1", "FE_$1" );
            }
        }
    }
}
$t->print('exit');

if ($debug) {
    foreach my $item ( sort keys %data ) {
        my $value = $data{$item};
        say( STDERR"data '$item' = '$value'" );
    }
}

if ($fields) {
    foreach my $item (@fields) {
        say("#   '$item',");
    }
    exit(0);
}

if ($auto) {
    my $file = glob("$prefix$ymd.csv");    # accepts ~ !
    if ( -e $file ) {
    }
    else {
        $header++;
    }
    $data++;
    open( my $fh, '>>:encoding(UTF-8)', $file );
    select($fh);
}

if ($header) {
    say( join( ",", $now, @wanted ) );
}

if ($data) {
    my @cells = ($now);
    foreach my $item (@wanted) {
        die("field $item not extracted") unless ( exists $data{$item} );
        push( @cells, $data{$item} );
    }
    say( join( ",", @cells ) );
}

=head1 NAME

vigor_stats.pl - extract stats from a Vigor 130

$Header: /home/aw1/vigor/RCS/vigor_stats.pl,v 1.1 2020/02/26 01:37:00 aw1 Exp aw1 $

=head1 SYNOPSIS

  --modem      Modem IP or name
  --user       Modem username
  --passwd     Modem password

  --auto       Output to file with prefix and automatic filename
               May not be used with --data --header or --fields
  --prefix     File prefix

  --data       Extract data as CSV to STDOUT
  --header     Extract header as CSV to STDOUT

  --fields     Extract names of all fields to STDOUT
               may not be used with --data or --header

Normal use
vigor_stats.pl --auto

=cut
Logged

graemev

  • Member
  • **
  • Posts: 10
Re: Line stats monitoring - DrayTek Vigor 130?
« Reply #3 on: June 20, 2020, 10:23:53 AM »

I have written a Perl script (attached) which interrogates my Draytek Vigor 130 every minute and dumps information
Thanks @adrianw . This pretty much fits the bill for what I need write now. I've a Vigor 2860 , and  Debian box as a firewall plugged into it.

[ Maybe I can offer up the list of CPAN modules , when I give it a go ]

My Perl is about the same age, we must have retired at the same time :-)
Logged

graemev

  • Member
  • **
  • Posts: 10
Re: Line stats monitoring - DrayTek Vigor 130?
« Reply #4 on: June 20, 2020, 04:22:04 PM »

OK, it's running. It's clear the vigor 2860 and the 130 produce slightly different messages (format).
The box I'm running it on is not a development box, so I try to keep packages at the "standard" level , in this case, ones in the Debian stretch repos , so I had to take a few liberties. I selected 2017 (vs 2020) as the modern Perl generation , I'm hoping there's nothing  newer than Perl 5.24  ? I also used the pre-existing Debian packages rather than using CPAN.

--------------- cut here ----------------

These Debian packages:
Code: [Select]
3 matches for "apt-get install" in buffer: getting-vigor_stats_running.txt
      4:root@zbox:~# apt-get install libmodern-perl-perl
     57:root@zbox:~# apt-get install libdatetime-perl
    156:root@zbox:~# apt-get install libnet-telnet-perl


Code: [Select]
$ diff vigor_stats.pl.orig vigor_stats.pl
2c2
< use Modern::Perl '2020';
---
> use Modern::Perl '2017';
6a7
> use File::Path qw(make_path);
14c15
<     "prefix=s" => \( my $prefix = '~/vigor_stats/' ),
---
>     "prefix=s" => \( my $prefix = '~/vigor_stats' ),
46a48
>
77,78c79,80
<     'NE_InterleaveDelay',
<     'FE_InterleaveDelay',
---
>     'NE_INTLVDelay',
>     'FE_INTLVDelay',
92,93c94,96
<     'NE_RsCorrection',
<     'FE_RsCorrection',
---
> # Not on virgor 2860
> #    'NE_RsCorrection',
> #    'FE_RsCorrection',
119a123
> my $dir;                          # To make intermediate dirs for prefix
186c190,192
<     my $file = glob("$prefix$ymd.csv");    # accepts ~ !
---
>     $dir=glob("$prefix");
>     make_path($dir);
>     my $file = glob("$prefix/$ymd.csv");    # accepts ~ !
235a242
>
Logged

adrianw

  • Reg Member
  • ***
  • Posts: 163
Re: Line stats monitoring - DrayTek Vigor 130?
« Reply #5 on: June 22, 2020, 12:07:14 AM »

The latest Perl version is 5.30.3. I am running 5.30.2. Your Perl 5.24 is a couple of years old.
But, if it works it does not matter.
Logged

graemev

  • Member
  • **
  • Posts: 10
Re: Line stats monitoring - DrayTek Vigor 130?
« Reply #6 on: June 29, 2020, 03:00:37 PM »

OK , 3rd attempt ...my posts are getting lost ...I'm guessing it's the attempt to attach an image ...so sadly not here

-------------

Huum, my post got lost

-----

I'm apparently running 5.28:

This is perl 5, version 28, subversion 1 (v5.28.1) built for x86_64-linux-gnu-thread-multi
(with 61 registered patches, see perl -V for more detail)



It's just Modern::Perl 2017  was the latest available on Debian:Stretch and it related to 5.24.

I came here to try to post some images generated via your tool  ...it's proving harder than I'd like
« Last Edit: June 29, 2020, 03:14:46 PM by graemev »
Logged

graemev

  • Member
  • **
  • Posts: 10
Re: Line stats monitoring - DrayTek Vigor 130?
« Reply #7 on: June 29, 2020, 03:13:27 PM »

OK, tried to include a hyperlink, this post got lost AGAIN ...so I guess I'll just need to make it text and you'll need to hand edit to use

link

[Moderator edited to create the above link.]
« Last Edit: June 29, 2020, 05:21:55 PM by burakkucat »
Logged

graemev

  • Member
  • **
  • Posts: 10
Re: Line stats monitoring - DrayTek Vigor 130?
« Reply #8 on: July 01, 2020, 11:19:07 AM »

ABTW, just stumbled upon cricket:

http://cricket.sourceforge.net/

(It's in the standard Debian repos)
Logged
 

anything