Skip to content

Commit 038805f

Browse files
authored
Add atomic CSV report for all-guests scans (#16)
Write semicolon-delimited CSV after full scan with ISO 8601 filename Allow selecting output directory via --csv-dir and interactive Options Include namespace path, last snapshot comment, and unique size in GiB Bump version to 2.10.0 and update README/CHANGELOG
2 parents e2f5da5 + 8b907ef commit 038805f

3 files changed

Lines changed: 222 additions & 21 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# 📝 Changelog
22

3+
- 2.10.0
4+
- Add CSV reporting for full datastore scans (`--all-guests`), written atomically at the end with an ISO 8601 timestamp filename.
5+
- Include namespace path with VM/CT ID, latest snapshot comment, and unique chunk size in GiB (fixed precision) in the CSV output.
6+
- Allow selecting the CSV output directory via `--csv-dir` and the interactive Options menu.
37
- 2.9.0
48
- Add an optional `--show-comments` flag and corresponding interactive option to show a short label derived from the latest PBS snapshot comment next to each VM/CT in the per‑guest summary and interactive search‑path selector (best‑effort, using `proxmox-backup-debug api get /admin/datastore/<DATASTORE>/snapshots`).
59
- Simplify the per‑guest overview output by removing the raw byte count from each line and keeping only the human‑readable IEC size (GiB / MiB / TiB) to improve readability.

README.md

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ It calculates the **real disk space usage** of a specific **namespace**, **VM**,
99

1010
This allows accurate insights into space consumption per tenant or object — useful for chargeback, reporting, and storage optimization.
1111

12-
**Current version:** 2.9.0 (`./pbs_chunk_checker.py --version`)
12+
**Current version:** 2.10.0 (`./pbs_chunk_checker.py --version`)
1313

1414
See full changes in `CHANGELOG.md`.
1515

@@ -61,6 +61,9 @@ Examples:
6161
# Per-guest summary for a datastore (all namespaces)
6262
./pbs_chunk_checker.py --datastore MyDatastore --all-guests
6363

64+
# Per-guest summary with CSV output directory
65+
./pbs_chunk_checker.py --datastore MyDatastore --all-guests --csv-dir /tmp/pbs-reports
66+
6467
# Per-guest summary limited to one namespace (and its nested namespaces)
6568
./pbs_chunk_checker.py --datastore MyDatastore --searchpath /ns/MyNamespace --all-guests
6669
```
@@ -76,14 +79,14 @@ In interactive mode you can:
7679
- Select an existing datastore from the list or enter one manually
7780
- Navigate the datastore directory structure and choose the search path (or enter it manually)
7881
- Scan all guests within the current path (datastore root or a selected namespace) to get a per-guest size overview, sorted by usage
79-
- Open the Options overlay (press `o`) to adjust threads, toggle emoji output, and enable guest comments next to IDs
82+
- Open the Options overlay (press `o`) to adjust threads, toggle emoji output, enable guest comments next to IDs, and set the CSV output directory for full datastore scans
8083
- When starting the full datastore scan you will see a warning and must confirm with `Proceed anyway? [y/N]` (English prompt) because the run can take a long time.
8184

8285
Interactive controls (TUI):
8386
- Use Up/Down arrows (or j/k) to move
8487
- Press Space or Enter to select/confirm
8588
- Press m to enter a value/path manually
86-
- Press o to open Options (threads)
89+
- Press o to open Options (threads, emoji output, comments, CSV path)
8790
- Press v to show current version
8891
- Press q (or Esc) to abort
8992
- Inside the Options overlay, press Space to toggle items (Emoji output shows ✔/✘)
@@ -132,15 +135,29 @@ Notes:
132135
|--------|-------------|-------------|---------|
133136
| `--datastore` | Required (script mode) | PBS datastore name that contains the object you want to analyse ||
134137
| `--searchpath` | Required (script mode) | Object path inside the datastore (e.g. `/ns/MyNamespace` or `/ns/MyNamespace/vm/100`) ||
135-
| `--all-guests` | Optional | Scan the entire datastore (or only the namespace given via `--searchpath`) and print a per-guest size summary (requires `--datastore`) ||
138+
| `--all-guests` | Optional | Scan the entire datastore (or only the namespace given via `--searchpath`), print a per-guest size summary, and write a CSV report (requires `--datastore`) ||
136139
| `--threads` | Optional | Degree of parallelism for parsing index files and statting chunks | `2 × CPU cores (max 32)` |
137140
| `--no-emoji` | Optional | Replace emoji icons in CLI output with ASCII labels | Emoji output |
138141
| `--show-comments` | Optional | Show a short guest label derived from the latest snapshot comment next to each VM/CT in per-guest summaries and interactive path selection | Disabled |
142+
| `--csv-dir` | Optional | Directory where the CSV report for `--all-guests` is written | Current working directory |
139143
| `--version` | Optional | Show the script version and exit ||
140144
| `--update` | Optional | Check for new releases and offer self-update, then exit ||
141145

142146
---
143147

148+
### CSV output for full datastore scans
149+
150+
When running with `--all-guests`, the script writes a CSV report **after** the scan finishes.
151+
152+
- File name: ISO 8601 timestamp, e.g. `2025-07-01T12:34:56.csv`
153+
- Output directory: current working directory by default, or via `--csv-dir` / the Options overlay
154+
- Separator: `;` (semicolon)
155+
- Columns: `namespace_path`, `last_comment`, `unique_size_gib`
156+
- Size unit: GiB (1024^3 bytes), fixed 3-decimal precision
157+
- The CSV is written automically at the end so no partial file is left behind on errors
158+
159+
---
160+
144161
## 🔄 Update (Releases)
145162

146163
In the interactive menus, press `v` (Version) to see the current version. While opening this menu, the script checks in the background for a newer release on GitHub. If one is available, you will be offered to update automatically. The script downloads the latest `pbs_chunk_checker.py` and replaces the current file atomically (a `.bak` backup is kept next to it). Restart the script to use the new version.

0 commit comments

Comments
 (0)