Re: df to get total disk usage on all filesystems?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Thu, Aug 14, 2008 at 10:09:23AM -0700, MHR wrote:
> On Thu, Aug 14, 2008 at 3:50 AM, Stephen Harris <lists@xxxxxxxxxx> wrote:
> > On Thu, Aug 14, 2008 at 01:12:58AM -0700, MHR wrote:
> >> On Wed, Aug 13, 2008 at 8:56 PM, Lunix1618 <lunix1618@xxxxxxxxx> wrote:
> >> > [root@centos-svr ~]# df -kPl
> >> > Filesystem         1024-blocks      Used Available Capacity Mounted on
> >> > /dev/mapper/VolGroup00-LogVol00 274405432  18584656 241656808       8% /
> >> > /dev/sda2               101105     19096     76788      20% /boot
> >> > tmpfs                  1682508         0   1682508       0% /dev/shm
> >> >
> >> > and with the command of Stephen :
> >> > [root@centos-svr ~]# df -Pkl | awk '/^\/dev\// { avail += $3/1024 } END { printf("%d Mb used\n",avail)} '
> >> > 18173 Mb used
> >
> >> Well, I get 18167, but that's not too far off.
> >
> > And, remember, that the output of "df" might have changed in between
> > times you ran "df" and you ran the "awk" command; there's only 7Mbytes
> > difference.  Did someone delete a 7Mbyte file?  Send email?  Finish a
> > print job?  Or... could be plenty of reasons for the used amount to
> > go down.
> >
> 
> Clarification - I just took the numbers above and used a calculator -
> my system would never produce numbers anything like that for any of my
> machines....

One trick is to sent the "df -Pkl" info to a file.
Then cat that file into the "awk" script.
Also cat that file to stdout during debugging.

Sending the df output to a file does a number of 
things.   It removes any race risk that you might be
seeing.  And it lets you and the community "check yer work".

When in this discussion did the variable name avail get assigned to
the Used col header in the line atributed to Stephen?

Something like:

$ cat /tmp/checkspace
#!/bin/bash
df -Pkl > /tmp/checkingdiskspce
echo -e "\nInput is:"
cat /tmp/checkingdiskspce 
echo -e "\nAdding up the bits"
cat /tmp/checkingdiskspce | awk '/^\/dev\// { used += $3/1024 } END { printf("%d Mb Used\n", used)} '
echo -e "\nNow df with a human flag"
df -h




-- 
	T o m  M i t c h e l l 
	Got a great hat... now what.

_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos

[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux