Пример #1
0
    $Smarty->assign('pageTitle', 'Ajuda | Zeus Monitor');
    $Smarty->display("alert.tpl");
});
$f3->route(array('GET /', 'GET /inicio'), function ($f3, $params) {
    global $Smarty;
    try {
        $jobs = new \Ramos\Zeus\Job();
        $run = new \Ramos\Zeus\Run();
        $returnInfo = $jobs->showJobs($params);
        if (empty($returnInfo['jobs'])) {
            throw new \Exception(__("Not found any job matching this parameters."));
        }
        $alert = new \Ramos\Zeus\Alert();
        foreach ($returnInfo['jobs'] as $key => $job) {
            $returnInfo['jobs'][$key]['lastRunning'] = $run->latestJobRun($job['job_id']);
            $returnInfo['jobs'][$key]['alerts'] = $alert->viewAlertsByJob($job['job_id']);
        }
        $javascriptHeaderCodes = array();
        $javascriptHeaderCodes[] = "\$(\"#showJobInfo\").on(\"click\", function(){\$(\"#infoJobs\").toggle();});";
        $javascriptHeaderCodes[] = "\$(\"#popAlert\").on(\"click\", function(){popupModalMonitor('Sucesso!', 'Essa é uma mensagem de sucesso', 'success');});";
        $javascriptHeaderCodes[] = "\$(window).on('resize', centerModals);";
        $javascriptHeaderCodes[] = "var refresh_rate = Cookies.get('refresh_rate');";
        $javascriptHeaderCodes[] = "if(!refresh_rate){Cookies.set('refresh_rate', 35);}";
        $javascriptHeaderCodes[] = "if(refresh_rate > 10){setInterval(\"reloadPage()\",refresh_rate*1000);}else{setInterval(\"reloadPage()\",35000);Cookies.set('refresh_rate', 35);}";
        $javascriptHeaderCodes[] = "count = refresh_rate; counter = setInterval(timer, 1000);";
        #appendHeaderJS($adicionar_job);
        appendHeaderCode($javascriptHeaderCodes);
        $Smarty->assign('jobs', $returnInfo['jobs']);
        $Smarty->assign('actualPage', 'inicio');
        $Smarty->display("home.tpl");
    } catch (\Exception $e) {
Пример #2
0
 if ($job->rowCount() == 0) {
     define('CURRENT_JOB', $jobID);
     $logger->addWarning(sprintf(__("Job %d cannot be called at this time."), $jobID));
     throw new \Exception(sprintf(__("Job %d cannot be called at this time."), $jobID));
 }
 $JobProperties = $job->fetch(PDO::FETCH_ASSOC);
 if ($JobProperties['job_status'] == false) {
     define('CURRENT_JOB', $jobID);
     $logger->addError(sprintf(__("Job %s (%d) has been disabled!"), $jobName, $jobID));
     throw new Exception(sprintf(__("Job %s (%d) has been disabled!"), $jobName, $jobID));
 }
 $jobName = $JobProperties['job_name'];
 $jobID = (int) $JobProperties['job_id'];
 define('CURRENT_JOB', $jobID);
 $jobPath = $JobProperties['job_path'];
 $viewAlertsByJob = $alertsClass->viewAlertsByJob($jobID);
 if (!file_exists($jobPath)) {
     $message = sprintf(__("Job %s (%d) has a invalid path!"), $jobName, $jobID);
     $populateArray = array('startingScript' => $startingScript, 'endingScript' => time(), 'http_code' => 0, 'total_time' => 0, 'redirect_count' => 0, 'content_type' => 'text/plain', 'others' => NULL, 'responseContent' => 'NULL', 'comments' => $message, 'run_problems' => true);
     $logger->addError($message);
     foreach ($viewAlertsByJob as $singleAlert) {
         if ($singleAlert['block_other_jobs'] == true) {
             $blockClass->addBlock($jobID, $singleAlert['alert_id']);
         }
     }
     $runClass->addRunning($jobID, $populateArray);
     throw new Exception($message);
 }
 $logger->addInfo(sprintf("\r\n############################################\r\nRunning job ID %d\r\n############################################", $jobID));
 //Atualizar o is_running e o last_run
 $jobClass->updateJobAttr($jobID, 'is_running', true);