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`.
This commit is contained in:
@@ -111,7 +111,7 @@
|
||||
<?php if($OSKernel){echo " <span class='badge rounded-pill bg-secondary text-light'>$OSKernel</span>";} ?>
|
||||
<?php
|
||||
if(is_array($Qvm)){
|
||||
$site = Invoke_Infra("SELECT site from cmdb_physical_site where hostname ='".$Qvm[0]['Owner']."'")[0]['site'];
|
||||
$site = Invoke_Infra("SELECT site from cmdb_physical_site where hostname ='".$Qvm[0]['Owner']."'")[0]['site'] ?? "?";
|
||||
if($Qvm[0]['Owner'] == $Qvm[0]['PreferredOwner']){
|
||||
echo " <span class='badge rounded-pill bg-success text-light'>Host : ".$Qvm[0]['Owner']."</span>";
|
||||
}else{
|
||||
@@ -298,10 +298,14 @@
|
||||
<!-- Backup for AIX, Linux -->
|
||||
<?php
|
||||
if(is_array($Qx)){
|
||||
try {
|
||||
$backup = Invoke_Infra("select * from X_cmdb_Backupsys where HOSTNAME='$server'");
|
||||
echo "<span class='badge rounded-pill bg-secondary text-light fs-5'>LastBackup : ".explode(".",$backup[0]['LastBackup'])[0]."</span> ";
|
||||
echo "<span class='badge rounded-pill bg-secondary text-light fs-5'>BackupType : ".$backup[0]['BackupType']."</span> ";
|
||||
echo "<span class='badge rounded-pill bg-secondary text-light fs-5'>Media : ".$backup[0]['Location']."</span>";
|
||||
if(is_array($backup) && $backup[0]['LastBackup']) {
|
||||
echo "<span class='badge rounded-pill bg-secondary text-light fs-5'>LastBackup : " . explode(".", $backup[0]['LastBackup'])[0] . "</span> ";
|
||||
echo "<span class='badge rounded-pill bg-secondary text-light fs-5'>BackupType : " . $backup[0]['BackupType'] . "</span> ";
|
||||
echo "<span class='badge rounded-pill bg-secondary text-light fs-5'>Media : " . $backup[0]['Location'] . "</span>";
|
||||
}
|
||||
} catch (Exception $e) {} // Catch any potential errors during backup information retrieval
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -311,4 +315,3 @@
|
||||
</div>
|
||||
<script src="/js/switch.js"></script>
|
||||
</body>
|
||||
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
<thead> <!-- Header -->
|
||||
<tr>
|
||||
<th data-field="Name" data-sortable="true">Name</th>
|
||||
<th data-field="Heartbeat" data-sortable="true" data-visible="false" >Heartbeat</th>
|
||||
<th data-field="Host" data-sortable="true">Host</th>
|
||||
<th data-field="OS" data-sortable="true">OS Type</th>
|
||||
<th data-field="distrib" data-sortable="true">Distrib</th>
|
||||
@@ -75,8 +76,24 @@
|
||||
$total++;
|
||||
echo "<tr>";
|
||||
//name
|
||||
$name = $s['hostname'];
|
||||
echo "<td><a href='/inventory/server-detail.php?s=".$name."' target='_blank'>$name</a></td>";
|
||||
$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 "<td class='{$statusClass}'>";
|
||||
echo " <a href='/inventory/server-detail.php?s={$name}' target='_blank'>{$name}</a>";
|
||||
echo "</td>";
|
||||
|
||||
//heartbeat
|
||||
echo "<td>".$s["Heartbeat"]."</td>";
|
||||
|
||||
//Host
|
||||
echo "<td>".$s['Owner']."</td>";
|
||||
|
||||
Reference in New Issue
Block a user