Index: head/net/rtg/Makefile =================================================================== --- head/net/rtg/Makefile (revision 484405) +++ head/net/rtg/Makefile (revision 484406) @@ -1,53 +1,60 @@ # Created by: Brad Davis # $FreeBSD$ PORTNAME= rtg PORTVERSION= 0.7.4 -PORTREVISION= 14 +PORTREVISION= 15 CATEGORIES= net MASTER_SITES= SF \ 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 RUN_DEPENDS= p5-DBI>=0:databases/p5-DBI \ p5-DBD-mysql>=0:databases/p5-DBD-mysql +FLAVORS= web noweb +noweb_PKGNAMESUFFIX= poller +web_PKGNAMESUFFIX= ${PHP_PKGNAMESUFFIX} + +USES= shebangfix perl5 mysql:client ssl USE_RC_SUBR= rtgpoll -WANT_PERL= yes -USES= shebangfix mysql:client ssl + 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} \ --with-mysql=${LOCALBASE} \ --with-snmp=${LOCALBASE} USERS= rtg GROUPS= rtg -OPTIONS_DEFINE= WEB MYSQL -OPTIONS_DEFAULT=WEB +.if ${FLAVOR:U} == web +USES+= php:web,flavors +USE_PHP= mysqli spl +.endif + +OPTIONS_DEFINE= MYSQL 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 -USE_PHP= mysqli spl - CFLAGS+= -fstack-protector LDFLAGS+= -fstack-protector + +pre-configure: + ${REINPLACE_CMD} -e 's/my_thread_init/mysql_thread_init/' ${WRKSRC}/configure 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 .include Index: head/net/rtg/files/patch-src-rtgpoll.c =================================================================== --- head/net/rtg/files/patch-src-rtgpoll.c (revision 484405) +++ head/net/rtg/files/patch-src-rtgpoll.c (nonexistent) @@ -1,65 +0,0 @@ ---- src/rtgpoll.c.orig 2003-09-25 15:56:04 UTC -+++ src/rtgpoll.c -@@ -13,6 +13,7 @@ - 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 +42,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 +56,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 +70,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 +85,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 +251,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 +266,7 @@ void usage(char *prog) - printf("\nOptions:\n"); - printf(" -c Specify configuration file\n"); - printf(" -d Disable database inserts\n"); -+ printf(" -p Specify pid file (defaults to /tmp/rtgpoll.pid)\n"); - printf(" -t Specify target file\n"); - printf(" -v Increase verbosity\n"); - printf(" -m Allow multiple instances\n"); Property changes on: head/net/rtg/files/patch-src-rtgpoll.c ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -yes \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/net/rtg/files/patch-src-rtg.h =================================================================== --- head/net/rtg/files/patch-src-rtg.h (revision 484405) +++ head/net/rtg/files/patch-src-rtg.h (nonexistent) @@ -1,13 +0,0 @@ ---- src/rtg.h.orig 2003-09-25 15:56:04 UTC -+++ src/rtg.h -@@ -42,9 +42,7 @@ - #define DEFAULT_DB_PASS "rtgdefault" - #define DEFAULT_SNMP_VER 1 - #define DEFAULT_SNMP_PORT 161 -- --/* PID File */ --#define PIDFILE "/tmp/rtgpoll.pid" -+#define DEFAULT_PIDFILE "/tmp/rtgpoll.pid" - - #define STAT_DESCRIP_ERROR 99 - #define HASHSIZE 5000 Property changes on: head/net/rtg/files/patch-src-rtg.h ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -yes \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/net/rtg/files/patch-etc-95.php =================================================================== --- head/net/rtg/files/patch-etc-95.php (revision 484405) +++ head/net/rtg/files/patch-etc-95.php (nonexistent) @@ -1,72 +0,0 @@ ---- etc/95.php.orig 2003-09-24 20:40:57 UTC -+++ etc/95.php -@@ -4,10 +4,8 @@ - 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 == "") { - $PHP_SELF = "95.php"; -@@ -50,8 +48,8 @@ function int_stats($statement, $dbc) { - $max = $avg = $nintyfifth = 0; - $rate = array(); - -- $selectResult=mysql_query($statement, $dbc); -- while ($selectRow=mysql_fetch_object($selectResult)){ -+ $selectResult=mysqli_query($dbc, $statement); -+ while ($selectRow=mysqli_fetch_object($selectResult)){ - $counter = $selectRow->counter; - $sample_secs = $selectRow->unixtime; - $total += $counter; -@@ -89,9 +87,8 @@ 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); -+ $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"); -@@ -104,11 +101,11 @@ Report: 95th percentile
- $range="dtime>FROM_UNIXTIME($bt) AND dtime<=FROM_UNIXTIME($et)"; - - $selectQuery="SELECT id, name, description, rid FROM interface WHERE description LIKE \"%$customer%\""; -- $selectResult=mysql_query($selectQuery, $dbc); -- if (mysql_num_rows($selectResult) <= 0) -+ $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; -@@ -127,8 +124,8 @@ Report: 95th percentile
- foreach($ids as $iid=>$name) { - - $selectQuery="SELECT name FROM router WHERE rid=$rids[$iid]"; -- $selectResult=mysql_query($selectQuery, $dbc); -- $selectRow=mysql_fetch_object($selectResult); -+ $selectResult=mysqli_query($dbc, $selectQuery); -+ $selectRow=mysqli_fetch_object($selectResult); - $router = $selectRow->name; - - if ($yellow) $yellow = 0; -@@ -201,7 +198,7 @@ Report: 95th percentile
- echo "

"; - } - -- if ($dbc) mysql_close($dbc); -+ if ($dbc) mysqli_close($dbc); - echo "\n"; - ?> -
Property changes on: head/net/rtg/files/patch-etc-95.php ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -yes \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/net/rtg/files/patch-src-rtgplot.c =================================================================== --- head/net/rtg/files/patch-src-rtgplot.c (revision 484405) +++ head/net/rtg/files/patch-src-rtgplot.c (nonexistent) @@ -1,74 +0,0 @@ ---- src/rtgplot.c.orig 2003-10-02 15:27:52 UTC -+++ src/rtgplot.c -@@ -221,7 +221,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 +632,15 @@ void plot_legend(gdImagePtr * img, rate_ - 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 +665,7 @@ void plot_legend(gdImagePtr * img, rate_ - 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 +869,13 @@ void plot_labels(gdImagePtr * img, 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 +1352,14 @@ void parseWeb(arguments_t *arguments, gr - } - } - /* 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)); Property changes on: head/net/rtg/files/patch-src-rtgplot.c ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -yes \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/net/rtg/files/patch-src-rtgplot.h =================================================================== --- head/net/rtg/files/patch-src-rtgplot.h (revision 484405) +++ head/net/rtg/files/patch-src-rtgplot.h (nonexistent) @@ -1,26 +0,0 @@ ---- src/rtgplot.h 2003-09-24 15:43:39.000000000 +0100 -+++ src/rtgplot.h.new 2010-04-20 21:41:37.131774833 +0100 -@@ -11,6 +11,7 @@ - - #include - #include -+#include - #include - - #define XPLOT_AREA 500 -@@ -95,6 +96,7 @@ - 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 arguments_struct { - char *table[MAXTABLES]; -+ char *tablename[MAXTABLES]; - int iid[MAXIIDS]; - int tables_to_plot; - int iids_to_plot; Property changes on: head/net/rtg/files/patch-src-rtgplot.h ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -yes \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/net/rtg/files/patch-etc-rtgtargmkr.pl.in =================================================================== --- head/net/rtg/files/patch-etc-rtgtargmkr.pl.in (revision 484405) +++ head/net/rtg/files/patch-etc-rtgtargmkr.pl.in (nonexistent) @@ -1,29 +0,0 @@ ---- etc/rtgtargmkr.pl.in.orig 2016-11-04 16:36:53 UTC -+++ etc/rtgtargmkr.pl.in -@@ -126,7 +126,7 @@ sub find_router_id { - &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); - } - } -@@ -289,7 +289,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 +304,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 ); Property changes on: head/net/rtg/files/patch-etc-rtgtargmkr.pl.in ___________________________________________________________________ Deleted: fbsd:nokeywords ## -1 +0,0 ## -yes \ No newline at end of property Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: head/net/rtg/files/patch-etc-rtg.php =================================================================== --- head/net/rtg/files/patch-etc-rtg.php (revision 484405) +++ head/net/rtg/files/patch-etc-rtg.php (nonexistent) @@ -1,122 +0,0 @@ ---- etc/rtg.php.orig 2003-09-24 20:42:03 UTC -+++ etc/rtg.php -@@ -4,10 +4,8 @@ - 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 == "") { - $PHP_SELF = "rtg.php"; -@@ -37,17 +35,17 @@ - # 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); -+ $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); -+ $selectResult=mysqli_query($dbc, $selectQuery); -+ $selectRow=mysqli_fetch_object($selectResult); - $router = $selectRow->router; - } - -@@ -71,8 +69,8 @@ echo "

\n"; - $selectQuery="SELECT DISTINCT name, rid FROM router ORDER BY name"; -- $selectResult=mysql_query($selectQuery, $dbc); -- while ($selectRow=mysql_fetch_object($selectResult)){ -+ $selectResult=mysqli_query($dbc, $selectQuery); -+ while ($selectRow=mysqli_fetch_object($selectResult)){ - echo "