Add VIO FC Status monitoring page and enhance server inventory filtering
- Introduced `Storage/VIO.php` for monitoring VIO Fibre Channel status with client balancing checks and table sorting. - Updated `/include/en.php` and `/include/fr.php` to include new translations for ServiceNow and VIO-related navigation elements. - Improved SQL query and filtering logic in `/X/Inventory.php` to exclude VIO entries and add XenSam version data. - Enhanced `/reports/heartbeat.php` with a new mechanism for handling server heartbeat status, allowing better granularity and readability.
This commit is contained in:
77
X/VIO.php
77
X/VIO.php
@@ -40,6 +40,14 @@
|
||||
// 1. DATA PROCESSING (PHP)
|
||||
// ==========================================
|
||||
|
||||
// Parity of a physical fc port (fcname): "fcs0" -> even, "fcs1" -> odd, ...
|
||||
function fcs_parity($fcs) {
|
||||
if (preg_match('/(\d+)\s*$/', strtolower(trim((string)$fcs)), $m)) {
|
||||
return (intval($m[1]) % 2 === 0) ? 'even' : 'odd';
|
||||
}
|
||||
return 'unknown';
|
||||
}
|
||||
|
||||
$rawRows = Invoke_Infra("SELECT * FROM x_cmdb_VIO");
|
||||
if (!$rawRows) $rawRows = [];
|
||||
|
||||
@@ -68,6 +76,7 @@ foreach ($groupedData as $clientKey => $rows) {
|
||||
|
||||
$names = []; $inerrs = []; $vfcs = []; $vios = [];
|
||||
$clintids = []; $fcnames = []; $tss = []; $vioerrs = [];
|
||||
$parities = [];
|
||||
|
||||
$hasError = false;
|
||||
$maxVioErr = 0;
|
||||
@@ -89,28 +98,45 @@ foreach ($groupedData as $clientKey => $rows) {
|
||||
$clintids[] = $r['clintid'] ?? '-';
|
||||
$fcnames[] = $r['fcname'] ?? '-';
|
||||
$tss[] = $r['ts'] ?? '-';
|
||||
|
||||
// Redundancy check is on the physical fc port (fcname).
|
||||
$parities[] = fcs_parity($r['fcname'] ?? '');
|
||||
}
|
||||
|
||||
// Parity issue = exactly 2 known fcs parities and they are identical
|
||||
// (both even or both odd -> no fabric redundancy).
|
||||
$hasParityIssue = false;
|
||||
$knownParities = array_values(array_filter($parities, fn($p) => $p !== 'unknown'));
|
||||
if (count($knownParities) === 2 && $knownParities[0] === $knownParities[1]) {
|
||||
$hasParityIssue = true;
|
||||
}
|
||||
|
||||
$displayRows[] = [
|
||||
'clintname' => $clientKey,
|
||||
'hasError' => $hasError,
|
||||
'maxVioErr' => $maxVioErr,
|
||||
'name' => implode('<br>', $names),
|
||||
'inerr' => implode('<br>', $inerrs),
|
||||
'vfc' => implode('<br>', $vfcs),
|
||||
'vio' => implode('<br>', $vios),
|
||||
'clintid' => implode('<br>', $clintids),
|
||||
'fcname' => implode('<br>', $fcnames),
|
||||
'ts' => implode('<br>', $tss),
|
||||
'vioerr' => implode('<br>', $vioerrs),
|
||||
'clintname' => $clientKey,
|
||||
'hasError' => $hasError,
|
||||
'hasParityIssue' => $hasParityIssue,
|
||||
'maxVioErr' => $maxVioErr,
|
||||
'name' => implode('<br>', $names),
|
||||
'inerr' => implode('<br>', $inerrs),
|
||||
'vfc' => implode('<br>', $vfcs),
|
||||
'vio' => implode('<br>', $vios),
|
||||
'clintid' => implode('<br>', $clintids),
|
||||
'fcname' => implode('<br>', $fcnames),
|
||||
'ts' => implode('<br>', $tss),
|
||||
'vioerr' => implode('<br>', $vioerrs),
|
||||
];
|
||||
}
|
||||
|
||||
// 4. Final Sort: 1. Warning (inerr), 2. VIOErr > 0, 3. Alpha
|
||||
// 4. Final Sort:
|
||||
// 1. Top tier: InErr (table-warning) OR parity issue (table-danger)
|
||||
// 2. VIOErr > 0
|
||||
// 3. Alpha
|
||||
usort($displayRows, function($a, $b) {
|
||||
// Priority 1: InErr (table-warning)
|
||||
if ($a['hasError'] && !$b['hasError']) return -1;
|
||||
if (!$a['hasError'] && $b['hasError']) return 1;
|
||||
// Priority 1: warning OR parity issue -> floated to the top, same standing
|
||||
$aTop = $a['hasError'] || $a['hasParityIssue'];
|
||||
$bTop = $b['hasError'] || $b['hasParityIssue'];
|
||||
if ($aTop && !$bTop) return -1;
|
||||
if (!$aTop && $bTop) return 1;
|
||||
|
||||
// Priority 2: VIOErr count
|
||||
if ($a['maxVioErr'] > 0 && $b['maxVioErr'] == 0) return -1;
|
||||
@@ -155,7 +181,17 @@ usort($displayRows, function($a, $b) {
|
||||
|
||||
<tbody>
|
||||
<?php foreach ($displayRows as $row): ?>
|
||||
<?php $class = $row['hasError'] ? 'table-warning' : ''; ?>
|
||||
<?php
|
||||
// Parity issue (red) takes precedence over inerr warning (yellow);
|
||||
// both are floated to the top by the sort above.
|
||||
if ($row['hasParityIssue']) {
|
||||
$class = 'table-danger';
|
||||
} elseif ($row['hasError']) {
|
||||
$class = 'table-warning';
|
||||
} else {
|
||||
$class = '';
|
||||
}
|
||||
?>
|
||||
<tr class="<?php echo $class; ?>">
|
||||
<td class="fw-bold align-middle"><?php echo htmlspecialchars($row['clintname']); ?></td>
|
||||
<td class="cell-multiline"><?php echo $row['name']; ?></td>
|
||||
@@ -164,7 +200,12 @@ usort($displayRows, function($a, $b) {
|
||||
<td class="cell-multiline"><?php echo $row['vfc']; ?></td>
|
||||
<td class="cell-multiline"><?php echo $row['vio']; ?></td>
|
||||
<td class="cell-multiline"><?php echo $row['clintid']; ?></td>
|
||||
<td class="cell-multiline"><?php echo $row['fcname']; ?></td>
|
||||
<td class="cell-multiline">
|
||||
<?php echo $row['fcname']; ?>
|
||||
<?php if ($row['hasParityIssue']): ?>
|
||||
<br><span class="badge bg-danger">même parité</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td class="cell-multiline small"><?php echo $row['ts']; ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
@@ -188,4 +229,4 @@ usort($displayRows, function($a, $b) {
|
||||
$(window).resize(function () { adjustTableHeight(); });
|
||||
});
|
||||
</script>
|
||||
</html>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user