Remove unused PHP files related to Hyper-V and Storage dashboards

- Deleted `cluster-detail2.php`, `constants.inc copy.php`, `D.php`, and `Dashboard2.php`. These files were no longer in use and contributed to unnecessary clutter in the codebase.
- Cleaned up references to removed files.
This commit is contained in:
e025532
2025-07-29 14:02:06 +02:00
parent 1f794e2273
commit 5c7ea9f3fc
70 changed files with 14141 additions and 6259 deletions

View File

@@ -24,130 +24,132 @@
<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 $answers = Invoke_Infra("select * from cmdb_vms where cluster not like 'DMV-VMH-SYN%' and decomtime is null order by name"); ?>
<?php include $_SERVER['DOCUMENT_ROOT'] . "/include/all.php"; ?> <!-- Include All -->
<?php $answers = Invoke_Infra("select * from cmdb_vms where cluster not like 'DMV-VMH-SYN%' and decomtime is null 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%;" >Legacy Hyper-V VM List - <?php echo count($answers); ?> VMs</span></h2>
<!-- 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%;" >Legacy Hyper-V VM List - <?php echo count($answers); ?> VMs</span></h2>
<!-- Main content -->
<div class="container-fluid">
<!-- TABLE -->
<div>
<!-- Main content -->
<div class="container-fluid">
<!-- TABLE -->
<div>
<table class='table table-bordered table-hover table-sm' id='t1' data-height="820" 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>
<tr>
<th data-field='vm' data-sortable='true'>VM</th>
<th data-field='owner' data-sortable='true'>Owner</th>
<th data-field='infos' data-sortable='true'>Infos</th>
<th data-field='PreferedOwner' data-sortable='true'>Prefered Owner</th>
<th data-field='gen-ver' data-sortable='true'>Gen & Version</th>
<th data-field='LastInventory' data-sortable='true'>Last Seen</th>
</tr>
</thead>
<tbody> <!-- Body -->
<?php
foreach ($answers as $row) {
echo "<tr>";
# Name
$state = '<i class="bi bi-question-square-fill text-primary"></i> ';
if($row['State'] == "Running"){$state = '<i class="bi bi-play-btn-fill text-success"></i> ';}
if($row['State'] == "Off" || $row['State'] == "Stopping"){$state = '<i class="bi bi-stop-btn-fill text-danger"></i> ';}
if($row['State'] == "Paused"){$state = '<i class="bi bi-pause-btn-fill text-warning"></i> ';}
echo "<td>".$state." <b>".$row['Name']."</td>";
# Owner
echo "<td>".$row['Owner']."</td>";
# Infos
echo '<td><span class="badge rounded-pill bg-secondary text-light">'.$row['Memory'].'GB / '.$row['CPU'].' CPU</span> ';
echo '<span class="badge rounded-pill bg-secondary text-light">VHDx(s) : '.$row['TotalDiskSize'].' GB</span> ';
if($row['WWPNs'] != ""){
echo '<span class="badge rounded-pill bg-primary text-light">LUN(s)</span> ';
}
if($row['DynamicVHD'] == "Y"){
echo '<span class="badge rounded-pill bg-secondary text-warning">Dyn. VHDX</span> ';
}
echo "</td>";
# Prefered Owner
if($row['Owner'] == $row['PreferredOwner']){
echo '<td><span class="badge rounded-pill bg-success text-light">'.$row['Owner'].'</span></td> ';
}else{
if($row['IsClustered'] == 'True'){
echo '<td><span class="badge rounded-pill bg-warning text-dark">'.$row['PreferredOwner'].'</span></td> ';
}else{
echo '<td><span class="badge rounded-pill bg-danger text-dark">NOT CLUSTERED</span></td> ';
}
}
# Gen & Ver
echo "<td>";
if($row['Generation'] == "2"){
echo '<span class="badge rounded-pill bg-success text-light">Gen '.$row['Generation'].'</span> ';
}else{
echo '<span class="badge rounded-pill bg-warning text-dark">Gen '.$row['Generation'].'</span> ';
}
if($row['Version'] == "10.0"){
echo '<span class="badge rounded-pill bg-success text-light">Ver '.$row['Version'].'</span> ';
}else{
echo '<span class="badge rounded-pill bg-warning text-dark">Ver '.$row['Version'].'</span> ';
}
echo "</td>";
# TS
echo "<td>".$row['LastInventory']."</td>";
echo "</tr>";
<?php
foreach ($answers as $row) {
echo "<tr>";
# Name
$state = '<i class="bi bi-question-square-fill text-primary"></i> ';
if($row['State'] == "Running"){$state = '<i class="bi bi-play-btn-fill text-success"></i> ';}
if($row['State'] == "Off" || $row['State'] == "Stopping"){$state = '<i class="bi bi-stop-btn-fill text-danger"></i> ';}
if($row['State'] == "Paused"){$state = '<i class="bi bi-pause-btn-fill text-warning"></i> ';}
echo "<td>".$state." <b>".$row['Name']."</td>";
# Owner
echo "<td>".$row['Owner']."</td>";
# Infos
echo '<td><span class="badge rounded-pill bg-secondary text-light">'.$row['Memory'].'GB / '.$row['CPU'].' CPU</span> ';
echo '<span class="badge rounded-pill bg-secondary text-light">VHDx(s) : '.$row['TotalDiskSize'].' GB</span> ';
if($row['WWPNs'] != ""){
echo '<span class="badge rounded-pill bg-primary text-light">LUN(s)</span> ';
}
?>
if($row['DynamicVHD'] == "Y"){
echo '<span class="badge rounded-pill bg-secondary text-warning">Dyn. VHDX</span> ';
}
echo "</td>";
# Prefered Owner
if($row['Owner'] == $row['PreferredOwner']){
echo '<td><span class="badge rounded-pill bg-success text-light">'.$row['Owner'].'</span></td> ';
}else{
if($row['IsClustered'] == 'True'){
echo '<td><span class="badge rounded-pill bg-warning text-dark">'.$row['PreferredOwner'].'</span></td> ';
}else{
echo '<td><span class="badge rounded-pill bg-danger text-dark">NOT CLUSTERED</span></td> ';
}
}
# Gen & Ver
echo "<td>";
if($row['Generation'] == "2"){
echo '<span class="badge rounded-pill bg-success text-light">Gen '.$row['Generation'].'</span> ';
}else{
echo '<span class="badge rounded-pill bg-warning text-dark">Gen '.$row['Generation'].'</span> ';
}
if($row['Version'] == "10.0"){
echo '<span class="badge rounded-pill bg-success text-light">Ver '.$row['Version'].'</span> ';
}else{
echo '<span class="badge rounded-pill bg-warning text-dark">Ver '.$row['Version'].'</span> ';
}
echo "</td>";
# TS
echo "<td>".$row['LastInventory']."</td>";
echo "</tr>";
}
?>
</tbody>
</table>
<br>
</div>
</table>
<br>
</div>
<!-- End of main content -->
</div>
<!-- End of main content -->
</div>
</div>
</div>
</body>
<script src="/js/switch.js"></script>
</HTML>
<SCRIPT>
$(function() {
// Exécution initiale pour définir la hauteur
adjustTableHeight();
// Événement de redimensionnement
$(window).on('resize', function() {
$(function() {
// Exécution initiale pour définir la hauteur
adjustTableHeight();
});
function adjustTableHeight() {
var windowHeight = $(window).height();
var tableTop = $('#t1').offset().top;
var footerHeight = 50; // Hauteur estimée pour d'éventuels éléments en bas
var availableHeight = windowHeight - tableTop - footerHeight;
// Définir une hauteur minimale
availableHeight = Math.max(availableHeight, 400);
$('#t1').bootstrapTable('refreshOptions', {
height: availableHeight
});
}
});
// Événement de redimensionnement
$(window).on('resize', function() {
adjustTableHeight();
});
function adjustTableHeight() {
const table = $('#t1');
const windowHeight = $(window).height();
const tableTop = table.offset().top;
const footerHeight = 50; // Hauteur estimée pour d'éventuels éléments en bas
let availableHeight = windowHeight - tableTop - footerHeight;
// Définir une hauteur minimale
availableHeight = Math.max(availableHeight, 400);
table.bootstrapTable('refreshOptions', {
height: availableHeight
});
}
});
</script>

View File

@@ -24,129 +24,208 @@
<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 include $_SERVER['DOCUMENT_ROOT'] . "/include/all.php"; ?> <!-- Include All -->
<!-- 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%;" >VM Storage (migration phase)</span></h2>
<!-- 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%;" >VM Storage (migration phase)</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>
<!-- 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 text-center">
<i class="bi bi-hourglass-split"></i><br> Work in progress ...
</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>
<!-- TABLE -->
<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>
<tr>
<th data-field='vm' data-sortable='true'>VM</th>
<th data-field='Last Backup' data-sortable='true'>Legacy Host</th>
<th data-field='Last Result' data-sortable='true'>Destination Host</th>
<th data-field='Last Good' data-sortable='true'>VHDX Storage</th>
<th data-field='Size' data-sortable='true'>VNX Luns</th>
<th data-field='Host' data-sortable='true'>SVC Luns</th>
</tr>
</thead>
<tbody> <!-- Body -->
<?php
$answers = Invoke_Infra("SELECT * FROM cmdb_vms where (owner like '%DUN%' or owner like '%mdk%') and owner not like '%VMH-WM%' and owner not like '%WKG%' and DecomTime is null order by name");
$clusters = Invoke_WebInfraTools("select distinct hostname from storage_lun where hostname like '%-c1%'");
$lunsVNX = Invoke_WebInfraTools("select * from storage_lun where baie = 'VNX'");
$lunsSVC = Invoke_WebInfraTools("select * from storage_lun where baie = 'SVC'");
foreach ($answers as $row) {
echo "<tr>";
echo "<td>".$row['Name']."</td>";
if(strpos($row['Owner'],"SYN") !== false || strpos($row['Owner'],"MIG") !== false){
echo "<td></td><td>".$row['Owner']."</td>";
}else{
echo "<td>".$row['Owner']."</td><td></td>";
}
echo "<td>".str_replace(".vhdx,"," : ",str_replace("|","GB<br>",$row['VHDXs']))."GB</td>";
if($row['WWPNs'] != ""){
echo "<td>";
foreach($lunsVNX as $lun){
if($lun['hostname'] == $row['Name']){
echo explode("_",$lun['name'])[1]." : ".$lun['size']."GB<br>\n";
}
}
echo "</td>";
echo "<td>";
foreach($lunsSVC as $lun){
if($lun['hostname'] == $row['Name']){
echo $lun['name']." : ".$lun['size']."GB<br>\n";
}
}
echo "</td>";
<tbody> <!-- Body -->
<?php
// --- STEP 1: DATA FETCHING ---
// Fetch all necessary data with the minimum number of queries.
}else{echo "<td></td><td></td>";}
echo "</tr>";
// Fetch all VMs
$vms = Invoke_Infra("SELECT Name, Owner, VHDXs, WWPNs FROM cmdb_vms WHERE (owner LIKE '%DUN%' OR owner LIKE '%mdk%') AND owner NOT LIKE '%VMH-WM%' AND owner NOT LIKE '%WKG%' AND DecomTime IS NULL ORDER BY name");
// Fetch all relevant LUNs (both VNX and SVC) in a SINGLE query.
// This is much more efficient than fetching them separately and then querying again in a loop.
$all_luns = Invoke_WebInfraTools("SELECT hostname, baie, name, size FROM storage_lun WHERE baie IN ('VNX', 'SVC')");
// --- STEP 2: DATA PROCESSING ---
// Organize the LUNs into an associative array for very fast lookups.
// The key will be the hostname, and the value will be an array of its LUNs.
$luns_by_hostname = [];
foreach ($all_luns as $lun) {
$hostname = $lun['hostname'];
// Initialize the array for this hostname if it's the first time we see it.
if (!isset($luns_by_hostname[$hostname])) {
$luns_by_hostname[$hostname] = [
'VNX' => [],
'SVC' => []
];
}
foreach ($clusters as $row) {
$lunsVNX = Invoke_WebInfraTools("select * from storage_lun where baie = 'VNX' and hostname = '".$row['hostname']."' order by name");
$lunsSVC = Invoke_WebInfraTools("select * from storage_lun where baie = 'SVC' and hostname = '".$row['hostname']."' order by name");
echo "<tr>";
echo "<td>".$row['hostname']." (Cluster)</td>";
echo "<td></td><td></td><td></td>";
echo "<td>";
foreach($lunsVNX as $lun){
if($lun['hostname'] == $row['hostname']){
echo explode("_",$lun['name'])[1]." : ".$lun['size']."GB<br>\n";
}
}
echo "</td>";
echo "<td>";
foreach($lunsSVC as $lun){
if($lun['hostname'] == $row['hostname']){
echo $lun['name']." : ".$lun['size']."GB<br>\n";
}
}
echo "</td>";
// Add the LUN to the correct category (VNX or SVC) for its host.
$luns_by_hostname[$hostname][$lun['baie']][] = $lun;
}
// Get the list of cluster hostnames from the LUNs we already fetched.
// This avoids an extra database query for clusters.
$cluster_hostnames = [];
foreach ($luns_by_hostname as $hostname => $luns) {
if (str_contains($hostname, '-c1')) {
$cluster_hostnames[] = $hostname;
}
}
sort($cluster_hostnames); // Sort them alphabetically
// --- STEP 3: RENDERING ---
// Now, loop through the prepared data and render the HTML.
// Use htmlspecialchars() on all output to prevent XSS attacks.
/**
* Helper function to render LUNs for a specific host, avoiding duplicates.
* This avoids code duplication and handles redundant data from the DB.
* @param array $luns The array of LUNs for a specific host.
* @param string $type 'VNX' or 'SVC'.
* @return string The generated HTML for the table cell.
*/
function renderLuns(array $luns, string $type): string {
$html = "<td>";
$rendered_luns = []; // Array to track what has been rendered
if (!empty($luns)) {
foreach ($luns as $lun) {
$lun_name = ($type === 'VNX' && str_contains($lun['name'], '_')) ? explode("_", $lun['name'])[1] : $lun['name'];
$lun_size = $lun['size'];
// Create a unique key for this LUN to detect duplicates
$unique_key = $lun_name . ':' . $lun_size;
// If we have already rendered this exact LUN, skip it
if (in_array($unique_key, $rendered_luns)) {
continue;
}
// Render the LUN and add its key to our tracking array
$html .= htmlspecialchars($lun_name) . " : " . htmlspecialchars($lun_size) . "GB<br>\n";
$rendered_luns[] = $unique_key;
}
echo "</tr>";
?>
</tbody>
</table>
<br>
</div>
}
$html .= "</td>";
return $html;
}
// Render rows for VMs
foreach ($vms as $vm) {
echo "<tr>";
echo "<td>" . htmlspecialchars($vm['Name']) . "</td>";
if (str_contains($vm['Owner'], "SYN") || str_contains($vm['Owner'], "MIG")) {
echo "<td></td><td>" . htmlspecialchars($vm['Owner']) . "</td>";
} else {
echo "<td>" . htmlspecialchars($vm['Owner']) . "</td><td></td>";
}
// --- CORRECTED VHDX RENDERING ---
$vhdx_parts = [];
if (!empty($vm['VHDXs'])) {
// 1. Split the string into an array of individual VHDX entries
$vhdx_entries = explode('|', $vm['VHDXs']);
foreach ($vhdx_entries as $entry) {
// 2. Replace the first comma (after .vhdx) with " : " and add "GB"
// The limit parameter '2' ensures we only replace the first occurrence.
$formatted_entry = preg_replace('/\.vhdx,/', ' : ', $entry, 1) . 'GB';
$vhdx_parts[] = $formatted_entry;
}
}
// 3. Join all formatted parts with a comma and a space
echo "<td>" . implode('<br>', $vhdx_parts) . "</td>";
if ($vm['WWPNs'] != "") {
$hostname = $vm['Name'];
$vnx_luns = $luns_by_hostname[$hostname]['VNX'] ?? [];
$svc_luns = $luns_by_hostname[$hostname]['SVC'] ?? [];
echo renderLuns($vnx_luns, 'VNX');
echo renderLuns($svc_luns, 'SVC');
} else {
echo "<td></td><td></td>";
}
echo "</tr>";
}
// Render rows for Clusters
foreach ($cluster_hostnames as $hostname) {
echo "<tr>";
echo "<td>" . htmlspecialchars($hostname) . " (Cluster)</td>";
echo "<td></td><td></td><td></td>"; // Empty cells for Legacy, Destination, VHDX
$vnx_luns = $luns_by_hostname[$hostname]['VNX'] ?? [];
$svc_luns = $luns_by_hostname[$hostname]['SVC'] ?? [];
echo renderLuns($vnx_luns, 'VNX');
echo renderLuns($svc_luns, 'SVC');
echo "</tr>";
}
?>
</tbody>
</tbody>
</table>
<br>
</div>
<!-- End of main content -->
</div>
<!-- End of main content -->
</div>
</div>
</div>
</body>
<script src="/js/switch.js"></script>
</HTML>
<SCRIPT>
const table = $('#t1');
$(document).ready(function() {
$('#t1').DataTable({
table.DataTable({
scrollY: '50vh',
scrollCollapse: true,
paging: false,
@@ -154,19 +233,15 @@
});
$(function () {
var options = $('#t1').bootstrapTable('getOptions');
const options = table.bootstrapTable('getOptions');
options.height= document.getElementById('content').clientHeight-170;
$('#t1').bootstrapTable('refreshOptions',options);
table.bootstrapTable('refreshOptions',options);
});
function tableresize() {
var options = $('#t1').bootstrapTable('getOptions');
const options = table.bootstrapTable('getOptions');
options.height= document.getElementById('content').clientHeight-170;
$('#t1').bootstrapTable('refreshOptions',options);
};
table.bootstrapTable('refreshOptions',options);
}
window.addEventListener("resize", tableresize);
document.getElementById("ERR").innerHTML = "<?php echo $ERR ; ?>";
</script>

View File

@@ -24,161 +24,163 @@
<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 $answers = Invoke_Infra("select * from cmdb_vms where cluster like 'DMV-VMH-SYN%' and decomtime is null order by name"); ?>
<?php include $_SERVER['DOCUMENT_ROOT'] . "/include/all.php"; ?> <!-- Include All -->
<?php $answers = Invoke_Infra("select * from cmdb_vms where cluster like 'DMV-VMH-SYN%' and decomtime is null 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%;" >Synergy VM List - <?php echo count($answers); ?> VMs</span></h2>
<!-- 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%;" >Synergy VM List - <?php echo count($answers); ?> VMs</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>
<!-- 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 text-center">
<i class="bi bi-hourglass-split"></i><br> Work in progress ...
</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>
<!-- TABLE -->
<div>
<div id="result" class="text-center"></div>
</div>
<!-- TABLE -->
<div>
<div id="result" class="text-center"></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>
<tr>
<th data-field='vm' data-sortable='true'>VM</th>
<th data-field='owner' data-sortable='true'>Owner</th>
<th data-field='infos' data-sortable='true'>Infos</th>
<th data-field='PreferedOwner' data-sortable='true'>Prefered Owner</th>
<th data-field='gen-ver' data-sortable='true'>Gen & Version</th>
<th data-field='LastInventory' data-sortable='true'>Last Seen</th>
</tr>
</thead>
<tbody> <!-- Body -->
<?php
$wrongOwner = $unclustered = $v10 = 0 ; $msg ="" ; $CpuComp = 0; $DynVHD = 0;
foreach ($answers as $row) {
echo "<tr>";
# Name
$state = '<i class="bi bi-question-square-fill text-primary"></i> ';
if($row['State'] == "Running"){$state = '<i class="bi bi-play-btn-fill text-success"></i> ';}
if($row['State'] == "Off" || $row['State'] == "Stopping"){$state = '<i class="bi bi-stop-btn-fill text-danger"></i> ';}
if($row['State'] == "Paused"){$state = '<i class="bi bi-pause-btn-fill text-warning"></i> ';}
echo "<td>".$state." <b>".$row['Name']."</td>";
# Owner
echo "<td>".$row['Owner']."</td>";
# Infos
echo '<td><span class="badge rounded-pill bg-secondary text-light">'.$row['Memory'].'GB / '.$row['CPU'].' CPU</span> ';
echo '<span class="badge rounded-pill bg-secondary text-light">VHDx(s) : '.$row['TotalDiskSize'].' GB</span> ';
if($row['WWPNs'] != ""){
echo '<span class="badge rounded-pill bg-primary text-light">LUN(s)</span> ';
}
if($row['CPUcomp'] == "True"){
echo '<span class="badge rounded-pill bg-warning text-dark">CPU Comp.</span> '; $CpuComp++;
}
if($row['DynamicVHD'] == "Y"){
echo '<span class="badge rounded-pill bg-secondary text-warning">Dyn. VHDX</span> '; $DynVHD++;
}
echo "</td>";
# Prefered Owner
if($row['Owner'] == $row['PreferredOwner']){
echo '<td><span class="badge rounded-pill bg-success text-light">'.$row['Owner'].'</span></td> ';
}else{
if($row['IsClustered'] == 'True'){
echo '<td><span class="badge rounded-pill bg-warning text-dark">'.$row['Owner'].'</span></td> ';
$wrongOwner++;
}else{
echo '<td><span class="badge rounded-pill bg-danger text-dark">NOT CLUSTERED</span></td> ';
$unclustered++;
}
}
# Gen & Ver
echo "<td>";
if($row['Generation'] == "2"){
echo '<span class="badge rounded-pill bg-success text-light">Gen '.$row['Generation'].'</span> ';
}else{
echo '<span class="badge rounded-pill bg-warning text-dark">Gen '.$row['Generation'].'</span> ';
}
if($row['Version'] == "10.0"){
echo '<span class="badge rounded-pill bg-success text-light">Ver '.$row['Version'].'</span> ';
}else{
echo '<span class="badge rounded-pill bg-warning text-dark">Ver '.$row['Version'].'</span> ';
$v10++;
}
echo "</td>";
# TS
echo "<td>".$row['LastInventory']."</td>";
echo "</tr>";
<?php
$wrongOwner = $unclustered = $v10 = 0 ; $msg ="" ; $CpuComp = 0; $DynVHD = 0;
foreach ($answers as $row) {
echo "<tr>";
# Name
$state = '<i class="bi bi-question-square-fill text-primary"></i> ';
if($row['State'] == "Running"){$state = '<i class="bi bi-play-btn-fill text-success"></i> ';}
if($row['State'] == "Off" || $row['State'] == "Stopping"){$state = '<i class="bi bi-stop-btn-fill text-danger"></i> ';}
if($row['State'] == "Paused"){$state = '<i class="bi bi-pause-btn-fill text-warning"></i> ';}
echo "<td>".$state." <b>".$row['Name']."</td>";
# Owner
echo "<td>".$row['Owner']."</td>";
# Infos
echo '<td><span class="badge rounded-pill bg-secondary text-light">'.$row['Memory'].'GB / '.$row['CPU'].' CPU</span> ';
echo '<span class="badge rounded-pill bg-secondary text-light">VHDx(s) : '.$row['TotalDiskSize'].' GB</span> ';
if($row['WWPNs'] != ""){
echo '<span class="badge rounded-pill bg-primary text-light">LUN(s)</span> ';
}
if($wrongOwner > 0){$msg = "<span class='badge bg-warning text-dark'>$wrongOwner VM(s) on Wrong Owner</span>";}
if($unclustered > 0){$msg .= "&nbsp;<span class='badge bg-danger'>$unclustered VM(s) Unclustered</span>";}
if($v10 > 0){$msg .= "&nbsp;<span class='badge bg-warning text-dark'>$v10 VM(s) < Ver 10.0</span>";}
if($CpuComp > 0){$msg .= "&nbsp;<span class='badge bg-warning text-dark'>$CpuComp VM(s) With 'CPU Compatibility' checked</span>";}
if($DynVHD > 0){$msg .= "&nbsp;<span class='badge bg-secondary text-warning'>$DynVHD VM(s) With Dynamic VHDx</span>";}
?>
</tbody>
</table>
<br>
</div>
if($row['CPUcomp'] == "True"){
echo '<span class="badge rounded-pill bg-warning text-dark">CPU Comp.</span> '; $CpuComp++;
}
if($row['DynamicVHD'] == "Y"){
echo '<span class="badge rounded-pill bg-secondary text-warning">Dyn. VHDX</span> '; $DynVHD++;
}
echo "</td>";
# Prefered Owner
if($row['Owner'] == $row['PreferredOwner']){
echo '<td><span class="badge rounded-pill bg-success text-light">'.$row['Owner'].'</span></td> ';
}else{
if($row['IsClustered'] == 'True'){
echo '<td><span class="badge rounded-pill bg-warning text-dark">'.$row['Owner'].'</span></td> ';
$wrongOwner++;
}else{
echo '<td><span class="badge rounded-pill bg-danger text-dark">NOT CLUSTERED</span></td> ';
$unclustered++;
}
}
# Gen & Ver
echo "<td>";
if($row['Generation'] == "2"){
echo '<span class="badge rounded-pill bg-success text-light">Gen '.$row['Generation'].'</span> ';
}else{
echo '<span class="badge rounded-pill bg-warning text-dark">Gen '.$row['Generation'].'</span> ';
}
if($row['Version'] == "10.0"){
echo '<span class="badge rounded-pill bg-success text-light">Ver '.$row['Version'].'</span> ';
}else{
echo '<span class="badge rounded-pill bg-warning text-dark">Ver '.$row['Version'].'</span> ';
$v10++;
}
echo "</td>";
# TS
echo "<td>".$row['LastInventory']."</td>";
echo "</tr>";
}
if($wrongOwner > 0){$msg = "<span class='badge bg-warning text-dark'>$wrongOwner VM(s) on Wrong Owner</span>";}
if($unclustered > 0){$msg .= "&nbsp;<span class='badge bg-danger'>$unclustered VM(s) Unclustered</span>";}
if($v10 > 0){$msg .= "&nbsp;<span class='badge bg-warning text-dark'>$v10 VM(s) < Ver 10.0</span>";}
if($CpuComp > 0){$msg .= "&nbsp;<span class='badge bg-warning text-dark'>$CpuComp VM(s) With 'CPU Compatibility' checked</span>";}
if($DynVHD > 0){$msg .= "&nbsp;<span class='badge bg-secondary text-warning'>$DynVHD VM(s) With Dynamic VHDx</span>";}
?>
</tbody>
</table>
<br>
</div>
<!-- End of main content -->
</div>
<!-- End of main content -->
</div>
</div>
</div>
</body>
<script src="/js/switch.js"></script>
</HTML>
<SCRIPT>
$(function() {
// Exécution initiale pour définir la hauteur
adjustTableHeight();
// Événement de redimensionnement
$(window).on('resize', function() {
$(function() {
const table = $('#t1');
// Exécution initiale pour définir la hauteur
adjustTableHeight();
});
function adjustTableHeight() {
var windowHeight = $(window).height();
var tableTop = $('#t1').offset().top;
var footerHeight = 50; // Hauteur estimée pour d'éventuels éléments en bas
var availableHeight = windowHeight - tableTop - footerHeight;
// Définir une hauteur minimale
availableHeight = Math.max(availableHeight, 400);
$('#t1').bootstrapTable('refreshOptions', {
height: availableHeight
// Événement de redimensionnement
$(window).on('resize', function() {
adjustTableHeight();
});
}
});
function adjustTableHeight() {
const windowHeight = $(window).height();
const tableTop = table.offset().top;
const footerHeight = 50; // Hauteur estimée pour d'éventuels éléments en bas
let availableHeight = windowHeight - tableTop - footerHeight;
// Définir une hauteur minimale
availableHeight = Math.max(availableHeight, 400);
table.bootstrapTable('refreshOptions', {
height: availableHeight
});
}
});
document.getElementById("result").innerHTML = "<?php echo "<h4>".$msg."</h4>" ; ?>";
</script>

View File

@@ -30,10 +30,6 @@
<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">
@@ -54,8 +50,8 @@
<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 class="modal-title mb-1 text-dark text-uppercase text-center">
<i class="bi bi-hourglass-split"></i><br> Work in progress ...
</h4>
</div>
<div class="modal-body">
@@ -70,6 +66,7 @@
<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 -->
<tr>
<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>
@@ -77,6 +74,7 @@
<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>
</tr>
</thead>
<tbody> <!-- Body -->
@@ -219,28 +217,31 @@
</HTML>
<SCRIPT>
$(document).ready(function() {
$('#t1').DataTable({
scrollY: '50vh',
scrollCollapse: true,
paging: false,
$(function() {
// Exécution initiale pour définir la hauteur
adjustTableHeight();
// Événement de redimensionnement
$(window).on('resize', function() {
adjustTableHeight();
});
function adjustTableHeight() {
const table = $('#t1');
const windowHeight = $(window).height();
const tableTop = table.offset().top;
const footerHeight = 50; // Hauteur estimée pour d'éventuels éléments en bas
let availableHeight = windowHeight - tableTop - footerHeight;
// Définir une hauteur minimale
availableHeight = Math.max(availableHeight, 400);
table.bootstrapTable('refreshOptions', {
height: availableHeight
});
}
});
$(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>

View File

@@ -1,246 +0,0 @@
<!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>

View File

@@ -24,184 +24,199 @@
<script src="/js/chart.min.js"></script>
<script src="/js/apexcharts.min.js"></script>
<!-- Gauge -->
<link rel="stylesheet" href="/css/gauge.css">
<link rel="stylesheet" href="/css/Gauge.css">
<script src="/js/jquery.AshAlom.gaugeMeter-2.0.0.min.js"></script>
</head>
<body class="bg-light text-dark">
<?php include $_SERVER['DOCUMENT_ROOT'] . "/include/all.php"; ?> <!-- Database connexion -->
<div class="container-fluid">
<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"; ?> <!-- Left Navbar -->
</div>
<!-- Display -->
<div class="col py-3">
<!-- Page Title -->
<h1><span class="badge text-bg-secondary font-weight-bold" style="width:100%;"><?php $_GET['cluster']." Details" ; ?></span></h1>
<?php include $_SERVER['DOCUMENT_ROOT'] . "/include/all.php"; ?> <!-- Database connexion -->
<div class="container-fluid">
<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"; ?> <!-- Left Navbar -->
</div>
<!-- Display -->
<div class="col py-3">
<!-- Page Title -->
<h1><span class="badge text-bg-secondary font-weight-bold"
style="width:100%;"><?php echo $_GET['cluster'] . " Details"; ?></span></h1>
<!-- Main content -->
<!-- Main content -->
<?php
$clusters = Invoke_Infra("select * from cmdb_HyperV_Hosts where cluster ='" . $_GET['cluster'] . "' order by node");
$vmmem = (Invoke_Infra("select sum(cast(vm_memory as int)) as vmem from cmdb_HyperV_Hosts where cluster ='" . $_GET['cluster'] . "'"))[0]['vmem'];
$clumem = (invoke_infra("select min(node_ram) as nmem from cmdb_HyperV_Hosts where cluster ='" . $_GET['cluster'] . "'"))[0]['nmem'];
$nb = (invoke_infra("select count(node) as nb from cmdb_HyperV_Hosts where cluster ='" . $_GET['cluster'] . "'"))[0]['nb'];
$clmem = $clumem - 32;
if ($nb == 4) {
$clmem = $clmem * 2;
}
?>
<div class="container-fluid" style="zoom:100%">
<h2><span class="badge text-bg-secondary font-weight-bold"
style="width:100%;"><?php echo $_GET['cluster']; ?></span></h2>
<?php
$clusters = Invoke_Infra("select * from cmdb_HyperV_Hosts where cluster ='".$_GET['cluster']."' order by node");
$vmmem = (Invoke_Infra("select sum(cast(vm_memory as int)) as vmem from cmdb_HyperV_Hosts where cluster ='".$_GET['cluster']."'"))[0]['vmem'];
$clumem = (invoke_infra("select min(node_ram) as nmem from cmdb_HyperV_Hosts where cluster ='".$_GET['cluster']."'"))[0]['nmem'];
$nb = (invoke_infra("select count(node) as nb from cmdb_HyperV_Hosts where cluster ='".$_GET['cluster']."'"))[0]['nb'];
$clmem = $clumem-32; if($nb == 4){$clmem = $clmem*2;}
?>
<div class="container-fluid" style="zoom:100%">
<h2><span class="badge text-bg-secondary font-weight-bold" style="width:100%;"><?php echo $_GET['cluster']; ?></span></h2>
<?php
echo "<b>Worst Failover scenario available memory : </b>".($clmem - $vmmem). " / " .$clmem. " GB";
$pcent = round(($clmem - $vmmem)/$clmem*100);
$pcent_restant = 100 - $pcent;
if($pcent <= 5){
$color = "bg-danger"; $border = "red";
}else{
if($pcent <= 10){
$color = "bg-warning"; $border = "yellow";
}else{
$color = "bg-success"; $border = "green";
}
echo "<b>Worst Failover scenario available memory : </b>" . ($clmem - $vmmem) . " / " . $clmem . " GB";
$pcent = round(($clmem - $vmmem) / $clmem * 100);
$pcent_restant = 100 - $pcent;
if ($pcent <= 5) {
$color = "bg-danger";
$border = "red";
} else {
if ($pcent <= 10) {
$color = "bg-warning";
$border = "yellow";
} else {
$color = "bg-success";
$border = "green";
}
echo "
}
echo "
<div class='progress' style='border: 2px solid $border; 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>";
echo "<br>";
?>
<div class="row">
<?php
echo "<br>";
?>
<div class="row">
<?php
foreach ($clusters as $cluster) {
echo "<div class='col-6'>";
$nbvm = Invoke_Infra("select count(*) as nbvm, sum(memory) as vmmem from cmdb_vms where owner ='".$cluster['node']."' and decomtime is null");
echo '<h3><span class="badge text-bg-secondary font-weight-bold" style="width:100%;">'.$cluster['node']." - ".$nbvm[0]['nbvm']." VMs <small><small> <i class='bi bi-clock'></i> ".$cluster['ts']."</small></small></span></h3><br>";
#Memory
echo "<div class='row'>";
echo "<div class='col'>";
echo "<b>Free Memory : </b>".($cluster['node_ram'] - 32 - $nbvm[0]['vmmem']). " / " .($cluster['node_ram'] - 32). " GB";
$pcent = round(($cluster['node_ram'] - 32 - $nbvm[0]['vmmem'])/($cluster['node_ram'] - 32)*100);
$pcent_restant = 100 - $pcent;
if($pcent <= 5){
$color = "bg-danger";
}else{
if($pcent <= 10){
$color = "bg-warning";
}else{
$color = "bg-success";
}
}
$progress_bar_height = '25px';
$marker_overlap = 5;
$marker_height = (int)$progress_bar_height + (2 * $marker_overlap);
$marker_top = -$marker_overlap;
echo "</div>";
echo "
$nbvm = Invoke_Infra("select count(*) as nbvm, sum(memory) as vmmem from cmdb_vms where owner ='" . $cluster['node'] . "' and decomtime is null");
echo '<h3><span class="badge text-bg-secondary font-weight-bold" style="width:100%;">' . $cluster['node'] . " - " . $nbvm[0]['nbvm'] . " VMs <small><small> <i class='bi bi-clock'></i> " . $cluster['ts'] . "</small></small></span></h3><br>";
#Memory
echo "<div class='row'>";
echo "<div class='col'>";
echo "<b>Free Memory : </b>" . ($cluster['node_ram'] - 32 - $nbvm[0]['vmmem']) . " / " . ($cluster['node_ram'] - 32) . " GB";
$pcent = round(($cluster['node_ram'] - 32 - $nbvm[0]['vmmem']) / ($cluster['node_ram'] - 32) * 100);
$pcent_restant = 100 - $pcent;
if ($pcent <= 5) {
$color = "bg-danger";
} else {
if ($pcent <= 10) {
$color = "bg-warning";
} else {
$color = "bg-success";
}
}
$progress_bar_height = '25px';
$marker_overlap = 5;
$marker_height = (int)$progress_bar_height + (2 * $marker_overlap);
$marker_top = -$marker_overlap;
echo "</div>";
echo "
<div style='position: relative; display: inline-block;'>
<div class='progress' style='border: 1px solid grey; height: ".$progress_bar_height."; margin-bottom: ".(2 * $marker_overlap)."px;'>
<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='border: 1px solid grey; height: " . $progress_bar_height . "; margin-bottom: " . (2 * $marker_overlap) . "px;'>
<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>
<div style='
position: absolute;
left: 50%;
transform: translateX(-50%);
top: ".$marker_top."px;
height: ".$marker_height."px;
top: " . $marker_top . "px;
height: " . $marker_height . "px;
width: 2px;
background-color: orange;
z-index: 1;
'></div>
</div>";
echo "</div>" ;
echo "<br>";
#Storage
echo "<div class='row'>";
foreach(explode("|",$cluster['csvs']) as $csv){
if(strpos($csv,";") != false){
echo "<div class='col'>";
echo "<b>" . explode(";",$csv)[0];
$total = explode(";",$csv)[1]; $used = explode(";",$csv)[2]; $free = $total-$used ;
echo " Free : </b>".$free."/" .$total. " GB";
echo "</div>";
echo "<div class='col'>";
$pcent = round($free/$total*100);
$pcent_restant = 100 - $pcent;
if($pcent <= 10){
$color = "bg-danger";
}else{
if($pcent <= 20){
$color = "bg-warning";
}else{
$color = "bg-success";
}
}
echo "
echo "</div>";
echo "<br>";
#Storage
echo "<div class='row'>";
foreach (explode("|", $cluster['csvs']) as $csv) {
if (strpos($csv, ";")) {
echo "<div class='col'>";
echo "<b>" . explode(";", $csv)[0];
$total = explode(";", $csv)[1];
$used = explode(";", $csv)[2];
$free = $total - $used;
echo " Free : </b>" . $free . "/" . $total . " GB";
echo "</div>";
echo "<div class='col'>";
$pcent = round($free / $total * 100);
$pcent_restant = 100 - $pcent;
if ($pcent <= 10) {
$color = "bg-danger";
} else {
if ($pcent <= 20) {
$color = "bg-warning";
} else {
$color = "bg-success";
}
}
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>";
echo "</div>";
}else{echo "<div class='col'></div><br>";}
}
echo "</div>";
echo "<hr>";
#VMs
$vms = Invoke_Infra("select * from cmdb_vms where owner ='".$cluster['node']."' and decomtime is null order by name");
foreach($vms as $vm){
echo "<div class='row'>";
echo "<div class='col'>";
$state = '<i class="bi bi-question-square-fill text-primary"></i> ';
if($vm['State'] == "Running"){$state = '<i class="bi bi-play-btn-fill text-success"></i> ';}
if($vm['State'] == "Off" || $vm['State'] == "Stopping"){$state = '<i class="bi bi-stop-btn-fill text-danger"></i> ';}
if($vm['State'] == "Paused"){$state = '<i class="bi bi-pause-btn-fill text-warning"></i> ';}
if(strpos($vm['Name'],'WS') === 0){
echo $state." <b>".substr($vm['Name'],0,10)."</b>";
}else{
echo $state." <b>".$vm['Name']."</b>";
}
echo "</div>";
echo "<div class='col'>";
echo '<span class="badge rounded-pill bg-secondary text-light">'.$vm['Memory'].'GB / '.$vm['CPU'].' CPU</span> ';
if($vm['WWPNs'] != ""){
echo '<span class="badge rounded-pill bg-primary text-light">LUN(s)</span> ';
}
#echo "</div>";
#echo "<div class='col'>";
if($vm['IsClustered'] != "True"){
echo '<span class="badge rounded-pill bg-danger text-dark"><small>Unclustered</small></span> ';
}else{
if($vm['Owner'] != $vm['PreferredOwner']){
echo '<span class="badge rounded-pill bg-warning text-dark"><small>Wrong Owner</small></span> ';
}
}
echo "</div>";
echo "<div class='col'>";
echo "</div>";
echo "</div>";
} else {
echo "<div class='col'></div><br>";
}
echo "<br>";
}
echo "</div>";
echo "<hr>";
#VMs
$vms = Invoke_Infra("select * from cmdb_vms where owner ='" . $cluster['node'] . "' and decomtime is null order by name");
foreach ($vms as $vm) {
echo "<div class='row'>";
echo "<div class='col'>";
$state = '<i class="bi bi-question-square-fill text-primary"></i> ';
if ($vm['State'] == "Running") {
$state = '<i class="bi bi-play-btn-fill text-success"></i> ';
}
if ($vm['State'] == "Off" || $vm['State'] == "Stopping") {
$state = '<i class="bi bi-stop-btn-fill text-danger"></i> ';
}
if ($vm['State'] == "Paused") {
$state = '<i class="bi bi-pause-btn-fill text-warning"></i> ';
}
if (str_starts_with($vm['Name'], 'WS')) {
echo $state . " <b>" . substr($vm['Name'], 0, 10) . "</b>";
} else {
echo $state . " <b>" . $vm['Name'] . "</b>";
}
echo "</div>";
echo "<div class='col'>";
echo '<span class="badge rounded-pill bg-secondary text-light">' . $vm['Memory'] . 'GB / ' . $vm['CPU'] . ' CPU</span> ';
if ($vm['WWPNs'] != "") {
echo '<span class="badge rounded-pill bg-primary text-light">LUN(s)</span> ';
}
if ($vm['IsClustered'] != "True") {
echo '<span class="badge rounded-pill bg-danger text-dark"><small>Unclustered</small></span> ';
} else {
if ($vm['Owner'] != $vm['PreferredOwner']) {
echo '<span class="badge rounded-pill bg-warning text-dark"><small>Wrong Owner</small></span> ';
}
}
echo "</div>";
echo "<div class='col'>";
echo "</div>";
echo "</div>";
}
echo "<br>";
echo "</div>";
}
echo "</div>";
?>
</div>
<!-- End of main content -->
?>
</div>
<!-- End of main content -->
</div>
</div>
<script src="/js/switch.js"></script>
</div>
<script src="/js/switch.js"></script>
</body>
<script>

View File

@@ -1,209 +0,0 @@
<!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</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">
<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>
<!-- Chart -->
<script src="/js/chart.min.js"></script>
<script src="/js/apexcharts.min.js"></script>
<!-- Gauge -->
<link rel="stylesheet" href="/css/gauge.css">
<script src="/js/jquery.AshAlom.gaugeMeter-2.0.0.min.js"></script>
</head>
<body class="bg-light text-dark">
<?php include $_SERVER['DOCUMENT_ROOT'] . "/include/all.php"; ?> <!-- Database connexion -->
<div class="container-fluid">
<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"; ?> <!-- Left Navbar -->
</div>
<!-- Display -->
<div class="col py-3">
<!-- Page Title -->
<h1><span class="badge text-bg-secondary font-weight-bold" style="width:100%;"><?php $_GET['cluster']." Details" ; ?></span></h1>
<!-- Main content -->
<?php
$clusters = Invoke_Infra("select * from cmdb_HyperV_Hosts where cluster ='".$_GET['cluster']."' order by node");
$vmmem = (Invoke_Infra("select sum(cast(vm_memory as int)) as vmem from cmdb_HyperV_Hosts where cluster ='".$_GET['cluster']."'"))[0]['vmem'];
$clumem = (invoke_infra("select min(node_ram) as nmem from cmdb_HyperV_Hosts where cluster ='".$_GET['cluster']."'"))[0]['nmem'];
$nb = (invoke_infra("select count(node) as nb from cmdb_HyperV_Hosts where cluster ='".$_GET['cluster']."'"))[0]['nb'];
$clmem = $clumem-32; if($nb == 4){$clmem = $clmem*2;}
?>
<div class="container-fluid" style="zoom:100%">
<h2><span class="badge text-bg-secondary font-weight-bold" style="width:100%;"><?php echo $_GET['cluster']; ?></span></h2>
<?php
echo "<b>Worst Failover scenario available memory : </b>".($clmem - $vmmem). " / " .$clmem. " GB";
$pcent = round(($clmem - $vmmem)/$clmem*100);
$pcent_restant = 100 - $pcent;
if($pcent <= 5){
$color = "bg-danger"; $border = "red";
}else{
if($pcent <= 10){
$color = "bg-warning"; $border = "yellow";
}else{
$color = "bg-success"; $border = "green";
}
}
echo "
<div class='progress' style='border: 2px solid $border; 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>";
echo "<br>";
?>
<div class="row">
<?php
foreach ($clusters as $cluster) {
echo "<div class='col-6'>";
$nbvm = Invoke_Infra("select count(*) as nbvm, sum(memory) as vmmem from cmdb_vms where owner ='".$cluster['node']."' and decomtime is null");
echo '<h3><span class="badge text-bg-secondary font-weight-bold" style="width:100%;">'.$cluster['node']." - ".$nbvm[0]['nbvm']." VMs <small><small> <i class='bi bi-clock'></i> ".$cluster['ts']."</small></small></span></h3><br>";
#Memory
echo "<div class='row'>";
echo "<div class='col'>";
echo "<b>Free Memory : </b>".($cluster['node_ram'] - 32 - $nbvm[0]['vmmem']). " / " .($cluster['node_ram'] - 32). " GB";
$pcent = round(($cluster['node_ram'] - 32 - $nbvm[0]['vmmem'])/($cluster['node_ram'] - 32)*100);
$pcent_restant = 100 - $pcent;
if($pcent <= 5){
$color = "bg-danger";
}else{
if($pcent <= 10){
$color = "bg-warning";
}else{
$color = "bg-success";
}
}
$progress_bar_height = '25px'; // Hauteur de la barre
$marker_overlap = 5; // Dépassement souhaité en px (haut et bas)
$marker_height = (int)$progress_bar_height + (2 * $marker_overlap); // Hauteur totale du marqueur
$marker_top = -$marker_overlap; // Position top du marqueur
echo "</div>";
echo "
<div style='position: relative; display: inline-block;'>
<div class='progress' style='border: 1px solid grey; height: ".$progress_bar_height."; margin-bottom: ".(2 * $marker_overlap)."px;'>
<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>
<div style='
position: absolute;
left: 50%;
transform: translateX(-50%);
top: ".$marker_top."px;
height: ".$marker_height."px;
width: 2px;
background-color: orange;
z-index: 1;
'></div>
</div>";
echo "</div>" ;
echo "<br>";
#Storage
echo "<div class='row'>";
foreach(explode("|",$cluster['csvs']) as $csv){
if(strpos($csv,";") != false){
echo "<div class='col'>";
echo "<b>" . explode(";",$csv)[0];
$total = explode(";",$csv)[1]; $used = explode(";",$csv)[2]; $free = $total-$used ;
echo " Free : </b>".$free."/" .$total. " GB";
echo "</div>";
echo "<div class='col'>";
$pcent = round($free/$total*100);
$pcent_restant = 100 - $pcent;
if($pcent <= 10){
$color = "bg-danger";
}else{
if($pcent <= 20){
$color = "bg-warning";
}else{
$color = "bg-success";
}
}
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>";
echo "</div>";
}else{echo "<div class='col'></div><br>";}
}
echo "</div>";
echo "<hr>";
#VMs
$vms = Invoke_Infra("select * from cmdb_vms where owner ='".$cluster['node']."' and decomtime is null order by name");
foreach($vms as $vm){
echo "<div class='row'>";
echo "<div class='col'>";
$state = '<i class="bi bi-question-square-fill text-primary"></i> ';
if($vm['State'] == "Running"){$state = '<i class="bi bi-play-btn-fill text-success"></i> ';}
if($vm['State'] == "Off" || $vm['State'] == "Stopping"){$state = '<i class="bi bi-stop-btn-fill text-danger"></i> ';}
if($vm['State'] == "Paused"){$state = '<i class="bi bi-pause-btn-fill text-warning"></i> ';}
if(strpos($vm['Name'],'WS') === 0){
echo $state." <b>".substr($vm['Name'],0,10)."</b>";
}else{
echo $state." <b>".$vm['Name']."</b>";
}
echo "</div>";
echo "<div class='col'>";
echo '<span class="badge rounded-pill bg-secondary text-light">'.$vm['Memory'].'GB / '.$vm['CPU'].' CPU</span> ';
if($vm['WWPNs'] != ""){
echo '<span class="badge rounded-pill bg-primary text-light">LUN(s)</span> ';
}
#echo "</div>";
#echo "<div class='col'>";
if($vm['IsClustered'] != "True"){
echo '<span class="badge rounded-pill bg-danger text-dark"><small>Unclustered</small></span> ';
}else{
if($vm['Owner'] != $vm['PreferredOwner']){
echo '<span class="badge rounded-pill bg-warning text-dark"><small>Wrong Owner</small></span> ';
}
}
echo "</div>";
echo "<div class='col'>";
echo "</div>";
echo "</div>";
}
echo "<br>";
echo "</div>";
}
echo "</div>";
?>
</div>
<!-- End of main content -->
</div>
</div>
</div>
<script src="/js/switch.js"></script>
</body>
<script>
$(".GaugeMeter").gaugeMeter();
</script>

View File

@@ -24,32 +24,32 @@
<script src="/js/chart.min.js"></script>
<script src="/js/apexcharts.min.js"></script>
<!-- Gauge -->
<link rel="stylesheet" href="/css/gauge.css">
<link rel="stylesheet" href="/css/Gauge.css">
<script src="/js/jquery.AshAlom.gaugeMeter-2.0.0.min.js"></script>
</head>
<body class="bg-light text-dark">
<?php include $_SERVER['DOCUMENT_ROOT'] . "/include/all.php"; ?> <!-- Database connexion -->
<div class="container-fluid">
<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"; ?> <!-- Left Navbar -->
</div>
<!-- Display -->
<div class="col py-3">
<!-- Page Title -->
<h1><span class="badge text-bg-secondary font-weight-bold" style="width:100%;">Hyper-V Clusters</span></h1>
<?php include $_SERVER['DOCUMENT_ROOT'] . "/include/all.php"; ?> <!-- Database connexion -->
<div class="container-fluid">
<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"; ?> <!-- Left Navbar -->
</div>
<!-- Display -->
<div class="col py-3">
<!-- Page Title -->
<h1><span class="badge text-bg-secondary font-weight-bold" style="width:100%;">Hyper-V Clusters</span></h1>
<!-- Main content -->
<?php
<!-- Main content -->
<?php
$clusters = Invoke_Infra("select distinct cluster from cmdb_HyperV_Hosts where cluster <> '' and cluster not like '%-WM%' and cluster not like '%-C1MAS%' and cluster not like '%-vrs%' and (cluster like 'DUN%' or cluster like 'DMV%') order by cluster");
?>
<div class="container-fluid" style="zoom:90%">
<div class="row">
?>
<div class="container-fluid" style="zoom:90%">
<div class="row">
<?php
<?php
$count = 0;
$totalleft = 0;
foreach ($clusters as $cluster) {
@@ -65,14 +65,15 @@
$vm_mem = 0;
$disk = 0;
$io = 0;
$node_mem = 0;
$capacity = 0; $free = 0;
foreach ($data as $d) {
$vms += $d['vm_count'];
$vm_mem += $d['vm_memory'];
$node_mem = 0 + (int) $d['node_ram'];
$node_mem = (int) $d['node_ram'];
foreach (explode("|", $d['csvs']) as $csv) {
if (instr($csv, ';')) {
$free += explode(";", $csv)[1] - explode(";", $csv)[2];
$free += intval(explode(";", $csv)[1]) - intval(explode(";", $csv)[2]);
$disk = max($disk, $free);
$capacity += (int) explode(";", $csv)[1];
}
@@ -97,30 +98,30 @@
?>
<div class='col-3'>
<a href="Cluster-detail.php?cluster=<?php echo $cluster['cluster']; ?>" class="text-decoration-none" target="_blank">
<div class='card border-secondary mb-3'>
<div class='card-header text-white bg-dark border-secondary'>
<h4>
<center><?php echo $cluster['cluster']; ?></center>
</h4>
<h6>
<center><b><?php echo $nodes; ?></b> Nodes / <b><?php echo $vms; ?></b> VMs <?php echo $vleft; ?></center>
</h6>
<?php
if((int)$nodes == 2 && $vms > 0){
$Repart = Invoke_Infra("select Owner, count(owner) as nbvm from cmdb_vms where Cluster ='".$cluster['cluster']."' and decomtime is null group by Owner order by Owner");
$vmCountNode1 = $vmCountNode2 = 0;
$node1_name = $node2_name = "";
if(count($Repart) == 1 ){
$node1_name = $Repart[0]['Owner']; $vmCountNode1 = $Repart[0]['nbvm'];
}else{
$node1_name = 'DUN'; $vmCountNode1 = $Repart[0]['nbvm'];
$node2_name = 'MDK'; $vmCountNode2 = $Repart[1]['nbvm'];
}
$totalVMs = $vmCountNode1 + $vmCountNode2;
$percentageNode1 = ($totalVMs > 0) ? ($vmCountNode1 / $totalVMs) * 100 : 0;
$percentageNode2 = ($totalVMs > 0) ? ($vmCountNode2 / $totalVMs) * 100 : 0;
echo "<div class='progress' style='border: 2px solid grey; height: 20px;'>
<a href="cluster-detail.php?cluster=<?php echo $cluster['cluster']; ?>" class="text-decoration-none" target="_blank">
<div class='card border-secondary mb-3'>
<div class='card-header text-white bg-dark border-secondary'>
<h4 class="text-center">
<?php echo $cluster['cluster']; ?>
</h4>
<h6 class="text-center">
<b><?php echo $nodes; ?></b> Nodes / <b><?php echo $vms; ?></b> VMs <?php echo $vleft; ?>
</h6>
<?php
if($nodes == 2 && $vms > 0){
$Repart = Invoke_Infra("select Owner, count(owner) as nbvm from cmdb_vms where Cluster ='".$cluster['cluster']."' and decomtime is null group by Owner order by Owner");
$vmCountNode1 = $vmCountNode2 = 0;
$node1_name = $node2_name = "";
if(count($Repart) == 1 ){
$node1_name = $Repart[0]['Owner']; $vmCountNode1 = $Repart[0]['nbvm'];
}else{
$node1_name = 'DUN'; $vmCountNode1 = $Repart[0]['nbvm'];
$node2_name = 'MDK'; $vmCountNode2 = $Repart[1]['nbvm'];
}
$totalVMs = $vmCountNode1 + $vmCountNode2;
$percentageNode1 = ($totalVMs > 0) ? ($vmCountNode1 / $totalVMs) * 100 : 0;
$percentageNode2 = ($totalVMs > 0) ? ($vmCountNode2 / $totalVMs) * 100 : 0;
echo "<div class='progress' style='border: 2px solid grey; height: 20px;'>
<div class='progress-bar text-white' role='progressbar' style='width:$percentageNode1%' aria-valuenow='$percentageNode1' aria-valuemin='0' aria-valuemax='100'>
<b>$node1_name : $vmCountNode1 VMs</b>
</div>
@@ -128,16 +129,16 @@
<b>$node2_name : $vmCountNode2 VMs</b>
</div>
</div>";
}elseif((int)$nodes == 4){
$RepartD = Invoke_Infra("select count(owner) as nbvm from cmdb_vms where Cluster ='".$cluster['cluster']."' and Owner like 'DUN%' and decomtime is null");
$RepartM = Invoke_Infra("select count(owner) as nbvm from cmdb_vms where Cluster ='".$cluster['cluster']."' and Owner like 'MDK%' and decomtime is null");
$vmCountNode1 = $vmCountNode2 = 0;
$node1_name = 'DUN'; $vmCountNode1 = $RepartD[0]['nbvm'];
$node2_name = 'MDK'; $vmCountNode2 = $RepartM[0]['nbvm'];
$totalVMs = $vmCountNode1 + $vmCountNode2;
$percentageNode1 = ($totalVMs > 0) ? ($vmCountNode1 / $totalVMs) * 100 : 0;
$percentageNode2 = ($totalVMs > 0) ? ($vmCountNode2 / $totalVMs) * 100 : 0;
echo "<div class='progress' style='border: 2px solid grey; height: 20px;'>
}elseif($nodes == 4){
$RepartD = Invoke_Infra("select count(owner) as nbvm from cmdb_vms where Cluster ='".$cluster['cluster']."' and Owner like 'DUN%' and decomtime is null");
$RepartM = Invoke_Infra("select count(owner) as nbvm from cmdb_vms where Cluster ='".$cluster['cluster']."' and Owner like 'MDK%' and decomtime is null");
$vmCountNode1 = $vmCountNode2 = 0;
$node1_name = 'DUN'; $vmCountNode1 = $RepartD[0]['nbvm'];
$node2_name = 'MDK'; $vmCountNode2 = $RepartM[0]['nbvm'];
$totalVMs = $vmCountNode1 + $vmCountNode2;
$percentageNode1 = ($totalVMs > 0) ? ($vmCountNode1 / $totalVMs) * 100 : 0;
$percentageNode2 = ($totalVMs > 0) ? ($vmCountNode2 / $totalVMs) * 100 : 0;
echo "<div class='progress' style='border: 2px solid grey; height: 20px;'>
<div class='progress-bar text-white' role='progressbar' style='width:$percentageNode1%' aria-valuenow='$percentageNode1' aria-valuemin='0' aria-valuemax='100'>
<b>$node1_name : $vmCountNode1 VMs</b>
</div>
@@ -146,17 +147,17 @@
</div>
</div>";
}else{
echo "<div class='progress' style='border: 2px solid grey; height: 20px; background-Color: transparent;'>
<div class='progress-bar' style='width: 0%; background-color: transparent;'></div>
}else{
echo "<div class='progress' style='border: 2px solid grey; height: 20px; background-Color: transparent;'>
<div class='progress-bar' style='width: 0; background-color: transparent;'></div>
</div>";
}
?>
</div>
<div class='card-body text-white bg-dark'>
<?php
//Memory
echo "<div class='row'>";
}
?>
</div>
<div class='card-body text-white bg-dark'>
<?php
//Memory
echo "<div class='row'>";
echo "<div class='col-7'>";
echo "<b>Free Mem : </b>".($clmem - $vm_mem). " / " .$clmem. " GB";
echo "</div><div class='col-5'>";
@@ -176,9 +177,9 @@
<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>";
echo "</div></div>";
//DISK
echo "<div class='row'>";
echo "</div></div>";
//DISK
echo "<div class='row'>";
echo "<div class='col-7'>";
$unit="GB";
if($capacity > 10000){
@@ -188,7 +189,7 @@
$used = $capacity - $free;
echo "<b>Free CSV : </b>".$free. " / " .$capacity. " $unit";
echo "</div><div class='col-5'>";
$pcent = round(($free)/$capacity*100);
$pcent = ($clmem > 0) ? round(($clmem - $vm_mem) / $clmem * 100) : 0;
$pcent_restant = 100 - $pcent;
if($pcent <= 5){
$color = "bg-danger"; $border = "red";
@@ -204,28 +205,25 @@
<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>";
echo "</div></div>";
echo "<div class='row'><div class='col-7'><b>CSV I/O</b> R/W (24h) :</div><div class='col-5'><b> $io KB/s</b></div></div>";
echo "</div></div>";
echo "<div class='row'><div class='col-7'><b>CSV I/O</b> R/W (24h) :</div><div class='col-5'><b> $io KB/s</b></div></div>";
?>
?>
</div>
</div>
</div>
</a>
</div>
<?php
$count++; }
?>
<br><br><h3><center>Total VM Left : <?php echo $totalleft;?> </center></h3>
</div>
<!-- End of main content -->
</div>
</div>
</div>
<script src="/js/switch.js"></script>
$count++; }
?>
<br><br><h3 class ="text-center">Total VM Left : <?php echo $totalleft;?> </h3>
</div>
<!-- End of main content -->
</div>
</div>
</div>
<script src="/js/switch.js"></script>
</body>
<script>