mirror of
https://github.com/Icinga/icingadb-web.git
synced 2026-05-28 04:36:06 -04:00
This was easy because only README.md and doc/01-About.md were redacted manually, everything else via: git ls-files -z |xargs -0 perl -pi -e 's/Icinga GmbH \| GPLv2/Icinga GmbH | GPLv2+/' This is legal because we have only merged PRs with label:cla/signed or made by Icinga staff: https://github.com/Icinga/icingadb-web/pulls?page=1&q=is%3Apr+is%3Aclosed+-label%3Acla%2Fsigned+-author%3Anilmerg This has no risk for us in people distributing their own version under GPLv3 only. After all, we won't take their patches anyway, unless they sign our CLA. This is the cleanest solution for having e.g. these in one address space: * Icinga Web, GPLv2+ * K8s Web, AGPLv3 * Thirdparty, some LGPLv3 and Apache-2.0 Apropos, K8s Web is even v3-licensed on purpose, to have a stronger protection against cloud ops.
85 lines
2.7 KiB
PHP
85 lines
2.7 KiB
PHP
<?php
|
|
|
|
/* Icinga DB Web | (c) 2020 Icinga GmbH | GPLv2+ */
|
|
|
|
namespace Icinga\Module\Icingadb\Widget;
|
|
|
|
use Icinga\Module\Icingadb\ProvidedHook\IcingaHealth;
|
|
use ipl\Html\BaseHtmlElement;
|
|
use ipl\Html\Html;
|
|
use ipl\Web\Widget\TimeAgo;
|
|
use ipl\Web\Widget\TimeSince;
|
|
use ipl\Web\Widget\VerticalKeyValue;
|
|
|
|
class Health extends BaseHtmlElement
|
|
{
|
|
protected $data;
|
|
|
|
protected $tag = 'section';
|
|
|
|
public function __construct($data)
|
|
{
|
|
$this->data = $data;
|
|
}
|
|
|
|
protected function assemble()
|
|
{
|
|
if (
|
|
! isset($this->data->icingadb_version)
|
|
|| version_compare(
|
|
IcingaHealth::normalizeVersion($this->data->icingadb_version),
|
|
IcingaHealth::REQUIRED_ICINGADB_VERSION,
|
|
'<'
|
|
)
|
|
) {
|
|
$this->addHtml(Html::tag('div', ['class' => 'icinga-health down'], [
|
|
sprintf(
|
|
t('Icinga DB is outdated, please upgrade to version %s or later.'),
|
|
IcingaHealth::REQUIRED_ICINGADB_VERSION
|
|
)
|
|
]));
|
|
} elseif ($this->data->heartbeat->getTimestamp() > time() - 60) {
|
|
$this->add(Html::tag('div', ['class' => 'icinga-health up'], [
|
|
Html::sprintf(
|
|
t('Icinga 2 is up and running %s', '...since <timespan>'),
|
|
new TimeSince($this->data->icinga2_start_time->getTimestamp())
|
|
)
|
|
]));
|
|
} else {
|
|
$this->add(Html::tag('div', ['class' => 'icinga-health down'], [
|
|
Html::sprintf(
|
|
t('Icinga 2 or Icinga DB is not running %s', '...since <timespan>'),
|
|
new TimeSince($this->data->heartbeat->getTimestamp())
|
|
)
|
|
]));
|
|
}
|
|
|
|
$icingaInfo = Html::tag('div', ['class' => 'icinga-info'], [
|
|
new VerticalKeyValue(
|
|
t('Icinga 2 Version'),
|
|
$this->data->icinga2_version
|
|
),
|
|
new VerticalKeyValue(
|
|
t('Icinga 2 Start Time'),
|
|
new TimeAgo($this->data->icinga2_start_time->getTimestamp())
|
|
),
|
|
new VerticalKeyValue(
|
|
t('Last Heartbeat'),
|
|
new TimeAgo($this->data->heartbeat->getTimestamp())
|
|
),
|
|
new VerticalKeyValue(
|
|
t('Active Icinga 2 Endpoint'),
|
|
$this->data->endpoint->name ?: t('N/A')
|
|
),
|
|
new VerticalKeyValue(
|
|
t('Icinga DB Version'),
|
|
$this->data->icingadb_version ?? t('N/A')
|
|
),
|
|
new VerticalKeyValue(
|
|
t('Active Icinga Web Endpoint'),
|
|
gethostname() ?: t('N/A')
|
|
)
|
|
]);
|
|
$this->add($icingaInfo);
|
|
}
|
|
}
|