From 878106f83f85a9b24a5d836916f503cf688b1559 Mon Sep 17 00:00:00 2001 From: sva-e025532 Date: Wed, 17 Sep 2025 10:20:48 +0200 Subject: [PATCH] Enhance resilience and UI in inventory and server detail pages: - Add `Heartbeat` column to `/X/Inventory.php` with status-based row styling. - Improve error handling and data validation for backup details in `Server-Detail.php`. --- Inventory/Server-Detail.php | 15 +++++++++------ X/Inventory.php | 21 +++++++++++++++++++-- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/Inventory/Server-Detail.php b/Inventory/Server-Detail.php index 50367a5..64f987d 100644 --- a/Inventory/Server-Detail.php +++ b/Inventory/Server-Detail.php @@ -111,7 +111,7 @@ $OSKernel";} ?> Host : ".$Qvm[0]['Owner'].""; }else{ @@ -298,10 +298,14 @@ LastBackup : ".explode(".",$backup[0]['LastBackup'])[0]." "; - echo "BackupType : ".$backup[0]['BackupType']." "; - echo "Media : ".$backup[0]['Location'].""; + try { + $backup = Invoke_Infra("select * from X_cmdb_Backupsys where HOSTNAME='$server'"); + if(is_array($backup) && $backup[0]['LastBackup']) { + echo "LastBackup : " . explode(".", $backup[0]['LastBackup'])[0] . " "; + echo "BackupType : " . $backup[0]['BackupType'] . " "; + echo "Media : " . $backup[0]['Location'] . ""; + } + } catch (Exception $e) {} // Catch any potential errors during backup information retrieval } ?> @@ -311,4 +315,3 @@ - diff --git a/X/Inventory.php b/X/Inventory.php index df8a044..b7e9ce9 100644 --- a/X/Inventory.php +++ b/X/Inventory.php @@ -56,6 +56,7 @@ Name + Heartbeat Host OS Type Distrib @@ -75,8 +76,24 @@ $total++; echo ""; //name - $name = $s['hostname']; - echo "$name"; + $name = $s['hostname']; $heartbeat = $s['Heartbeat']; $statusClass = ''; + $heartbeatDate = new DateTime($heartbeat); + $now = new DateTime(); + $interval = $now->diff($heartbeatDate); + $diffInMinutes = ($interval->days * 24 * 60) + ($interval->h * 60) + $interval->i; + if ($diffInMinutes < 10) { + $statusClass = 'table-success'; + } elseif ($diffInMinutes <= 30) { + $statusClass = 'table-warning'; + } else { + $statusClass = 'table-danger'; + } + echo ""; + echo " {$name}"; + echo ""; + + //heartbeat + echo "".$s["Heartbeat"].""; //Host echo "".$s['Owner']."";