Skip to content

Instantly share code, notes, and snippets.

@nikeshashar
Created September 1, 2022 20:32
Show Gist options
  • Save nikeshashar/ddab2d693aa09755658bc264f1e12d7c to your computer and use it in GitHub Desktop.
Save nikeshashar/ddab2d693aa09755658bc264f1e12d7c to your computer and use it in GitHub Desktop.
#!/bin/zsh
# Disk percentage usage to alert on, 90 is 90% used
targetFreeSpace=90
diskPercentageUsed=$( /bin/df -H | /usr/bin/awk '/\/dev\/disk1s1/ {print $5}' | /usr/bin/tr -d '%')
echo "Disk percent used: $diskPercentageUsed"
if [ "$diskPercentageUsed" -gt "$targetFreeSpace" ]; then
exit 1
else
exit 0
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment