Added a CPU info page with some rudimentary CPU temperature polling
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Gregory Ballantine 2022-05-25 16:23:42 -04:00
parent 056a5ad2a6
commit fb1d0fc664
6 changed files with 74 additions and 35 deletions

View File

@ -1,13 +1,22 @@
si = require('systeminformation')
window.onload = () ->
# Grab the static CPU information
si.cpu()
.then((data) ->
document.getElementById('cpuInfo').innerText = data.brand
document.getElementById('cpuCores').innerText = data.physicalCores
document.getElementById('cpuThreads').innerText = data.cores
document.getElementById('cpuClock').innerText = data.speed
console.log(data)
).catch((error) ->
console.error(error)
)
# Start the CPU temperature loop
setCpuTemp()
setCpuTemp = () ->
si.cpuTemperature()
.then((data) ->
document.getElementById('cpuTemp').innerText = data.main
@ -15,11 +24,4 @@ window.onload = () ->
).catch((error) ->
console.error(error)
)
si.graphics()
.then((data) ->
document.getElementById('gpuInfo').innerText = data.controllers[0].model
console.log(data)
).catch((error) ->
console.error(error)
)
setTimeout(setCpuTemp, 2000)

10
assets/coffee/gpu.coffee Normal file
View File

@ -0,0 +1,10 @@
si = require('systeminformation')
window.onload = () ->
si.graphics()
.then((data) ->
document.getElementById('gpuInfo').innerText = data.controllers[0].model
console.log(data)
).catch((error) ->
console.error(error)
)

View File

@ -30,6 +30,16 @@ button
.container.fluid
max-width: 100%
.pageLink
text-decoration: none
i
font-size: 10rem
p
margin-top: 10px
color: #212121
font-size: 2.5rem
text-decoration: none
#header h1
text-align: center

27
assets/twig/cpu.twig Normal file
View File

@ -0,0 +1,27 @@
{% extends 'layout.twig' %}
{% block scripts %}
<script src="./js/cpu.js" charset="utf-8"></script>
{% endblock %}
{% block content %}
<header class="row">
<div class="columns twelve u-text-center">
<h1>Sentry System Info</h1>
</div>
</header>
<section class="row">
<h5>CPU Model: <span id="cpuInfo">Random CPU</span></h5>
<p><span id="cpuCores">2</span>c/<span id="cpuThreads">4</span>t @ <span id="cpuClock">2.0</span>Ghz</p>
<p>CPU temperature: <span id="cpuTemp">12</span>&deg;C</p>
</section>
<section class="row">
<div class="columns twelve">
<a href="index.html">Back</a>
</div>
</section>
{% endblock %}

View File

@ -1,39 +1,29 @@
{% extends 'layout.twig' %}
{% block scripts %}
<script src="./js/index.js" charset="utf-8"></script>
{% endblock %}
{% block content %}
<header class="row">
<div class="columns twelve u-text-center">
<h1>Sentry System Info</h1>
<h1>Sentry System Monitor</h1>
</div>
</header>
<section class="row">
<table class="columns twelve">
<thead>
<tr>
<th>HW Type</th>
<th>Hardware Model Info.</th>
<th>Current Temp.</th>
</tr>
</thead>
<tbody>
<tr>
<td>CPU</td>
<td id="cpuInfo"></td>
<td id="cpuTemp"></td>
</tr>
<tr>
<td>GPU</td>
<td id="gpuInfo"></td>
<td id="gpuTemp"></td>
</tr>
</tbody>
</table>
<!-- CPU info page link -->
<div class="columns six u-text-center">
<a class="pageLink" href="cpu.html">
<i class="fa-solid fa-microchip"></i>
<p class="u-text-center">CPU</p>
</a>
</div>
<!-- GPU info page link -->
<div class="columns six u-text-center">
<a class="pageLink" href="gpu.html">
<i class="fa-solid fa-display"></i>
<p class="u-text-center">Graphics Card</p>
</a>
</div>
</section>
{% endblock %}

View File

@ -3,8 +3,8 @@
<head>
<meta charset="UTF-8">
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'">
<link rel="stylesheet" href="{{ file_root }}/styles/skeleton-2.0.4.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css">
<link rel="stylesheet" href="{{ file_root }}//styles/sentry.css">
<title>Sentry System Monitor</title>
<script src="{{ file_root }}/js/sentry.js" charset="utf-8"></script>