You are here

protected function SolrDiskUsageSensorPlugin::getSolrInfo in Monitoring 8

Returns Solr information.

Return value

array Returns an array with server name, host, core name, physical and swap memory information.

1 call to SolrDiskUsageSensorPlugin::getSolrInfo()
SolrDiskUsageSensorPlugin::resultVerbose in src/Plugin/monitoring/SensorPlugin/SolrDiskUsageSensorPlugin.php
Provide additional info about sensor call.

File

src/Plugin/monitoring/SensorPlugin/SolrDiskUsageSensorPlugin.php, line 242

Class

SolrDiskUsageSensorPlugin
Monitors the Solr disk usage.

Namespace

Drupal\monitoring\Plugin\monitoring\SensorPlugin

Code

protected function getSolrInfo() {
  $info = [];

  // Condition is used to simulate data for purpose of testing.
  if ($data = $this->state
    ->get('monitoring.test_solr_info')) {
    $info = $data;
  }
  elseif ($server = $this
    ->getSolrServer()) {

    /** @var \Drupal\search_api_solr\SolrBackendInterface $backend */
    $backend = $server
      ->getBackend();
    $connector = $backend
      ->getSolrConnector();
    $info = [
      'server_name' => $server
        ->label(),
      'host' => $backend
        ->getConfiguration()['connector_config']['host'],
      'core' => $backend
        ->getConfiguration()['connector_config']['core'],
      'total_physical_memory' => $connector
        ->getServerInfo()['system']['totalPhysicalMemorySize'],
      'free_physical_memory' => $connector
        ->getServerInfo()['system']['freePhysicalMemorySize'],
      'total_swap_memory' => $connector
        ->getServerInfo()['system']['totalSwapSpaceSize'],
      'free_swap_memory' => $connector
        ->getServerInfo()['system']['freeSwapSpaceSize'],
      'indexed_docs' => $connector
        ->getLuke()['index']['numDocs'],
    ];
  }
  return $info;
}