Skip to content
Snippets Groups Projects
Select Git revision
  • 37b007dd0a5931d79581fe8d8a48ab9c9a41471a
  • master default protected
  • update-renderer-class
3 results

cronlog-renderer.class.php

Blame
  • cronlog-renderer.class.php 30.87 KiB
    <?php
    require_once 'cronlog.class.php';
    /**
     * ______________________________________________________________________
     * 
     *  _____                 _       _             _                        
     * /  __ \               (_)     | |           (_)                       
     * | /  \/_ __ ___  _ __  _  ___ | |__   __   ___  _____      _____ _ __ 
     * | |   | '__/ _ \| '_ \| |/ _ \| '_ \  \ \ / / |/ _ \ \ /\ / / _ \ '__|
     * | \__/\ | | (_) | | | | | (_) | |_) |  \ V /| |  __/\ V  V /  __/ |   
     *  \____/_|  \___/|_| |_| |\___/|_.__/    \_/ |_|\___| \_/\_/ \___|_|   
     *                      _/ |                                             
     *                     |__/                                              
     * ______________________________________________________________________
     * 
     * The cronjob viewer for centralized monitoring of cronjobs using
     * Axels cronrwapper (see <https://github.com/axelhahn/cronwrapper>).
     * 
     * You can browse all servers to see 
     * - the last status of all cronjobs
     * - results an execution times of running jonbs
     * - a timeline for all jobs running > 60s
     * 
     * 
     * Free software. Open Source. GNU GPL 3.
     * SOURCE: <https://git-repo.iml.unibe.ch/iml-open-source/cronlog-viewer>
     * 
     * ______________________________________________________________________
     * 
     * The class cronlog-renderer contains visual methods to render html
     * @see cronlog.class.php
     *
     * @license GNU GPL 3.0
     * @author Axel Hahn <axel.hahn@iml.unibe.ch>
     * 
     * 2024-10-01  <axel.hahn@unibe.ch>  added type declarations; update php docs
     */
    class cronlogrenderer extends cronlog
    {
    
        /**
         * minimal length for execution time of a job to be rendered in the timeline; value is in seconds
         * @var integer
         */
        protected int $_iMinTime4Timeline = 60;
    
        /**
         * Max count of entries in history table to prevent freezing of the screen
         * when displaying a lot of entries, eg all logs of 100+ servers
         * @var int
         */
        protected int $_iHistoryLimit = 1000;
    
        /**
         * Show date of last data and last access; used in rendering methods to display it on top
         * @param integer $iLast  unix timestamp of last log entry
         * @return string
         */
        protected function _renderAccessAndAge(int $iLast): string
        {
            if (!$iLast) {
                return '';
            }
            $iAge = round((date('U') - $iLast) / 60);
            $sAge = ($iAge > 60*24 ? '<span class="message-error">'.$iAge.'</span>' : $iAge);
            return '<div class="accessandage">'
                . sprintf($this->t("request-time"), date("Y-m-d H:i:s")) . '<br>'
                . sprintf($this->t("last-entry"), $sAge)
                /*
                .($iAge > 60*24