r030: convert Unraid disk KiB values to bytes at source boundary

This commit is contained in:
Mikei386 committed 2026-10-11 17:10:22 +02:00
1 parent cd5694bf6a
commit b72fdd90e0
10 files changed
+74 -14

No files matched your search

+2 -2
View File
@@ -99,10 +99,10 @@ Oder manuell:
```bash
# .txz von Gitea laden
curl -O https://git.casaderoll.de/michael/MUA-Mikes-Unraid-Agent/raw/branch/main/dist/mua-2026.09.21.r029-x86_64-1.txz
curl -O https://git.casaderoll.de/michael/MUA-Mikes-Unraid-Agent/raw/branch/main/dist/mua-2026.10.11.r030-x86_64-1.txz
# Installieren
upgradepkg --install-new mua-2026.09.21.r029-x86_64-1.txz
upgradepkg --install-new mua-2026.10.11.r030-x86_64-1.txz
```
### 2. Service starten
+33
View File
@@ -0,0 +1,33 @@
# Storage byte units — r030 (2026-10-11)
`unraid_storage_status` calls `runStatusHelper("storage-status")`, which executes
`scripts/unraid-mcp-status-helper.php`. `storage_status()` reads
`/var/local/emhttp/disks.ini`; `selected_disk()` formerly copied KiB values into
fields labelled bytes.
Only `fsSize` (fallback `size`), `fsUsed`, and `fsFree` are multiplied by 1024.
Unraid's installed `webGui/nchan/device_list` and `include/DiskList.php` likewise
multiply filesystem values by 1024. `df -k /mnt/disk1` independently reproduces
all three raw filesystem values. The fallback `size * 1024` matches blockdev.
The generic numeric parser, filesize byte outputs and memory processing are
unchanged. `/proc/meminfo` already receives one KiB-to-byte conversion.
Observed on disk1 / /dev/md1p1:
| Source | KiB | Bytes (independent host check) |
|---|---:|---:|
| fsSize | 7811938628 | 7999425155072 |
| fsUsed | 6683446380 | 6843849093120 |
| fsFree | 1128492248 | 1155576061952 |
| size (partition) | 7814025540 | 8001562152960 |
Filesystem figures match `df -B1 /mnt/disk1`; partition capacity matches
`blockdev --getsize64 /dev/md1p1`. They measure different layers: filesystem
capacity is 2,136,997,888 bytes smaller than partition capacity. Preserve
filesystem capacity for consistency with filesystem used/free, rather than
forcing equality with raw block-device size. Used + free = filesystem capacity;
percentage is unchanged (85.6%). Cached emhttp data may lag current df during writes.
Validation: 10 PHP storage regression checks on Unraid, including memory;
20 existing Bun security tests; TypeScript check; package build and XML validation.
Live MCP validation is recorded after installation. No storage or media changes.
+1 -1
View File
@@ -10,7 +10,7 @@
error_reporting(E_ALL);
ini_set('display_errors', 0); // Fehler werden als JSON-RPC-Error zurückgegeben, nicht als HTML
const MUA_VERSION = '2026.09.21.r029';
const MUA_VERSION = '2026.10.11.r030';
const MUA_SERVER_NAME = 'mua';
/**
+1 -1
View File
@@ -21,7 +21,7 @@ const MUA_PORT = 3002;
const MUA_BIND = '0.0.0.0';
const MUA_SESSION_TTL = 3600; // Sekunden
const MUA_SERVER_NAME = 'mua';
const MUA_VERSION = '2026.09.21.r029';
const MUA_VERSION = '2026.10.11.r030';
// ── Session-Management (in-memory) ───────────────────────────────────────
$sessions = []; // session_id => ['created' => time, 'initialized' => bool]
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "mua",
"version": "2026.09.21.r029",
"version": "2026.10.11.r030",
"description": "Mikes Unraid Agent - MCP over HTTP (Streamable HTTP) for Unraid",
"type": "module",
"main": "src/index.ts",
+8 -4
View File
@@ -2,13 +2,13 @@
<!DOCTYPE PLUGIN [
<!ENTITY name "mua">
<!ENTITY author "Michael">
<!ENTITY version "2026.09.21.r029">
<!ENTITY version "2026.10.11.r030">
<!ENTITY launch "Settings/mua">
<!ENTITY pluginURL "https://git.casaderoll.de/michael/MUA-Mikes-Unraid-Agent/raw/branch/main/plugin/mua.plg">
<!ENTITY pluginLOC "/boot/config/plugins/&name;">
<!ENTITY emhttpLOC "/usr/local/emhttp/plugins/&name;">
<!ENTITY txzURL "https://git.casaderoll.de/michael/MUA-Mikes-Unraid-Agent/raw/branch/main/dist/mua-2026.09.21.r029-x86_64-1.txz">
<!ENTITY txzSHA256 "9de60f05d97801dd9da33556e9696f78559659f76e816b642611515565d7d73c">
<!ENTITY txzURL "https://git.casaderoll.de/michael/MUA-Mikes-Unraid-Agent/raw/branch/main/dist/mua-2026.10.11.r030-x86_64-1.txz">
<!ENTITY txzSHA256 "c4498aa6874cd64960b7fcef920e156265f40802e0c6f98ba7c62e10c44283bd">
]>
<PLUGIN name="&name;"
@@ -23,6 +23,10 @@
>
<CHANGES>
### 2026.10.11.r030
- Konvertiert disks.ini-Kapazität, belegt und frei gezielt von KiB in Bytes. RAM und bereits bytebasierte Quellen bleiben unverändert.
- Regressionstest und Live-Abgleich mit df -B1 und blockdev dokumentiert.
### 2026.09.21.r029
- Liest mehrzeilige URBM- und Unraid-Benachrichtigungen ohne PHP-Parserwarnungen.
- Erhält Benachrichtigungstext wörtlich, ohne INI-Variablen auszuwerten; ergänzt Regressionstests.
@@ -177,7 +181,7 @@ Das .txz enthält:
install/doinst.sh (läuft nach Installation)
===========================================
-->
<FILE Name="/boot/config/plugins/&name;/mua-2026.09.21.r029-x86_64-1.txz" Run="upgradepkg --install-new" Mode="755" Min="7.0.0">
<FILE Name="/boot/config/plugins/&name;/mua-2026.10.11.r030-x86_64-1.txz" Run="upgradepkg --install-new" Mode="755" Min="7.0.0">
<URL>&txzURL;</URL>
<SHA256>&txzSHA256;</SHA256>
</FILE>
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "mua",
"author": "Michael",
"version": "2026.09.21.r029",
"version": "2026.10.11.r030",
"minver": "7.0.0",
"pluginDirectory": "/usr/local/emhttp/plugins/mua",
"configDirectory": "/boot/config/plugins/mua",
+20
View File
@@ -0,0 +1,20 @@
<?php
require_once __DIR__ . '/unraid-mcp-status-helper.php';
function check_units(string $label, mixed $want, mixed $got): void {
if ($want !== $got) throw new RuntimeException("FAIL: $label");
echo "PASS: $label\n";
}
$d = selected_disk(['fsSize'=>'7811938628','fsUsed'=>'6683446380','fsFree'=>'1128492248']);
check_units('filesystem bytes vs df -B1', 7999425155072, $d['size_bytes']);
check_units('used bytes vs df -B1', 6843849093120, $d['used_bytes']);
check_units('free bytes vs df -B1', 1155576061952, $d['free_bytes']);
check_units('consistent sum', $d['size_bytes'], $d['used_bytes']+$d['free_bytes']);
check_units('percentage unchanged', 85.6, $d['used_percent']);
check_units('fallback partition size in KiB', 8001562152960, selected_disk(['size'=>'7814025540'])['size_bytes']);
check_units('filesystem capacity preferred', 2048, selected_disk(['fsSize'=>'2','size'=>'4'])['size_bytes']);
check_units('missing fields', 0, selected_disk([])['size_bytes']);
check_units('generic numeric byte values untouched', 8001562152960, number_value('8001562152960'));
if (is_readable('/proc/meminfo')) {
preg_match('/^MemTotal:\s+(\d+)\s+kB/m', file_get_contents('/proc/meminfo'), $m);
check_units('RAM converted exactly once', (int)$m[1]*1024, system_health()['memory']['total_bytes']);
}
+6 -3
View File
@@ -91,9 +91,12 @@ function system_health(): array {
}
function selected_disk(array $disk): array {
$size = number_value($disk['fsSize'] ?? $disk['size'] ?? 0);
$used = number_value($disk['fsUsed'] ?? 0);
$free = number_value($disk['fsFree'] ?? 0);
// emhttp disks.ini reports fsSize/fsUsed/fsFree and fallback size in KiB.
// Convert only these source fields; number_value and RAM/file byte values stay unchanged.
// fsSize is filesystem capacity, not the raw block-device capacity.
$size = number_value($disk['fsSize'] ?? $disk['size'] ?? 0) * 1024;
$used = number_value($disk['fsUsed'] ?? 0) * 1024;
$free = number_value($disk['fsFree'] ?? 0) * 1024;
return [
'name' => $disk['name'] ?? '',
'device' => $disk['device'] ?? '',
+1 -1
View File
@@ -15,7 +15,7 @@ import { existsSync, mkdirSync, readFileSync, rmSync, statSync, writeFileSync }
// ── Konstanten ──────────────────────────────────────────────────────────
export const MUA_SERVER_NAME = "mua";
export const MUA_VERSION = "2026.09.21.r029";
export const MUA_VERSION = "2026.10.11.r030";
export const MUA_PROTOCOL_VERSION = "2025-03-26";
export const PHP_HELPER = "/usr/local/bin/unraid-docker-mcp-helper.php";
export const STATUS_HELPER = "/usr/local/bin/unraid-mcp-status-helper.php";