Skip to content

Athoillah21/Healthcheck_PostgreSQL_to_Email

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Healthcheck PostgreSQL to Email

A shell-based utility to monitor PostgreSQL database health, generate an HTML report, and send it via email.

Features

  • Collects PostgreSQL health metrics.
  • Generates an HTML report.
  • Sends the report via email.

Prerequisites

  • Unix-like OS (Linux/macOS)
  • Bash shell
  • PostgreSQL client utilities (psql)
  • sendmail or equivalent mail transfer agent

Setup

  1. Clone the Repository

    git clone https://github.com/Athoillah21/Healthcheck_PostgreSQL_to_Email.git
    cd Healthcheck_PostgreSQL_to_Email
  2. Set Email Parameters

    Edit hc_mail.sh to specify:

    • EMAIL_TO: Recipient email address
    • EMAIL_SUBJECT: Email subject
    • EMAIL_BODY: Email body content

Usage

  1. Generate HTML Report

    ./generate_html.sh -h ${server_host} -p ${db_port} -d ${db_name} -U ${db_user}

    This script connects to the PostgreSQL database, retrieves health metrics, and generates an HTML report saved in the report/ directory.

  2. Generate HTML Report then Send via Email

    ./hc_mail.sh -h ${server_host} -p ${db_port} -d ${db_name} -U ${db_user}

    This script connects to the PostgreSQL database, retrieves health metrics, and generates an HTML report saved in the report/ directory. Then this script sends the generated HTML report to the specified email address.

Automation

To automate the health check and email dispatch, add the following to your crontab:

0 8 * * * /path/to/Healthcheck_PostgreSQL_to_Email/generate_html.sh && /path/to/Healthcheck_PostgreSQL_to_Email/hc_mail.sh

This example runs the scripts daily at 8 AM.

License

This project is licensed under the MIT License.

Author

Created by Athoillah21.

About

Healthcheck script for postgresql database, resulting in html then send to email

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published