Modified : Dashboard

Added : Migration - VMs Backup
This commit is contained in:
e025532
2024-12-30 12:19:06 +01:00
parent fe0b5f6880
commit 9e6f83b6ec
6 changed files with 782 additions and 58 deletions

View File

@@ -31,10 +31,8 @@
<body class="bg-light text-dark">
<?php include $_SERVER['DOCUMENT_ROOT'] . "/include/all.php"; ?> <!-- Include All -->
<?php // DATA
$answers = Invoke_WebInfraReports("SELECT a.VM, a.LastBackup, a.Result, a.LastGoodBackup, a.Host, b.OS
FROM netbackup_vms a
left join globalcrossover b on a.VM = b.Server
where a.vm not like 'WS%' and a.vm not like '%vmmsv%' order by a.VM");
//$answers = Invoke_infra("SELECT * FROM VMs_Backup where Owner like 'DUN-VMH%' and name not like 'WS%' and owner not like '%WKG%' and Exclusion ='' and LastResult <> 'OK' order by lastresult,name");
//$answers += Invoke_infra("SELECT * FROM VMs_Backup where Owner like 'DUN-VMH%' and name not like 'WS%' and owner not like '%WKG%' and Exclusion <>'' order by name");
?>
<!-- HTML -->
@@ -47,7 +45,7 @@
<!-- Display -->
<div class="col py-3">
<!-- Page Title -->
<h1><span class="badge text-bg-secondary font-weight-bold" style="width:100%;" id="ERR"></span></h1>
<h2><span class="badge text-bg-secondary " style="width:100%;" id="ERR"></span></h2>
<!-- Main content -->
<div class="container-fluid">
@@ -71,57 +69,93 @@
<!-- TABLE -->
<div>
<table class='table table-bordered table-hover table-sm' id='t1' data-height="620" data-toggle="table" data-search="true" data-show-columns="true" data-export-types="['xlsx','csv','json']" data-show-export="true" data-sortable="true" data-sort-name="VM">
<thead> <!-- Header -->
<th data-field='vm' data-sortable='true'>VM</th>
<th data-field='Last Backup' data-sortable='true'>Last Backup</th>
<th data-field='LastGood' data-sortable='true'>Last Good Backup</th>
<th data-field='OS' data-sortable='true'>OS</th>
<th data-field='Host' data-sortable='true'>Host</th>
</thead>
<thead> <!-- Header -->
<th data-field='vm' data-sortable='true'>VM</th>
<th data-field='Last Backup' data-sortable='true'>Last Backup</th>
<th data-field='Last Result' data-sortable='true'>Last Result</th>
<th data-field='Last Good' data-sortable='true'>Last Good Backup</th>
<th data-field='Size' data-sortable='true'>Size</th>
<th data-field='Host' data-sortable='true'>Host</th>
<th data-field='Policy' data-sortable='true' data-visible='false'>Policy</th>
</thead>
<tbody> <!-- Body -->
<?php
<tbody> <!-- Body -->
<?php
// NO Backup or Backup with Errors
$er = 0;
$answers = Invoke_infra("SELECT * FROM VMs_Backup where Owner like 'DUN-VMH%' and name not like 'WS%' and owner not like '%WKG%' and owner not like '%VMH-WM%' and Exclusion ='' and (LastResult <> 'OK' or lastresult is null) order by lastresult,name");
foreach ($answers as $row) {
$ok = 1;
if($row['LastBackup'] == 0){
echo '<tr class="table-primary">';
echo '<td><b>'.$row['VM'].'</b></td>';
echo '<td>Excluded via VMM</td>';
echo '<td></td><td>'.$row['OS'].'</td><td>'.$row['Host'].'</td>';
$er++;
$date1 = date_create($row['LastKnownGood']); $diff = date_diff($date1, date_create(date("Y-m-d")));
if ($diff->format("%R%a") >= 2 || $row['LastKnownGood'] == ''){
echo "<tr class='table-danger'>";
}else{
echo '<tr>';
$date1 = date_create($row['LastGoodBackup']);
$diff = date_diff($date1, date_create(date("Y-m-d")));
if ($diff->format("%R%a") > 3 || $row['LastGoodBackup'] == ""){
echo '<td class="table-danger"><b>'.$row['VM'].'</b></td>';
$ok = 0;
}else{
echo '<td class="table-success"><b>'.$row['VM'].'</b></td>';
}
if($row['Result'] === "0"){
echo '<td class="table-success">OK</td>';
}else{
$ok = 0;
if($row['Result'] == " : FAILED"){
echo '<td class="table-danger"> SNAPSHOT FAILED</td>';
}else{
echo '<td class="table-warning"> ERROR '.$row['Result'].'</td>';
}
}
if ($diff->format("%R%a") > 3 || $row['LastGoodBackup'] == ""){
echo '<td class="table-danger">'.$row['LastGoodBackup'].'</td>';
$ok = 0;
}else{
echo '<td class="table-success">'.$row['LastGoodBackup'].'</td>';
}
echo '<td>'.$row['OS'].'</td>';
echo '<td>'.$row['Host'].'</td>';
echo '</tr>' ;
echo "<tr class='table-warning'>";
}
if($ok ==0){$er++;}
if($diff->format("%R%a") == "-0"){$LastGood = "NEVER";}else{$LastGood = $row['LastKnownGood']." (".$diff->format("%R%a")."J)";}
echo "<td><b>".$row['Name']."<b></td>";
echo "<td>".$row['LastBackup']." ".$row['TimeStamp']."</td>";
echo "<td>".$row['LastResult']."</td>";
echo "<td>".$LastGood."</td>";
echo "<td>".$row['LastSize']."</td>";
echo "<td>".$row['Owner']."</td>";
echo "<td>".$row['Policy']."</td>";
echo "</tr>";
}
?>
// Backup OK
$outdated = 0;
$answers = Invoke_infra("SELECT * FROM VMs_Backup where Owner like 'DUN-VMH%' and name not like 'WS%' and owner not like '%WKG%' and owner not like '%VMH-WM%' and Exclusion ='' and LastResult = 'OK' order by name");
foreach ($answers as $row) {
$date1 = date_create($row['LastKnownGood']); $diff = date_diff($date1, date_create(date("Y-m-d")));
if(date('w') >= 2 && date('w') <= 6 ){
if ($diff->format("%R%a") >= 2){
echo "<tr class='table-warning'>";
}else{
echo "<tr class='table-success'>";
}
}else{
if((date('w') < 2 || date('w') == 7)){
if($diff->format("%R%a") <= 3){
echo "<tr class='table-success'>";
}else{
echo "<tr class='table-warning'>";
}
}
}
if($diff->format("%R%a") == "-0"){$LastGood = $row['LastKnownGood'];}else{$LastGood = $row['LastKnownGood']." (".$diff->format("%R%a")."J)";}
echo "<td><b>".$row['Name']."<b></td>";
echo "<td>".$row['LastBackup']." ".$row['TimeStamp']."</td>";
echo "<td>".$row['LastResult']."</td>";
if (date('w') >= 2 && date('w') <= 6 && $diff->format("%R%a") < 1){
echo "<td>".$LastGood."</td>";
}else{
echo "<td class='table-warning'>".$LastGood."</td>";
$outdated++;
}
echo "<td>".$row['LastSize']."</td>";
echo "<td>".$row['Owner']."</td>";
echo "<td>".$row['Policy']."</td>";
echo "</tr>";
}
// Backup OK
$excluded = 0;
$answers = Invoke_infra("SELECT * FROM VMs_Backup where Owner like 'DUN-VMH%' and name not like 'WS%' and owner not like '%WKG%' and owner not like '%VMH-WM%' and Exclusion <> '' order by name");
foreach ($answers as $row) {
$excluded++;
echo "<tr class='table-secondary'>";
echo "<td><b>".$row['Name']."<b></td>";
echo "<td>Tag NoBackup</td>";
echo "<td>Tag NoBackup</td>";
echo "<td>Tag NoBackup</td>";
echo "<td>Tag NoBackup</td>";
echo "<td>".$row['Owner']."</td>";
echo "<td>".$row['Policy']."</td>";
echo "</tr>";
}
?>
</tbody>
</table>
<br>
@@ -131,6 +165,9 @@
</div>
</div>
</div>
<?php
$ERR = "VMs backups (<span class='text-danger'>".$er." issues</span> - <span class='text-warning'>".$outdated." outdated </span>- <span class='text-info'>".$excluded.' excluded</span>)';
?>
</body>
<script src="/js/switch.js"></script>
</HTML>
@@ -158,11 +195,6 @@
window.addEventListener("resize", tableresize);
document.getElementById("ERR").innerHTML = "<?php echo 'VMs backups ('.$er.' issues)'; ?>";
document.getElementById("ERR").innerHTML = "<?php echo $ERR ; ?>";
</script>
</SCRIPT>