Way to total the columns in a df -h
Hi everybody. I need to get total space available, total space used, and total space available for all my servers.
What I was planning to do was log into each of them, do a df -h, then add up the size, used, and avail columns manually. Is there a better/faster/easier way to do this? |
On a single machine to get "all" freespace into one number:
Code:
df -lP | awk '{total+=$4} END {printf "%d", total/2^20 + 0.5}' |
Very cool, thanks. How do I tweak that to use for the other columns? change the $4 part?
|
Correct. $4 is the column number.
|
Great, thanks.
|
Instead of using | to pipe the output of df to awk I would use this
Code:
< <(df -lP) awk '..awk stuff here ..' A better example is a while read loop Code:
unset Array Array2 Anyway You will almost certainly want to apply either in conjunction with a passwordless ssh login, using public keys Example Code:
for Server in Server1 Server2 Server3;do |
pretty cool stuff there, thanks
|
All times are GMT -5. The time now is 10:56 AM. |