Thursday, March 21, 2024

 <!DOCTYPE html>

<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>System Monitor</title>
  <style>
      * {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: Arial, sans-serif;
  background-color: #f1f1f1;
  padding: 20px;
}

.container {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-around;
  margin: 0 auto;
  max-width: 800px;
}

.box {
  background-color: #fff;
  border: 1px solid #ccc;
  border-radius: 5px;
  padding: 20px;
  margin: 20px;
  width: calc(50% - 40px);
  min-width: 300px;
  text-align: center;
  box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
}

.title {
  font-size: 24px;
  font-weight: bold;
  margin-bottom: 10px;
}

.cpu-meter, .memory-meter {
  position: relative;
  height: 40px;
  background-color: #ddd;
  border-radius: 20px;
}

.cpu-bar, .memory-bar {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  border-radius: 20px;
}

.cpu-bar {
  background-color: #fc605b;
}

.memory-bar {
  background-color: #43b581;
}

.percent {
  font-size: 36px;
  font-weight: bold;
  margin-top: 10px;
  color: #666;
}

  </style>
</head>
<body>
  <div class="container">
    <div class="box">
      <div class="title">CPU Usage</div>
      <div class="cpu-meter">
        <div class="cpu-bar" id="cpu-bar"></div>
      </div>
      <div class="percent" id="cpu-percent">0%</div>
    </div>
    <div class="box">
      <div class="title">Memory Usage</div>
      <div class="memory-meter">
        <div class="memory-bar" id="memory-bar"></div>
      </div>
      <div class="percent" id="memory-percent">0%</div>
    </div>
  </div>
  <script>
      // CPU usage
const cpuBar = document.getElementById('cpu-bar');
const cpuPercent = document.getElementById('cpu-percent');

function updateCPUUsage() {
  const randomNum = Math.floor(Math.random() * 101);
  cpuBar.style.width = randomNum + '%';
  cpuPercent.textContent = randomNum + '%';
}

setInterval(updateCPUUsage, 2000);

// Memory usage
const memoryBar = document.getElementById('memory-bar');
const memoryPercent = document.getElementById('memory-percent');

function updateMemoryUsage() {
  const randomNum = Math.floor(Math.random() * 101);
  memoryBar.style.width = randomNum + '%';
  memoryPercent.textContent = randomNum + '%';
}

setInterval(updateMemoryUsage, 3000);

  </script>
</body>
</html>

No comments:

Post a Comment

AI Story Writing Tool AI Story Writing Tool Moral Educational Historical ...