| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- use Modern::Perl;
- use utf8;
- use telnet;
- use Exporter;
- our @ISA= qw( Exporter );
- our @EXPORT = qw( onu_cdata );
- async onu_cdata => sub
- {
- my $ip = shift;
- my $login = shift;
- my $password = shift;
- my $tree = shift;
- my $t = new telnet($ip);
- # $t->debug(1);
- await $t->connect;
- await $t->reply(qr/User name:/, $login);
- await $t->reply(qr/User password:/, $password);
- $t->print("enable");
- await $t->waitfor("#");
- $t->prompt(qr/#\s?$/);
- await $t->cmd("config");
- await $t->cmd("vty output show-all");
- $t->print("interface epon 0/0");
- $t->prompt(qr/#\s?$/);
- my @lines = await $t->cmd("show ont info $tree all");
- my $onu_count_line = @lines[@lines-3];
- $onu_count_line =~ m|Total: (\d+), online (\d+)|;
- my $total_onu_cnt = $1;
- my $online_onu_cnt = $2;
- my $offline_onu_cnt = $total_onu_cnt - $online_onu_cnt;
- $t->close;
- if ($lines[2] =~ /Error/) {
- $total_onu_cnt = 0;
- $online_onu_cnt = 0;
- $offline_onu_cnt = 0;
- }
- my $res = "Всего: $total_onu_cnt
- Количество активных ONU: $online_onu_cnt
- Количество неактивных ONU: $offline_onu_cnt
- \n";
- return $res;
- };
- 1;
|