From owner-svn-ports-all@freebsd.org Fri May 31 12:58:32 2019 Return-Path: Delivered-To: svn-ports-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B2AF615BCE6E; Fri, 31 May 2019 12:58:31 +0000 (UTC) (envelope-from rodrigo@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 54D296C14F; Fri, 31 May 2019 12:58:31 +0000 (UTC) (envelope-from rodrigo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2413696D; Fri, 31 May 2019 12:58:31 +0000 (UTC) (envelope-from rodrigo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4VCwVjq013032; Fri, 31 May 2019 12:58:31 GMT (envelope-from rodrigo@FreeBSD.org) Received: (from rodrigo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4VCwSne013019; Fri, 31 May 2019 12:58:28 GMT (envelope-from rodrigo@FreeBSD.org) Message-Id: <201905311258.x4VCwSne013019@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rodrigo set sender to rodrigo@FreeBSD.org using -f From: Rodrigo Osorio Date: Fri, 31 May 2019 12:58:28 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r503172 - in head/net/rtg: . files X-SVN-Group: ports-head X-SVN-Commit-Author: rodrigo X-SVN-Commit-Paths: in head/net/rtg: . files X-SVN-Commit-Revision: 503172 X-SVN-Commit-Repository: ports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 54D296C14F X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.98)[-0.975,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-ports-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the ports tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 31 May 2019 12:58:32 -0000 Author: rodrigo Date: Fri May 31 12:58:28 2019 New Revision: 503172 URL: https://svnweb.freebsd.org/changeset/ports/503172 Log: Fix net/rtg with modern perl and php * Fix runtime PHP errors if short_opentag is disabled (default) * Remove most PHP warnings/notices that go to error_log * Fix HTML output to be valid * Fix quoting of SQL objects * Fix escaping of user-provided SQL data (potential sql injection) * Widen fields in 95.php and 95.pl for interface and router names * Fix warnings in perl modules in newer perl versions * Fix createdb script to use CREATE USER/GRANT not manipulate user db directly * Add "Update_desc" config entry to auto-update port descriptions from snmp * Update default SNMP version to 2 PR: 227376 Submitted by: (maintainer) Added: head/net/rtg/files/patch-cgilib-0.4_cgi.c (contents, props changed) head/net/rtg/files/patch-config_config.h.in (contents, props changed) head/net/rtg/files/patch-etc_95.php (contents, props changed) head/net/rtg/files/patch-etc_Makefile.in (contents, props changed) head/net/rtg/files/patch-etc_SNMP__util.pm (contents, props changed) head/net/rtg/files/patch-etc_createdb.in (contents, props changed) head/net/rtg/files/patch-etc_rtg.conf (contents, props changed) head/net/rtg/files/patch-etc_rtg.php (contents, props changed) head/net/rtg/files/patch-etc_rtgtargmkr.pl.in (contents, props changed) head/net/rtg/files/patch-etc_view.php (contents, props changed) head/net/rtg/files/patch-man_rtgplot.1 (contents, props changed) head/net/rtg/files/patch-man_rtgpoll.1 (contents, props changed) head/net/rtg/files/patch-src_rtg.h (contents, props changed) head/net/rtg/files/patch-src_rtgplot.c (contents, props changed) head/net/rtg/files/patch-src_rtgplot.h (contents, props changed) head/net/rtg/files/patch-src_rtgpoll.c (contents, props changed) head/net/rtg/files/patch-src_rtgutil.c (contents, props changed) Deleted: head/net/rtg/files/patch-cgilib-cgi.c head/net/rtg/files/patch-config-config.h.in head/net/rtg/files/patch-etc-95.php head/net/rtg/files/patch-etc-Makefile.in head/net/rtg/files/patch-etc-rtg.php head/net/rtg/files/patch-etc-rtgtargmkr.pl.in head/net/rtg/files/patch-etc-view.php head/net/rtg/files/patch-man-rtgplot.1 head/net/rtg/files/patch-man-rtgpoll.1 head/net/rtg/files/patch-src-rtg.h head/net/rtg/files/patch-src-rtgplot.c head/net/rtg/files/patch-src-rtgplot.h head/net/rtg/files/patch-src-rtgpoll.c Modified: head/net/rtg/Makefile head/net/rtg/files/patch-etc_95.pl head/net/rtg/files/patch-etc_common.php.in head/net/rtg/files/patch-etc_report.pl Modified: head/net/rtg/Makefile ============================================================================== --- head/net/rtg/Makefile Fri May 31 12:39:12 2019 (r503171) +++ head/net/rtg/Makefile Fri May 31 12:58:28 2019 (r503172) @@ -3,7 +3,7 @@ PORTNAME= rtg PORTVERSION= 0.7.4 -PORTREVISION= 17 +PORTREVISION= 18 CATEGORIES= net MASTER_SITES= SF \ ftp://ftpmirror.uk/freebsd-ports/rtg/ @@ -17,8 +17,9 @@ LIB_DEPENDS= libnetsnmp.so:net-mgmt/net-snmp RUN_DEPENDS= p5-DBI>=0:databases/p5-DBI \ p5-DBD-mysql>=0:databases/p5-DBD-mysql -USE_RC_SUBR= rtgpoll USES= mysql:client perl5 shebangfix ssl +USE_RC_SUBR= rtgpoll + SHEBANG_FILES= etc/95.pl etc/report.pl etc/rtgtargmkr.pl.in SUB_FILES= pkg-message GNU_CONFIGURE= yes Added: head/net/rtg/files/patch-cgilib-0.4_cgi.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/net/rtg/files/patch-cgilib-0.4_cgi.c Fri May 31 12:58:28 2019 (r503172) @@ -0,0 +1,15 @@ +--- cgilib-0.4/cgi.c.orig 2003-09-25 15:21:06 UTC ++++ cgilib-0.4/cgi.c +@@ -33,9 +33,12 @@ + #ifdef HAVE_CTYPE_H + # include + #endif ++/* Unnecessary on FreeBSD; malloc.h included in stdlib.h */ ++/* + #ifdef HAVE_MALLOC_H + # include + #endif ++*/ + + #include + Added: head/net/rtg/files/patch-config_config.h.in ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/net/rtg/files/patch-config_config.h.in Fri May 31 12:58:28 2019 (r503172) @@ -0,0 +1,27 @@ +--- config/config.h.in.orig 2003-09-25 15:21:14 UTC ++++ config/config.h.in +@@ -91,19 +91,19 @@ + #undef PACKAGE + + /* Define to the address where bug reports for this package should be sent. */ +-#undef PACKAGE_BUGREPORT ++#undef RTG_PACKAGE_BUGREPORT + + /* Define to the full name of this package. */ +-#undef PACKAGE_NAME ++#undef RTG_PACKAGE_NAME + + /* Define to the full name and version of this package. */ +-#undef PACKAGE_STRING ++#undef RTG_PACKAGE_STRING + + /* Define to the one symbol short name of this package. */ +-#undef PACKAGE_TARNAME ++#undef RTG_PACKAGE_TARNAME + + /* Define to the version of this package. */ +-#undef PACKAGE_VERSION ++#undef RTG_PACKAGE_VERSION + + /* Define as the return type of signal handlers (`int' or `void'). */ + #undef RETSIGTYPE Added: head/net/rtg/files/patch-etc_95.php ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/net/rtg/files/patch-etc_95.php Fri May 31 12:58:28 2019 (r503172) @@ -0,0 +1,288 @@ +--- etc/95.php.orig 2003-09-24 20:40:57 UTC ++++ etc/95.php +@@ -1,41 +1,37 @@ + \n\n\n"; ++ print "\n\n\n"; + + /* Connect to RTG MySQL Database */ +- $dbc=@mysql_connect ($host, $user, $pass) or +- $dbc=@mysql_connect ("$host:/var/lib/mysql/mysql.sock", $user, $pass) or ++ $dbc=@mysqli_connect ($host, $user, $pass, $db) or + die ("MySQL Connection Failed, Check Configuration."); +- mysql_select_db($db,$dbc); + +- if ($PHP_SELF == "") { ++ if (!isset($PHP_SELF) || ($PHP_SELF == "")) { + $PHP_SELF = "95.php"; +- $customer = $_GET['customer']; +- $syear = $_GET['syear']; +- $eyear = $_GET['eyear']; +- $smonth = $_GET['smonth']; +- $emonth = $_GET['emonth']; +- $sday = $_GET['sday']; +- $eday = $_GET['eday']; +- $shour = $_GET['shour']; +- $ehour = $_GET['ehour']; +- $smin = $_GET['smin']; +- $emin = $_GET['emin']; +- $debug = $_GET['debug']; ++ $customer = isset($_GET['customer'])?$_GET['customer']:""; ++ $syear = isset($_GET['syear'])?$_GET['syear']:""; ++ $eyear = isset($_GET['eyear'])?$_GET['eyear']:""; ++ $smonth = isset($_GET['smonth'])?$_GET['smonth']:""; ++ $emonth = isset($_GET['emonth'])?$_GET['emonth']:""; ++ $sday = isset($_GET['sday'])?$_GET['sday']:""; ++ $eday = isset($_GET['eday'])?$_GET['eday']:""; ++ $shour = isset($_GET['shour'])?$_GET['shour']:""; ++ $ehour = isset($_GET['ehour'])?$_GET['ehour']:""; ++ $smin = isset($_GET['smin'])?$_GET['smin']:""; ++ $emin = isset($_GET['emin'])?$_GET['emin']:""; ++ $debug = isset($_GET['debug'])?$_GET['debug']:""; + } + +- print "RTG: "; +- if ($customer) print "$customer\n"; ++ print "<title>RTG: "; ++ if ($customer != "") print "$customer\n"; + ?> + +- +- +- +- +- +- +-

++ ++ ++ ++[RTG Home Page] ++

+ + counter; + $sample_secs = $selectRow->unixtime; + $total += $counter; +@@ -83,132 +79,136 @@ function int_stats($statement, $dbc) { + } + ?> + +-


+-Report: 95th percentile
++
++Report: 95th percentile
+ + \n"; +- if (($bt || $smonth)) { +- $dbc=@mysql_connect ($host, $user, $pass) or +- $dbc=@mysql_connect ("$host:/var/lib/mysql/mysql.sock", $user, $pass) or die ("MySQL Connection Failed, Check Configuration."); +- mysql_select_db($db,$dbc); ++ echo "
\n"; ++ if (($bt != "") || ($smonth != "")) { ++ $dbc=@mysqli_connect ($host, $user, $pass, $db) or ++ die ("MySQL Connection Failed, Check Configuration."); + /* Format into GNU date syntax */ + if ($bt == "") { + $bt = strtotime("$syear-$smonth-$sday $shour:$smin:00"); + $et = strtotime("$eyear-$emonth-$eday $ehour:$emin:59"); + } +- echo "Customer: $customer
\n"; ++ echo "Customer: $customer
\n"; + print strftime("Period: %m/%d/%Y %H:%M - ", $bt); + print strftime("%m/%d/%Y %H:%M

\n", $et); + +- $range="dtime>FROM_UNIXTIME($bt) AND dtime<=FROM_UNIXTIME($et)"; ++ $range="`dtime`>FROM_UNIXTIME(" . mysqli_real_escape_string($dbc, $bt) . ++ ") AND `dtime`<=FROM_UNIXTIME(" . mysqli_real_escape_string($dbc, $et) . ")"; + +- $selectQuery="SELECT id, name, description, rid FROM interface WHERE description LIKE \"%$customer%\""; +- $selectResult=mysql_query($selectQuery, $dbc); +- if (mysql_num_rows($selectResult) <= 0) +- print "
No Such Customer Found.
\n"; ++ $selectQuery="SELECT `id`, `name`, `description`, `rid` FROM `interface` WHERE " . ++ "`description` LIKE \"%" . mysqli_real_escape_string($dbc, $customer) . "%\""; ++ $selectResult=mysqli_query($dbc, $selectQuery); ++ if (mysqli_num_rows($selectResult) <= 0) ++ print "
No Such Customer Found.
\n"; + else { +- while ($selectRow=mysql_fetch_object($selectResult)){ ++ while ($selectRow=mysqli_fetch_object($selectResult)){ + $ids[$selectRow->id] = $selectRow->name; + $rids[$selectRow->id] = $selectRow->rid; + $desc[$selectRow->id] = $selectRow->description; + } +- echo "\n"; +- echo "\n"; +- echo "
InterfaceCurrent RateMax Rate95th %\n"; ++ echo "\n"; ++ echo "\n"; ++ echo "\n"; + if ($debug) +- echo "\n"; +- echo "\n"; ++ echo "\n"; ++ echo "\n"; ++ echo "\n"; + if ($debug) +- echo "\n"; ++ echo "\n"; ++ echo "\n"; ++ echo "\n"; + $yellow = 1; + foreach($ids as $iid=>$name) { + +- $selectQuery="SELECT name FROM router WHERE rid=$rids[$iid]"; +- $selectResult=mysql_query($selectQuery, $dbc); +- $selectRow=mysql_fetch_object($selectResult); ++ $selectQuery="SELECT `name` FROM `router` WHERE `rid`=$rids[$iid]"; ++ $selectResult=mysqli_query($dbc, $selectQuery); ++ $selectRow=mysqli_fetch_object($selectResult); + $router = $selectRow->name; + + if ($yellow) $yellow = 0; + else $yellow = 1; + +- echo ""; + +- $selectQuery="SELECT counter, UNIX_TIMESTAMP(dtime) as unixtime, dtime from ifInOctets_$rids[$iid] WHERE $range AND id=$iid ORDER BY dtime"; ++ $selectQuery="SELECT `counter`, UNIX_TIMESTAMP(`dtime`) AS `unixtime`, `dtime` FROM `ifInOctets_$rids[$iid]` WHERE $range AND `id`=$iid ORDER BY `dtime`"; + list ($intbytes_in, $maxin, $avgin, $nfin,$insamples,$inignore) = int_stats($selectQuery, $dbc); + $bytesin = round($intbytes_in/1000000); + +- $selectQuery="SELECT counter, UNIX_TIMESTAMP(dtime) as unixtime, dtime from ifOutOctets_$rids[$iid] WHERE $range AND id=$iid ORDER BY dtime"; ++ $selectQuery="SELECT `counter`, UNIX_TIMESTAMP(`dtime`) AS `unixtime`, `dtime` FROM `ifOutOctets_$rids[$iid]` WHERE $range AND `id`=$iid ORDER BY `dtime`"; + list ($intbytes_out, $maxout, $avgout, $nfout,$outsamples,$outignore) = int_stats($selectQuery, $dbc); + $bytesout = round($intbytes_in/1000000); + +- printf("", $avgin/1000000); ++ printf("", $avgout/1000000); ++ printf("", $maxin/1000000); ++ printf("", $maxout/1000000); ++ printf("", $nfin/1000000); ++ printf("", $nfout/1000000); + if ($debug) { +- echo ""; + } +- if ($yellow) echo "\n"; +- else echo "\n"; ++ echo "\n"; ++ if ($yellow) echo "\n"; ++ else echo "\n"; + } +- echo "
InterfaceCurrent RateMax Rate95th %SamplesIgnore Top\n"; +- echo "
NameDescriptionRouterIn (Mbps)Out (Mbps)InOutInOut\n"; ++ echo "SamplesIgnore Top
NameDescriptionRouterIn (Mbps)Out (Mbps)InOutInOutInOutInOut\n"; +- echo "
InOutInOut
$name$desc[$iid]$router"; ++ echo "$name$desc[$iid]$router%2.2f", $avgin/1000000); +- printf("%2.2f", $avgout/1000000); +- printf("%2.2f", $maxin/1000000); +- printf("%2.2f", $maxout/1000000); +- printf("%2.2f", $nfin/1000000); +- printf("%2.2f", $nfout/1000000); ++ printf("%2.2f%2.2f%2.2f%2.2f%2.2f%2.2f$insamples$outsamples$inignore$outignore"; ++ echo "$insamples$outsamples$inignore$outignore
\n"; ++ echo "
\n"; + } + } else { +- echo "Customer Name:
\n"; +- echo "

\n"; +- echo "\n"; ++ echo "\n"; ++ echo "\n"; ++ echo "
From: \n"; +- echo "
\n"; ++ echo "

\n"; ++ echo "\n"; ++ echo "\n"; ++ echo "\n"; + +- echo "\n"; ++ echo "\n"; ++ echo "
From: / \n"; +- echo " / \n"; ++ echo " / \n"; +- echo " / \n"; ++ echo "\n"; +- echo ":\n"; +- echo ":\n"; ++ echo "\n"; ++ echo "\" />
To: \n"; +- echo "To: / \n"; +- echo " / \n"; ++ echo " / \n"; +- echo " / \n"; ++ echo "\n"; +- echo ":\n"; +- echo ":\n"; ++ echo "\n"; +- echo "
Debug: \n"; +- echo "\n"; +- echo "
\n"; ++ echo "\" />

Debug:
\n"; + +- echo "

"; ++ echo "

"; + } + +- if ($dbc) mysql_close($dbc); +- echo "

\n"; ++ if ($dbc) mysqli_close($dbc); ++ echo "\n"; + ?> +-
+-
+- ++
++
++ + RTG Version $VERSION"; ++ print "RTG Version $VERSION
"; + ?> +- +- ++ ++ Modified: head/net/rtg/files/patch-etc_95.pl ============================================================================== --- head/net/rtg/files/patch-etc_95.pl Fri May 31 12:39:12 2019 (r503171) +++ head/net/rtg/files/patch-etc_95.pl Fri May 31 12:58:28 2019 (r503172) @@ -1,4 +1,4 @@ ---- etc/95.pl.orig 2016-11-04 16:36:01 UTC +--- etc/95.pl.orig 2018-04-02 20:14:41 UTC +++ etc/95.pl @@ -31,7 +31,7 @@ $pass="rtgdefault"; $onedaysec=60*60*24; @@ -9,3 +9,52 @@ foreach $conf (@configs) { if (open CONF, "<$conf") { print "Reading [$conf].\n" if $DEBUG; +@@ -207,13 +207,13 @@ print "Period: [", format_dt($startdate) + write; + ($name,$router, $ratein, $rateout, $maxratein, $maxrateout, $nfratein, $nfrateout) = ("Connection", "", "Mbps", "Mbps", "Mbps", "Mbps", "Mbps", "Mbps"); + write; +-print "--------------------------------------------------------------------------------\n"; ++print "----------------------------------------------------------------------------------------------------\n"; + + $dbh= DBI->connect("DBI:mysql:$db:host=$host", $user, $pass); + $dbh2= DBI->connect("DBI:mysql:$db:host=$host", $user, $pass); +-$range="dtime>$startdate and dtime<=$enddate"; ++$range="`dtime`>$startdate AND `dtime`<=$enddate"; + +-$statement="SELECT id FROM interface WHERE description LIKE \"%$cust%\""; ++$statement="SELECT `id` FROM `interface` WHERE `description` LIKE \"%$cust%\""; + $sth = $dbh->prepare($statement) + or die "Can't prepare $statement: $dbh->errstr\n"; + $rv = $sth->execute +@@ -223,19 +223,19 @@ while (@row = $sth->fetchrow_array ()) { + } + + foreach $interface (@interfaces) { +- $statement="SELECT rid, name, speed FROM interface WHERE id=$interface"; ++ $statement="SELECT `rid`, `name`, `speed` FROM `interface` WHERE `id`=$interface"; + &run_query($statement); + ($rid, $name, $speed) = @row; + +- $statement="SELECT rid, name FROM router WHERE rid=$rid"; ++ $statement="SELECT `rid`, `name` FROM `router` WHERE `rid`=$rid"; + &run_query($statement); + ($rid, $router) = @row; + +- $statement="SELECT counter, UNIX_TIMESTAMP(dtime), dtime FROM ifInOctets_".$rid." WHERE $range AND id=$interface ORDER BY dtime"; ++ $statement="SELECT `counter`, UNIX_TIMESTAMP(`dtime`), `dtime` FROM `ifInOctets_".$rid."` WHERE $range AND `id`=$interface ORDER BY `dtime`"; + ($intbytes_in, $maxin, $avgin, $nfin) = &interface_stats($statement); + $bytesin = int($intbytes_in/1000000 + .5); + +- $statement="SELECT counter, UNIX_TIMESTAMP(dtime), dtime FROM ifOutOctets_".$rid." WHERE $range AND id=$interface ORDER BY dtime"; ++ $statement="SELECT `counter`, UNIX_TIMESTAMP(`dtime`), `dtime` FROM `ifOutOctets_".$rid."` WHERE $range AND `id`=$interface ORDER BY `dtime`"; + ($intbytes_out, $maxout, $avgout, $nfout) = &interface_stats($statement); + $bytesout = int($intbytes_out/1000000 + .5); + +@@ -279,6 +279,6 @@ $rc = $dbh->disconnect; + exit; + + format STDOUT = +-@<<<<<<<<<<< @<<<<<<<<<<< @>>>>>>> @>>>>>>> @>>>>>> @>>>>>> @>>>>>> @>>>>>> ++@<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<< @>>>>>>> @>>>>>>> @>>>>>> @>>>>>> @>>>>>> @>>>>>> + $name,$router, $ratein, $rateout, $maxratein, $maxrateout, $nfratein, $nfrateout + . Added: head/net/rtg/files/patch-etc_Makefile.in ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/net/rtg/files/patch-etc_Makefile.in Fri May 31 12:58:28 2019 (r503172) @@ -0,0 +1,49 @@ +--- etc/Makefile.in.orig 2003-10-02 15:59:32 UTC ++++ etc/Makefile.in +@@ -84,19 +84,19 @@ am__quote = @am__quote@ + install_sh = @install_sh@ + + top_builddir = .. +-etcdir = /etc +-webdir = /web +-reportsdir = /bin ++etcdir = @etcdir@ ++webdir = @webdir@ ++reportsdir = @bindir@ + +-ETC = rtg.conf rtgtargmkr.pl routers createdb BER.pm \ ++ETC = rtg.conf.sample rtgtargmkr.pl routers.sample createdb BER.pm \ + SNMP_Session.pm SNMP_util.pm + + WEB = rtg.php 95.php view.php common.php rtg.png rtgback.png + REPORTS = report.pl 95.pl + + EXTRA_DIST = rtgtargmkr.pl.in report.pl 95.pl createdb.in \ +- BER.pm SNMP_Session.pm SNMP_util.pm rtg.conf \ +- routers rtg.php 95.php view.php common.php.in rtg.png rtgback.png ++ BER.pm SNMP_Session.pm SNMP_util.pm rtg.conf.sample \ ++ routers.sample rtg.php 95.php view.php common.php.in rtg.png rtgback.png + + subdir = etc + mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs +@@ -220,14 +220,14 @@ uninstall-am: uninstall-info-am + all: + + install: installdirs +- @for i in $(ETC) ; do $(INSTALL) $(srcdir)/$$i $(prefix)$(etcdir) ; echo "install: installed $$i in $(prefix)$(etcdir)" ; done +- @for i in $(WEB) ; do $(INSTALL) $(srcdir)/$$i $(prefix)$(webdir) ; echo "install: installed $$i in $(prefix)$(webdir)" ; done +- @for i in $(REPORTS) ; do $(INSTALL) $(srcdir)/$$i $(prefix)$(reportsdir) ; echo "install: installed $$i in $(prefix)$(reportsdir)" ; done ++ @for i in $(ETC) ; do $(INSTALL) $(srcdir)/$$i $(DESTDIR)$(etcdir) ; echo "install: installed $$i in $(DESTDIR)$(etcdir)" ; done ++ @for i in $(WEB) ; do $(INSTALL) $(srcdir)/$$i $(DESTDIR)$(webdir) ; echo "install: installed $$i in $(DESTDIR)$(webdir)" ; done ++ @for i in $(REPORTS) ; do $(INSTALL) $(srcdir)/$$i $(DESTDIR)$(reportsdir) ; echo "install: installed $$i in $(DESTDIR)$(reportsdir)" ; done + + installdirs: +- $(mkinstalldirs) $(prefix)$(etcdir) +- $(mkinstalldirs) $(prefix)$(webdir) +- $(mkinstalldirs) $(prefix)$(reportsdir) ++ $(mkinstalldirs) $(DESTDIR)$(etcdir) ++ $(mkinstalldirs) $(DESTDIR)$(webdir) ++ $(mkinstalldirs) $(DESTDIR)$(reportsdir) + # Tell versions [3.59,3.63) of GNU make to not export all variables. + # Otherwise a system limit (for SysV at least) may be exceeded. + .NOEXPORT: Added: head/net/rtg/files/patch-etc_SNMP__util.pm ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/net/rtg/files/patch-etc_SNMP__util.pm Fri May 31 12:58:28 2019 (r503172) @@ -0,0 +1,22 @@ +--- etc/SNMP_util.pm.orig 2018-04-02 22:51:02 UTC ++++ etc/SNMP_util.pm +@@ -1129,16 +1129,16 @@ sub snmpMIB_to_OID ($) { + $buf =~ s/OBJECT-GROUP/OBJECT IDENTIFIER/; + $buf =~ s/MODULE-IDENTITY/OBJECT IDENTIFIER/; + $buf =~ s/ IMPORTS .*\;//; +- $buf =~ s/ SEQUENCE {.*}//; ++ $buf =~ s/ SEQUENCE \{.*}//; + $buf =~ s/ SYNTAX .*//; + $buf =~ s/ [\w-]+ ::= OBJECT IDENTIFIER//; +- $buf =~ s/ OBJECT IDENTIFIER .* ::= {/ OBJECT IDENTIFIER ::= {/; ++ $buf =~ s/ OBJECT IDENTIFIER .* ::= \{/ OBJECT IDENTIFIER ::= {/; + $buf =~ s/".*"//; + if ($buf =~ /"/) { + $quote = 1; + } + +- if ($buf =~ / ([\w\-]+) OBJECT IDENTIFIER ::= {([^}]+)}/) { ++ if ($buf =~ / ([\w\-]+) OBJECT IDENTIFIER ::= \{([^}]+)}/) { + $var = $1; + $buf = $2; + undef $val; Modified: head/net/rtg/files/patch-etc_common.php.in ============================================================================== --- head/net/rtg/files/patch-etc_common.php.in Fri May 31 12:39:12 2019 (r503171) +++ head/net/rtg/files/patch-etc_common.php.in Fri May 31 12:58:28 2019 (r503172) @@ -1,5 +1,11 @@ --- etc/common.php.in.orig 2003-09-26 15:52:29 UTC +++ etc/common.php.in +@@ -1,4 +1,4 @@ +-/tmp/mysql.sql +-INSERT INTO user (Host, User, Password) VALUES ('$HOST','$USER',PASSWORD("$RTGPASS")); +-INSERT INTO db (Host, Db, User, Select_priv, Insert_priv, Update_priv, Delete_priv, +-Create_priv, Drop_priv, Grant_priv, References_priv, Index_priv, Alter_priv) +-VALUES ('$HOST','$DATABASE','$USER','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y'); +-FLUSH PRIVILEGES; ++CREATE USER '$USER'@'$HOST' IDENTIFIED BY '$RTG_PASS'; ++GRANT ALL ON '$DATABASE'.* TO '$USER'@'$HOST'; + EOT + + cat </tmp/rtg.sql +@@ -35,81 +32,81 @@ cat </tmp/rtg.sql + # Table structure for table 'router' + # + +-CREATE TABLE router ( +- rid int(11) unsigned NOT NULL auto_increment, +- name char(120) NOT NULL default '', +- pop char(10) NOT NULL default '', +- popid tinyint(3) unsigned NOT NULL default '0', +- PRIMARY KEY (rid) ++CREATE TABLE `router` ( ++ `rid` int(11) unsigned NOT NULL auto_increment, ++ `name` char(120) NOT NULL default '', ++ `pop` char(10) NOT NULL default '', ++ `popid` tinyint(3) unsigned NOT NULL default '0', ++ PRIMARY KEY (`rid`) + ); + + # + # Table structure for table 'interface' + # + +-CREATE TABLE interface ( +- id int(11) unsigned NOT NULL auto_increment, +- name char(255) NOT NULL default '', +- rid int(11) NOT NULL default '0', +- speed bigint(11) default NULL, +- description char(255) default NULL, +- status enum('active','inactive') default 'active', +- PRIMARY KEY (id) ++CREATE TABLE `interface` ( ++ `id` int(11) unsigned NOT NULL auto_increment, ++ `name` char(255) NOT NULL default '', ++ `rid` int(11) NOT NULL default '0', ++ `speed` bigint(11) default NULL, ++ `description` char(255) default NULL, ++ `status` enum('active','inactive') default 'active', ++ PRIMARY KEY (`id`) + ); + + # + # Table structure for table 'ifInOctets' + # + +-CREATE TABLE ifInOctets ( +- id int(11) NOT NULL default '0', +- dtime datetime NOT NULL default '0000-00-00 00:00:00', +- counter bigint(20) NOT NULL default '0', +- KEY ifInOctets_idx (dtime) ++CREATE TABLE `ifInOctets` ( ++ `id` int(11) NOT NULL default '0', ++ `dtime` datetime NOT NULL default '0000-00-00 00:00:00', ++ `counter` bigint(20) NOT NULL default '0', ++ KEY `ifInOctets_idx` (`dtime`) + ); + + # + # Table structure for table 'ifOutOctets' + # + +-CREATE TABLE ifOutOctets ( +- id int(11) NOT NULL default '0', +- dtime datetime NOT NULL default '0000-00-00 00:00:00', +- counter bigint(20) NOT NULL default '0', +- KEY ifOutOctets_idx (dtime) ++CREATE TABLE `ifOutOctets` ( ++ `id` int(11) NOT NULL default '0', ++ `dtime` datetime NOT NULL default '0000-00-00 00:00:00', ++ `counter` bigint(20) NOT NULL default '0', ++ KEY `ifOutOctets_idx` (`dtime`) + ); + + # + # Table structure for table 'ifInUcastPkts' + # + +-CREATE TABLE ifInUcastPkts ( +- id int(11) NOT NULL default '0', +- dtime datetime NOT NULL default '0000-00-00 00:00:00', +- counter bigint(20) NOT NULL default '0', +- KEY ifInUcastPkts_idx (dtime) ++CREATE TABLE `ifInUcastPkts` ( ++ `id` int(11) NOT NULL default '0', ++ `dtime` datetime NOT NULL default '0000-00-00 00:00:00', ++ `counter` bigint(20) NOT NULL default '0', ++ KEY `ifInUcastPkts_idx` (`dtime`) + ); + + # + # Table structure for table 'ifOutUcastPkts' + # + +-CREATE TABLE ifOutUcastPkts ( +- id int(11) NOT NULL default '0', +- dtime datetime NOT NULL default '0000-00-00 00:00:00', +- counter bigint(20) NOT NULL default '0', +- KEY ifOutUcastPkts_idx (dtime) ++CREATE TABLE `ifOutUcastPkts` ( ++ `id` int(11) NOT NULL default '0', ++ `dtime` datetime NOT NULL default '0000-00-00 00:00:00', ++ `counter` bigint(20) NOT NULL default '0', ++ KEY `ifOutUcastPkts_idx` (`dtime`) + ); + + # + # Table structure for table 'ifInErrors' + # + +-CREATE TABLE ifInErrors ( +- id int(11) NOT NULL default '0', +- dtime datetime NOT NULL default '0000-00-00 00:00:00', +- counter bigint(20) NOT NULL default '0', +- KEY ifInErrors_idx (dtime) ++CREATE TABLE `ifInErrors` ( ++ `id` int(11) NOT NULL default '0', ++ `dtime` datetime NOT NULL default '0000-00-00 00:00:00', ++ `counter` bigint(20) NOT NULL default '0', ++ KEY `ifInErrors_idx` (`dtime`) + ); + EOT + +@@ -117,8 +114,6 @@ echo "Adding user \"$USER\" to MySQL dat + cat /tmp/mysql.sql | $MYSQLBIN/mysql -u root -p$ROOTPASS mysql + echo "Creating RTG database \"$DATABASE\"..." + $MYSQLBIN/mysqladmin -u root -p$ROOTPASS create $DATABASE +-echo "Reloading MySQL privileges..." +-$MYSQLBIN/mysqladmin -u root -p$ROOTPASS flush-privileges + echo "Creating RTG tables..." + cat /tmp/rtg.sql | $MYSQLBIN/mysql -u $USER -p$RTGPASS $DATABASE + echo "Done." Modified: head/net/rtg/files/patch-etc_report.pl ============================================================================== --- head/net/rtg/files/patch-etc_report.pl Fri May 31 12:39:12 2019 (r503171) +++ head/net/rtg/files/patch-etc_report.pl Fri May 31 12:58:28 2019 (r503172) @@ -1,4 +1,4 @@ ---- etc/report.pl.orig 2016-11-04 16:36:08 UTC +--- etc/report.pl.orig 2018-04-02 20:14:41 UTC +++ etc/report.pl @@ -30,7 +30,7 @@ $pass="rtgdefault"; $onedaysec=60*60*24; @@ -9,3 +9,52 @@ foreach $conf (@configs) { if (open CONF, "<$conf") { print "Reading [$conf].\n" if $DEBUG; +@@ -192,13 +192,13 @@ print "Period: [", format_dt($startdate) + write; + ($router,$name,$bytesin, $bytesout, $ratein, $rateout, $utilin, $utilout, $maxratein, $maxrateout, $maxutilin, $maxutilout) = ("","Connection", "MBytes", "MBytes", "Mbps", "Mbps", "In %", "Out%", "Mbps", "Mbps", "In%", "Out%"); + write; +-print "----------------------------------------------------------------------------------------------------------\n"; ++print "------------------------------------------------------------------------------------------------------------------------------\n"; + + $dbh= DBI->connect("DBI:mysql:$db:host=$host", $user, $pass); + $dbh2= DBI->connect("DBI:mysql:$db:host=$host", $user, $pass); +-$range="dtime>$startdate and dtime<=$enddate"; ++$range="`dtime`>$startdate and `dtime`<=$enddate"; + +-$statement="SELECT id FROM interface WHERE description LIKE \"%$cust%\""; ++$statement="SELECT `id` FROM `interface` WHERE `description` LIKE \"%$cust%\""; + $sth = $dbh->prepare($statement) + or die "Can't prepare $statement: $dbh->errstr\n"; + $rv = $sth->execute +@@ -209,19 +209,19 @@ while (@row = $sth->fetchrow_array ()) + } + + foreach $interface (@interfaces) { +- $statement="SELECT rid, name, speed FROM interface WHERE id=$interface"; ++ $statement="SELECT `rid`, `name`, `speed` FROM `interface` WHERE `id`=$interface"; + &run_query($statement); + ($rid, $name, $speed) = @row; + +- $statement="SELECT rid, name FROM router WHERE rid=$rid"; ++ $statement="SELECT `rid`, `name` FROM `router` WHERE `rid`=$rid"; + &run_query($statement); + ($rid, $router) = @row; + +- $statement="SELECT counter, UNIX_TIMESTAMP(dtime), dtime FROM ifInOctets_".$rid." WHERE $range AND id=$interface ORDER BY dtime"; ++ $statement="SELECT `counter`, UNIX_TIMESTAMP(`dtime`), `dtime` FROM `ifInOctets_".$rid."` WHERE $range AND `id`=$interface ORDER BY `dtime`"; + ($intbytes_in, $maxin, $avgin) = &interface_stats($statement); + $bytesin = int($intbytes_in/1000000 + .5); + +- $statement="SELECT counter, UNIX_TIMESTAMP(dtime), dtime FROM ifOutOctets_".$rid." WHERE $range AND id=$interface ORDER BY dtime"; ++ $statement="SELECT `counter`, UNIX_TIMESTAMP(`dtime`), `dtime` FROM `ifOutOctets_".$rid."` WHERE $range AND `id`=$interface ORDER BY `dtime`"; + ($intbytes_out, $maxout, $avgout) = &interface_stats($statement); + $bytesout = int($intbytes_out/1000000 + .5); + +@@ -267,6 +267,6 @@ $rc = $dbh->disconnect; + exit; + + format STDOUT = +-@<<<<<<<<<<< @<<<<<<<<<<< @>>>>>>> @>>>>>>> @>>>>>> @>>>>>> @>>>>> @>>>>> @>>>>>> @>>>>>> @>>>>> @>>>>> ++@<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<< @>>>>>>> @>>>>>>> @>>>>>> @>>>>>> @>>>>> @>>>>> @>>>>>> @>>>>>> @>>>>> @>>>>> + $name,$router,&commify($bytesin), &commify($bytesout), $ratein, $rateout, $utilin, $utilout, $maxratein, $maxrateout, $maxutilin, $maxutilout + . Added: head/net/rtg/files/patch-etc_rtg.conf ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/net/rtg/files/patch-etc_rtg.conf Fri May 31 12:58:28 2019 (r503172) @@ -0,0 +1,10 @@ +--- etc/rtg.conf.orig 2018-04-02 23:07:32 UTC ++++ etc/rtg.conf +@@ -12,3 +12,7 @@ DB_Database rtg + DB_User snmp + DB_Pass rtgdefault + Threads 5 ++# Set Update_desc to 1 to cause rtgtargmkr.pl to auto-update descriptions from ++# SNMP port data ++Update_desc 0 ++ Added: head/net/rtg/files/patch-etc_rtg.php ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/net/rtg/files/patch-etc_rtg.php Fri May 31 12:58:28 2019 (r503172) @@ -0,0 +1,389 @@ +--- etc/rtg.php.orig 2003-09-24 20:42:03 UTC ++++ etc/rtg.php +@@ -1,146 +1,152 @@ + \n\n\n"; ++ print "\n\n\n"; + + /* Connect to RTG MySQL Database */ +- $dbc=@mysql_connect ($host, $user, $pass) or +- $dbc=@mysql_connect ("$host:/var/lib/mysql/mysql.sock", $user, $pass) or ++ $dbc=@mysqli_connect ($host, $user, $pass, $db) or + die ("MySQL Connection Failed, Check Configuration."); +- mysql_select_db($db,$dbc); + +- if ($PHP_SELF == "") { ++ if (!isset($PHP_SELF) || $PHP_SELF == "") { + $PHP_SELF = "rtg.php"; +- $errors = $_GET['errors']; +- $scalex = $_GET['scalex']; +- $scaley = $_GET['scaley']; +- $aggr = $_GET['aggr']; +- $percentile = $_GET['percentile']; +- $nth = $_GET['nth']; +- $xplot = $_GET['xplot']; +- $yplot = $_GET['yplot']; +- $borderb = $_GET['borderb']; +- $iid = $_GET['iid']; +- $rid = $_GET['rid']; +- $syear = $_GET['syear']; +- $eyear = $_GET['eyear']; +- $smonth = $_GET['smonth']; +- $emonth = $_GET['emonth']; +- $sday = $_GET['sday']; +- $eday = $_GET['eday']; +- $shour = $_GET['shour']; +- $ehour = $_GET['ehour']; +- $smin = $_GET['smin']; +- $emin = $_GET['emin']; ++ $errors = isset($_GET['errors'])?$_GET['errors']:""; ++ $scalex = isset($_GET['scalex'])?$_GET['scalex']:""; ++ $scaley = isset($_GET['scaley'])?$_GET['scaley']:""; ++ $aggr = isset($_GET['aggr'])?$_GET['aggr']:""; ++ $percentile = isset($_GET['percentile'])?$_GET['percentile']:""; ++ $nth = isset($_GET['nth'])?$_GET['nth']:""; ++ $xplot = isset($_GET['xplot'])?$_GET['xplot']:""; ++ $yplot = isset($_GET['yplot'])?$_GET['yplot']:""; ++ $borderb = isset($_GET['borderb'])?$_GET['borderb']:""; ++ $iid = isset($_GET['iid'])?$_GET['iid']:""; ++ $rid = isset($_GET['rid'])?$_GET['rid']:""; ++ $syear = isset($_GET['syear'])?$_GET['syear']:""; ++ $eyear = isset($_GET['eyear'])?$_GET['eyear']:""; ++ $smonth = isset($_GET['smonth'])?$_GET['smonth']:""; ++ $emonth = isset($_GET['emonth'])?$_GET['emonth']:""; ++ $sday = isset($_GET['sday'])?$_GET['sday']:""; ++ $eday = isset($_GET['eday'])?$_GET['eday']:""; ++ $shour = isset($_GET['shour'])?$_GET['shour']:""; ++ $ehour = isset($_GET['ehour'])?$_GET['ehour']:""; ++ $smin = isset($_GET['smin'])?$_GET['smin']:""; ++ $emin = isset($_GET['emin'])?$_GET['emin']:""; + } + + # Determine router, interface names as necessary +- if ($rid && $iid) { +- $selectQuery="SELECT a.name, a.description, a.speed, b.name AS router FROM interface a, router b WHERE a.rid=b.rid AND a.rid=$rid AND a.id=$iid[0]"; +- $selectResult=mysql_query($selectQuery, $dbc); +- $selectRow=mysql_fetch_object($selectResult); +- $interfaces = mysql_num_rows($selectResult); ++ if (($rid != "") && ($iid != "")) { ++ $selectQuery="SELECT `a`.`name`, `a`.`description`, `a`.`speed`, `b`.`name` " . ++ "AS `router` FROM `interface` `a`, `router` `b` WHERE `a`.`rid`=`b`.`rid` " . ++ "AND `a`.`rid`=" . mysqli_real_escape_string($dbc, $rid) . " AND `a`.`id`=" . ++ mysqli_real_escape_string($dbc, $iid[0]); ++ $selectResult=mysqli_query($dbc, $selectQuery); ++ $selectRow=mysqli_fetch_object($selectResult); ++ $interfaces = mysqli_num_rows($selectResult); + $name = $selectRow->name; + $description = $selectRow->description; + $speed = ($selectRow->speed)/1000000; + $router = $selectRow->router; +- } else if ($rid && !$iid) { +- $selectQuery="SELECT name AS router from router where rid=$rid"; +- $selectResult=mysql_query($selectQuery, $dbc); +- $selectRow=mysql_fetch_object($selectResult); ++ } else if (($rid != "") && ($iid == "")) { ++ $selectQuery="SELECT `name` AS `router` FROM `router` WHERE `rid`=" . ++ mysqli_real_escape_string($dbc, $rid); ++ $selectResult=mysqli_query($dbc, $selectQuery); ++ $selectRow=mysqli_fetch_object($selectResult); + $router = $selectRow->router; + } + + # Generate Title +- echo "RTG: "; +- if ($rid && $iid) echo "$router: $name"; +- else if ($rid && !$iid) echo "$router"; +- echo "\n"; ++ echo "RTG: "; ++ if (($rid != "") && ($iid != "")) echo "$router: $name"; ++ else if (($rid != "") && ($iid == "")) echo "$router"; ++ echo "\n"; + ?> + +- +- +- +- +- +-

++ ++ ++ ++

+ + \n"; ++echo "

\n"; + +-if (!$rid && !$iid) { +- echo "\n"; ++ $selectQuery="SELECT DISTINCT `name`, `rid` FROM `router` ORDER BY `name`"; ++ $selectResult=mysqli_query($dbc, $selectQuery); ++ while ($selectRow=mysqli_fetch_object($selectResult)){ ++ echo "\n"; + } +- echo "\n"; ++ echo "\n"; + } + +-if ($smonth != "" && $iid == "") { +- echo "
\n"; ++if (($smonth != "") && ($iid == "")) { ++ echo "
\n"; + echo "Please select an interface!\n"; +- echo "
\n"; ++ echo "
\n"; + } + +-if ($rid && !$iid) { +- echo "\n"; ++if (($rid != "") && ($iid == "")) { ++ echo "\n"; + +- echo "\n"; ++ $selectQuery="SELECT `id`, `name`, `description` FROM `interface` WHERE " . ++ "`rid`=" . mysqli_real_escape_string($dbc, $rid) . " ORDER BY `name`"; ++ $selectResult=mysqli_query($dbc, $selectQuery); ++ while ($selectRow=mysqli_fetch_object($selectResult)){ ++ echo "\n"; + } +- echo "\n"; ++ echo "\n"; + +- echo "

\n"; +- echo ""; ++ echo "\n"; ++ ++ echo "\n"; ++ echo "\n"; ++ echo "\n"; ++ echo "\n"; ++ echo "\n"; ++ echo "\n"; ++ echo "\n"; ++ echo "\n"; ++ echo "\n"; ++ echo "\n"; ++ echo "\n"; ++ echo "\n"; ++ echo "\n"; ++ echo "\n"; ++ echo "
From: \n"; +- echo "\n"; ++ echo "\n"; ++ echo ""; ++ echo "\n"; + +- echo "\n"; ++ echo "
From: / \n"; +- echo " / \n"; ++ echo " / \n"; +- echo " / \n"; ++ echo "\n"; +- echo ":\n"; +- echo "\n"; ++ echo "\" />\n"; ++ echo ":\n"; ++ echo "\n"; ++ echo "
To: \n"; +- echo "To: / \n"; +- echo " / \n"; ++ echo " / \n"; +- echo " / \n"; ++ echo "\n"; +- echo ":\n"; +- echo "\n"; +- echo "
Aggregate Interfaces: \n"; +- echo "\n"; +- echo "
th Percentile: \n"; +- echo "\n"; +- echo "
Fit to Data: \n"; +- echo "\n"; +- echo "
Fit to Speed: \n"; +- echo "\n"; +- echo "
X Size: \n"; +- echo "\n"; +- echo "
Y Size: \n"; +- echo "\n"; +- echo "
BorderB: \n"; +- echo "\n"; +- echo "
\n"; ++ echo "\" />\n"; ++ echo "
:\n"; ++ echo "\n"; ++ echo "
Aggregate Interfaces:
th Percentile:
Fit to Data:
Fit to Speed:
X Size:
Y Size:
BorderB:
\n"; + } + +-if (($bt || $smonth) && $iid) { ++if (($bt != "" || $smonth != "") && ($iid != "")) { + + /* Format into GNU date syntax */ + if ($bt == "") { +@@ -148,67 +154,84 @@ if (($bt || $smonth) && $iid) { + $et = strtotime("$eyear-$emonth-$eday $ehour:$emin:59"); + } + +- $range="dtime>FROM_UNIXTIME($bt) AND dtime<=FROM_UNIXTIME($et)"; *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***