103 Commits

Author SHA1 Message Date
justin 7a45a9c49a Add VmSourceVRA label and resolve VRA names for VM metrics
- Add VmSourceVRA to _VM_LABELS, populated from vm['OwningHostName']
  resolved to a VRA name via a host→VRA lookup built from zvm.vras()
- VmRecoveryVRA now also resolves to the actual VRA name (e.g.
  Z-VRA-192.168.50.21) instead of the raw ESXi host IP
- Cloud-target VPGs (Azure/AWS) correctly emit VmRecoveryVRA="" since
  there is no local VRA on the recovery side
- Bump version to 3.1.0

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-21 11:39:35 -05:00
justin 4252d3c187 Fix duplicate VRA metrics after VRA upgrade (closes #21)
VraVersion is used as a Prometheus label. When a VRA upgrades, the new
version creates a new time series while the old one persists until restart.

Fix: clear all VRA Gauges at the start of each collection cycle so stale
label sets (old version numbers) are removed before repopulating with
current data.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-20 20:04:00 -05:00
justin 1f591e20ef Bump version to 3.0.0 and remove leaked PyPI token
- Version bumped to 3.0.0 to reflect breaking changes: dropped zvma9_7,
  switched to prometheus_client + JSON stdout logging, removed legacy packages
- Remove app/.pypirc (contained leaked PyPI token, now gitignored)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-20 19:55:19 -05:00
justin a4ff29e1b5 Fix counter spike/negative on ZVM reboot (closes #12)
When a ZVM reboots its cumulative counters (IOPs, write/sync/network MBs,
encrypted/unencrypted LBs) reset to zero. The previous abs() approach
converted the large negative delta into an equally wrong positive spike.

Introduces _counter_delta(new, old, vm_id, metric) which:
- Returns new - old when new >= old (normal incrementing counter)
- Returns new as-is when new < old (counter reset / reboot detected)
  and logs a WARNING identifying the VM and metric that reset

Publishing the raw new value on reset correctly reflects the restarted
counter state, suppresses the false spike, and produces a visible dip
in Grafana that naturally indicates the ZVM reboot event.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-20 19:47:35 -05:00
justin 1992fb1d17 Bump to Python 3.14.3-slim, fix 9 CVEs, remove leaked PyPI token
- Dockerfile: python:3.13-slim -> python:3.14.3-slim (stable as of Feb 2026)
- certifi: 2023.7.22 -> >=2024.7.4 (CVE-2024-39689, LOW)
- idna: 3.4 -> >=3.7 (CVE-2024-3651, MEDIUM)
- requests: 2.32.0 -> >=2.32.4 (CVE-2024-47081, MEDIUM)
- urllib3: 2.0.6 -> >=2.6.3 (6 CVEs including 3 HIGH decompression/redirect)
- Add app/.pypirc and .pypirc to .gitignore to prevent future token leaks

NOTE: PyPI token was previously committed at 21f32e5 - rotate at pypi.org.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-20 19:32:41 -05:00
justin 2836e1ae10 Refactor to prometheus_client, JSON logging, and codebase cleanup
- Replace file-based metrics and HTTP server with prometheus_client
  (Gauge + start_http_server), eliminating file I/O race conditions
- Fix ThreadProbe and thread restart lambda bugs
- Switch logging from RotatingFileHandler to JSON stdout for fluentd/Loki
- Add PYTHONUNBUFFERED=1 to Dockerfile for immediate container log output
- Upgrade base image from python:3.12.3-slim to python:3.13-slim
- Upgrade pyvmomi to 9.0.0.0; pin pydantic>=2.9.0 and typing_extensions>=4.12.2
  to use pre-built Python 3.13 wheels (removes Rust toolchain from build)
- Remove unused packages: boto3, botocore, s3transfer, jmespath, redis,
  docopt, pyflakes, posthog
- Remove unused imports (Posthog, CaseInsensitiveDict) and dead variables
  (callhomestats, local_site_info, lastStats)
- Fix service_profile() NameError (siteidentifier -> serviceProfileIdentifier)
- Remove bare print() in zvma.py __authhandler__, replace with self.log.info()
- Remove all commented-out PostHog blocks from zvma10/zvma.py
- Delete legacy zvma9_7/ module and app/logs/ directory
- Remove deprecated 'version: 3.3' from docker-compose.yml

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-20 19:05:45 -05:00
justin a0afcefc78 Create requirements.txt 2025-02-18 19:42:08 -05:00
justin a0ac6883f4 updates for zvma10 2024-05-30 20:57:39 -04:00
justin 4e95d13c6d Update python-node-exporter.py 2023-12-21 14:00:10 -05:00
justin 21f32e5a31 updates for docker environments 2023-12-21 12:57:30 -05:00
justin a581cdfb6d Update requirements.txt 2023-12-21 10:48:29 -05:00
justin 7618fa7d04 finished exporter refactor
Ready for some beta testing with Zerto 10.0
2023-12-21 10:34:41 -05:00
justin deae17aca9 updates to modules 2023-12-19 12:18:46 -05:00
justin 0911a4eccc zvma10 wrapper module
Created a python module that has everything needed for comms with ZVMA version 10 in a seperate class. It does not have full api coverage, but is enough to start refactoring the exporter to use the class for ZVMa10
2023-12-08 11:05:50 -05:00
justin b51a7bd068 added zvma class to module 2023-10-26 19:35:29 -04:00
justin 4781b942f4 started zvm site class from vcenter template 2023-10-24 20:57:41 -04:00
justin 48dc444166 dev updates
Not finished, but pushing for use on another machine
2023-10-24 19:52:09 -04:00
justin 251b23990c Update python-node-exporter.py
Updated logic to look for VM and VPG ID in encryption detection stats incase VM is protected using one to many
2023-03-25 13:23:15 -04:00
justin 65ab4d33d6 Update python-node-exporter.py 2023-03-25 00:14:13 -04:00
justin a265a84517 Update python-node-exporter.py
fix for one to many protection of vms
2023-03-25 00:02:03 -04:00
justin bb4b538bb5 Update python-node-exporter.py 2023-03-24 23:38:59 -04:00
justin 1cc51f6434 updated vm metric tags
added vpgname to vm stats
2023-03-24 23:00:02 -04:00
justin 39d8ac07ae Update python-node-exporter.py
removing data from the VM api for VMs recovering to a site
2023-03-24 22:36:12 -04:00
justin af393322de threads logger update
updated threads file so that it shows which exporter it is actually monitoring incase there is many
2023-03-23 13:26:47 -04:00
justin c8f145b27b updated log file path
moved logs into a path where they can easily be seen over http instead of logging into the docker host
2023-03-23 13:19:03 -04:00
justin cf05ae8e34 Update python-node-exporter.py
Had to account for public cloud recoveryhosts returning None. Will open an issue to solve this better later
2023-03-23 13:16:12 -04:00
justin 59df05c079 make vcenter optional
If vcenter hostname isnt set dont try to get vra cpu and memory
2023-03-23 12:45:43 -04:00
justin 4a6588cc82 Update python-node-exporter.py
ill get it right sooner or later
2023-03-23 12:39:00 -04:00
justin 7f80cdf3cb Update python-node-exporter.py
im stupid :)
2023-03-23 12:35:21 -04:00
justin 6420a1d0ec Update python-node-exporter.py
added exception handling to data collection function
2023-03-23 12:31:11 -04:00
justin a20eb125c9 Update python-node-exporter.py 2023-03-23 12:17:21 -04:00
justin 502ea13a6d Update python-node-exporter.py
multi-exporter logging to seperate files
2023-03-23 12:00:25 -04:00
justin b985e8885c gitignore and a sleep time for liveness checker 2023-03-23 11:39:44 -04:00
justin d07b949825 remove lab metrics 2023-03-23 11:38:13 -04:00
justin 69aaaaf69b app code update
added default site name and id
2023-03-23 11:37:29 -04:00
justin 94a3822353 multi-site readiness and VRA CPU and Memory
Added Site ID and Site Name to every metric. Moved all VRA metrics to a separate thread and started collecting VRA CPU and Memory usage from vCenter API.
2023-03-23 08:01:21 -04:00
justin 0688fe6aab exception handling and comments 2023-03-22 23:27:22 -04:00
justin 79002278d7 Update python-node-exporter.py 2023-03-20 20:39:08 -04:00
justin 43dc741d52 Update python-node-exporter.py 2023-03-20 20:26:47 -04:00
justin de3a4a83b1 Update python-node-exporter.py 2023-03-20 20:20:43 -04:00
justin a6e42d3a73 fixing logging 2023-03-20 20:13:26 -04:00
justin 67ae2e6e09 Update python-node-exporter.py 2023-03-20 19:48:18 -04:00
justin ebf6fd168f Update python-node-exporter.py 2023-03-20 19:42:54 -04:00
justin 7c0ffd1458 Update python-node-exporter.py 2023-03-20 19:40:05 -04:00
justin 78943bf5f6 fixed version dunder 2023-03-20 19:37:41 -04:00
justin 84fa3d207d Added versioning 2023-03-20 19:21:45 -04:00
justin 00e60c31fe Update python-node-exporter.py 2023-03-20 19:14:52 -04:00
justin 674e16b956 Update python-node-exporter.py 2023-03-20 19:00:16 -04:00
justin a23b0cf701 Update python-node-exporter.py 2023-03-20 18:44:53 -04:00
justin 2897ae0fa9 Update python-node-exporter.py 2023-03-08 23:33:19 -05:00