Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Feb 2013 12:44:33 -0600 (CST)
From:      Lawrence Chen <beastie@tardisi.com>
To:        FreeBSD-gnats-submit@freebsd.org
Cc:        beastie_t@lhaven.homeip.net
Subject:   ports/176121: [patch] sysutils/backuppc: add rrdtool pool statistic graphs
Message-ID:  <201302131844.r1DIiXwm086172@zen.lhaven.homeip.net>
Resent-Message-ID: <201302131850.r1DIo15c015924@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         176121
>Category:       ports
>Synopsis:       [patch] sysutils/backuppc: add rrdtool pool statistic graphs
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Feb 13 18:50:01 UTC 2013
>Closed-Date:
>Last-Modified:
>Originator:     Lawrence Chen
>Release:        FreeBSD 9.1-RELEASE amd64
>Organization:
>Environment:
System: FreeBSD zen.lhaven.homeip.net 9.1-RELEASE FreeBSD 9.1-RELEASE #0 r243825: Tue Dec 4 09:23:10 UTC 2012 root@farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC amd64


	
>Description:
	BackupPC under Ubuntu had pretty graphs of pool information, which
	is apparently an upstream patch from debian.

	I have adapted the rrdtool patch from the backuppc-users mailing list
	http://www.mail-archive.com/backuppc-users@lists.sourceforge.net/msg09451.html

	
>How-To-Repeat:
	
>Fix:

	

--- patch.txt begins here ---
--- Makefile.orig	2012-12-16 00:16:58.000000000 -0600
+++ Makefile	2013-02-13 12:12:00.013857443 -0600
@@ -7,6 +7,7 @@
 
 PORTNAME=	backuppc
 PORTVERSION=	3.2.1
+PORTREVISION=	1
 CATEGORIES=	sysutils
 MASTER_SITES=	SF
 MASTER_SITE_SUBDIR=	${PORTNAME}/${PORTNAME}/${PORTVERSION}
@@ -39,7 +40,8 @@
 		FILE_RSYNCP "Perl Rsync client"					off \
 		SMBCLIENT "Samba client"					off \
 		NMBLOOKUP "NetBIOS Name lookup tool"				off \
-		XML_RSS "Perl extension to manage RSS files"			off
+		XML_RSS "Perl extension to manage RSS files"			off \
+		RRDTOOL "Use RRDTool to generate pool statistic graphs"		off
 
 .include <bsd.port.options.mk>
 
@@ -61,6 +63,11 @@
 .if defined(WITH_XML_RSS)
 RUN_DEPENDS+=	p5-XML-RSS>=0:${PORTSDIR}/textproc/p5-XML-RSS
 .endif
+.if defined(WITH_RRDTOOL)
+RUN_DEPENDS+=	rrdtool:${PORTSDIR}/databases/rrdtool
+EXTRA_PATCHES+= ${FILESDIR}/extra-patch-bin__BackupPC \
+		${FILESDIR}/extra-patch-lib__BackupPC__CGI__GeneralInfo.pm
+.endif
 
 post-patch:
 	@${REINPLACE_CMD} \
--- files/extra-patch-bin__BackupPC.orig	1969-12-31 18:00:00.000000000 -0600
+++ files/extra-patch-bin__BackupPC	2013-02-13 12:12:12.532857364 -0600
@@ -0,0 +1,36 @@
+--- ./bin/BackupPC.orig	2011-04-24 22:31:54.000000000 -0500
++++ ./bin/BackupPC	2013-02-13 12:02:07.917857713 -0600
+@@ -1198,6 +1198,33 @@
+ 				     $Info{"${p}FileRepMax"},
+ 				     $Info{"${p}FileLinkMax"}, $Info{"${p}DirCnt"});
+ 			}
++
++			# RRDTool Graphing stuff
++			if (-x "/usr/local/bin/rrdtool") {
++			  my $date = time() + (24*3600);
++			  if (! -f "$LogDir/pool.rrd") {
++			    system("/usr/local/bin/rrdtool create $LogDir/pool.rrd --step 86400 DS:ckb:GAUGE:172800:0:U DS:tps:GAUGE:172800:0:U RRA:AVERAGE:0.5:1:1400");
++			  }
++
++			  # Generate size totals prior to poolng and compression
++			  my $sizeTot;
++			  foreach my $host ( sort(keys(%{$bpc->HostInfoRead()})) ) {
++			    my @Backups = $bpc->BackupInfoRead($host);
++			    for ( my $i = 0 ; $i < @Backups ; $i++ ) {
++			      $sizeTot += $Backups[$i]{size};
++			    }
++			  }
++
++			  $sizeTot = $sizeTot / 1024;
++
++			  system("/usr/local/bin/rrdtool update $LogDir/pool.rrd $date:".($Info{"cpoolKb"}+$Info{"poolKb"}).":$sizeTot");
++			  printf(LOG "%sRRD Data: %s:%f:%f\n",
++			    $bpc->timeStamp,
++			    $date,
++			    $Info{"cpoolKb"} + $Info{"poolKb"},
++			    $sizeTot);
++			}
++
+                     }
+                 } else {
+                     $CmdJob = "";
--- files/extra-patch-lib__BackupPC__CGI__GeneralInfo.pm.orig	1969-12-31 18:00:00.000000000 -0600
+++ files/extra-patch-lib__BackupPC__CGI__GeneralInfo.pm	2013-02-13 12:12:12.532857364 -0600
@@ -0,0 +1,35 @@
+--- ./lib/BackupPC/CGI/GeneralInfo.pm.orig	2011-04-24 22:31:55.000000000 -0500
++++ ./lib/BackupPC/CGI/GeneralInfo.pm	2013-02-13 12:02:07.920857680 -0600
+@@ -44,6 +44,18 @@
+     GetStatusInfo("info jobs hosts queueLen");
+     my $Privileged = CheckPermission();
+ 
++    if ($In{image} ne "") {
++	$In{image} =~ /([0-9]+)/;
++	my $weeks = $1;
++	my $real = $<; ### SUID
++	$< = $>; ### SUID
++	print "Content-type: image/png\n\n";
++	print `/usr/local/bin/rrdtool graph - --imgformat=PNG --start=end-${weeks}w --end=-300 --title="BackupPC Pool Size" --logarithmic --rigid --units=si --base=1024 --height=100 --width=600 --alt-autoscale-max --vertical-label="" --slope-mode --font TITLE:10: --font AXIS:8: --font LEGEND:8: --font UNIT:8: -c BACK#FFFFFF DEF:ao="$LogDir/pool.rrd":ckb:AVERAGE DEF:aob="$LogDir/pool.rrd":tps:AVERAGE CDEF:a=ao,1024,* CDEF:b=aob,1024,* AREA:a#95B8DB:"CPool in bytes                  " GPRINT:a:LAST:"Current\\:%8.2lf %s" GPRINT:a:AVERAGE:"Average\\:%8.2lf %s" GPRINT:a:MAX:"Maximum\\:%8.2lf %s\\n" LINE1:b#FF0000:"Prior to pooling and compression" GPRINT:b:LAST:"Current\\:%8.2lf %s" GPRINT:b:AVERAGE:"Average\\:%8.2lf %s" GPRINT:b:MAX:"Maximum\\:%8.2lf %s\\n"`;
++
++	$< = $real; ### SUID
++	return;
++    }
++
+     my($jobStr, $statusStr);
+     foreach my $host ( sort(keys(%Jobs)) ) {
+         my $startTime = timeStamp2($Jobs{$host}{startTime});
+@@ -126,9 +138,13 @@
+     } elsif ( $Info{cpoolFileCnt} > 0 ) {
+         $poolInfo = $cpoolInfo;
+     }
++    if ( -r "$LogDir/pool.rrd") {
++	$poolInfo .= '<br/><img src="'.$MyURL.'?image=4"><img src="'.$MyURL.'?image=52"><br/>';
++    }
+     my $generalInfo = eval("qq{$Lang->{BackupPC_Server_Status_General_Info}}")
+                                 if ( $Privileged );
+     my $content = eval("qq{$Lang->{BackupPC_Server_Status}}");
++
+     Header($Lang->{H_BackupPC_Server_Status}, $content);
+     Trailer();
+ }
--- patch.txt ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201302131844.r1DIiXwm086172>