feat(agent): zfs collector for pools + datasets/snapshots with fixture tests

This commit is contained in:
Carsten 2026-04-21 22:32:36 +02:00
parent 6fca450d7e
commit 8c3e953e4e
5 changed files with 305 additions and 0 deletions

37
agent/test/fixtures/zfs/zfs_list.json vendored Normal file
View file

@ -0,0 +1,37 @@
{
"output_version": { "command": "zfs list", "vers_major": 0, "vers_minor": 1 },
"datasets": {
"rpool": {
"name": "rpool",
"type": "FILESYSTEM",
"properties": {
"used": { "value": "200000000000" },
"available": { "value": "300000000000" },
"usedbysnapshots": { "value": "5000000000" }
}
},
"rpool/data": {
"name": "rpool/data",
"type": "FILESYSTEM",
"properties": {
"used": { "value": "100000000000" },
"available": { "value": "300000000000" },
"usedbysnapshots": { "value": "2000000000" }
}
},
"rpool/data@daily-2026-04-20": {
"name": "rpool/data@daily-2026-04-20",
"type": "SNAPSHOT",
"properties": {
"creation": { "value": "1745107200" }
}
},
"rpool/data@daily-2026-04-21": {
"name": "rpool/data@daily-2026-04-21",
"type": "SNAPSHOT",
"properties": {
"creation": { "value": "1745193600" }
}
}
}
}

23
agent/test/fixtures/zfs/zpool_list.json vendored Normal file
View file

@ -0,0 +1,23 @@
{
"output_version": { "command": "zpool list", "vers_major": 0, "vers_minor": 1 },
"pools": {
"rpool": {
"name": "rpool",
"size": 500000000000,
"alloc": 200000000000,
"free": 300000000000,
"frag": 17,
"cap": 40,
"health": "ONLINE"
},
"tank": {
"name": "tank",
"size": 8000000000000,
"alloc": 6000000000000,
"free": 2000000000000,
"frag": 55,
"cap": 75,
"health": "DEGRADED"
}
}
}

View file

@ -0,0 +1,45 @@
{
"output_version": { "command": "zpool status", "vers_major": 0, "vers_minor": 1 },
"pools": {
"rpool": {
"name": "rpool",
"state": "ONLINE",
"scan": {
"function": "scrub",
"state": "FINISHED",
"end_time": "Sat Apr 19 02:00:00 2026"
},
"error_count": "0",
"vdevs": {
"mirror-0": {
"name": "mirror-0",
"vdev_type": "mirror",
"state": "ONLINE",
"read_errors": "0",
"write_errors": "0",
"checksum_errors": "0"
}
}
},
"tank": {
"name": "tank",
"state": "DEGRADED",
"scan": {
"function": "scrub",
"state": "FINISHED",
"end_time": "Tue Mar 01 08:00:00 2026"
},
"error_count": "2",
"vdevs": {
"raidz2-0": {
"name": "raidz2-0",
"vdev_type": "raidz2",
"state": "DEGRADED",
"read_errors": "0",
"write_errors": "0",
"checksum_errors": "2"
}
}
}
}
}