Script returning 0

hello i write a script which calculate free space but he always is 0 thats wrong with my script?

getFileSystemPerformanceData()
{


  if [ -r /etc/issue ] ; then
     if grep -q "Ubuntu" /etc/issue ; then
         CMD="df -lP | grep -v "\/home" | grep -v "\/dev/mapper/VolGroup-lv_root""
      elif grep -q "Mageia" /etc/issue; then
        CMD="df -lP | sed -e '2d'"
       elif grep -q "Fedora" /etc/issue; then
          CMD="df -lP | grep -v "\/home" | grep -v "\/dev/mapper/VolGroup-lv_root""
       else
       CMD="df -lP"
       fi
   else
  CMD="df -lP"
  fi
  OUTPUT=`$CMD`
    echo "$OUTPUT" |
    ( # Skip the header-line
        read IGNORED
        SUM=0
        SIZE=0
        while read FS SIZE USED AVAIL PCT MOUNTED ; do
            SIZE=`echo "$AVAIL 1024" | awk '{print $1/$2}'`
            SUM=`echo "$SUM $SIZE" | awk '{print $1 + $2}'`
        done
        PERFCLASS=LogicalDisk;PERFINSTANCE=$FS;PERFMETRIC='Avail Megabytes';PERFINT=0;PERFSAMP=1;PERFAVG=$SUM;PERFMIN=$PERFAVG;PERFMAX=$PERFAVG;writePerformanceDataXml
    )
    
}

Try to run your script in debug mode.

bash -x ./yourscript

Well, I think you - after assigning variables to and fro - echo "$CMD", read that , ignore it, and skip the while loop as there's nothing more to read, leaving all variables = 0:

.
.
.
CMD="df -lP"
fi                    # from somewhere above
OUTPUT=`$CMD`         # assign literal $CMD to OUTPUT
echo "$OUTPUT" |      # echo $CMD literally - one word in one single line
read IGNORED          # ignore literal $CMD, input stream ends, skip loop
.
.
.

Perhaps your should try:

eval "$CMD" | ( # skip the header-line
    read IGNORED
    ...

I have to revise my comment: I've taken the backtics for single quotes due to sloppy reading - sorry for that.
So, OUTPUT will contain the desired info from df -lP line by line, which you can and do read into several variables to compute with - in a subshell! You can't have subshell variables returned to the calling script except by echoing them there and reading them here.
If I read your script correctly (now, finally!), all you want is the overall available size in MB. Why don't you try to get that in an one-liner:

df -lP | awk 'NR>1 {sum+=$4/1024} END {print sum}'
30569.2

yes you get it correct about that i want to do . i cant use df -lP because script schoud work for many different linux mashine and in some mashine pvz

Filesystem            Size  Used Avail Use% Mounted on
rootfs                9.0G  3.6G  4.9G  43% /
udev                  368M     0  368M   0% /dev
tmpfs                 375M  248K  375M   1% /dev/shm
tmpfs                 375M  552K  375M   1% /run
/dev/mapper/VolGroup-lv_root  9.0G  3.6G  4.9G  43% /
tmpfs                 375M     0  375M   0% /sys/fs/cgroup
tmpfs                 375M     0  375M   0% /media
/dev/sda1             485M   31M  430M   7% /boot
/dev/mapper/VolGroup-lv_root  9.0G  3.6G  4.9G  43% /tmp
/dev/mapper/VolGroup-lv_root  9.0G  3.6G  4.9G  43% /var/tmp
/dev/mapper/VolGroup-lv_root  9.0G  3.6G  4.9G  43% /home

and with your command i get

[root@localhost ~]# df -lP | awk 'NR>1 {sum+=$4/1024} END {print sum}'
27220.8

but mashine have only 12000MB

thats why i little modiffied df -lP command