Nutanix VM Inventory Audits with Bash

Introduction

Accurate VM inventory reporting is essential for operations, compliance, and capacity planning. Instead of exporting data manually from Prism, use Bash and Nutanix’s acli to automatically generate inventory reports in CSV format. These reports can feed into asset management systems or compliance checks.


My Personal Repository on GitHub

Nutanix Repository on GitHub


Diagram: VM Audit Script Flow


What We’ll Extract

  • VM Name
  • vCPUs
  • Memory (MB)
  • Power State
  • Network
  • IP Address (if available)

Bash Script: nutanix_vm_inventory.sh

#!/usr/bin/env bash
set -euo pipefail

output="vm_inventory_$(date +%F).csv"
echo "VM Name,vCPUs,MemoryMB,PowerState,Network,IP" > "$output"

vms=$(acli vm.list | awk 'NR>2 {print $1}')
for vm in $vms; do
info=$(acli vm.get "$vm")
cpu=$(echo "$info" | awk '/num_vcpus/ {print $2}')
mem=$(echo "$info" | awk '/memory_mb/ {print $2}')
power=$(echo "$info" | awk '/power_state/ {print $2}')
net=$(echo "$info" | awk '/network/ {print $2}')
ip=$(echo "$info" | grep ip_address | awk '{print $3}')

echo "$vm,$cpu,$mem,$power,$net,$ip" >> "$output"
done

Output Example

VM Name,vCPUs,MemoryMB,PowerState,Network,IP
web01,2,4096,on,VLAN10,10.1.10.21
db01,4,8192,off,VLAN20,10.1.20.15

Optional Enhancements

  • Upload to S3 or FTP
  • Email CSV to admin team
  • Schedule via cron for daily snapshots
0 6 * * * /usr/local/bin/nutanix_vm_inventory.sh

Summary

With a few lines of Bash and acli, you can export VM inventories on-demand or on schedule. This supports operational readiness, audit compliance, and visibility for Nutanix-based environments.

External Documentation:

Leave a Reply

Discover more from Digital Thought Disruption

Subscribe now to keep reading and get access to the full archive.

Continue reading