mirror of
https://github.com/Icinga/icingaweb2-module-businessprocess.git
synced 2025-12-18 15:06:17 -05:00
Custom variables used in Detail View Extension can be read from the host if not present on the service, and can be customized, if desired, in the config.ini for this module
This commit is contained in:
parent
ba7043d14b
commit
2111103957
3 changed files with 69 additions and 7 deletions
|
|
@ -39,7 +39,7 @@ configuration:
|
|||
checkcommand_name=businessprocess-check
|
||||
```
|
||||
|
||||
A service can define specific custom variables for this. Mandatory ones
|
||||
A service, or its host, can define specific custom variables for this. Mandatory ones
|
||||
that are not defined, cause the detail view integration to not be active.
|
||||
|
||||
| Variable Name | Mandatory | Description |
|
||||
|
|
@ -47,3 +47,13 @@ that are not defined, cause the detail view integration to not be active.
|
|||
| icingacli\_businessprocess\_process | Yes | The `<process>` being checked |
|
||||
| icingacli\_businessprocess\_config | No | Name of the config that contains `<process>` |
|
||||
| icingaweb\_businessprocess\_as\_tree | No | Whether to show `<process>` as tree or tiles |
|
||||
|
||||
These variable names can also be customized in the module configuration:
|
||||
|
||||
**/etc/icingaweb2/modules/businessprocess/config.ini**
|
||||
```ini
|
||||
[DetailviewExtension]
|
||||
config_var=my_bp_config
|
||||
process_var=my_bp_proces
|
||||
tree_var=my_as_tree_view
|
||||
```
|
||||
|
|
|
|||
|
|
@ -22,6 +22,15 @@ class ServiceDetailExtension extends ServiceDetailExtensionHook
|
|||
/** @var string */
|
||||
private $commandName;
|
||||
|
||||
/** @var string */
|
||||
private $configVar;
|
||||
|
||||
/** @var string */
|
||||
private $processVar;
|
||||
|
||||
/** @var string */
|
||||
private $treeVar;
|
||||
|
||||
protected function init()
|
||||
{
|
||||
$this->setSection(self::GRAPH_SECTION);
|
||||
|
|
@ -33,6 +42,21 @@ class ServiceDetailExtension extends ServiceDetailExtensionHook
|
|||
'checkcommand_name',
|
||||
'icingacli-businessprocess'
|
||||
);
|
||||
$this->configVar = $this->getModule()->getConfig()->get(
|
||||
'DetailviewExtension',
|
||||
'config_var',
|
||||
'icingacli_businessprocess_config'
|
||||
);
|
||||
$this->processVar = $this->getModule()->getConfig()->get(
|
||||
'DetailviewExtension',
|
||||
'process_var',
|
||||
'icingacli_businessprocess_process'
|
||||
);
|
||||
$this->treeVar = $this->getModule()->getConfig()->get(
|
||||
'DetailviewExtension',
|
||||
'tree_var',
|
||||
'icingaweb_businessprocess_as_tree'
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
// Ignore and don't display anything
|
||||
}
|
||||
|
|
@ -46,12 +70,14 @@ class ServiceDetailExtension extends ServiceDetailExtensionHook
|
|||
return HtmlString::create('');
|
||||
}
|
||||
|
||||
$bpName = $service->customvars['icingacli_businessprocess_config'] ?? null;
|
||||
$customvars = array_merge($service->host->customvars, $service->customvars);
|
||||
|
||||
$bpName = $customvars[$this->configVar] ?? null;
|
||||
if (! $bpName) {
|
||||
$bpName = key($this->storage->listProcessNames());
|
||||
}
|
||||
|
||||
$nodeName = $service->customvars['icingacli_businessprocess_process'] ?? null;
|
||||
$nodeName = $customvars[$this->processVar] ?? null;
|
||||
if (! $nodeName) {
|
||||
return HtmlString::create('');
|
||||
}
|
||||
|
|
@ -61,7 +87,7 @@ class ServiceDetailExtension extends ServiceDetailExtensionHook
|
|||
|
||||
IcingaDbState::apply($bp);
|
||||
|
||||
if ($service->customvars['icingaweb_businessprocess_as_tree'] ?? false) {
|
||||
if ($customvars[$this->treeVar] ?? false) {
|
||||
$renderer = new TreeRenderer($bp, $node);
|
||||
$tag = 'ul';
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -19,6 +19,15 @@ class DetailviewExtension extends DetailviewExtensionHook
|
|||
/** @var string */
|
||||
private $commandName;
|
||||
|
||||
/** @var string */
|
||||
private $configVar;
|
||||
|
||||
/** @var string */
|
||||
private $processVar;
|
||||
|
||||
/** @var string */
|
||||
private $treeVar;
|
||||
|
||||
/**
|
||||
* Initialize storage
|
||||
*/
|
||||
|
|
@ -31,6 +40,21 @@ class DetailviewExtension extends DetailviewExtensionHook
|
|||
'checkcommand_name',
|
||||
'icingacli-businessprocess'
|
||||
);
|
||||
$this->configVar = $this->getModule()->getConfig()->get(
|
||||
'DetailviewExtension',
|
||||
'config_var',
|
||||
'icingacli_businessprocess_config'
|
||||
);
|
||||
$this->processVar = $this->getModule()->getConfig()->get(
|
||||
'DetailviewExtension',
|
||||
'process_var',
|
||||
'icingacli_businessprocess_process'
|
||||
);
|
||||
$this->treeVar = $this->getModule()->getConfig()->get(
|
||||
'DetailviewExtension',
|
||||
'tree_var',
|
||||
'icingaweb_businessprocess_as_tree'
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
// Ignore and don't display anything
|
||||
}
|
||||
|
|
@ -52,12 +76,14 @@ class DetailviewExtension extends DetailviewExtensionHook
|
|||
return '';
|
||||
}
|
||||
|
||||
$bpName = $object->_service_icingacli_businessprocess_config;
|
||||
# Grab custom vars first, merge service over host vars
|
||||
$customvars = array_merge($object->hostVariables, $object->customvars);
|
||||
$bpName = $customvars[$this->configVar] ?? null;
|
||||
if (! $bpName) {
|
||||
$bpName = key($this->storage->listProcessNames());
|
||||
}
|
||||
|
||||
$nodeName = $object->_service_icingacli_businessprocess_process;
|
||||
$nodeName = $customvars[$this->processVar] ?? null;
|
||||
if (! $nodeName) {
|
||||
return '';
|
||||
}
|
||||
|
|
@ -67,7 +93,7 @@ class DetailviewExtension extends DetailviewExtensionHook
|
|||
|
||||
MonitoringState::apply($bp);
|
||||
|
||||
if (filter_var($object->_service_icingaweb_businessprocess_as_tree, FILTER_VALIDATE_BOOLEAN)) {
|
||||
if (filter_var($customvars[$this->treeVar] ?? false, FILTER_VALIDATE_BOOLEAN)) {
|
||||
$renderer = new TreeRenderer($bp, $node);
|
||||
$tag = 'ul';
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in a new issue