Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

- added new setting days_to_show_jobs_terminated feature #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions application/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ bacula.bconsolecmd = "-n -c /opt/bacula/etc/bconsole.conf"
;; Jobs with errors (last NN day(s)
; days_to_show_jobs_with_errors = 7


;; As many days to show those Jobs that are terminated (default = 1)
;; Jobs terminated (last NN day(s)
;; days_to_show_jobs_terminated = 2

;; Show human readable short Job description instead of Bacula Job names (default = 0)
; avaliable optins : 0 | 1 | 2
; 0 - only show Bacula Job Name (behavior as in earlier versions)
Expand Down
2 changes: 1 addition & 1 deletion application/controllers/FeedController.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function feedAction ()
);
// terminated Jobs
$jobs = new Job();
$result = $jobs->getTerminatedJobs();
$result = $jobs->getTerminatedJobs(1);
foreach ($result as $item) {
// convert date to timestamp format
$date = new Zend_Date($item['starttime'], 'YYYY-MM-dd HH:mm:ss');
Expand Down
14 changes: 11 additions & 3 deletions application/controllers/JobController.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,18 @@ function init()
*/
function terminatedAction()
{
$this->view->title = $this->view->translate->_("Terminated Jobs (executed in last 24 hours)");
$terminatedDays = trim( $this->_request->getParam('days') );
if ( empty($terminatedDays) ) {
if ( empty($this->view->config->general->days_to_show_jobs_terminated) ) {
$terminatedDays = 1;
} else {
$terminatedDays = $this->view->config->general->days_to_show_jobs_terminated;
}
}
$this->view->title = $this->view->translate->_("Terminated Jobs (executed in last " . ($terminatedDays*24) . " hours)");
// get data from model
$jobs = new Job();
$this->view->result = $jobs->getTerminatedJobs();
$this->view->result = $jobs->getTerminatedJobs($terminatedDays);
$this->view->meta_refresh = 300; // meta http-equiv="refresh"
$this->view->show_job_description = Zend_Registry::get('show_job_description');
}
Expand Down Expand Up @@ -527,7 +535,7 @@ function terminatedDashboardAction()
$this->_helper->layout->setLayout('dashboard');
$this->view->title = $this->view->translate->_("Terminated Jobs (executed in last 24 hours)");
$job = new Job();
$this->view->result = $job->getTerminatedJobs();
$this->view->result = $job->getTerminatedJobs(1);
if ( empty($this->view->result) )
$this->_helper->viewRenderer->setNoRender();
else
Expand Down
6 changes: 4 additions & 2 deletions application/models/Job.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,13 @@ function isJobNameExists($jobname)
* See also http://www.bacula.org/manuals/en/developers/developers/Database_Tables.html
*
*/
function getTerminatedJobs()
function getTerminatedJobs($days)
{
if ( empty($days) )
$days = 1;
$select = new Zend_Db_Select($this->db);
//$select->distinct();
$last1day = date('Y-m-d H:i:s', time() - 86400); // для совместимости со старыми версиями mysql: NOW() - INTERVAL 1 DAY
$last1day = date('Y-m-d H:i:s', time() - ($days * 86400)); // для совместимости со старыми версиями mysql: NOW() - INTERVAL $days

switch ($this->db_adapter) {
case 'PDO_MYSQL':
Expand Down