<?
/*
+-------------------------------------------------------------------------+
-| Copyright (C) 2004 Juan Luis Francés Jiménez |
+| Copyright (C) 2004-2005 Juan Luis Frances Jiminez |
| |
| This program is free software; you can redistribute it and/or |
| modify it under the terms of the GNU General Public License |
$this->dsn[username] = $conf->get(CONFIG_FILE,"DATABASE","login");
$this->dsn[password] = $conf->get(CONFIG_FILE,"DATABASE","pass");
$this->dsn[database] = $conf->get(CONFIG_FILE,"DATABASE","db_name");
- $this->dsn[phptype] = $conf->get(CONFIG_FILE,"DATABASE","db_type"); // mysql, (sqlite, pgsql) -->> Yet not checked
+ $this->dsn[phptype] = $conf->get(CONFIG_FILE,"DATABASE","db_type"); // mysql, (sqlite, pgsql) -->> Yet not checked
if ( $conf->get(CONFIG_FILE,"DATABASE","db_port") )
$this->dsn[port] = $conf->get(CONFIG_FILE,"DATABASE","db_port");
- function CalculateBytesPeriod($server,$StartDate,$EndPeriod) { // Bytes transferred in a period.
+ function CalculateBytesPeriod($server,$StartDate,$EndPeriod) { // Bytes transferred in a period.
$result =& $this->link->query("select SUM(JobBytes) from Job WHERE EndTime < '$EndPeriod' and EndTime > '$StartDate' and Name='$server'")
or die("classes.inc: Error query: 1");
- function CalculateFilesPeriod($server,$StartDate,$EndPeriod) { // Number of files transferred in a period.
+ function CalculateFilesPeriod($server,$StartDate,$EndPeriod) { // Number of files transferred in a period.
$result =& $this->link->query("select SUM(JobFiles) from Job WHERE EndTime < '$EndPeriod' and EndTime > '$StartDate' and Name='$server'")
or die("classes.inc: Error query: 2");
require_once ("external_packages/phplot/phplot.php");
- if ( empty($this->sizex) || empty($this->sizey) ) { //Default size
+ if ( empty($this->sizex) || empty($this->sizey) ) { //Default size
$this->sizex = "600";
$this->sizey = "400";
}
}
$legend = $leyenda;
-// $bgcolor = array(222,206,215); // Background color of graph
+// $bgcolor = array(222,206,215); // Background color of graph
$bgcolor = array(207,231,231);
$fgcolor = array(110,41,57);
if ( $this->Leg == 1 ) {
$this->MarginLeftWithLegend($legend);
$graph->SetMarginsPixels($this->MarginLeft,10,35,$this->MarginBottom);
- $graph->SetLegend($legend);
- }
+ $graph->SetLegend($legend);
+ }
else
$graph->SetMarginsPixels(90,35,35,$this->MarginBottom);
// $graph->SetDataColors(array($fgcolor),array( "black"));
$maxlen = 0;
while (next($clients)) {
- $tmp = strlen (current($clients));
+ $tmp = strlen(current($clients));
if ( $tmp > $maxlen )
$maxlen = $tmp;
}
var $derecha;
var $StartDate;
var $EndDate;
- var $elapsed; // Default elapsed time to show complex graphs
+ var $elapsed; // Default elapsed time to show complex graphs
$this->StartDate = "1900-01-01";
$this->EndDate = "4000-01-01";
- $this->elapsed = "86400"; // 24 hours in seconds.
+ $this->elapsed = "86400"; // 24 hours in seconds.
}
$DB_bacula = new Bweb();
$datos = $this->SQLPrepareData($server,$tipo_dato);
- if ( empty($datos) ) { //No data = No stats = Empty graph
+ if ( empty($datos) ) { //No data = No stats = Empty graph
header("Content-type: image/png");
$img= @ImageCreate(200,100) or die ("Cannot intialize GD stream");
$bgc= ImageColorAllocate($img, 0, 255,255);
return;
}
- if ( empty ($xlabel) ) { // If no label, table names like leyends
+ if ( empty ($xlabel) ) { // If no label, table names like leyends
$xlabel=$derecha; $ylabel=$izquierda;
- }
+ }
$this->SetDataType("text-data");
$this->BShowGraph($datos,$title,$xlabel,$ylabel,$this->clientes,$tipo);
- function SQLPrepareData($servidor,$tipo_dato=0) { // Prepare bytes data from database.
+ function SQLPrepareData($servidor,$tipo_dato=0) { // Prepare bytes data from database.
global $DB_bacula;
global $izquierda;
global $derecha;
- if ( $tipo_dato<30 ) { // Simple graph. Only 2 data
+ if ( $tipo_dato<30 ) { // Simple graph. Only 2 data
switch ($tipo_dato)
{
$whole_result[] = $this->array_merge_php4($row["$derecha"],$row[$izquierda]);
}
$result->free();
- } else { // Complex graph. 3 or more data.
+ } else { // Complex graph. 3 or more data.
switch ( $tipo_dato )
{
- case '30': // Unused, at this time.
+ case '30': // Unused, at this time.
$result = $DB_bacula->link->query("select JobBytes,JobFiles,Jobid from Job where Name='$servidor' order by EndTime asc")
or die ("classes.inc: Error at query: 6");
while ( $row = $result->fetchRow(DB_FETCHMODE_ASSOC) )
$whole_result[] = array_merge($row["Jobid"],$row["JobFiles"],$row["JobBytes"]);
$result->free();
break;
- case BACULA_TYPE_BYTES_ENDTIME_ALLJOBS: // Special: Generic graph from all clientes.
- $i = -1; // Counter of number of jobs of one cliente. SP: Contador del número de jobs totales de un cliente.
- $i2 = 0; // Counter of number of keys of array. SP: Contador del número de valores del array.
+ case BACULA_TYPE_BYTES_ENDTIME_ALLJOBS: // Special: Generic graph from all clientes.
+ $i = -1; // Counter of number of jobs of one cliente. SP: Contador del nmero de jobs totales de un cliente.
+ $i2 = 0; // Counter of number of keys of array. SP: Contador del nmero de valores del array.
$res = $DB_bacula->link->query("select Name from Job where UNIX_TIMESTAMP(EndTime) > UNIX_TIMESTAMP(NOW())-$this->elapsed group by Name order by Name desc")
or die ("classes.inc: Error at query: 7");
// echo "</pre>";
- $spr = array(); // Temporal array
- $spr2 = array(); // Temporal array
+ $spr = array(); // Temporal array
+ $spr2 = array(); // Temporal array
$whole_result = array();
while ( $tmpdata = $resdata->fetchRow() ) {
// print_r ($spr2);
// echo "</pre>";
- reset ($this->clientes);
- do {
+ reset ($this->clientes);
+ do {
if ( $spr2[current($this->clientes)] != NULL)
array_push($spr,$spr2[current($this->clientes)]);
else
$spr2 = array();
}
- for ( $i = 0; $i < count($whole_result); $i++ ) { // To equal the arrays so that the graph is not unsquared. SP:Igualamos las matrices para que la gráfica no se descuadre
+ for ( $i = 0; $i < count($whole_result); $i++ ) { // To equal the arrays so that the graph is not unsquared. SP:Igualamos las matrices para que la gr�ica no se descuadre
$tmp = count($whole_result[$i]);
- if ( $i2 < $tmp ) // Estupidez?. Check this code later...
+ if ( $i2 < $tmp ) // Estupidez?. Check this code later...
continue;
$tmp = $i2 - $tmp;
for ( $a = 0; $a <= $tmp; $a++ )
- //Conversión de la fecha a Mysql-format para Smarty. THE SAME FUNCTION AT 2 CLASSES. THIS WAY IS BUGGY. TO SOLVE LATER.
+ //Conversi� de la fecha a Mysql-format para Smarty. THE SAME FUNCTION AT 2 CLASSES. THIS WAY IS BUGGY. TO SOLVE LATER.
function PrepareDate($StartDateMonth,$StartDateDay,$StartDateYear,$EndDateMonth,$EndDateDay,$EndDateYear){
$this->StartDate = $StartDateYear."-".$StartDateMonth."-".$StartDateDay." 00:00:00";
<?
/*
+-------------------------------------------------------------------------+
-| Copyright (C) 2004 Juan Luis Francés Jiménez |
+| Copyright (C) 2004-2005 Juan Luis Frances Jiminez |
| |
| This program is free software; you can redistribute it and/or |
| modify it under the terms of the GNU General Public License |
//$smarty->compile_check = true;
//$smarty->debugging = true;
-$smarty->template_dir = "./templates";
-$smarty->compile_dir = "./templates_c";
-$smarty->config_dir = "./configs";
+$smarty->template_dir = "./templates";
+$smarty->compile_dir = "./templates_c";
+$smarty->config_dir = "./configs";
$smarty->config_load("bacula.conf");
require("lang.php");
$dbSql = new Bweb();
-if ( $_GET['default'] == 1) { // Default params, 1 month
- $dbSql->StartDate = strftime("%Y-%m-%d %H:%M:%S",time()-2678400);
- $dbSql->EndDate = strftime("%Y-%m-%d %H:%M:%S",time());
+if ( $_GET['default'] == 1) { // Default params, 1 month
+ $dbSql->StartDate = strftime("%Y-%m-%d %H:%M:%S",time()-2678400);
+ $dbSql->EndDate = strftime("%Y-%m-%d %H:%M:%S",time());
}
-else // With params
- $dbSql->PrepareDate($_GET['StartDateMonth'],$_GET['StartDateDay'],$_GET['StartDateYear'],$_GET['EndDateMonth'],$_GET['EndDateDay'],$_GET['EndDateYear']);
-
+else // With params
+ $dbSql->PrepareDate($_GET['StartDateMonth'],$_GET['StartDateDay'],$_GET['StartDateYear'],$_GET['EndDateMonth'],$_GET['EndDateDay'],$_GET['EndDateYear']);
+
$bytes = $dbSql->CalculateBytesPeriod($_GET['server'],$dbSql->StartDate,$dbSql->EndDate);
$files = $dbSql->CalculateFilesPeriod($_GET['server'],$dbSql->StartDate,$dbSql->EndDate);
$smarty->assign('startperiod',$dbSql->StartDate);
// Array with jobs data
$a_jobs = array();
if ($dbSql->driver == "mysql")
- $res_jobs = $dbSql->link->query("select *,SEC_TO_TIME( UNIX_TIMESTAMP(Job.EndTime)-UNIX_TIMESTAMP(Job.StartTime) ) as elapsed from Job where EndTime < '$dbSql->EndDate' and EndTime > '$dbSql->StartDate' and Name='$_GET[server]' order by EndTime")
- or die("Error query row 50");
+ $res_jobs = $dbSql->link->query("select *,SEC_TO_TIME( UNIX_TIMESTAMP(Job.EndTime)-UNIX_TIMESTAMP(Job.StartTime) ) as elapsed from Job where EndTime < '$dbSql->EndDate' and EndTime > '$dbSql->StartDate' and Name='$_GET[server]' order by EndTime")
+ or die("Error query row 50");
else if ($dbSql->driver == "pgsql")
- $res_jobs = $dbSql->link->query("select jobid as \"JobId\",job as \"Job\",name as \"Name\",type as \"Type\",level as \"Level\",clientid as \"ClientId\",jobstatus as \"JobStatus\",schedtime as \"SchedTime\",starttime as \"StartTime\",endtime as \"EndTime\",jobtdate as \"JobtDate\",volsessionid as \"VolSessionId\",volsessiontime as \"VolSessionTime\",jobfiles as \"JobFiles\",jobbytes as \"JobBytes\",joberrors as \"JobErrors\",jobmissingfiles as \"JobMissingFiles\",poolid as \"PoolId\",filesetid as \"FilesetId\",purgedfiles as \"PurgedFiles\",hasbase,Job.EndTime::timestamp-Job.StartTime::timestamp as elapsed from Job where EndTime < '$dbSql->EndDate' and EndTime > '$dbSql->StartDate' and Name='$_GET[server]' order by EndTime")
- or die("Error query row 56");
+ $res_jobs = $dbSql->link->query("select jobid as \"JobId\",job as \"Job\",name as \"Name\",type as \"Type\",level as \"Level\",clientid as \"ClientId\",jobstatus as \"JobStatus\",schedtime as \"SchedTime\",starttime as \"StartTime\",endtime as \"EndTime\",jobtdate as \"JobtDate\",volsessionid as \"VolSessionId\",volsessiontime as \"VolSessionTime\",jobfiles as \"JobFiles\",jobbytes as \"JobBytes\",joberrors as \"JobErrors\",jobmissingfiles as \"JobMissingFiles\",poolid as \"PoolId\",filesetid as \"FilesetId\",purgedfiles as \"PurgedFiles\",hasbase,Job.EndTime::timestamp-Job.StartTime::timestamp as elapsed from Job where EndTime < '$dbSql->EndDate' and EndTime > '$dbSql->StartDate' and Name='$_GET[server]' order by EndTime")
+ or die("Error query row 56");
while ( $tmp = $res_jobs->fetchRow(DB_FETCHMODE_ASSOC) ) {
- $tdate = explode (":",$tmp[elapsed]); // Temporal "workaround" ;) Fix later
- if ( $tdate[0] > 300000 )
- $tmp[elapsed] = "00:00:00";
- array_push($a_jobs,$tmp);
+ $tdate = explode (":",$tmp[elapsed]); // Temporal "workaround" ;) Fix later
+ if ( $tdate[0] > 300000 )
+ $tmp[elapsed] = "00:00:00";
+ array_push($a_jobs,$tmp);
}
$smarty->assign('jobs',$a_jobs);
$res = $dbSql->link->query("select Name from Job group by Name");
$a_jobs = array();
while ( $tmp = $res->fetchRow() )
- array_push($a_jobs, $tmp[0]);
+ array_push($a_jobs, $tmp[0]);
$smarty->assign('total_name_jobs',$a_jobs);
$res->free();
$smarty->assign('time2',( (time())-2678400) ); // Current time - 1 month. <select> date
$smarty->display('report.tpl');
?>
-