case 'db-connection': $check['check_result'] = $icon_result[CDBUtils::isConnected($dbSql->db_link)]; break; case 'php-timezone': $timezone = ini_get('date.timezone'); if (!empty($timezone)) { $check['check_result'] = $icon_result[true]; } else { $check['check_result'] = $icon_result[false]; } break; } } // Testing graph capabilities $data = array(array('test', 100), array('test1', 150), array('test1', 180), array('test1', 456)); // Pie graph $pie_graph = new CGraph("testpage-graph03.jpg"); $pie_graph->SetData($data, 'pie'); $view->assign('pie_graph', $pie_graph->Render()); unset($pie_graph); // Bar graph $bar_graph = new CGraph("testpage-graph04.jpg"); $bar_graph->SetData($data, 'bars'); $view->assign('bar_graph', $bar_graph->Render()); unset($bar_graph); // Set page name $current_page = 'Test page'; $view->assign('page_name', $current_page); // Template rendering $view->assign('checks', $check_list); $view->display('test.tpl');
// Stored files on the defined period $backupjob_files = Jobs_Model::getStoredFiles($dbSql->db_link, array(LAST_WEEK, NOW), $backupjob_name); $backupjob_files = CUtils::format_Number($backupjob_files); // Get the last 7 days interval (start and end) $days = DateTimeUtil::getLastDaysIntervals(7); // =============================================================== // Last 7 days stored Bytes graph // =============================================================== $graph = new CGraph("backupjobreport-graph01.jpg"); foreach ($days as $day) { $stored_bytes = Jobs_Model::getStoredBytes($dbSql->db_link, array($day['start'], $day['end']), $backupjob_name); $days_stored_bytes[] = array(date("m-d", $day['start']), $stored_bytes); } $graph->SetData($days_stored_bytes, 'bars', true); // Graph rendering $view->assign('graph_stored_bytes', $graph->Render()); unset($graph); // =============================================================== // Getting last 7 days stored files graph // =============================================================== $graph = new CGraph("backupjobreport-graph02.jpg"); foreach ($days as $day) { $stored_files = Jobs_Model::getStoredFiles($dbSql->db_link, array($day['start'], $day['end']), $backupjob_name); $days_stored_files[] = array(date("m-d", $day['start']), $stored_files); } $graph->SetData($days_stored_files, 'bars'); $graph->SetYTitle("Files"); // Graph rendering $view->assign('graph_stored_files', $graph->Render()); unset($graph); // Get last 10 jobs list
<?php /* +-------------------------------------------------------------------------+ | Copyright 2010-2016, Davide Franco | | | | This program is free software; you can redistribute it and/or | | modify it under the terms of the GNU General Public License | | as published by the Free Software Foundation; either version 2 | | of the License, or (at your option) any later version. | | | | This program is distributed in the hope that it will be useful, | | but WITHOUT ANY WARRANTY; without even the implied warranty of | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | GNU General Public License for more details. | +-------------------------------------------------------------------------+ */ session_start(); include_once 'core/global.inc.php'; // Initialise view and model $view = new CView(); $dbSql = new Bweb($view); // Get volumes list (pools.tpl) $view->assign('pools', $dbSql->GetVolumeList()); // Set page name $current_page = 'Pools and volumes report'; $view->assign('page_name', $current_page); // Process and display the template $view->display('pools.tpl');
$view = new CView(); $dbSql = new Bweb($view); // That's horrible, it must be improved require_once 'core/const.inc.php'; $query = ""; $last_jobs = array(); // Job Status list define('STATUS_ALL', 0); define('STATUS_RUNNING', 1); define('STATUS_WAITING', 2); define('STATUS_COMPLETED', 3); define('STATUS_COMPLETED_WITH_ERRORS', 4); define('STATUS_FAILED', 5); define('STATUS_CANCELED', 6); $job_status = array(STATUS_ALL => 'All', STATUS_RUNNING => 'Running', STATUS_WAITING => 'Waiting', STATUS_COMPLETED => 'Completed', STATUS_COMPLETED_WITH_ERRORS => 'Completed with errors', STATUS_FAILED => 'Failed', STATUS_CANCELED => 'Canceled'); $view->assign('job_status', $job_status); // Global variables $job_levels = array('D' => 'Diff', 'I' => 'Incr', 'F' => 'Full'); // Clients list filter $clients_list = Clients_Model::getClients($dbSql->db_link); $clients_list[0] = 'Any'; $view->assign('clients_list', $clients_list); $query .= "SELECT Job.JobId, Job.Name AS Job_name, Job.Type, Job.StartTime, Job.EndTime, Job.Level, Job.ReadBytes, Job.JobBytes, Job.JobFiles, Pool.Name, Job.JobStatus, Pool.Name AS Pool_name, Status.JobStatusLong "; $query .= "FROM Job "; $query .= "LEFT JOIN Pool ON Job.PoolId=Pool.PoolId "; $query .= "LEFT JOIN Status ON Job.JobStatus = Status.JobStatus "; // Check job status filter if (!is_null(CHttpRequest::get_Value('status'))) { // Selected job status filter switch (CHttpRequest::get_Value('status')) { case STATUS_RUNNING:
foreach (Jobs_Model::get_Jobs_List($dbSql->db_link, $clientid) as $jobname) { // Last good client's for each backup jobs $query = 'SELECT Job.Name, Job.Jobid, Job.Level, Job.Endtime, Job.Jobbytes, Job.Jobfiles, Status.JobStatusLong FROM Job '; $query .= "LEFT JOIN Status ON Job.JobStatus = Status.JobStatus "; $query .= "WHERE Job.Name = '{$jobname}' AND Job.JobStatus = 'T' AND Job.Type = 'B' "; $query .= 'ORDER BY Job.EndTime DESC '; $query .= 'LIMIT 1'; $jobs_result = CDBUtils::runQuery($query, $dbSql->db_link); foreach ($jobs_result->fetchAll() as $job) { $job['level'] = $job_levels[$job['level']]; $job['jobfiles'] = CUtils::format_Number($job['jobfiles']); $job['jobbytes'] = CUtils::Get_Human_Size($job['jobbytes']); $backup_jobs[] = $job; } } $view->assign('backup_jobs', $backup_jobs); // Get the last n days interval (start and end) $days = DateTimeUtil::getLastDaysIntervals($period); // =============================================================== // Last n days stored Bytes graph // =============================================================== $graph = new CGraph("clientreport-graph01.jpg"); foreach ($days as $day) { $stored_bytes = Jobs_Model::getStoredBytes($dbSql->db_link, array($day['start'], $day['end']), 'ALL', $clientid); $days_stored_bytes[] = array(date("m-d", $day['start']), $stored_bytes); } $graph->SetData($days_stored_bytes, 'bars', true); // Graph rendering $view->assign('graph_stored_bytes', $graph->Render()); unset($graph); // ===============================================================
include_once 'core/global.inc.php'; // Initialise view and model $view = new CView(); $dbSql = null; try { $dbSql = new Bweb($view); require_once 'core/const.inc.php'; // Custom period for dashboard $no_period = array(FIRST_DAY, NOW); $last_day = array(LAST_DAY, NOW); // Default period (last day) $custom_period = $last_day; $selected_period = 'last_day'; if (isset($_POST['period_selector'])) { $selected_period = CHttpRequest::get_Value('period_selector'); $view->assign('custom_period_list_selected', $selected_period); switch ($selected_period) { case 'last_day': $custom_period = array(LAST_DAY, NOW); break; case 'last_week': $custom_period = array(LAST_WEEK, NOW); break; case 'last_month': $custom_period = array(LAST_MONTH, NOW); break; case 'since_bot': $custom_period = $no_period; break; } // end switch
+-------------------------------------------------------------------------+ */ session_start(); include_once 'core/global.inc.php'; try { $view = new CView(); $dbSql = new Bweb($view); $joblogs = array(); $jobid = CHttpRequest::get_Value('jobid'); // If $_GET['jobid'] is null and is not a number, throw an Exception if (is_null($jobid) or !is_numeric($jobid)) { throw new Exception('Invalid job id (invalid or null) provided in Job logs report'); } // Prepare and execute SQL statment $statment = array('table' => 'Log', 'where' => array("JobId = '{$jobid}'"), 'orderby' => 'Time'); $result = CDBUtils::runQuery(CDBQuery::get_Select($statment), $dbSql->db_link); // Processing result foreach ($result->fetchAll() as $log) { $log['logtext'] = nl2br($log['logtext']); $joblogs[] = $log; } $view->assign('jobid', $jobid); $view->assign('joblogs', $joblogs); // Set page name $current_page = 'Job logs'; $view->assign('page_name', $current_page); // Process and display the template $view->render('joblogs.tpl'); } catch (Exception $e) { CErrorHandler::displayError($e); }