Index: head/net/rtg/Makefile =================================================================== --- head/net/rtg/Makefile +++ head/net/rtg/Makefile @@ -2,18 +2,17 @@ # $FreeBSD$ PORTNAME= rtg -PORTVERSION= 0.7.4 -PORTREVISION= 21 +PORTVERSION= 0.7.5 CATEGORIES= net -MASTER_SITES= SF \ - ftp://ftpmirror.uk/freebsd-ports/rtg/ +MASTER_SITES= ftp://ftpmirror.uk/freebsd-ports/rtg/ MAINTAINER= freebsd-ports@dan.me.uk COMMENT= Flexible, high-performance SNMP statistics monitoring system LICENSE= GPLv2 -LIB_DEPENDS= libnetsnmp.so:net-mgmt/net-snmp +LIB_DEPENDS= libnetsnmp.so:net-mgmt/net-snmp \ + libgd.so:graphics/gd RUN_DEPENDS= p5-DBI>=0:databases/p5-DBI \ p5-DBD-mysql>=0:databases/p5-DBD-mysql @@ -21,31 +20,30 @@ USE_RC_SUBR= rtgpoll SHEBANG_FILES= etc/95.pl etc/report.pl etc/rtgtargmkr.pl.in -SUB_FILES= pkg-message GNU_CONFIGURE= yes CONFIGURE_ARGS+= --sysconfdir=${PREFIX}/etc/${PORTNAME} \ + --htmldir=${PREFIX}/www/data \ --with-mysql=${LOCALBASE} \ + --with-gd=${LOCALBASE} \ --with-snmp=${LOCALBASE} +CFLAGS+= -fstack-protector +LDFLAGS+= -fstack-protector + USERS= rtg GROUPS= rtg OPTIONS_DEFINE= WEB MYSQL -OPTIONS_DEFAULT=WEB MYSQL_DESC= Pull MySQL server in as a dependancy for local setups WEB_DESC= Include PHP-based web client interface pre-requisites MYSQL_USES= mysql:server -WEB_USES= php -WEB_USE= PHP=mysqli,spl +WEB_USES= php +WEB_USE= PHP=mysqli,spl +WEB_SUB_FILES= pkg-message -CFLAGS+= -fstack-protector -LDFLAGS+= -fstack-protector - post-patch: - @${MV} ${WRKSRC}/etc/rtg.conf ${WRKSRC}/etc/rtg.conf.sample - @${MV} ${WRKSRC}/etc/routers ${WRKSRC}/etc/routers.sample @${REINPLACE_CMD} -e "s|%%PREFIX%%|${PREFIX}|g" ${WRKSRC}/etc/95.pl @${REINPLACE_CMD} -e "s|%%PREFIX%%|${PREFIX}|g" ${WRKSRC}/etc/report.pl @${REINPLACE_CMD} -e "s|%%PREFIX%%|${PREFIX}|g" ${WRKSRC}/etc/common.php.in Index: head/net/rtg/distinfo =================================================================== --- head/net/rtg/distinfo +++ head/net/rtg/distinfo @@ -1,2 +1,3 @@ -SHA256 (rtg-0.7.4.tar.gz) = db0dfefe335d551aaaa3e60876a1431916e7db55c980902413711512dd2132a0 -SIZE (rtg-0.7.4.tar.gz) = 710621 +TIMESTAMP = 1612622708 +SHA256 (rtg-0.7.5.tar.gz) = c0f4632e26423689037634ed59194dbfb017af57079b9039e33381d3698d6fe8 +SIZE (rtg-0.7.5.tar.gz) = 269657 Index: head/net/rtg/files/patch-cgilib-0.4_cgi.c =================================================================== --- head/net/rtg/files/patch-cgilib-0.4_cgi.c +++ head/net/rtg/files/patch-cgilib-0.4_cgi.c @@ -1,15 +0,0 @@ ---- 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 - Index: head/net/rtg/files/patch-config_config.h.in =================================================================== --- head/net/rtg/files/patch-config_config.h.in +++ head/net/rtg/files/patch-config_config.h.in @@ -1,27 +0,0 @@ ---- 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 Index: head/net/rtg/files/patch-configure =================================================================== --- head/net/rtg/files/patch-configure +++ head/net/rtg/files/patch-configure @@ -1,43 +0,0 @@ ---- configure.orig 2003-10-02 15:59:33 UTC -+++ configure -@@ -328,6 +328,8 @@ sbindir='${exec_prefix}/sbin' - libexecdir='${exec_prefix}/libexec' - datadir='${prefix}/share' - sysconfdir='${prefix}/etc' -+etcdir='${prefix}/etc/rtg' -+webdir='${prefix}/www/data' - sharedstatedir='${prefix}/com' - localstatedir='${prefix}/var' - libdir='${exec_prefix}/lib' -@@ -558,6 +560,12 @@ do - | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) - sysconfdir=$ac_optarg ;; - -+ -etcdir=* | --etcdir=* ) -+ etcdir=$ac_optarg ;; -+ -+ -webdir=* | --webdir=* ) -+ webdir=$ac_optarg ;; -+ - -target | --target | --targe | --targ | --tar | --ta | --t) - ac_prev=target_alias ;; - -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) -@@ -654,7 +662,8 @@ done - - # Be sure to have absolute paths. - for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \ -- localstatedir libdir includedir oldincludedir infodir mandir -+ localstatedir libdir includedir oldincludedir infodir mandir \ -+ etcdir webdir - do - eval ac_val=$`echo $ac_var` - case $ac_val in -@@ -5310,6 +5319,8 @@ s,@sbindir@,$sbindir,;t t - s,@libexecdir@,$libexecdir,;t t - s,@datadir@,$datadir,;t t - s,@sysconfdir@,$sysconfdir,;t t -+s,@etcdir@,$etcdir,;t t -+s,@webdir@,$webdir,;t t - s,@sharedstatedir@,$sharedstatedir,;t t - s,@localstatedir@,$localstatedir,;t t - s,@libdir@,$libdir,;t t Index: head/net/rtg/files/patch-etc_95.php =================================================================== --- head/net/rtg/files/patch-etc_95.php +++ head/net/rtg/files/patch-etc_95.php @@ -1,288 +0,0 @@ ---- 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
"; - ?> -- -- -+ -+ Index: head/net/rtg/files/patch-etc_95.pl =================================================================== --- head/net/rtg/files/patch-etc_95.pl +++ head/net/rtg/files/patch-etc_95.pl @@ -1,4 +1,4 @@ ---- etc/95.pl.orig 2018-04-02 20:14:41 UTC +--- etc/95.pl.orig 2020-09-23 14:55:01 UTC +++ etc/95.pl @@ -31,7 +31,7 @@ $pass="rtgdefault"; $onedaysec=60*60*24; @@ -9,52 +9,3 @@ 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 - . Index: head/net/rtg/files/patch-etc_Makefile.in =================================================================== --- head/net/rtg/files/patch-etc_Makefile.in +++ head/net/rtg/files/patch-etc_Makefile.in @@ -1,49 +0,0 @@ ---- 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: Index: head/net/rtg/files/patch-etc_SNMP__util.pm =================================================================== --- head/net/rtg/files/patch-etc_SNMP__util.pm +++ head/net/rtg/files/patch-etc_SNMP__util.pm @@ -1,22 +0,0 @@ ---- 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; Index: head/net/rtg/files/patch-etc_common.php.in =================================================================== --- head/net/rtg/files/patch-etc_common.php.in +++ head/net/rtg/files/patch-etc_common.php.in @@ -1,22 +1,10 @@ ---- etc/common.php.in.orig 2003-09-26 15:52:29 UTC +--- etc/common.php.in.orig 2020-09-22 19:52:22 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; -+cat <$MYSQL_FILE -+CREATE USER '$USER'@'$HOST' IDENTIFIED BY '$RTG_PASS'; -+GRANT ALL ON '$DATABASE'.* TO '$USER'@'$HOST'; - EOT - --cat </tmp/rtg.sql -+cat <$RTG_FILE - # - # 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 - - echo "Adding user \"$USER\" to MySQL database..." --cat /tmp/mysql.sql | $MYSQLBIN/mysql -u root -p$ROOTPASS mysql -+cat $MYSQL_FILE | $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 -+cat $RTG_FILE | $MYSQLBIN/mysql -u $USER -p$RTGPASS $DATABASE - echo "Done." Index: head/net/rtg/files/patch-etc_report.pl =================================================================== --- head/net/rtg/files/patch-etc_report.pl +++ head/net/rtg/files/patch-etc_report.pl @@ -1,4 +1,4 @@ ---- etc/report.pl.orig 2018-04-02 20:14:41 UTC +--- etc/report.pl.orig 2020-09-23 14:55:01 UTC +++ etc/report.pl @@ -30,7 +30,7 @@ $pass="rtgdefault"; $onedaysec=60*60*24; @@ -9,52 +9,3 @@ 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 - . Index: head/net/rtg/files/patch-etc_rtg.conf =================================================================== --- head/net/rtg/files/patch-etc_rtg.conf +++ head/net/rtg/files/patch-etc_rtg.conf @@ -1,10 +0,0 @@ ---- 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 -+ Index: head/net/rtg/files/patch-etc_rtg.php =================================================================== --- head/net/rtg/files/patch-etc_rtg.php +++ head/net/rtg/files/patch-etc_rtg.php @@ -1,389 +0,0 @@ ---- 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)"; -- $range="$range AND id=$iid[0]"; -+ $range="`dtime`>FROM_UNIXTIME(" . mysqli_real_escape_string($dbc, $bt) . ") AND " . -+ "`dtime`<=FROM_UNIXTIME(" . mysqli_real_escape_string($dbc, $et) . ") " . -+ "AND `id`=" . mysqli_real_escape_string($dbc, $iid[0]); - -- $selectQuery="SELECT description, name, speed FROM interface WHERE rid=$rid AND id=$iid[0]"; -- $selectResult=mysql_query($selectQuery, $dbc); -- $selectRow=mysql_fetch_object($selectResult); -- echo "\n"; -- echo "\n"; -- echo "\n"; -- printf ("\n", $selectRow->speed / 1000000); -- echo "\n"; -- print strftime("\n", $et); -- echo "
Device:$router ($rid)
Interface:$selectRow->name ($iid[0])
Speed:%2.3f Mbps
Description:$selectRow->description
Period:%m/%d/%Y %H:%M - ", $bt); -- print strftime("%m/%d/%Y %H:%M
\n"; -- echo "

\n"; -+ $selectQuery="SELECT `description`, `name`, `speed` FROM `interface` WHERE " . -+ "`rid`=" . mysqli_real_escape_string($dbc, $rid) . " AND `id`=" . -+ mysqli_real_escape_string($dbc, $iid[0]); -+ $selectResult=mysqli_query($dbc, $selectQuery); -+ $selectRow=mysqli_fetch_object($selectResult); -+ echo "\n"; -+ echo "\n"; -+ echo "\n"; -+ printf ("\n", $selectRow->speed / 1000000); -+ echo "\n"; -+ print strftime("\n", $et); -+ echo "\n"; -+ echo "
Device:$router ($rid)
Interface:$selectRow->name ($iid[0])
Speed:%2.3f Mbps
Description:$selectRow->description
Period:%m/%d/%Y %H:%M - ", $bt); -+ print strftime("%m/%d/%Y %H:%M
\n"; -+ echo "

\n"; - - #$selectQuery="SELECT DISTINCT id FROM ifInOctets_$rid WHERE $range"; -- #$selectResult=mysql_query($selectQuery, $dbc); -- #if (mysql_num_rows($selectResult) <= 0) { -+ #$selectResult=mysqli_query($dbc, $selectQuery); -+ #if (mysqli_num_rows($selectResult) <= 0) { - # print "
No Data Found on Interface for Given Range.
\n"; - #} - #else { -- $args = "t1=ifInOctets_$rid&t2=ifOutOctets_$rid&begin=$bt&end=$et&units=bits/s&factor=8"; -+ $args = "t1=ifInOctets_$rid&t2=ifOutOctets_$rid&begin=$bt&"; -+ $args .= "end=$et&units=bits/s&factor=8"; -+ $args .= "&title=" . urlencode($selectRow->description); -+ $args .= "&t1_name=" . urlencode("Input Octets"); -+ $args .= "&t2_name=" . urlencode("Output Octets"); - foreach ($iid as $value) { -- $args="$args&iid=$value"; -+ $args="$args&iid=" . urlencode($value); - } -- if ($scalex) $args = "$args&scalex=yes"; -- if ($scaley) $args = "$args&scaley=yes"; -- if ($xplot) $args = "$args&xplot=$xplot"; -- if ($yplot) $args = "$args&yplot=$yplot"; -- if ($borderb) $args = "$args&borderb=$borderb"; -- if ($aggr) $args = "$args&aggr=yes"; -- if ($percentile) $args = "$args&percentile=$nth"; -- print "
\n"; -- $args = "t1=ifInUcastPkts_$rid&t2=ifOutUcastPkts_$rid&begin=$bt&end=$et&units=pkts/s"; -+ if ($scalex != "") $args = "$args&scalex=yes"; -+ if ($scaley != "") $args = "$args&scaley=yes"; -+ if ($xplot != "") $args = "$args&xplot=$xplot"; -+ if ($yplot != "") $args = "$args&yplot=$yplot"; -+ if ($borderb != "") $args = "$args&borderb=$borderb"; -+ if ($aggr != "") $args = "$args&aggr=yes"; -+ if ($percentile != "") $args = "$args&percentile=$nth"; -+ print "\"graph\"
\n"; -+ $args = "t1=ifInUcastPkts_$rid&t2=ifOutUcastPkts_$rid&begin=$bt&"; -+ $args .= "end=$et&units=pkts/s"; -+ $args .= "&title=" . urlencode($selectRow->description); -+ $args .= "&t1_name=" . urlencode("Input Packets"); -+ $args .= "&t2_name=" . urlencode("Output Packets"); - foreach ($iid as $value) { -- $args="$args&iid=$value"; -+ $args="$args&iid=" . urlencode($value); -+ } -+ if ($scalex != "") $args = "$args&scalex=yes"; -+ if ($xplot != "") $args = "$args&xplot=$xplot"; -+ if ($yplot != "") $args = "$args&yplot=$yplot"; -+ if ($borderb != "") $args = "$args&borderb=$borderb"; -+ if ($aggr != "") $args = "$args&aggr=yes"; -+ if ($percentile != "") $args = "$args&percentile=$nth"; -+ print "\"graph\"
\n"; -+ if ($errors != "") -+ { -+ print "\"graph\"\n"; - } -- if ($scalex) $args = "$args&scalex=yes"; -- if ($xplot) $args = "$args&xplot=$xplot"; -- if ($yplot) $args = "$args&yplot=$yplot"; -- if ($borderb) $args = "$args&borderb=$borderb"; -- if ($aggr) $args = "$args&aggr=yes"; -- if ($percentile) $args = "$args&percentile=$nth"; -- print "
\n"; -- if ($errors) -- print "\n"; - # } - } - --mysql_close($dbc); -+mysqli_close($dbc); - ?> - --

-- --

--
--
-- -+

-+ -+ -+
-+


-+ - RTG Version $VERSION"; --?> -- -- -+ print "RTG Version $VERSION
"; -+?>

-+ -+ Index: head/net/rtg/files/patch-etc_rtgtargmkr.pl.in =================================================================== --- head/net/rtg/files/patch-etc_rtgtargmkr.pl.in +++ head/net/rtg/files/patch-etc_rtgtargmkr.pl.in @@ -1,110 +1,11 @@ ---- etc/rtgtargmkr.pl.in.orig 2018-04-02 20:14:41 UTC +--- etc/rtgtargmkr.pl.in.orig 2020-09-23 11:57:31 UTC +++ etc/rtgtargmkr.pl.in -@@ -10,10 +10,11 @@ - # Local customization - - $community = "public"; # Default SNMP community --$defbits = 32; # Default OID bits: 32/64 -+$defbits = 64; # Default OID bits: 32/64 - $output = "targets.cfg"; # Output target file name - $router_file = "routers"; # Input list of devices to poll - $conf_file = "rtg.conf"; # RTGpoll and RTGplot configurations -+$update_desc = 0; # Update interface descriptions - $INFO = 1; # Print informational messages - $DEBUG = 0; # Print debug messages - $DBOFF = 0; # Turn database queries off (debug) -@@ -77,7 +78,7 @@ $catalyst = [ +@@ -78,7 +78,7 @@ $catalyst = [ ); # Default locations to find RTG configuration file -@configs = ("rtg.conf", "/usr/local/rtg/etc/rtg.conf", "/etc/rtg.conf"); -+@configs = ("rtg.conf", "@RTG_HOME@/etc/rtg.conf", "/usr/local/rtg/etc/rtg.conf", "/etc/rtg.conf"); ++@configs = ("rtg.conf", "%%PREFIX%%/etc/rtg/rtg.conf", "/usr/local/rtg/etc/rtg.conf", "/etc/rtg.conf"); foreach $conf (@configs) { if (open CONF, "<$conf") { print "Reading [$conf].\n" if $DEBUG; -@@ -93,7 +94,9 @@ foreach $conf (@configs) { - $db_db=$cVals[1]; - } elsif ($cVals[0] =~ /Interval/) { - $interval=$cVals[1]; -- } -+ } elsif ($cVals[0] =~ /Update_desc/) { -+ $update_desc=$cVals[1]; -+ } - } - last; - } -@@ -113,7 +116,7 @@ sub sql_insert { - # exist, create a new entry and corresponding tables. - sub find_router_id { - ($router) = @_; -- $sql = "SELECT DISTINCT rid FROM router WHERE name=\"$router\""; -+ $sql = "SELECT DISTINCT `rid` FROM `router` WHERE `name`=\"$router\""; - print "SQL: $sql\n" if $DEBUG; - my $sth = $dbh->prepare($sql) - or die "Can't prepare $sql: $dbh->errstr\n"; -@@ -121,12 +124,12 @@ sub find_router_id { - or die "can't execute the query: $sth->errstr\n"; - if ( $sth->rows == 0 ) { - print "No router id found for $router..."; -- $sql = "INSERT INTO router (name) VALUES(\"$router\")"; -+ $sql = "INSERT INTO `router` (`name`) VALUES(\"$router\")"; - print "adding.\n"; - &sql_insert($sql); - $rid = &find_router_id($router); - foreach $mib ( keys %mibs_of_interest ) { -- $sql = "CREATE TABLE $mib"."_$rid (id INT NOT NULL, dtime DATETIME NOT NULL, counter BIGINT NOT NULL, KEY $mib"."_$rid". "_idx (dtime))"; -+ $sql = "CREATE TABLE `$mib"."_$rid` (`id` INT NOT NULL, `dtime` DATETIME NOT NULL, `counter` BIGINT NOT NULL, KEY `$mib"."_$rid". "_idx` (`dtime`), KEY `id_dtime_idx` (`id`,`dtime`))"; - &sql_insert($sql); - } - } -@@ -143,7 +146,7 @@ sub find_router_id { - sub find_interface_id { - ( $rid, $int, $desc, $speed ) = @_; - $desc =~ s/ +$//g; #remove trailing whitespace -- $sql = "SELECT id, description FROM interface WHERE rid=$rid AND name=\"$int\""; -+ $sql = "SELECT `id`, `description` FROM `interface` WHERE `rid`=$rid AND `name`=\"$int\""; - print "SQL: $sql\n" if $DEBUG; - my $sth = $dbh->prepare($sql) - or die "Can't prepare $sql: $dbh->errstr\n"; -@@ -152,7 +155,7 @@ sub find_interface_id { - if ( $sth->rows == 0 ) { - print "No id found for $int on device $rid..."; - $desc =~ s/\"/\\\"/g; # Fix " in desc -- $sql = "INSERT INTO interface (name, rid, speed, description) VALUES(\"$int\", $rid, $speed, \"$desc\")"; -+ $sql = "INSERT INTO `interface` (`name`, `rid`, `speed`, `description`) VALUES(\"$int\", $rid, $speed, \"$desc\")"; - print "adding.\n"; - &sql_insert($sql); - $iid = &find_interface_id( $rid, $int, $desc, $speed ); -@@ -164,7 +167,13 @@ sub find_interface_id { - print "Interface description changed.\n"; - print "Was: \"$row[1]\"\n"; - print "Now: \"$desc\"\n"; -- print "Suggest: UPDATE interface SET description='$desc' WHERE id=$iid\n"; -+ if ( $update_desc == 1 ) { -+ $sql = "UPDATE `interface` SET `description`='$desc' WHERE `id`=$iid"; -+ &sql_insert($sql); -+ print "Updated.\n"; -+ } else { -+ print "Suggest: UPDATE `interface` SET `description`='$desc' WHERE `id`=$iid\n"; -+ } - } - } - $sth->finish; -@@ -289,7 +298,7 @@ sub main { - $year + 1900, $hour, $min; - print CFG "# Host\tOID\tBits\tCommunity\tTable\tID\tDescription\n"; - -- foreach $router (@routers) { -+ POKE: foreach $router (@routers) { - $bits = $counterBits{$router}; - # Sanity check bits - $bits = $defbits if ( ( $bits != 32 ) && ( $bits != 64 ) ); -@@ -304,7 +313,7 @@ sub main { - $system = join ( ' ', @result ); - print "System: $system\n" if $DEBUG; - $session = SNMP_Session->open( $router, $communities{$router}, 161 ) -- || die "Error opening SNMP session to $router"; -+ || ( print "Error opening SNMP session to $router" and next POKE ); - if ( $system =~ /.*Cisco.*WS-.*/ ) { - $system = "Catalyst"; - $session->map_table( $catalyst, \&process ); Index: head/net/rtg/files/patch-etc_view.php =================================================================== --- head/net/rtg/files/patch-etc_view.php +++ head/net/rtg/files/patch-etc_view.php @@ -1,258 +0,0 @@ ---- etc/view.php.orig 2003-09-26 15:58:34 UTC -+++ etc/view.php -@@ -8,154 +8,163 @@ - header("Cache-Control: no-cache, must-revalidate"); - header("Pragma: no-cache"); - -- print "\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); - - # Global variables off by default in newer versions of PHP -- if (!$PHP_SELF) { -+ if (!isset($PHP_SELF) || ($PHP_SELF == "")) { - $PHP_SELF = "view.php"; -- $rid = $_GET['rid']; -- $iid = $_GET['iid']; -+ $rid = isset($_GET['rid'])?$_GET['rid']:""; -+ $iid = isset($_GET['iid'])?$_GET['iid']:""; - } - - # 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"; -- $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); -+ $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"; - -- print "\n"; -- print "\n"; -- print "\n"; -- print "\n"; -- print "\n"; -- print "\n"; -- print "\n"; -+ print "\n"; -+ print "\n"; -+ print "\n"; -+ print "\n"; -+ print "\n"; -+ print "\n"; -+ print "\n"; - ?> - -- -- -- --


-+ -+ -+


- - \n"; -+ echo "
\n"; - - $et = time(); - -- if (!$rid) { -+ if ($rid == "") { - print "Monitored Devices:

\n"; -- $selectQuery="SELECT rid, name FROM router"; -- $selectResult=mysql_query($selectQuery, $dbc); -- if (mysql_num_rows($selectResult) <= 0) -- print "
No Routers Found.
\n"; -+ $selectQuery="SELECT `rid`, `name` FROM `router`"; -+ $selectResult=mysqli_query($dbc, $selectQuery); -+ if (mysqli_num_rows($selectResult) <= 0) -+ print "
No Routers Found.
\n"; - else { -- print "

\n"; - } - } - -- if ($rid && $iid) { -+ if (($rid != "") && ($iid != "")) { - if ($interfaces <= 0) -- print "
Interface $iid Not Found for Router $router (ID: $rid).
\n"; -+ print "
Interface $iid Not Found for Router $router (ID: $rid).
\n"; - else { -- print "\n"; -- print "
System:$router\n"; -- print "
Interface:$name\n"; -- print "
Description:$description\n"; -- print "
Speed:$speed Mbps\n"; -- print "
Page Generated:".gmdate('D, d M Y H:i:s \G\M\T', time())."\n"; -- print "

\n"; -+ print "\n"; -+ print "\n"; -+ print "\n"; -+ print "\n"; -+ print "\n"; -+ print "\n"; -+ print "
System:$router
Interface:$name
Description:$description
Speed:$speed Mbps
Page Generated:".gmdate('D, d M Y H:i:s \G\M\T', time())."

\n"; - - $bt = $et - (60*60*24); -- print "Day View:
\n"; -- print "\n"; -- print "
$router: $name ($description)\n"; -- print "

\n"; -+ print "Day View:
\n"; -+ print "\n"; -+ print "
$router: $name ($description)\n"; -+ print "

\n"; - - $bt = $et - (60*60*24*7); -- print "Week View:
\n"; -- print "\n"; -- print "
$router: $name ($description)\n"; -- print "

\n"; -+ print "Week View:
\n"; -+ print "\n"; -+ print "
$router: $name ($description)\n"; -+ print "

\n"; - - $bt = $et - (60*60*24*30); -- print "Month View:
\n"; -- print "\n"; -- print "
$router: $name ($description)\n"; -- print "

\n"; -+ print "Month View:
\n"; -+ print "\n"; -+ print "
$router: $name ($description)\n"; -+ print "

\n"; - } -- print "\n"; -+ print "\n"; - } - -- if ($rid && !$iid) { -- $selectQuery="SELECT id, name, description FROM interface WHERE rid=$rid"; -- $selectResult=mysql_query($selectQuery, $dbc); -- $interfaces = mysql_num_rows($selectResult); -+ if (($rid != "") && ($iid == "")) { -+ $selectQuery="SELECT `id`, `name`, `description` FROM `interface` WHERE " . -+ "`rid`=" . mysqli_real_escape_string($dbc, $rid); -+ $selectResult=mysqli_query($dbc, $selectQuery); -+ $interfaces = mysqli_num_rows($selectResult); - if ($interfaces <= 0) -- print "
No Interfaces Found for Router $router (ID: $rid).
\n"; -+ print "
No Interfaces Found for Router $router (ID: $rid).
\n"; - else { - $bt = $et - (60*60*12); -- print "\n"; -- print "
System:$router\n"; -- print "
Interfaces:$interfaces\n"; -- print "
Page Generated:"; -- print gmdate('D, d M Y H:i:s \G\M\T', time())."\n"; -- print "

\n"; -- print "\n"; -- while ($selectRow=mysql_fetch_object($selectResult)){ -+ print "
\n"; -+ print "\n"; -+ print "\n"; -+ print "\n"; -+ print "
System:$router
Interfaces:$interfaces
Page Generated:"; -+ print gmdate('D, d M Y H:i:s \G\M\T', time())."

\n"; -+ print "\n"; -+ print "\n"; -+ while ($selectRow=mysqli_fetch_object($selectResult)){ - $ids[$selectRow->id] = $selectRow->name; - $desc[$selectRow->id] = $selectRow->description; - $iid = $selectRow->id; -- print "\n"; -+ print "\n"; - } - else $even = 1; - } -- print "
\n"; -- print "\n"; -- print "
\n"; -- print "$selectRow->name ($selectRow->description)\n"; -- if ($even) { -+ print "
\n"; -+ print "name . " (" . $selectRow->description . ")"); -+ print "&t1_name=" . urlencode("Input Octets") . "&t2_name=" . urlencode("Output Octets"); -+ print "&iid=$iid&begin=$bt&end=$et&units=bits/s&factor=8&filled=yes\" border=\"0\" />\n"; -+ print "
\n"; -+ print "$selectRow->name ($selectRow->description)\n"; -+ if ($even == 1) { - $even = 0; -- print "
\n"; -+ print "\n"; - } -- print "\n"; -+ print "\n"; - } - -- if ($dbc) mysql_close($dbc); -- echo "
\n"; -+ if ($dbc) mysqli_close($dbc); -+ echo "\n"; - ?> - --
-- -+
-+ - RTG Version $VERSION"; -+ print "RTG Version $VERSION
"; - ?> -- -- -+ -+ Index: head/net/rtg/files/patch-man_rtgplot.1 =================================================================== --- head/net/rtg/files/patch-man_rtgplot.1 +++ head/net/rtg/files/patch-man_rtgplot.1 @@ -1,43 +0,0 @@ ---- man/rtgplot.1.orig 2003-09-25 04:10:36 UTC -+++ man/rtgplot.1 -@@ -10,7 +10,8 @@ - -t tablename(s) -i interface(s) [options] begin end - .br - .B rtgplot.cgi --?t1=tablename &t2=tablename &iid=interface &begin=unixtime &end=unixtime &[options] -+?t1=tablename &t`_name=descname &t2=tablename &t2_name=descname &iid=interface -+&begin=unixtime &end=unixtime &[options] - .SH DESCRIPTION - .I rtgplot - generates traffic plots of RTG data in PNG format. It operates in -@@ -82,14 +83,19 @@ pixels. - Set plot bottom border to - .RI - pixels. -+.TP -+.IR "title=" -+Set graph title to -+.RI <title> - .PP - .SH "EXAMPLES" - .PP - .br - Example HTML IMG TAG: - .PP --<IMG SRC="rtgplot.cgi? t1=ifInOctets_2& t2=ifOutOctets_2& iid=4& --begin=1046754000& end=1046840399& units=bits/s& factor=8& scalex=yes"> -+<IMG SRC="rtgplot.cgi? t1=ifInOctets_2& t1_name=Input& t2=ifOutOctets_2& -+t2_name=Output& iid=4& begin=1046754000& end=1046840399& units=bits/s& -+factor=8& scalex=yes& title=Bandwidth+Graph"> - .PP - will plot two lines from the MySQL tables ifInOctets_2 and ifOutOctets_2 - corresponding to interface 4 on router 2 for the time span 1046754000 to -@@ -97,6 +103,8 @@ corresponding to interface 4 on router 2 - second; the units argument is displayed as the Y-axis label on the plot. - The scalex argument auto-adjusts the X time axis according to the available - data samples rather than according to the actual time span given. -+It will have a graph title of "Bandwidth Graph" and legend tags of "Input" -+and "Output" for t1 and t2 respectively. - .PP - Draw a 95th percentile line: - .PP Index: head/net/rtg/files/patch-man_rtgpoll.1 =================================================================== --- head/net/rtg/files/patch-man_rtgpoll.1 +++ head/net/rtg/files/patch-man_rtgpoll.1 @@ -1,12 +0,0 @@ ---- man/rtgpoll.1.orig 2003-09-24 17:26:57 UTC -+++ man/rtgpoll.1 -@@ -31,6 +31,9 @@ Disable database inserts. - .IR "\-m" - Skip checking for multiple instances. - .TP -+.IR "\-p file" -+PID file. Process ID file. -+.TP - .IR "\-z" - Force database insertion of zero deltas. - .TP Index: head/net/rtg/files/patch-src_rtg.h =================================================================== --- head/net/rtg/files/patch-src_rtg.h +++ head/net/rtg/files/patch-src_rtg.h @@ -1,33 +0,0 @@ ---- src/rtg.h.orig 2003-09-25 15:56:04 UTC -+++ src/rtg.h -@@ -40,12 +40,10 @@ - #define DEFAULT_DB_DB "rtg" - #define DEFAULT_DB_USER "snmp" - #define DEFAULT_DB_PASS "rtgdefault" --#define DEFAULT_SNMP_VER 1 -+#define DEFAULT_SNMP_VER 2 - #define DEFAULT_SNMP_PORT 161 -+#define DEFAULT_PIDFILE "/tmp/rtgpoll.pid" - --/* PID File */ --#define PIDFILE "/tmp/rtgpoll.pid" -- - #define STAT_DESCRIP_ERROR 99 - #define HASHSIZE 5000 - -@@ -175,10 +173,10 @@ int add_hash_entry(target_t *); - int hash_target_file(char *); - - /* Globals */ --config_t set; --int lock; --int waiting; --char config_paths[CONFIG_PATHS][BUFSIZE]; --hash_t hash; -+extern config_t set; -+extern int lock; -+extern int waiting; -+extern char config_paths[CONFIG_PATHS][BUFSIZE]; -+extern hash_t hash; - - #endif /* not _RTG_H_ */ Index: head/net/rtg/files/patch-src_rtgplot.h =================================================================== --- head/net/rtg/files/patch-src_rtgplot.h +++ head/net/rtg/files/patch-src_rtgplot.h @@ -1,26 +0,0 @@ ---- src/rtgplot.h.orig 2003-09-24 14:43:39 UTC -+++ src/rtgplot.h -@@ -11,6 +11,7 @@ - - #include <gd.h> - #include <gdfonts.h> -+#include <gdfontmb.h> - #include <strings.h> - - #define XPLOT_AREA 500 -@@ -95,6 +96,7 @@ typedef struct graph_struct { - int scaley; - range_t range; - image_t image; -+ char *titlestr; - } graph_t; - - /* A linked list of colors that we iterate through each line */ -@@ -106,6 +108,7 @@ typedef struct color_struct { - - typedef struct arguments_struct { - char *table[MAXTABLES]; -+ char *tablename[MAXTABLES]; - int iid[MAXIIDS]; - int tables_to_plot; - int iids_to_plot; Index: head/net/rtg/files/patch-src_rtgplot.c =================================================================== --- head/net/rtg/files/patch-src_rtgplot.c +++ head/net/rtg/files/patch-src_rtgplot.c @@ -1,84 +0,0 @@ ---- src/rtgplot.c.orig 2003-10-02 15:27:52 UTC -+++ src/rtgplot.c -@@ -54,6 +54,9 @@ - #include "rtgplot.h" - #include "cgi.h" - -+config_t set; -+char config_paths[CONFIG_PATHS][BUFSIZE]; -+ - /* dfp is a debug file pointer. Points to stderr unless debug=level is set */ - FILE *dfp = NULL; - -@@ -221,7 +224,10 @@ int main(int argc, char **argv) { - plot_line(data[i][j], &img, &graph, colors->shade, TRUE); - else - plot_line(data[i][j], &img, &graph, colors->shade, FALSE); -- snprintf(intname, sizeof(intname), "%s%d", arguments.table[i], arguments.iid[j]); -+ if (arguments.tablename[i]) -+ snprintf(intname, sizeof(intname), "%s", arguments.tablename[i]); -+ else -+ snprintf(intname, sizeof(intname), "%s%d", arguments.table[i], arguments.iid[j]); - plot_legend(&img, rate[i][j], &graph, colors->shade, intname, offset); - offset++; - } -@@ -629,15 +635,15 @@ void plot_legend(gdImagePtr * img, rate_t rate, graph_ - if (set.verbose >= HIGH) - fprintf(dfp, "Plotting legend (%s).\n", __FUNCTION__); - -- gdImageFilledRectangle(*img, BORDER_L, -+ gdImageFilledRectangle(*img, BORDER_L - 10, - BORDER_T + graph->image.yplot_area + 37 + 10 * offset, -- BORDER_L + 7, BORDER_T + graph->image.yplot_area + 44 + 10 * offset, color); -- gdImageRectangle(*img, BORDER_L, BORDER_T + graph->image.yplot_area + 37 + 10 * offset, -- BORDER_L + 7, BORDER_T + graph->image.yplot_area + 44 + 10 * offset, -+ BORDER_L - 3, BORDER_T + graph->image.yplot_area + 44 + 10 * offset, color); -+ gdImageRectangle(*img, BORDER_L - 10, BORDER_T + graph->image.yplot_area + 37 + 10 * offset, -+ BORDER_L - 3, BORDER_T + graph->image.yplot_area + 44 + 10 * offset, - std_colors[black]); - -- if (strlen(interface) > 17) { -- interface[17] = '\0'; -+ if (strlen(interface) > 15) { -+ interface[15] = '\0'; - } - snprintf(string, sizeof(string), "%s", interface); - for (i = 0; i < (17 - strlen(interface)); i++) { -@@ -662,7 +668,7 @@ void plot_legend(gdImagePtr * img, rate_t rate, graph_ - units(rate.cur, cur), graph->units, - units((float)rate.total, total)); - } -- gdImageString(*img, gdFontSmall, BORDER_L + 10, -+ gdImageString(*img, gdFontSmall, BORDER_L, - BORDER_T + graph->image.yplot_area + 33 + (10 * offset), string, std_colors[black]); - } - -@@ -866,6 +872,13 @@ void plot_labels(gdImagePtr * img, graph_t * graph) { - title_offset = 1 - (0.01 * (strlen(VERSION) + strlen(COPYRIGHT) + 2)); - snprintf(string, sizeof(string), "%s %s", COPYRIGHT, VERSION); - gdImageString(*img, gdFontSmall, BORDER_L + (graph->image.xplot_area * title_offset), BORDER_T - 15, string, std_colors[black]); -+ -+ /* title */ -+ if (graph->titlestr) -+ { -+ snprintf(string, sizeof(string), "%s", graph->titlestr); -+ gdImageString(*img, gdFontMediumBold, BORDER_L + 5, BORDER_T - 16, string, std_colors[black]); -+ } - } - - -@@ -1342,10 +1355,14 @@ void parseWeb(arguments_t *arguments, graph_t *graph) - } - } - /* XXX REB - Warning: Deprecated, tN argument will go away in RTG 0.8 XXX */ -+ snprintf(var, sizeof(var), "title"); -+ graph->titlestr = cgiGetValue(cgiArg, var); - for (i = 0; i < MAXTABLES; i++) { - snprintf(var, sizeof(var), "t%d", i + 1); - if ((arguments->table[i] = cgiGetValue(cgiArg, var))) - arguments->tables_to_plot++; -+ snprintf(var, sizeof(var), "t%d_name", i + 1); -+ arguments->tablename[i] = cgiGetValue(cgiArg, var); - } - if ((graph->units = cgiGetValue(cgiArg, "units")) == NULL) { - graph->units = malloc(sizeof(DEFAULT_UNITS)); Index: head/net/rtg/files/patch-src_rtgpoll.c =================================================================== --- head/net/rtg/files/patch-src_rtgpoll.c +++ head/net/rtg/files/patch-src_rtgpoll.c @@ -1,71 +0,0 @@ ---- src/rtgpoll.c.orig 2003-09-25 15:56:04 UTC -+++ src/rtgpoll.c -@@ -9,10 +9,13 @@ - #include "common.h" - #include "rtg.h" - -+char config_paths[CONFIG_PATHS][BUFSIZE]; -+ - /* Yes. Globals. */ - stats_t stats = - {PTHREAD_MUTEX_INITIALIZER, 0, 0, 0, 0, 0, 0, 0, 0, 0.0}; - char *target_file = NULL; -+char *pidfile = NULL; - target_t *current = NULL; - MYSQL mysql; - int entries = 0; -@@ -41,7 +44,7 @@ int main(int argc, char *argv[]) { - config_defaults(&set); - - /* Parse the command-line. */ -- while ((ch = getopt(argc, argv, "c:dhmt:vz")) != EOF) -+ while ((ch = getopt(argc, argv, "c:dhmp:t:vz")) != EOF) - switch ((char) ch) { - case 'c': - conf_file = optarg; -@@ -55,6 +58,9 @@ int main(int argc, char *argv[]) { - case 'm': - set.multiple++; - break; -+ case 'p': -+ pidfile = optarg; -+ break; - case 't': - target_file = optarg; - break; -@@ -66,6 +72,9 @@ int main(int argc, char *argv[]) { - break; - } - -+ if (!pidfile) -+ pidfile = DEFAULT_PIDFILE; -+ - if (set.verbose >= LOW) - printf("RTG version %s starting.\n", VERSION); - -@@ -78,7 +87,7 @@ int main(int argc, char *argv[]) { - sigaddset(&signal_set, SIGINT); - sigaddset(&signal_set, SIGQUIT); - if (!set.multiple) -- checkPID(PIDFILE); -+ checkPID(pidfile); - - if (pthread_sigmask(SIG_BLOCK, &signal_set, NULL) != 0) - printf("pthread_sigmask error\n"); -@@ -244,7 +253,7 @@ void *sig_handler(void *arg) - if (set.verbose >= LOW) - printf("Quiting: received signal %d.\n", sig_number); - rtg_dbdisconnect(&mysql); -- unlink(PIDFILE); -+ unlink(pidfile); - exit(1); - break; - } -@@ -259,6 +268,7 @@ void usage(char *prog) - printf("\nOptions:\n"); - printf(" -c <file> Specify configuration file\n"); - printf(" -d Disable database inserts\n"); -+ printf(" -p <file> Specify pid file (defaults to /tmp/rtgpoll.pid)\n"); - printf(" -t <file> Specify target file\n"); - printf(" -v Increase verbosity\n"); - printf(" -m Allow multiple instances\n"); Index: head/net/rtg/files/patch-src_rtgsnmp.c =================================================================== --- head/net/rtg/files/patch-src_rtgsnmp.c +++ head/net/rtg/files/patch-src_rtgsnmp.c @@ -1,14 +0,0 @@ ---- src/rtgsnmp.c.orig 2003-09-25 18:23:35 UTC -+++ src/rtgsnmp.c -@@ -8,6 +8,11 @@ - #include "common.h" - #include "rtg.h" - -+config_t set; -+int lock; -+int waiting; -+hash_t hash; -+ - #ifdef OLD_UCD_SNMP - #include "asn1.h" - #include "snmp_api.h" Index: head/net/rtg/files/patch-src_rtgutil.c =================================================================== --- head/net/rtg/files/patch-src_rtgutil.c +++ head/net/rtg/files/patch-src_rtgutil.c @@ -1,10 +0,0 @@ ---- src/rtgutil.c.orig 2018-04-02 23:03:54 UTC -+++ src/rtgutil.c -@@ -37,6 +37,7 @@ int read_rtg_config(char *file, config_t - else if (!strcasecmp(p1, "DB_Database")) strncpy(set->dbdb, p2, sizeof(set->dbdb)); - else if (!strcasecmp(p1, "DB_User")) strncpy(set->dbuser, p2, sizeof(set->dbuser)); - else if (!strcasecmp(p1, "DB_Pass")) strncpy(set->dbpass, p2, sizeof(set->dbpass)); -+ else if (!strcasecmp(p1, "Update_desc")) ; // no-op - - /* Long longs not ANSI C. If OS doesn't support atoll() use default. */ - else if (!strcasecmp(p1, "OutOfRange")) Index: head/net/rtg/files/rtgpoll.in =================================================================== --- head/net/rtg/files/rtgpoll.in +++ head/net/rtg/files/rtgpoll.in @@ -21,10 +21,10 @@ name="rtgpoll" rcvar=rtgpoll_enable -cmd=%%PREFIX%%/bin/${name} -command="/usr/sbin/daemon" +start_precmd="${name}_prestart" +command="%%PREFIX%%/bin/${name}" -load_rc_config $name +load_rc_config ${name} : ${rtgpoll_enable="NO"} : ${rtgpoll_config="%%PREFIX%%/etc/rtg/rtg.conf"} @@ -33,19 +33,11 @@ : ${rtgpoll_user="rtg"} : ${rtgpoll_group="rtg"} -required_files="$rtgpoll_targets" +required_files="${rtgpoll_targets}" +command_args="-b -p ${rtgpoll_pidfile} -c ${rtgpoll_config} -t ${rtgpoll_targets}" -command_args="-f -p $rtgpoll_pidfile $cmd -c $rtgpoll_config -t $rtgpoll_targets" - -start_precmd="rtgpoll_prestart" - -rtgpoll_prestart() { - if [ ! -e "${rtgpoll_pidfile}" ]; then - touch $rtgpoll_pidfile - fi - - chown "${rtgpoll_user}:${rtgpoll_group}" "$rtgpoll_pidfile" - chmod 640 "$rtgpoll_pidfile" +rtgpoll_prestart() +{ chown -R "${rtgpoll_user}:${rtgpoll_group}" "%%PREFIX%%/etc/rtg" chmod -R u+rwX,g+rX "%%PREFIX%%/etc/rtg" } Index: head/net/rtg/pkg-plist =================================================================== --- head/net/rtg/pkg-plist +++ head/net/rtg/pkg-plist @@ -4,13 +4,13 @@ bin/rtgpoll contrib/README contrib/rtgtargmkr-with-modules-0.2.tar.gz -%%ETCDIR%%/rtg.conf.sample -%%ETCDIR%%/rtgtargmkr.pl -%%ETCDIR%%/routers.sample -%%ETCDIR%%/createdb %%ETCDIR%%/BER.pm %%ETCDIR%%/SNMP_Session.pm %%ETCDIR%%/SNMP_util.pm +%%ETCDIR%%/createdb +@sample %%ETCDIR%%/routers.sample +@sample %%ETCDIR%%/rtg.conf.sample +%%ETCDIR%%/rtgtargmkr.pl include/common.h include/rtg.h include/rtgplot.h