Send an alert email if FS is 75% used in bash

Anju
Aug 17, 2021

--

df -h |sed s/%//g | awk '{if($5 > 75) print $6,$5}' | column -t | mail -s "df status alert" -r user@example.com  sender@example.com

Another method:

df -h |sed s/%//g | awk '{print $6,$5}'|while read fs usage; do if [[ $usage -ge 75 ]]; then echo "Usage is high of $fs to $usage"; fi; done > tmp_filecat tmp_file | mail -s "df status alert" -r user@example.com  sender@example.com && rm -rf tmp_file

--

--

Anju
Anju

Written by Anju

A DevOps engineer who loves automating everything (almost), exploring new places, and finding peace in nature. Always looking for the next adventure!

No responses yet