Nutanix Command Line Interface (nCLI) Overview

Reading Time: 3 minutes

Nutanix Command Line Interface (nCLI) provides another command-line interface for executing commands in a Nutanix Cluster. This article will give some valuable examples of this critical tool.

First and foremost, How can I execute the nCLI?

To run nCLI, we can access any Controller VM (CVM) in the cluster:

Since we are using the Nutanix AOS 6.5 in our lab environment, the following documentation can be used for all nCLI options:

https://portal.nutanix.com/page/documents/details?targetId=Command-Ref-AOS-v6_5:man-ncli-c.html

Executing nCLI to Get Cluster Details (ncli cluster)

Checking the configured cluster name servers (DNS servers) and NTP servers:

#Getting configured DNS servers on the Nutanix cluster:
ncli cluster get-name-servers

#Getting configured NTP servers on the Nutanix cluster:
ncli cluster get-ntp-servers

We can use the following command to get:

  • Cluster ID and UUID
  • Cluster Name and Version
  • Virtual IP address (aka External IP address)
  • Node count
  • External IP Data Services
  • RF1 Container Support (Enabled or not)
  • NCC version
  • Etc…….
ncli cluster get-params

If you need to get only the cluster version:

ncli cluster version

To get the cluster redundancy state (Redundancy Factor) and resiliency preference:

#Getting the cluster redundancy state:
ncli cluster get-redundancy-state

#Getting the cluster resiliency preference:
ncli cluster get-resiliency-preference

To get the status for all cluster services (on all Controller VMs):

ncli cluster status

(…we have omitted the total command output….)

Executing nCLI to Get Host Details (ncli host)

To list all hosts (hypervisors) and their details:

ncli host list

To get stats data for hosts:

ncli host list-stats

Example of usage: To get the current CPU and Memory usage (%) for all Hypervisors:

ncli host list-stats | egrep -i "Hypervisor|CPU Usage|Memory" | awk '/CPU Usage Percent/ {print; print "-----------------------"} !/CPU Usage Percent/ {print}'

or

ncli host list-stats | egrep -i "Hypervisor|CPU Usage|Memory" | sed '/CPU Usage Percent/a --------------------------'

Executing nCLI to Get VM Details (ncli virtualmachine)

To list all virtual machines (VMs):

ncli virtualmachine list

To get stats for each virtual machine (VM):

ncli virtualmachine list-stats

Example of Usage: To get the CPU usage (%) and Memory Usage (bytes) for all Controller VMs (CVMs):

ncli virtualmachine list-stats | egrep -i "Name|CPU Usage|Memory Usage" | grep -A2 '\CVM' | sed '/Memory Usage/a --'

That’s it 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *