diff --git a/README.md b/README.md index 81f7020..4fadb8a 100644 --- a/README.md +++ b/README.md @@ -4,5 +4,12 @@ This is a custom prometheus exporter to provide the available capacity as a metr ```ShellSession $ uv run ./zuul-capacity.py -usage: zuul-capacity.py [-h] --nodepool FILE +usage: zuul-capacity.py [-h] [--nodepool FILE] [--port PORT] + +options: + -h, --help show this help message and exit + --nodepool FILE The list of providers + --port PORT The prometheus scrap target listening port ``` + +To run this service, you must provide a nodepool configuration and a clouds.yaml. diff --git a/zuul-capacity.py b/zuul-capacity.py index 2f762fb..92ab92e 100644 --- a/zuul-capacity.py +++ b/zuul-capacity.py @@ -1,5 +1,8 @@ # Copyright © 2024 Tristan de Cacqueray # SPDX-License-Identifier: Apache-2.0 +# +# The purpose of this script is to collect resources usage of nodepool provider. +# The metrics are available as a prometheus scrap target. import argparse, openstack, logging, time, yaml from dataclasses import dataclass @@ -59,7 +62,8 @@ def update_providers_metric(metrics, providers): def usage(): parser = argparse.ArgumentParser() - parser.add_argument("--nodepool", metavar="FILE", required=True) + parser.add_argument("--nodepool", metavar="FILE", default="/etc/nodepool/nodepool.yaml", help="The list of providers") + parser.add_argument("--port", type=int, default=8080, help="The prometheus scrap target listening port") return parser.parse_args() def main(): @@ -77,8 +81,8 @@ def main(): update_providers_metric(metrics, providers) # Initialize connection - log.info("Starting exporter at :8080 for %d provider", len(providers)) - start_http_server(8080) + log.info("Starting exporter at :%d for %d provider", args.port, len(providers)) + start_http_server(args.port) while True: time.sleep(300)