Skip to content
Snippets Groups Projects

Added diskwatch script.

Merged Filip Strömbäck requested to merge devel into production
3 files
+ 87
0
Compare changes
  • Side-by-side
  • Inline
Files
3
+ 37
0
 
#!/bin/bash
 
 
WARNINGS=$(df -l --output=source,fstype,pcent,target | tail --lines=+2 | while read source fstype usage mountpoint
 
do
 
# Only filesystems that originate from some kind of device
 
if [[ "$source" != /* ]]
 
then
 
continue
 
fi
 
 
# Remove trailing percentage sign.
 
usage=${usage%%%}
 
 
# Warn if usage is above 90%
 
if [[ ${usage} -gt 89 ]]
 
then
 
echo "${source} (mounted on ${mountpoint}) is ${usage}% full"
 
fi
 
done)
 
 
if [[ "$WARNINGS" != "" ]]
 
then
 
echo "WARNINGS"
 
 
(
 
echo -n "From: noreply@"
 
cat /etc/hostname
 
for r in $WARNING_RECIPIENTS
 
do
 
echo "To: ${r}"
 
done
 
echo "Subject: Disk usage warning"
 
echo
 
echo "The following disks are almost full:"
 
echo "$WARNINGS"
 
) | sendmail -t
 
fi
Loading