#!/bin/bash # Dumps DSL speed and connection stats from cisco router # marc_soft@merlins.org 2008/04/10 router=rb-gw pw=`cat ~/rbgw` echo -n "`date '+%Y/%m/%d %H:%M:%S'`: " # I have 2 DSL lines, cycle through them. Same goes if you have more. for i in 0 1 do # capture the lines of output we want, alarm is to cut the connection # after 1sec and avoid a hang set `echo -e "$pw\nshow dsl interface ATM $i\n \n" | alarm 1 nc $router 23 | grep -E '(Noise Margin|Capacity Used|^Speed)'` # output a resulting line (the last cut is to remove a carriage return # otherwise captured in $4, and that -n doesn't strip echo -n "Down$i: ${13}kbps/$7dB/$3 | Up$i: ${15}kbps/$9dB/$(echo $4|cut -c1-3) | " done echo