S.M.A.R.T Monitor Tool for Linux - Real-time disk health monitoring with web dashboard
Project description
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
pip install mosmart
sudo mosmart
Open http://localhost:5000 in your browser.
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)
pip install mosmart
Run the web dashboard:
sudo mosmart
Manual Installation (Development)
-
Install system dependencies
sudo apt update sudo apt install smartmontools python3-full python3-pip pipx
-
Install with pipx (recommended for standalone tools)
pipx install pySMART
OR create a 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 virtual environment, activate it first:
source venv/bin/activate
Web Dashboard (Recommended!)
Start the web server:
sudo ./venv/bin/python3 web_monitor.py
With custom port:
sudo ./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
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: magnus@modig.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.
Project details
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 mosmart-0.9.3.tar.gz.
File metadata
- Download URL: mosmart-0.9.3.tar.gz
- Upload date:
- Size: 18.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b3699cee9006c57eee426058364da7621a978ff3d3f445b7aeb47f76418bb0b
|
|
| MD5 |
03c1d64678a925c9e40e130a7bf5fc98
|
|
| BLAKE2b-256 |
9e2421a71d597683570171da881058c269850af0e61f20ebd20ce73c925d8c17
|
File details
Details for the file mosmart-0.9.3-py3-none-any.whl.
File metadata
- Download URL: mosmart-0.9.3-py3-none-any.whl
- Upload date:
- Size: 18.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ff59e577bcdb21c9491cd540d6dc66fecf26aa03470c396e367077e8bc715e5a
|
|
| MD5 |
91b03f71bd897dc8d32f5a087b926f60
|
|
| BLAKE2b-256 |
ae3bd769cbc97bbde928a50a28a22511b58b841428fd6820f149ec862db27968
|