View | Details | Raw Unified | Return to bug 253311 | Differences between
and this patch

Collapse All | Expand All

(-)net/rtg/Makefile (-14 / +12 lines)
Lines 2-12 Link Here
2
# $FreeBSD$
2
# $FreeBSD$
3
3
4
PORTNAME=	rtg
4
PORTNAME=	rtg
5
PORTVERSION=	0.7.4
5
PORTVERSION=	0.7.5
6
PORTREVISION=	21
7
CATEGORIES=	net
6
CATEGORIES=	net
8
MASTER_SITES=	SF \
7
MASTER_SITES=	ftp://ftpmirror.uk/freebsd-ports/rtg/
9
		ftp://ftpmirror.uk/freebsd-ports/rtg/
10
8
11
MAINTAINER=	freebsd-ports@dan.me.uk
9
MAINTAINER=	freebsd-ports@dan.me.uk
12
COMMENT=	Flexible, high-performance SNMP statistics monitoring system
10
COMMENT=	Flexible, high-performance SNMP statistics monitoring system
Lines 13-19 Link Here
13
11
14
LICENSE=	GPLv2
12
LICENSE=	GPLv2
15
13
16
LIB_DEPENDS=	libnetsnmp.so:net-mgmt/net-snmp
14
LIB_DEPENDS=	libnetsnmp.so:net-mgmt/net-snmp \
15
		libgd.so:graphics/gd
17
RUN_DEPENDS=	p5-DBI>=0:databases/p5-DBI \
16
RUN_DEPENDS=	p5-DBI>=0:databases/p5-DBI \
18
		p5-DBD-mysql>=0:databases/p5-DBD-mysql
17
		p5-DBD-mysql>=0:databases/p5-DBD-mysql
19
18
Lines 21-51 Link Here
21
USE_RC_SUBR=	rtgpoll
20
USE_RC_SUBR=	rtgpoll
22
21
23
SHEBANG_FILES=	etc/95.pl etc/report.pl etc/rtgtargmkr.pl.in
22
SHEBANG_FILES=	etc/95.pl etc/report.pl etc/rtgtargmkr.pl.in
24
SUB_FILES=	pkg-message
25
GNU_CONFIGURE=	yes
23
GNU_CONFIGURE=	yes
26
CONFIGURE_ARGS+=	--sysconfdir=${PREFIX}/etc/${PORTNAME} \
24
CONFIGURE_ARGS+=	--sysconfdir=${PREFIX}/etc/${PORTNAME} \
25
			--htmldir=${PREFIX}/www/data \
27
			--with-mysql=${LOCALBASE} \
26
			--with-mysql=${LOCALBASE} \
27
			--with-gd=${LOCALBASE} \
28
			--with-snmp=${LOCALBASE}
28
			--with-snmp=${LOCALBASE}
29
29
30
CFLAGS+=	-fstack-protector
31
LDFLAGS+=	-fstack-protector
32
30
USERS=		rtg
33
USERS=		rtg
31
GROUPS=		rtg
34
GROUPS=		rtg
32
35
33
OPTIONS_DEFINE=	WEB MYSQL
36
OPTIONS_DEFINE=	WEB MYSQL
34
OPTIONS_DEFAULT=WEB
35
MYSQL_DESC=	Pull MySQL server in as a dependancy for local setups
37
MYSQL_DESC=	Pull MySQL server in as a dependancy for local setups
36
WEB_DESC=	Include PHP-based web client interface pre-requisites
38
WEB_DESC=	Include PHP-based web client interface pre-requisites
37
39
38
MYSQL_USES=	mysql:server
40
MYSQL_USES=	mysql:server
39
41
40
WEB_USES=	php
42
WEB_USES=		php
41
WEB_USE=	PHP=mysqli,spl
43
WEB_USE=		PHP=mysqli,spl
44
WEB_SUB_FILES=		pkg-message
42
45
43
CFLAGS+=	-fstack-protector
44
LDFLAGS+=	-fstack-protector
45
46
post-patch:
46
post-patch:
47
	@${MV} ${WRKSRC}/etc/rtg.conf ${WRKSRC}/etc/rtg.conf.sample
48
	@${MV} ${WRKSRC}/etc/routers ${WRKSRC}/etc/routers.sample
49
	@${REINPLACE_CMD} -e "s|%%PREFIX%%|${PREFIX}|g" ${WRKSRC}/etc/95.pl
47
	@${REINPLACE_CMD} -e "s|%%PREFIX%%|${PREFIX}|g" ${WRKSRC}/etc/95.pl
50
	@${REINPLACE_CMD} -e "s|%%PREFIX%%|${PREFIX}|g" ${WRKSRC}/etc/report.pl
48
	@${REINPLACE_CMD} -e "s|%%PREFIX%%|${PREFIX}|g" ${WRKSRC}/etc/report.pl
51
	@${REINPLACE_CMD} -e "s|%%PREFIX%%|${PREFIX}|g" ${WRKSRC}/etc/common.php.in
49
	@${REINPLACE_CMD} -e "s|%%PREFIX%%|${PREFIX}|g" ${WRKSRC}/etc/common.php.in
(-)net/rtg/distinfo (-2 / +3 lines)
Lines 1-2 Link Here
1
SHA256 (rtg-0.7.4.tar.gz) = db0dfefe335d551aaaa3e60876a1431916e7db55c980902413711512dd2132a0
1
TIMESTAMP = 1612622708
2
SIZE (rtg-0.7.4.tar.gz) = 710621
2
SHA256 (rtg-0.7.5.tar.gz) = c0f4632e26423689037634ed59194dbfb017af57079b9039e33381d3698d6fe8
3
SIZE (rtg-0.7.5.tar.gz) = 269657
(-)net/rtg/files/patch-cgilib-0.4_cgi.c (-15 lines)
Lines 1-15 Link Here
1
--- cgilib-0.4/cgi.c.orig	2003-09-25 15:21:06 UTC
2
+++ cgilib-0.4/cgi.c
3
@@ -33,9 +33,12 @@
4
 #ifdef HAVE_CTYPE_H
5
 # include <ctype.h>
6
 #endif
7
+/* Unnecessary on FreeBSD; malloc.h included in stdlib.h */
8
+/*
9
 #ifdef HAVE_MALLOC_H
10
 # include <malloc.h>
11
 #endif
12
+*/
13
 
14
 #include <cgi.h>
15
 
(-)net/rtg/files/patch-config_config.h.in (-27 lines)
Lines 1-27 Link Here
1
--- config/config.h.in.orig	2003-09-25 15:21:14 UTC
2
+++ config/config.h.in
3
@@ -91,19 +91,19 @@
4
 #undef PACKAGE
5
 
6
 /* Define to the address where bug reports for this package should be sent. */
7
-#undef PACKAGE_BUGREPORT
8
+#undef RTG_PACKAGE_BUGREPORT
9
 
10
 /* Define to the full name of this package. */
11
-#undef PACKAGE_NAME
12
+#undef RTG_PACKAGE_NAME
13
 
14
 /* Define to the full name and version of this package. */
15
-#undef PACKAGE_STRING
16
+#undef RTG_PACKAGE_STRING
17
 
18
 /* Define to the one symbol short name of this package. */
19
-#undef PACKAGE_TARNAME
20
+#undef RTG_PACKAGE_TARNAME
21
 
22
 /* Define to the version of this package. */
23
-#undef PACKAGE_VERSION
24
+#undef RTG_PACKAGE_VERSION
25
 
26
 /* Define as the return type of signal handlers (`int' or `void'). */
27
 #undef RETSIGTYPE
(-)net/rtg/files/patch-configure (-43 lines)
Lines 1-43 Link Here
1
--- configure.orig	2003-10-02 15:59:33 UTC
2
+++ configure
3
@@ -328,6 +328,8 @@ sbindir='${exec_prefix}/sbin'
4
 libexecdir='${exec_prefix}/libexec'
5
 datadir='${prefix}/share'
6
 sysconfdir='${prefix}/etc'
7
+etcdir='${prefix}/etc/rtg'
8
+webdir='${prefix}/www/data'
9
 sharedstatedir='${prefix}/com'
10
 localstatedir='${prefix}/var'
11
 libdir='${exec_prefix}/lib'
12
@@ -558,6 +560,12 @@ do
13
   | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
14
     sysconfdir=$ac_optarg ;;
15
 
16
+  -etcdir=* | --etcdir=* )
17
+    etcdir=$ac_optarg ;;
18
+
19
+  -webdir=* | --webdir=* )
20
+    webdir=$ac_optarg ;;
21
+
22
   -target | --target | --targe | --targ | --tar | --ta | --t)
23
     ac_prev=target_alias ;;
24
   -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
25
@@ -654,7 +662,8 @@ done
26
 
27
 # Be sure to have absolute paths.
28
 for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \
29
-              localstatedir libdir includedir oldincludedir infodir mandir
30
+              localstatedir libdir includedir oldincludedir infodir mandir \
31
+	      etcdir webdir
32
 do
33
   eval ac_val=$`echo $ac_var`
34
   case $ac_val in
35
@@ -5310,6 +5319,8 @@ s,@sbindir@,$sbindir,;t t
36
 s,@libexecdir@,$libexecdir,;t t
37
 s,@datadir@,$datadir,;t t
38
 s,@sysconfdir@,$sysconfdir,;t t
39
+s,@etcdir@,$etcdir,;t t
40
+s,@webdir@,$webdir,;t t
41
 s,@sharedstatedir@,$sharedstatedir,;t t
42
 s,@localstatedir@,$localstatedir,;t t
43
 s,@libdir@,$libdir,;t t
(-)net/rtg/files/patch-etc_95.php (-288 lines)
Lines 1-288 Link Here
1
--- etc/95.php.orig	2003-09-24 20:40:57 UTC
2
+++ etc/95.php
3
@@ -1,41 +1,37 @@
4
 <?php
5
   include('./common.php');
6
 
7
-  print "<HTML>\n<!-- RTG Version $VERSION -->\n<HEAD>\n";
8
+  print "<html>\n<!-- RTG Version $VERSION -->\n<head>\n";
9
 
10
   /* Connect to RTG MySQL Database */
11
-  $dbc=@mysql_connect ($host, $user, $pass) or
12
-  $dbc=@mysql_connect ("$host:/var/lib/mysql/mysql.sock", $user, $pass) or 
13
+  $dbc=@mysqli_connect ($host, $user, $pass, $db) or
14
      die ("MySQL Connection Failed, Check Configuration.");
15
-  mysql_select_db($db,$dbc);
16
 
17
-  if ($PHP_SELF == "") {
18
+  if (!isset($PHP_SELF) || ($PHP_SELF == "")) {
19
     $PHP_SELF = "95.php";
20
-    $customer = $_GET['customer'];
21
-    $syear = $_GET['syear'];
22
-    $eyear = $_GET['eyear'];
23
-    $smonth = $_GET['smonth'];
24
-    $emonth = $_GET['emonth'];
25
-    $sday = $_GET['sday'];
26
-    $eday = $_GET['eday'];
27
-    $shour = $_GET['shour'];
28
-    $ehour = $_GET['ehour'];
29
-    $smin = $_GET['smin'];
30
-    $emin = $_GET['emin'];
31
-    $debug = $_GET['debug'];
32
+    $customer = isset($_GET['customer'])?$_GET['customer']:"";
33
+    $syear = isset($_GET['syear'])?$_GET['syear']:"";
34
+    $eyear = isset($_GET['eyear'])?$_GET['eyear']:"";
35
+    $smonth = isset($_GET['smonth'])?$_GET['smonth']:"";
36
+    $emonth = isset($_GET['emonth'])?$_GET['emonth']:"";
37
+    $sday = isset($_GET['sday'])?$_GET['sday']:"";
38
+    $eday = isset($_GET['eday'])?$_GET['eday']:"";
39
+    $shour = isset($_GET['shour'])?$_GET['shour']:"";
40
+    $ehour = isset($_GET['ehour'])?$_GET['ehour']:"";
41
+    $smin = isset($_GET['smin'])?$_GET['smin']:"";
42
+    $emin = isset($_GET['emin'])?$_GET['emin']:"";
43
+    $debug = isset($_GET['debug'])?$_GET['debug']:"";
44
   }
45
 
46
- print "<TITLE>RTG: ";
47
- if ($customer) print "$customer\n";
48
+ print "<title>RTG: ";
49
+ if ($customer != "") print "$customer\n";
50
 ?>
51
 
52
-</TITLE>
53
-</HEAD>
54
-<BODY BGCOLOR="ffffff">
55
-<A HREF="http://rtg.sourceforge.net" ALT="[RTG Home Page]">
56
-<IMG SRC="rtg.png" BORDER="0">
57
-</A>
58
-<P>
59
+</title>
60
+</head>
61
+<body bgcolor="ffffff">
62
+<a href="http://rtg.sourceforge.net"><img src="rtg.png" border="0" alt="[RTG Home Page]" /></a>
63
+<p>
64
 
65
 <?php
66
 function cmp($c1, $c2) {
67
@@ -50,8 +46,8 @@ function int_stats($statement, $dbc) {
68
   $max = $avg = $nintyfifth = 0;
69
   $rate = array();
70
 
71
-  $selectResult=mysql_query($statement, $dbc);
72
-  while ($selectRow=mysql_fetch_object($selectResult)){
73
+  $selectResult=mysqli_query($dbc, $statement);
74
+  while ($selectRow=mysqli_fetch_object($selectResult)){
75
     $counter = $selectRow->counter;
76
     $sample_secs = $selectRow->unixtime;
77
     $total += $counter;
78
@@ -83,132 +79,136 @@ function int_stats($statement, $dbc) {
79
 }
80
 ?>
81
 
82
-<HR>
83
-Report: 95th percentile<BR>
84
+<hr />
85
+Report: 95th percentile<br />
86
 
87
 <?php
88
-  echo "<FORM ACTION=\"$PHP_SELF\" METHOD=\"GET\">\n";
89
-  if (($bt || $smonth)) { 
90
-    $dbc=@mysql_connect ($host, $user, $pass) or
91
-    $dbc=@mysql_connect ("$host:/var/lib/mysql/mysql.sock", $user, $pass) or die ("MySQL Connection Failed, Check Configuration.");
92
-    mysql_select_db($db,$dbc);
93
+  echo "<form action=\"$PHP_SELF\" method=\"get\">\n";
94
+  if (($bt != "") || ($smonth != "")) {
95
+    $dbc=@mysqli_connect ($host, $user, $pass, $db) or
96
+      die ("MySQL Connection Failed, Check Configuration.");
97
     /* Format into GNU date syntax */
98
     if ($bt == "") {
99
       $bt = strtotime("$syear-$smonth-$sday $shour:$smin:00");
100
       $et = strtotime("$eyear-$emonth-$eday $ehour:$emin:59");
101
     }
102
-    echo "Customer: $customer <BR>\n";
103
+    echo "Customer: $customer <br />\n";
104
     print strftime("Period: %m/%d/%Y %H:%M - ", $bt);
105
     print strftime("%m/%d/%Y %H:%M<P>\n", $et);
106
 
107
-    $range="dtime>FROM_UNIXTIME($bt) AND dtime<=FROM_UNIXTIME($et)";
108
+    $range="`dtime`>FROM_UNIXTIME(" . mysqli_real_escape_string($dbc, $bt) . 
109
+      ") AND `dtime`<=FROM_UNIXTIME(" . mysqli_real_escape_string($dbc, $et) . ")";
110
 
111
-    $selectQuery="SELECT id, name, description, rid FROM interface WHERE description LIKE \"%$customer%\"";
112
-    $selectResult=mysql_query($selectQuery, $dbc);
113
-    if (mysql_num_rows($selectResult) <= 0) 
114
-      print "<BR>No Such Customer Found.<BR>\n";
115
+    $selectQuery="SELECT `id`, `name`, `description`, `rid` FROM `interface` WHERE " .
116
+      "`description` LIKE \"%" . mysqli_real_escape_string($dbc, $customer) . "%\"";
117
+    $selectResult=mysqli_query($dbc, $selectQuery);
118
+    if (mysqli_num_rows($selectResult) <= 0) 
119
+      print "<br />No Such Customer Found.<br />\n";
120
     else {
121
-      while ($selectRow=mysql_fetch_object($selectResult)){
122
+      while ($selectRow=mysqli_fetch_object($selectResult)){
123
         $ids[$selectRow->id] = $selectRow->name; 
124
         $rids[$selectRow->id] = $selectRow->rid; 
125
 	$desc[$selectRow->id] = $selectRow->description;
126
       }
127
-      echo "<TABLE BORDER=\"1\">\n";
128
-      echo "<TR BGCOLOR=\"#E0E0E0\">\n";
129
-      echo "<TH COLSPAN=\"3\">Interface<TH COLSPAN=\"2\">Current Rate<TH COLSPAN=\"2\">Max Rate<TH COLSPAN=\"2\">95th %\n";
130
+      echo "<table border=\"1\">\n";
131
+      echo "<tr bgcolor=\"#E0E0E0\">\n";
132
+      echo "<th colspan=\"3\">Interface</th><th colspan=\"2\">Current Rate</th><th colspan=\"2\">Max Rate</th><th colspan=\"2\">95th %</th>\n";
133
       if ($debug) 
134
-        echo "<TH COLSPAN=\"2\">Samples<TH COLSPAN=\"2\">Ignore Top\n";
135
-      echo "<TR BGCOLOR=\"#E0E0E0\">\n";
136
-      echo "<TH>Name<TH>Description<TH>Router<TH>In (Mbps)<TH>Out (Mbps)<TH>In<TH>Out<TH>In<TH>Out\n";
137
+        echo "<th colspan=\"2\">Samples</th><th colspan=\"2\">Ignore Top</th>\n";
138
+      echo "</tr>\n";
139
+      echo "<tr bgcolor=\"#E0E0E0\">\n";
140
+      echo "<th>Name</th><th>Description</th><th>Router</th><th>In (Mbps)</th><th>Out (Mbps)</th><th>In</th><th>Out</th><th>In</th><th>Out</th>\n";
141
       if ($debug) 
142
-        echo "<TH>In<TH>Out<TH>In<TH>Out\n";
143
-      echo "<TR BGCOLOR=\"#ffffcc\">\n";
144
+        echo "<th>In</th><th>Out</th><th>In</th><th>Out</th>\n";
145
+      echo "</tr>\n";
146
+      echo "<tr bgcolor=\"#ffffcc\">\n";
147
       $yellow = 1;
148
       foreach($ids as $iid=>$name) {
149
 
150
-        $selectQuery="SELECT name FROM router WHERE rid=$rids[$iid]";
151
-        $selectResult=mysql_query($selectQuery, $dbc);
152
-        $selectRow=mysql_fetch_object($selectResult);
153
+        $selectQuery="SELECT `name` FROM `router` WHERE `rid`=$rids[$iid]";
154
+        $selectResult=mysqli_query($dbc, $selectQuery);
155
+        $selectRow=mysqli_fetch_object($selectResult);
156
 	$router = $selectRow->name;
157
 
158
         if ($yellow) $yellow = 0;
159
 	else $yellow = 1;
160
 
161
-        echo "<TD>$name<TD>$desc[$iid]<TD>$router";
162
+        echo "<td>$name</td><td>$desc[$iid]</td><td>$router</td>";
163
 
164
-        $selectQuery="SELECT counter, UNIX_TIMESTAMP(dtime) as unixtime, dtime from ifInOctets_$rids[$iid] WHERE $range AND id=$iid ORDER BY dtime";
165
+        $selectQuery="SELECT `counter`, UNIX_TIMESTAMP(`dtime`) AS `unixtime`, `dtime` FROM `ifInOctets_$rids[$iid]` WHERE $range AND `id`=$iid ORDER BY `dtime`";
166
         list ($intbytes_in, $maxin, $avgin, $nfin,$insamples,$inignore) = int_stats($selectQuery, $dbc);
167
 	$bytesin = round($intbytes_in/1000000);
168
 
169
-        $selectQuery="SELECT counter, UNIX_TIMESTAMP(dtime) as unixtime, dtime from ifOutOctets_$rids[$iid] WHERE $range AND id=$iid ORDER BY dtime";
170
+        $selectQuery="SELECT `counter`, UNIX_TIMESTAMP(`dtime`) AS `unixtime`, `dtime` FROM `ifOutOctets_$rids[$iid]` WHERE $range AND `id`=$iid ORDER BY `dtime`";
171
         list ($intbytes_out, $maxout, $avgout, $nfout,$outsamples,$outignore) = int_stats($selectQuery, $dbc);
172
 	$bytesout = round($intbytes_in/1000000);
173
 
174
-	printf("<TD ALIGN=\"right\">%2.2f", $avgin/1000000);
175
-	printf("<TD ALIGN=\"right\">%2.2f", $avgout/1000000);
176
-	printf("<TD ALIGN=\"right\">%2.2f", $maxin/1000000);
177
-	printf("<TD ALIGN=\"right\">%2.2f", $maxout/1000000);
178
-	printf("<TD ALIGN=\"right\">%2.2f", $nfin/1000000);
179
-	printf("<TD ALIGN=\"right\">%2.2f", $nfout/1000000);
180
+	printf("<td align=\"right\">%2.2f</td>", $avgin/1000000);
181
+	printf("<td align=\"right\">%2.2f</td>", $avgout/1000000);
182
+	printf("<td align=\"right\">%2.2f</td>", $maxin/1000000);
183
+	printf("<td align=\"right\">%2.2f</td>", $maxout/1000000);
184
+	printf("<td align=\"right\">%2.2f</td>", $nfin/1000000);
185
+	printf("<td align=\"right\">%2.2f</td>", $nfout/1000000);
186
 	if ($debug) {
187
-          echo "<TD ALIGN=\"right\">$insamples<TD ALIGN=\"right\">$outsamples<TD ALIGN=\"right\">$inignore<TD ALIGN=\"right\">$outignore";
188
+          echo "<td align=\"right\">$insamples</td><td align=\"right\">$outsamples</td><td align=\"right\">$inignore</td><td align=\"right\">$outignore</td>";
189
 	}
190
-	if ($yellow) echo "<TR BGCOLOR=\"#ffffcc\">\n";
191
-	else echo "<TR BGCOLOR=\"#94D6E7\">\n";
192
+        echo "</tr>\n";
193
+	if ($yellow) echo "<tr bgcolor=\"#ffffcc\">\n";
194
+	else echo "<tr bgcolor=\"#94D6E7\">\n";
195
       }
196
-      echo "</TABLE>\n";
197
+      echo "</table>\n";
198
     }
199
   } else {
200
-    echo "Customer Name: <INPUT TYPE=\"text\" NAME=\"customer\"><BR>\n";
201
-    echo "<P><TABLE>\n";
202
-    echo "<TD>From: \n";
203
-    echo "<TD><INPUT TYPE=TEXT NAME=\"smonth\" SIZE=3 MAXLENGTH=2 VALUE=\"";
204
+    echo "Customer Name: <input type=\"text\" name=\"customer\" /><br />\n";
205
+    echo "<p><table>\n";
206
+    echo "<tr><td>From: </td>\n";
207
+    echo "<td><input type=\"text\" name=\"smonth\" size=\"3\" maxlength=\"2\" value=\"";
208
     print (date("m"));
209
-    echo "\"> / \n";
210
-    echo "<INPUT TYPE=TEXT NAME=\"sday\" SIZE=3 MAXLENGTH=2 VALUE=\"";
211
+    echo "\" /> / \n";
212
+    echo "<input type=\"text\" name=\"sday\" size=\"3\" maxlength=\"2\" value=\"";
213
     printf("%02d", (date("d") - 1));
214
-    echo "\"> / \n";
215
-    echo "<INPUT TYPE=TEXT NAME=\"syear\" SIZE=5 MAXLENGTH=4 VALUE=\"";
216
+    echo "\" /> / \n";
217
+    echo "<input type=\"text\" name=\"syear\" size=\"5\" maxlength=\"4\" value=\"";
218
     print (date("Y"));
219
-    echo "\">\n";
220
-    echo "<TD><INPUT TYPE=TEXT NAME=\"shour\" SIZE=3 MAXLENGTH=2 VALUE=\"";
221
+    echo "\" /></td>\n";
222
+    echo "<td><input type=\"text\" name=\"shour\" size=\"3\" maxlength=\"2\" value=\"";
223
     print (date("H"));
224
-    echo "\">:\n";
225
-    echo "<INPUT TYPE=TEXT NAME=\"smin\" SIZE=3 MAXLENGTH=2 VALUE=\"";
226
+    echo "\" />:\n";
227
+    echo "<input type=\"text\" name=\"smin\" size=\"3\" maxlength=\"2\" value=\"";
228
     print (date("i"));
229
-    echo "\">\n";
230
+    echo "\" /></td></tr>\n";
231
 
232
-    echo "<TR><TD>To: \n";
233
-    echo "<TD><INPUT TYPE=TEXT NAME=\"emonth\" SIZE=3 MAXLENGTH=2 VALUE=\"";
234
+    echo "<tr><td>To: </td>\n";
235
+    echo "<td><input type=\"text\" name=\"emonth\" size=\"3\" maxlength=\"2\" value=\"";
236
     print (date("m"));
237
-    echo "\"> / \n";
238
-    echo "<INPUT TYPE=TEXT NAME=\"eday\" SIZE=3 MAXLENGTH=2 VALUE=\"";
239
+    echo "\" /> / \n";
240
+    echo "<input type=\"text\" name=\"eday\" size=\"3\" maxlength=\"2\" value=\"";
241
     print (date("d"));
242
-    echo "\"> / \n";
243
-    echo "<INPUT TYPE=TEXT NAME=\"eyear\" SIZE=5 MAXLENGTH=4 VALUE=\"";
244
+    echo "\" /> / \n";
245
+    echo "<input type=\"text\" name=\"eyear\" size=\"5\" maxlength=\"4\" value=\"";
246
     print (date("Y"));
247
-    echo "\">\n";
248
-    echo "<TD><INPUT TYPE=TEXT NAME=\"ehour\" SIZE=3 MAXLENGTH=2 VALUE=\"";
249
+    echo "\" /></td>\n";
250
+    echo "<td><input type=\"text\" name=\"ehour\" size=\"3\" maxlength=\"2\" value=\"";
251
     print (date("H"));
252
-    echo "\">:\n";
253
-    echo "<INPUT TYPE=TEXT NAME=\"emin\" SIZE=3 MAXLENGTH=2 VALUE=\"";
254
+    echo "\" />:\n";
255
+    echo "<input type=\"text\" name=\"emin\" size=\"3\" maxlength=\"2\" value=\"";
256
     print (date("i"));
257
-    echo "\">\n";
258
-    echo "<TR><TD>Debug: \n";
259
-    echo "<TD><INPUT TYPE=CHECKBOX NAME=\"debug\">\n";
260
-    echo "</TABLE>\n";
261
+    echo "\" /></td></tr>\n";
262
+    echo "<tr><td>Debug: </td>\n";
263
+    echo "<td><input type=\"checkbox\" name=\"debug\" /></td></tr>\n";
264
+    echo "</table>\n";
265
 
266
-    echo "<P><INPUT TYPE=\"SUBMIT\" VALUE=\"Ok\">";
267
+    echo "<p><input type=\"submit\" VALUE=\"Ok\" />";
268
   }
269
 
270
-  if ($dbc) mysql_close($dbc);
271
-  echo "</FORM>\n";
272
+  if ($dbc) mysqli_close($dbc);
273
+  echo "</form>\n";
274
 ?>
275
-<BR>
276
-<HR>
277
-<FONT FACE="Arial" SIZE="2">
278
+<br />
279
+<hr />
280
+<font face="Arial" size="2">
281
 <?php
282
- print "<A HREF=\"http://rtg.sourceforge.net\">RTG</A> Version $VERSION</FONT>";
283
+ print "<a href=\"http://rtg.sourceforge.net\">RTG</a> Version $VERSION</font>";
284
 ?>
285
-</BODY>
286
-</HTML>
287
+</body>
288
+</html>
(-)net/rtg/files/patch-etc_95.pl (-50 / +1 lines)
Lines 1-4 Link Here
1
--- etc/95.pl.orig	2018-04-02 20:14:41 UTC
1
--- etc/95.pl.orig	2020-09-23 14:55:01 UTC
2
+++ etc/95.pl
2
+++ etc/95.pl
3
@@ -31,7 +31,7 @@ $pass="rtgdefault";
3
@@ -31,7 +31,7 @@ $pass="rtgdefault";
4
 $onedaysec=60*60*24;
4
 $onedaysec=60*60*24;
Lines 9-60 Link Here
9
 foreach $conf (@configs) {
9
 foreach $conf (@configs) {
10
   if (open CONF, "<$conf") {
10
   if (open CONF, "<$conf") {
11
     print "Reading [$conf].\n" if $DEBUG;
11
     print "Reading [$conf].\n" if $DEBUG;
12
@@ -207,13 +207,13 @@ print "Period: [", format_dt($startdate)
13
 write;
14
 ($name,$router, $ratein, $rateout, $maxratein, $maxrateout, $nfratein, $nfrateout) = ("Connection", "", "Mbps", "Mbps", "Mbps", "Mbps", "Mbps", "Mbps");
15
 write;
16
-print "--------------------------------------------------------------------------------\n";
17
+print "----------------------------------------------------------------------------------------------------\n";
18
 
19
 $dbh= DBI->connect("DBI:mysql:$db:host=$host", $user, $pass);
20
 $dbh2= DBI->connect("DBI:mysql:$db:host=$host", $user, $pass);
21
-$range="dtime>$startdate and dtime<=$enddate";
22
+$range="`dtime`>$startdate AND `dtime`<=$enddate";
23
 
24
-$statement="SELECT id FROM interface WHERE description LIKE \"%$cust%\"";
25
+$statement="SELECT `id` FROM `interface` WHERE `description` LIKE \"%$cust%\"";
26
 $sth = $dbh->prepare($statement)
27
   or die "Can't prepare $statement: $dbh->errstr\n";
28
 $rv = $sth->execute
29
@@ -223,19 +223,19 @@ while (@row = $sth->fetchrow_array ()) {
30
 }
31
 
32
 foreach $interface (@interfaces) {
33
-  $statement="SELECT rid, name, speed FROM interface WHERE id=$interface";
34
+  $statement="SELECT `rid`, `name`, `speed` FROM `interface` WHERE `id`=$interface";
35
   &run_query($statement);
36
   ($rid, $name, $speed) = @row;
37
 
38
-  $statement="SELECT rid, name FROM router WHERE rid=$rid";
39
+  $statement="SELECT `rid`, `name` FROM `router` WHERE `rid`=$rid";
40
   &run_query($statement);
41
   ($rid, $router) = @row;
42
 
43
-  $statement="SELECT counter, UNIX_TIMESTAMP(dtime), dtime FROM ifInOctets_".$rid." WHERE $range AND id=$interface ORDER BY dtime"; 
44
+  $statement="SELECT `counter`, UNIX_TIMESTAMP(`dtime`), `dtime` FROM `ifInOctets_".$rid."` WHERE $range AND `id`=$interface ORDER BY `dtime`"; 
45
   ($intbytes_in, $maxin, $avgin, $nfin) = &interface_stats($statement);
46
   $bytesin = int($intbytes_in/1000000 + .5);
47
 
48
-  $statement="SELECT counter, UNIX_TIMESTAMP(dtime), dtime FROM ifOutOctets_".$rid." WHERE $range AND id=$interface ORDER BY dtime"; 
49
+  $statement="SELECT `counter`, UNIX_TIMESTAMP(`dtime`), `dtime` FROM `ifOutOctets_".$rid."` WHERE $range AND `id`=$interface ORDER BY `dtime`"; 
50
   ($intbytes_out, $maxout, $avgout, $nfout) = &interface_stats($statement);
51
   $bytesout = int($intbytes_out/1000000 + .5);
52
 
53
@@ -279,6 +279,6 @@ $rc = $dbh->disconnect;
54
 exit;
55
 
56
 format STDOUT = 
57
-@<<<<<<<<<<< @<<<<<<<<<<< @>>>>>>>  @>>>>>>>  @>>>>>>  @>>>>>>  @>>>>>>  @>>>>>>
58
+@<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<< @>>>>>>>  @>>>>>>>  @>>>>>>  @>>>>>>  @>>>>>>  @>>>>>>
59
 $name,$router, $ratein, $rateout, $maxratein, $maxrateout, $nfratein, $nfrateout  
60
 .
(-)net/rtg/files/patch-etc_Makefile.in (-49 lines)
Lines 1-49 Link Here
1
--- etc/Makefile.in.orig	2003-10-02 15:59:32 UTC
2
+++ etc/Makefile.in
3
@@ -84,19 +84,19 @@ am__quote = @am__quote@
4
 install_sh = @install_sh@
5
 
6
 top_builddir = ..
7
-etcdir = /etc
8
-webdir = /web
9
-reportsdir = /bin
10
+etcdir = @etcdir@
11
+webdir = @webdir@
12
+reportsdir = @bindir@
13
 
14
-ETC = rtg.conf rtgtargmkr.pl routers createdb BER.pm \
15
+ETC = rtg.conf.sample rtgtargmkr.pl routers.sample createdb BER.pm \
16
                SNMP_Session.pm SNMP_util.pm
17
 
18
 WEB = rtg.php 95.php view.php common.php rtg.png rtgback.png
19
 REPORTS = report.pl 95.pl
20
 
21
 EXTRA_DIST = rtgtargmkr.pl.in report.pl 95.pl createdb.in \
22
-               BER.pm SNMP_Session.pm SNMP_util.pm rtg.conf \
23
-	       routers rtg.php 95.php view.php common.php.in rtg.png rtgback.png
24
+               BER.pm SNMP_Session.pm SNMP_util.pm rtg.conf.sample \
25
+	       routers.sample rtg.php 95.php view.php common.php.in rtg.png rtgback.png
26
 
27
 subdir = etc
28
 mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
29
@@ -220,14 +220,14 @@ uninstall-am: uninstall-info-am
30
 all:
31
 
32
 install: installdirs
33
-	@for i in $(ETC) ; do $(INSTALL) $(srcdir)/$$i $(prefix)$(etcdir) ; echo "install: installed $$i in $(prefix)$(etcdir)" ; done
34
-	@for i in $(WEB) ; do $(INSTALL) $(srcdir)/$$i $(prefix)$(webdir) ; echo "install: installed $$i in $(prefix)$(webdir)" ; done
35
-	@for i in $(REPORTS) ; do $(INSTALL) $(srcdir)/$$i $(prefix)$(reportsdir) ; echo "install: installed $$i in $(prefix)$(reportsdir)" ; done
36
+	@for i in $(ETC) ; do $(INSTALL) $(srcdir)/$$i $(DESTDIR)$(etcdir) ; echo "install: installed $$i in $(DESTDIR)$(etcdir)" ; done
37
+	@for i in $(WEB) ; do $(INSTALL) $(srcdir)/$$i $(DESTDIR)$(webdir) ; echo "install: installed $$i in $(DESTDIR)$(webdir)" ; done
38
+	@for i in $(REPORTS) ; do $(INSTALL) $(srcdir)/$$i $(DESTDIR)$(reportsdir) ; echo "install: installed $$i in $(DESTDIR)$(reportsdir)" ; done
39
 
40
 installdirs:
41
-	$(mkinstalldirs) $(prefix)$(etcdir)
42
-	$(mkinstalldirs) $(prefix)$(webdir)
43
-	$(mkinstalldirs) $(prefix)$(reportsdir)
44
+	$(mkinstalldirs) $(DESTDIR)$(etcdir)
45
+	$(mkinstalldirs) $(DESTDIR)$(webdir)
46
+	$(mkinstalldirs) $(DESTDIR)$(reportsdir)
47
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
48
 # Otherwise a system limit (for SysV at least) may be exceeded.
49
 .NOEXPORT:
(-)net/rtg/files/patch-etc_SNMP__util.pm (-22 lines)
Lines 1-22 Link Here
1
--- etc/SNMP_util.pm.orig	2018-04-02 22:51:02 UTC
2
+++ etc/SNMP_util.pm
3
@@ -1129,16 +1129,16 @@ sub snmpMIB_to_OID ($) {
4
       $buf =~ s/OBJECT-GROUP/OBJECT IDENTIFIER/;
5
       $buf =~ s/MODULE-IDENTITY/OBJECT IDENTIFIER/;
6
       $buf =~ s/ IMPORTS .*\;//;
7
-      $buf =~ s/ SEQUENCE {.*}//;
8
+      $buf =~ s/ SEQUENCE \{.*}//;
9
       $buf =~ s/ SYNTAX .*//;
10
       $buf =~ s/ [\w-]+ ::= OBJECT IDENTIFIER//;
11
-      $buf =~ s/ OBJECT IDENTIFIER .* ::= {/ OBJECT IDENTIFIER ::= {/;
12
+      $buf =~ s/ OBJECT IDENTIFIER .* ::= \{/ OBJECT IDENTIFIER ::= {/;
13
       $buf =~ s/".*"//;
14
       if ($buf =~ /"/) {
15
 	$quote = 1;
16
       }
17
 
18
-      if ($buf =~ / ([\w\-]+) OBJECT IDENTIFIER ::= {([^}]+)}/) {
19
+      if ($buf =~ / ([\w\-]+) OBJECT IDENTIFIER ::= \{([^}]+)}/) {
20
 	$var = $1;
21
 	$buf = $2;
22
 	undef $val;
(-)net/rtg/files/patch-etc_common.php.in (-20 / +8 lines)
Lines 1-22 Link Here
1
--- etc/common.php.in.orig	2003-09-26 15:52:29 UTC
1
--- etc/common.php.in.orig	2020-09-22 19:52:22 UTC
2
+++ etc/common.php.in
2
+++ etc/common.php.in
3
@@ -1,4 +1,4 @@
3
@@ -12,6 +12,7 @@ date_default_timezone_set('UTC');
4
-<?
4
 /* Default locations to find RTG configuration file */
5
+<?php
5
 $configs[] = 'rtg.conf';
6
  /* Begin with reasonable defaults */
6
 $configs[] = '@RTG_HOME@/etc/rtg.conf';
7
  $VERSION = "@VERSION@";
7
+$configs[] = '%%PREFIX%%/etc/rtg/rtg.conf';
8
  $host="localhost";
8
 $configs[] = '/usr/local/rtg/etc/rtg.conf';
9
@@ -6,10 +6,13 @@
9
 $configs[] = '/etc/rtg.conf';
10
  $pass="rtgdefault";
11
  $db="rtg";
12
  $refresh=300;
13
+
14
+ date_default_timezone_set ( 'UTC' );
15
  
16
  /* Default locations to find RTG configuration file */
17
  $configs[] = 'rtg.conf';
18
  $configs[] = '@RTG_HOME@/etc/rtg.conf';
19
+ $configs[] = '%%PREFIX%%/etc/rtg/rtg.conf';
20
  $configs[] = '/usr/local/rtg/etc/rtg.conf';
21
  $configs[] = '/etc/rtg.conf';
22
 
10
 
(-)net/rtg/files/patch-etc_createdb.in (-160 lines)
Lines 1-160 Link Here
1
--- etc/createdb.in.orig	2003-01-22 19:07:02 UTC
2
+++ etc/createdb.in
3
@@ -15,6 +15,8 @@
4
 RTGPASS="rtgdefault"
5
 DATABASE="rtg"
6
 USER="snmp"
7
+MYSQL_FILE=`mktemp -q /tmp/mysql.XXXXXX`
8
+RTG_FILE=`mktemp -q /tmp/rtg.XXXXXX`
9
 
10
 echo ""
11
 echo "$0 setting up MySQL database for RTG."
12
@@ -22,103 +24,98 @@
13
 echo ""
14
 
15
 # Create the necessary SQL in two /tmp files
16
-cat <<EOT >/tmp/mysql.sql
17
-INSERT INTO user (Host, User, Password) VALUES ('$HOST','$USER',PASSWORD("$RTGPASS"));
18
-INSERT INTO db (Host, Db, User, Select_priv, Insert_priv, Update_priv, Delete_priv, 
19
-Create_priv, Drop_priv, Grant_priv, References_priv, Index_priv, Alter_priv) 
20
-VALUES ('$HOST','$DATABASE','$USER','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y');
21
-FLUSH PRIVILEGES;
22
+cat <<EOT >$MYSQL_FILE
23
+CREATE USER '$USER'@'$HOST' IDENTIFIED BY '$RTG_PASS';
24
+GRANT ALL ON '$DATABASE'.* TO '$USER'@'$HOST';
25
 EOT
26
 
27
-cat <<EOT >/tmp/rtg.sql
28
+cat <<EOT >$RTG_FILE
29
 #
30
 # Table structure for table 'router'
31
 #
32
 
33
-CREATE TABLE router (
34
-  rid int(11) unsigned NOT NULL auto_increment,
35
-  name char(120) NOT NULL default '',
36
-  pop char(10) NOT NULL default '',
37
-  popid tinyint(3) unsigned NOT NULL default '0',
38
-  PRIMARY KEY  (rid)
39
+CREATE TABLE `router` (
40
+  `rid` int(11) unsigned NOT NULL auto_increment,
41
+  `name` char(120) NOT NULL default '',
42
+  `pop` char(10) NOT NULL default '',
43
+  `popid` tinyint(3) unsigned NOT NULL default '0',
44
+  PRIMARY KEY (`rid`)
45
 );
46
 
47
 #
48
 # Table structure for table 'interface'
49
 #
50
 
51
-CREATE TABLE interface (
52
-  id int(11) unsigned NOT NULL auto_increment,
53
-  name char(255) NOT NULL default '',
54
-  rid int(11) NOT NULL default '0',
55
-  speed bigint(11) default NULL,
56
-  description char(255) default NULL,
57
-  status enum('active','inactive') default 'active',
58
-  PRIMARY KEY  (id)
59
+CREATE TABLE `interface` (
60
+  `id` int(11) unsigned NOT NULL auto_increment,
61
+  `name` char(255) NOT NULL default '',
62
+  `rid` int(11) NOT NULL default '0',
63
+  `speed` bigint(11) default NULL,
64
+  `description` char(255) default NULL,
65
+  `status` enum('active','inactive') default 'active',
66
+  PRIMARY KEY (`id`)
67
 );
68
 
69
 #
70
 # Table structure for table 'ifInOctets'
71
 #
72
 
73
-CREATE TABLE ifInOctets (
74
-  id int(11) NOT NULL default '0',
75
-  dtime datetime NOT NULL default '0000-00-00 00:00:00',
76
-  counter bigint(20) NOT NULL default '0',
77
-  KEY ifInOctets_idx (dtime)
78
+CREATE TABLE `ifInOctets` (
79
+  `id` int(11) NOT NULL default '0',
80
+  `dtime` datetime NOT NULL default '0000-00-00 00:00:00',
81
+  `counter` bigint(20) NOT NULL default '0',
82
+  KEY `ifInOctets_idx` (`dtime`)
83
 );
84
 
85
 #
86
 # Table structure for table 'ifOutOctets'
87
 #
88
 
89
-CREATE TABLE ifOutOctets (
90
-  id int(11) NOT NULL default '0',
91
-  dtime datetime NOT NULL default '0000-00-00 00:00:00',
92
-  counter bigint(20) NOT NULL default '0',
93
-  KEY ifOutOctets_idx (dtime)
94
+CREATE TABLE `ifOutOctets` (
95
+  `id` int(11) NOT NULL default '0',
96
+  `dtime` datetime NOT NULL default '0000-00-00 00:00:00',
97
+  `counter` bigint(20) NOT NULL default '0',
98
+  KEY `ifOutOctets_idx` (`dtime`)
99
 );
100
 
101
 #
102
 # Table structure for table 'ifInUcastPkts'
103
 #
104
 
105
-CREATE TABLE ifInUcastPkts (
106
-  id int(11) NOT NULL default '0',
107
-  dtime datetime NOT NULL default '0000-00-00 00:00:00',
108
-  counter bigint(20) NOT NULL default '0',
109
-  KEY ifInUcastPkts_idx (dtime)
110
+CREATE TABLE `ifInUcastPkts` (
111
+  `id` int(11) NOT NULL default '0',
112
+  `dtime` datetime NOT NULL default '0000-00-00 00:00:00',
113
+  `counter` bigint(20) NOT NULL default '0',
114
+  KEY `ifInUcastPkts_idx` (`dtime`)
115
 );
116
 
117
 #
118
 # Table structure for table 'ifOutUcastPkts'
119
 #
120
 
121
-CREATE TABLE ifOutUcastPkts (
122
-  id int(11) NOT NULL default '0',
123
-  dtime datetime NOT NULL default '0000-00-00 00:00:00',
124
-  counter bigint(20) NOT NULL default '0',
125
-  KEY ifOutUcastPkts_idx (dtime)
126
+CREATE TABLE `ifOutUcastPkts` (
127
+  `id` int(11) NOT NULL default '0',
128
+  `dtime` datetime NOT NULL default '0000-00-00 00:00:00',
129
+  `counter` bigint(20) NOT NULL default '0',
130
+  KEY `ifOutUcastPkts_idx` (`dtime`)
131
 );
132
 
133
 #
134
 # Table structure for table 'ifInErrors'
135
 #
136
 
137
-CREATE TABLE ifInErrors (
138
-  id int(11) NOT NULL default '0',
139
-  dtime datetime NOT NULL default '0000-00-00 00:00:00',
140
-  counter bigint(20) NOT NULL default '0',
141
-  KEY ifInErrors_idx (dtime)
142
+CREATE TABLE `ifInErrors` (
143
+  `id` int(11) NOT NULL default '0',
144
+  `dtime` datetime NOT NULL default '0000-00-00 00:00:00',
145
+  `counter` bigint(20) NOT NULL default '0',
146
+  KEY `ifInErrors_idx` (`dtime`)
147
 );
148
 EOT
149
 
150
 echo "Adding user \"$USER\" to MySQL database..."
151
-cat /tmp/mysql.sql | $MYSQLBIN/mysql -u root -p$ROOTPASS mysql
152
+cat $MYSQL_FILE | $MYSQLBIN/mysql -u root -p$ROOTPASS mysql
153
 echo "Creating RTG database \"$DATABASE\"..."
154
 $MYSQLBIN/mysqladmin -u root -p$ROOTPASS create $DATABASE
155
-echo "Reloading MySQL privileges..."
156
-$MYSQLBIN/mysqladmin -u root -p$ROOTPASS flush-privileges
157
 echo "Creating RTG tables..."
158
-cat /tmp/rtg.sql | $MYSQLBIN/mysql -u $USER -p$RTGPASS $DATABASE
159
+cat $RTG_FILE | $MYSQLBIN/mysql -u $USER -p$RTGPASS $DATABASE
160
 echo "Done."
(-)net/rtg/files/patch-etc_report.pl (-50 / +1 lines)
Lines 1-4 Link Here
1
--- etc/report.pl.orig	2018-04-02 20:14:41 UTC
1
--- etc/report.pl.orig	2020-09-23 14:55:01 UTC
2
+++ etc/report.pl
2
+++ etc/report.pl
3
@@ -30,7 +30,7 @@ $pass="rtgdefault";
3
@@ -30,7 +30,7 @@ $pass="rtgdefault";
4
 $onedaysec=60*60*24;
4
 $onedaysec=60*60*24;
Lines 9-60 Link Here
9
 foreach $conf (@configs) {
9
 foreach $conf (@configs) {
10
   if (open CONF, "<$conf") {
10
   if (open CONF, "<$conf") {
11
     print "Reading [$conf].\n" if $DEBUG;
11
     print "Reading [$conf].\n" if $DEBUG;
12
@@ -192,13 +192,13 @@ print "Period: [", format_dt($startdate)
13
 write;
14
 ($router,$name,$bytesin, $bytesout, $ratein, $rateout, $utilin, $utilout, $maxratein, $maxrateout, $maxutilin, $maxutilout) = ("","Connection", "MBytes", "MBytes", "Mbps", "Mbps", "In %", "Out%",  "Mbps", "Mbps", "In%", "Out%");
15
 write;
16
-print "----------------------------------------------------------------------------------------------------------\n";
17
+print "------------------------------------------------------------------------------------------------------------------------------\n";
18
 
19
 $dbh= DBI->connect("DBI:mysql:$db:host=$host", $user, $pass);
20
 $dbh2= DBI->connect("DBI:mysql:$db:host=$host", $user, $pass);
21
-$range="dtime>$startdate and dtime<=$enddate";
22
+$range="`dtime`>$startdate and `dtime`<=$enddate";
23
 
24
-$statement="SELECT id FROM interface WHERE description LIKE \"%$cust%\"";
25
+$statement="SELECT `id` FROM `interface` WHERE `description` LIKE \"%$cust%\"";
26
 $sth = $dbh->prepare($statement)
27
         or die "Can't prepare $statement: $dbh->errstr\n";
28
 $rv = $sth->execute
29
@@ -209,19 +209,19 @@ while (@row = $sth->fetchrow_array ())
30
 }
31
 
32
 foreach $interface (@interfaces) {
33
-  $statement="SELECT rid, name, speed FROM interface WHERE id=$interface";
34
+  $statement="SELECT `rid`, `name`, `speed` FROM `interface` WHERE `id`=$interface";
35
   &run_query($statement);
36
   ($rid, $name, $speed) = @row;
37
 
38
-  $statement="SELECT rid, name FROM router WHERE rid=$rid";
39
+  $statement="SELECT `rid`, `name` FROM `router` WHERE `rid`=$rid";
40
   &run_query($statement);
41
   ($rid, $router) = @row;
42
 
43
-  $statement="SELECT counter, UNIX_TIMESTAMP(dtime), dtime FROM ifInOctets_".$rid." WHERE $range AND id=$interface ORDER BY dtime"; 
44
+  $statement="SELECT `counter`, UNIX_TIMESTAMP(`dtime`), `dtime` FROM `ifInOctets_".$rid."` WHERE $range AND `id`=$interface ORDER BY `dtime`"; 
45
   ($intbytes_in, $maxin, $avgin) = &interface_stats($statement);
46
   $bytesin = int($intbytes_in/1000000 + .5);
47
 
48
-  $statement="SELECT counter, UNIX_TIMESTAMP(dtime), dtime FROM ifOutOctets_".$rid." WHERE $range AND id=$interface ORDER BY dtime"; 
49
+  $statement="SELECT `counter`, UNIX_TIMESTAMP(`dtime`), `dtime` FROM `ifOutOctets_".$rid."` WHERE $range AND `id`=$interface ORDER BY `dtime`"; 
50
   ($intbytes_out, $maxout, $avgout) = &interface_stats($statement);
51
   $bytesout = int($intbytes_out/1000000 + .5);
52
 
53
@@ -267,6 +267,6 @@ $rc = $dbh->disconnect;
54
 exit;
55
 
56
 format STDOUT = 
57
-@<<<<<<<<<<< @<<<<<<<<<<< @>>>>>>> @>>>>>>> @>>>>>> @>>>>>> @>>>>> @>>>>> @>>>>>> @>>>>>> @>>>>> @>>>>>
58
+@<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<< @>>>>>>> @>>>>>>> @>>>>>> @>>>>>> @>>>>> @>>>>> @>>>>>> @>>>>>> @>>>>> @>>>>>
59
 $name,$router,&commify($bytesin), &commify($bytesout), $ratein, $rateout, $utilin, $utilout, $maxratein, $maxrateout, $maxutilin, $maxutilout  
60
 .
(-)net/rtg/files/patch-etc_rtg.conf (-10 lines)
Lines 1-10 Link Here
1
--- etc/rtg.conf.orig	2018-04-02 23:07:32 UTC
2
+++ etc/rtg.conf
3
@@ -12,3 +12,7 @@ DB_Database	rtg
4
 DB_User	snmp
5
 DB_Pass	rtgdefault
6
 Threads 5
7
+# Set Update_desc to 1 to cause rtgtargmkr.pl to auto-update descriptions from
8
+# SNMP port data
9
+Update_desc	0
10
+
(-)net/rtg/files/patch-etc_rtg.php (-389 lines)
Lines 1-389 Link Here
1
--- etc/rtg.php.orig	2003-09-24 20:42:03 UTC
2
+++ etc/rtg.php
3
@@ -1,146 +1,152 @@
4
 <?php
5
   include('./common.php');
6
 
7
-  print "<HTML>\n<!-- RTG Version $VERSION -->\n<HEAD>\n";
8
+  print "<html>\n<!-- RTG Version $VERSION -->\n<head>\n";
9
 
10
   /* Connect to RTG MySQL Database */
11
-  $dbc=@mysql_connect ($host, $user, $pass) or
12
-  $dbc=@mysql_connect ("$host:/var/lib/mysql/mysql.sock", $user, $pass) or 
13
+  $dbc=@mysqli_connect ($host, $user, $pass, $db) or
14
      die ("MySQL Connection Failed, Check Configuration.");
15
-  mysql_select_db($db,$dbc);
16
 
17
- if ($PHP_SELF == "") {
18
+ if (!isset($PHP_SELF) || $PHP_SELF == "") {
19
    $PHP_SELF = "rtg.php";
20
-   $errors = $_GET['errors'];
21
-   $scalex = $_GET['scalex'];
22
-   $scaley = $_GET['scaley'];
23
-   $aggr = $_GET['aggr'];
24
-   $percentile = $_GET['percentile'];
25
-   $nth = $_GET['nth'];
26
-   $xplot = $_GET['xplot'];
27
-   $yplot = $_GET['yplot'];
28
-   $borderb = $_GET['borderb'];
29
-   $iid = $_GET['iid'];
30
-   $rid = $_GET['rid'];
31
-   $syear = $_GET['syear'];
32
-   $eyear = $_GET['eyear'];
33
-   $smonth = $_GET['smonth'];
34
-   $emonth = $_GET['emonth'];
35
-   $sday = $_GET['sday'];
36
-   $eday = $_GET['eday'];
37
-   $shour = $_GET['shour'];
38
-   $ehour = $_GET['ehour'];
39
-   $smin = $_GET['smin'];
40
-   $emin = $_GET['emin'];
41
+   $errors = isset($_GET['errors'])?$_GET['errors']:"";
42
+   $scalex = isset($_GET['scalex'])?$_GET['scalex']:"";
43
+   $scaley = isset($_GET['scaley'])?$_GET['scaley']:"";
44
+   $aggr = isset($_GET['aggr'])?$_GET['aggr']:"";
45
+   $percentile = isset($_GET['percentile'])?$_GET['percentile']:"";
46
+   $nth = isset($_GET['nth'])?$_GET['nth']:"";
47
+   $xplot = isset($_GET['xplot'])?$_GET['xplot']:"";
48
+   $yplot = isset($_GET['yplot'])?$_GET['yplot']:"";
49
+   $borderb = isset($_GET['borderb'])?$_GET['borderb']:"";
50
+   $iid = isset($_GET['iid'])?$_GET['iid']:"";
51
+   $rid = isset($_GET['rid'])?$_GET['rid']:"";
52
+   $syear = isset($_GET['syear'])?$_GET['syear']:"";
53
+   $eyear = isset($_GET['eyear'])?$_GET['eyear']:"";
54
+   $smonth = isset($_GET['smonth'])?$_GET['smonth']:"";
55
+   $emonth = isset($_GET['emonth'])?$_GET['emonth']:"";
56
+   $sday = isset($_GET['sday'])?$_GET['sday']:"";
57
+   $eday = isset($_GET['eday'])?$_GET['eday']:"";
58
+   $shour = isset($_GET['shour'])?$_GET['shour']:"";
59
+   $ehour = isset($_GET['ehour'])?$_GET['ehour']:"";
60
+   $smin = isset($_GET['smin'])?$_GET['smin']:"";
61
+   $emin = isset($_GET['emin'])?$_GET['emin']:"";
62
  }
63
 
64
   # Determine router, interface names as necessary
65
-  if ($rid && $iid) {
66
-    $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]";
67
-    $selectResult=mysql_query($selectQuery, $dbc);
68
-    $selectRow=mysql_fetch_object($selectResult);
69
-    $interfaces = mysql_num_rows($selectResult);
70
+  if (($rid != "") && ($iid != "")) {
71
+    $selectQuery="SELECT `a`.`name`, `a`.`description`, `a`.`speed`, `b`.`name` " .
72
+      "AS `router` FROM `interface` `a`, `router` `b` WHERE `a`.`rid`=`b`.`rid` " .
73
+      "AND `a`.`rid`=" . mysqli_real_escape_string($dbc, $rid) . " AND `a`.`id`=" .
74
+      mysqli_real_escape_string($dbc, $iid[0]);
75
+    $selectResult=mysqli_query($dbc, $selectQuery);
76
+    $selectRow=mysqli_fetch_object($selectResult);
77
+    $interfaces = mysqli_num_rows($selectResult);
78
     $name = $selectRow->name;
79
     $description = $selectRow->description;
80
     $speed = ($selectRow->speed)/1000000;
81
     $router = $selectRow->router;
82
-  } else if ($rid && !$iid) {
83
-    $selectQuery="SELECT name AS router from router where rid=$rid";
84
-    $selectResult=mysql_query($selectQuery, $dbc);
85
-    $selectRow=mysql_fetch_object($selectResult);
86
+  } else if (($rid != "") && ($iid == "")) {
87
+    $selectQuery="SELECT `name` AS `router` FROM `router` WHERE `rid`=" .
88
+      mysqli_real_escape_string($dbc, $rid);
89
+    $selectResult=mysqli_query($dbc, $selectQuery);
90
+    $selectRow=mysqli_fetch_object($selectResult);
91
     $router = $selectRow->router;
92
   }
93
 
94
   # Generate Title 
95
-  echo "<TITLE>RTG: ";
96
-  if ($rid && $iid) echo "$router: $name";
97
-  else if ($rid && !$iid) echo "$router";
98
-  echo "</TITLE>\n";
99
+  echo "<title>RTG: ";
100
+  if (($rid != "") && ($iid != "")) echo "$router: $name";
101
+  else if (($rid != "") && ($iid == "")) echo "$router";
102
+  echo "</title>\n";
103
 ?>
104
 
105
-</HEAD>
106
-<BODY BACKGROUND="rtgback.png" BGCOLOR="ffffff">
107
-<A HREF="http://rtg.sourceforge.net" ALT="[RTG Home Page]">
108
-<IMG SRC="rtg.png" BORDER="0">
109
-</A>
110
-<P>
111
+</head>
112
+<body background="rtgback.png" bgcolor="ffffff">
113
+<a href="http://rtg.sourceforge.net" alt="[RTG Home Page]"><img src="rtg.png" border="0" /></a>
114
+<p>
115
 
116
 <?php
117
-echo "<FORM ACTION=\"$PHP_SELF\" METHOD=\"get\">\n";
118
+echo "<form action=\"$PHP_SELF\" method=\"get\">\n";
119
 
120
-if (!$rid && !$iid) {
121
- echo "<SELECT NAME=\"rid\" SIZE=10>\n";
122
- $selectQuery="SELECT DISTINCT name, rid FROM router ORDER BY name";
123
- $selectResult=mysql_query($selectQuery, $dbc);
124
- while ($selectRow=mysql_fetch_object($selectResult)){
125
-    echo "<OPTION VALUE=\"$selectRow->rid\">$selectRow->name\n";
126
+if (($rid == "") && ($iid == "")) {
127
+ echo "<select name=\"rid\" size=\"10\">\n";
128
+ $selectQuery="SELECT DISTINCT `name`, `rid` FROM `router` ORDER BY `name`";
129
+ $selectResult=mysqli_query($dbc, $selectQuery);
130
+ while ($selectRow=mysqli_fetch_object($selectResult)){
131
+    echo "<option value=\"$selectRow->rid\">$selectRow->name</option>\n";
132
  }
133
- echo "</SELECT>\n";
134
+ echo "</select>\n";
135
 }
136
 
137
-if ($smonth != "" && $iid == "") {
138
- echo "<BLOCKQUOTE><FONT SIZE=+1><STRONG>\n";
139
+if (($smonth != "") && ($iid == "")) {
140
+ echo "<blockquote><font size=\"+1\"><b>\n";
141
  echo "Please select an interface!\n";
142
- echo "</FONT></STRONG></BLOCKQUOTE>\n";
143
+ echo "</b></font></blockquote>\n";
144
 }
145
 
146
-if ($rid && !$iid) {
147
-  echo "<SELECT NAME=\"rid\" SIZE=10>\n"; 
148
-  echo "<OPTION SELECTED VALUE=\"$rid\">$router\n";
149
-  echo "</SELECT>\n";
150
+if (($rid != "") && ($iid == "")) {
151
+  echo "<select name=\"rid\" size=\"10\">\n"; 
152
+  echo "<option selected value=\"$rid\">$router</option>\n";
153
+  echo "</select>\n";
154
 
155
-  echo "<SELECT MULTIPLE NAME=\"iid[]\" SIZE=10>\n"; 
156
-  $selectQuery="SELECT id, name, description FROM interface WHERE rid=$rid ORDER BY name";
157
-  $selectResult=mysql_query($selectQuery, $dbc);
158
-  while ($selectRow=mysql_fetch_object($selectResult)){
159
-     echo "<OPTION VALUE=\"$selectRow->id\">$selectRow->name ($selectRow->description)\n";
160
+  echo "<select multiple name=\"iid[]\" size=\"10\">\n";
161
+  $selectQuery="SELECT `id`, `name`, `description` FROM `interface` WHERE " .
162
+    "`rid`=" . mysqli_real_escape_string($dbc, $rid) . " ORDER BY `name`";
163
+  $selectResult=mysqli_query($dbc, $selectQuery);
164
+  while ($selectRow=mysqli_fetch_object($selectResult)){
165
+     echo "<option value=\"$selectRow->id\">$selectRow->name ($selectRow->description)</option>\n";
166
   }
167
-  echo "</SELECT>\n";
168
+  echo "</select>\n";
169
 
170
-  echo "<P><TABLE>\n";
171
-  echo "<TD>From: \n";
172
-  echo "<TD><INPUT TYPE=TEXT NAME=\"smonth\" SIZE=3 MAXLENGTH=2 VALUE=\"";
173
+  echo "<p><table>\n";
174
+  echo "<tr><td>From: </td>\n";
175
+  echo "<td><input type=\"text\" name=\"smonth\" size=\"3\" maxlength=\"2\" value=\"";
176
   print (date("m"));
177
-  echo "\"> / \n";
178
-  echo "<INPUT TYPE=TEXT NAME=\"sday\" SIZE=3 MAXLENGTH=2 VALUE=\"";
179
+  echo "\" /> / \n";
180
+  echo "<input type=\"text\" name=\"sday\" size=\"3\" maxlength=\"2\" value=\"";
181
   print (date("d"));
182
-  echo "\"> / \n";
183
-  echo "<INPUT TYPE=TEXT NAME=\"syear\" SIZE=5 MAXLENGTH=4 VALUE=\"";
184
+  echo "\" /> / \n";
185
+  echo "<input type=\"text\" name=\"syear\" size=\"5\" maxlength=\"4\" value=\"";
186
   print (date("Y"));
187
-  echo "\">\n";
188
-  echo "<TD><INPUT TYPE=TEXT NAME=\"shour\" SIZE=3 MAXLENGTH=2 VALUE=\"00\">:\n";
189
-  echo "<INPUT TYPE=TEXT NAME=\"smin\" SIZE=3 MAXLENGTH=2 VALUE=\"00\">\n";
190
+  echo "\" />\n";
191
+  echo "</td>";
192
+  echo "<td><input type=\"text\" name=\"shour\" size=\"3\" maxlength=\"2\" value=\"00\" />:\n";
193
+  echo "<input type=\"text\" name=\"smin\" size=\"3\" maxlength=\"2\" value=\"00\" />\n";
194
+  echo "</td></tr>\n";
195
 
196
-  echo "<TR><TD>To: \n";
197
-  echo "<TD><INPUT TYPE=TEXT NAME=\"emonth\" SIZE=3 MAXLENGTH=2 VALUE=\"";
198
+  echo "<tr><td>To: </td>\n";
199
+  echo "<td><input type=\"text\" name=\"emonth\" size=\"3\" maxlength=\"2\" value=\"";
200
   print (date("m"));
201
-  echo "\"> / \n";
202
-  echo "<INPUT TYPE=TEXT NAME=\"eday\" SIZE=3 MAXLENGTH=2 VALUE=\"";
203
+  echo "\" /> / \n";
204
+  echo "<input type=\"text\" name=\"eday\" size=\"3\" maxlength=\"2\" value=\"";
205
   print (date("d"));
206
-  echo "\"> / \n";
207
-  echo "<INPUT TYPE=TEXT NAME=\"eyear\" SIZE=5 MAXLENGTH=4 VALUE=\"";
208
+  echo "\" /> / \n";
209
+  echo "<input type=\"text\" name=\"eyear\" size=\"5\" maxlength=\"4\" value=\"";
210
   print (date("Y"));
211
-  echo "\">\n";
212
-  echo "<TD><INPUT TYPE=TEXT NAME=\"ehour\" SIZE=3 MAXLENGTH=2 VALUE=\"23\">:\n";
213
-  echo "<INPUT TYPE=TEXT NAME=\"emin\" SIZE=3 MAXLENGTH=2 VALUE=\"59\">\n";
214
-  echo "<TR><TD>Aggregate Interfaces: \n";
215
-  echo "<TD><INPUT TYPE=CHECKBOX NAME=\"aggr\">\n";
216
-  echo "<TR><TD><INPUT TYPE=TEXT NAME=\"nth\" SIZE=2 MAXLENGTH=2 VALUE=\"95\">th Percentile: \n";
217
-  echo "<TD><INPUT TYPE=CHECKBOX NAME=\"percentile\">\n";
218
-  echo "<TR><TD>Fit to Data: \n";
219
-  echo "<TD><INPUT TYPE=CHECKBOX NAME=\"scalex\">\n";
220
-  echo "<TR><TD>Fit to Speed: \n";
221
-  echo "<TD><INPUT TYPE=CHECKBOX NAME=\"scaley\">\n";
222
-  echo "<TR><TD>X Size: \n";
223
-  echo "<TD><INPUT TYPE=TEXT NAME=\"xplot\" SIZE=3 VALUE=\"500\">\n";
224
-  echo "<TR><TD>Y Size: \n";
225
-  echo "<TD><INPUT TYPE=TEXT NAME=\"yplot\" SIZE=3 VALUE=\"150\">\n";
226
-  echo "<TR><TD>BorderB: \n";
227
-  echo "<TD><INPUT TYPE=TEXT NAME=\"borderb\" SIZE=3 VALUE=\"70\">\n";
228
-  echo "</TABLE>\n";
229
+  echo "\" />\n";
230
+  echo "</td>";
231
+  echo "<td><input type=\"text\" name=\"ehour\" size=\"3\" maxlength=\"2\" value=\"23\" />:\n";
232
+  echo "<input type=\"text\" name=\"emin\" size=\"3\" maxlength=\"2\" value=\"59\" />\n";
233
+  echo "</td></tr>\n";
234
+
235
+  echo "<tr><td>Aggregate Interfaces: </td>\n";
236
+  echo "<td><input type=\"checkbox\" name=\"aggr\" /></td></tr>\n";
237
+  echo "<tr><td><input type=\"text\" name=\"nth\" size=\"2\" maxlength=\"2\" value=\"95\" />th Percentile: </td>\n";
238
+  echo "<td><input type=\"checkbox\" name=\"percentile\" /></td></tr>\n";
239
+  echo "<tr><td>Fit to Data: </td>\n";
240
+  echo "<td><input type=\"checkbox\" name=\"scalex\" /></td></tr>\n";
241
+  echo "<tr><td>Fit to Speed: </td>\n";
242
+  echo "<td><input type=\"checkbox\" name=\"scaley\" /></td></tr>\n";
243
+  echo "<tr><td>X Size: </td>\n";
244
+  echo "<td><input type=\"text\" name=\"xplot\" size=\"3\" value=\"500\" /></td></tr>\n";
245
+  echo "<tr><td>Y Size: </td>\n";
246
+  echo "<td><input type=\"text\" name=\"yplot\" size=\"3\" value=\"150\" /></td></tr>\n";
247
+  echo "<tr><td>BorderB: </td>\n";
248
+  echo "<td><input type=\"text\" name=\"borderb\" size=\"3\" value=\"70\" /></td></tr>\n";
249
+  echo "</table>\n";
250
 }
251
 
252
-if (($bt || $smonth) && $iid) { 
253
+if (($bt != "" || $smonth != "") && ($iid != "")) { 
254
 
255
   /* Format into GNU date syntax */
256
   if ($bt == "") {
257
@@ -148,67 +154,84 @@ if (($bt || $smonth) && $iid) { 
258
     $et = strtotime("$eyear-$emonth-$eday $ehour:$emin:59");
259
   }
260
 
261
-  $range="dtime>FROM_UNIXTIME($bt) AND dtime<=FROM_UNIXTIME($et)";
262
-  $range="$range AND id=$iid[0]";
263
+  $range="`dtime`>FROM_UNIXTIME(" . mysqli_real_escape_string($dbc, $bt) . ") AND " .
264
+    "`dtime`<=FROM_UNIXTIME(" . mysqli_real_escape_string($dbc, $et) . ") " .
265
+    "AND `id`=" . mysqli_real_escape_string($dbc, $iid[0]);
266
 
267
-  $selectQuery="SELECT description, name, speed FROM interface WHERE rid=$rid AND id=$iid[0]";
268
-  $selectResult=mysql_query($selectQuery, $dbc);
269
-  $selectRow=mysql_fetch_object($selectResult);
270
-  echo "<TABLE BORDER=0>\n";
271
-  echo "<TD><I>Device</I>:</TD><TD>$router ($rid)</TD><TR>\n";
272
-  echo "<TD><I>Interface</I>:</TD><TD>$selectRow->name ($iid[0])</TD><TR>\n";
273
-  printf ("<TD><I>Speed</I>:</TD><TD>%2.3f Mbps</TD><TR>\n", $selectRow->speed / 1000000);
274
-  echo "<TD><I>Description</I>:</TD><TD>$selectRow->description</TD><TR>\n";
275
-  print strftime("<TD><I>Period</I>:</TD><TD>%m/%d/%Y %H:%M - ", $bt);
276
-  print strftime("%m/%d/%Y %H:%M</TD>\n", $et);
277
-  echo "</TABLE>\n";
278
-  echo "<P>\n";
279
+  $selectQuery="SELECT `description`, `name`, `speed` FROM `interface` WHERE " .
280
+    "`rid`=" . mysqli_real_escape_string($dbc, $rid) . " AND `id`=" .
281
+    mysqli_real_escape_string($dbc, $iid[0]);
282
+  $selectResult=mysqli_query($dbc, $selectQuery);
283
+  $selectRow=mysqli_fetch_object($selectResult);
284
+  echo "<table border=\"0\">\n";
285
+  echo "<tr><td><i>Device</i>:</td><td>$router ($rid)</td></tr>\n";
286
+  echo "<tr><td><i>Interface</i>:</td><td>$selectRow->name ($iid[0])</td></tr>\n";
287
+  printf ("<tr><td><i>Speed</i>:</td><td>%2.3f Mbps</td></tr>\n", $selectRow->speed / 1000000);
288
+  echo "<tr><td><i>Description</i>:</td><td>$selectRow->description</td></tr>\n";
289
+  print strftime("<tr><td><i>Period</i>:</td><td>%m/%d/%Y %H:%M - ", $bt);
290
+  print strftime("%m/%d/%Y %H:%M</td>\n", $et);
291
+  echo "</tr>\n";
292
+  echo "</table>\n";
293
+  echo "<p>\n";
294
  
295
   #$selectQuery="SELECT DISTINCT id FROM ifInOctets_$rid WHERE $range";
296
-  #$selectResult=mysql_query($selectQuery, $dbc);
297
-  #if (mysql_num_rows($selectResult) <= 0) {
298
+  #$selectResult=mysqli_query($dbc, $selectQuery);
299
+  #if (mysqli_num_rows($selectResult) <= 0) {
300
   #   print "<BR>No Data Found on Interface for Given Range.<BR>\n";
301
   #}
302
   #else {
303
-    $args = "t1=ifInOctets_$rid&t2=ifOutOctets_$rid&begin=$bt&end=$et&units=bits/s&factor=8";
304
+    $args = "t1=ifInOctets_$rid&amp;t2=ifOutOctets_$rid&amp;begin=$bt&amp;";
305
+    $args .= "end=$et&amp;units=bits/s&amp;factor=8";
306
+    $args .= "&amp;title=" . urlencode($selectRow->description);
307
+    $args .= "&amp;t1_name=" . urlencode("Input Octets");
308
+    $args .= "&amp;t2_name=" . urlencode("Output Octets");
309
     foreach ($iid as $value) {
310
-      $args="$args&iid=$value";
311
+      $args="$args&amp;iid=" . urlencode($value);
312
     }
313
-    if ($scalex) $args = "$args&scalex=yes";
314
-    if ($scaley) $args = "$args&scaley=yes";
315
-    if ($xplot) $args = "$args&xplot=$xplot";
316
-    if ($yplot) $args = "$args&yplot=$yplot";
317
-    if ($borderb) $args = "$args&borderb=$borderb";
318
-    if ($aggr) $args = "$args&aggr=yes";
319
-    if ($percentile) $args = "$args&percentile=$nth";
320
-    print "<IMG SRC=rtgplot.cgi?$args><BR>\n";
321
-    $args = "t1=ifInUcastPkts_$rid&t2=ifOutUcastPkts_$rid&begin=$bt&end=$et&units=pkts/s";
322
+    if ($scalex != "") $args = "$args&amp;scalex=yes";
323
+    if ($scaley != "") $args = "$args&amp;scaley=yes";
324
+    if ($xplot != "") $args = "$args&amp;xplot=$xplot";
325
+    if ($yplot != "") $args = "$args&amp;yplot=$yplot";
326
+    if ($borderb != "") $args = "$args&amp;borderb=$borderb";
327
+    if ($aggr != "") $args = "$args&amp;aggr=yes";
328
+    if ($percentile != "") $args = "$args&amp;percentile=$nth";
329
+    print "<img src=\"/cgi-bin/rtgplot.cgi?$args\" alt=\"graph\" /><br />\n";
330
+    $args = "t1=ifInUcastPkts_$rid&amp;t2=ifOutUcastPkts_$rid&amp;begin=$bt&amp;";
331
+    $args .= "end=$et&amp;units=pkts/s";
332
+    $args .= "&amp;title=" . urlencode($selectRow->description);
333
+    $args .= "&amp;t1_name=" . urlencode("Input Packets");
334
+    $args .= "&amp;t2_name=" . urlencode("Output Packets");
335
     foreach ($iid as $value) {
336
-      $args="$args&iid=$value";
337
+      $args="$args&amp;iid=" . urlencode($value);
338
+    }
339
+    if ($scalex != "") $args = "$args&amp;scalex=yes";
340
+    if ($xplot != "") $args = "$args&amp;xplot=$xplot";
341
+    if ($yplot != "") $args = "$args&amp;yplot=$yplot";
342
+    if ($borderb != "") $args = "$args&amp;borderb=$borderb";
343
+    if ($aggr != "") $args = "$args&amp;aggr=yes";
344
+    if ($percentile != "") $args = "$args&amp;percentile=$nth";
345
+    print "<img src=\"/cgi-bin/rtgplot.cgi?$args\" alt=\"graph\" /><br />\n";
346
+    if ($errors != "")
347
+    {
348
+       print "<img src=\"/cgi-bin/rtgplot.cgi?t1=ifInErrors_$rid&amp;begin=$bt";
349
+       print "&amp;end=$et&amp;units=errors&amp;impulses=yes";
350
+       print "&amp;title=" . urlencode($selectRow->description);
351
+       print "&amp;t1_name=" . urlencode("Errors") . "\" alt=\"graph\" />\n";
352
     }
353
-    if ($scalex) $args = "$args&scalex=yes";
354
-    if ($xplot) $args = "$args&xplot=$xplot";
355
-    if ($yplot) $args = "$args&yplot=$yplot";
356
-    if ($borderb) $args = "$args&borderb=$borderb";
357
-    if ($aggr) $args = "$args&aggr=yes";
358
-    if ($percentile) $args = "$args&percentile=$nth";
359
-    print "<IMG SRC=rtgplot.cgi?$args><BR>\n";
360
-    if ($errors) 
361
-       print "<IMG SRC=rtgplot.cgi?t1=ifInErrors_$rid&begin=$bt&end=$et&units=errors&impulses=yes>\n";
362
 #  }
363
 } 
364
 
365
-mysql_close($dbc);
366
+mysqli_close($dbc);
367
 ?>
368
 
369
-<P>
370
-<INPUT TYPE="SUBMIT" VALUE="Ok">
371
-</FORM>
372
-<BR>
373
-<HR>
374
-<FONT FACE="Arial" SIZE="2">
375
+<p>
376
+<input type="submit" value="Ok" />
377
+</form>
378
+<br />
379
+<hr />
380
+<font face="Arial" size="2">
381
 <?php
382
- print "<A HREF=\"http://rtg.sourceforge.net\">RTG</A> Version $VERSION</FONT>";
383
-?>
384
-</BODY>
385
-</HTML>
386
+ print "<a href=\"http://rtg.sourceforge.net\">RTG</a> Version $VERSION</font>";
387
+?></p>
388
+</body>
389
+</html>
(-)net/rtg/files/patch-etc_rtgtargmkr.pl.in (-102 / +3 lines)
Lines 1-110 Link Here
1
--- etc/rtgtargmkr.pl.in.orig	2018-04-02 20:14:41 UTC
1
--- etc/rtgtargmkr.pl.in.orig	2020-09-23 11:57:31 UTC
2
+++ etc/rtgtargmkr.pl.in
2
+++ etc/rtgtargmkr.pl.in
3
@@ -10,10 +10,11 @@
3
@@ -78,7 +78,7 @@ $catalyst = [
4
 # Local customization
5
 
6
 $community   = "public";         # Default SNMP community
7
-$defbits     = 32;               # Default OID bits: 32/64
8
+$defbits     = 64;               # Default OID bits: 32/64
9
 $output      = "targets.cfg";    # Output target file name
10
 $router_file = "routers";        # Input list of devices to poll
11
 $conf_file   = "rtg.conf";       # RTGpoll and RTGplot configurations
12
+$update_desc = 0;		 # Update interface descriptions
13
 $INFO        = 1;                # Print informational messages
14
 $DEBUG       = 0;                # Print debug messages
15
 $DBOFF       = 0;                # Turn database queries off (debug)
16
@@ -77,7 +78,7 @@ $catalyst = [
17
 );
4
 );
18
 
5
 
19
 # Default locations to find RTG configuration file
6
 # Default locations to find RTG configuration file
20
-@configs = ("rtg.conf", "/usr/local/rtg/etc/rtg.conf", "/etc/rtg.conf");
7
-@configs = ("rtg.conf", "/usr/local/rtg/etc/rtg.conf", "/etc/rtg.conf");
21
+@configs = ("rtg.conf", "@RTG_HOME@/etc/rtg.conf", "/usr/local/rtg/etc/rtg.conf", "/etc/rtg.conf");
8
+@configs = ("rtg.conf", "%%PREFIX%%/etc/rtg/rtg.conf", "/usr/local/rtg/etc/rtg.conf", "/etc/rtg.conf");
22
 foreach $conf (@configs) {
9
 foreach $conf (@configs) {
23
   if (open CONF, "<$conf") {
10
   if (open CONF, "<$conf") {
24
     print "Reading [$conf].\n" if $DEBUG;
11
     print "Reading [$conf].\n" if $DEBUG;
25
@@ -93,7 +94,9 @@ foreach $conf (@configs) {
26
         $db_db=$cVals[1];
27
       } elsif ($cVals[0] =~ /Interval/) {
28
         $interval=$cVals[1];
29
-      }	
30
+      }	elsif ($cVals[0] =~ /Update_desc/) {
31
+        $update_desc=$cVals[1];
32
+      }
33
     }
34
     last;
35
   }
36
@@ -113,7 +116,7 @@ sub sql_insert {
37
 # exist, create a new entry and corresponding tables.
38
 sub find_router_id {
39
     ($router) = @_;
40
-    $sql = "SELECT DISTINCT rid FROM router WHERE name=\"$router\"";
41
+    $sql = "SELECT DISTINCT `rid` FROM `router` WHERE `name`=\"$router\"";
42
     print "SQL: $sql\n" if $DEBUG;
43
     my $sth = $dbh->prepare($sql)
44
       or die "Can't prepare $sql: $dbh->errstr\n";
45
@@ -121,12 +124,12 @@ sub find_router_id {
46
       or die "can't execute the query: $sth->errstr\n";
47
     if ( $sth->rows == 0 ) {
48
         print "No router id found for $router...";
49
-        $sql = "INSERT INTO router (name) VALUES(\"$router\")";
50
+        $sql = "INSERT INTO `router` (`name`) VALUES(\"$router\")";
51
         print "adding.\n";
52
         &sql_insert($sql);
53
         $rid = &find_router_id($router);
54
         foreach $mib ( keys %mibs_of_interest ) {
55
-          $sql = "CREATE TABLE $mib"."_$rid (id INT NOT NULL, dtime DATETIME NOT NULL, counter BIGINT NOT NULL, KEY $mib"."_$rid". "_idx (dtime))";
56
+          $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`))";
57
           &sql_insert($sql);
58
         }
59
     }
60
@@ -143,7 +146,7 @@ sub find_router_id {
61
 sub find_interface_id {
62
     ( $rid, $int, $desc, $speed ) = @_;
63
     $desc =~ s/ +$//g;    #remove trailing whitespace
64
-    $sql = "SELECT id, description FROM interface WHERE rid=$rid AND name=\"$int\"";
65
+    $sql = "SELECT `id`, `description` FROM `interface` WHERE `rid`=$rid AND `name`=\"$int\"";
66
     print "SQL: $sql\n" if $DEBUG;
67
     my $sth = $dbh->prepare($sql)
68
       or die "Can't prepare $sql: $dbh->errstr\n";
69
@@ -152,7 +155,7 @@ sub find_interface_id {
70
     if ( $sth->rows == 0 ) {
71
         print "No id found for $int on device $rid...";
72
         $desc =~ s/\"/\\\"/g;    # Fix " in desc
73
-        $sql = "INSERT INTO interface (name, rid, speed, description) VALUES(\"$int\", $rid, $speed, \"$desc\")";
74
+        $sql = "INSERT INTO `interface` (`name`, `rid`, `speed`, `description`) VALUES(\"$int\", $rid, $speed, \"$desc\")";
75
         print "adding.\n";
76
         &sql_insert($sql);
77
         $iid = &find_interface_id( $rid, $int, $desc, $speed );
78
@@ -164,7 +167,13 @@ sub find_interface_id {
79
             print "Interface description changed.\n";
80
             print "Was: \"$row[1]\"\n";
81
             print "Now: \"$desc\"\n";
82
-            print "Suggest: UPDATE interface SET description='$desc' WHERE id=$iid\n";
83
+            if ( $update_desc == 1 ) {
84
+              $sql = "UPDATE `interface` SET `description`='$desc' WHERE `id`=$iid";
85
+              &sql_insert($sql);
86
+              print "Updated.\n";
87
+            } else {
88
+              print "Suggest: UPDATE `interface` SET `description`='$desc' WHERE `id`=$iid\n";
89
+            }
90
         }
91
     }
92
     $sth->finish;
93
@@ -289,7 +298,7 @@ sub main {
94
       $year + 1900, $hour, $min;
95
     print CFG "# Host\tOID\tBits\tCommunity\tTable\tID\tDescription\n";
96
 
97
-    foreach $router (@routers) {
98
+    POKE: foreach $router (@routers) {
99
         $bits = $counterBits{$router};
100
         # Sanity check bits
101
         $bits = $defbits if ( ( $bits != 32 ) && ( $bits != 64 ) );
102
@@ -304,7 +313,7 @@ sub main {
103
         $system = join ( ' ', @result );
104
         print "System: $system\n" if $DEBUG;
105
         $session = SNMP_Session->open( $router, $communities{$router}, 161 )
106
-          || die "Error opening SNMP session to $router";
107
+          || ( print "Error opening SNMP session to $router" and next POKE );
108
         if ( $system =~ /.*Cisco.*WS-.*/ ) {
109
             $system = "Catalyst";
110
             $session->map_table( $catalyst, \&process );
(-)net/rtg/files/patch-etc_view.php (-258 lines)
Lines 1-258 Link Here
1
--- etc/view.php.orig	2003-09-26 15:58:34 UTC
2
+++ etc/view.php
3
@@ -8,154 +8,163 @@
4
   header("Cache-Control: no-cache, must-revalidate");
5
   header("Pragma: no-cache");
6
 
7
-  print "<HTML>\n<!-- RTG Version $VERSION -->\n<HEAD>\n";
8
+  print "<html>\n<!-- RTG Version $VERSION -->\n<head>\n";
9
 
10
   /* Connect to RTG MySQL Database */
11
-  $dbc=@mysql_connect ($host, $user, $pass) or
12
-  $dbc=@mysql_connect ("$host:/var/lib/mysql/mysql.sock", $user, $pass) or 
13
+  $dbc=@mysqli_connect ($host, $user, $pass, $db) or
14
      die ("MySQL Connection Failed, Check Configuration.");
15
-  mysql_select_db($db,$dbc);
16
 
17
   # Global variables off by default in newer versions of PHP
18
-  if (!$PHP_SELF) {
19
+  if (!isset($PHP_SELF) || ($PHP_SELF == "")) {
20
     $PHP_SELF = "view.php";
21
-    $rid = $_GET['rid'];
22
-    $iid = $_GET['iid'];
23
+    $rid = isset($_GET['rid'])?$_GET['rid']:"";
24
+    $iid = isset($_GET['iid'])?$_GET['iid']:"";
25
   }
26
 
27
   # Determine router, interface names as necessary
28
-  if ($rid && $iid) {
29
-    $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";
30
-    $selectResult=mysql_query($selectQuery, $dbc);
31
-    $selectRow=mysql_fetch_object($selectResult);
32
-    $interfaces = mysql_num_rows($selectResult);
33
+  if (($rid != "") && ($iid != "")) {
34
+    $selectQuery="SELECT `a`.`name`, `a`.`description`, `a`.`speed`, `b`.`name` " .
35
+      "AS `router` FROM `interface` `a`, `router` `b` WHERE `a`.`rid`=`b`.`rid` " .
36
+      "AND `a`.`rid`=" . mysqli_real_escape_string($dbc, $rid) . " AND `a`.`id`=" .
37
+      mysqli_real_escape_string($dbc, $iid);
38
+    $selectResult=mysqli_query($dbc, $selectQuery);
39
+    $selectRow=mysqli_fetch_object($selectResult);
40
+    $interfaces = mysqli_num_rows($selectResult);
41
     $name = $selectRow->name;
42
     $description = $selectRow->description;
43
     $speed = ($selectRow->speed)/1000000;
44
     $router = $selectRow->router;
45
-  } else if ($rid && !$iid) {
46
-    $selectQuery="SELECT name AS router from router where rid=$rid";
47
-    $selectResult=mysql_query($selectQuery, $dbc);
48
-    $selectRow=mysql_fetch_object($selectResult);
49
+  } else if (($rid != "")&& ($iid == "")) {
50
+    $selectQuery="SELECT `name` AS `router` FROM `router` WHERE `rid`=" .
51
+      mysqli_real_escape_string($dbc, $rid);
52
+    $selectResult=mysqli_query($dbc, $selectQuery);
53
+    $selectRow=mysqli_fetch_object($selectResult);
54
     $router = $selectRow->router;
55
   }
56
 
57
   # Generate Title 
58
-  echo "<TITLE>RTG: ";
59
-  if ($rid && $iid) echo "$router: $name";
60
-  else if ($rid && !$iid) echo "$router";
61
-  echo "</TITLE>\n";
62
+  echo "<title>RTG: ";
63
+  if (($rid != "") && ($iid != "")) echo "$router: $name";
64
+  else if (($rid != "")&& ($iid == "")) echo "$router";
65
+  echo "</title>\n";
66
 
67
-  print "<meta HTTP-EQUIV=\"Refresh\" CONTENT=\"300\">\n";
68
-  print "<meta HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">\n";
69
-  print "<meta HTTP-EQUIV=\"Cache-Control\" CONTENT=\"no-cache\">\n";
70
-  print "<meta HTTP-EQUIV=\"Expires\" CONTENT=\"".gmdate('D, d M Y H:i:s \G\M\T', time() + 300)."\">\n";
71
-  print "<meta HTTP-EQUIV=\"Generator\" CONTENT=\"RTG $VERSION\">\n";
72
-  print "<meta HTTP-EQUIV=\"Date\" CONTENT=\"".gmdate('D, d M Y H:i:s \G\M\T', time())."\">\n";
73
-  print "<meta HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=iso-8859-1\">\n";
74
+  print "<meta http-equiv=\"Refresh\" content=\"300\" />\n";
75
+  print "<meta http-equiv=\"Pragma\" content=\"no-cache\" />\n";
76
+  print "<meta http-equiv=\"Cache-Control\" content=\"no-cache\" />\n";
77
+  print "<meta http-equiv=\"Expires\" content=\"".gmdate('D, d M Y H:i:s \G\M\T', time() + 300)."\" />\n";
78
+  print "<meta http-equiv=\"Generator\" content=\"RTG $VERSION\" />\n";
79
+  print "<meta http-equiv=\"Date\" content=\"".gmdate('D, d M Y H:i:s \G\M\T', time())."\" />\n";
80
+  print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />\n";
81
 ?>
82
 
83
-</HEAD>
84
-<BODY BGCOLOR="ffffff">
85
-<A HREF="http://rtg.sourceforge.net" ALT="[RTG Home Page]">
86
-<IMG SRC="rtg.png" BORDER="0"></A><P><HR>
87
+</head>
88
+<body bgcolor="ffffff">
89
+<a href="http://rtg.sourceforge.net"<img src="rtg.png" border="0" alt="[RTG Home Page]" /></a><p><hr />
90
 
91
 <?php
92
- echo "<FORM ACTION=\"$PHP_SELF\" METHOD=\"GET\">\n";
93
+ echo "<form action=\"$PHP_SELF\" method=\"get\">\n";
94
 
95
  $et = time();
96
  
97
- if (!$rid) {
98
+ if ($rid == "") {
99
     print "Monitored Devices: <P>\n";
100
-    $selectQuery="SELECT rid, name FROM router";
101
-    $selectResult=mysql_query($selectQuery, $dbc);
102
-    if (mysql_num_rows($selectResult) <= 0) 
103
-      print "<BR>No Routers Found.<BR>\n";
104
+    $selectQuery="SELECT `rid`, `name` FROM `router`";
105
+    $selectResult=mysqli_query($dbc, $selectQuery);
106
+    if (mysqli_num_rows($selectResult) <= 0) 
107
+      print "<br />No Routers Found.<br />\n";
108
     else {
109
-      print "<UL>\n";
110
-      while ($selectRow=mysql_fetch_object($selectResult)){
111
-        print "<LI><A HREF=\"$PHP_SELF?rid=$selectRow->rid\">";
112
-        print "$selectRow->name</A><BR>\n";
113
+      print "<ul>\n";
114
+      while ($selectRow=mysqli_fetch_object($selectResult)){
115
+        print "<li><a href=\"$PHP_SELF?rid=$selectRow->rid\">";
116
+        print "$selectRow->name</a></li><br />\n";
117
       }
118
-      print "</UL>\n";
119
+      print "</ul>\n";
120
     }
121
  }
122
 
123
- if ($rid && $iid) {
124
+ if (($rid != "") && ($iid != "")) {
125
     if ($interfaces <= 0)
126
-      print "<BR>Interface $iid Not Found for Router $router (ID: $rid).<BR>\n";
127
+      print "<br />Interface $iid Not Found for Router $router (ID: $rid).<br />\n";
128
     else {
129
-      print "<TABLE>\n";
130
-      print "<TD>System:<TD>$router\n";
131
-      print "<TR><TD>Interface:<TD>$name\n";
132
-      print "<TR><TD>Description:<TD>$description\n";
133
-      print "<TR><TD>Speed:<TD>$speed Mbps\n";
134
-      print "<TR><TD>Page Generated:<TD>".gmdate('D, d M Y H:i:s \G\M\T', time())."\n";
135
-      print "</TABLE><HR>\n";
136
+      print "<table>\n";
137
+      print "<tr><td>System:</td><td>$router</td></tr>\n";
138
+      print "<tr><td>Interface:</td><td>$name</td></tr>\n";
139
+      print "<tr><td>Description:</td><td>$description</td></tr>\n";
140
+      print "<tr><td>Speed:</td><td>$speed Mbps</td></tr>\n";
141
+      print "<tr><td>Page Generated:</td><td>".gmdate('D, d M Y H:i:s \G\M\T', time())."</td></tr>\n";
142
+      print "</table><hr />\n";
143
 
144
       $bt = $et - (60*60*24);
145
-      print "<B>Day View:</B><BR>\n";
146
-      print "<IMG SRC=\"rtgplot.cgi?t1=ifInOctets_".$rid."&t2=ifOutOctets_".$rid."&iid=$iid&begin=$bt&end=$et&units=bits/s&factor=8&filled=yes\">\n";
147
-      print "<BR><B>$router: $name ($description)</B>\n";
148
-      print "<BR><HR>\n";
149
+      print "<b>Day View:</b><br />\n";
150
+      print "<img src=\"/cgi-bin/rtgplot.cgi?t1=ifInOctets_".$rid."&amp;t2=ifOutOctets_".$rid."&amp;iid=$iid&amp;begin=$bt&amp;end=$et&amp;units=bits/s&amp;factor=8&amp;filled=yes";
151
+      print "&amp;title=" . urlencode("$router: $name ($description)") . "&amp;t1_name=" . urlencode("Input Octets") . "&amp;t2_name=" . urlencode("Output Octets") . "\" />\n";
152
+      print "<br /><b>$router: $name ($description)</b>\n";
153
+      print "<br /><hr />\n";
154
 
155
       $bt = $et - (60*60*24*7);
156
-      print "<B>Week View:</B><BR>\n";
157
-      print "<IMG SRC=\"rtgplot.cgi?t1=ifInOctets_".$rid."&t2=ifOutOctets_".$rid."&iid=$iid&begin=$bt&end=$et&units=bits/s&factor=8&filled=yes\">\n";
158
-      print "<BR><B>$router: $name ($description)</B>\n";
159
-      print "<BR><HR>\n";
160
+      print "<b>Week View:</b><br />\n";
161
+      print "<img src=\"/cgi-bin/rtgplot.cgi?t1=ifInOctets_".$rid."&amp;t2=ifOutOctets_".$rid."&amp;iid=$iid&amp;begin=$bt&amp;end=$et&amp;units=bits/s&amp;factor=8&amp;filled=yes";
162
+      print "&amp;title=" . urlencode("$router: $name ($description)") . "&amp;t1_name=" . urlencode("Input Octets") . "&amp;t2_name=" . urlencode("Output Octets") . "\" />\n";
163
+      print "<br /><b>$router: $name ($description)</b>\n";
164
+      print "<br /><hr />\n";
165
 
166
       $bt = $et - (60*60*24*30);
167
-      print "<B>Month View:</B><BR>\n";
168
-      print "<IMG SRC=\"rtgplot.cgi?t1=ifInOctets_".$rid."&t2=ifOutOctets_".$rid."&iid=$iid&begin=$bt&end=$et&units=bits/s&factor=8&filled=yes\">\n";
169
-      print "<BR><B>$router: $name ($description)</B>\n";
170
-      print "<BR><BR>\n";
171
+      print "<b>Month View:</b><br />\n";
172
+      print "<img src=\"/cgi-bin/rtgplot.cgi?t1=ifInOctets_".$rid."&amp;t2=ifOutOctets_".$rid."&amp;iid=$iid&amp;begin=$bt&amp;end=$et&amp;units=bits/s&amp;factor=8&amp;filled=yes";
173
+      print "&amp;title=" . urlencode("$router: $name ($description)") . "&amp;t1_name=" . urlencode("Input Octets") . "&amp;t2_name=" . urlencode("Output Octets") . "\" />\n";
174
+      print "<br /><b>$router: $name ($description)</b>\n";
175
+      print "<br /><br />\n";
176
     }
177
-    print "<INPUT TYPE=\"SUBMIT\" VALUE=\"Back to Main\">\n";
178
+    print "<input type=\"submit\" value=\"Back to Main\" />\n";
179
  }
180
 
181
- if ($rid && !$iid) {
182
-    $selectQuery="SELECT id, name, description FROM interface WHERE rid=$rid";
183
-    $selectResult=mysql_query($selectQuery, $dbc);
184
-    $interfaces = mysql_num_rows($selectResult);
185
+ if (($rid != "") && ($iid == "")) {
186
+    $selectQuery="SELECT `id`, `name`, `description` FROM `interface` WHERE " .
187
+      "`rid`=" . mysqli_real_escape_string($dbc, $rid);
188
+    $selectResult=mysqli_query($dbc, $selectQuery);
189
+    $interfaces = mysqli_num_rows($selectResult);
190
     if ($interfaces <= 0) 
191
-      print "<BR>No Interfaces Found for Router $router (ID: $rid).<BR>\n";
192
+      print "<br />No Interfaces Found for Router $router (ID: $rid).<br />\n";
193
     else {
194
       $bt = $et - (60*60*12);
195
-      print "<TABLE>\n";
196
-      print "<TD>System:<TD>$router\n";
197
-      print "<TR><TD>Interfaces:<TD>$interfaces\n";
198
-      print "<TR><TD>Page Generated:<TD>";
199
-      print gmdate('D, d M Y H:i:s \G\M\T', time())."\n";
200
-      print "</TABLE><HR>\n";
201
-      print "<TABLE BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"10\">\n";
202
-      while ($selectRow=mysql_fetch_object($selectResult)){
203
+      print "<table>\n";
204
+      print "<tr><td>System:</td><td>$router</td></tr>\n";
205
+      print "<tr><td>Interfaces:</td><td>$interfaces</td></tr>\n";
206
+      print "<tr><td>Page Generated:</td><td>";
207
+      print gmdate('D, d M Y H:i:s \G\M\T', time())."</td></tr>\n";
208
+      print "</table><hr />\n";
209
+      print "<table border=\"0\" cellpadding=\"0\" cellspacing=\"10\">\n";
210
+      print "<tr>\n";
211
+      while ($selectRow=mysqli_fetch_object($selectResult)){
212
         $ids[$selectRow->id] = $selectRow->name; 
213
 	$desc[$selectRow->id] = $selectRow->description;
214
 	$iid = $selectRow->id;
215
-	print "<TD><A HREF=\"$PHP_SELF?rid=$rid&iid=$iid\">\n";
216
-	print "<IMG HEIGHT=\"135\" WIDTH=\"500\" SRC=\"rtgplot.cgi?t1=ifInOctets_".$rid."&t2=ifOutOctets_".$rid."&iid=$iid&begin=$bt&end=$et&units=bits/s&factor=8&filled=yes\" BORDER=\"0\">\n";
217
-	print "</A><BR>\n";
218
-        print "<B>$selectRow->name ($selectRow->description)</B>\n";
219
-        if ($even) {
220
+	print "<td><a href=\"$PHP_SELF?rid=$rid&amp;iid=$iid\">\n";
221
+	print "<img height=\"135\" width=\"500\" src=\"/cgi-bin/rtgplot.cgi?t1=ifInOctets_".$rid."&amp;t2=ifOutOctets_".$rid;
222
+	print "&amp;title=" . urlencode("$router: " . $selectRow->name . " (" . $selectRow->description . ")");
223
+	print "&amp;t1_name=" . urlencode("Input Octets") . "&t2_name=" . urlencode("Output Octets");
224
+	print "&amp;iid=$iid&amp;begin=$bt&amp;end=$et&amp;units=bits/s&amp;factor=8&amp;filled=yes\" border=\"0\" />\n";
225
+	print "</a><br />\n";
226
+        print "<b>$selectRow->name ($selectRow->description)</b>\n";
227
+        if ($even == 1) {
228
 	  $even = 0;
229
-	  print "<TR>\n";
230
+	  print "</tr><tr>\n";
231
 	}
232
 	else $even = 1;
233
       }
234
-      print "</TABLE>\n";
235
+      print "</tr></table>\n";
236
     }
237
-    print "<INPUT TYPE=\"SUBMIT\" VALUE=\"Back to Main\">\n";
238
+    print "<input type=\"submit\" value=\"Back to Main\" />\n";
239
   }
240
 
241
-  if ($dbc) mysql_close($dbc);
242
-  echo "</FORM>\n";
243
+  if ($dbc) mysqli_close($dbc);
244
+  echo "</form>\n";
245
 ?>
246
 
247
-<HR>
248
-<FONT FACE="Arial" SIZE="2">
249
+<hr />
250
+<font face="Arial" size="2">
251
 <?php
252
- print "<A HREF=\"http://rtg.sourceforge.net\">RTG</A> Version $VERSION</FONT>";
253
+ print "<a href=\"http://rtg.sourceforge.net\">RTG</a> Version $VERSION</font>";
254
 ?>
255
-</BODY>
256
-</HTML>
257
+</body>
258
+</html>
(-)net/rtg/files/patch-man_rtgplot.1 (-43 lines)
Lines 1-43 Link Here
1
--- man/rtgplot.1.orig	2003-09-25 04:10:36 UTC
2
+++ man/rtgplot.1
3
@@ -10,7 +10,8 @@
4
 -t tablename(s) -i interface(s) [options] begin end
5
 .br
6
 .B rtgplot.cgi
7
-?t1=tablename &t2=tablename &iid=interface &begin=unixtime &end=unixtime &[options]
8
+?t1=tablename &t`_name=descname &t2=tablename &t2_name=descname &iid=interface 
9
+&begin=unixtime &end=unixtime &[options]
10
 .SH DESCRIPTION
11
 .I rtgplot
12
 generates traffic plots of RTG data in PNG format.  It operates in
13
@@ -82,14 +83,19 @@ pixels.
14
 Set plot bottom border to 
15
 .RI <size> 
16
 pixels.
17
+.TP
18
+.IR "title=<title>"
19
+Set graph title to
20
+.RI <title>
21
 .PP
22
 .SH "EXAMPLES"
23
 .PP
24
 .br
25
 Example HTML IMG TAG:
26
 .PP
27
-<IMG SRC="rtgplot.cgi? t1=ifInOctets_2& t2=ifOutOctets_2& iid=4& 
28
-begin=1046754000& end=1046840399& units=bits/s& factor=8& scalex=yes">
29
+<IMG SRC="rtgplot.cgi? t1=ifInOctets_2& t1_name=Input& t2=ifOutOctets_2& 
30
+t2_name=Output& iid=4& begin=1046754000& end=1046840399& units=bits/s& 
31
+factor=8& scalex=yes& title=Bandwidth+Graph">
32
 .PP
33
 will plot two lines from the MySQL tables ifInOctets_2 and ifOutOctets_2
34
 corresponding to interface 4 on router 2 for the time span 1046754000 to
35
@@ -97,6 +103,8 @@ corresponding to interface 4 on router 2
36
 second; the units argument is displayed as the Y-axis label on the plot.
37
 The scalex argument auto-adjusts the X time axis according to the available 
38
 data samples rather than according to the actual time span given.  
39
+It will have a graph title of "Bandwidth Graph" and legend tags of "Input"
40
+and "Output" for t1 and t2 respectively.
41
 .PP
42
 Draw a 95th percentile line:
43
 .PP
(-)net/rtg/files/patch-man_rtgpoll.1 (-12 lines)
Lines 1-12 Link Here
1
--- man/rtgpoll.1.orig	2003-09-24 17:26:57 UTC
2
+++ man/rtgpoll.1
3
@@ -31,6 +31,9 @@ Disable database inserts.
4
 .IR "\-m"
5
 Skip checking for multiple instances.
6
 .TP
7
+.IR "\-p file"
8
+PID file.  Process ID file.
9
+.TP
10
 .IR "\-z"
11
 Force database insertion of zero deltas.
12
 .TP
(-)net/rtg/files/patch-src_rtg.h (-33 lines)
Lines 1-33 Link Here
1
--- src/rtg.h.orig	2003-09-25 15:56:04 UTC
2
+++ src/rtg.h
3
@@ -40,12 +40,10 @@
4
 #define DEFAULT_DB_DB "rtg"
5
 #define DEFAULT_DB_USER "snmp"
6
 #define DEFAULT_DB_PASS "rtgdefault"
7
-#define DEFAULT_SNMP_VER 1
8
+#define DEFAULT_SNMP_VER 2
9
 #define DEFAULT_SNMP_PORT 161
10
+#define DEFAULT_PIDFILE "/tmp/rtgpoll.pid"
11
 
12
-/* PID File */
13
-#define PIDFILE "/tmp/rtgpoll.pid"
14
-
15
 #define STAT_DESCRIP_ERROR 99
16
 #define HASHSIZE 5000
17
 
18
@@ -175,10 +173,10 @@ int add_hash_entry(target_t *);
19
 int hash_target_file(char *);
20
 
21
 /* Globals */
22
-config_t set;
23
-int lock;
24
-int waiting;
25
-char config_paths[CONFIG_PATHS][BUFSIZE];
26
-hash_t hash;
27
+extern config_t set;
28
+extern int lock;
29
+extern int waiting;
30
+extern char config_paths[CONFIG_PATHS][BUFSIZE];
31
+extern hash_t hash;
32
 
33
 #endif /* not _RTG_H_ */
(-)net/rtg/files/patch-src_rtgplot.c (-84 lines)
Lines 1-84 Link Here
1
--- src/rtgplot.c.orig	2003-10-02 15:27:52 UTC
2
+++ src/rtgplot.c
3
@@ -54,6 +54,9 @@
4
 #include "rtgplot.h"
5
 #include "cgi.h"
6
 
7
+config_t set;
8
+char config_paths[CONFIG_PATHS][BUFSIZE];
9
+
10
 /* dfp is a debug file pointer.  Points to stderr unless debug=level is set */
11
 FILE *dfp = NULL;
12
 
13
@@ -221,7 +224,10 @@ int main(int argc, char **argv) {
14
 						plot_line(data[i][j], &img, &graph, colors->shade, TRUE);
15
 					else
16
 						plot_line(data[i][j], &img, &graph, colors->shade, FALSE);
17
-					snprintf(intname, sizeof(intname), "%s%d", arguments.table[i], arguments.iid[j]);
18
+					if (arguments.tablename[i])
19
+						snprintf(intname, sizeof(intname), "%s", arguments.tablename[i]);
20
+					else
21
+						snprintf(intname, sizeof(intname), "%s%d", arguments.table[i], arguments.iid[j]);
22
 					plot_legend(&img, rate[i][j], &graph, colors->shade, intname, offset);
23
 					offset++;
24
 				}
25
@@ -629,15 +635,15 @@ void plot_legend(gdImagePtr * img, rate_t rate, graph_
26
 	if (set.verbose >= HIGH)
27
 		fprintf(dfp, "Plotting legend (%s).\n", __FUNCTION__);
28
 
29
-	gdImageFilledRectangle(*img, BORDER_L,
30
+	gdImageFilledRectangle(*img, BORDER_L - 10,
31
 			     BORDER_T + graph->image.yplot_area + 37 + 10 * offset,
32
-	BORDER_L + 7, BORDER_T + graph->image.yplot_area + 44 + 10 * offset, color);
33
-	gdImageRectangle(*img, BORDER_L, BORDER_T + graph->image.yplot_area + 37 + 10 * offset,
34
-	       BORDER_L + 7, BORDER_T + graph->image.yplot_area + 44 + 10 * offset,
35
+	BORDER_L - 3, BORDER_T + graph->image.yplot_area + 44 + 10 * offset, color);
36
+	gdImageRectangle(*img, BORDER_L - 10, BORDER_T + graph->image.yplot_area + 37 + 10 * offset,
37
+	       BORDER_L - 3, BORDER_T + graph->image.yplot_area + 44 + 10 * offset,
38
 			 std_colors[black]);
39
 
40
-	if (strlen(interface) > 17) {
41
-		interface[17] = '\0';
42
+	if (strlen(interface) > 15) {
43
+		interface[15] = '\0';
44
 	}
45
 	snprintf(string, sizeof(string), "%s", interface);
46
 	for (i = 0; i < (17 - strlen(interface)); i++) {
47
@@ -662,7 +668,7 @@ void plot_legend(gdImagePtr * img, rate_t rate, graph_
48
 			units(rate.cur, cur), graph->units,
49
 			units((float)rate.total, total));
50
 	}
51
-	gdImageString(*img, gdFontSmall, BORDER_L + 10,
52
+	gdImageString(*img, gdFontSmall, BORDER_L,
53
 		      BORDER_T + graph->image.yplot_area + 33 + (10 * offset), string, std_colors[black]);
54
 }
55
 
56
@@ -866,6 +872,13 @@ void plot_labels(gdImagePtr * img, graph_t * graph) {
57
 	title_offset = 1 - (0.01 * (strlen(VERSION) + strlen(COPYRIGHT) + 2));
58
 	snprintf(string, sizeof(string), "%s %s", COPYRIGHT, VERSION);
59
 	gdImageString(*img, gdFontSmall, BORDER_L + (graph->image.xplot_area * title_offset), BORDER_T - 15, string, std_colors[black]);
60
+
61
+	/* title */
62
+	if (graph->titlestr)
63
+	{
64
+		snprintf(string, sizeof(string), "%s", graph->titlestr);
65
+		gdImageString(*img, gdFontMediumBold, BORDER_L + 5, BORDER_T - 16, string, std_colors[black]);
66
+	}
67
 }
68
 
69
 
70
@@ -1342,10 +1355,14 @@ void parseWeb(arguments_t *arguments, graph_t *graph) 
71
 			}
72
 		}
73
 /* XXX REB - Warning: Deprecated, tN argument will go away in RTG 0.8 XXX */
74
+		snprintf(var, sizeof(var), "title");
75
+		graph->titlestr = cgiGetValue(cgiArg, var); 
76
 		for (i = 0; i < MAXTABLES; i++) {
77
 			snprintf(var, sizeof(var), "t%d", i + 1);
78
 			if ((arguments->table[i] = cgiGetValue(cgiArg, var)))
79
 				arguments->tables_to_plot++;
80
+			snprintf(var, sizeof(var), "t%d_name", i + 1);
81
+			arguments->tablename[i] = cgiGetValue(cgiArg, var);
82
 		}
83
 		if ((graph->units = cgiGetValue(cgiArg, "units")) == NULL) {
84
 			graph->units = malloc(sizeof(DEFAULT_UNITS));
(-)net/rtg/files/patch-src_rtgplot.h (-26 lines)
Lines 1-26 Link Here
1
--- src/rtgplot.h.orig	2003-09-24 14:43:39 UTC
2
+++ src/rtgplot.h
3
@@ -11,6 +11,7 @@
4
 
5
 #include <gd.h>
6
 #include <gdfonts.h>
7
+#include <gdfontmb.h>
8
 #include <strings.h>
9
 
10
 #define XPLOT_AREA 500
11
@@ -95,6 +96,7 @@ typedef struct graph_struct {
12
     int scaley; 
13
     range_t range;
14
     image_t image;
15
+    char *titlestr;
16
 } graph_t;
17
 
18
 /* A linked list of colors that we iterate through each line */
19
@@ -106,6 +108,7 @@ typedef struct color_struct {
20
 
21
 typedef struct arguments_struct {
22
     char *table[MAXTABLES];
23
+    char *tablename[MAXTABLES];
24
     int iid[MAXIIDS];
25
     int tables_to_plot;
26
     int iids_to_plot;
(-)net/rtg/files/patch-src_rtgpoll.c (-71 lines)
Lines 1-71 Link Here
1
--- src/rtgpoll.c.orig	2003-09-25 15:56:04 UTC
2
+++ src/rtgpoll.c
3
@@ -9,10 +9,13 @@
4
 #include "common.h"
5
 #include "rtg.h"
6
 
7
+char config_paths[CONFIG_PATHS][BUFSIZE];
8
+
9
 /* Yes.  Globals. */
10
 stats_t stats =
11
 {PTHREAD_MUTEX_INITIALIZER, 0, 0, 0, 0, 0, 0, 0, 0, 0.0};
12
 char *target_file = NULL;
13
+char *pidfile = NULL;
14
 target_t *current = NULL;
15
 MYSQL mysql;
16
 int entries = 0;
17
@@ -41,7 +44,7 @@ int main(int argc, char *argv[]) {
18
     config_defaults(&set);
19
 
20
     /* Parse the command-line. */
21
-    while ((ch = getopt(argc, argv, "c:dhmt:vz")) != EOF)
22
+    while ((ch = getopt(argc, argv, "c:dhmp:t:vz")) != EOF)
23
 	switch ((char) ch) {
24
 	case 'c':
25
 	    conf_file = optarg;
26
@@ -55,6 +58,9 @@ int main(int argc, char *argv[]) {
27
 	case 'm':
28
 	    set.multiple++;
29
 	    break;
30
+	case 'p':
31
+	    pidfile = optarg;
32
+	    break;
33
 	case 't':
34
 	    target_file = optarg;
35
 	    break;
36
@@ -66,6 +72,9 @@ int main(int argc, char *argv[]) {
37
 	    break;
38
 	}
39
 
40
+    if (!pidfile)
41
+        pidfile = DEFAULT_PIDFILE;
42
+
43
     if (set.verbose >= LOW)
44
 	printf("RTG version %s starting.\n", VERSION);
45
 
46
@@ -78,7 +87,7 @@ int main(int argc, char *argv[]) {
47
     sigaddset(&signal_set, SIGINT);
48
     sigaddset(&signal_set, SIGQUIT);
49
 	if (!set.multiple) 
50
-    	checkPID(PIDFILE);
51
+    	checkPID(pidfile);
52
 
53
     if (pthread_sigmask(SIG_BLOCK, &signal_set, NULL) != 0)
54
 	printf("pthread_sigmask error\n");
55
@@ -244,7 +253,7 @@ void *sig_handler(void *arg)
56
                 if (set.verbose >= LOW)
57
                    printf("Quiting: received signal %d.\n", sig_number);
58
                 rtg_dbdisconnect(&mysql);
59
-                unlink(PIDFILE);
60
+                unlink(pidfile);
61
                 exit(1);
62
                 break;
63
         }
64
@@ -259,6 +268,7 @@ void usage(char *prog)
65
     printf("\nOptions:\n");
66
     printf("  -c <file>   Specify configuration file\n");
67
     printf("  -d          Disable database inserts\n");
68
+    printf("  -p <file>   Specify pid file (defaults to /tmp/rtgpoll.pid)\n");
69
     printf("  -t <file>   Specify target file\n");
70
     printf("  -v          Increase verbosity\n");
71
 	printf("  -m          Allow multiple instances\n");
(-)net/rtg/files/patch-src_rtgsnmp.c (-14 lines)
Lines 1-14 Link Here
1
--- src/rtgsnmp.c.orig	2003-09-25 18:23:35 UTC
2
+++ src/rtgsnmp.c
3
@@ -8,6 +8,11 @@
4
 #include "common.h"
5
 #include "rtg.h"
6
 
7
+config_t set;
8
+int lock;
9
+int waiting;
10
+hash_t hash;
11
+
12
 #ifdef OLD_UCD_SNMP
13
  #include "asn1.h"
14
  #include "snmp_api.h"
(-)net/rtg/files/patch-src_rtgutil.c (-10 lines)
Lines 1-10 Link Here
1
--- src/rtgutil.c.orig	2018-04-02 23:03:54 UTC
2
+++ src/rtgutil.c
3
@@ -37,6 +37,7 @@ int read_rtg_config(char *file, config_t
4
               else if (!strcasecmp(p1, "DB_Database")) strncpy(set->dbdb, p2, sizeof(set->dbdb));
5
               else if (!strcasecmp(p1, "DB_User")) strncpy(set->dbuser, p2, sizeof(set->dbuser));
6
               else if (!strcasecmp(p1, "DB_Pass")) strncpy(set->dbpass, p2, sizeof(set->dbpass));
7
+              else if (!strcasecmp(p1, "Update_desc")) ; // no-op
8
 
9
 /* Long longs not ANSI C.  If OS doesn't support atoll() use default. */
10
               else if (!strcasecmp(p1, "OutOfRange")) 
(-)net/rtg/files/rtgpoll.in (-15 / +7 lines)
Lines 21-30 Link Here
21
name="rtgpoll"
21
name="rtgpoll"
22
rcvar=rtgpoll_enable
22
rcvar=rtgpoll_enable
23
23
24
cmd=%%PREFIX%%/bin/${name}
24
start_precmd="${name}_prestart"
25
command="/usr/sbin/daemon"
25
command="%%PREFIX%%/bin/${name}"
26
26
27
load_rc_config $name
27
load_rc_config ${name}
28
28
29
: ${rtgpoll_enable="NO"}
29
: ${rtgpoll_enable="NO"}
30
: ${rtgpoll_config="%%PREFIX%%/etc/rtg/rtg.conf"}
30
: ${rtgpoll_config="%%PREFIX%%/etc/rtg/rtg.conf"}
Lines 33-51 Link Here
33
: ${rtgpoll_user="rtg"}
33
: ${rtgpoll_user="rtg"}
34
: ${rtgpoll_group="rtg"}
34
: ${rtgpoll_group="rtg"}
35
35
36
required_files="$rtgpoll_targets"
36
required_files="${rtgpoll_targets}"
37
command_args="-b -p ${rtgpoll_pidfile} -c ${rtgpoll_config} -t ${rtgpoll_targets}"
37
38
38
command_args="-f -p $rtgpoll_pidfile $cmd -c $rtgpoll_config -t $rtgpoll_targets"
39
rtgpoll_prestart()
39
40
{
40
start_precmd="rtgpoll_prestart"
41
42
rtgpoll_prestart() {
43
  if [ ! -e "${rtgpoll_pidfile}" ]; then
44
	touch $rtgpoll_pidfile
45
  fi
46
47
  chown "${rtgpoll_user}:${rtgpoll_group}" "$rtgpoll_pidfile"
48
  chmod 640 "$rtgpoll_pidfile"
49
  chown -R "${rtgpoll_user}:${rtgpoll_group}" "%%PREFIX%%/etc/rtg"
41
  chown -R "${rtgpoll_user}:${rtgpoll_group}" "%%PREFIX%%/etc/rtg"
50
  chmod -R u+rwX,g+rX "%%PREFIX%%/etc/rtg"
42
  chmod -R u+rwX,g+rX "%%PREFIX%%/etc/rtg"
51
}
43
}
(-)net/rtg/pkg-plist (-4 / +4 lines)
Lines 4-16 Link Here
4
bin/rtgpoll
4
bin/rtgpoll
5
contrib/README
5
contrib/README
6
contrib/rtgtargmkr-with-modules-0.2.tar.gz
6
contrib/rtgtargmkr-with-modules-0.2.tar.gz
7
%%ETCDIR%%/rtg.conf.sample
8
%%ETCDIR%%/rtgtargmkr.pl
9
%%ETCDIR%%/routers.sample
10
%%ETCDIR%%/createdb
11
%%ETCDIR%%/BER.pm
7
%%ETCDIR%%/BER.pm
12
%%ETCDIR%%/SNMP_Session.pm
8
%%ETCDIR%%/SNMP_Session.pm
13
%%ETCDIR%%/SNMP_util.pm
9
%%ETCDIR%%/SNMP_util.pm
10
%%ETCDIR%%/createdb
11
@sample %%ETCDIR%%/routers.sample
12
@sample %%ETCDIR%%/rtg.conf.sample
13
%%ETCDIR%%/rtgtargmkr.pl
14
include/common.h
14
include/common.h
15
include/rtg.h
15
include/rtg.h
16
include/rtgplot.h
16
include/rtgplot.h

Return to bug 253311