I am writing a script that ssh's out to our various servers and extracts diskspace info to generate into a report. With the mix of servers linux/solairs 8-10/AIX the easiest way is to use df -k (though I much rather prefer df -h).
I have pasted the relevant code:
dfdata=`ssh -q -o ConnectTimeout=10 rkruck@$host df -k `
if (( $? == 0 ))
then
echo "$dfdata" | \
grep "/dev/" | \
egrep ' 9[0-9]%| 100%' | \
awk '{printf "%-16s %4s %6.2f %s\n"
, H, $5, $4/ 1024, $6}' H=$host >> $RDIR/diskspace.$RDATE
I get the right output, but am having trouble formatting the 3rd colum lining up so it's right justfied with the 2 decimal places lining up so it looks like the following:
hostname1 91% 1809.53 /u01
hostname2 95% 1196.00 /u02
hostname3 99% 209.20 /u04
hostname4 97% 734.77 /u03
hostname5 98% 448.74 /u08
hostname6 94% 1214.33 /u07
hostname7 100% 188.25 /u05
hostname8 95% 1053.51 /u09
hostname9 94% 4232.70 /d02
hostname10 91% 6424.62 /d01
hostname11 99% 24354.89 /ora05
hostname12 90% 643.86 /home
Any help is appreicated.
Robert