MoSMART - S.M.A.R.T. Monitor
A Python-based tool for reading and interpreting S.M.A.R.T. (Self-Monitoring, Analysis and Reporting Technology) data from hard drives on Linux systems.
🚀 Quick Installation
sudo apt update
sudo apt install smartmontools python3-full pipx
pipx ensurepath
pipx install mosmart
sudo mosmart-web
Open http://localhost:5000 in your browser.
Distribution-specific guides
- Linux Mint: INSTALL_LINUX_MINT.md
- Debian: INSTALL_DEBIAN.md
- Ubuntu: INSTALL_UBUNTU.md
Which install method should I choose?
| Method | Best for | Pros | Notes |
|---|---|---|---|
pipx install mosmart |
Most users | Simple, isolated, PEP 668-safe | Recommended on Linux Mint/Debian/Ubuntu |
Source + venv |
Development and customization | Full control of source and dependencies | Run from repository with venv/bin/python3 |
install.sh |
System-wide service deployments | Integrates with systemd | Better for dedicated hosts/servers |
Features
- 📊 Scan and display all available storage devices
- 🔍 Read detailed S.M.A.R.T. attributes
- ⚠️ Detect potential health issues
- 🌡️ Monitor disk temperature
- 📈 Display critical parameters like reallocated sectors, power-on hours, and more
- 🧠 Health Score System - Intelligent scoring (0-100) based on critical parameters
- 🌐 Web Dashboard - Modern web interface for real-time monitoring
- ⚙️ Configurable auto-refresh and individual disk monitoring
- 🛡️ Emergency Unmount - Automatic removal of critically failing drives (optional)
- ⌛ Lifetime Remaining - SMART ID 202 support for SSD wear measurement
- 🔒 Thread-safe Scanning - Race condition protection with watchdog monitoring
- 💻 Linux support and ⚠️ Windows (via WSL2 - theoretical, not tested)
Testing and Validation
MoSMART has been validated through comprehensive testing with 24 different storage devices:
- Diverse disk types: SSDs, SATA HDDs and IDE (legacy) drives
- Real-world conditions: Drives have been used by different users with varying workloads
- Different wear levels: From nearly new drives to near end-of-life
- Real-world alignment: The test set reflects how drives are actually used in practice - not just lab tests
This testing ensures that the program works reliably on drives in all conditions and user scenarios.
Requirements
System Requirements
- Linux operating system
- Python 3.7 or newer
smartmontoolsinstalled on the system- Root/sudo access to read S.M.A.R.T. data
Installing System Dependencies
# Ubuntu/Debian
sudo apt update
sudo apt install smartmontools python3-pip python3-venv
# Fedora/RHEL
sudo dnf install smartmontools python3-pip
# Arch Linux
sudo pacman -S smartmontools python-pip
Installation
Install via PyPI (Recommended)
sudo apt update
sudo apt install smartmontools python3-full pipx
pipx ensurepath
pipx install mosmart
Run the web dashboard:
sudo mosmart-web
On Linux Mint, Ubuntu, and Debian,
pip installto system Python may fail withexternally-managed-environment(PEP 668). This is expected behavior. Usepipx install mosmart, or create and use a virtual environment.
Manual Installation (Development)
-
Install system dependencies
sudo apt update sudo apt install smartmontools python3-full python3-pip pipx
-
Virtual Environment Setup (Isolated and Clean)
A virtual environment can be created at $HOME/mosmart-venv (or any path you prefer). This keeps MoSMART isolated from system Python.
# Use a pre-configured virtual environment:
$HOME/mosmart-venv/bin/python3 web_monitor.py
# Or with sudo:
sudo $HOME/mosmart-venv/bin/python3 web_monitor.py
To create a fresh virtual environment:
cd /path/to/mosmart
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
When using virtual environment, activate it before use:
source venv/bin/activate
Usage
Important: If you're using a pre-configured venv:
$HOME/mosmart-venv/bin/python3(no activation needed)If using a manually created venv, activate it first:
source venv/bin/activate
Web Dashboard (Recommended!)
Start the web server (using pre-configured venv):
sudo $HOME/mosmart-venv/bin/python3 web_monitor.py
Check disk health (CLI, no WebUI needed):
sudo $HOME/mosmart-venv/bin/python3 web_monitor.py --check-health
With custom port:
sudo $HOME/mosmart-venv/bin/python3 web_monitor.py --port 8080
With custom refresh interval:
sudo ./venv/bin/python3 web_monitor.py --refresh 30
Then open your browser and go to: http://localhost:5000
systemd Service (Recommended for servers)
If you install via PyPI, use the console script in ExecStart so it works regardless of install path:
[Service]
Type=simple
User=root
ExecStart=/usr/bin/env mosmart-web
Restart=always
RestartSec=10
StandardOutput=append:/var/log/mosmart.log
StandardError=append:/var/log/mosmart.log
Web Dashboard features:
- 🎨 Modern, color-coded display of all disks
- 🔄 Auto-refresh (configurable, default 60 sec)
- ⏯️ Enable/disable monitoring per disk
- 📊 Real-time updates of health scores
- 🎯 Detailed view of all health components
- 📱 Responsive design for mobile and desktop
Command Line (CLI)
List all storage devices:
sudo ./venv/bin/python3 smart_monitor.py --list
Display information about a specific disk:
sudo ./venv/bin/python3 smart_monitor.py -d /dev/sda
Display detailed S.M.A.R.T. attributes:
sudo ./venv/bin/python3 smart_monitor.py -d /dev/sda --attributes
Health summary only:
sudo ./venv/bin/python3 smart_monitor.py -d /dev/sda --health
Scan all disks:
sudo ./venv/bin/python3 smart_monitor.py
Command Line Options (CLI)
smart_monitor.py:
-l, --list List all available storage devices
-d, --device PATH Specify which device to monitor (e.g. /dev/sda)
-a, --attributes Display detailed S.M.A.R.T. attributes
--health Display health summary only
web_monitor.py:
-p, --port PORT Port for webserver (default: 5000)
-r, --refresh SEC Auto-refresh interval in seconds (default: 60)
--host HOST Host to bind to (default: 127.0.0.1)
Health Score System
The program uses an advanced scoring system based on industry standards from Backblaze, Google and disk manufacturers:
Weighting:
- Reallocated sectors: 50% - Most critical parameter
- Pending sectors: 15% - Sectors waiting for reallocation
- Uncorrectable sectors: 10% - Permanently damaged sectors
- Command timeouts: 10% - Responsiveness issues
- Age: 10% - Expected lifespan (HDD: 3-5 years, SSD: 5-10 years)
- Temperature: 5% - Operating temperature (HDD: <35°C ideal, SSD: <40°C)
Score interpretation:
95-100: 🔵 EXCELLENT - Perfect condition80-94: 🟢 Good - Normal operation60-79: 🟡 Acceptable - Monitor regularly40-59: 🟠 Warning - Secure data with backup20-39: 🔴 Poor - High risk0-19: 🔴 CRITICAL - Replace ASAP<0: 💀 DEAD/ZOMBIE - Immediate replacement
Important S.M.A.R.T. Attributes
The program specifically monitors these critical attributes:
- ID 5: Reallocated Sectors Count - Number of defective sectors that have been moved
- ID 187: Reported Uncorrectable Errors - Errors that could not be corrected
- ID 196: Reallocation Event Count - Number of attempts to move sectors
- ID 197: Current Pending Sectors - Sectors waiting to be moved (CRITICAL)
- ID 198: Offline Uncorrectable - Sectors that cannot be read
- ID 199: UltraDMA CRC Errors - Communication errors
- ID 194: Temperature - Current disk temperature
- ID 9: Power On Hours - Total operating time
Ghost Drive Condition (GDC)
MoSMART includes special detection for "ghost drives" - drives that freeze or become unresponsive during SMART reads. This is especially common in certain Seagate models (ST2000DM001).
GDC Status Levels:
OK- Drive responds normallySUSPECT- Some timeout issues detectedCONFIRMED- Repeated failures, drive likely failingTERMINAL- Drive completely unresponsive
GDC drives are:
- Automatically excluded from normal scans (to prevent freezing)
- Only scanned during manual "Force Scan"
- Clearly marked with 👻 icon in the web interface
Alert System
MoSMART can send email alerts when disk problems are detected:
Alert Triggers:
- Health score drops below thresholds
- Pending sectors detected
- Temperature exceeds limits
- GDC status changes
Configuration:
Edit ~/.mosmart/settings.json:
{
"email": {
"enabled": true,
"smtp_server": "smtp.gmail.com",
"smtp_port": 587,
"sender_email": "your-email@gmail.com",
"sender_password": "your-app-password",
"recipient_email": "alert-recipient@example.com"
}
}
Emergency Unmount
When a disk reaches EMERGENCY status, MoSMART can automatically unmount it to prevent data corruption.
Two Modes:
- PASSIVE (Default): Logs decisions only, takes no action
- ACTIVE (Optional): Automatically unmounts on EMERGENCY
Safety Features:
- Five-layer validation before unmount
- Never unmounts critical paths (/, /boot, /home, /usr, /var)
- 30-minute cooldown between attempts
- Comprehensive logging
Enable ACTIVE mode:
{
"emergency_unmount": {
"mode": "ACTIVE",
"require_confirmation": true
}
}
See EMERGENCY_UNMOUNT_IMPLEMENTATION.md for details.
Multi-Language Support
MoSMART supports multiple languages:
- 🇬🇧 English
- 🇳🇴 Norwegian (Norsk)
Language files are located in languages/ directory. The web interface automatically uses the language from your browser settings, with fallback to English.
Example Output
============================================================
Device: /dev/sda
============================================================
Model: Samsung SSD 870 EVO 500GB
Serial: S5XXXXXXXX
Capacity: 500.107 GB
Interface: ATA
Assessment: PASS
Temperature: 35°C
Power On: 1234 hours
Health Summary:
Status: PASS
✓ No issues detected
Project Structure
smart_monitor.py- Main S.M.A.R.T. monitoring and health score calculationweb_monitor.py- Flask web application with dashboarddisk_logger.py- Smart logging with periodic and change-based triggersdecision_engine.py- Pure decision logic for disk health evaluationemergency_actions.py- Emergency unmount execution with safety checksgdc.py- GDCManager class for detecting failing drivesalert_engine.py&email_notifier.py- Alert system with email notificationsconfig_manager.py- Configuration managementdevice_lifecycle_logger.py- Track disk connection/disconnection eventsrequirements.txt- Python dependenciessetup.py- Package installation configuration
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Author
Magnus Modig
- Email: kontakt@modigs-datahjelp.no
- GitHub: @MsModig
Acknowledgments
- Based on the pySMART library
- Health score algorithms inspired by Backblaze Hard Drive Stats
- Special thanks to all beta testers who provided drives for testing
Support
⚠️ Important Disclaimer:
This tool is provided as-is for monitoring purposes. While it can help detect drive failures early, it is NOT a substitute for regular backups. Always maintain backups of important data, regardless of drive health status.
Metadata
Release files for mosmart 0.9.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mosmart-0.9.5.tar.gz | 15.1 MB | Without provenance | Details for mosmart-0.9.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mosmart-0.9.5-py3-none-any.whl | Python 3 | none | any | Details for mosmart-0.9.5-py3-none-any.whl |
Total release size: 15.2 MB
Release files / mosmart-0.9.5.tar.gz
| Download URL | mosmart-0.9.5.tar.gz |
|---|---|
| Size | 15.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c101ff6a7ac2a8f7ee55f382b908ce16f702445c5fde8d77022dadb4c764be88
|
|
BLAKE2b-256 checksum How to use checksums |
82facec67afe551092d27f08c411ce936f4436745711dddeff43881f5d1097b1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / mosmart-0.9.5-py3-none-any.whl
| Download URL | mosmart-0.9.5-py3-none-any.whl |
|---|---|
| Size | 132.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a1ea1ee6aca0d4ed0c517bc9d48e3b16fc091706bcf39eead020011cdd362f85
|
|
BLAKE2b-256 checksum How to use checksums |
03f4ff024fd0484dfc3edda116e78fe982af1de4b98441a5c0c6018aeaef9336
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Security for mosmart 0.9.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.