function dba_statpack_page in Database Administration 7
Display database report.
1 string reference to 'dba_statpack_page'
- dba_menu in ./
dba.module - Implements hook_menu().
File
- ./
dba.statpack.inc, line 9
Code
function dba_statpack_page() {
$form = array();
if (isset($_SESSION['dba_statpack_reports']) && is_array($_SESSION['dba_statpack_reports'])) {
$reports = array();
foreach ($_SESSION['dba_statpack_reports'] as $report) {
$reports[] = $report;
}
unset($_SESSION['dba_statpack_reports']);
if (isset($_SESSION['dba_statpack_interval'])) {
$interval = $_SESSION['dba_statpack_interval'];
unset($_SESSION['dba_statpack_interval']);
}
$form['view_report'] = array(
'#type' => 'fieldset',
'#title' => t('Database statistics report'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$name = dba_invoke_driver_specific('name', NULL, 'report');
$uptime = dba_invoke_driver_specific('uptime', $reports[0], 'statpack');
$output = dba_statpack_header($uptime, $interval);
$output = array_merge($output, dba_invoke_driver_specific('output', $reports, 'statpack'));
$display = '';
foreach ($output as $line) {
if (substr($line, 0, 1) == '_') {
$display .= "\n";
}
$display .= $line . "\n";
}
$form['view_report']['report'] = array(
'#type' => 'markup',
'#markup' => "<pre>{$display}</pre>",
);
}
$form['run_report'] = array(
'#type' => 'fieldset',
'#title' => t('Generate database statistics report'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form['run_report']['interval'] = array(
'#title' => t('Snapshot interval'),
'#description' => t('Specify how long an interval between snapshots.'),
'#type' => 'select',
'#options' => drupal_map_assoc(array(
5,
15,
30,
45,
60,
120,
180,
240,
300,
600,
900,
1800,
3600,
), 'format_interval'),
);
$form['run_report']['submit'] = array(
'#type' => 'submit',
'#value' => t('Generate report'),
);
return $form;
}