>_nexthopreachable

My Disk Manager Script Grew Up and Got a Web Interface

Ali Bahadır Coşkun5 min read

A while ago I wrote about disk.py, a Python script I built to manage a 12-slot SAS backplane after HDSentinel kept losing track of which disks were in which slots. It used PHY symlink paths instead of /dev/sdX names, ran health checks with explicit targets, formatted disks in parallel, and had a terminal-based progress monitor that polled sg_requests independently per device so you could actually read the output. I was pretty happy with it. Since then it grew a web UI and a logs tab.

WHY THE CLI WASN'T ENOUGH

The CLI worked fine. The issue was more about the experience of checking on things. To see the shelf state I had to SSH in, run sudo disk health, and read a terminal table. Opening a browser tab is faster than that.

The other thing was the visual representation. A 12-row text table and a visual grid of 12 bays are showing the same information, but one of them lets you see at a glance that slot 7 is missing without reading every row. For something that has a direct physical layout, a spatial UI makes more sense, and once I decided to build that I needed somewhere to serve it from.

HOW IT IS BUILT

The web app is a Flask backend in web/app.py that imports disk.py directly as a module. All the device discovery, health scanning, formatting, and polling logic stays in the original script. The web layer just calls into it and exposes the results over a REST API. Everything that already worked in the CLI keeps working exactly the same way. The frontend is plain HTML and JavaScript with no framework. The whole UI lives in a single index.html file.

THE SLOT COMMAND CENTER

The main view shows a front-panel representation of the 12-slot backplane at the top, and a detailed table below it. In the screenshot below you can see a mostly empty shelf, only slots 8 and 11 are PRESENT, shown with green indicators and real serial numbers. The other ten slots show MISSING in red.

The bay grid at the top is clickable. You can click individual bays to toggle them in and out of your selection, and the table rows below support the same multi-select through checkboxes. The selection summary in the top right of the table section always shows how many slots are selected versus how many are actually actionable (meaning present and not currently formatting).

Selecting a bay expands a detail card below the grid. It shows device path, health, format status, zeroed state, size, serial, and model for that slot. Below the disk info there are three result panels that persist across operations: last health check result, last speed test with the tested timestamp, and last format state with the outcome and timestamp. Before this the only way to know when a format finished and whether it succeeded was to go dig through the log file.

The speed test panel expands into a full results table when you run one, showing each disk that was tested, its device path, serial, speed in MB/s, and the time it was tested. The format monitor panel works similarly, it shows state, progress percentage, elapsed time, and ETA per disk, and updates on each poll tick.

The table below the bay grid shows the full slot inventory: status, health percentage, sector format, zeroed state, device path, serial, and model, all in one place. For present disks you also get the action buttons directly on the row so you do not have to select the bay first. There is an Export Excel button at the bottom if you want a snapshot of the shelf state, mostly useful when you are tracking a batch of disks across multiple format and zeroed cycles.

One thing I added across the whole UI is inventory integration. Rather than showing the raw model string from the disk, which is not always reliable, the tool matches each disk by serial number against a local inventory export and shows the asset name instead. It makes a difference when you are looking at a shelf full of drives and need to know which one is which without cross-referencing a spreadsheet separately.

THE LOGS TAB

The CLI was already writing lifecycle events to diskops.log, but in practice I rarely looked at it. The Logs tab made it readable enough to actually use.

Real entries from the log look like this:

text
FORMAT_STARTED mode=full slot=2 dev=/dev/sdc model=ST3600057SS serial=6SL43LSLFORMAT_STARTED mode=full slot=5 dev=/dev/sdh model=ST3600057SS serial=6SL1V37JFORMAT_COMPLETE slot=2 dev=/dev/sdc model=ST3600057SS serial=6SL43LSLFORMAT_COMPLETE slot=5 dev=/dev/sdh model=ST3600057SS serial=6SL1V37JSPEEDTEST slot=1 read=198 MB/sSPEEDTEST slot=11 read=202 MB/s

Logs tab in the web app look like this:

The logs also feed the "Last Format State" panel in the slot detail view, which shows when the last format completed and how long it took. Before this, figuring that out meant digging into the raw log file and calculating the difference between FORMAT_STARTED and FORMAT_COMPLETE timestamps yourself.

CONCLUSION

I am still running this on the same server as before, connected to the same backplane, formatting the same rotating rust. The web UI did not change any of the underlying logic, it just made checking on the shelf state faster and gave the physical layout a visual representation that actually matches how the bays are arranged. That turned out to be worth building.