You are here

function nagios_nagios_settings in Nagios Monitoring 8

Same name and namespace in other branches
  1. 5 nagios.module \nagios_nagios_settings()
  2. 6 nagios.module \nagios_nagios_settings()
  3. 7 nagios.module \nagios_nagios_settings()

Implements hook_nagios_settings().

File

./nagios.module, line 130
Main file for Nagios service monitoring.

Code

function nagios_nagios_settings() {
  $config = Drupal::config('nagios.settings');
  $moduleHandler = Drupal::moduleHandler();
  foreach (nagios_functions() as $function => $description) {
    $var = 'nagios_func_' . $function;
    $cfgname = 'function.' . $function;
    $form[$var] = [
      '#type' => 'checkbox',
      '#title' => $function,
      '#default_value' => (bool) $config
        ->get('nagios.' . $cfgname),
      '#description' => $description,
      '#configname' => $cfgname,
    ];
  }
  $form['nagios_show_outdated_names'] = [
    '#type' => 'checkbox',
    '#title' => t('Show outdated module/theme name'),
    '#default_value' => $config
      ->get('nagios.show_outdated_names'),
    '#configname' => 'show_outdated_names',
    '#states' => [
      'disabled' => [
        '#edit-nagios-func-requirements' => [
          'checked' => FALSE,
        ],
      ],
    ],
  ];
  $group = 'thresholds';
  $form[$group] = [
    '#type' => 'fieldset',
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
    '#title' => t('Thresholds'),
    '#description' => t('Thresholds for reporting critical alerts to Nagios.'),
  ];
  $form[$group]['nagios_cron_duration'] = [
    '#type' => 'textfield',
    '#title' => t('Cron duration'),
    '#description' => t('Issue a critical alert when cron has not been running for this duration (in minutes). Default is 60 minutes.'),
    '#states' => [
      'disabled' => [
        '#edit-nagios #edit-nagios-func-cron' => [
          'checked' => FALSE,
        ],
      ],
    ],
    '#configname' => 'cron_duration',
  ];
  if ($moduleHandler
    ->moduleExists('elysia_cron')) {
    $form[$group]['nagios_elysia_cron_duration'] = [
      '#type' => 'textfield',
      '#title' => t('Elysia cron duration'),
      '#description' => t('Issue a critical alert when elysia cron has not been running for this duration (in minutes). Default is 60 minutes.'),
      '#configname' => 'elysia_cron_duration',
    ];
  }
  $form[$group]['nagios_min_report_severity'] = [
    '#type' => 'select',
    '#title' => t('Mininum report severity'),
    '#options' => nagios_status(),
    '#description' => t('Issue an alert only for this minimum severity, not for lower severities.'),
    '#configname' => 'min_report_severity',
  ];
  return $form;
}