summaryrefslogtreecommitdiffstats
path: root/library/Icingadb
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 11:45:00 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 11:45:00 +0000
commitbe4626482ba8761da39746a6ac60d133d3852a0f (patch)
tree45065832c85c4789237e94b3114360eac91d86f0 /library/Icingadb
parentReleasing progress-linux version 1.1.1-1~progress7.99u1. (diff)
downloadicingadb-web-be4626482ba8761da39746a6ac60d133d3852a0f.tar.xz
icingadb-web-be4626482ba8761da39746a6ac60d133d3852a0f.zip
Merging upstream version 1.1.2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'library/Icingadb')
-rw-r--r--library/Icingadb/Command/Object/ObjectsCommand.php13
-rw-r--r--library/Icingadb/Command/Transport/CommandTransport.php4
-rw-r--r--library/Icingadb/Common/CommandActions.php21
-rw-r--r--library/Icingadb/Common/Macros.php13
-rw-r--r--library/Icingadb/Compat/CompatObject.php15
-rw-r--r--library/Icingadb/Compat/UrlMigrator.php13
-rw-r--r--library/Icingadb/Data/CsvResultSet.php79
-rw-r--r--library/Icingadb/Data/CsvResultSetUtils.php106
-rw-r--r--library/Icingadb/Data/JsonResultSet.php74
-rw-r--r--library/Icingadb/Data/JsonResultSetUtils.php132
-rw-r--r--library/Icingadb/Data/VolatileCsvResults.php15
-rw-r--r--library/Icingadb/Data/VolatileJsonResults.php15
-rw-r--r--library/Icingadb/Model/AcknowledgementHistory.php16
-rw-r--r--library/Icingadb/Model/ActionUrl.php5
-rw-r--r--library/Icingadb/Model/Behavior/FlattenedObjectVars.php29
-rw-r--r--library/Icingadb/Model/Checkcommand.php11
-rw-r--r--library/Icingadb/Model/CheckcommandArgument.php17
-rw-r--r--library/Icingadb/Model/CheckcommandCustomvar.php6
-rw-r--r--library/Icingadb/Model/CheckcommandEnvvar.php8
-rw-r--r--library/Icingadb/Model/Comment.php19
-rw-r--r--library/Icingadb/Model/CommentHistory.php18
-rw-r--r--library/Icingadb/Model/Customvar.php7
-rw-r--r--library/Icingadb/Model/CustomvarFlat.php25
-rw-r--r--library/Icingadb/Model/Downtime.php27
-rw-r--r--library/Icingadb/Model/DowntimeHistory.php25
-rw-r--r--library/Icingadb/Model/Endpoint.php9
-rw-r--r--library/Icingadb/Model/Environment.php4
-rw-r--r--library/Icingadb/Model/Eventcommand.php11
-rw-r--r--library/Icingadb/Model/EventcommandArgument.php17
-rw-r--r--library/Icingadb/Model/EventcommandCustomvar.php6
-rw-r--r--library/Icingadb/Model/EventcommandEnvvar.php8
-rw-r--r--library/Icingadb/Model/FlappingHistory.php14
-rw-r--r--library/Icingadb/Model/History.php16
-rw-r--r--library/Icingadb/Model/Host.php40
-rw-r--r--library/Icingadb/Model/HostCustomvar.php6
-rw-r--r--library/Icingadb/Model/Hostgroup.php10
-rw-r--r--library/Icingadb/Model/HostgroupCustomvar.php6
-rw-r--r--library/Icingadb/Model/HostgroupMember.php6
-rw-r--r--library/Icingadb/Model/Hostgroupsummary.php29
-rw-r--r--library/Icingadb/Model/HoststateSummary.php14
-rw-r--r--library/Icingadb/Model/IconImage.php5
-rw-r--r--library/Icingadb/Model/Instance.php16
-rw-r--r--library/Icingadb/Model/NotesUrl.php5
-rw-r--r--library/Icingadb/Model/Notification.php18
-rw-r--r--library/Icingadb/Model/NotificationCustomvar.php6
-rw-r--r--library/Icingadb/Model/NotificationHistory.php16
-rw-r--r--library/Icingadb/Model/NotificationUser.php6
-rw-r--r--library/Icingadb/Model/NotificationUsergroup.php6
-rw-r--r--library/Icingadb/Model/Notificationcommand.php11
-rw-r--r--library/Icingadb/Model/NotificationcommandArgument.php17
-rw-r--r--library/Icingadb/Model/NotificationcommandCustomvar.php6
-rw-r--r--library/Icingadb/Model/NotificationcommandEnvvar.php8
-rw-r--r--library/Icingadb/Model/Service.php38
-rw-r--r--library/Icingadb/Model/ServiceCustomvar.php6
-rw-r--r--library/Icingadb/Model/ServiceState.php5
-rw-r--r--library/Icingadb/Model/Servicegroup.php10
-rw-r--r--library/Icingadb/Model/ServicegroupCustomvar.php6
-rw-r--r--library/Icingadb/Model/ServicegroupMember.php6
-rw-r--r--library/Icingadb/Model/ServicegroupSummary.php23
-rw-r--r--library/Icingadb/Model/ServicestateSummary.php18
-rw-r--r--library/Icingadb/Model/State.php7
-rw-r--r--library/Icingadb/Model/StateHistory.php20
-rw-r--r--library/Icingadb/Model/Timeperiod.php11
-rw-r--r--library/Icingadb/Model/TimeperiodCustomvar.php6
-rw-r--r--library/Icingadb/Model/TimeperiodOverrideExclude.php6
-rw-r--r--library/Icingadb/Model/TimeperiodOverrideInclude.php6
-rw-r--r--library/Icingadb/Model/TimeperiodRange.php7
-rw-r--r--library/Icingadb/Model/User.php16
-rw-r--r--library/Icingadb/Model/UserCustomvar.php6
-rw-r--r--library/Icingadb/Model/Usergroup.php10
-rw-r--r--library/Icingadb/Model/UsergroupCustomvar.php6
-rw-r--r--library/Icingadb/Model/UsergroupMember.php6
-rw-r--r--library/Icingadb/Model/Zone.php11
-rw-r--r--library/Icingadb/ProvidedHook/ApplicationState.php4
-rw-r--r--library/Icingadb/ProvidedHook/RedisHealth.php10
-rw-r--r--library/Icingadb/Setup/RedisPage.php4
-rw-r--r--library/Icingadb/Setup/RedisStep.php4
-rw-r--r--library/Icingadb/Util/PluginOutput.php21
-rw-r--r--library/Icingadb/Web/Control/SearchBar/ObjectSuggestions.php8
-rw-r--r--library/Icingadb/Web/Controller.php21
-rw-r--r--library/Icingadb/Web/Navigation/Action.php2
-rw-r--r--library/Icingadb/Web/Navigation/Renderer/ProblemsBadge.php4
-rw-r--r--library/Icingadb/Widget/Detail/DowntimeCard.php2
-rw-r--r--library/Icingadb/Widget/Detail/EventDetail.php8
-rw-r--r--library/Icingadb/Widget/Detail/MultiselectQuickActions.php1
-rw-r--r--library/Icingadb/Widget/Detail/ObjectDetail.php5
-rw-r--r--library/Icingadb/Widget/HostSummaryDonut.php2
-rw-r--r--library/Icingadb/Widget/ItemList/BaseDowntimeListItem.php6
-rw-r--r--library/Icingadb/Widget/ItemList/HostDetailHeader.php4
-rw-r--r--library/Icingadb/Widget/ItemList/ServiceDetailHeader.php4
-rw-r--r--library/Icingadb/Widget/ItemList/StateList.php2
-rw-r--r--library/Icingadb/Widget/ItemList/StateListItem.php2
-rw-r--r--library/Icingadb/Widget/ItemTable/BaseHostGroupItem.php4
-rw-r--r--library/Icingadb/Widget/ItemTable/BaseServiceGroupItem.php4
-rw-r--r--library/Icingadb/Widget/ItemTable/HostgroupTableRow.php4
-rw-r--r--library/Icingadb/Widget/ItemTable/ServicegroupTableRow.php4
-rw-r--r--library/Icingadb/Widget/ItemTable/StateRowItem.php2
-rw-r--r--library/Icingadb/Widget/ServiceSummaryDonut.php2
98 files changed, 1165 insertions, 228 deletions
diff --git a/library/Icingadb/Command/Object/ObjectsCommand.php b/library/Icingadb/Command/Object/ObjectsCommand.php
index 3de6c83..f1a50d7 100644
--- a/library/Icingadb/Command/Object/ObjectsCommand.php
+++ b/library/Icingadb/Command/Object/ObjectsCommand.php
@@ -5,8 +5,11 @@
namespace Icinga\Module\Icingadb\Command\Object;
use ArrayIterator;
+use Generator;
use Icinga\Module\Icingadb\Command\IcingaCommand;
+use InvalidArgumentException;
use ipl\Orm\Model;
+use LogicException;
use Traversable;
/**
@@ -24,12 +27,18 @@ abstract class ObjectsCommand extends IcingaCommand
/**
* Set the involved objects
*
- * @param Traversable<Model> $objects
+ * @param Traversable<Model> $objects Except generators
*
* @return $this
+ *
+ * @throws InvalidArgumentException If a generator is passed
*/
public function setObjects(Traversable $objects): self
{
+ if ($objects instanceof Generator) {
+ throw new InvalidArgumentException('Generators are not supported');
+ }
+
$this->objects = $objects;
return $this;
@@ -57,7 +66,7 @@ abstract class ObjectsCommand extends IcingaCommand
public function getObjects(): Traversable
{
if ($this->objects === null) {
- throw new \LogicException(
+ throw new LogicException(
'You are accessing an unset property. Please make sure to set it beforehand.'
);
}
diff --git a/library/Icingadb/Command/Transport/CommandTransport.php b/library/Icingadb/Command/Transport/CommandTransport.php
index ea125bc..952cb14 100644
--- a/library/Icingadb/Command/Transport/CommandTransport.php
+++ b/library/Icingadb/Command/Transport/CommandTransport.php
@@ -50,7 +50,7 @@ class CommandTransport implements CommandTransportInterface
/**
* Create a transport from config
*
- * @param ConfigObject $config
+ * @param ConfigObject<string> $config
*
* @return ApiCommandTransport
*
@@ -59,7 +59,7 @@ class CommandTransport implements CommandTransportInterface
public static function createTransport(ConfigObject $config): ApiCommandTransport
{
$config = clone $config;
- switch (strtolower($config->transport)) {
+ switch (strtolower($config->transport ?? '')) {
case ApiCommandTransport::TRANSPORT:
$transport = new ApiCommandTransport();
break;
diff --git a/library/Icingadb/Common/CommandActions.php b/library/Icingadb/Common/CommandActions.php
index 2cd13fe..af7d194 100644
--- a/library/Icingadb/Common/CommandActions.php
+++ b/library/Icingadb/Common/CommandActions.php
@@ -4,6 +4,7 @@
namespace Icinga\Module\Icingadb\Common;
+use Icinga\Exception\Http\HttpNotFoundException;
use Icinga\Module\Icingadb\Forms\Command\CommandForm;
use Icinga\Module\Icingadb\Forms\Command\Object\AcknowledgeProblemForm;
use Icinga\Module\Icingadb\Forms\Command\Object\AddCommentForm;
@@ -26,7 +27,7 @@ use ipl\Web\Url;
*/
trait CommandActions
{
- /** @var Query $commandTargets */
+ /** @var null|Query|array<Model> $commandTargets */
protected $commandTargets;
/** @var Model $commandTargetModel */
@@ -51,14 +52,14 @@ trait CommandActions
/**
* Fetch command targets
*
- * @return Query|Model[]
+ * @return Query|array<Model>
*/
abstract protected function fetchCommandTargets();
/**
* Get command targets
*
- * @return Query|Model[]
+ * @return Query|array<Model>
*/
protected function getCommandTargets()
{
@@ -73,14 +74,19 @@ trait CommandActions
* Get the model of the command targets
*
* @return Model
+ * @throws HttpNotFoundException If no command targets were found
*/
protected function getCommandTargetModel(): Model
{
if (! isset($this->commandTargetModel)) {
$commandTargets = $this->getCommandTargets();
- if (is_array($commandTargets) && !empty($commandTargets)) {
+ if (empty($commandTargets) || count($commandTargets) === 0) {
+ throw new HttpNotFoundException('No command targets found');
+ }
+
+ if (is_array($commandTargets)) {
$this->commandTargetModel = $commandTargets[0];
- } else {
+ } elseif ($commandTargets->count() > 0) {
$this->commandTargetModel = $commandTargets->getModel();
}
}
@@ -139,7 +145,8 @@ trait CommandActions
protected function handleCommandForm($form)
{
$isXhr = $this->getRequest()->isXmlHttpRequest();
- if ($isXhr && $this->getRequest()->isApiRequest()) {
+ $isApi = $this->getRequest()->isApiRequest();
+ if ($isXhr && $isApi) {
// Prevents the framework already, this is just a fail-safe
$this->httpBadRequest('Responding with JSON during a Web request is not supported');
}
@@ -151,7 +158,7 @@ trait CommandActions
$form->setObjects($this->getCommandTargets());
- if ($isXhr) {
+ if (! $isApi || $isXhr) {
$this->handleWebRequest($form);
} else {
$this->handleApiRequest($form);
diff --git a/library/Icingadb/Common/Macros.php b/library/Icingadb/Common/Macros.php
index 4842c27..c7f0e15 100644
--- a/library/Icingadb/Common/Macros.php
+++ b/library/Icingadb/Common/Macros.php
@@ -8,7 +8,7 @@ use Icinga\Application\Logger;
use Icinga\Module\Icingadb\Compat\CompatHost;
use Icinga\Module\Icingadb\Compat\CompatService;
use Icinga\Module\Icingadb\Model\Host;
-use ipl\Orm\Model;
+use Icinga\Module\Icingadb\Model\Service;
use ipl\Orm\Query;
use ipl\Orm\ResultSet;
@@ -20,7 +20,7 @@ trait Macros
* Get the given string with macros being resolved
*
* @param string $input The string in which to look for macros
- * @param Model|CompatService|CompatHost $object The host or service used to resolve the macros
+ * @param Host|Service|CompatService|CompatHost $object The host or service used to resolve the macros
*
* @return string
*/
@@ -42,7 +42,7 @@ trait Macros
* Resolve a macro based on the given object
*
* @param string $macro The macro to resolve
- * @param Model|CompatService|CompatHost $object The host or service used to resolve the macros
+ * @param Host|Service|CompatService|CompatHost $object The host or service used to resolve the macros
*
* @return string
*/
@@ -102,8 +102,13 @@ trait Macros
$value = $object->$macro;
}
} catch (\Exception $e) {
+ $objectName = $object->name;
+ if ($objectType === 'service' && isset($object->host)) {
+ $objectName = $object->host->name . '!' . $objectName;
+ }
+
$value = null;
- Logger::debug('Unable to resolve macro "%s". An error occurred: %s', $macro, $e);
+ Logger::debug('Unable to resolve macro "%s" on object "%s". An error occured: %s', $macro, $objectName, $e);
}
if ($value instanceof Query || $value instanceof ResultSet || is_array($value)) {
diff --git a/library/Icingadb/Compat/CompatObject.php b/library/Icingadb/Compat/CompatObject.php
index 6a30751..1d9657d 100644
--- a/library/Icingadb/Compat/CompatObject.php
+++ b/library/Icingadb/Compat/CompatObject.php
@@ -361,13 +361,14 @@ trait CompatObject
*/
private function getBoolType($value)
{
- switch ($value) {
- case false:
- return 0;
- case true:
- return 1;
- case 'sticky':
- return 2;
+ if ($value === 'sticky') {
+ return 2;
}
+
+ if (is_string($value)) {
+ return null;
+ }
+
+ return (int) $value;
}
}
diff --git a/library/Icingadb/Compat/UrlMigrator.php b/library/Icingadb/Compat/UrlMigrator.php
index 47780be..f6a4a4a 100644
--- a/library/Icingadb/Compat/UrlMigrator.php
+++ b/library/Icingadb/Compat/UrlMigrator.php
@@ -234,9 +234,14 @@ class UrlMigrator
case $exprRule === self::LOWER_EXPR:
$filter->setValue(strtolower($filter->getValue()));
break;
- case is_array($exprRule) && isset($exprRule[$filter->getValue()]):
- $filter->setValue($exprRule[$filter->getValue()]);
- break;
+ case is_array($exprRule):
+ if (isset($exprRule[$filter->getValue()])) {
+ $filter->setValue($exprRule[$filter->getValue()]);
+
+ break;
+ }
+
+ return false;
default:
$filter->setValue($exprRule);
}
@@ -290,6 +295,8 @@ class UrlMigrator
},
'dir' => self::DROP,
'limit' => self::USE_EXPR,
+ 'addFilter' => self::DROP,
+ 'modifyFilter' => self::DROP,
'showCompact' => self::USE_EXPR,
'showFullscreen' => self::USE_EXPR,
'view' => function ($value) {
diff --git a/library/Icingadb/Data/CsvResultSet.php b/library/Icingadb/Data/CsvResultSet.php
index 746a7e4..d65364e 100644
--- a/library/Icingadb/Data/CsvResultSet.php
+++ b/library/Icingadb/Data/CsvResultSet.php
@@ -4,82 +4,9 @@
namespace Icinga\Module\Icingadb\Data;
-use DateTime;
-use DateTimeZone;
-use Icinga\Module\Icingadb\Redis\VolatileStateResults;
-use ipl\Orm\Model;
-use ipl\Orm\Query;
+use ipl\Orm\ResultSet;
-class CsvResultSet extends VolatileStateResults
+class CsvResultSet extends ResultSet
{
- protected $isCacheDisabled = true;
-
- /**
- * @return array<string, ?string>
- */
- public function current(): array
- {
- return $this->extractKeysAndValues(parent::current());
- }
-
- protected function formatValue(string $key, $value): ?string
- {
- if (
- $value
- && (
- $key === 'id'
- || substr($key, -3) === '_id'
- || substr($key, -3) === '.id'
- || substr($key, -9) === '_checksum'
- || substr($key, -4) === '_bin'
- )
- ) {
- $value = bin2hex($value);
- }
-
- if (is_bool($value)) {
- return $value ? 'true' : 'false';
- } elseif (is_string($value)) {
- return '"' . str_replace('"', '""', $value) . '"';
- } elseif (is_array($value)) {
- return '"' . implode(',', $value) . '"';
- } elseif ($value instanceof DateTime) {
- return $value->setTimezone(new DateTimeZone('UTC'))
- ->format('Y-m-d\TH:i:s.vP');
- } else {
- return $value;
- }
- }
-
- protected function extractKeysAndValues(Model $model, string $path = ''): array
- {
- $keysAndValues = [];
- foreach ($model as $key => $value) {
- $keyPath = ($path ? $path . '.' : '') . $key;
- if ($value instanceof Model) {
- $keysAndValues += $this->extractKeysAndValues($value, $keyPath);
- } else {
- $keysAndValues[$keyPath] = $this->formatValue($key, $value);
- }
- }
-
- return $keysAndValues;
- }
-
- public static function stream(Query $query): void
- {
- $query->setResultSetClass(__CLASS__);
-
- foreach ($query as $i => $keysAndValues) {
- if ($i === 0) {
- echo implode(',', array_keys($keysAndValues));
- }
-
- echo "\r\n";
-
- echo implode(',', array_values($keysAndValues));
- }
-
- exit;
- }
+ use CsvResultSetUtils;
}
diff --git a/library/Icingadb/Data/CsvResultSetUtils.php b/library/Icingadb/Data/CsvResultSetUtils.php
new file mode 100644
index 0000000..61995d3
--- /dev/null
+++ b/library/Icingadb/Data/CsvResultSetUtils.php
@@ -0,0 +1,106 @@
+<?php
+
+/* Icinga DB Web | (c) 2024 Icinga GmbH | GPLv2 */
+
+namespace Icinga\Module\Icingadb\Data;
+
+use DateTime;
+use DateTimeZone;
+use Icinga\Module\Icingadb\Model\Host;
+use Icinga\Module\Icingadb\Model\Service;
+use ipl\Orm\Model;
+use ipl\Orm\Query;
+
+trait CsvResultSetUtils
+{
+ /**
+ * @return array<string, ?string>
+ */
+ public function current(): array
+ {
+ return $this->extractKeysAndValues(parent::current());
+ }
+
+ protected function formatValue(string $key, $value): ?string
+ {
+ if (
+ $value
+ && (
+ $key === 'id'
+ || substr($key, -3) === '_id'
+ || substr($key, -3) === '.id'
+ || substr($key, -9) === '_checksum'
+ || substr($key, -4) === '_bin'
+ )
+ ) {
+ $value = bin2hex($value);
+ }
+
+ if (is_bool($value)) {
+ return $value ? 'true' : 'false';
+ } elseif (is_string($value)) {
+ return '"' . str_replace('"', '""', $value) . '"';
+ } elseif (is_array($value)) {
+ return '"' . implode(',', $value) . '"';
+ } elseif ($value instanceof DateTime) {
+ return $value->setTimezone(new DateTimeZone('UTC'))
+ ->format('Y-m-d\TH:i:s.vP');
+ } else {
+ return $value;
+ }
+ }
+
+ protected function extractKeysAndValues(Model $model, string $path = ''): array
+ {
+ $keysAndValues = [];
+ foreach ($model as $key => $value) {
+ $keyPath = ($path ? $path . '.' : '') . $key;
+ if ($value instanceof Model) {
+ $keysAndValues += $this->extractKeysAndValues($value, $keyPath);
+ } else {
+ $keysAndValues[$keyPath] = $this->formatValue($key, $value);
+ }
+ }
+
+ return $keysAndValues;
+ }
+
+ public static function stream(Query $query): void
+ {
+ if ($query->getModel() instanceof Host || $query->getModel() instanceof Service) {
+ $query->setResultSetClass(VolatileCsvResults::class);
+ } else {
+ $query->setResultSetClass(__CLASS__);
+ }
+
+ if ($query->hasLimit()) {
+ // Custom limits should still apply
+ $query->peekAhead(false);
+ $offset = $query->getOffset();
+ } else {
+ $query->limit(1000);
+ $query->peekAhead();
+ $offset = 0;
+ }
+
+ do {
+ $query->offset($offset);
+ $result = $query->execute()->disableCache();
+ foreach ($result as $i => $keysAndValues) {
+ if ($i === 0) {
+ echo implode(',', array_keys($keysAndValues));
+ }
+
+ echo "\r\n";
+
+ echo implode(',', array_values($keysAndValues));
+
+ JsonResultSet::giveMeMoreTime();
+ }
+
+ $offset += 1000;
+ } while ($result->hasMore());
+
+ exit;
+ }
+}
diff --git a/library/Icingadb/Data/JsonResultSet.php b/library/Icingadb/Data/JsonResultSet.php
index 73cd9ef..715437a 100644
--- a/library/Icingadb/Data/JsonResultSet.php
+++ b/library/Icingadb/Data/JsonResultSet.php
@@ -4,77 +4,9 @@
namespace Icinga\Module\Icingadb\Data;
-use DateTime;
-use DateTimeZone;
-use Icinga\Module\Icingadb\Redis\VolatileStateResults;
-use Icinga\Util\Json;
-use ipl\Orm\Model;
-use ipl\Orm\Query;
+use ipl\Orm\ResultSet;
-class JsonResultSet extends VolatileStateResults
+class JsonResultSet extends ResultSet
{
- protected $isCacheDisabled = true;
-
- /**
- * @return array<string, ?string>
- */
- public function current(): array
- {
- return $this->createObject(parent::current());
- }
-
- protected function formatValue(string $key, $value): ?string
- {
- if (
- $value
- && (
- $key === 'id'
- || substr($key, -3) === '_id'
- || substr($key, -3) === '.id'
- || substr($key, -9) === '_checksum'
- || substr($key, -4) === '_bin'
- )
- ) {
- $value = bin2hex($value);
- }
-
- if ($value instanceof DateTime) {
- return $value->setTimezone(new DateTimeZone('UTC'))
- ->format('Y-m-d\TH:i:s.vP');
- }
-
- return $value;
- }
-
- protected function createObject(Model $model): array
- {
- $keysAndValues = [];
- foreach ($model as $key => $value) {
- if ($value instanceof Model) {
- $keysAndValues[$key] = $this->createObject($value);
- } else {
- $keysAndValues[$key] = $this->formatValue($key, $value);
- }
- }
-
- return $keysAndValues;
- }
-
- public static function stream(Query $query): void
- {
- $query->setResultSetClass(__CLASS__);
-
- echo '[';
- foreach ($query as $i => $object) {
- if ($i > 0) {
- echo ",\n";
- }
-
- echo Json::sanitize($object);
- }
-
- echo ']';
-
- exit;
- }
+ use JsonResultSetUtils;
}
diff --git a/library/Icingadb/Data/JsonResultSetUtils.php b/library/Icingadb/Data/JsonResultSetUtils.php
new file mode 100644
index 0000000..422a5b2
--- /dev/null
+++ b/library/Icingadb/Data/JsonResultSetUtils.php
@@ -0,0 +1,132 @@
+<?php
+
+/* Icinga DB Web | (c) 2024 Icinga GmbH | GPLv2 */
+
+namespace Icinga\Module\Icingadb\Data;
+
+use DateTime;
+use DateTimeZone;
+use Icinga\Module\Icingadb\Model\Host;
+use Icinga\Module\Icingadb\Model\Service;
+use Icinga\Util\Json;
+use ipl\Orm\Model;
+use ipl\Orm\Query;
+
+trait JsonResultSetUtils
+{
+ /**
+ * @return array<string, ?string>
+ */
+ public function current(): array
+ {
+ return $this->createObject(parent::current());
+ }
+
+ protected function formatValue(string $key, $value)
+ {
+ if (
+ $value
+ && (
+ $key === 'id'
+ || substr($key, -3) === '_id'
+ || substr($key, -3) === '.id'
+ || substr($key, -9) === '_checksum'
+ || substr($key, -4) === '_bin'
+ )
+ ) {
+ $value = bin2hex($value);
+ }
+
+ if ($value instanceof DateTime) {
+ return $value->setTimezone(new DateTimeZone('UTC'))
+ ->format('Y-m-d\TH:i:s.vP');
+ }
+
+ return $value;
+ }
+
+ protected function createObject(Model $model): array
+ {
+ $keysAndValues = [];
+ foreach ($model as $key => $value) {
+ if ($value instanceof Model) {
+ $keysAndValues[$key] = $this->createObject($value);
+ } else {
+ $keysAndValues[$key] = $this->formatValue($key, $value);
+ }
+ }
+
+ return $keysAndValues;
+ }
+
+ public static function stream(Query $query): void
+ {
+ if ($query->getModel() instanceof Host || $query->getModel() instanceof Service) {
+ $query->setResultSetClass(VolatileJsonResults::class);
+ } else {
+ $query->setResultSetClass(__CLASS__);
+ }
+
+ if ($query->hasLimit()) {
+ // Custom limits should still apply
+ $query->peekAhead(false);
+ $offset = $query->getOffset();
+ } else {
+ $query->limit(1000);
+ $query->peekAhead();
+ $offset = 0;
+ }
+
+ echo '[';
+
+ do {
+ $query->offset($offset);
+ $result = $query->execute()->disableCache();
+ foreach ($result as $i => $object) {
+ if ($i > 0 || $offset !== 0) {
+ echo ",\n";
+ }
+
+ echo Json::sanitize($object);
+
+ self::giveMeMoreTime();
+ }
+
+ $offset += 1000;
+ } while ($result->hasMore());
+
+ echo ']';
+
+ exit;
+ }
+
+ /**
+ * Grant the caller more time to work with
+ *
+ * This resets the execution time before it runs out. The advantage of this, compared with no execution time
+ * limit at all, is that only the caller can bypass the limit. Any other (faulty) code will still be stopped.
+ *
+ * @internal Don't use outside of {@see JsonResultSet::stream()} or {@see CsvResultSet::stream()}
+ *
+ * @return void
+ */
+ public static function giveMeMoreTime()
+ {
+ $spent = getrusage();
+ if ($spent !== false) {
+ $maxExecutionTime = ini_get('max_execution_time');
+ if (! $maxExecutionTime || ! is_numeric($maxExecutionTime)) {
+ $maxExecutionTime = 30;
+ } else {
+ $maxExecutionTime = (int) $maxExecutionTime;
+ }
+
+ if ($maxExecutionTime > 0) {
+ $timeRemaining = $maxExecutionTime - $spent['ru_utime.tv_sec'] % $maxExecutionTime;
+ if ($timeRemaining <= 5) {
+ set_time_limit($maxExecutionTime);
+ }
+ }
+ }
+ }
+}
diff --git a/library/Icingadb/Data/VolatileCsvResults.php b/library/Icingadb/Data/VolatileCsvResults.php
new file mode 100644
index 0000000..7d9f8ab
--- /dev/null
+++ b/library/Icingadb/Data/VolatileCsvResults.php
@@ -0,0 +1,15 @@
+<?php
+
+/* Icinga DB Web | (c) 2024 Icinga GmbH | GPLv2 */
+
+namespace Icinga\Module\Icingadb\Data;
+
+use Icinga\Module\Icingadb\Redis\VolatileStateResults;
+
+/**
+ * @internal This class is supposed to be used by {@see CsvResultSet::stream()} only.
+ */
+final class VolatileCsvResults extends VolatileStateResults
+{
+ use CsvResultSetUtils;
+}
diff --git a/library/Icingadb/Data/VolatileJsonResults.php b/library/Icingadb/Data/VolatileJsonResults.php
new file mode 100644
index 0000000..034fb0e
--- /dev/null
+++ b/library/Icingadb/Data/VolatileJsonResults.php
@@ -0,0 +1,15 @@
+<?php
+
+/* Icinga DB Web | (c) 2024 Icinga GmbH | GPLv2 */
+
+namespace Icinga\Module\Icingadb\Data;
+
+use Icinga\Module\Icingadb\Redis\VolatileStateResults;
+
+/**
+ * @internal This class is supposed to be used by {@see JsonResultSet::stream()} only.
+ */
+final class VolatileJsonResults extends VolatileStateResults
+{
+ use JsonResultSetUtils;
+}
diff --git a/library/Icingadb/Model/AcknowledgementHistory.php b/library/Icingadb/Model/AcknowledgementHistory.php
index 549d2ff..edbcc83 100644
--- a/library/Icingadb/Model/AcknowledgementHistory.php
+++ b/library/Icingadb/Model/AcknowledgementHistory.php
@@ -4,6 +4,7 @@
namespace Icinga\Module\Icingadb\Model;
+use DateTime;
use Icinga\Module\Icingadb\Model\Behavior\BoolCast;
use ipl\Orm\Behavior\Binary;
use ipl\Orm\Behavior\MillisecondTimestamp;
@@ -16,6 +17,21 @@ use ipl\Orm\Relations;
*
* Please note that using this model will fetch history entries for decommissioned services. To avoid this, the query
* needs a `acknowledgement_history.service_id IS NULL OR acknowledgement_history_service.id IS NOT NULL` where.
+ *
+ * @property string $id
+ * @property string $environment_id
+ * @property ?string $endpoint_id
+ * @property string $object_type
+ * @property string $host_id
+ * @property ?string $service_id
+ * @property DateTime $set_time
+ * @property ?DateTime $clear_time
+ * @property ?string $author
+ * @property ?string $cleared_by
+ * @property ?string $comment
+ * @property ?DateTime $expire_time
+ * @property ?bool $is_sticky
+ * @property ?bool $is_persistent
*/
class AcknowledgementHistory extends Model
{
diff --git a/library/Icingadb/Model/ActionUrl.php b/library/Icingadb/Model/ActionUrl.php
index e0b092e..928ce35 100644
--- a/library/Icingadb/Model/ActionUrl.php
+++ b/library/Icingadb/Model/ActionUrl.php
@@ -10,6 +10,11 @@ use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;
+/**
+ * @property string $id
+ * @property string[] $action_url
+ * @property string $environment_id
+ */
class ActionUrl extends Model
{
public function getTableName()
diff --git a/library/Icingadb/Model/Behavior/FlattenedObjectVars.php b/library/Icingadb/Model/Behavior/FlattenedObjectVars.php
index b1c308a..8b110e0 100644
--- a/library/Icingadb/Model/Behavior/FlattenedObjectVars.php
+++ b/library/Icingadb/Model/Behavior/FlattenedObjectVars.php
@@ -32,11 +32,30 @@ class FlattenedObjectVars implements RewriteColumnBehavior, QueryAwareBehavior
$column = $condition->metaData()->get('columnName');
if ($column !== null) {
$relation = substr($relation, 0, -5) . 'customvar_flat.';
- $nameFilter = Filter::like($relation . 'flatname', $column);
- $class = get_class($condition);
- $valueFilter = new $class($relation . 'flatvalue', $condition->getValue());
-
- return Filter::all($nameFilter, $valueFilter);
+ $condition->metaData()
+ ->set('requiresTransformation', true)
+ ->set('columnPath', $relation . $column)
+ ->set('relationPath', substr($relation, 0, -1));
+
+ // The ORM's FilterProcessor only optimizes filter conditions that are in the same level (chain).
+ // Previously, this behavior transformed a single condition to an ALL chain and hence the semantics
+ // of the level changed, since the FilterProcessor interpreted the conditions separately from there on.
+ // To not change the semantics of the condition it is required to delay the transformation of the condition
+ // until the subquery is created. Though, since this is about custom variables, and such can contain dots,
+ // the FilterProcessor then continues traversing the parts of the column's path, which then would include
+ // the dot-separated parts of the custom variable name. To prevent this, we have to signal that what we
+ // return a replacement here, that should be used as-is and not processed further.
+ $condition->metaData()->set('forceResolved', true);
+
+ // But to make it even worse: If we do that, (not transforming the condition) the FilterProcessor sees
+ // multiple conditions as targeting different columns, as it doesn't know that the *columns* are in fact
+ // custom variables. It then attempts to combine the conditions with an AND, which is not possible, since
+ // they refer to the same columns (flatname and flatvalue) after being transformed. So we have to make
+ // the condition refer to a different column, which is totally irrelevant, but since it's always the same
+ // column, the FilterProcessor won't attempt to combine the conditions. The literal icing on the cake.
+ $condition->setColumn('always_the_same_but_totally_irrelevant');
+
+ return $condition;
}
}
diff --git a/library/Icingadb/Model/Checkcommand.php b/library/Icingadb/Model/Checkcommand.php
index 400a24b..7f55c0d 100644
--- a/library/Icingadb/Model/Checkcommand.php
+++ b/library/Icingadb/Model/Checkcommand.php
@@ -10,6 +10,17 @@ use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;
+/**
+ * @property string $id
+ * @property ?string $zone_id
+ * @property string $environment_id
+ * @property string $name_checksum
+ * @property string $properties_checksum
+ * @property string $name
+ * @property string $name_ci
+ * @property string $command
+ * @property int $timeout
+ */
class Checkcommand extends Model
{
public function getTableName()
diff --git a/library/Icingadb/Model/CheckcommandArgument.php b/library/Icingadb/Model/CheckcommandArgument.php
index 3fb4ad5..155f6da 100644
--- a/library/Icingadb/Model/CheckcommandArgument.php
+++ b/library/Icingadb/Model/CheckcommandArgument.php
@@ -9,6 +9,22 @@ use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;
+/**
+ * @property string $id
+ * @property string $checkcommand_id
+ * @property string $argument_key
+ * @property string $environment_id
+ * @property string $properties_checksum
+ * @property ?string $argument_value
+ * @property ?int $argument_order
+ * @property ?string $description
+ * @property ?string $argument_key_override
+ * @property string $repeat_key
+ * @property string $required
+ * @property ?string $set_if
+ * @property ?string $separator
+ * @property string $skip_key
+ */
class CheckcommandArgument extends Model
{
public function getTableName()
@@ -35,6 +51,7 @@ class CheckcommandArgument extends Model
'repeat_key',
'required',
'set_if',
+ 'separator',
'skip_key'
];
}
diff --git a/library/Icingadb/Model/CheckcommandCustomvar.php b/library/Icingadb/Model/CheckcommandCustomvar.php
index 0a834b5..5382689 100644
--- a/library/Icingadb/Model/CheckcommandCustomvar.php
+++ b/library/Icingadb/Model/CheckcommandCustomvar.php
@@ -9,6 +9,12 @@ use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;
+/**
+ * @property string $id
+ * @property string $checkcommand_id
+ * @property string $customvar_id
+ * @property string $environment_id
+ */
class CheckcommandCustomvar extends Model
{
public function getTableName()
diff --git a/library/Icingadb/Model/CheckcommandEnvvar.php b/library/Icingadb/Model/CheckcommandEnvvar.php
index 517a45f..05cdeed 100644
--- a/library/Icingadb/Model/CheckcommandEnvvar.php
+++ b/library/Icingadb/Model/CheckcommandEnvvar.php
@@ -9,6 +9,14 @@ use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;
+/**
+ * @property string $id
+ * @property string $checkcommand_id
+ * @property string $envvar_key
+ * @property string $environment_id
+ * @property string $properties_checksum
+ * @property string $envvar_value
+ */
class CheckcommandEnvvar extends Model
{
public function getTableName()
diff --git a/library/Icingadb/Model/Comment.php b/library/Icingadb/Model/Comment.php
index bcdd5e0..bdfcaf0 100644
--- a/library/Icingadb/Model/Comment.php
+++ b/library/Icingadb/Model/Comment.php
@@ -4,6 +4,7 @@
namespace Icinga\Module\Icingadb\Model;
+use DateTime;
use Icinga\Module\Icingadb\Model\Behavior\BoolCast;
use Icinga\Module\Icingadb\Model\Behavior\ReRoute;
use ipl\Orm\Behavior\Binary;
@@ -12,6 +13,24 @@ use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;
+/**
+ * @property string $id
+ * @property string $environment_id
+ * @property string $object_type
+ * @property string $host_id
+ * @property ?string $service_id
+ * @property string $name_checksum
+ * @property string $properties_checksum
+ * @property string $name
+ * @property string $author
+ * @property string $text
+ * @property string $entry_type
+ * @property DateTime $entry_time
+ * @property bool $is_persistent
+ * @property bool $is_sticky
+ * @property ?DateTime $expire_time
+ * @property ?string $zone_id
+ */
class Comment extends Model
{
public function getTableName()
diff --git a/library/Icingadb/Model/CommentHistory.php b/library/Icingadb/Model/CommentHistory.php
index 5f03e68..1cb02e3 100644
--- a/library/Icingadb/Model/CommentHistory.php
+++ b/library/Icingadb/Model/CommentHistory.php
@@ -4,6 +4,7 @@
namespace Icinga\Module\Icingadb\Model;
+use DateTime;
use Icinga\Module\Icingadb\Model\Behavior\BoolCast;
use ipl\Orm\Behavior\Binary;
use ipl\Orm\Behavior\MillisecondTimestamp;
@@ -16,6 +17,23 @@ use ipl\Orm\Relations;
*
* Please note that using this model will fetch history entries for decommissioned services. To avoid this,
* the query needs a `comment_history.service_id IS NULL OR comment_history_service.id IS NOT NULL` where.
+ *
+ * @property string $comment_id
+ * @property string $environment_id
+ * @property ?string $endpoint_id
+ * @property string $object_type
+ * @property string $host_id
+ * @property ?string $service_id
+ * @property DateTime $entry_time
+ * @property string $author
+ * @property ?string $removed_by
+ * @property string $comment
+ * @property string $entry_type
+ * @property bool $is_persistent
+ * @property bool $is_sticky
+ * @property ?DateTime $expire_time
+ * @property ?DateTime $remove_time
+ * @property bool $has_been_removed
*/
class CommentHistory extends Model
{
diff --git a/library/Icingadb/Model/Customvar.php b/library/Icingadb/Model/Customvar.php
index e043229..70fb709 100644
--- a/library/Icingadb/Model/Customvar.php
+++ b/library/Icingadb/Model/Customvar.php
@@ -9,6 +9,13 @@ use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;
+/**
+ * @property string $id
+ * @property string $environment_id
+ * @property string $name_checksum
+ * @property string $name
+ * @property string $value
+ */
class Customvar extends Model
{
public function getTableName()
diff --git a/library/Icingadb/Model/CustomvarFlat.php b/library/Icingadb/Model/CustomvarFlat.php
index 99d8aca..e7a0459 100644
--- a/library/Icingadb/Model/CustomvarFlat.php
+++ b/library/Icingadb/Model/CustomvarFlat.php
@@ -6,11 +6,22 @@ namespace Icinga\Module\Icingadb\Model;
use ipl\Orm\Behavior\Binary;
use ipl\Orm\Behaviors;
+use ipl\Orm\Contract\RewriteFilterBehavior;
use ipl\Orm\Model;
use ipl\Orm\Query;
use ipl\Orm\Relations;
+use ipl\Stdlib\Filter;
+use ipl\Stdlib\Filter\Condition;
use Traversable;
+/**
+ * @property string $id
+ * @property string $environment_id
+ * @property string $customvar_id
+ * @property string $flatname_checksum
+ * @property string $flatname
+ * @property ?string $flatvalue
+ */
class CustomvarFlat extends Model
{
public function getTableName()
@@ -42,6 +53,20 @@ class CustomvarFlat extends Model
'customvar_id',
'flatname_checksum'
]));
+ $behaviors->add(new class implements RewriteFilterBehavior {
+ public function rewriteCondition(Condition $condition, $relation = null)
+ {
+ if ($condition->metaData()->has('requiresTransformation')) {
+ /** @var string $columnName */
+ $columnName = $condition->metaData()->get('columnName');
+ $nameFilter = Filter::like($relation . 'flatname', $columnName);
+ $class = get_class($condition);
+ $valueFilter = new $class($relation . 'flatvalue', $condition->getValue());
+
+ return Filter::all($nameFilter, $valueFilter);
+ }
+ }
+ });
}
public function createRelations(Relations $relations)
diff --git a/library/Icingadb/Model/Downtime.php b/library/Icingadb/Model/Downtime.php
index 7f600e9..b2ba617 100644
--- a/library/Icingadb/Model/Downtime.php
+++ b/library/Icingadb/Model/Downtime.php
@@ -4,6 +4,7 @@
namespace Icinga\Module\Icingadb\Model;
+use DateTime;
use Icinga\Module\Icingadb\Model\Behavior\BoolCast;
use Icinga\Module\Icingadb\Model\Behavior\ReRoute;
use ipl\Orm\Behavior\Binary;
@@ -12,6 +13,32 @@ use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;
+/**
+ * @property string $id
+ * @property string $environment_id
+ * @property ?string $triggered_by_id
+ * @property ?string $parent_id
+ * @property string $object_type
+ * @property string $host_id
+ * @property ?string $service_id
+ * @property string $name_checksum
+ * @property string $properties_checksum
+ * @property string $name
+ * @property string $author
+ * @property string $comment
+ * @property DateTime $entry_time
+ * @property DateTime $scheduled_start_time
+ * @property DateTime $scheduled_end_time
+ * @property int $scheduled_duration
+ * @property bool $is_flexible
+ * @property int $flexible_duration
+ * @property bool $is_in_effect
+ * @property ?DateTime $start_time
+ * @property ?DateTime $end_time
+ * @property int $duration
+ * @property ?string $scheduled_by
+ * @property ?string $zone_id
+ */
class Downtime extends Model
{
public function getTableName()
diff --git a/library/Icingadb/Model/DowntimeHistory.php b/library/Icingadb/Model/DowntimeHistory.php
index 7ba992f..b69a097 100644
--- a/library/Icingadb/Model/DowntimeHistory.php
+++ b/library/Icingadb/Model/DowntimeHistory.php
@@ -4,6 +4,7 @@
namespace Icinga\Module\Icingadb\Model;
+use DateTime;
use Icinga\Module\Icingadb\Model\Behavior\BoolCast;
use ipl\Orm\Behavior\Binary;
use ipl\Orm\Behavior\MillisecondTimestamp;
@@ -16,6 +17,29 @@ use ipl\Orm\Relations;
*
* Please note that using this model will fetch history entries for decommissioned services. To avoid this,
* the query needs a `downtime_history.service_id IS NULL OR downtime_history_service.id IS NOT NULL` where.
+ *
+ * @property string $id
+ * @property string $environment_id
+ * @property ?string $endpoint_id
+ * @property ?string $triggered_by_id
+ * @property ?string $parent_id
+ * @property string $object_type
+ * @property string $host_id
+ * @property ?string $service_id
+ * @property DateTime $entry_time
+ * @property string $author
+ * @property ?string $cancelled_by
+ * @property string $comment
+ * @property bool $is_flexible
+ * @property int $flexible_duration
+ * @property DateTime $scheduled_start_time
+ * @property DateTime $scheduled_end_time
+ * @property DateTime $start_time
+ * @property DateTime $end_time
+ * @property ?string $scheduled_by
+ * @property bool $has_been_cancelled
+ * @property DateTime $trigger_time
+ * @property ?DateTime $cancel_time
*/
class DowntimeHistory extends Model
{
@@ -49,6 +73,7 @@ class DowntimeHistory extends Model
'scheduled_end_time',
'start_time',
'end_time',
+ 'scheduled_by',
'has_been_cancelled',
'trigger_time',
'cancel_time'
diff --git a/library/Icingadb/Model/Endpoint.php b/library/Icingadb/Model/Endpoint.php
index 257001b..f8a9b8c 100644
--- a/library/Icingadb/Model/Endpoint.php
+++ b/library/Icingadb/Model/Endpoint.php
@@ -9,6 +9,15 @@ use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;
+/**
+ * @property string $id
+ * @property string $environment_id
+ * @property string $name_checksum
+ * @property string $properties_checksum
+ * @property string $name
+ * @property string $name_ci
+ * @property string $zone_id
+ */
class Endpoint extends Model
{
public function getTableName()
diff --git a/library/Icingadb/Model/Environment.php b/library/Icingadb/Model/Environment.php
index 919ca1c..cd82082 100644
--- a/library/Icingadb/Model/Environment.php
+++ b/library/Icingadb/Model/Environment.php
@@ -9,6 +9,10 @@ use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;
+/**
+ * @property string $id
+ * @property string $name
+ */
class Environment extends Model
{
public function getTableName()
diff --git a/library/Icingadb/Model/Eventcommand.php b/library/Icingadb/Model/Eventcommand.php
index ad18e22..68c1c06 100644
--- a/library/Icingadb/Model/Eventcommand.php
+++ b/library/Icingadb/Model/Eventcommand.php
@@ -10,6 +10,17 @@ use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;
+/**
+ * @property string $id
+ * @property ?string $zone_id
+ * @property string $environment_id
+ * @property string $name_checksum
+ * @property string $properties_checksum
+ * @property string $name
+ * @property string $name_ci
+ * @property string $command
+ * @property int $timeout
+ */
class Eventcommand extends Model
{
public function getTableName()
diff --git a/library/Icingadb/Model/EventcommandArgument.php b/library/Icingadb/Model/EventcommandArgument.php
index 485e5d3..1f60ac2 100644
--- a/library/Icingadb/Model/EventcommandArgument.php
+++ b/library/Icingadb/Model/EventcommandArgument.php
@@ -9,6 +9,22 @@ use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;
+/**
+ * @property string $id
+ * @property string $eventcommand_id
+ * @property string $argument_key
+ * @property string $environment_id
+ * @property string $properties_checksum
+ * @property ?string $argument_value
+ * @property ?int $argument_order
+ * @property ?string $description
+ * @property ?string $argument_key_override
+ * @property string $repeat_key
+ * @property string $required
+ * @property ?string $set_if
+ * @property ?string $separator
+ * @property string $skip_key
+ */
class EventcommandArgument extends Model
{
public function getTableName()
@@ -35,6 +51,7 @@ class EventcommandArgument extends Model
'repeat_key',
'required',
'set_if',
+ 'separator',
'skip_key'
];
}
diff --git a/library/Icingadb/Model/EventcommandCustomvar.php b/library/Icingadb/Model/EventcommandCustomvar.php
index 3d1fa48..0da010b 100644
--- a/library/Icingadb/Model/EventcommandCustomvar.php
+++ b/library/Icingadb/Model/EventcommandCustomvar.php
@@ -9,6 +9,12 @@ use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;
+/**
+ * @property string $id
+ * @property string $eventcommand_id
+ * @property string $customvar_id
+ * @property string $environment_id
+ */
class EventcommandCustomvar extends Model
{
public function getTableName()
diff --git a/library/Icingadb/Model/EventcommandEnvvar.php b/library/Icingadb/Model/EventcommandEnvvar.php
index 3883bef..2eb8acf 100644
--- a/library/Icingadb/Model/EventcommandEnvvar.php
+++ b/library/Icingadb/Model/EventcommandEnvvar.php
@@ -9,6 +9,14 @@ use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;
+/**
+ * @property string $id
+ * @property string $eventcommand_id
+ * @property string $envvar_key
+ * @property string $environment_id
+ * @property string $properties_checksum
+ * @property string $envvar_value
+ */
class EventcommandEnvvar extends Model
{
public function getTableName()
diff --git a/library/Icingadb/Model/FlappingHistory.php b/library/Icingadb/Model/FlappingHistory.php
index 69711eb..e060ca6 100644
--- a/library/Icingadb/Model/FlappingHistory.php
+++ b/library/Icingadb/Model/FlappingHistory.php
@@ -4,6 +4,7 @@
namespace Icinga\Module\Icingadb\Model;
+use DateTime;
use ipl\Orm\Behavior\Binary;
use ipl\Orm\Behavior\MillisecondTimestamp;
use ipl\Orm\Behaviors;
@@ -15,6 +16,19 @@ use ipl\Orm\Relations;
*
* Please note that using this model will fetch history entries for decommissioned services. To avoid this,
* the query needs a `flapping_history.service_id IS NULL OR flapping_history_service.id IS NOT NULL` where.
+ *
+ * @property string $id
+ * @property string $environment_id
+ * @property ?string $endpoint_id
+ * @property string $object_type
+ * @property string $host_id
+ * @property ?string $service_id
+ * @property DateTime $start_time
+ * @property ?DateTime $end_time
+ * @property ?float $percent_state_change_start
+ * @property ?float $percent_state_change_end
+ * @property float $flapping_threshold_low
+ * @property float $flapping_threshold_high
*/
class FlappingHistory extends Model
{
diff --git a/library/Icingadb/Model/History.php b/library/Icingadb/Model/History.php
index a34b3bd..3643a22 100644
--- a/library/Icingadb/Model/History.php
+++ b/library/Icingadb/Model/History.php
@@ -4,6 +4,7 @@
namespace Icinga\Module\Icingadb\Model;
+use DateTime;
use Icinga\Module\Icingadb\Model\Behavior\ReRoute;
use ipl\Orm\Behavior\Binary;
use ipl\Orm\Behavior\MillisecondTimestamp;
@@ -16,6 +17,21 @@ use ipl\Orm\Relations;
*
* Please note that using this model will fetch history entries for decommissioned services. To avoid
* this, the query needs a `history.service_id IS NULL OR history_service.id IS NOT NULL` where.
+ *
+ * @property string $id
+ * @property string $environment_id
+ * @property ?string $endpoint_id
+ * @property string $object_type
+ * @property string $host_id
+ * @property ?string $service_id
+ * @property ?string $comment_history_id
+ * @property ?string $downtime_history_id
+ * @property ?string $flapping_history_id
+ * @property ?string $notification_history_id
+ * @property ?string $acknowledgement_history_id
+ * @property ?string $state_history_id
+ * @property string $event_type
+ * @property DateTime $event_time
*/
class History extends Model
{
diff --git a/library/Icingadb/Model/Host.php b/library/Icingadb/Model/Host.php
index e1296c8..c697983 100644
--- a/library/Icingadb/Model/Host.php
+++ b/library/Icingadb/Model/Host.php
@@ -16,6 +16,46 @@ use ipl\Orm\ResultSet;
/**
* Host model.
+ *
+ * @property string $id
+ * @property string $environment_id
+ * @property string $name_checksum
+ * @property string $properties_checksum
+ * @property string $name
+ * @property string $name_ci
+ * @property string $display_name
+ * @property string $address
+ * @property string $address6
+ * @property ?string $address_bin
+ * @property ?string $address6_bin
+ * @property string $checkcommand_name
+ * @property string $checkcommand_id
+ * @property int $max_check_attempts
+ * @property string $check_timeperiod_name
+ * @property ?string $check_timeperiod_id
+ * @property ?int $check_timeout
+ * @property int $check_interval
+ * @property int $check_retry_interval
+ * @property bool $active_checks_enabled
+ * @property bool $passive_checks_enabled
+ * @property bool $event_handler_enabled
+ * @property bool $notifications_enabled
+ * @property bool $flapping_enabled
+ * @property float $flapping_threshold_low
+ * @property float $flapping_threshold_high
+ * @property bool $perfdata_enabled
+ * @property string $eventcommand_name
+ * @property ?string $eventcommand_id
+ * @property bool $is_volatile
+ * @property ?string $action_url_id
+ * @property ?string $notes_url_id
+ * @property string $notes
+ * @property ?string $icon_image_id
+ * @property string $icon_image_alt
+ * @property string $zone_name
+ * @property ?string $zone_id
+ * @property string $command_endpoint_name
+ * @property ?string $command_endpoint_id
*/
class Host extends Model
{
diff --git a/library/Icingadb/Model/HostCustomvar.php b/library/Icingadb/Model/HostCustomvar.php
index 9f7df26..bda786b 100644
--- a/library/Icingadb/Model/HostCustomvar.php
+++ b/library/Icingadb/Model/HostCustomvar.php
@@ -9,6 +9,12 @@ use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;
+/**
+ * @property string $id
+ * @property string $host_id
+ * @property string $customvar_id
+ * @property string $environment_id
+ */
class HostCustomvar extends Model
{
public function getTableName()
diff --git a/library/Icingadb/Model/Hostgroup.php b/library/Icingadb/Model/Hostgroup.php
index 97930fa..1ff6f0f 100644
--- a/library/Icingadb/Model/Hostgroup.php
+++ b/library/Icingadb/Model/Hostgroup.php
@@ -10,6 +10,16 @@ use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;
+/**
+ * @property string $id
+ * @property string $environment_id
+ * @property string $name_checksum
+ * @property string $properties_checksum
+ * @property string $name
+ * @property string $name_ci
+ * @property string $display_name
+ * @property ?string $zone_id
+ */
class Hostgroup extends Model
{
public function getTableName()
diff --git a/library/Icingadb/Model/HostgroupCustomvar.php b/library/Icingadb/Model/HostgroupCustomvar.php
index 41272d1..d3dd09b 100644
--- a/library/Icingadb/Model/HostgroupCustomvar.php
+++ b/library/Icingadb/Model/HostgroupCustomvar.php
@@ -9,6 +9,12 @@ use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;
+/**
+ * @property string $id
+ * @property string $hostgroup_id
+ * @property string $customvar_id
+ * @property string $environment_id
+ */
class HostgroupCustomvar extends Model
{
public function getTableName()
diff --git a/library/Icingadb/Model/HostgroupMember.php b/library/Icingadb/Model/HostgroupMember.php
index 3660e71..e03db73 100644
--- a/library/Icingadb/Model/HostgroupMember.php
+++ b/library/Icingadb/Model/HostgroupMember.php
@@ -9,6 +9,12 @@ use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;
+/**
+ * @property string $id
+ * @property string $host_id
+ * @property string $hostgroup_id
+ * @property string $environment_id
+ */
class HostgroupMember extends Model
{
public function getTableName()
diff --git a/library/Icingadb/Model/Hostgroupsummary.php b/library/Icingadb/Model/Hostgroupsummary.php
index a9295bb..172413e 100644
--- a/library/Icingadb/Model/Hostgroupsummary.php
+++ b/library/Icingadb/Model/Hostgroupsummary.php
@@ -13,6 +13,27 @@ use ipl\Sql\Connection;
use ipl\Sql\Expression;
use ipl\Sql\Select;
+/**
+ * @property string $id
+ * @property string $display_name
+ * @property string $name_ci
+ * @property string $name
+ * @property int $hosts_down_handled
+ * @property int $hosts_down_unhandled
+ * @property int $hosts_pending
+ * @property int $hosts_total
+ * @property int $hosts_up
+ * @property int $hosts_severity
+ * @property int $services_critical_handled
+ * @property int $services_critical_unhandled
+ * @property int $services_ok
+ * @property int $services_pending
+ * @property int $services_total
+ * @property int $services_unknown_handled
+ * @property int $services_unknown_unhandled
+ * @property int $services_warning_handled
+ * @property int $services_warning_unhandled
+ */
class Hostgroupsummary extends UnionModel
{
public static function on(Connection $db)
@@ -55,6 +76,8 @@ class Hostgroupsummary extends UnionModel
public function getColumns()
{
return [
+ 'name' => 'hostgroup_name',
+ 'name_ci' => 'hostgroup_name_ci',
'display_name' => 'hostgroup_display_name',
'hosts_down_handled' => new Expression(
'SUM(CASE WHEN host_state = 1'
@@ -74,7 +97,6 @@ class Hostgroupsummary extends UnionModel
'SUM(CASE WHEN host_state = 0 THEN 1 ELSE 0 END)'
),
'hosts_severity' => new Expression('MAX(host_severity)'),
- 'name' => 'hostgroup_name',
'services_critical_handled' => new Expression(
'SUM(CASE WHEN service_state = 2'
. ' AND (service_handled = \'y\' OR service_reachable = \'n\') THEN 1 ELSE 0 END)'
@@ -113,7 +135,7 @@ class Hostgroupsummary extends UnionModel
public function getSearchColumns()
{
- return ['display_name'];
+ return ['name_ci', 'display_name'];
}
public function getDefaultSort()
@@ -133,6 +155,7 @@ class Hostgroupsummary extends UnionModel
[
'hostgroup_id' => 'hostgroup.id',
'hostgroup_name' => 'hostgroup.name',
+ 'hostgroup_name_ci' => 'hostgroup.name_ci',
'hostgroup_display_name' => 'hostgroup.display_name',
'host_id' => 'host.id',
'host_state' => 'state.soft_state',
@@ -154,6 +177,7 @@ class Hostgroupsummary extends UnionModel
[
'hostgroup_id' => 'hostgroup.id',
'hostgroup_name' => 'hostgroup.name',
+ 'hostgroup_name_ci' => 'hostgroup.name_ci',
'hostgroup_display_name' => 'hostgroup.display_name',
'host_id' => new Expression('NULL'),
'host_state' => new Expression('NULL'),
@@ -172,6 +196,7 @@ class Hostgroupsummary extends UnionModel
[
'hostgroup_id' => 'hostgroup.id',
'hostgroup_name' => 'hostgroup.name',
+ 'hostgroup_name_ci' => 'hostgroup.name_ci',
'hostgroup_display_name' => 'hostgroup.display_name',
'host_id' => new Expression('NULL'),
'host_state' => new Expression('NULL'),
diff --git a/library/Icingadb/Model/HoststateSummary.php b/library/Icingadb/Model/HoststateSummary.php
index 93268f3..3184c28 100644
--- a/library/Icingadb/Model/HoststateSummary.php
+++ b/library/Icingadb/Model/HoststateSummary.php
@@ -7,6 +7,20 @@ namespace Icinga\Module\Icingadb\Model;
use ipl\Sql\Connection;
use ipl\Sql\Expression;
+/**
+ * @property int $hosts_acknowledged
+ * @property int $hosts_active_checks_enabled
+ * @property int $hosts_passive_checks_enabled
+ * @property int $hosts_down_handled
+ * @property int $hosts_down_unhandled
+ * @property int $hosts_event_handler_enabled
+ * @property int $hosts_flapping_enabled
+ * @property int $hosts_notifications_enabled
+ * @property int $hosts_pending
+ * @property int $hosts_problems_unacknowledged
+ * @property int $hosts_total
+ * @property int $hosts_up
+ */
class HoststateSummary extends Host
{
public function getSummaryColumns()
diff --git a/library/Icingadb/Model/IconImage.php b/library/Icingadb/Model/IconImage.php
index 212234a..58f0be6 100644
--- a/library/Icingadb/Model/IconImage.php
+++ b/library/Icingadb/Model/IconImage.php
@@ -9,6 +9,11 @@ use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;
+/**
+ * @property string $id
+ * @property string $icon_image
+ * @property string $environment_id
+ */
class IconImage extends Model
{
public function getTableName()
diff --git a/library/Icingadb/Model/Instance.php b/library/Icingadb/Model/Instance.php
index 73db565..716d23d 100644
--- a/library/Icingadb/Model/Instance.php
+++ b/library/Icingadb/Model/Instance.php
@@ -4,6 +4,7 @@
namespace Icinga\Module\Icingadb\Model;
+use DateTime;
use Icinga\Module\Icingadb\Model\Behavior\BoolCast;
use ipl\Orm\Behavior\Binary;
use ipl\Orm\Behavior\MillisecondTimestamp;
@@ -11,6 +12,21 @@ use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;
+/**
+ * @property string $id
+ * @property string $environment_id
+ * @property ?string $endpoint_id
+ * @property DateTime $heartbeat
+ * @property bool $responsible
+ * @property bool $icinga2_active_host_checks_enabled
+ * @property bool $icinga2_active_service_checks_enabled
+ * @property bool $icinga2_event_handlers_enabled
+ * @property bool $icinga2_flap_detection_enabled
+ * @property bool $icinga2_notifications_enabled
+ * @property bool $icinga2_performance_data_enabled
+ * @property DateTime $icinga2_start_time
+ * @property string $icinga2_version
+ */
class Instance extends Model
{
public function getTableName()
diff --git a/library/Icingadb/Model/NotesUrl.php b/library/Icingadb/Model/NotesUrl.php
index 5865c52..138eaba 100644
--- a/library/Icingadb/Model/NotesUrl.php
+++ b/library/Icingadb/Model/NotesUrl.php
@@ -10,6 +10,11 @@ use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;
+/**
+ * @property string $id
+ * @property string[] $notes_url
+ * @property string $environment_id
+ */
class NotesUrl extends Model
{
public function getTableName()
diff --git a/library/Icingadb/Model/Notification.php b/library/Icingadb/Model/Notification.php
index 8d42301..4c15d2e 100644
--- a/library/Icingadb/Model/Notification.php
+++ b/library/Icingadb/Model/Notification.php
@@ -11,6 +11,24 @@ use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;
+/**
+ * @property string $id
+ * @property string $environment_id
+ * @property string $name_checksum
+ * @property string $properties_checksum
+ * @property string $name
+ * @property string $name_ci
+ * @property string $host_id
+ * @property ?string $service_id
+ * @property string $notificationcommand_id
+ * @property ?int $times_begin
+ * @property ?int $times_end
+ * @property int $notification_interval
+ * @property ?string $timeperiod_id
+ * @property string[] $states
+ * @property string[] $types
+ * @property ?string $zone_id
+ */
class Notification extends Model
{
public function getTableName()
diff --git a/library/Icingadb/Model/NotificationCustomvar.php b/library/Icingadb/Model/NotificationCustomvar.php
index 620ae5c..655d1de 100644
--- a/library/Icingadb/Model/NotificationCustomvar.php
+++ b/library/Icingadb/Model/NotificationCustomvar.php
@@ -9,6 +9,12 @@ use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;
+/**
+ * @property string $id
+ * @property string $notification_id
+ * @property string $customvar_id
+ * @property string $environment_id
+ */
class NotificationCustomvar extends Model
{
public function getTableName()
diff --git a/library/Icingadb/Model/NotificationHistory.php b/library/Icingadb/Model/NotificationHistory.php
index c635dbb..08903ad 100644
--- a/library/Icingadb/Model/NotificationHistory.php
+++ b/library/Icingadb/Model/NotificationHistory.php
@@ -4,6 +4,7 @@
namespace Icinga\Module\Icingadb\Model;
+use DateTime;
use Icinga\Module\Icingadb\Model\Behavior\ReRoute;
use ipl\Orm\Behavior\Binary;
use ipl\Orm\Behavior\MillisecondTimestamp;
@@ -16,6 +17,21 @@ use ipl\Orm\Relations;
*
* Please note that using this model will fetch history entries for decommissioned services. To avoid this, the
* query needs a `notification_history.service_id IS NULL OR notification_history_service.id IS NOT NULL` where.
+ *
+ * @property string $id
+ * @property string $environment_id
+ * @property ?string $endpoint_id
+ * @property string $object_type
+ * @property string $host_id
+ * @property ?string $service_id
+ * @property string $notification_id
+ * @property string $type
+ * @property DateTime $send_time
+ * @property int $state
+ * @property int $previous_hard_state
+ * @property string $author
+ * @property string $text
+ * @property int $users_notified
*/
class NotificationHistory extends Model
{
diff --git a/library/Icingadb/Model/NotificationUser.php b/library/Icingadb/Model/NotificationUser.php
index ab23ad4..efb779c 100644
--- a/library/Icingadb/Model/NotificationUser.php
+++ b/library/Icingadb/Model/NotificationUser.php
@@ -9,6 +9,12 @@ use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;
+/**
+ * @property string $id
+ * @property string $notification_id
+ * @property string $user_id
+ * @property string $environment_id
+ */
class NotificationUser extends Model
{
public function getTableName()
diff --git a/library/Icingadb/Model/NotificationUsergroup.php b/library/Icingadb/Model/NotificationUsergroup.php
index bd60fae..a503337 100644
--- a/library/Icingadb/Model/NotificationUsergroup.php
+++ b/library/Icingadb/Model/NotificationUsergroup.php
@@ -9,6 +9,12 @@ use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;
+/**
+ * @property string $id
+ * @property string $notification_id
+ * @property string $usergroup_id
+ * @property string $environment_id
+ */
class NotificationUsergroup extends Model
{
public function getTableName()
diff --git a/library/Icingadb/Model/Notificationcommand.php b/library/Icingadb/Model/Notificationcommand.php
index 6ee2a21..c170aae 100644
--- a/library/Icingadb/Model/Notificationcommand.php
+++ b/library/Icingadb/Model/Notificationcommand.php
@@ -10,6 +10,17 @@ use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;
+/**
+ * @property string $id
+ * @property ?string $zone_id
+ * @property string $environment_id
+ * @property string $name_checksum
+ * @property string $properties_checksum
+ * @property string $name
+ * @property string $name_ci
+ * @property string $command
+ * @property int $timeout
+ */
class Notificationcommand extends Model
{
public function getTableName()
diff --git a/library/Icingadb/Model/NotificationcommandArgument.php b/library/Icingadb/Model/NotificationcommandArgument.php
index e855022..e3a5e67 100644
--- a/library/Icingadb/Model/NotificationcommandArgument.php
+++ b/library/Icingadb/Model/NotificationcommandArgument.php
@@ -9,6 +9,22 @@ use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;
+/**
+ * @property string $id
+ * @property string $notificationcommand_id
+ * @property string $argument_key
+ * @property string $environment_id
+ * @property string $properties_checksum
+ * @property ?string $argument_value
+ * @property ?int $argument_order
+ * @property ?string $description
+ * @property ?string $argument_key_override
+ * @property string $repeat_key
+ * @property string $required
+ * @property ?string $set_if
+ * @property ?string $separator
+ * @property string $skip_key
+ */
class NotificationcommandArgument extends Model
{
public function getTableName()
@@ -35,6 +51,7 @@ class NotificationcommandArgument extends Model
'repeat_key',
'required',
'set_if',
+ 'separator',
'skip_key'
];
}
diff --git a/library/Icingadb/Model/NotificationcommandCustomvar.php b/library/Icingadb/Model/NotificationcommandCustomvar.php
index bd103f7..f541927 100644
--- a/library/Icingadb/Model/NotificationcommandCustomvar.php
+++ b/library/Icingadb/Model/NotificationcommandCustomvar.php
@@ -9,6 +9,12 @@ use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;
+/**
+ * @property string $id
+ * @property string $notificationcommand_id
+ * @property string $customvar_id
+ * @property string $environment_id
+ */
class NotificationcommandCustomvar extends Model
{
public function getTableName()
diff --git a/library/Icingadb/Model/NotificationcommandEnvvar.php b/library/Icingadb/Model/NotificationcommandEnvvar.php
index 09f77b0..0180be6 100644
--- a/library/Icingadb/Model/NotificationcommandEnvvar.php
+++ b/library/Icingadb/Model/NotificationcommandEnvvar.php
@@ -9,6 +9,14 @@ use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;
+/**
+ * @property string $id
+ * @property string $notificationcommand_id
+ * @property string $envvar_key
+ * @property string $environment_id
+ * @property string $properties_checksum
+ * @property string $envvar_value
+ */
class NotificationcommandEnvvar extends Model
{
public function getTableName()
diff --git a/library/Icingadb/Model/Service.php b/library/Icingadb/Model/Service.php
index c57b6ba..1d97b96 100644
--- a/library/Icingadb/Model/Service.php
+++ b/library/Icingadb/Model/Service.php
@@ -14,6 +14,44 @@ use ipl\Orm\Model;
use ipl\Orm\Relations;
use ipl\Orm\ResultSet;
+/**
+ * @property string $id
+ * @property string $environment_id
+ * @property string $name_checksum
+ * @property string $properties_checksum
+ * @property string $host_id
+ * @property string $name
+ * @property string $name_ci
+ * @property string $display_name
+ * @property string $checkcommand_name
+ * @property string $checkcommand_id
+ * @property int $max_check_attempts
+ * @property string $check_timeperiod_name
+ * @property ?string $check_timeperiod_id
+ * @property ?int $check_timeout
+ * @property int $check_interval
+ * @property int $check_retry_interval
+ * @property bool $active_checks_enabled
+ * @property bool $passive_checks_enabled
+ * @property bool $event_handler_enabled
+ * @property bool $notifications_enabled
+ * @property bool $flapping_enabled
+ * @property float $flapping_threshold_low
+ * @property float $flapping_threshold_high
+ * @property bool $perfdata_enabled
+ * @property string $eventcommand_name
+ * @property ?string $eventcommand_id
+ * @property bool $is_volatile
+ * @property ?string $action_url_id
+ * @property ?string $notes_url_id
+ * @property string $notes
+ * @property ?string $icon_image_id
+ * @property string $icon_image_alt
+ * @property string $zone_name
+ * @property ?string $zone_id
+ * @property string $command_endpoint_name
+ * @property ?string $command_endpoint_id
+ */
class Service extends Model
{
use Auth;
diff --git a/library/Icingadb/Model/ServiceCustomvar.php b/library/Icingadb/Model/ServiceCustomvar.php
index 07ee84c..ba462f1 100644
--- a/library/Icingadb/Model/ServiceCustomvar.php
+++ b/library/Icingadb/Model/ServiceCustomvar.php
@@ -9,6 +9,12 @@ use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;
+/**
+ * @property string $id
+ * @property string $service_id
+ * @property string $customvar_id
+ * @property string $environment_id
+ */
class ServiceCustomvar extends Model
{
public function getTableName()
diff --git a/library/Icingadb/Model/ServiceState.php b/library/Icingadb/Model/ServiceState.php
index c5daa08..1d7dc31 100644
--- a/library/Icingadb/Model/ServiceState.php
+++ b/library/Icingadb/Model/ServiceState.php
@@ -7,6 +7,11 @@ namespace Icinga\Module\Icingadb\Model;
use Icinga\Module\Icingadb\Common\ServiceStates;
use ipl\Orm\Relations;
+/**
+ * Service state model.
+ *
+ * @property string $service_id
+ */
class ServiceState extends State
{
public function getTableName()
diff --git a/library/Icingadb/Model/Servicegroup.php b/library/Icingadb/Model/Servicegroup.php
index 0da92fb..2e4b847 100644
--- a/library/Icingadb/Model/Servicegroup.php
+++ b/library/Icingadb/Model/Servicegroup.php
@@ -10,6 +10,16 @@ use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;
+/**
+ * @property string $id
+ * @property string $environment_id
+ * @property string $name_checksum
+ * @property string $properties_checksum
+ * @property string $name
+ * @property string $name_ci
+ * @property string $display_name
+ * @property ?string $zone_id
+ */
class Servicegroup extends Model
{
public function getTableName()
diff --git a/library/Icingadb/Model/ServicegroupCustomvar.php b/library/Icingadb/Model/ServicegroupCustomvar.php
index 23e536b..01479ee 100644
--- a/library/Icingadb/Model/ServicegroupCustomvar.php
+++ b/library/Icingadb/Model/ServicegroupCustomvar.php
@@ -9,6 +9,12 @@ use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;
+/**
+ * @property string $id
+ * @property string $servicegroup_id
+ * @property string $customvar_id
+ * @property string $environment_id
+ */
class ServicegroupCustomvar extends Model
{
public function getTableName()
diff --git a/library/Icingadb/Model/ServicegroupMember.php b/library/Icingadb/Model/ServicegroupMember.php
index 5da537a..80a5054 100644
--- a/library/Icingadb/Model/ServicegroupMember.php
+++ b/library/Icingadb/Model/ServicegroupMember.php
@@ -9,6 +9,12 @@ use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;
+/**
+ * @property string $id
+ * @property string $service_id
+ * @property string $servicegroup_id
+ * @property string $environment_id
+ */
class ServicegroupMember extends Model
{
public function getTableName()
diff --git a/library/Icingadb/Model/ServicegroupSummary.php b/library/Icingadb/Model/ServicegroupSummary.php
index 89a0953..c15ef07 100644
--- a/library/Icingadb/Model/ServicegroupSummary.php
+++ b/library/Icingadb/Model/ServicegroupSummary.php
@@ -13,6 +13,22 @@ use ipl\Sql\Connection;
use ipl\Sql\Expression;
use ipl\Sql\Select;
+/**
+ * @property string $id
+ * @property string $display_name
+ * @property string $name_ci
+ * @property string $name
+ * @property int $services_critical_handled
+ * @property int $services_critical_unhandled
+ * @property int $services_ok
+ * @property int $services_pending
+ * @property int $services_total
+ * @property int $services_unknown_handled
+ * @property int $services_unknown_unhandled
+ * @property int $services_warning_handled
+ * @property int $services_warning_unhandled
+ * @property int $services_severity
+ */
class ServicegroupSummary extends UnionModel
{
public static function on(Connection $db)
@@ -55,8 +71,9 @@ class ServicegroupSummary extends UnionModel
public function getColumns()
{
return [
- 'display_name' => 'servicegroup_display_name',
'name' => 'servicegroup_name',
+ 'name_ci' => 'servicegroup_name_ci',
+ 'display_name' => 'servicegroup_display_name',
'services_critical_handled' => new Expression(
'SUM(CASE WHEN service_state = 2'
. ' AND (service_handled = \'y\' OR service_reachable = \'n\') THEN 1 ELSE 0 END)'
@@ -96,7 +113,7 @@ class ServicegroupSummary extends UnionModel
public function getSearchColumns()
{
- return ['display_name'];
+ return ['name_ci', 'display_name'];
}
public function getDefaultSort()
@@ -116,6 +133,7 @@ class ServicegroupSummary extends UnionModel
[
'servicegroup_id' => 'servicegroup.id',
'servicegroup_name' => 'servicegroup.name',
+ 'servicegroup_name_ci' => 'servicegroup.name_ci',
'servicegroup_display_name' => 'servicegroup.display_name',
'service_id' => 'service.id',
'service_state' => 'state.soft_state',
@@ -130,6 +148,7 @@ class ServicegroupSummary extends UnionModel
[
'servicegroup_id' => 'servicegroup.id',
'servicegroup_name' => 'servicegroup.name',
+ 'servicegroup_name_ci' => 'servicegroup.name_ci',
'servicegroup_display_name' => 'servicegroup.display_name',
'service_id' => new Expression('NULL'),
'service_state' => new Expression('NULL'),
diff --git a/library/Icingadb/Model/ServicestateSummary.php b/library/Icingadb/Model/ServicestateSummary.php
index b1364f7..daf3bec 100644
--- a/library/Icingadb/Model/ServicestateSummary.php
+++ b/library/Icingadb/Model/ServicestateSummary.php
@@ -7,6 +7,24 @@ namespace Icinga\Module\Icingadb\Model;
use ipl\Sql\Connection;
use ipl\Sql\Expression;
+/**
+ * @property int $services_acknowledged
+ * @property int $services_active_checks_enabled
+ * @property int $services_passive_checks_enabled
+ * @property int $services_critical_handled
+ * @property int $services_critical_unhandled
+ * @property int $services_event_handler_enabled
+ * @property int $services_flapping_enabled
+ * @property int $services_notifications_enabled
+ * @property int $services_ok
+ * @property int $services_pending
+ * @property int $services_problems_unacknowledged
+ * @property int $services_total
+ * @property int $services_unknown_handled
+ * @property int $services_unknown_unhandled
+ * @property int $services_warning_handled
+ * @property int $services_warning_unhandled
+ */
class ServicestateSummary extends Service
{
public function getSummaryColumns()
diff --git a/library/Icingadb/Model/State.php b/library/Icingadb/Model/State.php
index 2d242a8..4529c9b 100644
--- a/library/Icingadb/Model/State.php
+++ b/library/Icingadb/Model/State.php
@@ -16,6 +16,7 @@ use ipl\Web\Widget\Icon;
/**
* Base class for the {@link HostState} and {@link ServiceState} models providing common columns.
*
+ * @property string $id
* @property string $environment_id The environment id
* @property string $state_type The state type (hard or soft)
* @property int $soft_state The current soft state code (0 = OK, 1 = WARNING, 2 = CRITICAL, 3 = UNKNOWN)
@@ -44,9 +45,9 @@ use ipl\Web\Widget\Icon;
* @property ?string $check_source The name of the node that executes the check
* @property ?string $scheduling_source The name of the node that schedules the check
* @property ?DateTime $last_update The time when the node was last updated
- * @property ?DateTime $last_state_change The time when the node last got a status change
- * @property ?DateTime $next_check The time when the node will execute the next check
- * @property ?DateTime $next_update The time when the next check of the node is expected to end
+ * @property DateTime $last_state_change The time when the node last got a status change
+ * @property DateTime $next_check The time when the node will execute the next check
+ * @property DateTime $next_update The time when the next check of the node is expected to end
*/
abstract class State extends Model
{
diff --git a/library/Icingadb/Model/StateHistory.php b/library/Icingadb/Model/StateHistory.php
index 9d80cb2..35d0115 100644
--- a/library/Icingadb/Model/StateHistory.php
+++ b/library/Icingadb/Model/StateHistory.php
@@ -4,6 +4,7 @@
namespace Icinga\Module\Icingadb\Model;
+use DateTime;
use ipl\Orm\Behavior\Binary;
use ipl\Orm\Behavior\MillisecondTimestamp;
use ipl\Orm\Behaviors;
@@ -15,6 +16,25 @@ use ipl\Orm\Relations;
*
* Please note that using this model will fetch history entries for decommissioned services. To avoid this,
* the query needs a `state_history.service_id IS NULL OR state_history_service.id IS NOT NULL` where.
+ *
+ * @property string $id
+ * @property string $environment_id
+ * @property ?string $endpoint_id
+ * @property string $object_type
+ * @property string $host_id
+ * @property ?string $service_id
+ * @property DateTime $event_time
+ * @property string $state_type
+ * @property int $soft_state
+ * @property int $hard_state
+ * @property int $check_attempt
+ * @property int $previous_soft_state
+ * @property int $previous_hard_state
+ * @property ?string $output
+ * @property ?string $long_output
+ * @property int $max_check_attempts
+ * @property ?string $check_source
+ * @property ?string $scheduling_source
*/
class StateHistory extends Model
{
diff --git a/library/Icingadb/Model/Timeperiod.php b/library/Icingadb/Model/Timeperiod.php
index 26dd722..e166410 100644
--- a/library/Icingadb/Model/Timeperiod.php
+++ b/library/Icingadb/Model/Timeperiod.php
@@ -10,6 +10,17 @@ use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;
+/**
+ * @property string $id
+ * @property string $environment_id
+ * @property string $name_checksum
+ * @property string $properties_checksum
+ * @property string $name
+ * @property string $name_ci
+ * @property string $display_name
+ * @property string $prefer_includes
+ * @property ?string $zone_id
+ */
class Timeperiod extends Model
{
public function getTableName()
diff --git a/library/Icingadb/Model/TimeperiodCustomvar.php b/library/Icingadb/Model/TimeperiodCustomvar.php
index 614a312..2931068 100644
--- a/library/Icingadb/Model/TimeperiodCustomvar.php
+++ b/library/Icingadb/Model/TimeperiodCustomvar.php
@@ -9,6 +9,12 @@ use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;
+/**
+ * @property string $id
+ * @property string $timeperiod_id
+ * @property string $customvar_id
+ * @property string $environment_id
+ */
class TimeperiodCustomvar extends Model
{
public function getTableName()
diff --git a/library/Icingadb/Model/TimeperiodOverrideExclude.php b/library/Icingadb/Model/TimeperiodOverrideExclude.php
index c33df77..2764dfb 100644
--- a/library/Icingadb/Model/TimeperiodOverrideExclude.php
+++ b/library/Icingadb/Model/TimeperiodOverrideExclude.php
@@ -9,6 +9,12 @@ use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;
+/**
+ * @property string $id
+ * @property string $timeperiod_id
+ * @property string $override_id
+ * @property string $environment_id
+ */
class TimeperiodOverrideExclude extends Model
{
public function getTableName()
diff --git a/library/Icingadb/Model/TimeperiodOverrideInclude.php b/library/Icingadb/Model/TimeperiodOverrideInclude.php
index 5418596..b92e9ee 100644
--- a/library/Icingadb/Model/TimeperiodOverrideInclude.php
+++ b/library/Icingadb/Model/TimeperiodOverrideInclude.php
@@ -9,6 +9,12 @@ use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;
+/**
+ * @property string $id
+ * @property string $timeperiod_id
+ * @property string $override_id
+ * @property string $environment_id
+ */
class TimeperiodOverrideInclude extends Model
{
public function getTableName()
diff --git a/library/Icingadb/Model/TimeperiodRange.php b/library/Icingadb/Model/TimeperiodRange.php
index 62e87f8..af94573 100644
--- a/library/Icingadb/Model/TimeperiodRange.php
+++ b/library/Icingadb/Model/TimeperiodRange.php
@@ -9,6 +9,13 @@ use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;
+/**
+ * @property string $id
+ * @property string $timeperiod_id
+ * @property string $range_key
+ * @property string $environment_id
+ * @property string $range_value
+ */
class TimeperiodRange extends Model
{
public function getTableName()
diff --git a/library/Icingadb/Model/User.php b/library/Icingadb/Model/User.php
index 91d0d71..1218de9 100644
--- a/library/Icingadb/Model/User.php
+++ b/library/Icingadb/Model/User.php
@@ -11,6 +11,22 @@ use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;
+/**
+ * @property string $id
+ * @property string $environment_id
+ * @property string $name_checksum
+ * @property string $properties_checksum
+ * @property string $name
+ * @property string $name_ci
+ * @property string $display_name
+ * @property string $email
+ * @property string $pager
+ * @property string $notifications_enabled
+ * @property ?string $timeperiod_id
+ * @property string[] $states
+ * @property string[] $types
+ * @property ?string $zone_id
+ */
class User extends Model
{
public function getTableName()
diff --git a/library/Icingadb/Model/UserCustomvar.php b/library/Icingadb/Model/UserCustomvar.php
index a702b68..883858b 100644
--- a/library/Icingadb/Model/UserCustomvar.php
+++ b/library/Icingadb/Model/UserCustomvar.php
@@ -9,6 +9,12 @@ use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;
+/**
+ * @property string $id
+ * @property string $customvar_id
+ * @property string $user_id
+ * @property string $environment_id
+ */
class UserCustomvar extends Model
{
public function getTableName()
diff --git a/library/Icingadb/Model/Usergroup.php b/library/Icingadb/Model/Usergroup.php
index 34b0647..281c9ce 100644
--- a/library/Icingadb/Model/Usergroup.php
+++ b/library/Icingadb/Model/Usergroup.php
@@ -10,6 +10,16 @@ use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;
+/**
+ * @property string $id
+ * @property string $environment_id
+ * @property string $name_checksum
+ * @property string $properties_checksum
+ * @property string $name
+ * @property string $name_ci
+ * @property string $display_name
+ * @property ?string $zone_id
+ */
class Usergroup extends Model
{
public function getTableName()
diff --git a/library/Icingadb/Model/UsergroupCustomvar.php b/library/Icingadb/Model/UsergroupCustomvar.php
index ab97273..cdc79bc 100644
--- a/library/Icingadb/Model/UsergroupCustomvar.php
+++ b/library/Icingadb/Model/UsergroupCustomvar.php
@@ -9,6 +9,12 @@ use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;
+/**
+ * @property string $id
+ * @property string $usergroup_id
+ * @property string $customvar_id
+ * @property string $environment_id
+ */
class UsergroupCustomvar extends Model
{
public function getTableName()
diff --git a/library/Icingadb/Model/UsergroupMember.php b/library/Icingadb/Model/UsergroupMember.php
index 7c61d67..7abd5c8 100644
--- a/library/Icingadb/Model/UsergroupMember.php
+++ b/library/Icingadb/Model/UsergroupMember.php
@@ -9,6 +9,12 @@ use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;
+/**
+ * @property string $id
+ * @property string $usergroup_id
+ * @property string $user_id
+ * @property string $environment_id
+ */
class UsergroupMember extends Model
{
public function getTableName()
diff --git a/library/Icingadb/Model/Zone.php b/library/Icingadb/Model/Zone.php
index aaf3bbf..04d63ce 100644
--- a/library/Icingadb/Model/Zone.php
+++ b/library/Icingadb/Model/Zone.php
@@ -9,6 +9,17 @@ use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;
+/**
+ * @property string $id
+ * @property string $environment_id
+ * @property string $name_checksum
+ * @property string $properties_checksum
+ * @property string $name
+ * @property string $name_ci
+ * @property string $is_global
+ * @property ?string $parent_id
+ * @property int $depth
+ */
class Zone extends Model
{
public function getTableName()
diff --git a/library/Icingadb/ProvidedHook/ApplicationState.php b/library/Icingadb/ProvidedHook/ApplicationState.php
index 8c7b008..208a97a 100644
--- a/library/Icingadb/ProvidedHook/ApplicationState.php
+++ b/library/Icingadb/ProvidedHook/ApplicationState.php
@@ -31,7 +31,7 @@ class ApplicationState extends ApplicationStateHook
$this->addError(
'icingadb/redis-down',
$downSince,
- sprintf(t("Can't connect to Icinga Redis: %s"), $e->getMessage())
+ sprintf(t("Can't connect to Redis: %s"), $e->getMessage())
);
return;
@@ -89,7 +89,7 @@ class ApplicationState extends ApplicationStateHook
$this->addError(
'icingadb/redis-outdated',
$lastIcingaHeartbeat,
- t('Icinga Redis is outdated. Make sure Icinga 2 is running and connected to Redis.')
+ t('Redis is outdated. Make sure Icinga 2 is running and connected to Redis.')
);
break;
diff --git a/library/Icingadb/ProvidedHook/RedisHealth.php b/library/Icingadb/ProvidedHook/RedisHealth.php
index 1471aba..681edac 100644
--- a/library/Icingadb/ProvidedHook/RedisHealth.php
+++ b/library/Icingadb/ProvidedHook/RedisHealth.php
@@ -16,7 +16,7 @@ class RedisHealth extends HealthHook
public function getName(): string
{
- return 'Icinga Redis';
+ return 'Redis';
}
public function checkHealth()
@@ -32,7 +32,7 @@ class RedisHealth extends HealthHook
if ($instance === null) {
$this->setState(self::STATE_UNKNOWN);
$this->setMessage(t(
- 'Can\'t check Icinga Redis: Icinga DB is not running or not writing into the database'
+ 'Can\'t check Redis: Icinga DB is not running or not writing into the database'
. ' (make sure the icinga feature "icingadb" is enabled)'
));
@@ -42,14 +42,14 @@ class RedisHealth extends HealthHook
$outdatedDbHeartbeat = $instance->heartbeat->getTimestamp() < time() - 60;
if (! $outdatedDbHeartbeat || $instance->heartbeat->getTimestamp() <= $lastIcingaHeartbeat) {
$this->setState(self::STATE_OK);
- $this->setMessage(t('Icinga Redis available and up to date.'));
+ $this->setMessage(t('Redis available and up to date.'));
} elseif ($instance->heartbeat->getTimestamp() > $lastIcingaHeartbeat) {
$this->setState(self::STATE_CRITICAL);
- $this->setMessage(t('Icinga Redis outdated. Make sure Icinga 2 is running and connected to Redis.'));
+ $this->setMessage(t('Redis outdated. Make sure Icinga 2 is running and connected to Redis.'));
}
} catch (Exception $e) {
$this->setState(self::STATE_CRITICAL);
- $this->setMessage(sprintf(t("Can't connect to Icinga Redis: %s"), $e->getMessage()));
+ $this->setMessage(sprintf(t("Can't connect to Redis: %s"), $e->getMessage()));
}
}
}
diff --git a/library/Icingadb/Setup/RedisPage.php b/library/Icingadb/Setup/RedisPage.php
index 3c0a741..69b04bb 100644
--- a/library/Icingadb/Setup/RedisPage.php
+++ b/library/Icingadb/Setup/RedisPage.php
@@ -12,9 +12,9 @@ class RedisPage extends Form
public function init()
{
$this->setName('setup_icingadb_redis');
- $this->setTitle(t('Icinga DB Redis'));
+ $this->setTitle(t('Redis'));
$this->addDescription(t(
- 'Please fill out the connection details to access the Icinga DB Redis.'
+ 'Please fill out the connection details to access the Redis server.'
));
$this->setValidatePartial(true);
}
diff --git a/library/Icingadb/Setup/RedisStep.php b/library/Icingadb/Setup/RedisStep.php
index 97e50e0..7f2baab 100644
--- a/library/Icingadb/Setup/RedisStep.php
+++ b/library/Icingadb/Setup/RedisStep.php
@@ -107,7 +107,7 @@ class RedisStep extends Step
$topic = new HtmlElement('div', Attributes::create(['class' => 'topic']));
$topic->addHtml(new HtmlElement('p', null, Text::create(mt(
'icingadb',
- 'The Icinga DB Redis will be accessed using the following connection details:'
+ 'Redis will be accessed using the following connection details:'
))));
$primaryOptions = new Table();
@@ -178,7 +178,7 @@ class RedisStep extends Step
$summary = new HtmlDocument();
$summary->addHtml(
- new HtmlElement('h2', null, Text::create(mt('icingadb', 'Icinga DB Redis'))),
+ new HtmlElement('h2', null, Text::create(mt('icingadb', 'Redis'))),
$topic
);
diff --git a/library/Icingadb/Util/PluginOutput.php b/library/Icingadb/Util/PluginOutput.php
index 71d08b1..03055a9 100644
--- a/library/Icingadb/Util/PluginOutput.php
+++ b/library/Icingadb/Util/PluginOutput.php
@@ -64,6 +64,9 @@ class PluginOutput extends HtmlString
/** @var bool Whether the output contains HTML */
protected $isHtml;
+ /** @var int The maximum amount of characters to process */
+ protected $characterLimit = 1000;
+
/** @var bool Whether output will be enriched */
protected $enrichOutput = true;
@@ -94,6 +97,20 @@ class PluginOutput extends HtmlString
}
/**
+ * Set the maximum amount of characters to process
+ *
+ * @param int $limit
+ *
+ * @return $this
+ */
+ public function setCharacterLimit(int $limit): self
+ {
+ $this->characterLimit = $limit;
+
+ return $this;
+ }
+
+ /**
* Set whether the output should be enriched
*
* @param bool $state
@@ -185,6 +202,10 @@ class PluginOutput extends HtmlString
$output = $this->processHtml($output);
}
+ if ($this->characterLimit) {
+ $output = substr($output, 0, $this->characterLimit);
+ }
+
$this->renderedOutput = $output;
return $output;
diff --git a/library/Icingadb/Web/Control/SearchBar/ObjectSuggestions.php b/library/Icingadb/Web/Control/SearchBar/ObjectSuggestions.php
index b89e729..31b6483 100644
--- a/library/Icingadb/Web/Control/SearchBar/ObjectSuggestions.php
+++ b/library/Icingadb/Web/Control/SearchBar/ObjectSuggestions.php
@@ -121,8 +121,12 @@ class ObjectSuggestions extends Suggestions
$quickFilter = Filter::any();
foreach ($model->getSearchColumns() as $column) {
- $where = Filter::like($resolver->qualifyColumn($column, $model->getTableName()), $searchTerm);
- $where->metaData()->set('columnLabel', $resolver->getColumnDefinition($where->getColumn())->getLabel());
+ if (strpos($column, '.') === false) {
+ $column = $resolver->qualifyColumn($column, $model->getTableName());
+ }
+
+ $where = Filter::like($column, $searchTerm);
+ $where->metaData()->set('columnLabel', $resolver->getColumnDefinition($column)->getLabel());
$quickFilter->add($where);
}
diff --git a/library/Icingadb/Web/Controller.php b/library/Icingadb/Web/Controller.php
index ad9f07e..ffa711a 100644
--- a/library/Icingadb/Web/Controller.php
+++ b/library/Icingadb/Web/Controller.php
@@ -307,10 +307,11 @@ class Controller extends CompatController
{
$columns = array_merge($query->getModel()->getSearchColumns(), $additionalColumns);
foreach ($columns as $column) {
- $filter->add(Filter::like(
- $query->getResolver()->qualifyColumn($column, $query->getModel()->getTableName()),
- "*$search*"
- ));
+ if (strpos($column, '.') === false) {
+ $column = $query->getResolver()->qualifyColumn($column, $query->getModel()->getTableName());
+ }
+
+ $filter->add(Filter::like($column, "*$search*"));
}
}
@@ -367,7 +368,10 @@ class Controller extends CompatController
// No matter the format, a limit should only apply if set
if ($this->format !== null) {
- $query->limit(Url::fromRequest()->getParam('limit'));
+ if (! Url::fromRequest()->hasParam('limit')) {
+ $query->limit(null)
+ ->offset(null);
+ }
}
if ($this->format === 'json' || $this->format === 'csv') {
@@ -512,7 +516,12 @@ class Controller extends CompatController
{
parent::preDispatch();
- $this->format = $this->params->shift('format');
+ $this->format = $this->params->shift(
+ 'format',
+ $this->getRequest()->isApiRequest()
+ ? 'json'
+ : null
+ );
}
public function postDispatch()
diff --git a/library/Icingadb/Web/Navigation/Action.php b/library/Icingadb/Web/Navigation/Action.php
index d02f933..449e9d2 100644
--- a/library/Icingadb/Web/Navigation/Action.php
+++ b/library/Icingadb/Web/Navigation/Action.php
@@ -113,7 +113,7 @@ class Action extends NavigationItem
public function getUrl(): ?\Icinga\Web\Url
{
$url = parent::getUrl();
- if (! $this->resolved && $url === null && $this->rawUrl !== null) {
+ if (! $this->resolved && $url === null && $this->rawUrl !== null && $this->object !== null) {
$this->setUrl(Url::fromPath($this->expandMacros($this->rawUrl, $this->getObject())));
$this->resolved = true;
return parent::getUrl();
diff --git a/library/Icingadb/Web/Navigation/Renderer/ProblemsBadge.php b/library/Icingadb/Web/Navigation/Renderer/ProblemsBadge.php
index 658fa1c..5e0f555 100644
--- a/library/Icingadb/Web/Navigation/Renderer/ProblemsBadge.php
+++ b/library/Icingadb/Web/Navigation/Renderer/ProblemsBadge.php
@@ -52,7 +52,7 @@ abstract class ProblemsBadge extends NavigationItemRenderer
return $this->count;
}
- $this->count = $this->round($count);
+ $this->count = $count;
$this->setState(static::STATE_CRITICAL);
}
@@ -146,7 +146,7 @@ abstract class ProblemsBadge extends NavigationItemRenderer
$count = $this->getProblemsCount();
if ($count) {
- return (new StateBadge($count, $this->getState()))
+ return (new StateBadge($this->round($count), $this->getState()))
->addAttributes(['class' => 'badge', 'title' => $this->getTitle()]);
}
diff --git a/library/Icingadb/Widget/Detail/DowntimeCard.php b/library/Icingadb/Widget/Detail/DowntimeCard.php
index 81f59da..8184479 100644
--- a/library/Icingadb/Widget/Detail/DowntimeCard.php
+++ b/library/Icingadb/Widget/Detail/DowntimeCard.php
@@ -35,7 +35,7 @@ class DowntimeCard extends BaseHtmlElement
$this->start = $this->downtime->scheduled_start_time->getTimestamp();
$this->end = $this->downtime->scheduled_end_time->getTimestamp();
- if ($this->downtime->end_time > $this->downtime->scheduled_end_time) {
+ if ($this->downtime->end_time && $this->downtime->end_time > $this->downtime->scheduled_end_time) {
$this->duration = $this->downtime->end_time->getTimestamp() - $this->start;
} else {
$this->duration = $this->end - $this->start;
diff --git a/library/Icingadb/Widget/Detail/EventDetail.php b/library/Icingadb/Widget/Detail/EventDetail.php
index 181c9ae..aaf7608 100644
--- a/library/Icingadb/Widget/Detail/EventDetail.php
+++ b/library/Icingadb/Widget/Detail/EventDetail.php
@@ -366,7 +366,7 @@ class EventDetail extends BaseHtmlElement
}
$cancelInfo = [];
- if ($downtime->has_been_cancelled) {
+ if ($downtime->has_been_cancelled && $downtime->cancel_time) {
$cancelInfo = [
new HtmlElement('h2', null, Text::create(t('This downtime has been cancelled'))),
new HorizontalKeyValue(
@@ -430,7 +430,7 @@ class EventDetail extends BaseHtmlElement
}
$removedInfo = [];
- if ($comment->has_been_removed) {
+ if ($comment->has_been_removed && $comment->remove_time) {
$removedInfo[] = new HtmlElement('h2', null, Text::create(t('This comment has been removed')));
if ($comment->removed_by) {
$removedInfo[] = new HorizontalKeyValue(
@@ -487,7 +487,7 @@ class EventDetail extends BaseHtmlElement
$flapping->percent_state_change_start,
$flapping->flapping_threshold_high
));
- } else {
+ } elseif ($flapping->end_time !== null) {
$eventInfo[] = new HorizontalKeyValue(
t('Ended on'),
DateFormatter::formatDateTime($flapping->end_time->getTimestamp())
@@ -567,7 +567,7 @@ class EventDetail extends BaseHtmlElement
if ($acknowledgement->cleared_by) {
$eventInfo[] = new HorizontalKeyValue(
t('Cleared by'),
- [new Icon('user', $acknowledgement->cleared_by)]
+ [new Icon('user'), $acknowledgement->cleared_by]
);
} else {
$expired = false;
diff --git a/library/Icingadb/Widget/Detail/MultiselectQuickActions.php b/library/Icingadb/Widget/Detail/MultiselectQuickActions.php
index f398d80..b80ec9d 100644
--- a/library/Icingadb/Widget/Detail/MultiselectQuickActions.php
+++ b/library/Icingadb/Widget/Detail/MultiselectQuickActions.php
@@ -67,6 +67,7 @@ class MultiselectQuickActions extends BaseHtmlElement
) {
$removeAckForm = (new RemoveAcknowledgementForm())
->setAction($this->getLink('removeAcknowledgement'))
+ // TODO: This is a hack as for the button label the count of objects is used. setCount? setMultiple?
->setObjects(array_fill(0, $this->summary->$acks, null));
$this->add(Html::tag('li', $removeAckForm));
diff --git a/library/Icingadb/Widget/Detail/ObjectDetail.php b/library/Icingadb/Widget/Detail/ObjectDetail.php
index a688173..4ba0e69 100644
--- a/library/Icingadb/Widget/Detail/ObjectDetail.php
+++ b/library/Icingadb/Widget/Detail/ObjectDetail.php
@@ -423,7 +423,10 @@ class ObjectDetail extends BaseHtmlElement
if (empty($this->object->state->output) && empty($this->object->state->long_output)) {
$pluginOutput = new EmptyState(t('Output unavailable.'));
} else {
- $pluginOutput = new PluginOutputContainer(PluginOutput::fromObject($this->object));
+ $pluginOutput = new PluginOutputContainer(
+ PluginOutput::fromObject($this->object)
+ ->setCharacterLimit(10000)
+ );
CopyToClipboard::attachTo($pluginOutput);
}
diff --git a/library/Icingadb/Widget/HostSummaryDonut.php b/library/Icingadb/Widget/HostSummaryDonut.php
index db5fef8..5efcf74 100644
--- a/library/Icingadb/Widget/HostSummaryDonut.php
+++ b/library/Icingadb/Widget/HostSummaryDonut.php
@@ -47,7 +47,7 @@ class HostSummaryDonut extends Card
->addSlice($this->summary->hosts_down_handled, ['class' => 'slice-state-critical-handled'])
->addSlice($this->summary->hosts_down_unhandled, ['class' => 'slice-state-critical'])
->addSlice($this->summary->hosts_pending, ['class' => 'slice-state-pending'])
- ->setLabelBig($this->summary->hosts_down_unhandled)
+ ->setLabelBig((string) $this->summary->hosts_down_unhandled)
->setLabelBigUrl(Links::hosts()->setFilter($labelBigUrlFilter)->addParams([
'sort' => 'host.state.last_state_change'
]))
diff --git a/library/Icingadb/Widget/ItemList/BaseDowntimeListItem.php b/library/Icingadb/Widget/ItemList/BaseDowntimeListItem.php
index 7ebc1f6..dedaa72 100644
--- a/library/Icingadb/Widget/ItemList/BaseDowntimeListItem.php
+++ b/library/Icingadb/Widget/ItemList/BaseDowntimeListItem.php
@@ -56,7 +56,11 @@ abstract class BaseDowntimeListItem extends BaseListItem
protected function init(): void
{
- if ($this->item->is_flexible && $this->item->is_in_effect) {
+ if (
+ isset($this->item->start_time, $this->item->end_time)
+ && $this->item->is_flexible
+ && $this->item->is_in_effect
+ ) {
$this->startTime = $this->item->start_time->getTimestamp();
$this->endTime = $this->item->end_time->getTimestamp();
} else {
diff --git a/library/Icingadb/Widget/ItemList/HostDetailHeader.php b/library/Icingadb/Widget/ItemList/HostDetailHeader.php
index 97176da..b7afb23 100644
--- a/library/Icingadb/Widget/ItemList/HostDetailHeader.php
+++ b/library/Icingadb/Widget/ItemList/HostDetailHeader.php
@@ -50,7 +50,9 @@ class HostDetailHeader extends HostListItemMinimal
}
$stateChange->setIcon($this->state->getIcon());
- $stateChange->setHandled($this->state->is_handled || ! $this->state->is_reachable);
+ $stateChange->setHandled(
+ $this->state->is_problem && ($this->state->is_handled || ! $this->state->is_reachable)
+ );
$visual->addHtml($stateChange);
}
diff --git a/library/Icingadb/Widget/ItemList/ServiceDetailHeader.php b/library/Icingadb/Widget/ItemList/ServiceDetailHeader.php
index 2f0dbbd..8c5094d 100644
--- a/library/Icingadb/Widget/ItemList/ServiceDetailHeader.php
+++ b/library/Icingadb/Widget/ItemList/ServiceDetailHeader.php
@@ -50,7 +50,9 @@ class ServiceDetailHeader extends ServiceListItemMinimal
}
$stateChange->setIcon($this->state->getIcon());
- $stateChange->setHandled($this->state->is_handled || ! $this->state->is_reachable);
+ $stateChange->setHandled(
+ $this->state->is_problem && ($this->state->is_handled || ! $this->state->is_reachable)
+ );
$visual->addHtml($stateChange);
}
diff --git a/library/Icingadb/Widget/ItemList/StateList.php b/library/Icingadb/Widget/ItemList/StateList.php
index 1e6dcb9..9671c97 100644
--- a/library/Icingadb/Widget/ItemList/StateList.php
+++ b/library/Icingadb/Widget/ItemList/StateList.php
@@ -53,7 +53,7 @@ abstract class StateList extends BaseItemList
if ($this->data instanceof VolatileStateResults && $this->data->isRedisUnavailable()) {
$this->prependWrapper((new HtmlDocument())->addHtml(new Notice(
- t('Icinga Redis is currently unavailable. The shown information might be outdated.')
+ t('Redis is currently unavailable. The shown information might be outdated.')
)));
}
}
diff --git a/library/Icingadb/Widget/ItemList/StateListItem.php b/library/Icingadb/Widget/ItemList/StateListItem.php
index d0b3363..cd8ff16 100644
--- a/library/Icingadb/Widget/ItemList/StateListItem.php
+++ b/library/Icingadb/Widget/ItemList/StateListItem.php
@@ -99,7 +99,7 @@ abstract class StateListItem extends BaseListItem
{
$stateBall = new StateBall($this->state->getStateText(), $this->getStateBallSize());
$stateBall->add($this->state->getIcon());
- if ($this->state->is_handled || ! $this->state->is_reachable) {
+ if ($this->state->is_problem && ($this->state->is_handled || ! $this->state->is_reachable)) {
$stateBall->getAttributes()->add('class', 'handled');
}
diff --git a/library/Icingadb/Widget/ItemTable/BaseHostGroupItem.php b/library/Icingadb/Widget/ItemTable/BaseHostGroupItem.php
index c56a1f8..b3099c8 100644
--- a/library/Icingadb/Widget/ItemTable/BaseHostGroupItem.php
+++ b/library/Icingadb/Widget/ItemTable/BaseHostGroupItem.php
@@ -5,7 +5,7 @@
namespace Icinga\Module\Icingadb\Widget\ItemTable;
use Icinga\Module\Icingadb\Common\Links;
-use Icinga\Module\Icingadb\Model\Hostgroup;
+use Icinga\Module\Icingadb\Model\Hostgroupsummary;
use ipl\Html\Attributes;
use ipl\Html\BaseHtmlElement;
use ipl\Html\HtmlElement;
@@ -18,7 +18,7 @@ use ipl\Web\Widget\Link;
/**
* Hostgroup item of a hostgroup list. Represents one database row.
*
- * @property Hostgroup $item
+ * @property Hostgroupsummary $item
* @property HostgroupTable $table
*/
abstract class BaseHostGroupItem extends BaseTableRowItem
diff --git a/library/Icingadb/Widget/ItemTable/BaseServiceGroupItem.php b/library/Icingadb/Widget/ItemTable/BaseServiceGroupItem.php
index 7bee532..24f0bea 100644
--- a/library/Icingadb/Widget/ItemTable/BaseServiceGroupItem.php
+++ b/library/Icingadb/Widget/ItemTable/BaseServiceGroupItem.php
@@ -5,7 +5,7 @@
namespace Icinga\Module\Icingadb\Widget\ItemTable;
use Icinga\Module\Icingadb\Common\Links;
-use Icinga\Module\Icingadb\Model\Servicegroup;
+use Icinga\Module\Icingadb\Model\ServicegroupSummary;
use ipl\Html\Attributes;
use ipl\Html\BaseHtmlElement;
use ipl\Html\HtmlElement;
@@ -18,7 +18,7 @@ use ipl\Web\Widget\Link;
/**
* Servicegroup item of a servicegroup list. Represents one database row.
*
- * @property Servicegroup $item
+ * @property ServicegroupSummary $item
* @property ServicegroupTable $table
*/
abstract class BaseServiceGroupItem extends BaseTableRowItem
diff --git a/library/Icingadb/Widget/ItemTable/HostgroupTableRow.php b/library/Icingadb/Widget/ItemTable/HostgroupTableRow.php
index 6aa61c2..cb3f06a 100644
--- a/library/Icingadb/Widget/ItemTable/HostgroupTableRow.php
+++ b/library/Icingadb/Widget/ItemTable/HostgroupTableRow.php
@@ -4,7 +4,7 @@
namespace Icinga\Module\Icingadb\Widget\ItemTable;
-use Icinga\Module\Icingadb\Model\Hostgroup;
+use Icinga\Module\Icingadb\Model\Hostgroupsummary;
use Icinga\Module\Icingadb\Widget\Detail\HostStatistics;
use Icinga\Module\Icingadb\Widget\Detail\ServiceStatistics;
use ipl\Html\BaseHtmlElement;
@@ -13,7 +13,7 @@ use ipl\Stdlib\Filter;
/**
* Hostgroup table row of a hostgroup table. Represents one database row.
*
- * @property Hostgroup $item
+ * @property Hostgroupsummary $item
* @property HostgroupTable $table
*/
class HostgroupTableRow extends BaseHostGroupItem
diff --git a/library/Icingadb/Widget/ItemTable/ServicegroupTableRow.php b/library/Icingadb/Widget/ItemTable/ServicegroupTableRow.php
index 3dea4c1..e34c029 100644
--- a/library/Icingadb/Widget/ItemTable/ServicegroupTableRow.php
+++ b/library/Icingadb/Widget/ItemTable/ServicegroupTableRow.php
@@ -4,7 +4,7 @@
namespace Icinga\Module\Icingadb\Widget\ItemTable;
-use Icinga\Module\Icingadb\Model\Servicegroup;
+use Icinga\Module\Icingadb\Model\ServicegroupSummary;
use Icinga\Module\Icingadb\Widget\Detail\ServiceStatistics;
use ipl\Html\BaseHtmlElement;
use ipl\Stdlib\Filter;
@@ -12,7 +12,7 @@ use ipl\Stdlib\Filter;
/**
* Servicegroup item of a servicegroup list. Represents one database row.
*
- * @property Servicegroup $item
+ * @property ServicegroupSummary $item
* @property ServicegroupTable $table
*/
class ServicegroupTableRow extends BaseServiceGroupItem
diff --git a/library/Icingadb/Widget/ItemTable/StateRowItem.php b/library/Icingadb/Widget/ItemTable/StateRowItem.php
index f62286b..7ca9392 100644
--- a/library/Icingadb/Widget/ItemTable/StateRowItem.php
+++ b/library/Icingadb/Widget/ItemTable/StateRowItem.php
@@ -33,7 +33,7 @@ abstract class StateRowItem extends BaseStateRowItem
$stateBall = new StateBall($this->item->state->getStateText(), StateBall::SIZE_LARGE);
$stateBall->add($this->item->state->getIcon());
- if ($this->item->state->is_handled) {
+ if ($this->item->state->is_problem && ($this->item->state->is_handled || ! $this->item->state->is_reachable)) {
$stateBall->getAttributes()->add('class', 'handled');
}
diff --git a/library/Icingadb/Widget/ServiceSummaryDonut.php b/library/Icingadb/Widget/ServiceSummaryDonut.php
index e806fba..e6b38a1 100644
--- a/library/Icingadb/Widget/ServiceSummaryDonut.php
+++ b/library/Icingadb/Widget/ServiceSummaryDonut.php
@@ -50,7 +50,7 @@ class ServiceSummaryDonut extends Card
->addSlice($this->summary->services_unknown_handled, ['class' => 'slice-state-unknown-handled'])
->addSlice($this->summary->services_unknown_unhandled, ['class' => 'slice-state-unknown'])
->addSlice($this->summary->services_pending, ['class' => 'slice-state-pending'])
- ->setLabelBig($this->summary->services_critical_unhandled)
+ ->setLabelBig((string) $this->summary->services_critical_unhandled)
->setLabelBigUrl(Links::services()->setFilter($labelBigUrlFilter)->addParams([
'sort' => 'service.state.last_state_change'
]))