You are here

function nagios_settings in Nagios Monitoring 7

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

Callback for the settings page

1 string reference to 'nagios_settings'
nagios_menu in ./nagios.module
Implements hook_menu().

File

./nagios.module, line 114

Code

function nagios_settings($form) {
  $group = 'modules';
  _nagios_update_os_user();
  $form['nagios_ua'] = [
    '#type' => 'textfield',
    '#title' => t('Unique ID'),
    '#default_value' => variable_get('nagios_ua', ''),
    '#description' => t('Restrict sending information to requests identified by this Unique ID. You should change this to some unique string for your organization, and configure Nagios accordingly. This makes Nagios data less accessible to curious users. See the README.txt for more details.'),
  ];
  $form['nagios_show_outdated_names'] = [
    '#type' => 'checkbox',
    '#title' => t('Show outdated module/theme name?'),
    '#default_value' => variable_get('nagios_show_outdated_names', TRUE),
  ];
  $form['nagios_status_page'] = [
    '#type' => 'fieldset',
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
    '#title' => t('Status page settings'),
    '#description' => t('Control the availability and location of the HTTP status page. NOTE: you must clear the menu cache for changes to these settings to register.'),
  ];
  $form['nagios_status_page']['nagios_enable_status_page'] = [
    '#type' => 'checkbox',
    '#title' => t('Enable status page?'),
    '#default_value' => variable_get('nagios_enable_status_page', FALSE),
  ];
  $form['nagios_status_page']['nagios_page_path'] = [
    '#type' => 'textfield',
    '#title' => t('Nagios page path'),
    '#description' => t('Enter the path for the Nagios HTTP status page. It must be a valid Drupal path.'),
    '#default_value' => variable_get('nagios_page_path', 'nagios'),
  ];
  $form['nagios_status_page']['nagios_page_callback'] = [
    '#type' => 'textfield',
    '#title' => t('Nagios page callback'),
    '#description' => t('Enter the name of the callback function to be used by the Nagios status page. Take care and be sure this function exists before clearing the menu cache!'),
    '#default_value' => variable_get('nagios_page_callback', 'nagios_status_page'),
  ];
  $form['nagios_status_page']['nagios_enable_status_page_get'] = [
    '#type' => 'checkbox',
    '#title' => t('Enable Unique ID checking via URL on status page?'),
    '#default_value' => variable_get('nagios_enable_status_page_get', FALSE),
    '#description' => t('If enabled the $_GET variable "unique_id" is used for checking the correct Unique ID instead of "User Agent" ($_SERVER[\'HTTP_USER_AGENT\']). This alternative checking is only working if the URL is containing the value like "/nagios?unique_id=*****". This feature is useful to avoid webserver stats with the Unique ID as "User Agent" and helpful for human testing.'),
  ];
  $form['nagios_error_levels'] = [
    '#type' => 'fieldset',
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
    '#title' => t('Error levels'),
    '#description' => t('Set the values to be used for error levels when reporting to Nagios.'),
  ];
  $form['nagios_error_levels']['nagios_status_ok_value'] = [
    '#type' => 'textfield',
    '#title' => t('Status OK'),
    '#description' => t('The value to send to Nagios for a Status OK message.'),
    '#default_value' => variable_get('nagios_status_ok_value', 0),
  ];
  $form['nagios_error_levels']['nagios_status_warning_value'] = [
    '#type' => 'textfield',
    '#title' => t('Warning'),
    '#description' => t('The value to send to Nagios for a Warning message.'),
    '#default_value' => variable_get('nagios_status_warning_value', 1),
  ];
  $form['nagios_error_levels']['nagios_status_critical_value'] = [
    '#type' => 'textfield',
    '#title' => t('Critical'),
    '#description' => t('The value to send to Nagios for a Critical message.'),
    '#default_value' => variable_get('nagios_status_critical_value', 2),
  ];
  $form['nagios_error_levels']['nagios_status_unknown_value'] = [
    '#type' => 'textfield',
    '#title' => t('Unknown'),
    '#description' => t('The value to send to Nagios for an Unknown message.'),
    '#default_value' => variable_get('nagios_status_unknown_value', 3),
  ];
  $form[$group] = [
    '#type' => 'fieldset',
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
    '#title' => t('Modules'),
    '#description' => t('Select the modules that should report their data into Nagios.'),
  ];
  foreach (nagios_invoke_all('nagios_info') as $module => $data) {
    $form[$group]['nagios_enable_' . $module] = [
      '#type' => 'checkbox',
      '#title' => $data['name'] . ' (' . $module . ')',
      '#default_value' => variable_get('nagios_enable_' . $module, TRUE),
    ];
  }
  $form['watchdog'] = [
    '#type' => 'fieldset',
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
    '#title' => t('Watchdog Settings'),
    '#description' => t('Controls how watchdog messages are retrieved and displayed when watchdog checking is set.'),
  ];
  $form['watchdog']['limit_watchdog_display'] = [
    '#type' => 'checkbox',
    '#title' => 'Limit watchdog display',
    '#default_value' => variable_get('limit_watchdog_display', FALSE),
    '#description' => t('Limit watchdog messages to only those that are new since the last check.'),
  ];
  $form['watchdog']['limit_watchdog_results'] = [
    '#type' => 'textfield',
    '#title' => 'Limit watchdog logs',
    '#default_value' => variable_get('limit_watchdog_results', 50),
    '#description' => t('Limit the number of watchdog logs that are checked. E.G. 50 will only check the newest 50 logs.'),
  ];
  foreach (nagios_invoke_all('nagios_settings') as $module => $module_settings) {
    $form[$module] = [
      '#type' => 'fieldset',
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
      '#title' => $module,
    ];
    foreach ($module_settings as $element => $data) {
      $form[$module][$element] = $data;
    }
  }
  return system_settings_form($form);
}