Site icon Digital Thought Disruption

Automating Nutanix Cluster Health Checks with Bash and ncli

Introduction

Daily cluster health checks are a best practice for Nutanix administrators. While Prism offers visual insights, Bash scripting combined with ncli allows you to create repeatable, automated health assessments. This guide walks through how to script these checks, log results, and optionally integrate notifications.


My Personal Repository on GitHub

Nutanix Repository on GitHub


Benefits of Automating Cluster Health Checks


Diagram: Automated Health Check Flow


Step-by-Step Bash Script

#!/usr/bin/env bash

set -euo pipefail

# Location for health logs
logfile="/var/log/nutanix/cluster_health_$(date +'%F').log"

# Run the health check
echo "[$(date)] Running Nutanix cluster health check" >> "$logfile"
ncli cluster get-health >> "$logfile"

# Basic alert condition
if grep -qi 'FAIL' "$logfile"; then
echo "[$(date)] ⚠️ Health check FAILED" >> "$logfile"
# Optional: send email or webhook alert here
else
echo "[$(date)] ✅ Cluster is healthy" >> "$logfile"
fi

Advanced Enhancements

1. Email Alerts

Integrate with mailx, sendmail, or an SMTP relay:

mailx -s "Nutanix Health Alert" admin@example.com < "$logfile"

2. Push to Monitoring Tools

Forward results to:


Scheduling the Health Check

Add the script to cron:

0 7 * * * /usr/local/bin/nutanix_health.sh

Runs daily at 7:00 AM and appends results to /var/log/nutanix.


Summary

With minimal setup, Nutanix cluster health checks can be fully automated. Bash and ncli provide a reliable, extensible way to gain insight into infrastructure status before users notice problems. Integrating alerts and logs further strengthens the value of this workflow.

External Documentation Link:

Exit mobile version