Skip to content
Snippets Groups Projects
Commit 761c64b9 authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

added comments, remove unnecessairy files

parent 09f9ad6f
Branches
No related tags found
No related merge requests found
<?php
require_once 'cronlog.class.php';
/**
* central cronlog viewer
* ______________________________________________________________________
*
* cronlog-renderer contains visual methods to render html
* _____ _ _ _
* / __ \ (_) | | (_)
* | / \/_ __ ___ _ __ _ ___ | |__ __ ___ _____ _____ _ __
* | | | '__/ _ \| '_ \| |/ _ \| '_ \ \ \ / / |/ _ \ \ /\ / / _ \ '__|
* | \__/\ | | (_) | | | | | (_) | |_) | \ 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
*
* @author hahn
* @license GNU GPL 3.0
* @author Axel Hahn <axel.hahn@iml.unibe.ch>
*/
class cronlogrenderer extends cronlog{
......@@ -49,7 +74,6 @@ class cronlogrenderer extends cronlog{
if(!$aData){
$aData=$this->getServersLastLog();
}
// $sHtml='DEBUG: <pre>'.print_r($aData, 1).'</pre>';
$sTblHead='';
$iOK=0;
......@@ -156,7 +180,6 @@ class cronlogrenderer extends cronlog{
$aData=array_merge($aData, $this->getServersLastLog());
}
$this->setServer('ALL');
// echo '<pre>'.print_r($aData, 1).'</pre>';
return $this->renderCronlogs($aData);
}
......@@ -190,7 +213,6 @@ class cronlogrenderer extends cronlog{
}
}
$iLast=max(array($iLast, date("U", $aEntry['start'])));
// $sViewerUrl='viewer.php?host='.$aEntry['host'].'&job='.$aEntry['job'];
$sClass='message-'.($aEntry['rc']?'error':'ok');
if($aEntry['rc']){
......@@ -264,7 +286,6 @@ class cronlogrenderer extends cronlog{
$aData=array_merge($aData, $this->getServerJobHistory());
}
$this->setServer('ALL');
// echo '<pre>'.print_r($aData, 1).'</pre>';
return $this->renderJoblist($aData);
}
......@@ -392,7 +413,6 @@ class cronlogrenderer extends cronlog{
$aData=array_merge($aData, $this->getServerJobHistory());
}
$this->setServer('ALL');
// echo '<pre>'.print_r($aData, 1).'</pre>';
return $this->renderJobGraph($aData);
}
......
<?php
/**
* central cronlog viewer
* ______________________________________________________________________
*
* cronlog contains non visual methods
* _____ _ _ _
* / __ \ (_) | | (_)
* | / \/_ __ ___ _ __ _ ___ | |__ __ ___ _____ _____ _ __
* | | | '__/ _ \| '_ \| |/ _ \| '_ \ \ \ / / |/ _ \ \ /\ / / _ \ '__|
* | \__/\ | | (_) | | | | | (_) | |_) | \ 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 cronlog class contains non visual methods
* @see cronlog-renderer.class.php
*
* @author hahn
* @license GNU GPL 3.0
* @author Axel Hahn <axel.hahn@iml.unibe.ch>
*/
class cronlog {
......@@ -238,7 +263,7 @@ class cronlog {
while (($line = fgets($fileHandle)) !== false) {
// send the current file part to the browser
$aData=$this->_parseJoblogLine($line);
if($bUseSkip && array_search($aData['job'], $this->_aSkipJoblogs)===false){
if(!$bUseSkip || array_search($aData['job'], $this->_aSkipJoblogs)===false){
$aReturn[$aData['start']]=$aData;
}
}
......
<?php
/**
* ______________________________________________________________________
*
* _____ _ _ _
* / __ \ (_) | | (_)
* | / \/_ __ ___ _ __ _ ___ | |__ __ ___ _____ _____ _ __
* | | | '__/ _ \| '_ \| |/ _ \| '_ \ \ \ / / |/ _ \ \ /\ / / _ \ '__|
* | \__/\ | | (_) | | | | | (_) | |_) | \ V /| | __/\ V V / __/ |
* \____/_| \___/|_| |_| |\___/|_.__/ \_/ |_|\___| \_/\_/ \___|_|
* _/ |
* |__/
* ______________________________________________________________________
*
* CONFIG FILE
*
* it is included by classes/cronlog.class.php
......@@ -14,7 +26,7 @@ return array(
// when show an error for expired jobs (latency to execute job and sync logs)
'iExpiredJobsFailAfter'=>60*30,
// hide these cronjob labels in the web gui
// hide these cronjob labels in the web gui tab "history"
'aHidelogs'=>array(
'copycronlogs',
)
......
<?php
/* ======================================================================
/**
* ______________________________________________________________________
*
* CRONJOB VIEWER :: AJAX HELPER
* _____ _ _ _
* / __ \ (_) | | (_)
* | / \/_ __ ___ _ __ _ ___ | |__ __ ___ _____ _____ _ __
* | | | '__/ _ \| '_ \| |/ _ \| '_ \ \ \ / / |/ _ \ \ /\ / / _ \ '__|
* | \__/\ | | (_) | | | | | (_) | |_) | \ 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>
*
* ______________________________________________________________________
*
* AJAX HELPER
*
* @license GNU GPL 3.0
* @author Axel Hahn <axel.hahn@iml.unibe.ch>
*/
require_once 'classes/cronlog-renderer.class.php';
......
......@@ -3,7 +3,10 @@
<head>
<meta charset="utf-8" />
<meta http-equiv="Pragma" content="no-cache">
<meta name="robots" content="noindex,nofollow">
<title>Cronjob-Viewer</title>
<script type="text/javascript" src="vendor/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript" src="js/asimax.class.js"></script>
<script type="text/javascript" src="js/functions.js"></script>
......@@ -19,7 +22,7 @@
</head>
<body>
<div id="errorlog"></div>
<span style="float: right">Coded by Axel in 2018 :-)</span>
<span style="float: right">&copy; 2018 -2019</span>
<h1><a href="?"><span class="imllogo"></span> CronjobViewer</a></h1>
<nav class="servers">
<div id="selectserver" class="active">...</div>
......
/* https://www.axel-hahn.de/ */
var sMyServer=false;var oMapHtml2Api={crontable:"crontable",graph:"graph",selectServer:"selectserver"};function getPageItem(c){var b="get.php";$("#"+c).css("opacity","0.2");var a="item="+oMapHtml2Api[c]+"&server="+sMyServer;jQuery.ajax({url:b,data:a,type:"GET",success:function(d){$("#"+c).css("opacity","1");$("#"+c).html(d)},error:function(){$("#"+c).css("opacity",false);$("#"+c).html("Failed :-/");$("#errorlog").html($("#errorlog").html()+'AJAX error: <a href="'+b+"?"+a+'">'+b+"?"+a+"</a><br><br>")}})}function setServer(a){sMyServer=a;$("#lblServername").html(sMyServer);getPageItem("crontable")};
\ No newline at end of file
......@@ -4,7 +4,7 @@
a {color: #38a;text-decoration: none;}
a:hover {text-decoration: underline;}
body{background:#fff; color:#456; font-family: verdana,arial; font-size:1.0em;}
body{background:#fff; color:#456; font-family: verdana,arial; font-size:1.0em; margin: 0;}
button{background:#46a; border: none; color:#fff; padding: 0.5em 1em; border-radius: 0.3em; border: 2px solid rgba(0,0,0,0.1); box-shadow: 0.2em 0.2em 0.5em #aaa;}
button.add{background:#8c8;}
button.del{background:#c88;}
......@@ -14,7 +14,7 @@ button:active{box-shadow: none; }
footer{background: rgba(0,60,60,0.05); border-top: 1px solid #ccc; padding: 1em; margin-top: 5em;}
footer a{color:#678;}
h1{border-bottom: 1px solid #cde;}
h1{border-bottom: 1px solid #cde; background:#eee; margin: 0 0 0.3em; padding: 1em 0.3em;}
h1 a{color: #38a;}
h1 a:hover{text-decoration: none;}
h2{color:#379;}
......@@ -25,14 +25,14 @@ i.fa{font-size: 150%; }
i.fa.lookup{font-size: 100%; opacity: 0.4;}
nav.servers{float: left; margin-right: 1em;}
#selectserver{min-height: 20em; border-right: 1px dashed #cde;}
#selectserver{min-height: 20em; border-right: 2px dashed #cde;}
nav.tabs a{display: block; float: left; background: rgba(0,60,60,0.05); padding: 0.5em 1em; color:#345; text-decoration: none; margin-right: 2px; border-top: 4px solid rgba(0,0,0,0.01);}
nav.tabs a.active{background: #d0e0e0; border-color: rgb(255,0,51); }
nav.tabs a:hover{border-color: #abc;}
input{border: 1px solid #ddd; padding: 0.3em;}
option{font-family: verdana,arial; font-size:1.0em; }
option{font-family: verdana,arial; font-size:1.2em; }
option:hover{background: #eee;}
select{border: 0;}
......
/* https://www.axel-hahn.de/ */
a{color:#38a;text-decoration:none}a:hover{text-decoration:underline}body{background:#fff;color:#456;font-family:verdana,arial;font-size:1.0em}button{background:#468;border:0;color:#fff;padding:.5em 1em;border-radius:.3em;border:1px solid rgba(0,0,0,0.1)}button.add{background:#8c8}button.del{background:#c88}button:hover{background:#cde;color:#000}footer{background:rgba(0,60,60,0.05);border-top:1px solid #ccc;padding:1em;margin-top:5em}footer a{color:#678}i.fa{font-size:150%}i.fa.lookup{font-size:100%;opacity:.4}nav{margin-right:1em}option{font-family:verdana,arial;font-size:1.0em}table{border:1px solid #ccc}tr:hover{background:#eee}th{background:#abc;padding:.5em}td{padding:.3em}.imllogo:before{background:#f03;color:#fff;padding:.5em .3em;content:'IML';font-family:"arial";text-shadow:none}.message{border:1px solid rgba(0,0,0,0.1);padding:1em;float:right}.message-ok{background:#cfc;color:#080}.message-error{background:#fee;color:#800}.vis-item.timeline-result-error{background:#fcc;border-color:#800}.vis-item.timeline-result-ok{background:#cfc;border-color:#080}
\ No newline at end of file
<?php
/*
Axels simpler Fileviewer fuer Cronwrapper-Logs
*/
?>
<?php
$mybasedir=$_SERVER["DOCUMENT_ROOT"]."/cronlogs";
/**
* im Cronwrapper Output den Wert eines Schlüsselwortes holen
* @return string
*/
function parse($sData, $sKeyword){
$sReturn='';
$sPattern='/\n'.$sKeyword.'=(.*)/';
preg_match_all($sPattern, $sData, $aMatches);
if (array_key_exists("1", $aMatches)) {
foreach ($aMatches[1] as $key=>$value) $sReturn.=$value . "\n";
}
return trim($sReturn);
}
// ------------------------------------------------------------
// Dateiname holen
// ------------------------------------------------------------
if (!array_key_exists("file", $_GET)){
die("no file was detected in the url.");
}
$myfile=$_GET["file"];
if (strpos(" ".$myfile, "..")){
echo "Sorry, the .. is not allowed.<br>";
die();
}
if (!file_exists($mybasedir."/".$myfile) || !is_file($mybasedir."/".$myfile)) {
echo "Sorry. File not found: $myfile<br>";
die();
}
// ------------------------------------------------------------
// Ausgabe zusammenbauen
// ------------------------------------------------------------
$sHtml='';
$sType="text";
$sData=file_get_contents($mybasedir."/".$myfile);
$sScript=parse($sData, "SCRIPTNAME");
if ($sScript) $sType="cronlog";
switch ($sType) {
case "cronlog":
$rc=parse($sData, "SCRIPTRC");
$iExpire=parse($sData, "JOBEXPIRE");
$sClassRc='error'; if ($rc==0) $sClassRc='ok';
$sClassExp='error'; if ($iExpire>date("U")) $sClassExp='ok';
if ($rc==0 && $iExpire>date("U")) {
$sHtml.='<div class="ok">Cronjob ist OK.';
} else {
$sHtml.='<div class="error">Fehler gefunden.';
$sHtml.='&nbsp;&nbsp;&nbsp;<span class="'.$sClassRc.'">returncode: '.$rc.'</span>';
}
$sHtml.='&nbsp;&nbsp;&nbsp;<span class="'.$sClassExp.'">expire: '.date("Y-m-d H:i:s", $iExpire).'</span>';
$sHtml.='</div>';
$sData=preg_replace('/([A-Z]*=)(.*)/', '<span class="key">$1</span><span class="value">$2</span>', $sData);
$sData=preg_replace('/(JOBEXPIRE=.*)/', '<span class="'.$sClassExp.'">$1</span>', $sData);
$sData=preg_replace('/(SCRIPTRC=.*)/', '<span class="'.$sClassRc.'">$1</span>', $sData);
// moegliche returncodes im scriptout Block einfaerben
$sData=preg_replace('/(rc=[1-9][0-9]*)/', '<span class="error">$1</span>', $sData);
$sData=preg_replace('/(rc=[1-9])/', '<span class="error">$1</span>', $sData);
// $sData=preg_replace('/(rc=0)/', '<span class="ok">$1</span>', $sData);
// remove terminal color
$sData=preg_replace('/(\[[0-9]{1,3}m)/', '', $sData);
$sData='<div class="cronlog">'.$sData.'</div>';
break;
default:
echo "";
}
// ------------------------------------------------------------
// Ausgabe
// ------------------------------------------------------------
echo "<!doctype html>
<html><head>
<title>$myfile</title>
<style>
.ok{background: #afa;}
.error{background: #faa;}
.cronlog{color:#aaa; font-style: italic;}
.key{color:#11a; font-style: normal;}
.value{color:#000; font-style: normal;}
a.button{
padding: 3px; border: 3px solid #fff; box-shadow: 0 0 7px #ccc;
background: #eee; background: linear-gradient(#ddd, #fff, #ccc);
border-radius: 5px; text-decoration: none; color: #555;
}
a.button:hover{background: #ddf; box-shadow: 0 0 2px #ddd; }
body{font-family: arial; background:#fff; color:#333;}
pre{background: #eee; color:#666; margin: 0;}
</style>
</head>
<body>
<a href='#' onclick='javascript:history.back();' class='button'>zur&uuml;ck</a>
<a href='cronjobs.html' class='button'>&uuml;bersicht der Cronjobs</a>
File: $myfile<br>
<br>
$sHtml
<pre>$sData</pre>
</body></html>
";
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment