glance
glance copied to clipboard
[Feature Request] Scrutiny/SMART Support
I am using Scrutiny to monitor the state of my hard drives. Would be lovely to have support for that or just SMART values, and then add it to a dashboard. I might look into it myself, but first wanted to open a request.
https://github.com/AnalogJ/scrutiny
As it is right now, you gonna need a middleware.
script in node.js
const express = require('express');
const fetch = require('node-fetch');
const app = express();
const PORT = 3006;
app.get('/scrutiny-summary', async (req, res) => {
try {
const response = await fetch('http://192.168.15.3:8080/api/summary', {
headers: { 'Content-Type': 'application/json' },
});
const data = await response.json();
if (!data.success || !data.data || !data.data.summary) {
throw new Error('Failed to fetch data or invalid response structure');
}
let passed = 0;
let failed = 0;
let unknown = 0;
Object.values(data.data.summary).forEach(device => {
if (device.device && device.device.device_status !== undefined) {
switch (device.device.device_status) {
case 0: // PASSED
passed++;
break;
case 1: // FAILED
failed++;
break;
case 2: // UNKNOWN
unknown++;
break;
default:
unknown++;
break;
}
}
});
res.json({ passed, failed, unknown });
} catch (error) {
console.error(error);
res.status(500).json({ error: 'Failed to fetch data' });
}
});
app.listen(PORT, () => {
console.log(`Server running on http://192.168.15.3:${PORT}`);
});
custom-api in glance
- type: custom-api
title: Scrutiny
url: http://192.168.15.3:3006/scrutiny-summary
headers:
Accept: application/json
template: |
<div class="flex justify-between text-center">
<div class="flex-1">
<a href="http://192.168.15.3:8080" target="_blank" class="color-highlight size-h3">
<div class="color-highlight size-h3">{{ .JSON.Int "passed" | formatNumber }}</div>
</a>
<div class="size-h6">PASSED</div>
</div>
<div class="flex-1">
<div class="color-highlight size-h3">{{ .JSON.Int "failed" | formatNumber }}</div>
<div class="size-h6">FAILED</div>
</div>
<div class="flex-1">
<div class="color-highlight size-h3">{{ .JSON.Int "unknown" | formatNumber }}</div>
<div class="size-h6">UNKNOWN</div>
</div>
</div>
Result: