mirror of
https://github.com/guezoloic/serverconfig.git
synced 2026-01-25 12:34:24 +00:00
add notification and update aws-backup (the changes will come soon)
This commit is contained in:
19
notification/disk-monitor.sh
Normal file
19
notification/disk-monitor.sh
Normal file
@@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
source /etc/serverconfig/.env
|
||||
|
||||
disk_usage() {
|
||||
df -h / | grep / | awk -v max="$1" '{
|
||||
usage = $5;
|
||||
gsub("%", "", usage);
|
||||
if (usage > max) {
|
||||
printf "<b>🚨 WARNING:</b>\nDisk usage is at %d%%. which exceed the treshold of %d%%.\n\n", usage, max;
|
||||
}
|
||||
printf "<b>💾 Disk Usage Information:</b>\nTotal Size: %s, Used: %s, Available: %s\n\n", $2, $3, $4;
|
||||
}'
|
||||
}
|
||||
|
||||
curl -X POST "https://api.telegram.org/bot$TOKEN/sendMessage" \
|
||||
-d "chat_id=$CHAT_ID" \
|
||||
-d "text=$(disk_usage 80)" \
|
||||
-d "parse_mode=HTML"
|
||||
Reference in New Issue
Block a user