7 my ( $self, $ip ) = @_;
9 my $t = Net::Telnet->new( Timeout => 10, Prompt => '/#/' );
11 $t->dump_log('/tmp/log') if $ENV{DEBUG};
16 $t->waitfor('/Login:/');
18 $t->waitfor('/Password:/');
22 $t->waitfor('/Please input password:/');
33 my ( $self, $out ) = @_;
36 foreach my $line ( split(/[\n\r]+/, $out) ) {
37 warn "# $line\n" if $ENV{DEBUG};
38 if ( $line =~ m/^(\S+.*?)\s*:\s+(\S+.*)$/ ) {
42 warn "## $n = $v\n" if $ENV{DEBUG};
51 'show interface %s' => [ qw(
56 'show adsl status %s' => [ qw(
59 'show adsl physical %s' => [ qw(
76 my ($self,$port) = @_;
78 my $out = $self->command_out("show interface $port adsl-status");
79 my @lines = split(/\s*[\n\r]+/,$out);
81 shift @lines if $lines[0] =~ m/adsl-status/; # skip command
82 if ( $lines[2] !~ m/^-+$/ ) {
83 warn "Can't parse into table - missing header separator at index 2: $lines[2]";
86 my @h1 = split(/\s+/, $lines[0]);
87 my @h2 = split(/\s+/, $lines[1]);
88 my @v = split(/\s+/, $lines[3]);
91 foreach my $i ( 0 .. $#v ) {
94 $h2[$i] =~ s/\(\w\)\s*$//; # remove unit
96 if ( $h2[$i] =~ m/\// && $v[$i] =~ m/\// ) {
97 my ($ln,$rn) = split(/\//, $h2[$i]);
98 my ($lv,$rv) = split(/\//, $v[$i]);
99 $hash->{ join('_',$k,$ln) } = $lv;
100 $hash->{ join('_',$k,$rn) } = $rv;
102 $hash->{ $h2[$i] ? $h1[$i] .'_'. $h2[$i] : $h1[$i] } = $v[$i];
106 my $out = $self->command_out("show adsl perf $port");
107 my @lines = split(/\s*[\n\r]+/,$out);
110 foreach my $line ( @lines ) {
112 if ( $line =~ m/ADSL\s+(\w+)\s+Table/i ) {
115 } elsif ( $line =~ m/^(\S+)\s+:\s+(\S)*$/ ) {
116 $hash->{ $table . '_' . $1 } = $2 if defined $2;
118 warn "# IGNORED: $line\n";