I wrote this script for logging emails if disk-space is more than 90. Please help me get the output in separate lines. Here is my code:
#!/bin/bash
errortext=""
EMAILS="[email protected]"
for line in `df | awk '{print$6, $5, $4, $1} ' `
do
# get the percent and chop off the %
percent=`echo "$line" | awk -F - '{print$5}' | cut -d % -f 1`
partition=`echo "$line" | awk -F - '{print$1}' | cut -d % -f 1`
# Let's set the limit to 90% when alert should be sent
limit=90
if [[ $percent -ge $limit ]]; then
errortext="$errortext $line"
fi
done
# send an email
if [ -n "$errortext" ]; then
echo "$errortext" | mail -s "NOTIFICATION: Some partitions on almost
full" $EMAILS
fi