Added : Heartbeat Map

This commit is contained in:
e025532
2024-12-10 10:17:16 +01:00
parent d528981311
commit fe0b5f6880
3 changed files with 183 additions and 1 deletions

174
reports/heartbeat.php Normal file
View File

@@ -0,0 +1,174 @@
<!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>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"; ?>
<?php // DATA
$windows = Invoke_Infra("select * from cmdb_srvall where DECOM is null and hostname not in (select server from maintenance_status where scom = 'Y' or zabbix = 'Y') order by hostname asc");
$linux = Invoke_aixcmdb("select h.hostname, h.hbtime, h.prevtime from heartbeat h left join srvall s on s.hostname = h.hostname where h.mainttime is null and h.decomtime is null and s.os_type = 'LINUX' order by h.hostname");
$aix = Invoke_aixcmdb("select h.hostname, h.hbtime, h.prevtime from heartbeat h left join srvall s on s.hostname = h.hostname where h.mainttime is null and h.decomtime is null and s.os_type = 'AIX' order by h.hostname");
$other = Invoke_aixcmdb("select h.hostname, h.hbtime, h.prevtime from heartbeat h left join srvall s on s.hostname = h.hostname where h.mainttime is null and h.decomtime is null and s.os_type is null order by h.hostname");
$lok = "<div class='row'>";$lko = "<div class='row'>";$lcount=0;
foreach($linux as $s){
if($s['HBTIME'] < date('Y-m-d H:i:s', strtotime(' -11 minutes '))){
$lko .= "<div class='col-6'><span class='badge bg-danger'>".strtoupper($s['HOSTNAME'])." since ".explode(".",$s['PREVTIME'])[0]."</span></div>";
$lcount++;
}else{
$lok .= "<div class='col-2'><span class='badge bg-success'>".strtoupper($s['HOSTNAME']." ")."</span></div>";
}
}
if($lcount){$color = "DarkOrange";$msg = $lcount." issues";}else{$color = "green";$msg = "OK";}
$aok = "<div class='row'>";$ako = "<div class='row'>";$acount=0;
foreach($aix as $s){
if($s['HBTIME'] < date('Y-m-d H:i:s', strtotime(' -11 minutes '))){
$ako .= "<div class='col-6'><span class='badge bg-danger'>".strtoupper($s['HOSTNAME'])." since".explode(".",$s['PREVTIME'])[0]."</span></div>";
$acount++;
}else{
$aok .= "<div class='col-2'><span class='badge bg-success'>".strtoupper($s['HOSTNAME']." ")."</span></div>";
}
}
$ook = "<div class='row'>";$oko = "<div class='row'>";$ocount=0;
foreach($other as $s){
if($s['HBTIME'] < date('Y-m-d H:i:s', strtotime(' -11 minutes '))){
$oko .= "<div class='col-6'><span class='badge bg-danger'>".strtoupper($s['HOSTNAME'])." since".explode(".",$s['PREVTIME'])[0]."</span></div>";
$ocount++;
}else{
$ook .= "<div class='col-2'><span class='badge bg-success'>".strtoupper($s['HOSTNAME']." ")."</span></div>";
}
}
$wok = "<div class='row'>";$wko = "<div class='row'>";$wcount=0;
foreach($windows as $s){
if($s['heartbeat'] < date('Y-m-d H:i:s', strtotime(' -16 minutes '))){
$wko .= "<div class='col-6'><span class='badge bg-danger'>".strtoupper($s['hostname'])." since ".explode(".",$s['heartbeat'])[0]."</span></div>";
$wcount++;
}else{
$wok .= "<div class='col-2'><span class='badge bg-success'>".strtoupper($s['hostname']." ")."</span></div>";
}
}
?>
<!-- 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 -->
<h1><span class="badge text-bg-secondary font-weight-bold" style="width:100%;">HeartBeat Map for servers NOT in maintenance</span></h1>
<!-- Main content -->
<div class="container">
<!-- TABLE -->
<div>
<div id="accordion">
<?php if($wcount){$color = "DarkOrange";$msg = "<b> --> ".$wcount." issue(s)</b>";}else{$color = "green";$msg = "OK";} ?>
<div class="card" style='background-color:<?php echo $color ?>;'>
<h4 class="card-header">
<a class="btn text-white" data-bs-toggle="collapse" href="#windows"><b><h3>Windows : <?php echo count($windows)." Devices ". $msg; ?></h3></b></a>
</h4>
</div>
<div id="windows" class="collapse" data-bs-parent="#accordion">
<?php echo "<br><h5>".$wko.'</div><br><br>'.$wok."</div></h5>"; ?>
</div>
<br>
<?php if($lcount){$color = "DarkOrange";$msg = "<b> --> ".$lcount." issue(s)</b>";}else{$color = "green";$msg = "OK";} ?>
<div class="card" style='background-color:<?php echo $color ?>;'>
<h4 class="card-header">
<a class="btn text-white" data-bs-toggle="collapse" href="#linux"><b><h3>Linux : <?php echo count($linux)." Devices ". $msg; ?></h3></b></a>
</h4>
</div>
<div id="linux" class="collapse" data-bs-parent="#accordion">
<?php echo "<br><h5>".$lko.'</div><br><br>'.$lok."</div></h5>"; ?>
</div>
<br>
<?php if($acount){$color = "DarkOrange";$msg = "<b> --> ".$acount." issue(s)</b>";}else{$color = "green";$msg = "OK";} ?>
<div class="card" style='background-color:<?php echo $color ?>;'>
<h4 class="card-header text-white">
<a class="btn text-white" data-bs-toggle="collapse" href="#aix"><b><h3>AIX : <?php echo count($aix)." Devices ". $msg; ?></h3></b></a>
</h4>
</div>
<div id="aix" class="collapse" data-bs-parent="#accordion">
<?php echo "<br><h5>".$ako.'</div><br><br>'.$aok."</div></h5>"; ?>
</div>
<br>
<?php if($ocount){$color = "DarkOrange";$msg = "<b> --> ".$ocount." issue(s)</b>";}else{$color = "green";$msg = "OK";} ?>
<div class="card" style='background-color:<?php echo $color ?>;'>
<h4 class="card-header text-white">
<a class="btn text-white" data-bs-toggle="collapse" href="#other"><b><h3>Other : <?php echo count($other)." Devices ". $msg; ?></h3></b></a>
</h4>
</div>
<div id="other" class="collapse" data-bs-parent="#accordion">
<?php echo "<br><h5>".$oko.'</div><br><br>'.$ook."</div></h5>"; ?>
</div>
<br>
</div>
</div>
<!-- End of main content -->
</div>
</div>
</div>
</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);
</SCRIPT>