-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add config page: monitoring integration
- Loading branch information
Showing
5 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace Icinga\Module\Masifupgrader\Forms; | ||
|
||
use Icinga\Application\Icinga; | ||
use Icinga\Forms\ConfigForm; | ||
|
||
class IntegrationForm extends ConfigForm | ||
{ | ||
public function init() | ||
{ | ||
$this->setName('form_config_integration'); | ||
$this->setTitle($this->translate('Monitoring integration')); | ||
$this->setSubmitLabel($this->translate('Save changes')); | ||
} | ||
|
||
public function createElements(array $formData) | ||
{ | ||
$this->addElement('checkbox', 'integration_monitoring', [ | ||
'label' => $this->translate('Monitoring module'), | ||
'description' => $this->translate('Integrate into the monitoring module (IDO)') | ||
]); | ||
|
||
if (!Icinga::app()->getModuleManager()->hasEnabled('monitoring')) { | ||
$this->getElement('integration_monitoring')->disabled = true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace Icinga\Module\Masifupgrader\Forms; | ||
|
||
use Icinga\Forms\ConfigForm; | ||
use Icinga\Module\Monitoring\Backend\MonitoringBackend; | ||
use PDO; | ||
|
||
class ServicesForm extends ConfigForm | ||
{ | ||
public function init() | ||
{ | ||
$this->setName('form_config_services'); | ||
$this->setTitle($this->translate('Services')); | ||
$this->setSubmitLabel($this->translate('Save changes')); | ||
} | ||
|
||
public function createElements(array $formData) | ||
{ | ||
/** @var PDO $pdo */ | ||
$pdo = MonitoringBackend::instance()->getResource()->getDbAdapter()->getConnection(); | ||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | ||
|
||
$stmt = $pdo->prepare('SELECT DISTINCT name2 FROM icinga_objects WHERE objecttype_id = 2 ORDER BY name2'); | ||
$stmt->execute(); | ||
|
||
foreach ($stmt->fetchAll(PDO::FETCH_COLUMN) as $service) { | ||
$this->addElement('checkbox', "services_$service", [ | ||
'label' => $this->translate($service), | ||
'description' => sprintf($this->translate('Integrate into services named "%s"'), $service) | ||
]); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<div class="controls"> | ||
<?= /** @var \Icinga\Web\Widget\Tabs $tabs */ $tabs ?> | ||
</div> | ||
<div class="content"> | ||
<?= /** @var \Icinga\Web\Form $form1 */ $form1 ?> | ||
<?= /** @var \Icinga\Web\Form $form2 */ $form2 ?> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters