Tag Archives: SUM

Script returningng 0

By donatas1234

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
)


}

…read more
Source: FULL ARTICLE at The UNIX and Linux Forums