summaryrefslogtreecommitdiff
path: root/sysutils/backuppc/files/extra-patch-lib-BackupPC-CGI-GeneralInfo.pm
blob: 80f4e8095a0e0fd4d9d6a2615c1ad1e040817189 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
--- lib/BackupPC/CGI/GeneralInfo.pm.orig	2011-04-25 07:31:55.000000000 +0400
+++ lib/BackupPC/CGI/GeneralInfo.pm	2013-02-17 16:52:16.000000000 +0400
@@ -44,6 +44,47 @@
     GetStatusInfo("info jobs hosts queueLen");
     my $Privileged = CheckPermission();
 
+    #
+    # Generate pool size RRDtool graph image
+    #
+    if ( $In{image} ne "" ) {
+        $In{image} =~ /([0-9]+)/;
+        my $weeks = $1;
+        my $real = $<; ### SUID
+        $< = $>; ### SUID
+
+        my $poolSizeGraph = "$BinDir/rrdtool graph -"
+          . " --start=end-${weeks}w --end=-300"
+          . ' --title="BackupPC Pool Size (' . ${weeks} . ' weeks)"'
+          . ' --vertical-label=""'
+          . ' --width=600 --height=100 --rigid --alt-autoscale-max'
+          . ' --base=1024 --logarithmic --units=si'
+          . ' --color BACK#FFFFFF --slope-mode --imgformat=PNG'
+          . ' --font TITLE:10: --font AXIS:8: --font LEGEND:8: --font UNIT:8:'
+          . ' --font-render-mode mono'
+
+          . ' 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"';
+
+        print "Content-type: image/png\n\n";
+        print `$poolSizeGraph`;
+
+        $< = $real; ### SUID
+        return;
+    }
+
     my($jobStr, $statusStr);
     foreach my $host ( sort(keys(%Jobs)) ) {
         my $startTime = timeStamp2($Jobs{$host}{startTime});
@@ -126,8 +167,20 @@
     } elsif ( $Info{cpoolFileCnt} > 0 ) {
         $poolInfo = $cpoolInfo;
     }
-    my $generalInfo = eval("qq{$Lang->{BackupPC_Server_Status_General_Info}}")
-                                if ( $Privileged );
+
+    my $generalInfo = "";
+    if ( $Privileged ) {
+        $generalInfo  = eval("qq{$Lang->{BackupPC_Server_Status_General_Info}}");
+        $generalInfo .= '
+<ul>
+    <ul>
+        <p><img src="' . $MyURL . '?image=4">
+        <p><img src="' . $MyURL . '?image=52">
+    </ul>
+</ul>'
+                                if ( -r "$LogDir/pool.rrd" );
+    }
+
     my $content = eval("qq{$Lang->{BackupPC_Server_Status}}");
     Header($Lang->{H_BackupPC_Server_Status}, $content);
     Trailer();