You are here

private function StatuspageController::calculateOutdatedModuleAndThemeNames in Nagios Monitoring 8

Belongs to nagios_check_requirements() function.

TODO: compare with functions in nagios.drush.inc; remove repeated code, if possible.

Parameters

string $tmp_state:

ImmutableConfig $config:

1 call to StatuspageController::calculateOutdatedModuleAndThemeNames()
StatuspageController::getStringFromNagiosData in src/Controller/StatuspageController.php

File

src/Controller/StatuspageController.php, line 94

Class

StatuspageController
Class StatuspageController produces the HTTP output that the bash script in the nagios-plugin directory understands.

Namespace

Drupal\nagios\Controller

Code

private function calculateOutdatedModuleAndThemeNames(&$tmp_state, ImmutableConfig $config) {
  $tmp_projects = update_calculate_project_data(\Drupal::service('update.manager')
    ->getProjects());
  $nagios_ignored_modules = $config
    ->get('nagios.ignored_modules') ?: [];
  $nagios_ignored_themes = $config
    ->get('nagios.ignored_themes') ?: [];
  $nagios_ignored_projects = $nagios_ignored_modules + $nagios_ignored_themes;
  $outdated_count = 0;
  $tmp_modules = '';
  foreach ($tmp_projects as $project_name => $value) {
    if (!isset($nagios_ignored_projects[$project_name]) && $value['status'] < UpdateManagerInterface::CURRENT && $value['status'] >= UpdateManagerInterface::NOT_SECURE) {
      switch ($value['status']) {
        case UpdateManagerInterface::NOT_SECURE:
          $project_status = $this
            ->t('NOT SECURE');
          break;
        case UpdateManagerInterface::REVOKED:
          $project_status = $this
            ->t('REVOKED');
          break;
        case UpdateManagerInterface::NOT_SUPPORTED:
          $project_status = $this
            ->t('NOT SUPPORTED');
          break;
        case UpdateManagerInterface::NOT_CURRENT:
          $project_status = $this
            ->t('NOT CURRENT');
          break;
        default:
          $project_status = $value['status'];
      }
      $tmp_modules .= ' ' . $project_name . ':' . $project_status;
      $outdated_count++;
    }
  }
  if ($outdated_count > 0) {
    $tmp_modules = trim($tmp_modules);
    $tmp_state .= " ({$tmp_modules})";
  }
}