Example: Python 3 checks two sample clusters in inventory.csv. The daily health script compares node state, volume state, capacity usage and SnapMirror healthy flags, then exports UTC-stamped CSV. A second script exports every volume across all pages. Requests verifies TLS by default; an internal CA bundle can be supplied explicitly.
Commands and screens can differ by release and platform. Replace example names and documentation IP addresses. Check prerequisites, impact, current health and rollback with your change owner.
1. Install dependencies and edit inventory
- Download daily-health.py, inventory-report.py, ontap_api.py, requirements.txt and inventory.csv into the same working directory. Use Python 3.10 or later, create a virtual environment, and install requests. Keep the helper alongside both scripts.
- Replace sample documentation addresses with actual cluster management IP addresses. The Python helper deliberately accepts literal IPv4 or IPv6 addresses in inventory; if your TLS certificate uses a DNS identity, adapt the helper validation to allow your approved hostnames. Prepare a read-only REST identity and the CA PEM file if an internal CA signs the cluster certificate.
- The helper checks pagination links before requesting another page and retains the original cluster host. All REST calls use timeouts; credentials are requested at the terminal unless your job supplies ONTAP_PASSWORD through a protected secret-injection mechanism.
python3 -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements.txt
cat inventory.csvThe virtual environment imports requests, inventory has Cluster,Address columns, and the monitoring account has the needed read-only API rights.
2. Run daily health and interpret results
- Run with your ONTAP account and an optional CA bundle. The script prompts for the password without echoing it. It writes a timestamped CSV in reports/ and exits 1 when any cluster has WARN or ERROR. Threshold defaults to 85 percent and can be changed from 1 to 99.
- Node state must be up; volumes must be online; aggregate physical block storage and volume space usage are tested against the threshold. A SnapMirror relationship with healthy=false is a warning. Investigate missing collections, unexpected lag, HA status and EMS alerts separately: these example checks do not cover them.
- Status ERROR is captured per cluster, allowing the next cluster to run. Review the error detail and fix certificate trust, authorization, endpoint availability or firewall access before relying on the output. Do not send credentials as command-line arguments or disable TLS verification.
python daily-health.py --inventory inventory.csv --username monitor --ca-bundle /etc/ssl/certs/ontap-ca.pem --threshold 85 --out-dir reports
head -n 5 reports/health-*.csvCSV contains one row per cluster; test a lower threshold to confirm WARN and exit code 1.
3. Export volumes and schedule a daily run
- Run inventory-report.py with the same inventory, user and CA bundle. It exports every returned volume as Cluster, SVM, Volume, State, SizeGiB and UsedGiB. It stops on an API failure to avoid presenting an incomplete list as complete.
- For a daily unattended Linux run, provision a protected secret source that injects ONTAP_PASSWORD into the job at execution time, such as your existing secrets manager. Restrict the job account, report directory and environment exposure. Set the scheduler at the desired local time and monitor nonzero exit codes and stale reports.
- For example, a service-account cron entry can invoke /opt/ontap/.venv/bin/python /opt/ontap/daily-health.py --inventory /opt/ontap/inventory.csv --username monitor --out-dir /var/log/ontap-reports. This only runs unattended when the password is supplied securely by the job environment; the interactive password prompt otherwise blocks it.
python inventory-report.py --inventory inventory.csv --username monitor --ca-bundle /etc/ssl/certs/ontap-ca.pem --out volume-inventory.csv
head -n 5 volume-inventory.csvRows and capacities match ONTAP; a scheduler reports missing output or a nonzero exit.