.
This commit is contained in:
@@ -103,10 +103,50 @@
|
||||
|
||||
echo "</tr>";
|
||||
}
|
||||
|
||||
// Outdated
|
||||
$outdated = 0;
|
||||
$answers = Invoke_infra("SELECT * FROM VMs_Backup where ( Owner like 'DUN-VMH%' or Owner like 'MDK-VMH%' ) and name not like 'WS%' and owner not like '%WKG%' and owner not like '%VMH-WM%' and Exclusion ='' and LastResult = 'OK' and TRY_CAST(lastknowngood AS DATE) < CAST(DATEADD(DAY, -2, GETDATE()) AS DATE) 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{
|
||||
if ((date('w') == 1 || date('w') == 7) && $diff->format("%R%a") <= 3){
|
||||
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
|
||||
$outdated = 0;
|
||||
$answers = Invoke_infra("SELECT * FROM VMs_Backup where ( Owner like 'DUN-VMH%' or Owner like 'MDK-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");
|
||||
$answers = Invoke_infra("SELECT * FROM VMs_Backup where ( Owner like 'DUN-VMH%' or Owner like 'MDK-VMH%' ) and name not like 'WS%' and owner not like '%WKG%' and owner not like '%VMH-WM%' and Exclusion ='' and LastResult = 'OK' and TRY_CAST(lastknowngood AS DATE) >= CAST(DATEADD(DAY, -2, GETDATE()) AS DATE) order by name");
|
||||
$total = count($answers);
|
||||
foreach ($answers as $row) {
|
||||
$date1 = date_create($row['LastKnownGood']); $diff = date_diff($date1, date_create(date("Y-m-d")));
|
||||
|
||||
246
Hyper-V/VMs-Backups2.php
Normal file
246
Hyper-V/VMs-Backups2.php
Normal file
@@ -0,0 +1,246 @@
|
||||
<!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">
|
||||
|
||||
<!-- Page Title -->
|
||||
<title>Web Infra Reports IT</title>
|
||||
<link rel="shortcut icon" type="image/png" href="/include/favicon-32x32.png">
|
||||
|
||||
<!-- JQuery -->
|
||||
<script src="/js/jquery-3.6.1.min.js"></script>
|
||||
<!-- Bootstrap -->
|
||||
<link rel="stylesheet" href="/css/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="/css/bootstrap-icons/bootstrap-icons.css">
|
||||
<link rel="stylesheet" href="/css/preloader.css">
|
||||
<script src="/js/bootstrap.bundle.min.js"></script>
|
||||
<!-- Bootstrap-tables -->
|
||||
<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>
|
||||
<script src="/js/tableExport.min.js"></script>
|
||||
<script src="/js/bootstrap-table-export.min.js"></script>
|
||||
<script src="/js/libs/js-xlsx/xlsx.core.min.js"></script>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body class="bg-light text-dark">
|
||||
<?php include $_SERVER['DOCUMENT_ROOT'] . "/include/all.php"; ?> <!-- Include All -->
|
||||
<?php // DATA
|
||||
//$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 -->
|
||||
<div class="container-fluid" id="content">
|
||||
<div class="row flex-nowrap">
|
||||
<!-- Left NAVBAR -->
|
||||
<div class="col-auto col-md-2 col-xl-2 px-sm-2 px-0 bg-dark" style="-ms-flex: 0 0 230px;flex: 0 0 230px;">
|
||||
<?php include $_SERVER['DOCUMENT_ROOT'] . "/navbar.html"; ?>
|
||||
</div>
|
||||
<!-- Display -->
|
||||
<div class="col py-3">
|
||||
<!-- Page Title -->
|
||||
<h2><span class="badge text-bg-secondary " style="width:100%;" id="ERR"></span></h2>
|
||||
|
||||
<!-- Main content -->
|
||||
<div class="container-fluid">
|
||||
<!-- MODAL WAIT -->
|
||||
<div class="modal fade bs-example-modal-sm" id="wait" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static" style="padding-top: 15%;">
|
||||
<div class="modal-dialog modal-sm">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title mb-1 text-dark text-uppercase">
|
||||
<center><i class="bi bi-hourglass-split"></i><br> Work in progress ...</center>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="progress">
|
||||
<div class="progress-bar progress-bar-secondary progress-bar-striped progress-bar-animated" style="width: 100%"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 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='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
|
||||
// NO Backup or Backup with Errors
|
||||
$er = 0;
|
||||
$answers = Invoke_infra("SELECT * FROM VMs_Backup where ( Owner like 'DUN-VMH%' or Owner like 'MDK-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) {
|
||||
$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 class='table-warning'>";
|
||||
}
|
||||
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>";
|
||||
}
|
||||
|
||||
// Outdated
|
||||
$outdated = 0;
|
||||
$answers = Invoke_infra("SELECT * FROM VMs_Backup where ( Owner like 'DUN-VMH%' or Owner like 'MDK-VMH%' ) and name not like 'WS%' and owner not like '%WKG%' and owner not like '%VMH-WM%' and Exclusion ='' and LastResult = 'OK' and TRY_CAST(lastknowngood AS DATE) < CAST(DATEADD(DAY, -2, GETDATE()) AS DATE) 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{
|
||||
if ((date('w') == 1 || date('w') == 7) && $diff->format("%R%a") <= 3){
|
||||
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
|
||||
$answers = Invoke_infra("SELECT * FROM VMs_Backup where ( Owner like 'DUN-VMH%' or Owner like 'MDK-VMH%' ) and name not like 'WS%' and owner not like '%WKG%' and owner not like '%VMH-WM%' and Exclusion ='' and LastResult = 'OK' and TRY_CAST(lastknowngood AS DATE) >= CAST(DATEADD(DAY, -2, GETDATE()) AS DATE) order by name");
|
||||
$total = count($answers);
|
||||
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{
|
||||
if ((date('w') == 1 || date('w') == 7) && $diff->format("%R%a") <= 3){
|
||||
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%' or Owner like 'MDK-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>
|
||||
</div>
|
||||
</div>
|
||||
<!-- End of main content -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
$success = $total - $er - $outdated -$excluded ;
|
||||
$ERR = "VMs backups (<span class='text-light'>".$total." Success</span> - <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>
|
||||
|
||||
<SCRIPT>
|
||||
$(document).ready(function() {
|
||||
$('#t1').DataTable({
|
||||
scrollY: '50vh',
|
||||
scrollCollapse: true,
|
||||
paging: false,
|
||||
});
|
||||
});
|
||||
|
||||
$(function () {
|
||||
var options = $('#t1').bootstrapTable('getOptions');
|
||||
options.height= document.getElementById('content').clientHeight-170;
|
||||
$('#t1').bootstrapTable('refreshOptions',options);
|
||||
});
|
||||
|
||||
function tableresize() {
|
||||
var options = $('#t1').bootstrapTable('getOptions');
|
||||
options.height= document.getElementById('content').clientHeight-170;
|
||||
$('#t1').bootstrapTable('refreshOptions',options);
|
||||
};
|
||||
|
||||
window.addEventListener("resize", tableresize);
|
||||
|
||||
document.getElementById("ERR").innerHTML = "<?php echo $ERR ; ?>";
|
||||
|
||||
</script>
|
||||
@@ -97,9 +97,10 @@
|
||||
echo "</div>";
|
||||
echo "<div class='col'>";
|
||||
echo "
|
||||
<div class='progress' style='border: 1px solid grey; height: 25px;'>
|
||||
<div class='progress-bar bg-dark progress-bar-striped' role='progressbar' style='width: $pcent_restant%;' aria-valuenow='$pcent_restant' aria-valuemin='0' aria-valuemax='100'></div>
|
||||
<div class='progress-bar $color' role='progressbar' style='width: $pcent%;' aria-valuenow='$pcent' aria-valuemin='0' aria-valuemax='100'></div>
|
||||
<div class='progress' style='position: relative; border: 1px solid grey; height: 25px;'>
|
||||
<div class='progress-bar bg-dark progress-bar-striped' role='progressbar' style='width:". $pcent_restant ."%;' aria-valuenow='".$pcent_restant."' aria-valuemin='0' aria-valuemax='100'></div>
|
||||
<div class='progress-bar ".$color."' role='progressbar' style='width: ".$pcent."%;' aria-valuenow='".$pcent."' aria-valuemin='0' aria-valuemax='100'></div>
|
||||
<div style='position: absolute; left: 50%; transform: translateX(-50%); top: -2px; height: 33px; width: 2px; background-color: orange;'></div>
|
||||
</div>";
|
||||
echo "</div>";
|
||||
echo "</div>" ;
|
||||
|
||||
Reference in New Issue
Block a user