Hi all, and William in particular.
Many thanks for the ghettoVCB.sh tool. I have been using it fine on ESXi 4.1, but have had to make a few tweaks to improve its robustness in the face of the weird things my users and I were doing with our VMs! Now that William is working hard on updates to the current version, I thought I'd post here with my changes, in the hope that they can be incorporated to the master. I hope the format I present them in below, is OK for you. The line numbers I refer to are from the master ghettoVCB.sh I downloaded today, size 62,058 bytes, md5 e6ad79a827dedfe706f5189a0f10e7dd.
Line 264, was seeing extraneous messages from the snapshot remove command in the logs, so changed from:
${VMWARE_CMD} vmsvc/snapshot.remove | grep "snapshotId" > /dev/null 2>&1
to:
${VMWARE_CMD} vmsvc/snapshot.remove 2>&1 | grep -q "snapshotId"
Line 395, had some commented-out VMDK's in a VMX, so made this grep more robust, changed from:
VMDKS_FOUND=$(grep -iE '(scsi|ide)' "${VMX_PATH}" | grep -i fileName | awk -F " " '{print $1}')
to:
VMDKS_FOUND=$(grep -iE "(^scsi|^ide)" "${VMX_PATH}" | grep -i fileName | awk -F " " '{print $1}')
Line 403, same reason as for line 395. Changed:
grep -i "${SCSI_ID}.present" "${VMX_PATH}" | grep -i "true" > /dev/null 2>&1
to:
grep -i "^${SCSI_ID}.present" "${VMX_PATH}" | grep -i "true" > /dev/null 2>&1
Line 408, same reason as for line 395. Changed:
grep -i "${SCSI_ID}.mode" "${VMX_PATH}" | grep -i "independent" > /dev/null 2>&1
to:
grep -i "^${SCSI_ID}.mode" "${VMX_PATH}" | grep -i "independent" > /dev/null 2>&1
Line 410, same reason as for line 395. Changed:
grep -i "${SCSI_ID}.deviceType" "${VMX_PATH}" | grep -i "scsi-hardDisk" > /dev/null 2>&1
to:
grep -i "^${SCSI_ID}.deviceType" "${VMX_PATH}" | grep -i "scsi-hardDisk" > /dev/null 2>&1
Line 414, same reason as for line 395. Changed:
DISK=$(grep -i ${SCSI_ID}.fileName "${VMX_PATH}" | awk -F "\"" '{print $2}')
to:
DISK=$(grep -i "^${SCSI_ID}.fileName" "${VMX_PATH}" | awk -F "\"" '{print $2}')
Line 430, same reason as for line 395. Changed:
grep -i ${SCSI_ID}.fileName "${VMX_PATH}" | grep -i ".vmdk" > /dev/null 2>&1
to:
grep -i "^${SCSI_ID}.fileName" "${VMX_PATH}" | grep -i ".vmdk" > /dev/null 2>&1
Line 433, same reason as for line 395. Changed:
DISK=$(grep -i ${SCSI_ID}.fileName "${VMX_PATH}" | awk -F "\"" '{print $2}')
to:
DISK=$(grep -i "^${SCSI_ID}.fileName" "${VMX_PATH}" | awk -F "\"" '{print $2}')
Line 448, same reason as for line 395. Changed:
DISK=$(grep -i ${SCSI_ID}.fileName "${VMX_PATH}" | awk -F "\"" '{print $2}')
to:
DISK=$(grep -i "^${SCSI_ID}.fileName" "${VMX_PATH}" | awk -F "\"" '{print $2}')
Line 767, since getallvms output includes the annotations for all VMs, I had to make this more robust, otherwise some lines from the annotations ended up looking like extra VMs. Changed:
${VMWARE_CMD} vmsvc/getallvms | sed 's/[[:blank:]]\{3,\}/ /g' | awk -F' ' '{print "\""$1"\";\""$2"\";\""$3"\""}' | sed 's/\] /\]\";\"/g' | sed '1,1d' > ${WORKDIR}/vms_list
to:
${VMWARE_CMD} vmsvc/getallvms | sed 's/[[:blank:]]\{3,\}/ /g' | fgrep "[" | fgrep "vmx-" | fgrep ".vmx" | fgrep "/" | awk -F' ' '{print "\""$1"\";\""$2"\";\""$3"\""}' | sed 's/\] /\]\";\"/g' > ${WORKDIR}/vms_list
Line 770, for the same reason as 767, changed:
${VMWARE_CMD} vmsvc/getallvms | sed 's/[[:blank:]]\{3,\}/ /g' | awk -F' ' '{print ""$2""}' | sed '1,1d' | sed '/^$/d' > "${VM_INPUT}"
to:
${VMWARE_CMD} vmsvc/getallvms | sed 's/[[:blank:]]\{3,\}/ /g' | fgrep "[" | fgrep "vmx-" | fgrep ".vmx" | fgrep "/" | awk -F' ' '{print ""$2""}' | sed '/^$/d' > "${VM_INPUT}"
regards Andy