Skip to content

Commit

Permalink
Merge pull request #31 from pazionit/v3
Browse files Browse the repository at this point in the history
Added checks to prevent Notice and warnings + config entry to list mo…
  • Loading branch information
nerdbaggy committed Feb 3, 2016
2 parents 9978232 + 575d431 commit ac1059a
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 61 deletions.
2 changes: 1 addition & 1 deletion build/statuspage/checks.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@

$tableHeaders = $statusPage->getTableHeaders();

$checks = $statusPage->getChecks($_GET['action']);
$checks = $statusPage->getChecks(( isset($_GET['action']) ? $_GET['action'] : null ));

echo $statusPage->padIt(array('headers' => $tableHeaders, 'checks' => $checks));
4 changes: 4 additions & 0 deletions build/statuspage/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,9 @@
//Only show these monitors
define('includedMonitors', '');


//Show monitors matching search
define('searchMonitors', '');

//Hide certain monitors
define('excludedMonitors', serialize(array()));
129 changes: 69 additions & 60 deletions build/statuspage/statusPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,17 @@ public function getChecks($action = null)
}

$needsUpdated = false;
foreach ($allChecks as $key => $cid) {
$allCheckInfo[] = $cache->get('statuspage-' . $cid);
if (count($allCheckInfo[0]['log']) === 0 && $action === 'update'){
$needsUpdated = true;
unset($allCheckInfo);
break;
}
}

if(count($allChecks)){
foreach ($allChecks as $key => $cid) {
$allCheckInfo[] = $cache->get('statuspage-' . $cid);
if (count($allCheckInfo[0]['log']) === 0 && $action === 'update'){
$needsUpdated = true;
unset($allCheckInfo);
break;
}
}
}

if ($needsUpdated){
$this->updateCache(true);

Expand All @@ -46,56 +48,58 @@ public function updateCache($action)
$checksArray = $this->getChecksJson($action);
$excludedMonitors = unserialize(constant('excludedMonitors'));

foreach ($checksArray['monitors']['monitor'] as $key => $check) {
if (!in_array($check['id'], $excludedMonitors)) {


$allCheckID[] = $check['id'];
$fixedResponseTimes = array();
$fixedEventTime = array();

if (is_array($check['responsetime'])) {

foreach ($check['responsetime'] as $key => $restime) {
$fixedResponseTimes[] = array(
'datetime' => date("Y-m-d G:i:s", strtotime($restime['datetime'])),
'value' => $restime['value']
);
}

}

if (!is_null($check['log'])){



foreach ($check['log'] as $key => $dt) {
$fixedEventTime[] = array(
'actualTime' => $dt['datetime'],
'type' => $dt['type'],
'datetime' => strtotime($dt['datetime'])
);
}

}


$tempCheck = array(
'id' => $check['id'],
'name' => html_entity_decode($check['friendlyname']),
'type' => $check['type'],
'interval' => $check['interval'],
'status' => $check['status'],
'allUpTimeRatio' => $check['alltimeuptimeratio'],
'customUptimeRatio' => explode("-", $check['customuptimeratio']),
'log' => $fixedEventTime,
'responseTime' => $fixedResponseTimes,
'timezone' => intval($checksArray['timezone']),
'currentTime' => time() + (intval($checksArray['timezone']))* 60
);
$cache->set('statuspage-' . $check['id'], $tempCheck, constant('cacheTime'));
}
}
if(count($checksArray['monitors']['monitor'])){
foreach ($checksArray['monitors']['monitor'] as $key => $check) {
if (!in_array($check['id'], $excludedMonitors)) {


$allCheckID[] = $check['id'];
$fixedResponseTimes = array();
$fixedEventTime = array();

if (is_array($check['responsetime'])) {

foreach ($check['responsetime'] as $key => $restime) {
$fixedResponseTimes[] = array(
'datetime' => date("Y-m-d G:i:s", strtotime($restime['datetime'])),
'value' => $restime['value']
);
}

}

if (!is_null($check['log'])){



foreach ($check['log'] as $key => $dt) {
$fixedEventTime[] = array(
'actualTime' => $dt['datetime'],
'type' => $dt['type'],
'datetime' => strtotime($dt['datetime'])
);
}

}


$tempCheck = array(
'id' => $check['id'],
'name' => html_entity_decode($check['friendlyname']),
'type' => $check['type'],
'interval' => $check['interval'],
'status' => $check['status'],
'allUpTimeRatio' => $check['alltimeuptimeratio'],
'customUptimeRatio' => explode("-", $check['customuptimeratio']),
'log' => $fixedEventTime,
'responseTime' => $fixedResponseTimes,
'timezone' => intval($checksArray['timezone']),
'currentTime' => time() + (intval($checksArray['timezone']))* 60
);
$cache->set('statuspage-' . $check['id'], $tempCheck, constant('cacheTime'));
}
}
}
$cache->set('statuspage-allChecks', $allCheckID, constant('cacheTime'));
}

Expand Down Expand Up @@ -128,7 +132,12 @@ private function getChecksJson($action)
if (constant('includedMonitors') != '') {
$monitors = constant('includedMonitors');
$url .= "&monitors=$monitors";
}
}

if (constant('searchMonitors') != '') {
$search = constant('searchMonitors');
$url .= "&search=$search";
}

$curl = curl_init();
curl_setopt_array($curl, array(
Expand Down

0 comments on commit ac1059a

Please sign in to comment.