# send an alert by mail if partition usage exceeds 95%



## ccc (Apr 21, 2014)

Hi

I need a bash script to send an alert by mail if partition usage exceeds 95%.


----------



## Dies_Irae (Apr 21, 2014)

This should work:

```
#!/bin/sh

# Partition mount point - parameter checks left as an exercise for the reader :-)
MPOINT=$1

# Partition usage
FULL=`df ${MPOINT} | egrep -o '[0-9]+%' | tr -d '%'`

if [ "$FULL" -gt 95 ]; then
	echo "$MPOINT usage exceeds 95%" | mail -s "$MPOINT usage report" admin@my.server
fi
```

Usage:
`the_above_script.sh /my/partiton/mount/point`


----------



## kpa (Apr 21, 2014)

Make the script a periodic(8) script and run it daily, the periodic(8) system will send mail with the output of the script to root automatically.


----------

