Giter Site home page Giter Site logo

nicholasodonnell / smart-runner Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 105 KB

Pyton script for S.M.A.R.T cronjobs

License: GNU General Public License v3.0

Python 90.72% Shell 9.28%
bash monitoring-scripts python smartctl smartmontools hdd-health

smart-runner's Introduction

Publish

Description

S.M.A.R.T Runner is a Python script designed to automate the scheduling and execution of S.M.A.R.T (Self-Monitoring, Analysis, and Reporting Technology) tests on hard drives. It allows for regular short and long health checks on specified disks, helping in the early detection of potential disk failures.

Features

  • Automated Scheduling: Configure once and let the script handle regular short and long S.M.A.R.T tests.
  • Customizable Frequency: Define how often each type of test should be performed on each disk.
  • Parallel Testing: Specify how many disks to test simultaneously for both short and long tests.
  • Offset Timing: Configure waiting periods between tests to avoid overloading the system or testing too frequently.
  • Logging: Keep track of tests, results, and any errors in a specified log file.
  • Email Notifications: Receive email alerts for test failures.
  • Configurable SMTP: Set up custom SMTP server settings for sending out email notifications.
  • Easy Cron Integration: Run the script as a daily cron job for hands-off operation.
  • Intelligent Disk Detection: Automatically detect and handle disks based on mount points if specified.
  • Lock File: Prevent multiple instances of the script from running simultaneously.

Setup Requirements

Before using the S.M.A.R.T Runner, ensure the following requirements are met:

  • Python 3: The script is written for Python 3. Ensure it is installed and properly configured on your system.
  • smartmontools: This suite contains the smartctl utility, which is used to perform the S.M.A.R.T tests. It must be installed on your system.
    • Install it using your package manager, e.g., sudo apt-get install smartmontools on Debian/Ubuntu.
  • Root Access: The script requires root permissions to access disk hardware for S.M.A.R.T tests.
  • Cron Job: Schedule the script to run at least once per day using cron or another scheduler to automate the disk checks.

Configuration

The script is configured via a smart-runner.conf file. Here's an explanation of each configuration option:

Section Option Description
disks (list) List the devices or mounts to test. Devices are listed as /dev/sdX. If a mount is given the disk will automatically be resolved.
database file Path to the file where test dates are stored.
short enabled Set to true to enable short SMART tests.
frequency_days How often (in days) to run a short test on each disk.
disks_per_run Number of disks to test in parallel for short tests. Set to 0 for all.
offset_days Time to wait (in days) before running a short test on a different disk.
long enabled Set to true to enable long SMART tests.
frequency_days How often (in days) to run a long test on each disk.
disks_per_run Number of disks to test in parallel for long tests. Set to 0 for all.
offset_days Time to wait (in days) before running a long test on a different disk.
log file Path to the log file where execution details are recorded.
level Log level. Set to debug for more detailed logs.
email enabled Set to true to enable email notifications for test failures.
from_email Sender email address for notifications.
to_email Recipient email address for notifications.
smtp host SMTP server for sending email notifications.
port SMTP server port. Leave empty for default port.
ssl Set to true to enable SSL for the SMTP connection.
tls Set to true to enable TLS for the SMTP connection.
user SMTP server username for authentication.
password SMTP server password for authentication.

Usage

  1. Clone this repository:
    git clone https://github.com/nicholasodonnell/smart-runner.git
  2. Create a smart-runner.conf configuration file according to your needs using smart-runner.conf.example as a reference:
    cp smart-runner.conf.example smart-runner.conf
  3. Schedule the script to run via a cron job (edit using crontab -e):
    0 3 * * * /path/to/smart-runner.py --conf=/path/to/smart-runner.conf
  4. Monitor the specified log file or your email for notifications about disk health.

smart-runner's People

Contributors

nicholasodonnell avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.