Merge pull request #3678 from Icinga/feature/dont-display-check-now-if-active-checks-are-disabled-3665

Don't allow to reschedule checks for objects with no active checks
This commit is contained in:
Johannes Meyer 2019-04-12 10:58:50 +02:00 committed by GitHub
commit 6a23a641ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 73 additions and 20 deletions

View File

@ -85,7 +85,12 @@ class HostsController extends Controller
public function showAction()
{
$this->setAutorefreshInterval(15);
if ($this->Auth()->hasPermission('monitoring/command/schedule-check')) {
$activeChecksEnabled = $this->hostList->getFeatureStatus()['active_checks_enabled'] !== 0;
if ($this->Auth()->hasPermission('monitoring/command/schedule-check')
|| ($this->Auth()->hasPermission('monitoring/command/schedule-check/active-only')
&& $activeChecksEnabled
)
) {
$checkNowForm = new CheckNowCommandForm();
$checkNowForm
->setObjects($this->hostList)
@ -114,8 +119,12 @@ class HostsController extends Controller
$hostStates = $this->hostList->getStateSummary();
$this->setAutorefreshInterval(15);
$this->view->rescheduleAllLink = Url::fromRequest()->setPath('monitoring/hosts/reschedule-check');
if ($activeChecksEnabled) {
$this->view->rescheduleAllLink = Url::fromRequest()
->setPath('monitoring/hosts/reschedule-check')
->addParams(['host_active_checks_enabled' => true]);
}
$this->view->downtimeAllLink = Url::fromRequest()->setPath('monitoring/hosts/schedule-downtime');
$this->view->processCheckResultAllLink = Url::fromRequest()->setPath('monitoring/hosts/process-check-result');
$this->view->addCommentLink = Url::fromRequest()->setPath('monitoring/hosts/add-comment');

View File

@ -92,7 +92,12 @@ class ServicesController extends Controller
public function showAction()
{
$this->setAutorefreshInterval(15);
if ($this->Auth()->hasPermission('monitoring/command/schedule-check')) {
$activeChecksEnabled = $this->serviceList->getFeatureStatus()['active_checks_enabled'] !== 0;
if ($this->Auth()->hasPermission('monitoring/command/schedule-check')
|| ($this->Auth()->hasPermission('monitoring/command/schedule-check/active-only')
&& $activeChecksEnabled
)
) {
$checkNowForm = new CheckNowCommandForm();
$checkNowForm
->setObjects($this->serviceList)
@ -119,8 +124,12 @@ class ServicesController extends Controller
->handleRequest();
$this->view->toggleFeaturesForm = $toggleFeaturesForm;
$this->setAutorefreshInterval(15);
$this->view->rescheduleAllLink = Url::fromRequest()->setPath('monitoring/services/reschedule-check');
if ($activeChecksEnabled) {
$this->view->rescheduleAllLink = Url::fromRequest()
->setPath('monitoring/services/reschedule-check')
->addParams(['service_active_checks_enabled' => true]);
}
$this->view->downtimeAllLink = Url::fromRequest()->setPath('monitoring/services/schedule-downtime');
$this->view->processCheckResultAllLink = Url::fromRequest()->setPath(
'monitoring/services/process-check-result'

View File

@ -58,6 +58,12 @@ class CheckNowCommandForm extends ObjectsCommandForm
{
foreach ($this->objects as $object) {
/** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */
if (! $object->active_checks_enabled
&& ! $this->Auth()->hasPermission('monitoring/command/schedule-check')
) {
continue;
}
if ($object->getType() === $object::TYPE_HOST) {
$check = new ScheduleHostCheckCommand();
} else {

View File

@ -45,6 +45,10 @@ class ScheduleHostCheckCommandForm extends ScheduleServiceCheckCommandForm
{
foreach ($this->objects as $object) {
/** @var \Icinga\Module\Monitoring\Object\Host $object */
if (! $object->active_checks_enabled) {
continue;
}
$check = new ScheduleHostCheckCommand();
$check
->setObject($object)

View File

@ -92,6 +92,10 @@ class ScheduleServiceCheckCommandForm extends ObjectsCommandForm
{
foreach ($this->objects as $object) {
/** @var \Icinga\Module\Monitoring\Object\Service $object */
if (! $object->active_checks_enabled) {
continue;
}
$check = new ScheduleServiceCheckCommand();
$check->setObject($object);
$this->scheduleCheck($check, $this->request);

View File

@ -181,6 +181,7 @@
</tr>
<?php endif ?>
<?php if (isset($rescheduleAllLink)): ?>
<tr>
<th></th>
<td>
@ -195,6 +196,7 @@
) ?>
</td>
</tr>
<?php endif ?>
</tbody>
</table>
<h2><?= $this->translate('Feature Commands') ?></h2>

View File

@ -183,6 +183,7 @@
</tr>
<?php endif ?>
<?php if (isset($rescheduleAllLink)): ?>
<tr>
<th></th>
<td>
@ -197,6 +198,7 @@
) ?>
</td>
</tr>
<?php endif ?>
</tbody>
</table>
<h2><?= $this->translate('Feature Commands') ?></h2>

View File

@ -11,6 +11,10 @@ $this->providePermission(
'monitoring/command/schedule-check',
$this->translate('Allow scheduling host and service checks')
);
$this->providePermission(
'monitoring/command/schedule-check/active-only',
$this->translate('Allow scheduling host and service checks (Only on objects with active checks enabled)')
);
$this->providePermission(
'monitoring/command/acknowledge-problem',
$this->translate('Allow acknowledging host and service problems')

View File

@ -12,19 +12,28 @@ A user needs specific permissions to be able to send those commands
when using the monitoring module.
Name | Permits
--------------------------------------------|-----------------------------------------------
monitoring/command/\* | Allow all commands.
monitoring/command/schedule-check | Allow scheduling host and service checks.
monitoring/command/acknowledge-problem | Allow acknowledging host and service problems.
monitoring/command/remove-acknowledgement | Allow removing problem acknowledgements.
monitoring/command/comment/\* | Allow adding and deleting host and service comments.
monitoring/command/comment/add | Allow commenting on hosts and services.
monitoring/command/downtime/delete | Allow deleting host and service downtimes.
monitoring/command/process-check-result | Allow processing host and service check results.
monitoring/command/feature/instance | Allow processing commands for toggling features on an instance-wide basis.
monitoring/command/feature/object | Allow processing commands for toggling features on host and service objects.
monitoring/command/send-custom-notification | Allow sending custom notifications for hosts and services.
Name | Permits
-------------------------------------------------|-----------------------------------------------
monitoring/command/* | Allow all commands.
monitoring/command/schedule-check | Allow scheduling host and service checks.
monitoring/command/schedule-check/active-only | Allow scheduling host and service checks. (Only on objects with active checks enabled)
monitoring/command/acknowledge-problem | Allow acknowledging host and service problems.
monitoring/command/remove-acknowledgement | Allow removing problem acknowledgements.
monitoring/command/comment/* | Allow adding and deleting host and service comments.
monitoring/command/comment/add | Allow commenting on hosts and services.
monitoring/command/comment/delete | Allow deleting host and service comments.
monitoring/command/downtime/* | Allow scheduling and deleting host and service downtimes.
monitoring/command/downtime/schedule | Allow scheduling host and service downtimes.
monitoring/command/downtime/delete | Allow deleting host and service downtimes.
monitoring/command/process-check-result | Allow processing host and service check results.
monitoring/command/feature/instance | Allow processing commands for toggling features on an instance-wide basis.
monitoring/command/feature/object/* | Allow processing commands for toggling features on host and service objects.
monitoring/command/feature/object/active-checks | Allow processing commands for toggling active checks on host and service objects.
monitoring/command/feature/object/passive-checks | Allow processing commands for toggling passive checks on host and service objects.
monitoring/command/feature/object/notifications | Allow processing commands for toggling notifications on host and service objects.
monitoring/command/feature/object/event-handler | Allow processing commands for toggling event handlers on host and service objects.
monitoring/command/feature/object/flap-detection | Allow processing commands for toggling flap detection on host and service objects.
monitoring/command/send-custom-notification | Allow sending custom notifications for hosts and services.
## Restrictions <a id="monitoring-module-security-restrictions"></a>

View File

@ -268,7 +268,11 @@ abstract class MonitoredObjectController extends Controller
protected function setupQuickActionForms()
{
$auth = $this->Auth();
if ($auth->hasPermission('monitoring/command/schedule-check')) {
if ($auth->hasPermission('monitoring/command/schedule-check')
|| ($auth->hasPermission('monitoring/command/schedule-check/active-only')
&& $this->object->active_checks_enabled
)
) {
$this->view->checkNowForm = $checkNowForm = new CheckNowCommandForm();
$checkNowForm
->setObjects($this->object)