Esempio n. 1
0
        header($e->getMessage(), true, 500);
        echo json_encode(array('error' => $e->getMessage()));
    }
});
$f3->route(array('GET /ajuda'), function ($f3, $params) {
    global $Smarty;
    $Smarty->assign('alert', array('message' => 'WIP', 'type' => 'info'));
    $Smarty->assign('actualPage', 'ajuda');
    $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);}";
Esempio n. 2
0
<?php

require_once "config.php";
/** Instancia a classe de Runs **/
$runClass = new \Ramos\Zeus\Run();
/** Instancia a classe de Blocks **/
$blockClass = new \Ramos\Zeus\Block();
/** Instancia a classe de Alerts **/
$alertsClass = new \Ramos\Zeus\Alert();
/** Instancia a classe de Jobs **/
$jobClass = new \Ramos\Zeus\Job();
try {
    $startingScript = time();
    $jobID = PHP_SAPI === 'cli' ? $argv[1] : $_GET['job_id'];
    if (empty($jobID) or !is_numeric($jobID)) {
        $logger->addError(__("Please, fill job ID parameter with a numeric string"));
        throw new Exception(__("Please, fill job ID parameter with a numeric string"));
    }
    $job = $connectDB->prepare("SELECT `j`.* FROM `jobs` AS `j` WHERE `j`.`job_id`=:jobID AND `j`.`job_type`='internal' AND `j`.`is_running`=0");
    $job->bindValue(":jobID", $jobID, PDO::PARAM_INT);
    $job->execute();
    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));