From 7dae943b5672082d947d99d00e37b3f1ffeb44bb Mon Sep 17 00:00:00 2001 From: hahn <axel.hahn@iml.unibe.ch> Date: Thu, 16 May 2019 11:46:51 +0200 Subject: [PATCH] ci server: update apmonitor and more checks --- public_html/appmonitor/index.php | 66 ++++++++++++++++++- .../deployment/classes/project.class.php | 1 + 2 files changed, 65 insertions(+), 2 deletions(-) diff --git a/public_html/appmonitor/index.php b/public_html/appmonitor/index.php index 05cdadd9..6c94072d 100644 --- a/public_html/appmonitor/index.php +++ b/public_html/appmonitor/index.php @@ -1,6 +1,7 @@ <?php require_once('classes/appmonitor-client.class.php'); +require_once(__DIR__.'/../deployment/classes/project.class.php'); $oMonitor = new appmonitor(); $oMonitor->addCheck( @@ -77,6 +78,67 @@ foreach (array( ); } +// ---------------------------------------------------------------------- +// count of Projects +// ---------------------------------------------------------------------- +$oPrj=new project(); +$iProjectCount=count($oPrj->getProjects()); +$iInProgress=0; +$iInQueue=0; +foreach ($oPrj->getProjects() as $sPrj) { + $oPrj->getPhases(); + $aProgress=$oPrj->getProgress(); + $iInProgress+=$aProgress['inprogress'] ? 1 : 0; + $iInQueue+=$aProgress['hasQueue'] ? 1 : 0; +} +$oMonitor->addCheck( + array( + "name" => "ci projects", + "description" => "Count of Projects in CI Webgui", + "check" => array( + "function" => "Simple", + "params" => array( + "result" => $iProjectCount ? RESULT_OK : RESULT_ERROR, + "value" => "found projects: $iProjectCount", + "count" => $iProjectCount, + "visual" => "simple", + ), + ), + ) +); +$oMonitor->addCheck( + array( + "name" => "ci inProgress", + "description" => "Projects in progress", + "check" => array( + "function" => "Simple", + "params" => array( + "result" => RESULT_OK, + "value" => "found projects: $iInProgress", + "count" => $iInProgress, + "visual" => "simple", + ), + ), + ) +); +$oMonitor->addCheck( + array( + "name" => "ci hasqueue", + "description" => "Waiting for install", + "check" => array( + "function" => "Simple", + "params" => array( + "result" => RESULT_OK, + "value" => "found projects: $iInQueue", + "count" => $iInQueue, + "visual" => "simple", + ), + ), + ) +); + + + // ---------------------------------------------------------------------- // foreman // ---------------------------------------------------------------------- @@ -99,12 +161,12 @@ if(isset($aConfig['foreman']['api'])){ $oMonitor->addCheck( array( "name" => "Foreman $sForemanKey", - "description" => "Count of $sForemanKey", + "description" => "Count of Foreman $sForemanKey", "check" => array( "function" => "Simple", "params" => array( "result" => count($aFData) ? RESULT_OK : RESULT_ERROR, - "value" => "Count of found $sForemanKey: " . count($aFData)."; response status: ".$oForeman->getResponseStatus() . "; Http-Code ".$oForeman->getResponseInfo('http_code'), + "value" => "Count of found Foreman $sForemanKey: " . count($aFData)."; response status: ".$oForeman->getResponseStatus() . "; Http-Code ".$oForeman->getResponseInfo('http_code'), "count" => count($aFData), "visual" => "simple", ), diff --git a/public_html/deployment/classes/project.class.php b/public_html/deployment/classes/project.class.php index 283b81fb..862a7988 100644 --- a/public_html/deployment/classes/project.class.php +++ b/public_html/deployment/classes/project.class.php @@ -3,6 +3,7 @@ define("OPTION_DEFAULT", -999); define("OPTION_NONE", -1); +require_once __DIR__.'/../inc_functions.php'; require_once 'base.class.php'; require_once 'htmlguielements.class.php'; require_once 'messenger.class.php'; -- GitLab