Collect and expose lightweight system snapshots (CLI).
Project description
30secs
30secs is an ultra-lightweight system monitoring tool that takes system snapshots every 30 seconds (default), or returns snapshots on-demand via CLI.
Features
- Real-time monitoring: CPU, memory, disk, network, and process metrics
- Multiple output formats: JSON, human-readable table, Prometheus metrics
- Alert system: Configurable threshold-based alerts
- Graceful shutdown: Handles SIGINT/SIGTERM signals
- Production-ready: Structured logging, error handling, modular architecture
⚠️ Python module names cannot start with a number, so while the project is named
30secs, the import package isthirtysecs.
Installation
Binary (No Python Required) - Recommended for K8s Nodes
Download the pre-built binary for your platform:
# Linux AMD64 (most K8s nodes)
curl -L https://github.com/<your-repo>/30secs/releases/latest/download/30secs-linux-amd64 -o 30secs
# Linux ARM64 (Graviton, etc.)
curl -L https://github.com/<your-repo>/30secs/releases/latest/download/30secs-linux-arm64 -o 30secs
# macOS Apple Silicon
curl -L https://github.com/<your-repo>/30secs/releases/latest/download/30secs-darwin-arm64 -o 30secs
# macOS Intel
curl -L https://github.com/<your-repo>/30secs/releases/latest/download/30secs-darwin-amd64 -o 30secs
# Make executable and run
chmod +x 30secs
./30secs watch -f table --alerts
One-liner for K8s Node Debugging
curl -sL https://github.com/<your-repo>/30secs/releases/latest/download/30secs-linux-amd64 -o /tmp/30secs \
&& chmod +x /tmp/30secs \
&& /tmp/30secs watch -f table --alerts -i 10
pip (PyPI) - Recommended for environments without GitHub access
# Install from PyPI (Python 3.12+ required)
pip install 30secs
# Or use pipx for isolated install
pipx install 30secs
# Or use uv
uv tool install 30secs
# Then run
30secs watch -f table --alerts -i 10
One-liner for K8s Node (pip)
pip install 30secs && 30secs watch -f table --alerts -i 10
From Source (uv)
Install uv (official docs)
curl -LsSf https://astral.sh/uv/install.sh | sh
Install/sync dependencies
uv sync
Usage
Single snapshot (JSON output)
uv run 30secs snapshot
Human-readable table output
uv run 30secs snapshot --format table
Prometheus metrics format
uv run 30secs snapshot --format prometheus
Continuous monitoring (every 30 seconds)
uv run 30secs watch
Custom interval (every 10 seconds)
uv run 30secs watch --interval 10
Watch with table format (auto-refresh)
uv run 30secs watch --format table --interval 5
Quick snapshot (without processes - faster)
uv run 30secs quick
Enable alerts
uv run 30secs watch --alerts
Save output to file
uv run 30secs watch --output metrics.jsonl
Limit number of snapshots
uv run 30secs watch --count 10 --interval 5
Exclude specific metrics
uv run 30secs snapshot --no-processes --no-network
Memory leak report for a process (table)
uv run 30secs leak <PID> --interval 2 --count 30
Memory leak report as JSON
uv run 30secs leak <PID> --format json --interval 1 --count 60
Output Formats
JSON (default)
Complete system metrics in JSON format, suitable for log aggregation and processing.
Table
Human-readable format with emojis and organized sections:
- System info (hostname, OS, uptime)
- CPU (usage, cores, load average)
- Memory (used/total, available, swap)
- Disk (partitions, usage)
- Network (sent/received, connections)
- Processes (top by CPU/memory)
Prometheus
Metrics in Prometheus exposition format, ready for scraping.
Alerts
Built-in alert thresholds:
- CPU: > 90%
- Memory: > 90%, > 95% (critical)
- Swap: > 80%
When alerts are enabled (--alerts), the tool will:
- Log warnings when thresholds are exceeded
- Exit with code 1 if any alert is triggered (for
snapshotcommand)
Development
Run tests
uv run pytest
Linting & Formatting
uv run ruff check .
uv run ruff format .
Type checking
uv run mypy src
Project Structure
src/thirtysecs/
├── __init__.py # Package init
├── __main__.py # Entry point
├── cli.py # CLI interface
├── config.py # Configuration
├── core.py # Core snapshot logic
├── alerts.py # Alert system
├── errors.py # Error definitions
├── logging.py # Structured logging
├── collectors/ # Metric collectors
│ ├── base.py # Base collector interface
│ ├── cpu.py # CPU metrics
│ ├── memory.py # Memory metrics
│ ├── disk.py # Disk metrics
│ ├── network.py # Network metrics
│ ├── process.py # Process metrics
│ └── system.py # System info
└── formatters/ # Output formatters
├── base.py # Base formatter interface
├── json_fmt.py # JSON output
├── table.py # Table output
└── prometheus.py # Prometheus metrics
Environment Variables
| Variable | Default | Description |
|---|---|---|
SERVICE_NAME |
30secs |
Service name for health checks |
DEFAULT_INTERVAL_SECONDS |
30 |
Default watch interval |
INCLUDE_HOSTNAME |
1 |
Include hostname in output |
LOG_LEVEL |
INFO |
Logging level |
ALERT_CPU_THRESHOLD |
90.0 |
CPU usage alert threshold (%) |
ALERT_MEMORY_THRESHOLD |
90.0 |
Memory usage alert threshold (%) |
ALERT_MEMORY_CRITICAL_THRESHOLD |
95.0 |
Critical memory alert threshold (%) |
ALERT_SWAP_THRESHOLD |
80.0 |
Swap usage alert threshold (%) |
MEMORY_LEAK_WINDOW_SIZE |
10 |
Number of samples for leak detection |
MEMORY_LEAK_GROWTH_THRESHOLD |
5.0 |
Memory growth % to trigger leak alert |
Memory Leak Detection
30secs includes automatic memory leak detection when using --alerts:
# Monitor with leak detection (default: 10 samples, 5% growth threshold)
30secs watch -f table --alerts -i 10
# Custom thresholds via environment variables
MEMORY_LEAK_WINDOW_SIZE=20 MEMORY_LEAK_GROWTH_THRESHOLD=3.0 30secs watch --alerts -i 5
The detector tracks memory usage over a sliding window and alerts when:
- Memory growth exceeds the threshold (default: 5%)
- At least 60% of samples show an increasing trend
uv Cheat Sheet
| Command | Description |
|---|---|
uv add <pkg> |
Add a dependency |
uv add --group dev <pkg> |
Add a dev dependency |
uv lock |
Lock dependencies |
uv sync |
Sync dependencies |
uv run --frozen ... |
Run with locked dependencies |
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file 30secs-0.2.7.tar.gz.
File metadata
- Download URL: 30secs-0.2.7.tar.gz
- Upload date:
- Size: 20.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e9d66b194f85abedc0388c48ee20c916ec77185d67407ceaf3e7c6d116e784c4
|
|
| MD5 |
8c61e30547bd0aaff729ed81811880e0
|
|
| BLAKE2b-256 |
41617115e58e08d675fdccaa1d774ed795564cdfe24bcc1082dc11a5a595bf44
|
Provenance
The following attestation bundles were made for 30secs-0.2.7.tar.gz:
Publisher:
publish-pypi.yml on jundorok/30secs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
30secs-0.2.7.tar.gz -
Subject digest:
e9d66b194f85abedc0388c48ee20c916ec77185d67407ceaf3e7c6d116e784c4 - Sigstore transparency entry: 953431467
- Sigstore integration time:
-
Permalink:
jundorok/30secs@be94e58760aa6dfbe702ae5440c71097a9cc1486 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/jundorok
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@be94e58760aa6dfbe702ae5440c71097a9cc1486 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file 30secs-0.2.7-py3-none-any.whl.
File metadata
- Download URL: 30secs-0.2.7-py3-none-any.whl
- Upload date:
- Size: 29.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
56b1646e007f11340a69766622974469603822e9ebc2ec0dc8f545c64bb67254
|
|
| MD5 |
c8ddf28146c02ea2c193becbff6146e3
|
|
| BLAKE2b-256 |
5ef6899d897358cb07722553254f63b51b36e5c29bc25b86453843901b2c7ca9
|
Provenance
The following attestation bundles were made for 30secs-0.2.7-py3-none-any.whl:
Publisher:
publish-pypi.yml on jundorok/30secs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
30secs-0.2.7-py3-none-any.whl -
Subject digest:
56b1646e007f11340a69766622974469603822e9ebc2ec0dc8f545c64bb67254 - Sigstore transparency entry: 953431470
- Sigstore integration time:
-
Permalink:
jundorok/30secs@be94e58760aa6dfbe702ae5440c71097a9cc1486 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/jundorok
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@be94e58760aa6dfbe702ae5440c71097a9cc1486 -
Trigger Event:
workflow_dispatch
-
Statement type: