Add VIO FC Status monitoring page and enhance server inventory filtering
- Introduced `Storage/VIO.php` for monitoring VIO Fibre Channel status with client balancing checks and table sorting. - Updated `/include/en.php` and `/include/fr.php` to include new translations for ServiceNow and VIO-related navigation elements. - Improved SQL query and filtering logic in `/X/Inventory.php` to exclude VIO entries and add XenSam version data. - Enhanced `/reports/heartbeat.php` with a new mechanism for handling server heartbeat status, allowing better granularity and readability.
This commit is contained in:
213
Astreinte/p1-p2.php
Normal file
213
Astreinte/p1-p2.php
Normal file
@@ -0,0 +1,213 @@
|
||||
<?php
|
||||
// ServiceNow credentials
|
||||
$snowUser = '9000056';
|
||||
$snowPass = 'tQNpID6m$';
|
||||
|
||||
$baseUrl = 'https://arcelormittalprod.service-now.com/api/now/table/incident';
|
||||
|
||||
function snowValue($value): string
|
||||
{
|
||||
if (is_array($value)) {
|
||||
return $value['display_value']
|
||||
?? $value['value']
|
||||
?? json_encode($value);
|
||||
}
|
||||
|
||||
return (string)$value;
|
||||
}
|
||||
|
||||
$query = implode('^', [
|
||||
'active=true',
|
||||
'incident_stateNOT IN7,6',
|
||||
'priorityIN1,2',
|
||||
'opened_atRELATIVEGE@hour@ago@72'
|
||||
]);
|
||||
|
||||
$params = [
|
||||
'sysparm_query' => $query,
|
||||
'sysparm_display_value' => 'true',
|
||||
'sysparm_fields' => 'sys_id,number,assignment_group,short_description,assigned_to,priority,opened_at',
|
||||
'sysparm_order_byDESC' => 'opened_at',
|
||||
];
|
||||
|
||||
$url = $baseUrl . '?' . http_build_query($params);
|
||||
|
||||
$ch = curl_init($url);
|
||||
|
||||
curl_setopt_array($ch, [
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_USERPWD => $snowUser . ':' . $snowPass,
|
||||
CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
|
||||
CURLOPT_HTTPHEADER => [
|
||||
'Accept: application/json'
|
||||
],
|
||||
CURLOPT_SSL_VERIFYPEER => false,
|
||||
CURLOPT_SSL_VERIFYHOST => 2,
|
||||
CURLOPT_PROXY => 'gateway.zscalertwo.net:10299',
|
||||
]);
|
||||
|
||||
$response = curl_exec($ch);
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
$error = curl_error($ch);
|
||||
|
||||
curl_close($ch);
|
||||
|
||||
$incidents = [];
|
||||
$errorMessage = null;
|
||||
|
||||
if ($error) {
|
||||
$errorMessage = "Erreur cURL : " . $error;
|
||||
} elseif ($httpCode !== 200) {
|
||||
$errorMessage = "Erreur ServiceNow HTTP " . $httpCode;
|
||||
} else {
|
||||
$data = json_decode($response, true);
|
||||
$incidents = $data['result'] ?? [];
|
||||
}
|
||||
?>
|
||||
|
||||
<!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 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>
|
||||
|
||||
</head>
|
||||
|
||||
<body class="bg-light text-dark">
|
||||
<?php
|
||||
include $_SERVER['DOCUMENT_ROOT'] . "/include/all.php";
|
||||
?>
|
||||
<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%;"><?php echo $ti_20;?></span></h1>
|
||||
<div class="container-fluid">
|
||||
<?php if ($errorMessage): ?>
|
||||
|
||||
<div class="alert alert-danger">
|
||||
<?= htmlspecialchars($errorMessage) ?>
|
||||
</div>
|
||||
|
||||
<?php else: ?>
|
||||
|
||||
<?php
|
||||
$p1 = 0; $p2 = 0;
|
||||
foreach ($incidents as $inc) {
|
||||
$p = $inc['priority'] ?? '';
|
||||
if (str_contains($p, '1')) $p1++;
|
||||
if (str_contains($p, '2')) $p2++;
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="alert alert-info text-center">
|
||||
<div class="d-inline-flex align-items-center justify-content-center gap-3">
|
||||
<span><strong><?= count($incidents) ?></strong> <?= $w_incFound ?> :</span>
|
||||
<span class="badge bg-danger text-white">P1 : <?= $p1 ?></span>
|
||||
<span class="badge bg-warning text-black">P2 : <?= $p2 ?></span>
|
||||
</div>
|
||||
</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" data-sort-name="Opened" data-sort-order="desc">
|
||||
<thead class="table-dark">
|
||||
<tr>
|
||||
<th data-field="Ticket" data-sortable="true">INC</th>
|
||||
<th data-field="Priority" data-sortable="true">P1/P2</th>
|
||||
<th data-field="Group" data-sortable="true"><?= $w_group ?></th>
|
||||
<th data-field="Assigned" data-sortable="true"><?= $w_assigned ?></th>
|
||||
<th data-field="Opened" data-sortable="true"><?= $w_opened ?></th>
|
||||
<th data-field="Descr" data-sortable="true">Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<?php if (empty($incidents)): ?>
|
||||
|
||||
<tr>
|
||||
<td colspan="6" class="text-center text-muted p-4">
|
||||
Aucun incident trouvé.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php else: ?>
|
||||
|
||||
<?php foreach ($incidents as $incident): ?>
|
||||
<?php
|
||||
$priority = $incident['priority'] ?? '';
|
||||
|
||||
$badgeClass = match (true) {
|
||||
str_contains($priority, '1') => 'badge bg-danger text-white',
|
||||
str_contains($priority, '2') => 'badge bg-warning text-black',
|
||||
default => 'secondary'
|
||||
};
|
||||
?>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<strong><a
|
||||
href="https://arcelormittalprod.service-now.com/incident.do?sys_id=<?= urlencode($incident['sys_id']) ?>"
|
||||
target="_blank"
|
||||
class="fw-bold text-decoration-none"
|
||||
>
|
||||
<?= htmlspecialchars($incident['number'] ?? '') ?>
|
||||
</a></strong>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<span class="<?= $badgeClass ?>">
|
||||
<?= htmlspecialchars($priority) ?>
|
||||
</span>
|
||||
</td>
|
||||
|
||||
<td><small><?= htmlspecialchars(snowValue($incident['assignment_group']) ?? '') ?></small></td>
|
||||
<td><small><?= htmlspecialchars(snowValue($incident['assigned_to']) ?? '') ?></small></td>
|
||||
<td><?php
|
||||
if (!empty($incident['opened_at'])) {
|
||||
$date = new DateTime($incident['opened_at']);
|
||||
echo htmlspecialchars($date->format('d-m H:i'));
|
||||
}
|
||||
?></td>
|
||||
<td><?= htmlspecialchars($incident['short_description'] ?? '') ?></td>
|
||||
</tr>
|
||||
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<script src="/js/switch.js"></script>
|
||||
</HTML>
|
||||
<script src="/js/tableResize2.js"></script>
|
||||
Reference in New Issue
Block a user