This repository contains scripts for monitoring various aspects of Linux servers and sending notifications to ntfy. Each script can be easily customized according to specific needs, such as setting ntfy URLs and adjusting thresholds for triggering notifications.
-
Certificates
LECheck.sh
: Script for monitoring the expiration of Let's Encrypt certificates. It will notify you when the certificate is nearing its expiration date.
-
Memory
ram.sh
: Script for monitoring RAM usage. It sends a notification if memory usage exceeds the set threshold.
-
Disk
disk.sh
: Script for monitoring disk usage. It alerts you when disk usage surpasses the defined threshold.
-
CPU
cpu.sh
: Script for monitoring CPU usage. It sends a notification if CPU usage exceeds the set threshold.
-
Applications
app.sh
: Script for monitoring the running status of specific applications. It notifies you if a specified application stops or is not running.
Before using these scripts, a few adjustments are needed:
-
Setting the ntfy URL
In each script, you need to set the URL for sending notifications to ntfy. This URL is set at the end of the CURL command in each script.
curl -d "Notification message" https://ntfy.sh/your_topic
-
Adjusting threshold values
In some scripts, it is possible (and recommended) to adjust the threshold values that trigger notifications. These values are set using variables, for example:
RAM_THRESHOLD=80 # Percentage of RAM usage DISK_THRESHOLD=90 # Percentage of disk usage CPU_THRESHOLD=75 # Percentage of CPU usage CERT_EXPIRY_DAYS=30 # Number of days until certificate expiry
-
Making scripts executable
Ensure the scripts have executable permissions:
chmod +x LECheck.sh chmod +x ram.sh chmod +x disk.sh chmod +x cpu.sh chmod +x app.sh
-
Running the scripts
The scripts can be run manually or set up as cron jobs for automatic monitoring at regular intervals.
./LECheck.sh ./ram.sh ./disk.sh ./cpu.sh ./app.sh
-
Setting up cron jobs
To automate the execution, you can add the scripts to the crontab:
crontab -e
And add the following lines as needed:
# Check certificate expiration every day at 2:00 AM 0 2 * * * /path/to/LECheck.sh # Check RAM usage every hour 0 * * * * /path/to/ram.sh # Check disk usage every hour 0 * * * * /path/to/disk.sh # Check CPU usage every 15 minutes */15 * * * * /path/to/cpu.sh # Check application running status every 5 minutes */5 * * * * /path/to/app.sh
If you have any ideas for improvements or have found a bug, feel free to contribute via pull requests or by opening an issue in this repository.