Menu-Driven Health Check for System Monitoring

Menu-Driven Health Check for System Monitoring

·

2 min read

In this post, I’m going to walk you through a Python-based system health check script that can monitor key system metrics such as disk usage, running services, memory usage, and CPU usage.

Additionally, the script automates the process of sending system health reports via email.

Let's dive into the details.

Prerequisites

Before you can get started, make sure you have the following:

  • Python 3.x

  • Git

  • SMTP Configuration: You'll need to configure your email server in a .env file to send reports.

Steps to Set Up

  1. Clone the repository:

    Start by cloning the repository where the script is hosted:

     git clone https://github.com/khan-atiq/system-health-checker.git
    
  2. Install the dependencies:

    Navigate into the project directory and install the required Python dependencies:

     pip install -r requirements.txt
    
  3. Set up the .env file:

    Configure your SMTP server details in the .env file, which will be used for sending emails. Here’s an example setup:

     SMTP_SERVER=smtp.yourserver.com
     SMTP_PORT=465
     SENDER_EMAIL=your-email@example.com
     PASSWORD=your-email-password
     RECEIVER_EMAIL=receiver-email@example.com
    
  4. Run the system health check script:

    Now that everything is set up, execute the script to start monitoring your system:

     python sys_healthCheck.py
    

Running the Script

Once the script is running, it will present you with a menu of options to choose from:

  1. Check Disk Usage

  2. Monitor Running Services

  3. Assess Memory Usage

  4. Evaluate CPU Usage

  5. Send a Comprehensive Report via Email (every 4 hours)

You can select the option by entering the corresponding number to perform a health check.

Additionally, the script will automatically send a detailed report via email every 4 hours.

Thanks!!!!