This patch adds the pool size graphs on the server status page for privileged 
users.
RRDtool required to store pool size statistics and show graphs.
If RRDtool not installed, status page looks as usual without graphs.
The graphs updates during the 'backuppc nightly' run.

This patch originally was written by Ludovic Drolez and Nicholas Hall:
http://sourceforge.net/mailarchive/forum.php?thread_name=20080302014621.GG618%40renesys.com&forum_name=backuppc-users
http://www.mail-archive.com/backuppc-users@lists.sourceforge.net/msg09451.html

I propose enclosed patch with several improvements:
- long code lines splitted to more readable form;
- place graphs at the end of "General Server Information" section. It looks 
better, IMHO;
- disabled fonts antialiasing;
- added time period to graphs title, like in Debian patch;
- some cosmetic code style corrections.

FYI Debian patch:
http://patch-tracker.debian.org/patch/misc/view/backuppc/3.2.1-5/bin/BackupPC
http://patch-tracker.debian.org/patch/misc/view/backuppc/3.2.1-5/lib/BackupPC/CGI/GeneralInfo.pm

--
Alexander Moisseev

--- ./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 "$BinDir/rrdtool") {
+                         my $date = time() + (24*3600);
+                         if (! -f "$LogDir/pool.rrd") {
+                           system("$BinDir/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("$BinDir/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 = "";
--- ./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 `$BinDir/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();
 }

<<attachment: BackupPC_Server_Status-RRD.png>>

------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_apr
_______________________________________________
BackupPC-devel mailing list
BackupPC-devel@lists.sourceforge.net
List:    https://lists.sourceforge.net/lists/listinfo/backuppc-devel
Wiki:    http://backuppc.wiki.sourceforge.net
Project: http://backuppc.sourceforge.net/

Reply via email to