From 381d721c4b66b93146178423592d90d80f1c3c8b Mon Sep 17 00:00:00 2001 From: Remi Verchere Date: Tue, 30 Jan 2018 23:10:43 +0100 Subject: [PATCH] Refs #23. handle /healthz endpoint --- vmware_exporter/__init__.py | 2 +- vmware_exporter/vmware_exporter.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/vmware_exporter/__init__.py b/vmware_exporter/__init__.py index 505a9c9..f790f2a 100644 --- a/vmware_exporter/__init__.py +++ b/vmware_exporter/__init__.py @@ -1,3 +1,3 @@ -__version__ = "0.1.0" +__version__ = "0.1.1" __author__ = "Remi Verchere" __license__ = "BSD 3-Clause License" diff --git a/vmware_exporter/vmware_exporter.py b/vmware_exporter/vmware_exporter.py index ba378b8..0b044e0 100755 --- a/vmware_exporter/vmware_exporter.py +++ b/vmware_exporter/vmware_exporter.py @@ -31,7 +31,7 @@ class VMWareMetricsResource(Resource): """ VMWare twisted ``Resource`` handling multi endpoints - Only handle /metrics path + Only handle /metrics and /healthz path """ isLeaf = True @@ -56,6 +56,9 @@ def render_GET(self, request): d.addCallback(self.generate_latest_target) d.addErrback(self.errback, request) return NOT_DONE_YET + elif path == '/healthz': + request.setResponseCode(200) + return 'Server is UP'.encode() else: request.setResponseCode(404) return '404 Not Found'.encode() @@ -430,6 +433,7 @@ def main(): # Start up the server to expose the metrics. root = Resource() root.putChild(b'metrics', VMWareMetricsResource(args)) + root.putChild(b'healthz', VMWareMetricsResource(args)) factory = Site(root) print("Starting web server on port {}".format(args.port))