icingaweb2-module-director/application/views/scripts/deployment/index.phtml

139 lines
3.6 KiB
PHTML

<?php
use Icinga\Util\Format;
$view = $this;
$logLink = function ($match) use ($view) {
$params = array(
'config_checksum' => $view->config_checksum,
'file_path' => $match[4],
'deployment_id' => $view->deployment->id,
'fileOnly' => true,
);
if (isset($match[5])) {
$params['highlight'] = $match[5];
$params['highlightSeverity'] = $match[1];
$suffix = ': ' . $match[5];
} else {
$suffix = '';
}
return sprintf(
'>%s%s',
$match[1] . $match[2],
$view->qlink(
$match[3] . $match[4],
'director/config/file',
$params,
array('data-base-target' => '_next')
)
) . $suffix;
};
function colorize($log, $logLink) {
$log = preg_replace(
'/^(debug|notice|information|warning|critical)\/(\w+)/m',
'<span class="loglevel \1">\1</span>/<span class="application">\2</span>',
$log
);
$log = preg_replace('/([\^]{2,})/', '<span class="error-hint">\1</span>', $log);
$log = preg_replace_callback(
'~\>(information)(\<.+ )'
. '(/.+?/api/packages/director/[^/]+/)([^:]+\.conf)$~m',
$logLink,
$log
);
$log = preg_replace_callback(
'~\>(critical|warning)(\<[^\n]+?\n?[^\n]+?in )'
. '(/.+?/api/packages/director/[^/]+/)([^:]+\.conf): (\d+)~m',
$logLink,
$log
);
return $log;
}
?><div class="controls">
<?= $this->tabs ?>
<h1><?= $this->escape($this->title) ?></h1>
</div>
<div class="content">
<table class="name-value-table">
<tr>
<th><?= $this->translate('Deployment time') ?></th>
<td><?= $deployment->start_time ?></td>
</tr>
<tr>
<th><?= $this->translate('Sent to') ?></th>
<td><?= $deployment->peer_identity ?></td>
</tr>
<tr>
<th><?= $this->translate('Configuration') ?></th>
<td><?= $this->qlink(
sprintf(
$this->translate('%d files'),
$this->config->getFileCount()
),
'director/config/files',
array(
'checksum' => $config_checksum,
'deployment_id' => $deployment->id
)
) ?>, <?= sprintf(
$this->translate('%d objects, %d templates, %d apply rules'),
$config->getObjectCount(),
$config->getTemplateCount(),
$config->getApplyCount()
)?>, <?= Format::bytes($config->getSize()) ?></td>
</tr>
<tr>
<th><?= $this->translate('Duration') ?></th>
<td><?= sprintf(
$this->translate('Rendered in %0.2fs, deployed in %0.2fs'),
$config->getDuration() / 1000,
$deployment->duration_dump / 1000
) ?></td>
</tr>
<tr>
<th><?= $this->translate('Stage name') ?></th>
<td><?= $deployment->stage_name ?></td>
</tr>
<tr>
<th><?= $this->translate('Startup') ?></th>
<td><?php
if ($deployment->startup_succeeded === null) {
if ($deployment->stage_collected === null) {
echo $this->translate('Unknown, still waiting for config check outcome') . ' ' . $this->icon('spinner');
} else {
echo $this->translate('Unknown, failed to collect related information') . ' ' . $this->icon('help');
}
} elseif ($deployment->startup_succeeded === 'y') {
echo '<div style="color: green">';
echo $this->translate('Succeeded') . ' ' . $this->icon('ok');
echo '</div>';
} else {
echo '<div style="color: red">';
echo $this->translate('Failed') . ' ' . $this->icon('cancel');
echo '</div>';
}
?></td>
</tr>
</table>
<?php if ($deployment->startup_succeeded !== null): ?>
<h2>Startup log</h2>
<pre class="logfile">
<?= colorize(
$this->escape($deployment->startup_log),
$logLink
) ?>
</pre>
<?php endif ?>
</div>