]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blobdiff - tools/checkup.php
Move some PHP files from ./ to ./inc: common, connection, header, footer
[irc/unrealircd/unrealircd-webpanel.git] / tools / checkup.php
index d841daa08982fca74ce5daf369b6f57efdc41901..73ede5a03ec76816576d349e407c627c0fbafb07 100644 (file)
@@ -1,14 +1,13 @@
 <?php
-require_once "../common.php";
-require_once "../connection.php";
-require_once "../header.php";
+require_once "../inc/common.php";
+require_once "../inc/connection.php";
+require_once "../inc/header.php";
 require_once "../Classes/class-checkup.php";
 
-
 $checkup = new CheckUp();
 
-
 ?>
+
 <h4>Network Health Checkup</h4>
 
 <div class="container">
@@ -105,4 +104,61 @@ $checkup = new CheckUp();
             </div>
         </div>
     </div>
-</div>
\ No newline at end of file
+</div>
+<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.js"></script>
+<body>
+<canvas id="myChart" style="width:100%;max-width:400px"></canvas>
+
+<script id="js">
+
+var xValues = ["15 minutes", "5 minutes", "1 minute"];
+var yValues = [<?php echo "\"".$cpuUsage[2]."\", \"".$cpuUsage[1]."\", \"".$cpuUsage[0]."\""; ?>];
+var barColors = ["blue", "blue", "blue"]
+
+new Chart("myChart", {
+  type: "bar",
+  type: "bar",
+  data: {
+    labels: xValues,
+    datasets: [{
+      backgroundColor: barColors,
+      data: yValues
+    }]
+  },
+
+  options: {
+    legend: {display: false},
+    title: {
+      display: true,
+      text: "CPU Usage",
+      fontSize: 16
+    },
+    scales: {
+      xAxes: [{ticks: {min: 0, max:15}}],
+      yAxes: [{ticks: {min: 0, max:1}}],
+    }
+  }
+});
+</script>
+<div id="stats-container">
+    <p id="cpu-usage">CPU Usage: </p>
+    <p id="memory-usage">Memory Usage: </p>
+</div>
+
+<script>
+    function updateStats() {
+        var xhttp = new XMLHttpRequest();
+        var BASE_URL = "<?php echo get_config("base_url"); ?>";
+        xhttp.onreadystatechange = function() {
+            if (this.readyState == 4 && this.status == 200) {
+                var data = JSON.parse(this.responseText);
+                document.getElementById("cpu-usage").innerHTML = "Current Usage: <code>" + data.cpu + "</code>";
+                document.getElementById("memory-usage").innerHTML = "Memory Usage: <code>" + data.memory + "</code>";
+            }
+        };
+        xhttp.open("GET", BASE_URL + "api/data.php", true);
+        xhttp.send();
+    }
+    updateStats();
+    setInterval(updateStats, 1000); // Update stats every second
+</script>