Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable output limit #1033

Merged
merged 4 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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