Skip to content

A lightweight command-line tool built in pure Python to display system information — CPU, RAM, disk, network, and uptime — with text and JSON output modes.

Notifications You must be signed in to change notification settings

mircothibes/sysinfo-cli

Repository files navigation

🖥️ sysinfo-cli CI

Python Docker Lint Format Tests Pulls Image Size Version

View on Docker Hub

A simple command-line tool written in pure Python that displays system information such as CPU, RAM, disk, network, and uptime.
It supports both standard text and JSON output.


🚀 Quick Start (Local)

# Clone this repository
git clone https://github.com/mircothibes/sysinfo-cli.git
cd sysinfo-cli

# Create and activate the virtual environment
python -m venv .venv && source .venv/bin/activate

# Install dependencies (development tools included)
pip install -e ".[dev]"

# Run the CLI
python -m sysinfo.cli
python -m sysinfo.cli --json

Example output:

CPU: cores=16 load={'1m': 0.18, '5m': 0.11, '15m': 0.03}
RAM: used=640000kB/8036544kB (7.9%)
DISK: used=3458965504/1081101176832 (0.32%)
NET: total_rx=290 total_tx=42
UPTIME: 21000s

🐳 Docker

You can run the same CLI in a lightweight Docker container.

# Build the image
docker build -t mvtk/sysinfo-cli:0.1.0 .

# Run it (JSON output)
docker run --rm mvtk/sysinfo-cli:0.1.0 --json

# Or plain text output
docker run --rm mvtk/sysinfo-cli:0.1.0

Example JSON output:

{
  "cpu": {"cores": 16, "loadavg": {"1m": 0.18, "5m": 0.11, "15m": 0.03}},
  "ram": {"total_kb": 8036544, "available_kb": 7397756, "used_kb": 638788, "percent": 7.95},
  "disk": {"path": "/", "total_bytes": 1081101176832, "used_bytes": 3458957312, "free_bytes": 1022649864192, "percent": 0.32},
  "net": {"total": {"rx_bytes": 290, "tx_bytes": 42}},
  "uptime": {"seconds": 20201}
}

🧰 Development

I use Neovim as my main development environment with:

  • lazy.nvim
  • mason.nvim
  • nvim-lspconfig -> (Pyright)
  • conform.nvim -> for formatting

Useful Commands:

ruff check .
black .
pytest -q

🧪 Tests

Run all tests using pytest:

pytest -q

📦 Project Structure

sysinfo-cli/
├── .github/                  # GitHub Actions workflows (CI/CD)
│   └── workflows/
│       └── ci.yml
├── src/                      # Application source code
│   └── sysinfo/
│       ├── __init__.py
│       └── cli.py
├── tests/                    # Unit tests (pytest)
│   └── test_cli.py
├── .dockerignore             # Files excluded from Docker build
├── .gitignore                # Git ignored files
├── .pre-commit-config.yaml   # Pre-commit hooks (Ruff, Black, Pytest)
├── Dockerfile                # Docker image definition
├── Makefile                  # Build, test, and lint automation
├── pyproject.toml            # Build system & dependencies
├── pytest.ini                # Pytest configuration
├── README.md                 # Project documentation
└── .venv/                    # Local virtual environment (ignored in Git)

⚙️ Command Reference

Command Description
python -m sysinfo.cli Run the CLI and show system info
python -m sysinfo.cli --json Output data in JSON format
python -m sysinfo.cli --help Show help message
python -m sysinfo.cli --version Display CLI version

🧰 Docker Commands

Command Description
docker run --rm mircothibes/sysinfo-cli Run CLI inside Docker (text)
docker run --rm mircothibes/sysinfo-cli --json Run CLI inside Docker (JSON)

🧱 Makefile Commands (for local development)

Command Description
make lint Run Ruff linter
make format Run Black formatter
make test Run Pytest test suite
make build Build Docker image locally
make run Run the CLI locally via Python

🧾 License

This project is released under the MIT License.


👨‍💻 Author

Marcos Vinicius Thibes Kemer


About

A lightweight command-line tool built in pure Python to display system information — CPU, RAM, disk, network, and uptime — with text and JSON output modes.

Resources

Stars

Watchers

Forks

Packages

No packages published