df -k


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting df -k
# 1  
Old 03-11-2005
df -k

df -k /netprov
Filesystem kbytes used avail capacity Mounted on
/dev/vx/dsk/appdg/vol01
60817408 43310395 16447098 73% /netprov

I want to cut and compare the capacity field with >85% , if it is >85% then i need to get an e-mail. I tried using cut but it didn't work properly. Any Help

Gundu
# 2  
Old 03-11-2005
This should get you close:

Code:
if [ `df -k /netprov | tail -1 | awk '{print $5'} | tr -d '%'` -gt 85 ]
then
    mail code goes here...
fi

thomas
# 3  
Old 03-11-2005
New question. IN the mail code i need to attach the df command output with the subject. I tried

Mail -s "subject" xxx@xxx.com < 'df -k /netprov'

gives output of df -k to the screen, but no e-mail. I checked with 70%, I know it is at 73%.
----------------------------------------
if [ `df -k /netprov | tail -1 | awk '{print $5'} | tr -d '%'` -gt 85 ]
then
mail code goes here...
fi
---------------------------------------
# 4  
Old 03-11-2005
There are other ways to do it but, at a minimum, you can simply use a temporary file.
Code:
if [ `df -k /netprov | tail -1 | awk '{print $5'} | tr -d '%'` -gt 85 ]
then
    df -k /netprov > /tmp/df_output.txt
    mailx -s "subject" xxx@xxx.com < /tmp/df_output.txt
    rm /tmp/df_output.txt
fi

or pipe the output as follows:
Code:
if [ `df -k /netprov | tail -1 | awk '{print $5'} | tr -d '%'` -gt 85 ]
then
    df -k /netprov | mailx -s "subject" xxx@xxx.com
fi

thomas
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question