Need script to monitor "ALL" Disk Spaces

Hi,

I have searched the forum and found that there are many scripts that need the path i.e. /tmp, /opt, /var etc to be provided or hard coded for it to calculate the disk space free percentage.

What i need is a script that shows the free disk space for all partitions on my HPUX itanium server.

expected output:

Current output for df -k looks something like this:

Can you please help ?

Hello,

Could you please use the following code with

 awk 

.
I am in AIX server but you can use

 awk 

to find out only free space. Here is an example for same.

$ df -kP | awk '{print$3}'

Output will be as follows.

 
Used
112736
4233904
193776
35380

Thanks,
R. Singh

df -k | awk -F":" '/^\//{a=a$1" : ";next} /%/ {a=a$1"\n"} END{print a}' | awk '(NF>0){$5=100-$5; $7="free"; $8=""} 1'
1 Like

It works for most but does not work for some. Please see my output below.

/opt/app/optier (/dev/vx/dsk/dgd1grn1m1app1/optier) : 4 100 allocation free
/dev/odm (/dev/odm ) : 100 % free
/etc/vx/cbr/bk (/dev/vg00/cbr ) : 95 % free
/home (/dev/vg00/home ) : 19 % free
/opt/app/d1grn1m1/app1/bea (/dev/vx/dsk/dgd1grn1m1bea/bea) : 31 100 allocation free
/opt/app/d1grn1m1/app1 (/dev/vx/dsk/dgd1grn1m1app1/app1) : 12 100 allocation free
/opt/app/ndm (/dev/vx/dsk/dgd1grn1m1app1/ndm) : 11 100 allocation free
/opt (/dev/vg00/opt ) : 22 % free
/tmp (/dev/vg00/tmp ) : 95 % free
/usr/local/EMC (/dev/vg00/emc ) : 97 % free
/usr/local/opt/introscope (/dev/vx/dsk/dgd1grn1m1intro/introscope) : 10 100 allocation free
/usr/localcw/opt/patrol (/dev/vg00/patrol ) : 68 % free
/usr/localcw (/dev/vg00/localcw ) : 77 % free
/usr (/dev/vg00/usr ) : 33 % free
/var/adm/crash (/dev/vg00/crash ) : 99 % free
/var/adm/sw (/dev/vg00/sw ) : 41 % free
/var (/dev/vg00/var ) : 87 % free
/stand (/dev/vg00/stand ) : 54 % free
/ (/dev/vg00/root ) : 69 % free

The BOLD does not show percentages. Can you please explain and help fix?

Mohtashims,

>> What i need is a script that shows the free disk space for all partitions on my HPUX itanium server.

  • Why not use bdf or bdfmegs to make things easier.

check this out:
bdfmegs ver 5.0 - HP Enterprise Business Community

When I see the difference between the BOLDed output lines and correct output lines, the difference is that the mount point having a space before ")" gives correct output. The space is important for awk command to interpret positional arguments properly. To fix this, let us insert a blank space before ")" so that the BOLDed output lines get fixed. Please use below command.

df -k | awk -F":" '/^\//{sub(/)/," )");a=a$1" : ";next} /%/ {a=a$1"\n"} END{print a}' | awk '(NF>0){$5=100-$5; $7="free"; $8=""} 1'