-
Notifications
You must be signed in to change notification settings - Fork 8
/
index.php
148 lines (126 loc) · 5.81 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<?php
require_once 'conn/conn.php';
require_once 'auth.php';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DRMUY</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.css">
<link rel="stylesheet" href="style/style.css">
<link href="https://cdnjs.cloudflare.com/ajax/libs/flowbite/1.7.0/flowbite.min.css" rel="stylesheet" />
</head>
<body class="bg-gray-900">
<?php include "menu.php"; ?>
<div class="p-4 sm:ml-64">
<div class="container mx-auto p-4">
<div class="flex flex-wrap -mx-2 mb-4">
<div class="w-full sm:w-1/2 md:w-1/3 lg:w-1/3 xl:w-1/4 px-2 mb-4">
<div class="flex justify-between">
<div class="w-1/3 bg-gray-800 hover:bg-gray-900 rounded-lg p-4 text-center min-w-200 h-44 m-2">
<h2 class="text-2xl text-white mb-2">Network Speed</h2>
<p id="networkSpeed" class="text-4xl text-white"></p>
</div>
<div class="w-1/3 bg-gray-800 hover:bg-gray-900 rounded-lg p-4 text-center min-w-200 h-44 m-2">
<h2 class="text-2xl text-white mb-2">RAM Usage</h2>
<p id="ramUsage" class="text-4xl text-white"></p>
</div>
<div class="w-1/3 bg-gray-800 hover:bg-gray-900 rounded-lg p-4 text-center min-w-200 h-44 m-2">
<h2 class="text-2xl text-white mb-2">CPU Usage</h2>
<p id="cpuUsage" class="text-4xl text-white"></p>
</div>
</div>
</div>
<div class="w-full sm:w-1/2 md:w-1/3 lg:w-1/3 xl:w-1/4 px-2 mb-4">
<div class="flex justify-between">
<div class="w-1/3 bg-gray-800 hover:bg-gray-900 rounded-lg p-4 text-center min-w-200 h-44 m-2">
<h2 class="text-2xl text-white mb-2">Disk Utilization</h2>
<p id="diskUtilization" class="text-4xl text-white"></p>
</div>
<div class="w-1/3 bg-gray-800 hover:bg-gray-900 rounded-lg p-4 text-center min-w-200 h-44 m-2">
<h2 class="text-2xl text-white mb-2">Watching Users</h2>
<p id="onlineUsers" class="text-4xl text-white"></p>
</div>
<div class="w-1/3 bg-gray-800 hover:bg-gray-900 rounded-lg p-4 text-center min-w-200 h-44 m-2">
<h2 class="text-2xl text-white mb-2">Channels Played</h2>
<div id="channelsPlayed" class="flex flex-col items-center">
<p id="channelsPlayedCount" class="text-4xl text-white"></p>
<p class="text-sm text-gray-400">Online Channels</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
// Function to update the online users count
function updateOnlineUsersCount(data) {
var onlineUsersElem = document.getElementById('onlineUsers');
var onlineUsersCount = data.onlineUsersCount;
onlineUsersElem.textContent = onlineUsersCount;
}
// Function to update the channels played count
function updateChannelsPlayedCount(data) {
var channelsPlayedCountElem = document.getElementById('channelsPlayedCount');
var channelsPlayedCount = data.channelsPlayedCount;
var totalChannelsCount = data.totalChannelsCount;
channelsPlayedCountElem.textContent = channelsPlayedCount + ' / ' + totalChannelsCount;
}
// Function to update the network speed
function updateNetworkSpeed(data) {
var networkSpeedElem = document.getElementById('networkSpeed');
var networkUsage = data.network.toFixed(1);
networkSpeedElem.textContent = networkUsage + ' M/s';
}
// Function to update the RAM usage
function updateRamUsage(data) {
var ramUsageElem = document.getElementById('ramUsage');
var ramUsage = data.ram.toFixed(1); // Limit to 1 decimal place
ramUsageElem.textContent = ramUsage + '%';
ramUsageElem.style.color = getUsageColor(ramUsage);
}
// Function to update the CPU usage
function updateCpuUsage(data) {
var cpuUsageElem = document.getElementById('cpuUsage');
var cpuUsage = data.cpu.toFixed(1); // Limit to 1 decimal place
cpuUsageElem.textContent = cpuUsage + '%';
cpuUsageElem.style.color = getUsageColor(cpuUsage);
}
// Function to update the disk utilization
function updateDiskUtilization(data) {
var diskUtilizationElem = document.getElementById('diskUtilization');
var diskUtilization = data.diskUtilization.toFixed(1); // Limit to 1 decimal place
diskUtilizationElem.textContent = diskUtilization + '%';
diskUtilizationElem.style.color = getUsageColor(diskUtilization);
}
// Function to get the color based on the usage value
function getUsageColor(usage) {
if (usage <= 35) {
return 'green';
} else if (usage <= 70) {
return 'yellow';
} else {
return 'red';
}
}
// Function to fetch the data and update the divs
function fetchDataAndUpdate() {
$.getJSON('monitor.php', function(data) {
updateNetworkSpeed(data);
updateRamUsage(data);
updateCpuUsage(data);
updateDiskUtilization(data);
updateChannelsPlayedCount(data);
});
}
// Fetch the initial data and update the divs
fetchDataAndUpdate();
// Update the divs every 1 second
setInterval(fetchDataAndUpdate, 1000);
</script>
</body>
</html>