You are here

function nagios_nagios in Nagios Monitoring 8

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

Implements hook_nagios().

Parameters

string $id: Name of the function to call. If $id is empty, all are called. The $id can be submitted from the HTTP status page. For example, the following will only run the cron check: URL: https://your-drupal-8-domain/nagios/nagios/cron

In the URL above, the path segments are

  • the "Nagios page path" (1ˢᵗ nagios),
  • the module machine name implementing hook_nagios() (nagios), and
  • the check name ($id = "cron")

Return value

array

File

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

Code

function nagios_nagios(string $id = '') {
  $config = Drupal::config('nagios.settings');
  $status = [];

  /** @var callable $func */
  if ($id && $config
    ->get('nagios.function.' . $id)) {
    $func = 'nagios_check_' . $id;
    $result = $func();
    $status[$result['key']] = $result['data'];
    return $status;
  }
  foreach (nagios_functions() as $function => $description) {
    if ($config
      ->get('nagios.function.' . $function)) {
      $func = 'nagios_check_' . $function;

      /**
       * @uses nagios_check_watchdog
       * @uses nagios_check_cron
       * @uses nagios_check_session_anon
       * @uses nagios_check_session_auth
       * @uses nagios_check_users
       * @uses nagios_check_modules
       * @uses nagios_check_themes
       * @uses nagios_check_requirements
       * @uses nagios_check_nodes
       * @uses nagios_check_maintenance
       */
      $result = $func();
      $status[$result['key']] = $result['data'];
    }
  }
  return $status;
}