Would love to comment on this, but have yet been able to get bacula- web running - :-(

If I had, this would be a great feature to have.

Erich


On Apr 9, 2006, at 3:57 PM, Kern Sibbald wrote:

Hello,

I'm a bit surprised because I have not seen any comments on this proposal. Am
I missing something?  It sounds like a nice feature to me.

I'm copying the users list as well as perhaps they have something to say about
this.


On Friday 31 March 2006 03:27, Kraft, Mike wrote:
Hi,

Pursuant to a brief discussion I had last week with Mr. Sibbald, please
find attached some diffs showing the implementation of a 'numDaysAgo'
CGI query parameter to allow users to see results in Bacula-Web from
previous days, not just the last 24 hours. Our implementation (and the attached diffs) is based on the 1.38.0 Bacula-Web codebase. A screenshot
is also attached so you can see what it looks like.

We changed the Bacula-Web status display so that it is not limited to
listing jobs from the previous 24 hours. It can now list jobs for any 24 hour period a specified number of days ago. Likewise, the General Report graph now shows bytecounts for a 48 hour period starting the specified
number of days ago, instead of just the last 48 hours.

index.php
To begin with, we implemented the recognition of a CGI query parameter
numDaysAgo for the index.php URL. For example:

http://bacula.celcorp.com/index.php?numDaysAgo=2

This would display jobs from 48-72 hours ago. The code in index.php to
read the numDaysAgo parameter:

$numDaysAgo = "0";

if (isset($_GET['numDaysAgo'])) {
        $numDaysAgo = $_GET['numDaysAgo'];
}

settype($numDaysAgo, "integer");
$smarty->assign('num_days_ago', $numDaysAgo);
settype($numDaysAgo, "string");

The next step was to change the 'where' clause of the query that
retrieves the data for the job listing to use the $numDaysAgo variable:

where
    UNIX_TIMESTAMP(EndTime) <= (UNIX_TIMESTAMP(NOW()) -
86400*$numDaysAgo)
  and
    UNIX_TIMESTAMP(EndTime) > (UNIX_TIMESTAMP(NOW()) -
86400*($numDaysAgo+1))

last_run_report.tpl
The status section label was changed in last_run_report.tpl.

index.tpl
The General Report graph is created when index.tpl calls stats.php to
ask it to return the image for the graph. stats.php in turn uses code in
classes.inc to create that image. So we needed to propagate the
numDaysAgo value all the way down this chain. Recall that we created a template variable num_days_ago in index.php; this is available for use
in index.tpl, so we add it to the URL for calling stats.php:

<img src=stats.php?server={$server}&tipo_dato=69&title={t}
General%20report{/t}&modo_graph=bars&sizex=420&
sizey=250&MBottom=20&legend=1&numDaysAgo={$num_days_ago}>

stats.php
In stats.php, we now need to read that parameter:

if (isset($_GET['numDaysAgo'])) {
    $graph->numDaysAgo = $_GET['numDaysAgo'];
}

classes.inc
$graph is an object of type BCreateGraph found in classes.inc. Of
course, it had no member variable numDaysAgo, so we had to add it:

class BCreateGraph extends BGraph {
        var $BD_bacula;
        var $izquierda;
        var $derecha;
        var $StartDate;
        var $EndDate;
        var $elapsed; // Default elapsed time to show complex graphs
        var $numDaysAgo;

        function BCreateGraph() {
                $this->StartDate = "1900-01-01";
                $this->EndDate = "4000-01-01";
                $this->elapsed = "86400"; // 24 hours in seconds.
                $this->numDaysAgo = "0";
         }

Finally, we used BCreateGraph.numDaysAgo in the same way as we did in
index.php, in the 'where' clause of the queries to get the data for the
graph:

where
    UNIX_TIMESTAMP(EndTime) <= (UNIX_TIMESTAMP(NOW()) -
$this->elapsed*$this->numDaysAgo)
  and
    UNIX_TIMESTAMP(EndTime) > (UNIX_TIMESTAMP(NOW()) -
$this->elapsed*($this->numDaysAgo+1))

Misc
Please note that, while we did implement the changes for the Postgres as
well as the MySQL versions of the queries, the Postgres versions have
not been tested...

We were too lazy ;^) to implement a form field for users to submit numDaysAgo values; we just use the browser URL field. Obviously, anyone
could add such a form at anytime.

I was pretty much learning PHP as I went, so please accept my apologies
if I violated any common PHP coding conventions...

So let me know what you think!

Sincerely,
Michael Kraft
Software Project Manager,
Celcorp
www.celcorp.com

--
Best regards,

Kern

  (">
  /\
  V_V


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel? cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Bacula-users mailing list
Bacula-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-users




-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Bacula-users mailing list
Bacula-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-users

Reply via email to