You are here

function dba_pgsql_report_output in Database Administration 7

PostgreSQL report.

File

database/pgsql.report.inc, line 77

Code

function dba_pgsql_report_output($data) {
  $output = array();
  $output[] = '';
  $output[] = dba_report_section(t('Connections'));
  $percent = dba_report_to_percentage($data->status->connections / $data->variables->max_connections);
  $alert = dba_report_alert(array(
    $percent,
  ), array(
    PGSQL_CONNECTIONS_PERCENT,
  ));
  $output[] = t('!openUsed        !count of !total      %Max: !percent!close', array(
    '!count' => sprintf('%9d', $data->status->connections),
    '!total' => sprintf('%4d', $data->variables->max_connections),
    '!percent' => sprintf('%6.2f', $percent),
    '!open' => _dba_alert_open($alert, dba_pgsql_report_help_connections(), $data->drush),
    '!close' => _dba_alert_close($alert, $data->drush),
  ));
  $output[] = dba_report_section(t('Locks'));
  $output[] = t('Held        !count of !total         %: !percent', array(
    '!count' => sprintf('%9d', $data->status->locks_held),
    '!total' => sprintf('%4d', $data->status->locks_total),
    '!percent' => sprintf('%6.2f', dba_report_to_percentage($data->status->locks_held / $data->status->locks_total)),
  ));
  $output[] = t('Wait        !count of !total         %: !percent', array(
    '!count' => sprintf('%9d', $data->status->locks_wait),
    '!total' => sprintf('%4d', $data->status->locks_total),
    '!percent' => sprintf('%6.2f', dba_report_to_percentage($data->status->locks_wait / $data->status->locks_total)),
  ));
  $output[] = '';
  $output[] = t('No further PostgreSQL reporting functionality has been implemented yet.');
  $output[] = t('Contributers welcome.');
  $output[] = t('Submit patches to !url.', array(
    '!url' => l(t('the DBA module issue queue'), 'http://drupal.org/project/issues/dba?categories=All'),
  ));
  $output[] = '';
  $output[] = t('Variable dump:');
  foreach ($data->variables as $key => $value) {
    $output[] = '  ' . $key . '  ' . $value;
  }
  return $output;
}