-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate.web.ajOnuGraph.pl
More file actions
100 lines (89 loc) · 2.83 KB
/
create.web.ajOnuGraph.pl
File metadata and controls
100 lines (89 loc) · 2.83 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
96
97
98
99
100
#<ACTION> file=>'web/ajOnuGraph.pl',hook=>'new'
# -------------------------- NoDeny --------------------------
# Created by Redmen for NoDeny (https://nodeny.com.ua)
# https://forum.nodeny.com.ua/index.php?action=profile;u=1139
# https://t.me/MrMethod
# ------------------------------------------------------------
# Info: PON monitor ONU graph
# NoDeny: rev. 718
# Update: 2025.11.01
# ------------------------------------------------------------
use strict;
use Time::localtime;
sub go {
my $domid = ses::input('domid');
push @$ses::cmd, {
id => 'a_onu_graph',
data => _proc_onu_list($_[0]),
};
}
sub _proc_onu_list {
my ($Url) = @_;
my $onu = ses::input('sn');
my $time = ses::input_exists('tm_stat') ? ses::input_int('tm_stat') : $ses::t;
my $title = the_date($time);
my $_tbl_name_template = 'z%d_%02d_%02d_pon';
my $t = localtime($time);
my ($day_now, $mon_now, $year_now) = ($t->mday, $t->mon, $t->year);
my $pon_tbl_name = sprintf $_tbl_name_template, $year_now+1900, $mon_now+1, $day_now;
debug $pon_tbl_name;
my $pointsrx = [];
my $pointstx = [];
my $series = [];
my $min_y = 0;
my $DB;
if ($cfg::ponmon_db_name) {
my $timeout = $cfg::ponmon_db_timeout || 10;
my $db = Db->new(
host => $cfg::ponmon_db_host,
user => $cfg::ponmon_db_login,
pass => $cfg::ponmon_db_password,
db => $cfg::ponmon_db_name,
timeout => $timeout,
tries => 2,
global => 0,
pool => [],
);
$db->connect;
$DB = $db if $db->is_connected;
}
$DB = Db->self unless $DB;
$DB->do("DELETE FROM $pon_tbl_name WHERE `rx` IS NULL AND `rx` IS NULL");
my $db = $DB->sql("SELECT * FROM $pon_tbl_name WHERE sn=? ORDER BY time ASC", $onu);
my ($rx, $tx) = 0;
while (my %p = $db->line) {
#next if $p{rx} eq '';
#next if $p{tx} eq '';
$rx = $p{rx} if $p{rx} ne '';
$tx = $p{tx} if $p{tx} ne '';
#$rx = $p{rx} ? $p{rx} : $rx;
#$tx = $p{tx} ? $p{tx} : $tx;
push @$pointsrx, { x=>$p{time}*1000, y=>$rx };
push @$pointstx, { x=>$p{time}*1000, y=>$tx };
$min_y = $p{rx} if $p{rx} < $min_y;
$rx = $p{rx};
$tx = $p{tx};
}
push @$series, {
points => $pointstx,
name => 'TX',
color => 'red',
num => int(scalar @$series)
};
push @$series, {
points => $pointsrx,
name => 'RX',
color => 'blue',
num => int(scalar @$series)
};
return 'Not found' if !scalar @$series;
return render_template(
'onu_graph',
locale => $cfg::Lang,
title => $title,
x_title => $lang::lbl_time,
y_title => 'dBi',
series => $series
);
}
1;