1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-22 18:50:08 +03:00

bug #4366: do not monitor lvm in tm/shared

This commit is contained in:
Javi Fontan 2016-04-27 12:04:44 +02:00
parent 53b0e1807f
commit 890f726f40

View File

@ -54,40 +54,14 @@ BRIDGE_LIST="${XPATH_ELEMENTS[i++]}"
# ------------ Compute datastore usage -------------
LVM_VG_PREFIX="vg-one-"
LVM_SIZE_CMD="sudo vgdisplay --separator : --units m -o vg_size,vg_free --nosuffix --noheadings -C"
MONITOR_SCRIPT=$(cat <<EOF
if [ ! -d $BASE_PATH ]; then
mkdir -p $BASE_PATH
fi
# If vg-one-$DS_ID exists, we assume it's an fs_lvm image datastore, therefore
# we return the space of the lvm, no of the filesystem
if PATH=\$PATH:/sbin:/bin:/usr/sbin:/usr/bin which vgdisplay &> /dev/null; then
LVM_SIZE=\$(sudo vgdisplay \
--separator : \
--units m \
-o vg_size,vg_free \
--nosuffix \
--noheadings \
-C \
${LVM_VG_PREFIX}${DS_ID} 2>/dev/null)
fi
if [ -n "\$LVM_SIZE" ]; then
LVM_TOTAL=\$(echo \$LVM_SIZE | cut -d: -f1 | sed 's/\..*//;s/^\s*//')
LVM_FREE=\$(echo \$LVM_SIZE | cut -d: -f2 | sed 's/\..*//;s/^\s*//')
LVM_USED=\$(( \$LVM_TOTAL - \$LVM_FREE ))
TOTAL_MB=\${LVM_TOTAL:-"0"}
FREE_MB=\${LVM_FREE:-"0"}
USED_MB=\${LVM_USED:-"0"}
else
USED_MB=\$(df -B1M -P $BASE_PATH 2>/dev/null | tail -n 1 | awk '{print \$3}')
TOTAL_MB=\$(df -B1M -P $BASE_PATH 2>/dev/null | tail -n 1 | awk '{print \$2}')
FREE_MB=\$(df -B1M -P $BASE_PATH 2>/dev/null | tail -n 1 | awk '{print \$4}')
fi
USED_MB=\$(df -B1M -P $BASE_PATH 2>/dev/null | tail -n 1 | awk '{print \$3}')
TOTAL_MB=\$(df -B1M -P $BASE_PATH 2>/dev/null | tail -n 1 | awk '{print \$2}')
FREE_MB=\$(df -B1M -P $BASE_PATH 2>/dev/null | tail -n 1 | awk '{print \$4}')
if [ -z "\$USED_MB" -o -z "\$TOTAL_MB" -o -z "\$FREE_MB" ]; then
msg="Empty value found"