A shell-based utility to monitor PostgreSQL database health, generate an HTML report, and send it via email.
- Collects PostgreSQL health metrics.
- Generates an HTML report.
- Sends the report via email.
- Unix-like OS (Linux/macOS)
- Bash shell
- PostgreSQL client utilities (
psql
) sendmail
or equivalent mail transfer agent
-
Clone the Repository
git clone https://github.com/Athoillah21/Healthcheck_PostgreSQL_to_Email.git cd Healthcheck_PostgreSQL_to_Email
-
Set Email Parameters
Edit
hc_mail.sh
to specify:EMAIL_TO
: Recipient email addressEMAIL_SUBJECT
: Email subjectEMAIL_BODY
: Email body content
-
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. -
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.
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.
This project is licensed under the MIT License.
Created by Athoillah21.