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:
ssh MACHINE_IP
Replace MACHINE_IP with the IP address of your Linux machine.
- Download the latest version of the
mcdc
CLI and make it executable:curl -O "https://mcdc-release.storage.googleapis.com/$(curl -s https://mcdc-release.storage.googleapis.com/latest)/mcdc" chmod +x mcdc
- Add the
mcdc
CLI to your shell path:PATH=$PATH:`pwd`
Perform a VMware inventory discovery
Run the inventory discovery:
./mcdc discover vsphere -u USERNAME --url https://VSPHERE_URL
Replace the following:
- USERNAME: your vCenter username
- VSPHERE_URL: the URL for your vCenter Server instance or the vSphere Client
The output of the
discover
command looks like the following:[+] Found 528 VMs Collecting data... 528 / 528 [---------------------------------------------------] 100.00% 5 p/s [✓] Collection completed.
Generate a CSV file with all the discovered VMs
To generate a CSV file, use the export
script from the Migrate to Containers
repository on GitHub.
The script uses the report
command to generate a CSV file containing all the
VMs that were discovered in the previous step.
Download the script:
curl -O https://raw.githubusercontent.com/GoogleCloudPlatform/migrate-to-containers/main/scripts/mcdc/mcdc_discovery_export_guest_tools.sh chmod +x mcdc_discovery_export_guest_tools.sh
Run the script and save the output to a file:
./mcdc_discovery_export_guest_tools.sh > VMS_CSV_FILE
Replace VMS_CSV_FILE with the name you want for the CSV file.
Split the CSV file into multiple CSV files with a subset of the VMs
To split the large CSV file into smaller CSV files, use the splitter
script
from the Migrate to Containers repository on GitHub.
Download the script:
curl -O https://raw.githubusercontent.com/GoogleCloudPlatform/migrate-to-containers/main/scripts/mcdc/csv_splitter.sh chmod +x csv_splitter.sh
Run the script:
./csv_splitter.sh VMS_CSV_FILE CSV_FILES_PREFIX LINES_PER_FILE VMS_CSV_FILE CSV_FILES_PREFIX
Replace the following:
- VMS_CSV_FILE: the input CSV file to split.
- 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 -lrt CSV_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.
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.
Create the text file:
cat <<EOF >> INPUT_FILE CSV_FILES_PREFIXCSV_FILE_SUFFIX VSPHERE_URL VSPHERE_USER VSPHERE_PASSWORD VM_USER VM_PASSWORD EOF
Replace the following:
- INPUT_FILE: input filename
- CSV_FILES_PREFIX: CSV filename prefix
- CSV_FILE_SUFFIX: CSV filename suffix
- VSPHERE_URL: the URL for your vCenter Server instance or the vSphere Client
- VSPHERE_USER: vCenter username
- VSPHERE_PASSWORD: vCenter password
- VM_USER: VM username
- VM_PASSWORD: VM password
Run the guest collection script:
nohup ./mcdc_collect_vms_guest_tools.sh <INPUT_FILE > /tmp/mcdc.out 2>&1 &
Repeat steps 1 and 2 for each CSV file generated in the previous step.
Generate an offline assessment report
After all the data is collected, you can produce a detailed HTML report:
./mcdc report --format html --full > REPORT_NAME.html
What's next
- Learn how to collect guest data from EC2 instances.
- Learn more about the
mcdc
CLI. - Look through scripts samples.