• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login
Netgate Discussion Forum
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login

Logging & graphing ADSL router linestats

Scheduled Pinned Locked Moved General pfSense Questions
1 Posts 1 Posters 492 Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R
    rmdashrf
    last edited by May 9, 2016, 8:10 AM

    Hi everyone.

    In pfsense 2.3, is it possible to add custom data points in Status -> Monitor?

    Currently I'm monitoring traffic and quality (x and y axis) but I'd also like the option to monitor line stats captured from my ADSL router.  I'm fairly new to pfSense - especially 2.3's new graphing system.

    If anyone's interested, here's the code I cobbled together for my Netgear DGN2200m v2 ADSL router that runs every 5mins on my Linux server.  You will of course need to tweak it for your own router.  For example my Netgear doesn't require a login for telnet (lame!) - I've also modified it so that telnet starts after a power cycle.

    Note: I'm pretty lame at coding/scripting I'm just sharing this in case it is useful to someone.

    
    #!/bin/bash
    rip=192.168.0.253
    rtmp=/tmp/adslstats.tmp
    log=/var/log/routerstats.log
    
    (
    sleep 2;
    echo -e "adsl info --stats\r";
    sleep 3;
    echo -e "exit\r"
    ) | telnet $rip >$rtmp
    
    clean=$"tr -d '\040\011\012\015'"				  # Cleanup whitespace, tabs, ^M etc
    mode=$(cat $rtmp |gawk '/Mode:/ {print $2}' |$clean )             # ADSL mode
    synd=$(cat $rtmp |gawk '/Bearer/ {print $11}'|$clean )	          # Downstream Rate
    synu=$(cat $rtmp |gawk '/Bearer/ {print $6}'|$clean )             # Upstream Rate
    attd=$(cat $rtmp |gawk '/Attn/ {print $2}'|$clean )               # Downstream Attenuation
    attu=$(cat $rtmp |gawk '/Attn/ {print $3}'|$clean )               # Upstream Attenuation
    snrd=$(cat $rtmp |gawk '/SNR/ {print $3}'|$clean )                # Downstream Signal to Noise
    snru=$(cat $rtmp |gawk '/SNR/ {print $4}'|$clean )                # Upstream Signal to Noise
    pwrd=$(cat $rtmp |gawk '/Pwr/ {print $2}'|$clean )                # Downstream Line Power
    pwru=$(cat $rtmp |gawk '/Pwr/ {print $3}'|$clean )                # Upstream Line Power
    crcd=$(cat $rtmp |gawk '/CRC/ {print $2}'| sed -n '2p' |$clean )  # CRC Errors Down captured in last 15 mins
    crcu=$(cat $rtmp |gawk '/CRC/ {print $3}'| sed -n '2p' |$clean )  # CRC Errors Up captured in last 15 mins
    fecd=$(cat $rtmp |gawk '/FEC/ {print $2}'| sed -n '2p' |$clean )  # FEC Errors Down captured in last 15 mins
    fecu=$(cat $rtmp |gawk '/FEC/ {print $3}'| sed -n '2p' |$clean )  # FEC Errors Up captured in last 15 mins
    esd=$(cat $rtmp |gawk '/ES/ {print $2}'| sed -n '1p' |$clean )    # Error Seconds Down 
    esu=$(cat $rtmp |gawk '/ES/ {print $3}'| sed -n '1p' |$clean )    # Error Seconds Up
    hecd=$(cat $rtmp |gawk '/HEC/ {print $2}'| sed -n '1p' |$clean )  # Header Error Check/Correction Down
    hecu=$(cat $rtmp |gawk '/HEC/ {print $3}'| sed -n '1p' |$clean )  # Header Error Check/Correction Up
    lcdd=$(cat $rtmp |gawk '/LCD/ {print $2}'| sed -n '1p' |$clean )  # Lost Cell Delineation Down
    lcdu=$(cat $rtmp |gawk '/LCD/ {print $3}'| sed -n '1p' |$clean )  # Lost Cell Delineation Up
    when=$(date +"%m-%d-%y-%T")
    
    hdrfmt='%17s%-8s%6s%6s%6s%6s%6s%6s%6s%6s%6s%6s%8s%8s%8s%8s%8s%8s%8s%8s\n'
    logfmt='%17s%-8s%6s%6s%6s%6s%6s%6s%6s%6s%6s%6s%8s%8s%8s%8s%8s%8s%8s%8s\n'
    
    #printf $hdrfmt "Datetime" "MODE" "SYNC D" "SYNC U" "ATT D" "ATT U" "SNR D" "SNR U" "PWR D" "PWR U" "CRC D" "CRC U" "FEC D" "FEC U" "ES D" "ES U" "HEC D" "HEC U" "LCD D" "LCD U" >>$log
    printf $logfmt "$when" "$mode" "$synd" "$synu" "$attd" "$attu" "$snrd" "$snru" "$pwrd" "$pwru" "$crcd" "$crcu" "$fecd" "$fecu" "$esd" "$esu" "$hecd" "$hecu" "$lcdd" "$lcdu" >>$log
    
    rm $rtmp
    
    
    1 Reply Last reply Reply Quote 0
    1 out of 1
    • First post
      1/1
      Last post
    Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.
      This community forum collects and processes your personal information.
      consent.not_received