Solaris / OpenSolarisThis forum is for the discussion of Solaris, OpenSolaris, OpenIndiana, and illumos.
General Sun, SunOS and Sparc related questions also go here. Any Solaris fork or distribution is welcome.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I want to enable monitoring on space size, if it exceeds certain limit then it should send alert mail. Please help me with this. Environment is Solaris. I found one code from the forum but that is throwing error (test.sh: syntax error at line 9: `percentuse=$' unexpected) to me
Code:
#!/bin/bash
(
unset FILLING
while read outstring;
do
percentuse=$(echo $outstring | awk '{ print $1}' | cut -d'%' -f1 )
partition=$(echo $outstring | awk '{ print $2 }' )
mountedon=$(echo $outstring | awk '{ print $3 }' )
if [[ $percentuse -ge 90 ]]; then
FILLING=1
echo "Filesystem near fill-up : $mountedon"
fi
done < <(df -Ph | awk '{ print $5 " " $1 " " $6 }')
if [ -z "$FILLING" ]; then
echo "All filesystem are in safe condition"
fi
) | mail -s "Daily disk space report" me@gmail.com
Last edited by ankitpandey; 04-21-2012 at 02:41 AM.
I seem to remember a thread a while back asking something similar and pulled this from it:
Code:
for i in `df -h | grep -v capaci | awk '{print $5}' | cut -d% -f1` ; do if [ $i -lt 90 ]; then echo "good" ; else echo "we have a problem on `df -h | grep $i `" ; fi ; done
sample output:
Code:
good
good
good
good
good
good
good
good
good
good
good
we have a problem on /dev/dsk/c0t0d0s6 9.8G 8.8G 994M 91% /var
good
good
good
good
I seem to remember a thread a while back asking something similar and pulled this from it:
Code:
for i in `df -h | grep -v capaci | awk '{print $5}' | cut -d% -f1` ; do if [ $i -lt 90 ]; then echo "good" ; else echo "we have a problem on `df -h | grep $i `" ; fi ; done
this oneliner is a nightmare, an example how one should not do it..
try this, it is almost the same (just won't print "good", and "we have a problem on")
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.