TrueNAS Scale Storage Tracker
A CLI tool to list storage usage for each data pool in TrueNAS SCALE using the TrueNAS API.
Features
- Lists all data pools with total size, used size, free size, and percentage used.
- Supports output in Text (default), JSON, and CSV formats.
- Configurable via
.envfile. - Robust error handling.
Prerequisites
- Python 3.x
requestspython-dotenv
Installation
- Clone the repository or navigate to the project directory.
- Install dependencies:
pip install -r requirements.txt
Configuration
-
Copy the
.env.templateto.env:cp .env.template .env -
Edit
.envand provide your TrueNAS Scale credentials:TRUENAS_API_URL=http://your-truenas-ip/api/v2.0 TRUENAS_API_KEY=your-api-key-here- TRUENAS_API_URL: The URL to your TrueNAS API (e.g.,
http://192.168.1.100/api/v2.0). - TRUENAS_API_KEY: An API Key generated from the TrueNAS web interface (Settings -> API Keys).
- TRUENAS_API_URL: The URL to your TrueNAS API (e.g.,
Usage
Run the tool from the command line:
python3 src/tracker.py
Options
--format: Specify the output format (text,json,csv). Default istext.
Examples
Default Text Output:
python3 src/tracker.py
JSON Output:
python3 src/tracker.py --format json
CSV Output:
python3 src/tracker.py --format csv
Testing
Run the unit tests:
python3 -m unittest discover tests
Project Structure
src/tracker.py: Main application logic.tests/test_tracker.py: Unit tests..env.template: Template for environment variables.requirements.txt: Python dependencies.