check-storage-space.sh 758 B

123456789101112131415
  1. #!/bin/bash
  2. #Check the disk usage of the root partition to ensure it is not too full.
  3. disk_usage=$(df -h / | tail -n1 | tr -s ' ' | cut -d ' ' -f 5 | cut -d '%' -f 1)
  4. email="openrsc.emailer@gmail.com";
  5. discordwebhook=$(cat .discordstaffmonitorwebhook); #We are in Deployment_Scripts, not the root core directory, so we can't specify Deployment_Scripts.
  6. # Check if the disk usage is over 90%
  7. if [ "$disk_usage" -ge 90 ]; then
  8. # Send an email using the mail command
  9. warning="Warning: The root partition on OpenRSC $(hostname) is ${disk_usage}% full.";
  10. mail -s "OpenRSC $(hostname) root partition usage warning" $email <<< "$warning";
  11. curl -H "Content-Type: application/json" \
  12. -X POST \
  13. -d "{\"content\": \"$warning\"}" $discordwebhook
  14. fi