Compare commits

...

10 Commits

Author SHA1 Message Date
e025532
d5b45dbc22 Remove test.php and enhance null safety and sorting across components
- Deleted `test.php` as it was no longer in use.
- Enhanced null safety checks in `Inventory.php`, `StdOut-detail.php`, `Backups.php`, and `SwitchsSAN.php` to prevent potential warnings.
- Refactored `SwitchsSAN.php` to improve sorting logic for ports based on errors, vFabric, and Port ID.
- Added seasonal snow effect script in `all.php` with toggle functionality for user engagement.
- Updated navigation bar (`navbar.html`) to include a new VIO page link.
- Introduced a new `VIO.php` page to display VIO monitoring details with table export and sorting features.
2026-02-04 14:52:49 +01:00
b0c9cafc46 Add backup and Fibre Channel switch management pages, update navbar.
- Introduce `/X/Backups.php` for Linux/AIX backup logs with dynamic filtering and export options.
- Add `/Storage/SwitchsSAN.php` to display Fibre Channel switch status with detailed port stats and error handling.
- Update `navbar.html` to include links to new pages and improve navigation consistency.
- Enhance `Storage/Dashboard.php` with clickable link to orphan LUNs report.
2025-12-04 16:08:49 +01:00
9afc833361 Enhance /X/Inventory.php with detailed backup log handling and dynamic styling, add new opwsinf URL in include/all.php, and remove unused Orphan LUNs link from the navbar. 2025-11-05 10:09:03 +01:00
ea46ba5c8f Improve inventory handling and cookie management:
- Replace old cookie logic with `Set_Cookie()` for enhanced security (SameSite, Secure, HttpOnly).
- Add dynamic AIX/Linux filtering on `/X/Inventory.php` with checkbox-driven UI and adjusted SQL queries.
- Expand `/X/Inventory.php` table with additional columns (`BES`, `FI`) and enhance data validation/styling.
- Add `decypher()` function in `Z_data_linux.php` to support OpenSSL-based file decryption with error handling.
2025-10-14 11:08:42 +02:00
dcfe098f35 Replace individual includes with include/all.php for consistent configuration and add cookie-based authentication in all.php. 2025-09-25 14:10:01 +02:00
878106f83f Enhance resilience and UI in inventory and server detail pages:
- Add `Heartbeat` column to `/X/Inventory.php` with status-based row styling.
- Improve error handling and data validation for backup details in `Server-Detail.php`.
2025-09-17 10:20:48 +02:00
2c279320ce Add "Host" column to the inventory table in /X/Inventory.php and introduce VM issue metrics (Unclustered, Wrong Owner) in Hyper-V clusters report with refined query logic. 2025-09-03 09:48:55 +02:00
e0d2dc00c1 Remove redundant comments, streamline query logic, and clean up variable handling for improved code readability and efficiency in StdOut.php and StdOut-detail.php. 2025-08-21 09:11:17 +02:00
a17bb63889 Optimize database queries, add resilience with is_countable, refine UI for progress bars and tables, update scripts for dynamic resizing, and correct navbar link case sensitivity. 2025-08-20 20:38:01 +02:00
70af042b7b Add new Cluster Resources report page and update navbar links accordingly 2025-08-13 16:37:01 +02:00
30 changed files with 1661 additions and 412 deletions

View File

@@ -6,49 +6,38 @@
<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">
<?php include $_SERVER['DOCUMENT_ROOT'] . "/include/all.php"; ?> <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 vh-100 position-sticky top-0" style="-ms-flex: 0 0 230px;flex: 0 0 230px;">
<?php include $_SERVER['DOCUMENT_ROOT'] . "/navbar.html"; ?> <!-- Left Navbar -->
</div>
<!-- Display -->
<?php include $_SERVER['DOCUMENT_ROOT'] . "/navbar.html"; ?> </div>
<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>
<div class="container-fluid" style="zoom:90%">
<div class="row">
<?php
// =================================================================
// STEP 1: Fetch all required data with minimal database queries (MSSQL SYNTAX)
// STEP 1: Fetch all required data with minimal database queries
// =================================================================
// Query 1: Get aggregated data for all clusters at once.
// Query 1: Get aggregated data for all clusters at once. (Unchanged)
$cluster_query = "
SELECT
cluster,
@@ -73,7 +62,7 @@
";
$all_clusters_data = Invoke_Infra($cluster_query);
// Query 2: Get VM distribution for all relevant clusters at once.
// Query 2: Get VM distribution for all relevant clusters at once. (Unchanged)
$vm_repart_query = "
SELECT
v.Cluster,
@@ -96,7 +85,6 @@
";
$raw_vm_distribution = Invoke_Infra($vm_repart_query);
// Process the VM distribution data into an easy-to-use associative array
$vm_distribution = [];
if (is_array($raw_vm_distribution)) {
foreach ($raw_vm_distribution as $repart) {
@@ -106,6 +94,37 @@
];
}
}
// MODIFICATION : Requête finale sans la jointure pour éviter les doublons
$vm_issues_query = "
SELECT
v.Cluster,
SUM(CASE WHEN v.IsClustered = 'False' THEN 1 ELSE 0 END) as unclustered_count,
SUM(CASE WHEN v.IsClustered = 'True' AND v.Owner <> v.PreferredOwner THEN 1 ELSE 0 END) as wrong_owner_count
FROM
cmdb_vms v
WHERE
v.decomtime IS NULL
AND v.Cluster <> ''
AND v.Cluster NOT LIKE '%-WM%'
AND v.Cluster NOT LIKE '%-C1MAS%'
AND v.Cluster NOT LIKE '%-vrs%'
AND (v.Cluster LIKE 'DUN%' OR v.Cluster LIKE 'DMV%')
GROUP BY
v.Cluster
";
$raw_vm_issues = Invoke_Infra($vm_issues_query);
$vm_issues = [];
if (is_array($raw_vm_issues)) {
foreach ($raw_vm_issues as $issue) {
$vm_issues[$issue['Cluster']] = [
'unclustered' => $issue['unclustered_count'],
'wrong_owner' => $issue['wrong_owner_count']
];
}
}
// =================================================================
// STEP 2: Loop through the pre-fetched data and display it
// =================================================================
@@ -136,17 +155,13 @@
$capacity_gb = 0;
$free_gb = 0;
if (!empty($cluster_data['all_csvs'])) {
// Explode the big string into an array of all CSV entries (with duplicates)
$all_csv_entries = explode("|", $cluster_data['all_csvs']);
// Create a new array containing only the unique CSV entries
$unique_csv_entries = array_unique($all_csv_entries);
// Loop through the UNIQUE entries to perform the calculation
foreach ($unique_csv_entries as $csv_string) {
if (str_contains($csv_string, ';')) {
$parts = explode(";", $csv_string);
if(count($parts) >= 3) {
$capacity_gb += (int)$parts[1];
// Free space is Total Capacity (parts[1]) - Used Space (parts[2])
$free_gb += (int)$parts[1] - (int)$parts[2];
}
}
@@ -155,10 +170,6 @@
$free_gb = max(0, $free_gb);
$free_storage_percentage = ($capacity_gb > 0) ? round($free_gb / $capacity_gb * 100) : 0;
// IOPS Calculation
$avg_io = ($node_count > 0) ? round((float)$cluster_data['total_io_disk'] / $node_count * 1024) : 0;
$io_display = ($avg_io == 0) ? "?" : $avg_io;
// VMs Left Calculation
$vms_left_by_mem = ($free_mem > 0) ? floor($free_mem / 16) : 0;
$vms_left_by_storage = ($free_gb > 0) ? floor($free_gb / 110) : 0;
@@ -168,7 +179,7 @@
// --- Display Logic ---
if ($vms_left > 2) {
$vleft_html = "<span class='text-success'><b>(" . $vms_left . "</b> VMs left)</span>";
} elseif ($vms_left >= 1) { // Handles 1 and 2
} elseif ($vms_left >= 1) {
$vleft_html = "<span class='text-warning'><b>(" . $vms_left . "</b> VMs left)</span>";
} else {
$vleft_html = "<span class='text-danger'><b>(" . $vms_left . "</b> VMs left)</span>";
@@ -193,13 +204,11 @@
$owner1_count = $dist_data[0]['vm_count'];
$owner2_name = isset($dist_data[1]) ? $dist_data[1]['owner'] : 'N/A';
$owner2_count = isset($dist_data[1]) ? $dist_data[1]['vm_count'] : 0;
$p1 = ($total_vms > 0) ? ($owner1_count / $total_vms) * 100 : 0;
$p2 = ($total_vms > 0) ? ($owner2_count / $total_vms) * 100 : 0;
$vm_dist_html = "<div class='progress' style='border: 2px solid grey; height: 20px;'>
<div class='progress-bar text-white' role='progressbar' style='width:$p1%'><b>$owner1_name: $owner1_count</b></div>
<div class='progress-bar bg-info text-dark' role='progressbar' style='width:$p2%'><b>$owner2_name: $owner2_count</b></div>
<div class='progress-bar text-white' role='progressbar' style='width:$p1%'><b>$owner1_name</b></div>
<div class='progress-bar bg-info text-dark' role='progressbar' style='width:$p2%'><b>$owner2_name</b></div>
</div>";
}
}
@@ -244,7 +253,25 @@
</div>
</div>
</div>
<div class='row'><div class='col-7'><b>CSV I/O</b> (24h):</div><div class='col-5'><b><?php echo $io_display; ?> KB/s</b></div></div>
<div class='row mt-2'>
<?php
$unclustered_count = $vm_issues[$cluster_name]['unclustered'] ?? 0;
$wrong_owner_count = $vm_issues[$cluster_name]['wrong_owner'] ?? 0;
if ($unclustered_count > 0) {
echo "<div class='col-7'><span class='badge text-bg-danger'>Unclustered: $unclustered_count</span></div>";
}else{
echo "<div class='col-7'><span class='badge text-bg-success'>Unclustered: $unclustered_count</span></div>";
}
if ($wrong_owner_count > 0) {
echo "<div class='col-5'><span class='badge text-bg-warning'>Wrong Owner: {$wrong_owner_count}</span></div>";
}else{
echo "<div class='col-5'><span class='badge text-bg-success'>Wrong Owner: {$wrong_owner_count}</span></div>";
}
?>
</div>
</div>
</div>
</a>
@@ -262,10 +289,8 @@
</div>
</div>
</div>
<!-- End of main content -->
</div>
</div>
</div>
<script src="/js/switch.js"></script>
</body>

View File

@@ -79,18 +79,29 @@
<tbody> <!-- Body -->
<?php
// get all active servers
$today = date("Y-m-d");
$active = Invoke_Infra("SELECT name from cmdb_vms where LastInventory like'$today%'");
$active = array_column($active, 'name');
// 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) and policy is not null order by lastresult,name");
foreach ($answers as $row) {
if(in_array($row['Name'], $active)){
$er++;
$date1 = date_create($row['LastKnownGood']??'01/01/1970'); $diff = date_diff($date1, date_create(date("Y-m-d")));
$date1 = date_create($row['LastKnownGood'] ?? '01/01/1970');
$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)";}
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>";
@@ -101,12 +112,15 @@
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 (in_array($row['Name'], $active)) {
$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'>";
@@ -122,7 +136,11 @@
}
}
}
if($diff->format("%R%a") == "-0"){$LastGood = $row['LastKnownGood'];}else{$LastGood = $row['LastKnownGood']." (".$diff->format("%R%a")."J)";}
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>";
@@ -141,11 +159,11 @@
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);
$total = is_countable($answers) ? count($answers) : 0;
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 ){

View File

@@ -0,0 +1,120 @@
<!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>
<style>
.cluster-separator td {
border-top: 3px solid lightseagreen; /* Bordure épaisse et sombre */
}
</style>
</head>
<body class="bg-light text-dark">
<?php include $_SERVER['DOCUMENT_ROOT'] . "/include/all.php"; ?> <!-- Include All -->
<?php // DATA
set_time_limit(300);
$Clusters = Invoke_Infra(" select * from cmdb_clusterResources
where Name not in('Available Storage')
order by Cluster, 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 vh-100 position-sticky top-0" 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 -->
<h1><span class="badge text-bg-secondary font-weight-bold" style="width:100%;">Cluster Resources <small><small>(Hyper-V excluded)</small></small></span></h1>
<!-- 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>
</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 -->
<tr>
<th data-field="Server" data-sortable="true">Cluster</th>
<th data-field="Folder" data-sortable="true">Resource</th>
<th data-field="ACL" data-sortable="true">Owner Node</th>
<th data-field="AD" data-sortable="true">State</th>
<th data-field="Enabled" data-sortable="true">Last Checked</th>
</tr>
</thead>
<tbody> <!-- Body -->
<?php
$last = "";
foreach ($Clusters as $answer) {
$current = $answer['Cluster'];
if($current != $last) {
echo "<tr class='cluster-separator'>";
echo "<td class='text-nowrap table-secondary'><b>" . $answer['Cluster'] . "</td>";
$last = $current;
}else{
echo "<tr><td></td>";
}
echo "<td>".$answer['Name']."</td>";
echo "<td>".$answer['Owner']."</td>";
echo "<td>".$answer['State']."</td>";
echo "<td>".$answer['ts']."</td>";
echo "</tr>";
}
?>
</tbody>
</table>
<br>
</div>
</div>
<!-- End of main content -->
</div>
</div>
</div>
</body>
<script src="/js/switch.js"></script>
</HTML>
<script src="/js/tableResize.js"></script>

View File

@@ -111,7 +111,7 @@
<?php if($OSKernel){echo "&nbsp;<span class='badge rounded-pill bg-secondary text-light'>$OSKernel</span>";} ?>
<?php
if(is_array($Qvm)){
$site = Invoke_Infra("SELECT site from cmdb_physical_site where hostname ='".$Qvm[0]['Owner']."'")[0]['site'];
$site = Invoke_Infra("SELECT site from cmdb_physical_site where hostname ='".$Qvm[0]['Owner']."'")[0]['site'] ?? "?";
if($Qvm[0]['Owner'] == $Qvm[0]['PreferredOwner']){
echo "&nbsp;<span class='badge rounded-pill bg-success text-light'>Host : ".$Qvm[0]['Owner']."</span>";
}else{
@@ -298,11 +298,15 @@
<!-- Backup for AIX, Linux -->
<?php
if(is_array($Qx)){
try {
$backup = Invoke_Infra("select * from X_cmdb_Backupsys where HOSTNAME='$server'");
if(is_array($backup) && $backup[0]['LastBackup']) {
echo "<span class='badge rounded-pill bg-secondary text-light fs-5'>LastBackup : " . explode(".", $backup[0]['LastBackup'])[0] . "</span>&nbsp;";
echo "<span class='badge rounded-pill bg-secondary text-light fs-5'>BackupType : " . $backup[0]['BackupType'] . "</span>&nbsp;";
echo "<span class='badge rounded-pill bg-secondary text-light fs-5'>Media : " . $backup[0]['Location'] . "</span>";
}
} catch (Exception $e) {} // Catch any potential errors during backup information retrieval
}
?>
<!-- End of main content -->
@@ -311,4 +315,3 @@
</div>
<script src="/js/switch.js"></script>
</body>

View File

@@ -1,5 +1,48 @@
<?php
include $_SERVER['DOCUMENT_ROOT']."/../../include/db_connect.php" ;
function decypher(string $name): ?string {
$openssl = 'C:\Program Files\FireDaemon OpenSSL 3\bin\openssl.exe';
$cmsFile = "F:\\Include\\dat\\$name.p7m";
$certPem = "F:\\Include\\certs\\cert_only.pem";
$keyPem = "F:\\Include\\certs\\key_only.pem";
foreach ([$openssl,$cmsFile,$certPem,$keyPem] as $p) {
if (!is_file($p)) { error_log("Missing file: $p"); return null; }
}
$cmd = '"' . $openssl . '" cms -decrypt -inform PEM'
. ' -in ' . escapeshellarg($cmsFile)
. ' -recip ' . escapeshellarg($certPem)
. ' -inkey ' . escapeshellarg($keyPem)
. ' -out -';
$spec = [
0 => ['pipe','r'], // stdin (unused)
1 => ['pipe','w'], // stdout -> texte déchiffré
2 => ['pipe','w'], // stderr -> erreurs OpenSSL
];
$proc = proc_open($cmd, $spec, $pipes);
if (!is_resource($proc)) { error_log('proc_open failed'); return null; }
fclose($pipes[0]); // rien à envoyer en stdin
$stdout = stream_get_contents($pipes[1]); fclose($pipes[1]);
$stderr = stream_get_contents($pipes[2]); fclose($pipes[2]);
$code = proc_close($proc);
if ($code !== 0) {
error_log("OpenSSL failed (code $code): $stderr");
return null;
}
return $stdout;
}
function DB_ZABBIX()
{
$host = 'aztprdzabbix52.armony.net';
$dbname = 'zabbix';
$user = 'patrick';
$pass = decypher( 'zabbix');
$pdo = new PDO("mysql:host=$host;dbname=$dbname", $user, $pass);
return $pdo;
}
$pdo = DB_ZABBIX();

View File

@@ -1,5 +1,48 @@
<?php
include $_SERVER['DOCUMENT_ROOT']."/../../include/db_connect.php" ;
function decypher(string $name): ?string {
$openssl = 'C:\Program Files\FireDaemon OpenSSL 3\bin\openssl.exe';
$cmsFile = "F:\\Include\\dat\\$name.p7m";
$certPem = "F:\\Include\\certs\\cert_only.pem";
$keyPem = "F:\\Include\\certs\\key_only.pem";
foreach ([$openssl,$cmsFile,$certPem,$keyPem] as $p) {
if (!is_file($p)) { error_log("Missing file: $p"); return null; }
}
$cmd = '"' . $openssl . '" cms -decrypt -inform PEM'
. ' -in ' . escapeshellarg($cmsFile)
. ' -recip ' . escapeshellarg($certPem)
. ' -inkey ' . escapeshellarg($keyPem)
. ' -out -';
$spec = [
0 => ['pipe','r'], // stdin (unused)
1 => ['pipe','w'], // stdout -> texte déchiffré
2 => ['pipe','w'], // stderr -> erreurs OpenSSL
];
$proc = proc_open($cmd, $spec, $pipes);
if (!is_resource($proc)) { error_log('proc_open failed'); return null; }
fclose($pipes[0]); // rien à envoyer en stdin
$stdout = stream_get_contents($pipes[1]); fclose($pipes[1]);
$stderr = stream_get_contents($pipes[2]); fclose($pipes[2]);
$code = proc_close($proc);
if ($code !== 0) {
error_log("OpenSSL failed (code $code): $stderr");
return null;
}
return $stdout;
}
function DB_ZABBIX()
{
$host = 'aztprdzabbix52.armony.net';
$dbname = 'zabbix';
$user = 'patrick';
$pass = decypher( 'zabbix');
$pdo = new PDO("mysql:host=$host;dbname=$dbname", $user, $pass);
return $pdo;
}
$pdo = DB_ZABBIX();

View File

@@ -1,5 +1,48 @@
<?php
include $_SERVER['DOCUMENT_ROOT']."/../../include/db_connect.php" ;
function decypher(string $name): ?string {
$openssl = 'C:\Program Files\FireDaemon OpenSSL 3\bin\openssl.exe';
$cmsFile = "F:\\Include\\dat\\$name.p7m";
$certPem = "F:\\Include\\certs\\cert_only.pem";
$keyPem = "F:\\Include\\certs\\key_only.pem";
foreach ([$openssl,$cmsFile,$certPem,$keyPem] as $p) {
if (!is_file($p)) { error_log("Missing file: $p"); return null; }
}
$cmd = '"' . $openssl . '" cms -decrypt -inform PEM'
. ' -in ' . escapeshellarg($cmsFile)
. ' -recip ' . escapeshellarg($certPem)
. ' -inkey ' . escapeshellarg($keyPem)
. ' -out -';
$spec = [
0 => ['pipe','r'], // stdin (unused)
1 => ['pipe','w'], // stdout -> texte déchiffré
2 => ['pipe','w'], // stderr -> erreurs OpenSSL
];
$proc = proc_open($cmd, $spec, $pipes);
if (!is_resource($proc)) { error_log('proc_open failed'); return null; }
fclose($pipes[0]); // rien à envoyer en stdin
$stdout = stream_get_contents($pipes[1]); fclose($pipes[1]);
$stderr = stream_get_contents($pipes[2]); fclose($pipes[2]);
$code = proc_close($proc);
if ($code !== 0) {
error_log("OpenSSL failed (code $code): $stderr");
return null;
}
return $stdout;
}
function DB_ZABBIX()
{
$host = 'aztprdzabbix52.armony.net';
$dbname = 'zabbix';
$user = 'patrick';
$pass = decypher( 'zabbix');
$pdo = new PDO("mysql:host=$host;dbname=$dbname", $user, $pass);
return $pdo;
}
$pdo = DB_ZABBIX();
$server = strtoupper($_GET['c']);

View File

@@ -1,6 +1,48 @@
<?php
header('Content-Type: application/json');
include $_SERVER['DOCUMENT_ROOT']."/../../include/db_connect.php" ;
function decypher(string $name): ?string {
$openssl = 'C:\Program Files\FireDaemon OpenSSL 3\bin\openssl.exe';
$cmsFile = "F:\\Include\\dat\\$name.p7m";
$certPem = "F:\\Include\\certs\\cert_only.pem";
$keyPem = "F:\\Include\\certs\\key_only.pem";
foreach ([$openssl,$cmsFile,$certPem,$keyPem] as $p) {
if (!is_file($p)) { error_log("Missing file: $p"); return null; }
}
$cmd = '"' . $openssl . '" cms -decrypt -inform PEM'
. ' -in ' . escapeshellarg($cmsFile)
. ' -recip ' . escapeshellarg($certPem)
. ' -inkey ' . escapeshellarg($keyPem)
. ' -out -';
$spec = [
0 => ['pipe','r'], // stdin (unused)
1 => ['pipe','w'], // stdout -> texte déchiffré
2 => ['pipe','w'], // stderr -> erreurs OpenSSL
];
$proc = proc_open($cmd, $spec, $pipes);
if (!is_resource($proc)) { error_log('proc_open failed'); return null; }
fclose($pipes[0]); // rien à envoyer en stdin
$stdout = stream_get_contents($pipes[1]); fclose($pipes[1]);
$stderr = stream_get_contents($pipes[2]); fclose($pipes[2]);
$code = proc_close($proc);
if ($code !== 0) {
error_log("OpenSSL failed (code $code): $stderr");
return null;
}
return $stdout;
}
function DB_INFRA() {
$user="INFRA_dbo";
$pwd=decypher("infra");
$server="DUN-PRD-R1MSSQL.armony.net\PRD";
$database="INFRA";
$conn = odbc_connect("Driver={SQL Server};Server=$server;Database=$database;", $user, $pwd);
return $conn ;
}
if (isset($_GET['term'])) {
$term = $_GET['term'];
$query = "SELECT hostname AS serv FROM cmdb_srvall WHERE hostname LIKE '%$term%' UNION SELECT hostname AS serv FROM x_SRVALL WHERE hostname LIKE '%$term%'";

View File

@@ -24,8 +24,7 @@
</head>
<body class="bg-light text-dark">
<?php include $_SERVER['DOCUMENT_ROOT']."/include/db_connect.php" ; ?> <!-- Database connexion -->
<?php //include $_SERVER['DOCUMENT_ROOT']."/include/functions.inc.php" ; ?> <!-- Functions -->
<?php include $_SERVER['DOCUMENT_ROOT'] . "/include/all.php"; ?> <!-- Include All -->
<div class="container-fluid">
<div class="row flex-nowrap">
<!-- Left NAVBAR -->

View File

@@ -442,8 +442,10 @@
<h5><i class="fs-4 bi-hdd text-black"></i> Unnasigned LUNs</h5>
</div>
<div class="card-body bg-dark text-center fs-2">
<a href="http://infra-tools.appliarmony.net/storage/svc-orphan-luns.php" target="_blank">
<button type="button" class="btn btn-secondary" data-bs-html="true" data-toggle="tooltip"
data-placement="top" title="<?php echo $lLUN; ?>"><b><?php echo $unnasigned; ?></b></button>
</a>
</div>
</div>
</div>

186
Storage/SwitchsSAN.php Normal file
View File

@@ -0,0 +1,186 @@
<!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">
<title>Infra Reports IT - SAN Status</title>
<link rel="shortcut icon" type="image/png" href="/include/favicon-32x32.png">
<script src="/js/jquery-3.6.1.min.js"></script>
<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>
<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>
<style>
.card-header a { text-decoration: none; color: white; display: block; width: 100%; }
.card-header a:hover { color: #f0f0f0; }
</style>
</head>
<body class="bg-light text-dark">
<?php
// Include global configurations
include $_SERVER['DOCUMENT_ROOT'] . "/include/all.php";
// --- PHP LOGIC START ---
// 1. Fetch JSON Data
$jsonString = PostJson("$bdnuss/Storage/BROCADE/PORT/BROCADE_PORT_LIST.php", '');
// 2. Decode to PHP Array
$sanData = json_decode($jsonString, true);
// Check if decode was successful
if (json_last_error() !== JSON_ERROR_NONE) {
$sanData = [];
$errorMessage = "Error decoding JSON: " . json_last_error_msg();
}
?>
<div class="container-fluid" id="content">
<div class="row flex-nowrap">
<div class="col-auto col-md-2 col-xl-2 px-sm-2 px-0 bg-dark vh-100 position-sticky top-0" style="-ms-flex: 0 0 230px;flex: 0 0 230px;">
<?php include $_SERVER['DOCUMENT_ROOT'] . "/navbar.html"; ?>
</div>
<div class="col py-3">
<h1><span class="badge text-bg-secondary font-weight-bold" style="width:100%;">Fibre Channel Switch Status</span></h1>
<div class="container mt-4">
<?php if (isset($errorMessage)): ?>
<div class="alert alert-danger"><?php echo $errorMessage; ?></div>
<?php endif; ?>
<div id="accordion">
<?php
// Loop through Switches
if (!empty($sanData)) {
$switchIndex = 0;
foreach ($sanData as $switchName => $ports) {
$switchIndex++;
$collapseId = "collapse_" . $switchIndex;
// Inject PortID into the array content for easier sorting
foreach ($ports as $k => $v) $ports[$k]['_PortID'] = $k;
// Custom Sort: Errors (Desc) > vFabric (Asc) > Port (Natural Asc)
uasort($ports, function ($a, $b) {
// Errors (Descending)
$errA = (int)$a['Errors'];
$errB = (int)$b['Errors'];
if ($errA !== $errB) {
return $errB <=> $errA;
}
// vFabric (Ascending / Case Insensitive)
$vfA = $a['vFabric'] ?? '';
$vfB = $b['vFabric'] ?? '';
$cmpVf = strcasecmp($vfA, $vfB);
if ($cmpVf !== 0) {
return $cmpVf;
}
// Port ID (Natural Sort, e.g. 2 comes before 10)
return strnatcmp($a['_PortID'], $b['_PortID']);
});
// Initialize counters & buffers
$upCount = 0;
$downCount = 0;
$errorCount = 0;
$tableBody = "";
// Generate HTML Rows based on sorted data
foreach ($ports as $portId => $portData) {
$state = $portData['State'];
$errors = (int)$portData['Errors'];
if ($state === 'UP') $upCount++;
elseif ($state === 'DN') $downCount++;
if ($errors > 0 && $state === 'UP') $errorCount++;
if ($state === 'DN') {
continue;
}
// Determine Row CSS Class
$rowClass = "table-success";
if ($errors > 0) $rowClass = "table-danger";
// Build Row HTML
$tableBody .= "
<tr class='{$rowClass}'>
<td>{$portData['vFabric']}</td>
<td>{$portId}</td>
<td>{$portData['Status']}</td>
<td>{$portData['State']}</td>
<td>{$portData['Speed']}</td>
<td>{$portData['Nego']}</td>
<td>{$portData['FrameTX']}</td>
<td>{$portData['FrameRX']}</td>
<td data-value='{$errors}'><strong>{$portData['Errors']}</strong></td>
</tr>";
}
// Determine Header Color
$headerColor = ($errorCount > 0) ? "DarkOrange" : "green";
$msg = ($errorCount > 0) ? "<b> {$errorCount} issue(s)</b>" : "OK";
?>
<div class="card" style="background-color:<?php echo $headerColor; ?>;">
<h4 class="card-header">
<a class="btn text-white fs-3 w-100 text-start" data-bs-toggle="collapse" href="#<?php echo $collapseId; ?>">
<b><?php echo strtoupper($switchName); ?> : <?php echo $upCount; ?> Ports UP / <?php echo ($upCount + $downCount); ?> : <?php echo $msg; ?></b>
</a>
</h4>
</div>
<div id="<?php echo $collapseId; ?>" class="collapse" data-bs-parent="#accordion">
<div class="card-body bg-white border p-0">
<div class="table-responsive">
<table class="table table-bordered table-hover mb-0 text-center" data-toggle="table">
<thead class="table-light">
<tr>
<th data-sortable="true">vFabric</th>
<th data-sortable="true">Port</th>
<th data-sortable="true">Status</th>
<th data-sortable="true">State</th>
<th data-sortable="true">Speed</th>
<th data-sortable="true">Nego</th>
<th data-sortable="true">FrameTX</th>
<th data-sortable="true">FrameRX</th>
<th data-sortable="true">Errors</th>
</tr>
</thead>
<tbody>
<?php echo $tableBody; ?>
</tbody>
</table>
</div>
</div>
</div>
<br>
<?php
}
} else {
echo "<div class='alert alert-warning'>No data available via API.</div>";
}
?>
</div>
</div>
</div>
</div>
</div>
</body>
<script src="/js/switch.js"></script>
</html>

153
X/Backups.php Normal file
View File

@@ -0,0 +1,153 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-t">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Web Infra Reports</title>
<link rel="shortcut icon" type="image/png" href="/include/favicon-32x32.png">
<script src="/js/jquery-3.6.1.min.js"></script>
<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>
<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/global.php";
$list = Invoke_Infra("select * from X_cmdb_backupsys order by HOSTNAME");
$all = $_POST['show_all'] ?? 0;
// Si on affiche TOUT, alors on force l'affichage de la taille,
// ou on récupère la valeur normale si All n'est pas coché.
if ($all == 1) {
$showSize = 1;
} else {
$showSize = $_POST['show_size'] ?? 0;
}
?>
<div class="container-fluid" id="content">
<div class="row flex-nowrap">
<div class="col-auto col-md-2 col-xl-2 px-sm-2 px-0 bg-dark vh-100 position-sticky top-0" style="-ms-flex: 0 0 230px;flex: 0 0 230px;">
<?php include $_SERVER['DOCUMENT_ROOT'] . "/navbar.html"; ?>
</div>
<div class="col py-3">
<h1><span class="badge text-bg-secondary font-weight-bold" style="width:100%;">Backups Linux/AIX</span></h1>
<div class="d-flex justify-content-start align-items-center mb-2 p-2 rounded bg-secondary-subtle">
<form class="form-inline d-flex gap-4" action="Backups.php" method="post" >
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" role="switch"
id="showAll" name="show_all" value="1"
<?php echo ($all == 1) ? 'checked' : ''; ?>>
<label class="form-check-label" for="showAll"><strong>All</strong></label>
</div>
<div class="form-check form-switch" <?php echo ($all == 1) ? 'style="display:none;"' : ''; ?>>
<input class="form-check-input" type="checkbox" role="switch"
id="showSize" name="show_size" value="1"
<?php echo ($showSize == 1) ? 'checked' : ''; ?>>
<label class="form-check-label" for="showSize"><strong>Size >= 15GB</strong></label>
</div>
</form>
</div>
<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>
<tr>
<th data-field="Name" data-sortable="true">Name</th>
<th data-field="ts" data-sortable="true">TS</th>
<th data-field="Log" data-sortable="true">Log</th>
<th data-field="Type" data-sortable="true">Type</th>
<th data-field="Location" data-sortable="true">Location</th>
</tr>
</thead>
<tbody>
<?php
$now = new DateTime();
foreach ($list as $s) {
$name = $s['HOSTNAME'];
$ts = $s['ts'];
$lastBackup = (explode(".",$s['LastBackup'] ?? ''))[0];
$location = $s['Location'];
$log = $s['Log'];
$backuptype = $s['BackupType'];
if(str_contains($log, "Length")) {
$size = floor(explode(" ",$log)[1] / 1024 / 1024 / 1024);
if(explode(" ",$log)[1] > 16106127360) {
$log = "Size : $size GB";
if($showSize == 0){ continue; }
}else{
$log = "OK - $size GB";
if($all == 0){ continue; }
}
}
if(str_contains($log, "Total bytes written:")) {
$size = floor(explode(" ",$log)[3] / 1024 / 1024 / 1024);
if(explode(" ",$log)[3] > 16106127360) {
$log = "Size : $size GB";
if($showSize == 0){ continue; }
}else{
$log = "OK - $size GB";
if($all == 0){ continue; }
}
}
echo "</tr>";
echo "<td>$name</td>";
echo "<td>$ts</td>";
if(str_contains($log, "waiting")) {
echo "<td class='table-primary'><b>$log</b></td>";
}elseif(str_contains($log, "error")){
echo "<td class='table-danger'><b>$log</b></td>";
}elseif(str_contains($log, "progress")){
echo "<td class='table-success'><b>$log</b></td>";
}elseif(str_contains($log, "OK -")){
echo "<td class='table-success'>$log</td>";
}elseif(str_contains($log, "Size : ")){
echo "<td class='table-warning'>$log</td>";
}else{echo "<td>$log</td>"; }
echo "<td>$backuptype</td>";
echo "<td>$location</td>";
echo "</tr>";
}
?>
</tbody>
</table><br>
</div>
</div>
</div>
</div>
</body>
<script src="/js/switch.js"></script>
<script>
$(function() {
$('#showAll').on('change', function() {
$(this).closest('form').submit();
});
$('#showSize').on('change', function() {
$(this).closest('form').submit();
});
});
</script>
</HTML>
<script src="/js/tableResize.js"></script>

View File

@@ -2,22 +2,18 @@
<html lang="en">
<head>
<meta charset="utf-8">
<meta charset="utf-t">
<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">
<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>
@@ -28,34 +24,80 @@
</head>
<body class="bg-light text-dark">
<?php include $_SERVER['DOCUMENT_ROOT'] . "/include/global.php"; ?>
<?php // DATA
$servers = Invoke_Infra("select * from x_inventory where type is not null");
<?php
include $_SERVER['DOCUMENT_ROOT'] . "/include/global.php";
// NOUVEAU : Gérer les filtres
// Par défaut, tout est coché (true)
// On vérifie si un paramètre est passé dans l'URL pour décocher une case
$show_aix = isset($_GET['show_aix']) ? $_GET['show_aix'] === '1' : true;
$show_linux = isset($_GET['show_linux']) ? $_GET['show_linux'] === '1' : true;
// Construction de la requête SQL
$base_sql = "SELECT * FROM x_inventory WHERE type IS NOT NULL and hostname not in ('DUNAPPDNIM51','DUNAPPDNIM52') ";
$conditions = [];
if ($show_aix) {
// La condition pour AIX est simple
$conditions[] = "type = 'AIX'";
}
if ($show_linux) {
// D'après votre code, tout ce qui n'est pas 'AIX' est considéré comme Linux
$conditions[] = "type <> 'AIX'";
}
if (!empty($conditions)) {
// On ajoute les conditions à la requête de base
$sql = $base_sql . " AND (" . implode(' OR ', $conditions) . ")";
} else {
// Si rien n'est coché, on ne retourne aucun résultat
$sql = $base_sql . " AND 1=0";
}
// DATA
$servers = Invoke_Infra($sql); // On utilise la nouvelle requête
$UTDS1 = (Invoke_Infra("select max(Ver) as utd from X_cmdb_Product where Name = 's1'"))[0]['utd'];
$UTDNessus = (Invoke_Infra("select max(Ver) as utd from X_cmdb_Product where Name = 'nessus'"))[0]['utd'];
$UTDZabbix = (Invoke_Infra("select max(Ver) as utd from X_cmdb_Product where Name = 'zabbix'"))[0]['utd'];
$rows = Invoke_Infra("SELECT DISTINCT(Ver) FROM X_cmdb_Product WHERE Name='bes'");
$versions = array_map(fn ($r) => $r['Ver'] ?? null, $rows);
$versions = array_values(array_filter($versions));
usort($versions, 'version_compare');
$UTDBES = end($versions);
$UTDFI = (Invoke_Infra("select max(Ver) as utd from X_cmdb_Product where Name = 'fi'"))[0]['utd'];
?>
<!-- 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 vh-100 position-sticky top-0" 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 -->
<h1><span class="badge text-bg-secondary font-weight-bold" style="width:100%;">AIX / Linux inventory</span></h1>
<!-- Main content -->
<div class="container-fluid">
<!-- TABLE -->
<div class="d-flex justify-content-start align-items-center mb-2 p-2 rounded bg-secondary-subtle">
<form class="form-inline d-flex gap-4">
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" role="switch" id="showAix" <?php echo $show_aix ? 'checked' : ''; ?>>
<label class="form-check-label" for="showAix"><strong>AIX</strong></label>
</div>
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" role="switch" id="showLinux" <?php echo $show_linux ? 'checked' : ''; ?>>
<label class="form-check-label" for="showLinux"><strong>Linux</strong></label>
</div>
</form>
</div>
<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 -->
<thead>
<tr>
<th data-field="Name" data-sortable="true">Name</th>
<th data-field="Heartbeat" data-sortable="true" data-visible="false">Heartbeat</th>
<th data-field="Host" data-sortable="true">Host</th>
<th data-field="OS" data-sortable="true">OS Type</th>
<th data-field="distrib" data-sortable="true">Distrib</th>
<th data-field="Last Boot" data-sortable="true">Last reboot</th>
@@ -64,10 +106,12 @@
<th data-field="SentinelOne" data-sortable="true">SentinelOne</th>
<th data-field="Nessus" data-sortable="true">Nessus</th>
<th data-field="Zabbix" data-sortable="true">Zabbix</th>
<th data-field="BES" data-sortable="true" data-visible="false">BES</th>
<th data-field="FI" data-sortable="true" data-visible="false">Fusion Inv.</th>
</tr>
</thead>
<tbody> <!-- Body -->
<tbody>
<?php
$total = 0;
foreach ($servers as $s) {
@@ -75,8 +119,28 @@
echo "<tr>";
//name
$name = $s['hostname'];
echo "<td><a href='/inventory/server-detail.php?s=".$name."' target='_blank'>$name</a></td>";
$heartbeat = $s['Heartbeat'];
$statusClass = '';
$heartbeatDate = new DateTime($heartbeat);
$now = new DateTime();
$interval = $now->diff($heartbeatDate);
$diffInMinutes = ($interval->days * 24 * 60) + ($interval->h * 60) + $interval->i;
if ($diffInMinutes < 10) {
$statusClass = 'table-success';
} elseif ($diffInMinutes <= 30) {
$statusClass = 'table-warning';
} else {
$statusClass = 'table-danger';
}
echo "<td class='$statusClass'>";
echo " <a href='/inventory/server-detail.php?s={$name}' target='_blank'>{$name}</a>";
echo "</td>";
//heartbeat
echo "<td>" . $s["Heartbeat"] . "</td>";
//Host
echo "<td>" . $s['Owner'] . "</td>";
//OS Type
$typ = match ($s['type'] ?? null) {
'AIX' => 'AIX',
@@ -96,10 +160,12 @@
echo "<td>$Distrib</td>";
//LastReboot
$lr = $s['lastboot'] ?? ""; $lrDate="";
$lr = $s['lastboot'] ?? "";
$lrDate = "";
try {
$lrDate = new DateTime($lr);
} catch (DateMalformedStringException $e) {}
} catch (DateMalformedStringException $e) {
}
$interval = (new DateTime())->diff($lrDate);
if ($interval->days > 60) {
echo "<td class='table-danger'>$lr</td>";
@@ -113,6 +179,13 @@
//LastBackup
$lr = explode(".", $s['backuplast'] ?? "")[0];
if(str_contains(strtolower($s['backuplog'] ?? ''), 'progress')){
$size = "<span class='text-warning'>In Progress</span>";
}elseif (str_contains(strtolower($s['backuplog'] ?? ''), 'waiting')){
$size = "<span class='text-warning'><br>".$s['backuplog']."</span>";
}elseif (str_contains(strtolower($s['backuplog'] ?? ''), 'error')){
$size = "<span class='text-danger'><b> ERROR !!!</b></span>";
}else {
$size = 0;
if ($s['backuplog'] != "") {
if (str_contains($s['backuplog'], "Length")) {
@@ -127,9 +200,11 @@
} else {
$size = "$size GB";
}
}
try {
$lrDate = new DateTime($lr);
} catch (DateMalformedStringException $e) {}
} catch (DateMalformedStringException $e) {
}
$interval = (new DateTime())->diff($lrDate);
if ($interval->days > 7 || $s['backuplast'] == "") {
echo "<td class='table-danger'>$lr" . " " . $size . "</td>";
@@ -145,7 +220,8 @@
echo "<td>" . $s['auth'] . "</td>";
//SentinelOne
$s1s = $s['S1State']; $s1v = $s['S1Version'];
$s1s = $s['S1State'];
$s1v = $s['S1Version'];
if ($typ == "LINUX") {
if ($s1s == "YY") {
if ($s1v == $UTDS1) {
@@ -165,7 +241,8 @@
}
//Nessus
$s1s = $s['NessusState']; $s1v = $s['NessusVersion'];
$s1s = $s['NessusState'];
$s1v = $s['NessusVersion'];
if ($typ == "LINUX") {
if ($s1s == "YYY_YYY") {
if ($s1v == $UTDNessus) {
@@ -185,7 +262,11 @@
}
//Zabbix
$s1s = $s['ZabbixState']; $s1v = $s['ZabbixVersion'];
$s1s = $s['ZabbixState'];
$s1v = $s['ZabbixVersion'];
if ($typ == "AIX" && str_starts_with($s['osversion'], '6')) {
echo "<td></td>";
} else {
if ($s1s == "Y") {
if ($s1v == $UTDZabbix) {
echo "<td class='table-success'>$s1v $s1s</td>";
@@ -199,6 +280,45 @@
echo "<td class='table-danger'>$s1v <b>$s1s</b></td>";
}
}
}
//BES
$s1s = $s['BESState'];
$s1v = $s['BESVersion'];
if ($s1s == "Y") {
if ($s1v == $UTDBES) {
echo "<td class='table-success'>$s1v $s1s</td>";
} else {
echo "<td class='table-warning'><b>$s1v</b> $s1s</td>";
}
} else {
if ($s1v == "") {
echo "<td class='table-danger text-center'>MISSING</td>";
} else {
echo "<td class='table-danger'>$s1v <b>$s1s</b></td>";
}
}
//FI
$s1s = $s['FIState'];
$s1v = $s['FIVersion'];
if ($typ == "LINUX") {
if ($s1s == "Y") {
if ($s1v == $UTDFI) {
echo "<td class='table-success'>$s1v $s1s</td>";
} else {
echo "<td class='table-warning'><b>$s1v</b> $s1s</td>";
}
} else {
if ($s1v == "") {
echo "<td class='table-danger text-center'>MISSING</td>";
} else {
echo "<td class='table-danger'>$s1v <b>$s1s</b></td>";
}
}
} else {
echo "<td></td>";
}
echo "</tr>";
}
@@ -209,11 +329,34 @@
<h5 class="text-center"><?php echo $total; ?> servers</h5>
</div>
</div>
<!-- End of main content -->
</div>
</div>
</div>
</body>
<script src="/js/switch.js"></script>
<script>
// This function will be executed when the document is ready
$(function() {
// Add an event listener to both checkboxes
$('#showAix, #showLinux').on('change', function() {
// Get the current state of the checkboxes (checked or not)
// '1' for checked, '0' for unchecked
const showAix = $('#showAix').is(':checked') ? '1' : '0';
const showLinux = $('#showLinux').is(':checked') ? '1' : '0';
// Create a URL object to easily manipulate query parameters
const url = new URL(window.location.href);
// Set the parameters based on checkbox states
url.searchParams.set('show_aix', showAix);
url.searchParams.set('show_linux', showLinux);
// Reload the page with the new URL
window.location.href = url.toString();
});
});
</script>
</HTML>
<script src="/js/tableResize.js"></script>

View File

@@ -67,28 +67,16 @@
</div>
<!-- TABLE -->
<div>
<?php // DATA
<?php
$aix = $linux = $dun = $azt = $other = "Checked";
$where = " and OS_TYPE IN (";
if (isset($_GET['AIX'])) {
if ($_GET['AIX'] == 1) {
$where .= "'AIX',";
} else {
$aix = "Unchecked";
}
} else {
$aix = "Unchecked";
}
if (isset($_GET['linux'])) {
if ($_GET['linux'] == 1) {
$where .= "'LINUX',";
} else {
$linux = "Unchecked";
}
} else {
$linux = "Unchecked";
}
$where = rtrim($where, ',') . ")";
$where = "";
if (!isset($_GET['AIX'])){$aix = "Unchecked";}
if (!isset($_GET['linux'])){$linux = "Unchecked";}
if($linux=="Unchecked" && $aix=="Unchecked"){ $where = " and 1=2 ";}
if($linux=="Unchecked" && $aix=="Checked"){ $where = " and Type ='AIX' ";}
if($linux=="Checked" && $aix=="Unchecked"){ $where = " and not Type ='AIX' ";}
$site = "";
if (isset($_GET['DUN'])) {
if ($_GET['DUN'] == 1) {
@@ -120,42 +108,53 @@
$site = " and (" . ltrim($site, ' or') . ") ";
$where .= $site;
$sql = "select hostname, os_type from srvall where decomtime is null and (ucase(filter) not like 'X_%' or filter is null) $where order by hostname";
$hosts = Invoke_aixcmdb($sql);
$sql = "select HOSTNAME, Type, OSVersion from x_srvall where Decom is null $where order by hostname";
$hosts = Invoke_Infra($sql);
//print_r($hosts);exit;
$taix = $aixok = $aixko = $tlinux = $linuxok = $linuxko = 0;
#print_r($hosts);
$resultsByHost = [];
if (!empty($hosts)) {
$hostnames = array_map(function ($h) {
return "'" . strtoupper($h['HOSTNAME']) . "'";
}, $hosts);
$hostnamesList = implode(',', $hostnames);
$sqlResults = "SELECT * FROM x_stdout WHERE cmd = '$script' AND host IN ($hostnamesList)";
$allAnswers = Invoke_Infra($sqlResults);
if (is_array($allAnswers)) {
foreach ($allAnswers as $answer) {
$resultsByHost[strtoupper($answer['host'])] = $answer;
}
}
}
?>
<form class="row">
<div class="col border rounded">
<b>Filters : </b>
<div class="form-check form-check-inline form-switch">
<input class="form-check-input" type="checkbox" role="switch" id="AIX" <?php echo $aix; ?>
name="AIX" value="1">
<input class="form-check-input" type="checkbox" role="switch" id="AIX" <?php echo $aix; ?> name="AIX" value="1">
<label class="form-check-label" for="AIX">AIX</label>
</div>
&nbsp;
<div class="form-check form-check-inline form-switch">
<input class="form-check-input" type="checkbox" role="switch" id="linux" <?php echo $linux; ?>
name="linux" value="1">
<input class="form-check-input" type="checkbox" role="switch" id="linux" <?php echo $linux; ?> name="linux" value="1">
<label class="form-check-label" for="linux">Linux</label>
</div>
&nbsp; | &nbsp;
<div class="form-check form-check-inline form-switch">
<input class="form-check-input" type="checkbox" role="switch" id="DUN" <?php echo $dun; ?>
name="DUN" value="1">
<input class="form-check-input" type="checkbox" role="switch" id="DUN" <?php echo $dun; ?> name="DUN" value="1">
<label class="form-check-label" for="DUN">DMV/DUN/MDK</label>
</div>
&nbsp;
<div class="form-check form-check-inline form-switch">
<input class="form-check-input" type="checkbox" role="switch" id="AZT" <?php echo $azt; ?>
name="AZT" value="1">
<input class="form-check-input" type="checkbox" role="switch" id="AZT" <?php echo $azt; ?> name="AZT" value="1">
<label class="form-check-label" for="AZT">Azure</label>
</div>
&nbsp;
<div class="form-check form-check-inline form-switch">
<input class="form-check-input" type="checkbox" role="switch" id="other" <?php echo $other; ?>
name="other" value="1">
<input class="form-check-input" type="checkbox" role="switch" id="other" <?php echo $other; ?> name="other" value="1">
<label class="form-check-label" for="other">Other</label>
</div>
<input type="hidden" name="s" value="<?php echo $script; ?>">
@@ -164,57 +163,55 @@
</form>
<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>
<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> <tr>
<th data-field='host' data-sortable='true'>Host</th>
<th data-field='OS' data-sortable='true'>OS</th>
<th data-field='OSVer' data-sortable='true'>Distrib</th>
<th data-field='TimeStamp' data-sortable='true'>TimeStamp</th>
<th data-field='RC' data-sortable='true'>RC</th>
<th data-field='Result' data-sortable='true'>StdOut</th>
</tr>
</thead>
<tbody> <!-- Body -->
<?php
<tbody> <?php
foreach ($hosts as $h) {
$host = strtoupper($h['HOSTNAME']);
$os = strtoupper($h['OS_TYPE']);
if (strtoupper($h['OS_TYPE']) == "AIX") {
$os = strtoupper($h['Type'] ?? "");
$osver = strtoupper($h['OSVersion'] ?? "");
if ($os == "AIX") {
$taix++;
} else {
$tlinux++;
}
$answer = Invoke_infra("SELECT * FROM x_stdout where cmd ='$script' and host ='$host'");
if (is_array($answer)) {
$rc = $answer[0]['rc'];
$stdout = $answer[0]['stdout'];
$ts = $answer[0]['ts'];
if (strtoupper($h['OS_TYPE']) == "AIX") {
$answer = $resultsByHost[$host] ?? null;
if ($answer) {
$rc = $answer['rc'];
$stdout = $answer['stdout'];
$ts = $answer['ts'];
if ($os == "AIX") {
if ($rc == 0 && (string)$rc <> "") {
$aixok++;
} else {
if ((string)$rc <> "") {
} elseif ((string)$rc <> "") {
$aixko++;
}
}
} else {
} else { // Linux
if ($rc == 0 && (string)$rc <> "") {
$linuxok++;
} else {
if ((string)$rc <> "") {
} elseif ((string)$rc <> "") {
$linuxko++;
}
}
}
} else {
$rc = $stdout = $ts = "";
}
echo "<tr><td><b>$host</b></td>";
echo "<td>$os</td>";
echo "<td>$osver</td>";
echo "<td>" . $ts . "</td>";
if ($rc == 0 && (string)$rc <> "") {
echo "<td class='table-success'>" . $rc . "</td>";
@@ -236,7 +233,8 @@
echo "<div class='row'><div class='col text-center h4'><b>$taix AIX : </b>";
echo "<span class='badge bg-success'>$aixok</span>&nbsp;<span class='badge bg-danger'>$aixko</span>&nbsp;<span class='badge bg-secondary'>$aixNO</span></div>";
echo "<div class='col text-center h4'><b>$tlinux Linux : </b>";
echo "<span class='badge bg-success'>$linuxok</span>&nbsp;<span class='badge bg-danger'>$linuxko</span>&nbsp;<span class='badge bg-secondary'>$linuxNO</span></div></div> "; ?>
echo "<span class='badge bg-success'>$linuxok</span>&nbsp;<span class='badge bg-danger'>$linuxko</span>&nbsp;<span class='badge bg-secondary'>$linuxNO</span></div></div> ";
?>
</div>
</div>
<!-- End of main content -->

View File

@@ -63,15 +63,21 @@
</div>
<!-- TABLE -->
<div>
<?php // DATA
$answers = Invoke_infra("SELECT distinct(cmd),max(ts) from x_stdout group by cmd order by max(ts) desc");
<?php
$sql = "SELECT cmd, MIN(ts) AS debut, MAX(ts) AS fin FROM x_stdout GROUP BY cmd ORDER BY fin DESC";
$results = Invoke_infra($sql);
echo "<div class='row'>";
foreach($answers as $cmd){
$ts = Invoke_infra("SELECT max(ts) as fin, min(ts) as debut FROM x_stdout where cmd = '".$cmd['cmd']."'");
echo "<div class='col-3 mb-3'><a href='StdOut-detail.php?s=".$cmd['cmd']."&AIX=1&linux=1&DUN=1' class='btn btn-primary btn-lg' role='button'>";
echo "<b>".$cmd['cmd']."</b><br><small>".$ts[0]['debut']." --> ".$ts[0]['fin']."</small>";
echo "</a></div> ";
if (is_array($results)) {
foreach ($results as $script) {
$scriptName = $script['cmd'];
$startTime = $script['debut'];
$endTime = $script['fin'];
echo "<div class='col-3 mb-3'>";
echo "<a href='StdOut-detail.php?s=$scriptName&AIX=1&linux=1&DUN=1' class='btn btn-primary btn-lg' role='button'>";
echo "<b>$scriptName</b><br><small>$startTime --> $endTime</small>";
echo "</a>";
echo "</div>";
}
}
echo "</div>";
?>

191
X/VIO.php Normal file
View File

@@ -0,0 +1,191 @@
<!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">
<title>Web Infra Reports IT</title>
<link rel="shortcut icon" type="image/png" href="/include/favicon-32x32.png">
<script src="/js/jquery-3.6.1.min.js"></script>
<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>
<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>
<style>
.cell-multiline {
white-space: nowrap;
}
/* Custom style for VIOErr badges */
.badge-err {
background-color: #dc3545 !important;
color: white;
}
</style>
</head>
<body class="bg-light text-dark">
<?php include $_SERVER['DOCUMENT_ROOT'] . "/include/all.php"; ?>
<?php
// ==========================================
// 1. DATA PROCESSING (PHP)
// ==========================================
$rawRows = Invoke_Infra("SELECT * FROM x_cmdb_VIO");
if (!$rawRows) $rawRows = [];
// Grouping
$groupedData = [];
foreach ($rawRows as $row) {
$key = $row['clintname'];
if (empty($key)) $key = "[No Client Name]";
if (!isset($groupedData[$key])) $groupedData[$key] = [];
$groupedData[$key][] = $row;
}
// Flattening for Display (1 Row per Client)
$displayRows = [];
foreach ($groupedData as $clientKey => $rows) {
// 1. Sort by date desc
usort($rows, function($a, $b) {
return strcmp($b['ts'], $a['ts']);
});
// 2. Keep max 2
if (count($rows) > 2) {
$rows = array_slice($rows, 0, 2);
}
$names = []; $inerrs = []; $vfcs = []; $vios = [];
$clintids = []; $fcnames = []; $tss = []; $vioerrs = [];
$hasError = false;
$maxVioErr = 0;
foreach ($rows as $r) {
if ($r['inerr'] != 0 && $r['inerr'] != '0') $hasError = true;
// Track VIOErr
$errVal = (int)($r['VIOErr'] ?? 0);
if ($errVal > $maxVioErr) $maxVioErr = $errVal;
// Format VIOErr for display (Red badge if > 0)
$vioerrs[] = ($errVal > 0) ? "<span class='badge badge-err'>$errVal</span>" : $errVal;
$names[] = $r['name'] ?? '-';
$inerrs[] = $r['inerr'] ?? '-';
$vfcs[] = $r['vfcclientname'] ?? '-';
$vios[] = $r['vio'] ?? '-';
$clintids[] = $r['clintid'] ?? '-';
$fcnames[] = $r['fcname'] ?? '-';
$tss[] = $r['ts'] ?? '-';
}
$displayRows[] = [
'clintname' => $clientKey,
'hasError' => $hasError,
'maxVioErr' => $maxVioErr,
'name' => implode('<br>', $names),
'inerr' => implode('<br>', $inerrs),
'vfc' => implode('<br>', $vfcs),
'vio' => implode('<br>', $vios),
'clintid' => implode('<br>', $clintids),
'fcname' => implode('<br>', $fcnames),
'ts' => implode('<br>', $tss),
'vioerr' => implode('<br>', $vioerrs),
];
}
// 4. Final Sort: 1. Warning (inerr), 2. VIOErr > 0, 3. Alpha
usort($displayRows, function($a, $b) {
// Priority 1: InErr (table-warning)
if ($a['hasError'] && !$b['hasError']) return -1;
if (!$a['hasError'] && $b['hasError']) return 1;
// Priority 2: VIOErr count
if ($a['maxVioErr'] > 0 && $b['maxVioErr'] == 0) return -1;
if ($a['maxVioErr'] == 0 && $b['maxVioErr'] > 0) return 1;
if ($a['maxVioErr'] != $b['maxVioErr']) return $b['maxVioErr'] - $a['maxVioErr'];
// Priority 3: Alphabetical
return strcasecmp($a['clintname'], $b['clintname']);
});
?>
<div class="container-fluid" id="content">
<div class="row flex-nowrap">
<div class="col-auto col-md-2 col-xl-2 px-sm-2 px-0 bg-dark vh-100 position-sticky top-0" style="flex: 0 0 230px;">
<?php include $_SERVER['DOCUMENT_ROOT'] . "/navbar.html"; ?>
</div>
<div class="col py-3">
<h1><span class="badge text-bg-secondary w-100">VIO Monitoring</span></h1>
<div class="container-fluid">
<div>
<table class='table table-bordered table-hover table-sm' id='t1'
data-toggle="table"
data-search="true"
data-show-columns="true"
data-export-types="['xlsx','csv','json']"
data-show-export="true"
data-sortable="true"> <thead>
<tr>
<th data-field="clintname" data-sortable="true">Clint Name</th>
<th data-field="name">Name</th>
<th data-field="vioerr">VIOErr</th>
<th data-field="inerr">InErr</th>
<th data-field="vfcclientname">VFC Client Name</th>
<th data-field="vio">VIO</th>
<th data-field="clintid">ClintID</th>
<th data-field="fcname">FC Name</th>
<th data-field="ts">Last Update</th>
</tr>
</thead>
<tbody>
<?php foreach ($displayRows as $row): ?>
<?php $class = $row['hasError'] ? 'table-warning' : ''; ?>
<tr class="<?php echo $class; ?>">
<td class="fw-bold align-middle"><?php echo htmlspecialchars($row['clintname']); ?></td>
<td class="cell-multiline"><?php echo $row['name']; ?></td>
<td class="cell-multiline text-center fw-bold"><?php echo $row['vioerr']; ?></td>
<td class="cell-multiline"><?php echo $row['inerr']; ?></td>
<td class="cell-multiline"><?php echo $row['vfc']; ?></td>
<td class="cell-multiline"><?php echo $row['vio']; ?></td>
<td class="cell-multiline"><?php echo $row['clintid']; ?></td>
<td class="cell-multiline"><?php echo $row['fcname']; ?></td>
<td class="cell-multiline small"><?php echo $row['ts']; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</body>
<script src="/js/switch.js"></script>
<script>
var $table = $('#t1');
function adjustTableHeight() {
let height = $(window).height() - 170;
$table.bootstrapTable('resetView', { height: height });
}
$(function () {
adjustTableHeight();
$(window).resize(function () { adjustTableHeight(); });
});
</script>
</html>

View File

@@ -27,7 +27,7 @@
</head>
<body class="bg-light text-dark">
<?php include $_SERVER['DOCUMENT_ROOT']."/../../include/db_connect.php" ; ?> <!-- Database connexion -->
<?php include $_SERVER['DOCUMENT_ROOT'] . "/include/all.php"; ?> <!-- Include All -->
<div class="container-fluid">
<div class="row flex-nowrap">
<!-- Left NAVBAR -->

View File

@@ -27,7 +27,7 @@
</head>
<body>
<?php include $_SERVER['DOCUMENT_ROOT']."/../../include/db_connect.php" ; ?> <!-- Database connexion -->
<?php include $_SERVER['DOCUMENT_ROOT'] . "/include/all.php"; ?> <!-- Include All -->
<div class="container-fluid">
<div class="row flex-nowrap">
<!-- Left NAVBAR -->

View File

@@ -29,9 +29,7 @@
</head>
<body class="bg-light text-dark">
<?php include $_SERVER['DOCUMENT_ROOT'] . "/include/preloader.inc.html"; ?> <!-- Preloader -->
<?php include $_SERVER['DOCUMENT_ROOT'] . "/../../include/db_connect.php"; ?> <!-- Database connexion -->
<?php //include $_SERVER['DOCUMENT_ROOT']."/include/functions.inc.php" ; ?> <!-- Functions -->
<?php include $_SERVER['DOCUMENT_ROOT'] . "/include/all.php"; ?> <!-- Include All -->
<div class="container-fluid">
<div class="row flex-nowrap">
<!-- Left NAVBAR -->

View File

@@ -26,8 +26,7 @@
</head>
<body class="bg-light text-dark">
<?php include $_SERVER['DOCUMENT_ROOT'] . "/../../include/db_connect.php"; ?> <!-- Database connexion -->
<?php //include $_SERVER['DOCUMENT_ROOT']."/include/functions.inc.php" ; ?> <!-- Functions -->
<?php include $_SERVER['DOCUMENT_ROOT'] . "/include/all.php"; ?>
<div class="container-fluid">
<div class="row flex-nowrap">
<!-- Left NAVBAR -->

View File

@@ -26,7 +26,7 @@
</head>
<body class="bg-light text-dark">
<?php include $_SERVER['DOCUMENT_ROOT']."/../../include/db_connect.php" ; ?> <!-- Database connexion -->
<?php include $_SERVER['DOCUMENT_ROOT'] . "/include/all.php"; ?> <!-- Include All -->
<div class="container-fluid">
<div class="row flex-nowrap">
<!-- Left NAVBAR -->

View File

@@ -26,7 +26,7 @@
</head>
<body class="bg-light text-dark">
<?php include $_SERVER['DOCUMENT_ROOT']."/../../include/db_connect.php" ; ?> <!-- Database connexion -->
<?php include $_SERVER['DOCUMENT_ROOT'] . "/include/all.php"; ?> <!-- Include All -->
<div class="container-fluid">
<div class="row flex-nowrap">
<!-- Left NAVBAR -->

View File

@@ -26,8 +26,7 @@
</head>
<body class="bg-light text-dark">
<?php include $_SERVER['DOCUMENT_ROOT']."/../../include/db_connect.php" ; ?> <!-- Database connexion -->
<?php //include $_SERVER['DOCUMENT_ROOT']."/include/functions.inc.php" ; ?> <!-- Functions -->
<?php include $_SERVER['DOCUMENT_ROOT'] . "/include/all.php"; ?> <!-- Include All -->
<div class="container-fluid">
<div class="row flex-nowrap">
<!-- Left NAVBAR -->

View File

@@ -26,7 +26,7 @@
</head>
<body class="bg-light text-dark">
<?php include $_SERVER['DOCUMENT_ROOT']."/../../include/db_connect.php" ; ?> <!-- Database connexion -->
<?php include $_SERVER['DOCUMENT_ROOT'] . "/include/all.php"; ?> <!-- Include All -->
<div class="container-fluid">
<div class="row flex-nowrap">
<!-- Left NAVBAR -->

View File

@@ -26,7 +26,7 @@
</head>
<body class="bg-light text-dark">
<?php include $_SERVER['DOCUMENT_ROOT']."/../../include/db_connect.php" ; ?> <!-- Database connexion -->
<?php include $_SERVER['DOCUMENT_ROOT'] . "/include/all.php"; ?> <!-- Include All -->
<div class="container-fluid">
<div class="row flex-nowrap">
<!-- Left NAVBAR -->

View File

@@ -26,8 +26,7 @@
</head>
<body class="bg-light text-dark">
<?php include $_SERVER['DOCUMENT_ROOT']."/../../include/db_connect.php" ; ?> <!-- Database connexion -->
<?php //include $_SERVER['DOCUMENT_ROOT']."/include/functions.inc.php" ; ?> <!-- Functions -->
<?php include $_SERVER['DOCUMENT_ROOT'] . "/include/all.php"; ?> <!-- Include All -->
<div class="container-fluid">
<div class="row flex-nowrap">
<!-- Left NAVBAR -->

View File

@@ -1,10 +1,9 @@
<?php
// CONSTANTS //
$BaseUrl = "http://".$_SERVER['SERVER_NAME'];
$root = $_SERVER['DOCUMENT_ROOT'];
$bdnuss = "http://web-bdnuss-sys-dev.appliarmony.net";
$opwsinf = "https://wsopinf.appliarmony.net";
// FUNCTIONS //
//tools//
@@ -212,9 +211,6 @@
}
}
//DB Conn//
function DB_SCCM(){
$user = "infra";
@@ -264,8 +260,282 @@
return $pdo;
}
//Cookie//
function Set_Cookie() {
// --- paramètres ---
$cookieName = 'UserInfo';
$cookieLife = 86400 * 365; // 1 an
$cookieDomain = '.appliarmony.net';
$secureFlag = true;
$httpOnly = true;
$sameSite = 'Lax';
// --- helpers ---
$now = date('Y-m-d H:i:s');
// IP client: XFF (première IP) -> fallback REMOTE_ADDR
$ip = '';
if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$parts = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
$cand = trim($parts[0]);
if (filter_var($cand, FILTER_VALIDATE_IP)) $ip = $cand;
}
if (!$ip && !empty($_SERVER['REMOTE_ADDR'])) $ip = $_SERVER['REMOTE_ADDR'];
// User Windows (SSO)
$user = $_SERVER['REMOTE_USER'] ?? null;
$hasUser = !empty($user);
// --- lecture éventuelle du cookie existant ---
$cookie = [];
if (!empty($_COOKIE[$cookieName])) {
$decoded = json_decode($_COOKIE[$cookieName], true);
if (is_array($decoded)) $cookie = $decoded;
}
// --- écriture/MAJ SEULEMENT si on a un REMOTE_USER ---
if ($hasUser) {
if (empty($cookie) || ($cookie['user'] ?? null) !== $user) {
// Nouveau cookie ou changement dutilisateur → reset
$cookie = [
'user' => $user,
'ip' => $ip,
'created' => $now,
'last' => $now
];
} else {
// Même user → on rafraîchit last + IP
$cookie['ip'] = $ip ?: ($cookie['ip'] ?? '');
$cookie['last'] = $now;
}
// Écrire le cookie (évite décrire si headers déjà envoyés)
if (!headers_sent()) {
setcookie($cookieName, json_encode($cookie), [
'expires' => time() + $cookieLife,
'path' => '/',
'domain' => $cookieDomain,
'secure' => $secureFlag,
'httponly' => $httpOnly,
'samesite' => $sameSite
]);
}
}
// --- exposer des constantes pour le reste du code ---
// Priorité: si on a REMOTE_USER on lutilise; sinon on retombe sur le cookie existant; sinon vide/anonyme.
$currentUser = $hasUser ? $user : ($cookie['user'] ?? 'Anonymous');
$currentIp = $hasUser ? $ip : ($cookie['ip'] ?? ($_SERVER['HTTP_X_FORWARDED_FOR'] ?? $_SERVER['REMOTE_ADDR'] ?? ''));
if (!defined('CURRENT_USER')) define('CURRENT_USER', $currentUser);
if (!defined('CURRENT_IP')) define('CURRENT_IP', $currentIp);
if (!defined('COOKIE_INFO')) define('COOKIE_INFO', $cookie);
}
Set_Cookie();
?>
<style>
/* 1. CONFIGURATION DES COULEURS */
:root {
/* Par défaut (Mode Clair / bg-light) : Gris visible sur blanc */
--snow-color: rgba(160, 160, 160, 0.9);
}
/* 2. DÉTECTION DU MODE SOMBRE BASÉE SUR TON SCRIPT */
/* Ton script ajoute la classe 'bg-dark' au body, on s'en sert ici */
body.bg-dark {
--snow-color: rgba(255, 255, 255, 0.9) !important;
}
/* Gestion des préférences système (OS) au cas où le script JS n'a pas encore chargé */
@media (prefers-color-scheme: dark) {
body:not(.bg-light) { /* Sauf si l'utilisateur a forcé le mode clair */
--snow-color: rgba(255, 255, 255, 0.9);
}
}
/* 3. STYLES DU CANVAS ET DU BOUTON */
#snow-canvas {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 9999; /* Au-dessus de tout */
pointer-events: none; /* LAISSE PASSER LES CLICS (Vital !) */
}
#snow-toggle-btn {
position: fixed;
/* Positionné un peu au-dessus du bas pour ne pas gêner d'autres footers */
bottom: 20px;
right: 20px;
z-index: 10000;
background: transparent;
color: var(--snow-color); /* Le bouton prend aussi la couleur du thème */
border: 1px solid var(--snow-color);
border-radius: 50%;
width: 35px;
height: 35px;
cursor: pointer;
font-size: 18px;
transition: all 0.3s;
display: flex;
align-items: center;
justify-content: center;
opacity: 0.5; /* Discret par défaut */
}
#snow-toggle-btn:hover {
opacity: 1;
background: rgba(128, 128, 128, 0.2);
}
</style>
<canvas id="snow-canvas"></canvas>
<button id="snow-toggle-btn" title="Activer/Désactiver la neige">❄️</button>
<script>
(function() {
// --- 1. GESTION DES DATES (15 Déc au 5 Jan) ---
const now = new Date();
const month = now.getMonth() + 1; // JS compte les mois de 0 à 11, donc on ajoute 1
const day = now.getDate();
// La condition : (Mois = 12 ET Jour >= 15) OU (Mois = 1 ET Jour <= 5)
const isSeason = (month === 12 && day >= 15) || (month === 1 && day <= 5);
const canvas = document.getElementById('snow-canvas');
const toggleBtn = document.getElementById('snow-toggle-btn');
// Si on n'est pas dans la période, on cache tout et on arrête le script.
if (!isSeason) {
if (canvas) canvas.style.display = 'none';
if (toggleBtn) toggleBtn.style.display = 'none';
return; // Arrêt immédiat du script
}
// --- 2. CONFIGURATION ---
const ctx = canvas.getContext('2d');
let width = window.innerWidth;
let height = window.innerHeight;
const maxFlakes = 80;
let flakes = [];
let animationId;
let isSnowing = false;
// Gestion du redimensionnement
canvas.width = width;
canvas.height = height;
window.addEventListener('resize', () => {
width = window.innerWidth;
height = window.innerHeight;
canvas.width = width;
canvas.height = height;
});
// --- 3. CLASSE FLOCON ---
class Snowflake {
constructor() {
this.reset(true);
}
reset(initial = false) {
this.x = Math.random() * width;
this.y = initial ? Math.random() * height : -10;
this.radius = Math.random() * 3 + 1;
this.speed = Math.random() * 1.5 + 0.5;
this.drift = Math.random() * 2 - 1;
}
update() {
this.y += this.speed;
this.x += this.drift;
if (this.y > height || this.x > width || this.x < 0) {
this.reset();
}
}
draw(color) {
ctx.beginPath();
ctx.fillStyle = color;
ctx.arc(this.x, this.y, this.radius, 0, Math.PI * 2, true);
ctx.fill();
}
}
// --- 4. ANIMATION ---
function initFlakes() {
flakes = [];
for (let i = 0; i < maxFlakes; i++) {
flakes.push(new Snowflake());
}
}
function animate() {
if (!isSnowing) {
ctx.clearRect(0, 0, width, height);
return;
}
ctx.clearRect(0, 0, width, height);
// Récupération dynamique de la couleur (compatible avec ton script Light Switch)
const style = getComputedStyle(document.body);
const currentColor = style.getPropertyValue('--snow-color').trim();
flakes.forEach(flake => {
flake.update();
flake.draw(currentColor);
});
animationId = requestAnimationFrame(animate);
}
// --- 5. BOUTON & INIT ---
function toggleSnow() {
isSnowing = !isSnowing;
updateButtonState();
if (isSnowing) {
initFlakes();
animate();
localStorage.setItem('snow-preference', 'on');
} else {
cancelAnimationFrame(animationId);
ctx.clearRect(0, 0, width, height);
localStorage.setItem('snow-preference', 'off');
}
}
function updateButtonState() {
if(isSnowing) {
toggleBtn.style.opacity = "1";
toggleBtn.style.background = "rgba(128, 128, 128, 0.3)";
} else {
toggleBtn.style.opacity = "0.5";
toggleBtn.style.background = "transparent";
}
}
toggleBtn.addEventListener('click', toggleSnow);
const savedPref = localStorage.getItem('snow-preference');
if (savedPref !== 'off') {
isSnowing = true;
initFlakes();
animate();
updateButtonState();
}
})();
</script>
<!-- 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">
@@ -283,3 +553,6 @@
</div>
</div>
</div>

View File

@@ -1,46 +0,0 @@
<?php
// Temporarily enable all error reporting to catch details from odbc_connect
// error_reporting(E_ALL); // Uncomment this line if you still don't get enough info
$conn_string = "DRIVER={IBM DB2 ODBC DRIVER - F_DB2_clidriver};" .
"DATABASE=AIXCMDB; " .
"HOSTNAME=db2_aixcmdb.appliarmony.net;" .
"PORT=50000; " .
"PROTOCOL=TCPIP; " .
"UID=aixcmdb;" .
"AUTHENTICATION=SERVER;" .
"PWD=aixcmdb;";
$conn = odbc_connect($conn_string, "", "");
if (!$conn) {
// --- IMPORTANT: Récupérer le message d'erreur ODBC détaillé ---
$error_message = "ODBC Connect Error: " . odbc_errormsg() . " (" . odbc_error() . ")";
echo "Pas de connexion : " . $error_message . "<br>";
// Pour débogage, tu peux aussi loguer cette erreur dans un fichier
// error_log($error_message);
return "ERROR: Could not connect to DB2. Check connection string and ODBC setup."; // Retourne une erreur pour éviter l'appel à odbc_exec
}
$rs = odbc_exec($conn, $request);
// Ton code existant après la connexion
if (strpos(strtoupper($request), "SELECT") !== false) { // strpos est plus robuste que instr ici en PHP
$answer = []; // Initialize array to prevent undefined variable warning
while ($row = odbc_fetch_array($rs)) {
$answer[] = $row;
}
}
if (isset($answer)) {
return $answer;
} else {
if ($rs) {
return "OK";
} else {
// If odbc_exec failed
error_reporting(E_ALL); // Re-enable for this specific error if needed
return "ERROR : " . odbc_errormsg($conn);
}
}

View File

@@ -25,7 +25,7 @@
</head>
<body class="bg-light text-dark">
<?php include $_SERVER['DOCUMENT_ROOT']."/../../include/db_connect.php" ; ?> <!-- Database connexion -->
<?php include $_SERVER['DOCUMENT_ROOT']."/include/all.php" ; ?> <!-- Database connexion -->
<div class="container-fluid">
<div class="row flex-nowrap">
<!-- Left NAVBAR -->

View File

@@ -33,8 +33,8 @@
<i class="fs-6 bi bi-folder-symlink-fill text-white"></i> <span class="ms-1 d-none d-sm-inline text-white h7">Shared Folders</span><i class="bi bi-caret-down"></i> </a>
<ul class="collapse nav flex-column ms-1" id="SharedFolders" data-bs-parent="#menu">
<li class="w-100">
<a href="/shared-folders/eqp-prj.php" class="nav-link px-0"> <span class="d-none d-sm-inline text-white h7">- PRJ & EQP Folders</span></a>
<a href="/shared-folders/homedirectories.php" class="nav-link px-0"> <span class="d-none d-sm-inline text-white h7">- HomeDirectories</span></a>
<a href="/Shared-Folders/eqp-prj.php" class="nav-link px-0"> <span class="d-none d-sm-inline text-white h7">- PRJ & EQP Folders</span></a>
<a href="/Shared-Folders/HomeDirectories.php" class="nav-link px-0"> <span class="d-none d-sm-inline text-white h7">- HomeDirectories</span></a>
</li>
</ul>
</li>
@@ -47,6 +47,8 @@
<a href="/X/SVA-SCU.php" class="nav-link px-0"> <span class="d-none d-sm-inline text-white h7">- SVA/SCU Accounts</span></a>
<a href="/X/autoremediationlog.php" class="nav-link px-0"> <span class="d-none d-sm-inline text-white h7">- AutoRemediation Logs</span></a>
<a href="/X/stdout.php" class="nav-link px-0"> <span class="d-none d-sm-inline text-white h7">- Scripts Result</span></a>
<a href="/X/backups.php" class="nav-link px-0"> <span class="d-none d-sm-inline text-white h7">- Backups</span></a>
<a href="/X/VIO.php" class="nav-link px-0"> <span class="d-none d-sm-inline text-white h7">- VIO</span></a>
</li>
</ul>
</li>
@@ -78,7 +80,8 @@
<ul class="collapse nav flex-column ms-1" id="Storage" data-bs-parent="#menu">
<li class="w-100">
<a href="/Storage/Dashboard.php" class="nav-link px-0"> <span class="d-none d-sm-inline text-white h7">- Dashboard IBM SAN</span></a>
<a href="/Storage/orphanluns.php" class="nav-link px-0"> <span class="d-none d-sm-inline text-white h7">- SVC Orphan LUNs</span></a>
<a href="/Storage/switchssan.php" class="nav-link px-0"> <span class="d-none d-sm-inline text-white h7">- Switchs FC</span></a>
</li>
</ul>
</li>
@@ -110,6 +113,15 @@
</li>
</ul>
</li>
<li>
<a href="#cluster" data-bs-toggle="collapse" class="nav-link px-0 align-middle">
<i class="fs-6 bi bi-pc text-white"></i> <span class="ms-1 d-none d-sm-inline text-white h7">Clusters</span><i class="bi bi-caret-down"></i> </a>
<ul class="collapse nav flex-column ms-1" id="cluster" data-bs-parent="#menu">
<li class="w-100">
<a href="/Inventory/ClusterResource.php" class="nav-link px-0" target="_blank"> <span class="d-none d-sm-inline text-white h7">- Cluster Ressources</span></a>
</li>
</ul>
</li>
<br>
<br>
<li>