Stay organized with collections
Save and categorize content based on your preferences.
This tutorial walks you through the process of discovering and collecting data
on a batch of VMware virtual machine (VM) instances using the
Migration Center discovery client CLI guest discovery. Large batches of VMs may be difficult
to monitor and troubleshoot. We recommend batching into smaller groups of less
than 1,000.
Objectives
In this tutorial, you will learn how to:
Download the mcdc CLI.
Run a VMWare inventory discovery.
Generate a CSV file with all the discovered VMs.
Split the CSV file into multiple CSV files containing a subset of the VMs.
Run guest discovery on all the VMs in a CSV file.
Generate an offline assessment report.
Costs
This tutorial uses on-premises resources and incurs no Google Cloud
costs.
Before you begin
Prepare a Linux machine to install and run the
mcdc CLI. The Linux machine must have the
following minimum requirements:
glibc version 2.25 or later
4 GB RAM and 10 GB disk space
Network connectivity to vCenter and ESX hosts
Ensure that you have a vSphere user with the necessary permissions:
Read privileges to VMs
Read privileges to all the ESX hosts
Guest operation modifications
Guest operation program execution
Guest operation queries
Download the mcdc CLI
Connect to the Linux machine:
sshMACHINE_IP
Replace MACHINE_IP with the IP address of your Linux machine.
Download the latest version of the mcdc CLI and make it executable:
CSV_FILES_PREFIX: the prefix for the generated CSV
files.
LINES_PER_FILE: the number of lines per generated
CSV file. The default value is 10.
The script generates various CSV files.
View the list of generated CSV files:
ls-lrtCSV_FILES_PREFIX*
Run guest discovery on all the VMs in a CSV files
To run the guest discovery for the VMs in a CSV file, use the
collection script from the Migrate to Containers GitHub repository.
Repeat this step for each CSV file generated in the previous step.
url_regex='^https?://[-A-Za-z0-9\+&@#/%?=~_|!:,.;]*[-A-Za-z0-9\+&@#/%=~_|]\.[-A-Za-z0-9\+&@#/%?=~_|!:,.;]*[-A-Za-z0-9\+&@#/%=~_|]$'read-r-p"CSV file name: "CSV_FILE
if[[!-r"$CSV_FILE"]];thenecho"The file $CSV_FILE does not exist or can not be accessed."exit1firead-r-p"vSphere URL: "VSPHERE_URL
if![[$VSPHERE_URL=~$url_regex]];thenecho"vSphere URL $VSPHERE_URL IS not a valid URL"exit1firead-r-p"vSphere username: "VSPHERE_USER
read-r-s-p"vSphere password: "VSPHERE_PASSWORD
echo""read-r-p"Default username: "DEFAULT_USER
read-r-s-p"Default password: "DEFAULT_PASSWORD
echo""# CSV fields#NAME;PLATFORM VM ID;OS;IP;USERNAME;PASSWORDwhileIFS=";"read-rvm_namevm_idosipusernamepassword
doif[-z"$username"]thenusername=$DEFAULT_USERfiif[-z"$password"]thenpassword=$DEFAULT_PASSWORDfiif[!-z"$vm_id"]then# Note that the below only works for VMWare VMs# vm_id after the last slash if prefixed by vSphere IPmod_vm_id=$(echo"$vm_id"|sed's/.*\///')mcdcdiscovervsphereguest--url$VSPHERE_URL-u$VSPHERE_USER-p$VSPHERE_PASSWORD--vm-user$username--vm-password$password$mod_vm_idelseecho"Skipping VM: $vm_name because it has no VM ID"fidone < <(tail-n+1$CSV_FILE)
The script uses the discover vsphere guest command to upload and execute the
guest collection script on the VM.
It's best to execute this script in the background and direct the output to a
log file. To do so, you need to create a text file which is passed as input to
the script.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[],[],null,["# Batching guest discovery and data collection\n\n*** ** * ** ***\n\nThis tutorial walks you through the process of discovering and collecting data\non a batch of VMware virtual machine (VM) instances using the\nMigration Center discovery client CLI guest discovery. Large batches of VMs may be difficult\nto monitor and troubleshoot. We recommend batching into smaller groups of less\nthan 1,000.\n\nObjectives\n----------\n\nIn this tutorial, you will learn how to:\n\n- Download the `mcdc` CLI.\n- Run a VMWare inventory discovery.\n- Generate a CSV file with all the discovered VMs.\n- Split the CSV file into multiple CSV files containing a subset of the VMs.\n- Run guest discovery on all the VMs in a CSV file.\n- Generate an offline assessment report.\n\nCosts\n-----\n\nThis tutorial uses on-premises resources and incurs no Google Cloud\ncosts.\n\nBefore you begin\n----------------\n\n1. Prepare a Linux machine to install and run the\n `mcdc` CLI. The Linux machine must have the\n following minimum requirements:\n\n - `glibc` version 2.25 or later\n - 4 GB RAM and 10 GB disk space\n - Network connectivity to vCenter and ESX hosts\n2. Ensure that you have a vSphere user with the necessary permissions:\n\n - Read privileges to VMs\n - Read privileges to all the ESX hosts\n - Guest operation modifications\n - Guest operation program execution\n- Guest operation queries \n\nDownload the `mcdc` CLI\n-----------------------\n\n1. Connect to the Linux machine: \n\n ```bash\n ssh MACHINE_IP\n ```\n\n Replace \u003cvar translate=\"no\"\u003eMACHINE_IP\u003c/var\u003e with the IP address of your Linux machine.\n2. Download the latest version of the `mcdc` CLI and make it executable: \n\n ```bash\n curl -O \"https://mcdc-release.storage.googleapis.com/$(curl -s https://mcdc-release.storage.googleapis.com/latest)/mcdc\"\n chmod +x mcdc\n ```\n3. Add the `mcdc` CLI to your shell path: \n\n ```bash\n PATH=$PATH:`pwd`\n ```\n\nPerform a VMware inventory discovery\n------------------------------------\n\n- Run the inventory discovery:\n\n ./mcdc discover vsphere -u \u003cvar translate=\"no\"\u003eUSERNAME\u003c/var\u003e --url https://\u003cvar translate=\"no\"\u003eVSPHERE_URL\u003c/var\u003e\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eUSERNAME\u003c/var\u003e: your vCenter username\n - \u003cvar translate=\"no\"\u003eVSPHERE_URL\u003c/var\u003e: the URL for your vCenter Server instance or the vSphere Client\n\n The output of the `discover` command looks like the following: \n\n ```\n [+] Found 528 VMs\n Collecting data...\n 528 / 528 [---------------------------------------------------] 100.00% 5 p/s\n [✓] Collection completed.\n ```\n\nGenerate a CSV file with all the discovered VMs\n-----------------------------------------------\n\nTo generate a CSV file, use the `export` script from the Migrate to Containers\nrepository on GitHub. \n\n\n vms=$(mcdc report --format csv | tail -n +2 | awk -F ',' '{; print $2\";\"$3\";\"$4\";;;\"}')\n printf \"%s\\n\" \"Name;Platform VM ID;OS Family;IP;USERNAME;PASSWORD\"\n printf \"%s\\n\" \"$vms\"\n\nThe script uses the `report` command to generate a CSV file containing all the\nVMs that were discovered in the previous step.\n\n1. Download the script:\n\n curl -O https://raw.githubusercontent.com/GoogleCloudPlatform/migrate-to-containers/main/scripts/mcdc/mcdc_discovery_export_guest_tools.sh\n chmod +x mcdc_discovery_export_guest_tools.sh\n\n2. Run the script and save the output to a file:\n\n ./mcdc_discovery_export_guest_tools.sh \u003e \u003cvar translate=\"no\"\u003eVMS_CSV_FILE\u003c/var\u003e\n\n Replace \u003cvar translate=\"no\"\u003eVMS_CSV_FILE\u003c/var\u003e with the name you want for the CSV file.\n\nSplit the CSV file into multiple CSV files with a subset of the VMs\n-------------------------------------------------------------------\n\nTo split the large CSV file into smaller CSV files, use the `splitter` script\nfrom the Migrate to Containers repository on GitHub. \n\n tail -n +2 $1 | split -d -l $num_of_lines - $2\n for file in $2*\n do\n head -n 1 $1 \u003e tmp_file\n cat \"$file\" \u003e\u003e tmp_file\n mv -f tmp_file \"$file\"\n done\n\n1. Download the script:\n\n curl -O https://raw.githubusercontent.com/GoogleCloudPlatform/migrate-to-containers/main/scripts/mcdc/csv_splitter.sh\n chmod +x csv_splitter.sh\n\n2. Run the script:\n\n ./csv_splitter.sh \u003cvar translate=\"no\"\u003eVMS_CSV_FILE\u003c/var\u003e \u003cvar translate=\"no\"\u003eCSV_FILES_PREFIX\u003c/var\u003e \u003cvar translate=\"no\"\u003eLINES_PER_FILE\u003c/var\u003e \u003cvar translate=\"no\"\u003eVMS_CSV_FILE\u003c/var\u003e \u003cvar translate=\"no\"\u003eCSV_FILES_PREFIX\u003c/var\u003e\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eVMS_CSV_FILE\u003c/var\u003e: the input CSV file to split.\n - \u003cvar translate=\"no\"\u003eCSV_FILES_PREFIX\u003c/var\u003e: the prefix for the generated CSV files.\n - \u003cvar translate=\"no\"\u003eLINES_PER_FILE\u003c/var\u003e: the number of lines per generated CSV file. The default value is `10`.\n\n The script generates various CSV files.\n3. View the list of generated CSV files:\n\n ls -lrt \u003cvar translate=\"no\"\u003eCSV_FILES_PREFIX\u003c/var\u003e*\n\nRun guest discovery on all the VMs in a CSV files\n-------------------------------------------------\n\nTo run the guest discovery for the VMs in a CSV file, use the\n`collection` script from the Migrate to Containers GitHub repository.\n\nRepeat this step for each CSV file generated in the previous step. \n\n\n url_regex='^https?://[-A-Za-z0-9\\+&@#/%?=~_|!:,.;]*[-A-Za-z0-9\\+&@#/%=~_|]\\.[-A-Za-z0-9\\+&@#/%?=~_|!:,.;]*[-A-Za-z0-9\\+&@#/%=~_|]$'\n\n read -r -p \"CSV file name: \" CSV_FILE\n if [[ ! -r \"$CSV_FILE\" ]]; then\n echo \"The file $CSV_FILE does not exist or can not be accessed.\"\n exit 1\n fi\n\n read -r -p \"vSphere URL: \" VSPHERE_URL\n if ! [[ $VSPHERE_URL =~ $url_regex ]]; then\n echo \"vSphere URL $VSPHERE_URL IS not a valid URL\"\n exit 1\n fi\n read -r -p \"vSphere username: \" VSPHERE_USER\n read -r -s -p \"vSphere password: \" VSPHERE_PASSWORD\n echo \"\"\n read -r -p \"Default username: \" DEFAULT_USER\n read -r -s -p \"Default password: \" DEFAULT_PASSWORD\n\n echo \"\"\n\n # CSV fields\n #NAME;PLATFORM VM ID;OS;IP;USERNAME;PASSWORD\n while IFS=\";\" read -r vm_name vm_id os ip username password\n do\n if [ -z \"$username\" ]\n then\n username=$DEFAULT_USER\n fi\n if [ -z \"$password\" ]\n then\n password=$DEFAULT_PASSWORD\n fi\n\n if [ ! -z \"$vm_id\" ]\n then\n # Note that the below only works for VMWare VMs\n # vm_id after the last slash if prefixed by vSphere IP\n mod_vm_id=$(echo \"$vm_id\" | sed 's/.*\\///')\n mcdc discover vsphere guest --url $VSPHERE_URL -u $VSPHERE_USER -p $VSPHERE_PASSWORD --vm-user $username --vm-password $password $mod_vm_id\n else\n echo \"Skipping VM: $vm_name because it has no VM ID\"\n fi\n done \u003c \u003c(tail -n +1 $CSV_FILE)\n\nThe script uses the `discover vsphere guest` command to upload and execute the\nguest collection script on the VM.\n\nIt's best to execute this script in the background and direct the output to a\nlog file. To do so, you need to create a text file which is passed as input to\nthe script.\n\n1. Create the text file:\n\n cat \u003c\u003cEOF \u003e\u003e \u003cvar translate=\"no\"\u003eINPUT_FILE\u003c/var\u003e\n \u003cvar translate=\"no\"\u003eCSV_FILES_PREFIX\u003c/var\u003e\u003cvar translate=\"no\"\u003eCSV_FILE_SUFFIX\u003c/var\u003e\n \u003cvar translate=\"no\"\u003eVSPHERE_URL\u003c/var\u003e\n \u003cvar translate=\"no\"\u003eVSPHERE_USER\u003c/var\u003e\n \u003cvar translate=\"no\"\u003eVSPHERE_PASSWORD\u003c/var\u003e\n \u003cvar translate=\"no\"\u003eVM_USER\u003c/var\u003e\n \u003cvar translate=\"no\"\u003eVM_PASSWORD\u003c/var\u003e\n EOF\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eINPUT_FILE\u003c/var\u003e: input filename\n - \u003cvar translate=\"no\"\u003eCSV_FILES_PREFIX\u003c/var\u003e: CSV filename prefix\n - \u003cvar translate=\"no\"\u003eCSV_FILE_SUFFIX\u003c/var\u003e: CSV filename suffix\n - \u003cvar translate=\"no\"\u003eVSPHERE_URL\u003c/var\u003e: the URL for your vCenter Server instance or the vSphere Client\n - \u003cvar translate=\"no\"\u003eVSPHERE_USER\u003c/var\u003e: vCenter username\n - \u003cvar translate=\"no\"\u003eVSPHERE_PASSWORD\u003c/var\u003e: vCenter password\n - \u003cvar translate=\"no\"\u003eVM_USER\u003c/var\u003e: VM username\n - \u003cvar translate=\"no\"\u003eVM_PASSWORD\u003c/var\u003e: VM password\n2. Run the guest collection script:\n\n nohup ./mcdc_collect_vms_guest_tools.sh \u003c\u003cvar translate=\"no\"\u003eINPUT_FILE\u003c/var\u003e \u003e /tmp/mcdc.out 2\u003e&1 &\n\n3. Repeat steps 1 and 2 for each CSV file generated in the previous step.\n\nGenerate an offline assessment report\n-------------------------------------\n\n- After all the data is collected, you can produce a detailed HTML report:\n\n ```bash\n ./mcdc report --format html --full \u003e REPORT_NAME.html\n \n ```\n\nWhat's next\n-----------\n\n- Learn how to [collect guest data from EC2 instances](/migrate/containers/docs/mcdc-aws-collection-tutorial).\n- Learn more about the [`mcdc` CLI](/migration-center/docs/discovery-client-cli-overview).\n- Look [through scripts samples](https://github.com/GoogleCloudPlatform/migrate-to-containers/tree/main/scripts/mcdc)."]]