Computing.Net > Forums > Solaris > script disk space

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

script disk space

Reply to Message Icon

Name: David
Date: June 2, 2003 at 03:40:12 Pacific
OS: Solaris
CPU/Ram: 1gig
Comment:

Does anyone have a script that will check disk space and if above say 95% will email me the relative disk information using cron?



Sponsored Link
Ads by Google

Response Number 1
Name: David Perry
Date: June 2, 2003 at 04:24:46 Pacific
Reply:

Flavor to suit.

#!/bin/ksh
rm /tmp/dfk.txt
echo "df -k output for `date` `uname -a`" > /tmp/dfk.txt
i=1
while [ $i -le `df -k | grep -v proc | grep -v Capacity | wc -l` ] ;do
if [ `df -k | grep -v proc | grep -v Capacity | head -n $i | tail -1 | awk '{print $5}' | sed -e 's/%//'` -gt 90 ] ; then
df -k | grep -v proc | grep -v Capacity | head -n $i | tail -1 >> /tmp/dfk.txt
fi
((i=i+1))
done
if [ `cat /tmp/dfk.txt | wc -l` -gt 1 ] ; then
cat /tmp/dfk.txt | mail user@host.com
fi


0

Response Number 2
Name: David Perry
Date: June 3, 2003 at 05:08:47 Pacific
Reply:

I like this one better.

#!/bin/ksh
cp /dev/null /tmp/df.out
case `uname -s` in
SunOS )
set -- `df -k | sed -e 's/%//g' | awk '/^\/dev/ { printf("%s %s\n", $5, $6) }'`
;;
HP-UX )
set -- `bdf | sed -e 's/%//g' | awk '/^\/dev/ { printf("%s %s\n", $5, $6) }'`
;;
esac

while [ $# -ge 2 ] ; do
CAPACITY=$1
FS=$2
shift 2

if [ $CAPACITY -gt 90 ] ; then
echo "$FS is at $CAPACITY %" >> /tmp/df.out
fi
done
if [ `wc -l /tmp/df.out | awk '{ print $1 }'` -ge 1 ] ; then
cat /tmp/df.out | mail user@host.com
fi


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


How cam all the users reb... system stuck after reboot



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Solaris Forum Home


Sponsored links

Ads by Google


Results for: script disk space

sed disk space (non) error www.computing.net/answers/solaris/sed-disk-space-non-error/5002.html

Available Disk Space on a Mount point www.computing.net/answers/solaris/available-disk-space-on-a-mount-point/695.html

Disk Space Allocation www.computing.net/answers/solaris/disk-space-allocation/236.html