You are here

function monitoring_drush_result_output_table_multiple in Monitoring 7

Same name and namespace in other branches
  1. 8 monitoring.drush.inc \monitoring_drush_result_output_table_multiple()

Outputs sensor results table for multiple results.

Parameters

\Drupal\monitoring\Result\SensorResultInterface[] $results: List of sensor result objects.

bool $show_exec_time: If TRUE the multi results view will display also execution time.

1 call to monitoring_drush_result_output_table_multiple()
monitoring_drush_result_output_table in ./monitoring.drush.inc
Outputs human readable table with results.

File

./monitoring.drush.inc, line 402
Drush support for monitoring.

Code

function monitoring_drush_result_output_table_multiple(array $results, $show_exec_time = FALSE) {
  $rows['header'] = array(
    dt('Sensor'),
    dt('Status'),
    dt('Message'),
    dt('Result age'),
  );
  if ($show_exec_time) {
    $rows['header'][] = dt('Execution time');
  }
  foreach ($results as $result) {
    $rows[$result
      ->getSensorName()] = array(
      format_string("@label\n(@name)", array(
        '@label' => truncate_utf8($result
          ->getSensorInfo()
          ->getLabel(), 40, TRUE, TRUE),
        '@name' => $result
          ->getSensorName(),
      )),
      $result
        ->getStatusLabel(),
      truncate_utf8($result
        ->getMessage(), 40, TRUE, TRUE),
      format_interval(time() - $result
        ->getTimestamp()),
    );
    if ($show_exec_time) {
      $rows[$result
        ->getSensorName()][] = $result
        ->getExecutionTime() . 'ms';
    }
  }
  drush_print_table($rows);
}