Merge branch 'feature/parameterize-variable-vars-check_command-101'

fixes #101
This commit is contained in:
Alexander A. Klimov 2017-12-18 11:30:53 +01:00
commit 5f74128a3e
4 changed files with 45 additions and 4 deletions

View file

@ -6,6 +6,7 @@ use Icinga\Module\Graphite\Forms\TimeRangePicker\TimeRangePickerTrait as TimeRan
use Icinga\Module\Graphite\Forms\TimeRangePicker\TimeRangePickerTrait as TimeRangePickerFormTrait;
use Icinga\Module\Graphite\Web\Controller\MonitoringAwareController;
use Icinga\Module\Graphite\Web\Controller\TimeRangePickerTrait;
use Icinga\Module\Graphite\Web\Widget\Graphs;
use Icinga\Module\Monitoring\DataView\DataView;
use Icinga\Web\Url;
use Icinga\Web\Widget\Tabextension\DashboardAction;
@ -34,7 +35,7 @@ class ListController extends MonitoringAwareController
'host_name',
'host_display_name',
'host_check_command',
'_host_check_command'
'_host_check_command' => '_host_' . Graphs::getObscuredCheckCommandCustomVar()
])
);
@ -68,7 +69,7 @@ class ListController extends MonitoringAwareController
'service_description',
'service_display_name',
'service_check_command',
'_service_check_command'
'_service_check_command' => '_service_' . Graphs::getObscuredCheckCommandCustomVar()
])
);

View file

@ -4,6 +4,7 @@ namespace Icinga\Module\Graphite\Forms\Config;
use Icinga\Forms\ConfigForm;
use Icinga\Module\Graphite\Web\Form\Validator\MacroTemplateValidator;
use Zend_Validate_Regex;
class AdvancedForm extends ConfigForm
{
@ -39,6 +40,18 @@ class AdvancedForm extends ConfigForm
),
'validators' => [new MacroTemplateValidator()]
]
],
[
'text',
'icinga_customvar_obscured_check_command',
[
'label' => $this->translate('Obscured check command custom variable'),
'description' => $this->translate(
'The Icinga custom variable with the "actual" check command obscured'
. ' by e.g. check_by_ssh (defaults to check_command)'
),
'validators' => [new Zend_Validate_Regex('/\A\w*\z/')]
]
]
]);
}

View file

@ -21,6 +21,10 @@ The settings *Host name template* and *Service name template* both are only
required if you are using a different naming schema than the default Icinga 2
is using. (As outlined [here](https://www.icinga.com/docs/icinga2/latest/doc/14-features/#current-graphite-schema))
The setting *Obscured check command custom variable* is only required if there
are wrapped check commands (see below) and the "actual" check command is stored
in another custom variable than `check_command`.
## Wrapped check commands
If a monitored object is checked remotely and not via an Icinga 2 agent, but

View file

@ -2,6 +2,7 @@
namespace Icinga\Module\Graphite\Web\Widget;
use Icinga\Application\Config;
use Icinga\Application\Icinga;
use Icinga\Module\Graphite\Forms\TimeRangePicker\TimeRangePickerTrait;
use Icinga\Module\Graphite\Graphing\GraphingTrait;
@ -20,6 +21,13 @@ abstract class Graphs extends AbstractWidget
{
use GraphingTrait;
/**
* The Icinga custom variable with the "real" check command (if any) of monitored objects we display graphs for
*
* @var string
*/
protected static $obscuredCheckCommandCustomVar;
/**
* Graph image width
*
@ -114,7 +122,7 @@ abstract class Graphs extends AbstractWidget
return new HostGraphs(
$object->getName(),
$object->host_check_command,
$object->_host_check_command
$object->{'_host_' . Graphs::getObscuredCheckCommandCustomVar()}
);
case 'service':
@ -123,11 +131,26 @@ abstract class Graphs extends AbstractWidget
$object->getHost()->getName(),
$object->getName(),
$object->service_check_command,
$object->_service_check_command
$object->{'_service_' . Graphs::getObscuredCheckCommandCustomVar()}
);
}
}
/**
* Get the Icinga custom variable with the "real" check command (if any) of monitored objects we display graphs for
*
* @return string
*/
public static function getObscuredCheckCommandCustomVar()
{
if (static::$obscuredCheckCommandCustomVar === null) {
static::$obscuredCheckCommandCustomVar = Config::module('graphite')
->get('icinga', 'customvar_obscured_check_command', 'check_command');
}
return static::$obscuredCheckCommandCustomVar;
}
/**
* Constructor
*