Skip to content

Commit

Permalink
Configurable output limit (#1033)
Browse files Browse the repository at this point in the history
resolves #1017
closes #1019
  • Loading branch information
nilmerg authored Jul 24, 2024
2 parents 092dca7 + 4a46b28 commit 29d7f4b
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 21 deletions.
40 changes: 20 additions & 20 deletions doc/03-Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,26 +69,26 @@ configuration file `/etc/icingaweb2/modules/icingadb/config.ini`.

### Available Settings and defaults

Option | Description | Default
----------------------------------|-----------------------------------|------------
acknowledge_expire | Sets "Use Expire Time" in Acknowledgement dialog. | **0 (false)**
acknowledge_expire_time | Sets the value for "Expire Time" in Acknowledgement dialog, its calculated as now + this setting. Format is a [PHP Dateinterval](http://www.php.net/manual/en/dateinterval.construct.php). | **1 hour (PT1H)**.
acknowledge_notify | Sets "Send Notification" in Acknowledgement dialog. | **1 (true)**
acknowledge_persistent | Sets "Persistent Comment" in Acknowledgement dialog. | **0 (false)**
acknowledge_sticky | Sets "Sticky Acknowledgement" in Acknowledgement dialog. | **0 (false)**
comment_expire | Sets "Use Expire Time" in Comment dialog. | **0 (false)**
hostdowntime_comment_text | Sets default text for "Comment" in Host Downtime dialog | ""
servicedowntime_comment_text | Sets default text for "Comment" in Service Downtime dialog. | ""
comment_expire_time | Sets default value for "Expire Time" in Comment dialog, its calculated as now + this setting. Format is a [PHP Dateinterval](http://www.php.net/manual/en/dateinterval.construct.php). | **1 hour (PT1H)**
custom_notification_forced | Sets "Forced" in Custom Notification dialog. | **0 (false)**
hostdowntime_all_services | Sets "All Services" in Schedule Host Downtime dialog. | **0 (false)**
hostdowntime_end_fixed | Sets default value for "End Time" in Schedule Host Downtime dialog for **Fixed** downtime, its calculated as now + this setting. Format is a [PHP Dateinterval](http://www.php.net/manual/en/dateinterval.construct.php). | **1 hour (PT1H)**.
hostdowntime_end_flexible | Sets default value for "End Time" in Schedule Host Downtime dialog for **Flexible** downtime, its calculated as now + this setting. Format is a [PHP Dateinterval](http://www.php.net/manual/en/dateinterval.construct.php). | **2 hours (PT2H)**.
hostdowntime_flexible_duration | Sets default value for "Flexible Duration" in Schedule Host Downtime dialog for **Flexible** downtime. Format is a [PHP Dateinterval](http://www.php.net/manual/en/dateinterval.construct.php). | **2 hour (PT2H)**.
servicedowntime_end_fixed | Sets default value for "End Time" in Schedule Service Downtime dialog for **Fixed** downtime, its calculated as now + this setting. Format is a [PHP Dateinterval](http://www.php.net/manual/en/dateinterval.construct.php). | **1 hour (PT1H)**.
servicedowntime_end_flexible | Set default value for "End Time" in Schedule Service Downtime dialog for **Flexible** downtime, its calculated as now + this setting. Format is a [PHP Dateinterval](http://www.php.net/manual/en/dateinterval.construct.php). | **1 hour (PT1H)**.
servicedowntime_flexible_duration | Set default value for "Flexible Duration" in Schedule Service Downtime dialog for **Flexible** downtime. Format is a [PHP Dateinterval](http://www.php.net/manual/en/dateinterval.construct.php). | **2 hour (PT2H)**.

| Option | Description | Default |
|-----------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------|
| acknowledge_expire | Toggles "Use Expire Time" in the Acknowledgement dialog. | **0 (false)** |
| acknowledge_expire_time | Sets the value for "Expire Time" in the Acknowledgement dialog. It is calculated as now + this setting. Format is a [PHP Dateinterval](http://www.php.net/manual/en/dateinterval.construct.php). | **1 hour (PT1H)**. |
| acknowledge_notify | Toggles "Send Notification" in the Acknowledgement dialog. | **1 (true)** |
| acknowledge_persistent | Toggles "Persistent Comment" in the Acknowledgement dialog. | **0 (false)** |
| acknowledge_sticky | Toggles "Sticky Acknowledgement" in the Acknowledgement dialog. | **0 (false)** |
| comment_expire | Toggles "Use Expire Time" in the Comment dialog. | **0 (false)** |
| hostdowntime_comment_text | Sets the value for "Comment" in the Host Downtime dialog | "" |
| servicedowntime_comment_text | Sets the value for "Comment" in the Service Downtime dialog. | "" |
| comment_expire_time | Sets the value for "Expire Time" in the Comment dialog. It is calculated as now + this setting. Format is a [PHP Dateinterval](http://www.php.net/manual/en/dateinterval.construct.php). | **1 hour (PT1H)** |
| custom_notification_forced | Toggles "Forced" in the Custom Notification dialog. | **0 (false)** |
| hostdowntime_all_services | Toggles "All Services" in the Schedule Host Downtime dialog. | **0 (false)** |
| hostdowntime_end_fixed | Sets the value for "End Time" in the Schedule Host Downtime dialog for a **Fixed** downtime. It is calculated as now + this setting. Format is a [PHP Dateinterval](http://www.php.net/manual/en/dateinterval.construct.php). | **1 hour (PT1H)**. |
| hostdowntime_end_flexible | Sets the value for "End Time" in the Schedule Host Downtime dialog for a **Flexible** downtime. It is calculated as now + this setting. Format is a [PHP Dateinterval](http://www.php.net/manual/en/dateinterval.construct.php). | **2 hours (PT2H)**. |
| hostdowntime_flexible_duration | Sets the value for "Flexible Duration" in the Schedule Host Downtime dialog for a **Flexible** downtime. Format is a [PHP Dateinterval](http://www.php.net/manual/en/dateinterval.construct.php). | **2 hour (PT2H)**. |
| servicedowntime_end_fixed | Sets the value for "End Time" in the Schedule Service Downtime dialog for a **Fixed** downtime. It is calculated as now + this setting. Format is a [PHP Dateinterval](http://www.php.net/manual/en/dateinterval.construct.php). | **1 hour (PT1H)**. |
| servicedowntime_end_flexible | Sets the value for "End Time" in the Schedule Service Downtime dialog for a **Flexible** downtime. It is calculated as now + this setting. Format is a [PHP Dateinterval](http://www.php.net/manual/en/dateinterval.construct.php). | **1 hour (PT1H)**. |
| servicedowntime_flexible_duration | Sets the value for "Flexible Duration" in the Schedule Service Downtime dialog for a **Flexible** downtime. Format is a [PHP Dateinterval](http://www.php.net/manual/en/dateinterval.construct.php). | **2 hour (PT2H)**. |
| plugin_output_character_limit | Sets the maximum number of characters to display in plugin output. | **10000** |

### Example

Expand Down
9 changes: 9 additions & 0 deletions library/Icingadb/Widget/Detail/EventDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use DateTime;
use DateTimeZone;
use Icinga\Application\Config;
use Icinga\Date\DateFormatter;
use Icinga\Module\Icingadb\Common\Auth;
use Icinga\Module\Icingadb\Common\Database;
Expand Down Expand Up @@ -79,6 +80,10 @@ protected function assembleNotificationEvent(NotificationHistory $notification)
->setCommandName($notification->object_type === 'host'
? $this->event->host->checkcommand_name
: $this->event->service->checkcommand_name)
->setCharacterLimit(
(int) Config::module('icingadb')
->get('settings', 'plugin_output_character_limit', 10000)
)
);

CopyToClipboard::attachTo($notificationText);
Expand Down Expand Up @@ -191,6 +196,10 @@ protected function assembleStateChangeEvent(StateHistory $stateChange)
$commandOutput = new PluginOutputContainer(
(new PluginOutput($stateChange->output . "\n" . $stateChange->long_output))
->setCommandName($commandName)
->setCharacterLimit(
(int) Config::module('icingadb')
->get('settings', 'plugin_output_character_limit', 10000)
)
);

CopyToClipboard::attachTo($commandOutput);
Expand Down
6 changes: 5 additions & 1 deletion library/Icingadb/Widget/Detail/ObjectDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Exception;
use Icinga\Application\ClassLoader;
use Icinga\Application\Config;
use Icinga\Application\Hook;
use Icinga\Application\Hook\GrapherHook;
use Icinga\Application\Icinga;
Expand Down Expand Up @@ -425,7 +426,10 @@ protected function createPluginOutput(): array
} else {
$pluginOutput = new PluginOutputContainer(
PluginOutput::fromObject($this->object)
->setCharacterLimit(10000)
->setCharacterLimit(
(int) Config::module('icingadb')
->get('settings', 'plugin_output_character_limit', 10000)
)
);
CopyToClipboard::attachTo($pluginOutput);
}
Expand Down
10 changes: 10 additions & 0 deletions phpstan-baseline-standard.neon
Original file line number Diff line number Diff line change
Expand Up @@ -5985,6 +5985,11 @@ parameters:
count: 1
path: library/Icingadb/Widget/Detail/EventDetail.php

-
message: "#^Cannot cast mixed to int\\.$#"
count: 2
path: library/Icingadb/Widget/Detail/EventDetail.php

-
message: "#^Method Icinga\\\\Module\\\\Icingadb\\\\Widget\\\\Detail\\\\EventDetail\\:\\:assemble\\(\\) has no return type specified\\.$#"
count: 1
Expand Down Expand Up @@ -6265,6 +6270,11 @@ parameters:
count: 4
path: library/Icingadb/Widget/Detail/ObjectDetail.php

-
message: "#^Cannot cast mixed to int\\.$#"
count: 1
path: library/Icingadb/Widget/Detail/ObjectDetail.php

-
message: "#^Method Icinga\\\\Module\\\\Icingadb\\\\Widget\\\\Detail\\\\ObjectDetail\\:\\:__construct\\(\\) has parameter \\$object with no type specified\\.$#"
count: 1
Expand Down

0 comments on commit 29d7f4b

Please sign in to comment.