parse show adsl perl $port
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 27 Nov 2011 18:28:39 +0000 (19:28 +0100)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 27 Nov 2011 18:28:39 +0000 (19:28 +0100)
lib/H1/ZTEDSLAM.pm

index f304345..c00a4a7 100644 (file)
@@ -103,6 +103,22 @@ sub custom {
                }
        }
 
+       my $out = $self->command_out("show adsl perf $port");
+       my @lines = split(/\s*[\n\r]+/,$out);
+
+       my $table;
+       foreach my $line ( @lines ) {
+               next if ! $line;
+               if ( $line =~ m/ADSL\s+(\w+)\s+Table/i ) {
+                       $table = $1;
+                       next;
+               } elsif ( $line =~ m/^(\S+)\s+:\s+(\S)*$/ ) {
+                       $hash->{ $table . '_' . $1 } = $2 if defined $2;
+               } else {
+                       warn "# IGNORED: $line\n";
+               }
+       }
+
        return $hash;
 }