Linux disk space information:-
create a shell file with the following script and run it in CRON job
______________________________________________________________________________
#!/bin/bash
df -h | grep -vE '^Filesystem|none|cdrom' | awk '{ print $5 " " $1 }' | while read output;
do
echo $output
usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 )
partition=$(echo $output | awk '{ print $2 }' )
if [ $usep -ge 85 ]; then
echo "Running out of space \"$partition ($usep%)\" on $(hostname) as on $(date)" |
mail -s "Alert: Almost out of disk space $usep%" <mail-id> (your mail id)
fi
done
_____________________________________________________________________________
it will send an alert to you mail if disk space reaches 85%.
if you want to set threshold value just place your value at 85.
create a shell file with the following script and run it in CRON job
______________________________________________________________________________
#!/bin/bash
df -h | grep -vE '^Filesystem|none|cdrom' | awk '{ print $5 " " $1 }' | while read output;
do
echo $output
usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 )
partition=$(echo $output | awk '{ print $2 }' )
if [ $usep -ge 85 ]; then
echo "Running out of space \"$partition ($usep%)\" on $(hostname) as on $(date)" |
mail -s "Alert: Almost out of disk space $usep%" <mail-id> (your mail id)
fi
done
_____________________________________________________________________________
it will send an alert to you mail if disk space reaches 85%.
if you want to set threshold value just place your value at 85.
No comments:
Post a Comment