Skip to content
This repository has been archived by the owner on Jul 23, 2018. It is now read-only.

Commit

Permalink
Refs #23. handle /healthz endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
rverchere committed Jan 30, 2018
1 parent f74df17 commit 381d721
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion vmware_exporter/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__version__ = "0.1.0"
__version__ = "0.1.1"
__author__ = "Remi Verchere"
__license__ = "BSD 3-Clause License"
6 changes: 5 additions & 1 deletion vmware_exporter/vmware_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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()
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 381d721

Please sign in to comment.