$v) { $query[$k] = $v; } $query['token'] = user_generate_auth_token(get_user_id($_SESSION['username'])); $query['locale'] = isset($_SESSION['language']) ? $_SESSION['language'] : 'en_US'; $query['records'] = 100000; $query['mode'] = 'getreport'; $query['hideoptions'] = 1; $query['export'] = 1; $base_url = get_localhost_url(); $path = (substr($base_url, -1) === '/') ? 'includes/components/saturationreport/index.php' : '/includes/components/saturationreport/index.php'; $url = $base_url . $path . '?' . http_build_query($query); $url = str_replace(["\r", "\n"], '', trim($url)); $filename = 'index-' . uniqid() . '.' . $type; $args = array( 'filename' => $filename, 'url' => $url, 'type' => $type, 'orientation' => 0, ); $command_id = submit_command(COMMAND_DOWNLOAD_REPORT, serialize($args)); header('Content-Type: application/json'); echo json_encode(array('command_id' => $command_id)); exit; } // Normal display display_saturationreport(); /** * Output report HTML only (no full page wrapper). * Used by: (1) AJAX load into #report, (2) Chromium for PDF/JPG export. */ function get_saturationreport_report() { define('SATURATIONREPORT_DATA_ONLY', 1); require_once(dirname(__FILE__) . '/saturationreport.api.php'); $services = get_saturationreport_services_data(); if (isset($services['error'])) { echo '
' . encode_form_val($services['error']) . '
'; return; } if (!is_array($services)) { $services = array(); } $table_class = (function_exists('is_neptune') && is_neptune()) ? 'table table-condensed table-striped table-bordered tablesorter' : 'table table-striped table-bordered'; $hideoptions = grab_request_var('hideoptions', 0); $export = grab_request_var('export', 0); $is_export = (int)$hideoptions === 1 || (int)$export === 1; if ($is_export) { // Minimal HTML document for Chromium print-to-PDF (and client-side capture) header('Content-Type: text/html; charset=utf-8'); echo '' . _('Storage Saturation Report') . ''; echo ''; } echo '
'; if ($is_export) { echo '
'; echo '

' . _('Storage Saturation Report') . '

'; echo '

' . _('Summary of Tracked Storage: Volumes') . '

'; echo '

' . _('Report Date:') . ' ' . date('n/j/y, g:i A') . '

'; echo '
'; } echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; if (count($services) === 0) { echo ''; } else { foreach ($services as $s) { $host_name = isset($s['host_name']) ? $s['host_name'] : 'N/A'; $caption = isset($s['caption_display']) ? $s['caption_display'] : (isset($s['service_description']) ? $s['service_description'] : 'N/A'); $disk_used = isset($s['disk_used_display']) ? $s['disk_used_display'] : 'N/A'; $disk_available = isset($s['disk_available_display']) ? $s['disk_available_display'] : 'N/A'; $percent = isset($s['disk_usage_percent']) ? $s['disk_usage_percent'] : 0; $available_bytes = isset($s['disk_available_bytes']) ? (int)$s['disk_available_bytes'] : 0; $available_extra = ''; if ($available_bytes > 0) { $available_gb = $available_bytes / (1024 * 1024 * 1024); if ($available_gb < 5) { $available_extra = ' text-danger'; } elseif ($available_gb < 50) { $available_extra = ' text-warning'; } } $percent_class = 'progress-bar-success'; if ($percent >= 95) { $percent_class = 'progress-bar-danger'; } elseif ($percent >= 85) { $percent_class = 'progress-bar-warning'; } elseif ($percent >= 70) { $percent_class = 'progress-bar-info'; } echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; } } echo '
' . _('DISPLAY NAME') . '' . _('CAPTION') . '' . _('DISK SPACE USED') . '' . _('DISK SPACE AVAILABLE') . '' . _('PERCENT USED') . '
' . _('No services with trackvolume custom variable found') . '
' . encode_form_val($host_name) . '' . encode_form_val($caption) . '' . encode_form_val($disk_used) . '' . encode_form_val($disk_available) . ''; if ($percent > 0) { echo '
' . number_format($percent, 1) . '%
'; } else { echo 'N/A'; } echo '
'; if ($is_export) { echo ''; } } /** * Display the storage saturation report (full page with form and report container) */ function display_saturationreport() { $component_url = get_component_url_base('saturationreport'); $table_class = (function_exists('is_neptune') && is_neptune()) ? 'table table-condensed table-striped table-bordered tablesorter' : 'table table-striped table-bordered'; do_page_start(array('page_title' => _('Storage Saturation Report')), true); ?>

close