Leser: 1
8 Einträge, 1 Seite |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/perl -w
use Net::Telnet::Cisco;
use strict;
my $linec;
my $line;
my $interface;
my $pvc;
my $array;
my $ip;
my $cbr;
my $session = Net::Telnet::Cisco-> new (Host => '10.200.2.100');
$session->login('admin', 'cisco');
# Execute a command
my @output = $session->cmd('show run');
#print @output;
foreach(@output)
{
if ( $_ =~ "interface ATM" ) {
$interface=$_;
chomp($interface);
#print "$_\t";
print" Int:\n $interface \n\n";
}
if ( $_ =~ "pvc"){
$pvc=$_;
chomp($pvc);
#print "$_\t";
print" PVC\t :$_\t\t ";
}
if ( $_ =~ "protocol ip " ){
$ip=$_;
chomp($ip);
#print "$_\t";
print" IP\t :$ip\n";
}
if ( $_ =~ "cbr" ){
$cbr=$_;
chomp($cbr);
#print "$_\t";
#print" CBR|$cbr";
}
#print "Int:$interface | PVC:$pvc | IP:$ip |Cbr:$cbr \n";
# print " Int|PVC |IP|Cbr \n";
#print" $interface |$pvc|$ip|$cbr \t";
}
1
2
3
4
5
6
7
8
9
10
11
12
13
interface ATM1/0
PVC :
pvc 22/180 IP :
protocol ip 10.200.50.81
PVC :
pvc 22/190 IP :
protocol ip 10.200.50.83
PVC :
pvc 22/202 IP : protocol ip 10.200.50.82
PVC :
pvc 122/202 IP :
protocol ip 10.200.51.82
1
2
3
4
5
6
ATM1/0 |PVC | IP
pvc 22/180 10.200.50.81
pvc 22/190 10.200.50.83
pvc 22/202 10.200.50.82
pvc 122/202 10.200.51.82
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/perl -w
use Net::Telnet::Cisco;
use strict;
my $linec;
my $line;
my $interface;
my $pvc;
my $array;
my $ip;
my $cbr;
my $session = Net::Telnet::Cisco-> new (Host => '10.200.2.100');
$session->login('admin', 'cisco');
# Execute a command
my @output = $session->cmd('show run');
my $string = join '',@output;
my @infos = split /interface ATM/,$string;
my %hash;
for my $interface(@infos){
my ($bez) = $interface =~ /^([^\n]+)/;
my @pvcs = $interface =~ /(pvc.*?cbr128)/sg;
for my $pvc(@pvcs){
my ($id,$ip) = $pvc =~ /(pvc\s*[\d\\]+).*?protocol ip((?:\d{1,3}\.){3}\d{1,3})/;
push @{$hash{'ATM'.$bez}}, [$id,$ip];
}
}
for my $atm(keys %hash){
print sprintf("%10s | %10s | %15s",$atm,'PVC','IP');
print sprintf("%10s | %10s | %15s",' ',@$_) for @{$hash{$atm}};
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/perl -w
use Net::Telnet::Cisco;
use strict;
#use Data::Dumper;
my $session = Net::Telnet::Cisco-> new (Host => '10.200.2.100');
$session->login('admin', 'cisco');
# Execute a command
my @output = $session->cmd('show run');
my $string = join '',@output;
my @infos = split /interface ATM/,$string;
shift @infos;
my %hash;
for my $interface(@infos){
my ($bez) = $interface =~ /^([^\n]+)/;
my @pvcs = $interface =~ /(pvc.*?cbr 128)/sg;
for my $pvc(@pvcs){
my ($id,$ip) = $pvc =~ /(pvc\s*[\d\/]+).*?protocol ip ((?:\d{1,3}\.){3}\d{1,3})/s;
push @{$hash{'ATM'.$bez}}, [$id,$ip];
}
}
for my $atm(keys %hash){
print sprintf("%10s | %10s | %15s\n",$atm,'PVC','IP');
print sprintf("%10s | %10s | %15s\n",' ',@$_) for @{$hash{$atm}};
}
print sprintf("%10s | %10s | %15s\n",$atm,'PVC','IP');
8 Einträge, 1 Seite |