- Deleted `test.php` as it was no longer in use. - Enhanced null safety checks in `Inventory.php`, `StdOut-detail.php`, `Backups.php`, and `SwitchsSAN.php` to prevent potential warnings. - Refactored `SwitchsSAN.php` to improve sorting logic for ports based on errors, vFabric, and Port ID. - Added seasonal snow effect script in `all.php` with toggle functionality for user engagement. - Updated navigation bar (`navbar.html`) to include a new VIO page link. - Introduced a new `VIO.php` page to display VIO monitoring details with table export and sorting features.
186 lines
7.0 KiB
PHP
186 lines
7.0 KiB
PHP
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
|
|
|
<title>Infra Reports IT - SAN Status</title>
|
|
<link rel="shortcut icon" type="image/png" href="/include/favicon-32x32.png">
|
|
|
|
<script src="/js/jquery-3.6.1.min.js"></script>
|
|
<link rel="stylesheet" href="/css/bootstrap.min.css">
|
|
<link rel="stylesheet" href="/css/bootstrap-icons/bootstrap-icons.css">
|
|
<script src="/js/bootstrap.bundle.min.js"></script>
|
|
|
|
<link rel="stylesheet" href="/css/bootstrap-table.min.css">
|
|
<script src="/js/bootstrap-table.min.js"></script>
|
|
<script src="/js/bootstrap-table-fr-FR.min.js"></script>
|
|
|
|
<style>
|
|
.card-header a { text-decoration: none; color: white; display: block; width: 100%; }
|
|
.card-header a:hover { color: #f0f0f0; }
|
|
</style>
|
|
</head>
|
|
|
|
<body class="bg-light text-dark">
|
|
<?php
|
|
// Include global configurations
|
|
include $_SERVER['DOCUMENT_ROOT'] . "/include/all.php";
|
|
|
|
// --- PHP LOGIC START ---
|
|
|
|
// 1. Fetch JSON Data
|
|
$jsonString = PostJson("$bdnuss/Storage/BROCADE/PORT/BROCADE_PORT_LIST.php", '');
|
|
|
|
// 2. Decode to PHP Array
|
|
$sanData = json_decode($jsonString, true);
|
|
|
|
// Check if decode was successful
|
|
if (json_last_error() !== JSON_ERROR_NONE) {
|
|
$sanData = [];
|
|
$errorMessage = "Error decoding JSON: " . json_last_error_msg();
|
|
}
|
|
?>
|
|
|
|
<div class="container-fluid" id="content">
|
|
<div class="row flex-nowrap">
|
|
<div class="col-auto col-md-2 col-xl-2 px-sm-2 px-0 bg-dark vh-100 position-sticky top-0" style="-ms-flex: 0 0 230px;flex: 0 0 230px;">
|
|
<?php include $_SERVER['DOCUMENT_ROOT'] . "/navbar.html"; ?>
|
|
</div>
|
|
|
|
<div class="col py-3">
|
|
<h1><span class="badge text-bg-secondary font-weight-bold" style="width:100%;">Fibre Channel Switch Status</span></h1>
|
|
|
|
<div class="container mt-4">
|
|
|
|
<?php if (isset($errorMessage)): ?>
|
|
<div class="alert alert-danger"><?php echo $errorMessage; ?></div>
|
|
<?php endif; ?>
|
|
|
|
<div id="accordion">
|
|
<?php
|
|
// Loop through Switches
|
|
if (!empty($sanData)) {
|
|
$switchIndex = 0;
|
|
|
|
foreach ($sanData as $switchName => $ports) {
|
|
$switchIndex++;
|
|
$collapseId = "collapse_" . $switchIndex;
|
|
|
|
// Inject PortID into the array content for easier sorting
|
|
foreach ($ports as $k => $v) $ports[$k]['_PortID'] = $k;
|
|
|
|
// Custom Sort: Errors (Desc) > vFabric (Asc) > Port (Natural Asc)
|
|
uasort($ports, function ($a, $b) {
|
|
// Errors (Descending)
|
|
$errA = (int)$a['Errors'];
|
|
$errB = (int)$b['Errors'];
|
|
if ($errA !== $errB) {
|
|
return $errB <=> $errA;
|
|
}
|
|
|
|
// vFabric (Ascending / Case Insensitive)
|
|
$vfA = $a['vFabric'] ?? '';
|
|
$vfB = $b['vFabric'] ?? '';
|
|
$cmpVf = strcasecmp($vfA, $vfB);
|
|
if ($cmpVf !== 0) {
|
|
return $cmpVf;
|
|
}
|
|
|
|
// Port ID (Natural Sort, e.g. 2 comes before 10)
|
|
return strnatcmp($a['_PortID'], $b['_PortID']);
|
|
});
|
|
// Initialize counters & buffers
|
|
$upCount = 0;
|
|
$downCount = 0;
|
|
$errorCount = 0;
|
|
$tableBody = "";
|
|
|
|
// Generate HTML Rows based on sorted data
|
|
foreach ($ports as $portId => $portData) {
|
|
$state = $portData['State'];
|
|
$errors = (int)$portData['Errors'];
|
|
|
|
if ($state === 'UP') $upCount++;
|
|
elseif ($state === 'DN') $downCount++;
|
|
|
|
if ($errors > 0 && $state === 'UP') $errorCount++;
|
|
|
|
if ($state === 'DN') {
|
|
continue;
|
|
}
|
|
|
|
// Determine Row CSS Class
|
|
$rowClass = "table-success";
|
|
if ($errors > 0) $rowClass = "table-danger";
|
|
|
|
// Build Row HTML
|
|
$tableBody .= "
|
|
<tr class='{$rowClass}'>
|
|
<td>{$portData['vFabric']}</td>
|
|
<td>{$portId}</td>
|
|
<td>{$portData['Status']}</td>
|
|
<td>{$portData['State']}</td>
|
|
<td>{$portData['Speed']}</td>
|
|
<td>{$portData['Nego']}</td>
|
|
<td>{$portData['FrameTX']}</td>
|
|
<td>{$portData['FrameRX']}</td>
|
|
<td data-value='{$errors}'><strong>{$portData['Errors']}</strong></td>
|
|
</tr>";
|
|
}
|
|
|
|
// Determine Header Color
|
|
$headerColor = ($errorCount > 0) ? "DarkOrange" : "green";
|
|
$msg = ($errorCount > 0) ? "<b> {$errorCount} issue(s)</b>" : "OK";
|
|
?>
|
|
|
|
<div class="card" style="background-color:<?php echo $headerColor; ?>;">
|
|
<h4 class="card-header">
|
|
<a class="btn text-white fs-3 w-100 text-start" data-bs-toggle="collapse" href="#<?php echo $collapseId; ?>">
|
|
<b><?php echo strtoupper($switchName); ?> : <?php echo $upCount; ?> Ports UP / <?php echo ($upCount + $downCount); ?> : <?php echo $msg; ?></b>
|
|
</a>
|
|
</h4>
|
|
</div>
|
|
|
|
<div id="<?php echo $collapseId; ?>" class="collapse" data-bs-parent="#accordion">
|
|
<div class="card-body bg-white border p-0">
|
|
<div class="table-responsive">
|
|
<table class="table table-bordered table-hover mb-0 text-center" data-toggle="table">
|
|
<thead class="table-light">
|
|
<tr>
|
|
<th data-sortable="true">vFabric</th>
|
|
<th data-sortable="true">Port</th>
|
|
<th data-sortable="true">Status</th>
|
|
<th data-sortable="true">State</th>
|
|
<th data-sortable="true">Speed</th>
|
|
<th data-sortable="true">Nego</th>
|
|
<th data-sortable="true">FrameTX</th>
|
|
<th data-sortable="true">FrameRX</th>
|
|
<th data-sortable="true">Errors</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php echo $tableBody; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<br>
|
|
|
|
<?php
|
|
}
|
|
} else {
|
|
echo "<div class='alert alert-warning'>No data available via API.</div>";
|
|
}
|
|
?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
<script src="/js/switch.js"></script>
|
|
</html>
|