3 +-------------------------------------------------------------------------+
4 | Copyright (C) 2004 Juan Luis Francés Jiménez |
6 | This program is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU General Public License |
8 | as published by the Free Software Foundation; either version 2 |
9 | of the License, or (at your option) any later version. |
11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. |
15 +-------------------------------------------------------------------------+
17 require ("paths.php");
18 require($smarty_path."Smarty.class.php");
19 include "classes.inc";
21 $smarty = new Smarty; // Template engine
24 //$smarty->compile_check = true;
25 //$smarty->debugging = true;
26 $smarty->template_dir = "./templates";
27 $smarty->compile_dir = "./templates_c";
28 $smarty->config_dir = "./configs";
29 $smarty->config_load("bacula.conf"); // Load config file
30 $mode = $smarty->get_config_vars("mode"); // Lite o Extend?
35 // generaldata.tpl & last_run_report.tpl (last24bytes)
36 $client = $dbSql->link->query("select count(*) from Client")
37 or die ("Error query at row 37");
38 $totalfiles = $dbSql->link->query("select count(FilenameId) from Filename")
39 or die ("Error query at row 39");
40 $last24bytes = $dbSql->link->query("select sum(JobBytes),count(*) from Job where Endtime <= NOW() and UNIX_TIMESTAMP(EndTime) > UNIX_TIMESTAMP(NOW())-86400")
41 or die ("Error query at row 41");
42 $bytes_stored =& $dbSql->link->getOne("select SUM(VolBytes) from Media")
43 or die ("Error query at row 43");
45 $smarty->assign('bytes_stored',$bytes_stored);
47 $tmp = $client->fetchRow();
48 $smarty->assign('clientes_totales',$tmp[0]);
50 $tmp = $last24bytes->fetchRow();
51 if ( empty($tmp[0]) ) { // No data for last 24, search last 48
52 $last24bytes = $dbSql->link->query("select sum(JobBytes) from Job where Endtime <= NOW() and UNIX_TIMESTAMP(EndTime) > UNIX_TIMESTAMP(NOW())-172800" );
53 $smarty->assign('when',"yesterday");
55 $smarty->assign('bytes_totales',$tmp[0]);
56 $smarty->assign('total_jobs', $tmp[1]);
58 $tmp = $totalfiles->fetchRow();
59 $smarty->assign('files_totales',$tmp[0]);
66 // report_select.tpl & last_run_report.tpl
67 $res = $dbSql->link->query("select Name from Job group by Name");
69 while ( $tmp = $res->fetchRow() )
70 array_push($a_jobs, $tmp[0]);
71 $smarty->assign('total_name_jobs',$a_jobs);
72 $smarty->assign('time2',( (time())-2678400) ); // Current time - 1 month. <select> date
76 $volumes = $dbSql->GetDataVolumes(); // Obtain array with info
77 $pools = array_keys($volumes); // Extract Pools
78 $smarty->assign('pools',$pools);
79 $smarty->assign('volumes',$volumes);
81 // last_run_report.tpl
82 if ($mode == "Lite" && $_GET['Full_popup'] != "yes") {
84 $status = $dbSql->link->query("select JobId,Name,EndTime,JobStatus from Job where EndTime <= NOW() and UNIX_TIMESTAMP(EndTime) >UNIX_TIMESTAMP(NOW())-86400 and JobStatus!=\"T\"" )
85 or die ("Error: query at row 85");
86 $smarty->assign('status', $status->numRows());
87 if ( $status->numRows() ) {
88 while ( $res = $status->fetchRow() )
89 array_push($tmp, $res);
90 $smarty->assign('errors_array',$tmp);
94 // Total Elapsed Time. Only for single Job.
95 $ret = $dbSql->link->query("select UNIX_TIMESTAMP(EndTime)-UNIX_TIMESTAMP(StartTime) as elapsed from Job where EndTime <= NOW() and UNIX_TIMESTAMP(EndTime) > UNIX_TIMESTAMP(NOW())-84600")
96 or die ("Error at row 96");
97 while ( $res = $ret->fetchRow() ) {
98 if ( $TotalElapsed < 1000000000 ) // Temporal "workaround" ;) Fix later
99 $TotalElapsed += $res[0];
101 if ($TotalElapsed > 86400) // More than 1 day!
102 $TotalElapsed = gmstrftime("%d days %H:%M:%S", $TotalElapsed);
104 $TotalElapsed = gmstrftime("%H:%M:%S", $TotalElapsed);
105 $smarty->assign('TotalElapsed',$TotalElapsed);
108 else if ($mode == "Full" || $_GET['Full_popup'] == "yes" ){
110 $query = "select SEC_TO_TIME( UNIX_TIMESTAMP(Job.EndTime)-UNIX_TIMESTAMP(Job.StartTime) )
111 as elapsed,Job.Name,Job.StartTime,Job.EndTime,Job.Level,Pool.Name,Job.JobStatus from Job
112 LEFT JOIN Pool ON Job.PoolId=Pool.PoolId where EndTime <= NOW() and UNIX_TIMESTAMP(EndTime) >UNIX_TIMESTAMP(NOW())-86400
113 order by elapsed "; // Full report array
114 $status = $dbSql->link->query($query)
115 or die ("Error: query at row 115");
116 while ( $tmp = $status->fetchRow() ) {
117 $tdate = explode (":",$tmp[0]);
118 if ( $tdate[0] > 300000 ) // Temporal "workaround" ;) Fix later
119 $tmp[0] = "00:00:00";
120 array_push($tmp1,$tmp);
123 $smarty->assign('clients',$tmp1);
127 if ($_GET['Full_popup'] == "yes" || $_GET['pop_graph1'] == "yes" || $_GET['pop_graph2'] == "yes")
128 $smarty->display('full_popup.tpl');
130 $smarty->display('index.tpl');