SD Card Exporter Documentation
This exporter monitors the health and performance of an SD card using B&R X20 Edge tools and exposes the data in Prometheus-compatible format.
It builds upon the B&R use case documented at:
SD Card Health
📝 Overview
The sdcard-exporter is a containerized Python application that uses:
mmcutility (from B&R) to retrieve SMART data from/dev/mmcblk1iostatto gather disk usage statisticsprometheus_clientPython module to expose metrics on port8000
These metrics are scraped by Prometheus and visualized in Grafana.
🐳 Container Structure
Folder structure:
Monitoring/
├── docker-compose.yml
├── prometheus/
│ ├── prometheus.yml
│ └── _data/ # Prometheus data volume
└── SdcardHealth/
├── Dockerfile
├── sdcard-exporter.json # Grafana dashboard export
└── app/
├── exporter.py # Python exporter script
└── mmc # MMC binary from B&R
📊 Exported Metrics
From mmc smart /dev/mmcblk1
sd_card_health_percentsd_card_bad_blockssd_card_spare_blockssd_card_min_erase_countsd_card_max_erase_countsd_card_total_erase_countsd_card_avg_erase_countsd_card_pe_cyclessd_card_power_cyclessd_card_write_crc_errors
From iostat -d -o JSON
iostat_util_percentiostat_tpsiostat_kb_read_siostat_kb_wrtn_siostat_kb_readiostat_kb_wrtn
🚀 Running the Exporter
The container is built and managed via Docker Compose. Here's a snippet from docker-compose.yml:
sdcard-exporter:
build: ./SdcardHealth
container_name: sdcard-exporter
restart: unless-stopped
privileged: true
cap_add:
- SYS_RAWIO
- SYS_ADMIN
devices:
- "/dev/mmcblk1:/dev/mmcblk1"
volumes:
- "/dev:/dev"
expose:
- "8000"
user: "0:0"
tty: true
stdin_open: true
networks:
- monitoring
📡 Prometheus Integration
Add this job to prometheus/prometheus.yml:
- job_name: 'sdcard-exporter'
static_configs:
- targets: ['sdcard-exporter:8000']
📊 Grafana Dashboard
Import the dashboard:
Go to Grafana → Dashboards → Import
Upload sdcard-exporter.json from the SDcardHealth folder
Set Prometheus as the data source
Alternatively, you can customize this dashboard using B&R’s original templates or your own metrics.
⚙️ Notes
The exporter must run with root privileges (user: "0:0", privileged: true) to access SD card diagnostics.
Make sure /dev/mmcblk1 matches your system's SD card device.
The Python script sleeps 15 seconds between metric reads. Adjust this if needed.
For visual examples and step-by-step dashboard import, refer to the main documentation file: monitoring-stack.md.