I’m currently trying to integrate UPS monitoring into my Cockpit dashboard, but I’ve hit a bit of a wall. I want to be able to track power status and battery levels directly from the UI, but the data isn’t showing up as expected.
I’ve already created the following configuration files:
homeserver:/usr/share/cockpit/ups-eaton # cat index.html
<!DOCTYPE html>
<html>
<head>
<script src="../base1/cockpit.js"></script>
<link href="../base1/cockpit.css" rel="stylesheet">
</head>
<body style="padding: 20px;">
<h2>Monitor UPS Eaton 5E</h2>
<hr>
<pre id="output" style="background: #222; color: #0f0; padding: 15px; border-radius: 5px;">Czekam na dane...</pre>
<script src="ups.js"></script>
</body>
</html>
homeserver:/usr/share/cockpit/ups-eaton # cat manifest.json
{
"version": "1.0",
"display": {
"title": "UPS Eaton",
"icon": "battery-full"
}
}
homeserver:/usr/share/cockpit/ups-eaton # cat ups.js
const out = document.getElementById("output");
const refresh = () => {
cockpit.spawn(["/usr/bin/upsc", "UPS@localhost"])
.done(data => { out.innerText = data; })
.fail(err => { out.innerText = "Błąd: " + err.message; });
};
cockpit.transport.wait(refresh);
setInterval(refresh, 5000);
Despite setting these up, it’s not working.
Ładowanie danych z NUT… → Loading data from NUT…
Does anyone see a syntax error or a missing permissions step?
