-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatch.web.ajOnuMenu(Bdcom_epon)_checkInfoOnu.pl
More file actions
95 lines (91 loc) · 3.17 KB
/
patch.web.ajOnuMenu(Bdcom_epon)_checkInfoOnu.pl
File metadata and controls
95 lines (91 loc) · 3.17 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#<ACTION> file=>'web/ajOnuMenu.pl',hook=>'menu_bind', after=>['Ponmon']
push @menuItems, { order => 21, title => L('Інформація'), act=>'checkInfoOnuBdcom' } if lc($p{vendor}) =~ 'bdcom' && (lc($p{model}) =~ '33' || lc($p{model}) =~ m/^p36/i);
#<ACTION> file=>'web/ajOnuMenu.pl',hook=>'subs', after=>['Ponmon']
sub act_checkInfoOnuBdcom {
# 2024.08.31
# https://t.me/MrMethod
my $attr = shift;
my $sn = $attr->{sn};
$sn =~ s/[\:\-\.]//g;
$sn =~ s/(....)(?=.)/$1\./g if $attr->{pon_type} eq 'epon';
$attr->{snx} = $sn;
debug $sn;
my $addr = $attr->{name};
$addr =~ s/[A-Za-z]//mgi;
return $ajax_url->a($lang::btn_Execute, act=>'checkInfoOnuBdcom', go=>1) unless ses::input_int('go');
my $tc = _telnetConnect($attr);
my %resp = ();
my $res = '';
ToLog(L('Запросив Detail Info ОНУ sn=[]', $attr->{sn}));
my $addr = $attr->{name};
$addr =~ s/[A-Za-z]//mgi;
my @output = (_tnCmd($tc, ""));
debug $tc->last_prompt();
if ($tc->last_prompt() =~ /\#\s*/) {
my $cmd_macs = "show epon interface EPON $addr onu mac address-table";
_tnCmd($tc, "");
my @macs = (_tnCmd($tc, $cmd_macs));
foreach my $ln (@macs) {
chomp($ln);
next unless $ln =~ /(([[:xdigit:]]{2}[:\-\.]?){6})/mgi;
debug $ln;
$ln =~ s/.*(([[:xdigit:]]{2}[:\-\.]?){6}).*/$1/gmi;
$ln =~ s/[\:\-\.]//mg;
$ln =~ s/(..)(?=.)/$1:/g;
push @{$resp{macs}}, uc($ln);
}
my $cmd_eth = "show epon interface EPON $addr onu port 1 state";
_tnCmd($tc, "");
my @eth = (_tnCmd($tc, $cmd_eth));
foreach my $ln (@eth) {
chomp($ln);
$ln =~ s/^\s*|\s*$//gmi;
next if $ln =~ /$cmd_eth/i;
next if !$ln;
debug $ln;
push @{$resp{eth}}, $ln;
}
my $cmd_pwr = "show epon interface ePON $addr onu ctc optical-transceiver-diagnosis";
_tnCmd($tc, "");
my @pwr = (_tnCmd($tc, $cmd_pwr));
foreach my $ln (@pwr) {
chomp($ln);
$ln =~ s/^\s*|\s*$//gmi;
next if $ln =~ /$cmd_pwr/i;
next if !$ln;
debug $ln;
push @{$resp{pwr}}, $ln;
}
my $tbl = tbl->new(-class=>'td_wide td_ok fade_border', -row1=>'', -row2=>'');
my $cc = 0;
if (defined $resp{pwr}) {
$tbl->add('', 'L', [ '<hr>' ]);
foreach my $ln (@{$resp{pwr}}) {
$tbl->add('', 'L', $ln);
$cc++;
}
}
if (defined $resp{eth}) {
$tbl->add('', 'L', [ '<hr>' ]);
foreach my $ln (@{$resp{eth}}) {
$tbl->add('', 'L', $ln);
$cc++;
}
}
if (defined $resp{macs}) {
$tbl->add('', 'L', [ '<hr>' ]);
foreach my $ln (@{$resp{macs}}) {
$tbl->add('', 'L', $ln);
$cc++;
}
}
unshift @$ses::cmd, {
id => 'a_onu_info',
data => $tbl->show,
} if $cc;
} else {
$res = "error prompt";
}
_telnetClose($tc);
return $res;
}