Skip to content

Commit

Permalink
Add missing Twig-templates
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdijen committed Jul 29, 2019
1 parent 940aba9 commit dd54af4
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 2 deletions.
1 change: 1 addition & 0 deletions templates/monitor.text.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{ status }}
58 changes: 58 additions & 0 deletions templates/monitor.xml.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<monitor>
<health>{{ overall }}</health>

<checks>

{% for key, check in modules %}
{% set health = check.state %}
<check category="{{ check.category }}">
<subject>{{ check.subject }}</subject>
<health>{{ healthInfo[health][0] }}</health>
<summary>{{ check.summary }}</summary>
</check>
{% endfor %}

{% for key, check in configuration %}
{% set health = check.state %}
<check category="{{ check.category }}">
<subject>{{ check.subject }}</subject>
<health>{{ healthInfo[health][0] }}</health>
<summary>{{ check.summary }}</summary>
</check>
{% endfor %}

{% for key, check in store %}
{% set health = check.state %}
<check category="{{ check.category }}">
<subject>{{ check.subject }}</subject>
<health>{{ healthInfo[health][0] }}</health>
<summary>{{ check.summary }}</summary>
</check>
{% endfor %}

{% for authsource in authsources %}
{% for key, check in authsource %}
{% set health = check.state %}
<check category="{{ check.category }}">
<subject>{{ check.subject }}</subject>
<health>{{ healthInfo[health][0] }}</health>
<summary>{{ check.summary }}</summary>
</check>
{% endfor %}
{% endfor %}

{% for entity in metadata %}
{% for key, check in entity %}
{% set health = check.state %}
<check category="{{ check.category }}">
<subject>{{ check.subject }}</subject>
<health>{{ healthInfo[health][0] }}</health>
<summary>{{ check.summary }}</summary>
</check>
{% endfor %}
{% endfor %}

</checks>

</monitor>
15 changes: 13 additions & 2 deletions www/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,28 @@
}

$outputFormat = $requestVars->get('output');

switch ($outputFormat) {
case 'xml':
$t = new \SimpleSAML\XHTML\Template($globalConfig, 'monitor:monitor.xml.php');
$protocol = $serverVars->get('HTTP_PROTOCOL');
$t->data['protocol'] = is_null($protocol) ? 'HTTP/1.0' : $protocol;
$GLOBALS['http_response_code'] = $responseCode;
http_response_code($responseCode);
header("Content-Type: text/xml");
break;
case 'json':
JsonResponse::create(['overall' => $healthInfo[$state][0], 'results' => $results], $responseCode)->send();
return;
case 'text':
$t = new \SimpleSAML\XHTML\Template($globalConfig, 'monitor:monitor.text.php');
$GLOBALS['http_response_code'] = $responseCode;
http_response_code($responseCode);
if ($responseCode === 200) {
$t->data['status'] = 'OK';
} else if ($responseCode === 417) {
$t->data['status'] = 'WARN';
} else {
$t->data['status'] = 'FAIL';
}
break;
default:
$t = new \SimpleSAML\XHTML\Template($globalConfig, 'monitor:monitor.php');
Expand Down

0 comments on commit dd54af4

Please sign in to comment.