diff --git a/modules/monitoring/doc/01-hooks/01-detailviewextension.md b/modules/monitoring/doc/01-hooks/01-detailviewextension.md new file mode 100644 index 000000000..480085710 --- /dev/null +++ b/modules/monitoring/doc/01-hooks/01-detailviewextension.md @@ -0,0 +1,76 @@ +# Detail View Extension Hook + +## About + +This hook can be used to easily extend the detail view of monitored objects (hosts and services). + +## How it works + +### Directory structure + +* `icingaweb2/modules/example` + * `library/Example/ProvidedHook/Monitoring/DetailviewExtension/Simple.php` + * `run.php` + +### Files + +#### run.php + +```php +provideHook( + 'monitoring/DetailviewExtension', + 'Icinga\Module\Example\ProvidedHook\Monitoring\DetailviewExtension\Simple' +); +``` + +#### Simple.php + +```php +name) as $c) { + if (isset($stats[$c])) { + ++$stats[$c]; + } else { + $stats[$c] = 1; + } + } + + ksort($stats); + + $view = $this->getView(); + + $thead = ''; + $tbody = ''; + foreach ($stats as $c => $amount) { + $thead .= '' . $view->escape($c) . ''; + $tbody .= '' . $amount . ''; + } + + return '

' + . $view->escape(sprintf($view->translate('A %s named "%s"'), $object->getType(), $object->name)) + . '

' + . '

Character stats

' + . '' + . '' . $thead . '' + . '' . $tbody . '' + . '
'; + } +} +``` + +## How it looks like + +![Screenshot](res/detailviewextension-01.png) diff --git a/modules/monitoring/doc/res/detailviewextension-01.png b/modules/monitoring/doc/res/detailviewextension-01.png new file mode 100644 index 000000000..a5ddaf188 Binary files /dev/null and b/modules/monitoring/doc/res/detailviewextension-01.png differ