"""network-diag-app exporter"""

import os
import time
from prometheus_client import start_http_server, Gauge, REGISTRY, PROCESS_COLLECTOR, PLATFORM_COLLECTOR
import requests
import json

REGISTRY.unregister(PROCESS_COLLECTOR)
REGISTRY.unregister(PLATFORM_COLLECTOR)
# Unlike process and platform_collector gc_collector registers itself as three different collectors that have no corresponding public named variable. 
REGISTRY.unregister(REGISTRY._names_to_collectors['python_gc_objects_collected_total'])
#REGISTRY.unregister(REGISTRY._names_to_collectors['python_gc_uncollectable_objects_sum'])
#REGISTRY.unregister(REGISTRY._names_to_collectors['python_gc_collected_objects_sum'])

class Metrics:
    def __init__(self, app_port=3333, polling_interval_seconds=5):
        self.app_port = app_port
        self.polling_interval_seconds = polling_interval_seconds

        self.num_configured_devices = Gauge("num_configured_devices", "Number of configured devices")
        self.num_reachable_devices = Gauge("num_reachable_devices", "Number of reachable devices")

    def run_metrics_loop(self):
        while True:
            self.fetch()
            time.sleep(self.polling_interval_seconds)

    def fetch(self):
        resp = requests.get(url=f"http://localhost:{self.app_port}/devices")
        self.num_configured_devices.set(len(json.loads(resp.text)))

        resp = requests.get(url=f"http://localhost:{self.app_port}/devices/reachable")
        self.num_reachable_devices.set(len(json.loads(resp.text)))

def main():
    polling_interval_seconds = int(os.getenv("POLLING_INTERVAL_SECONDS", "5"))
    app_port = int(os.getenv("APP_PORT", "3333"))
    exporter_port = int(os.getenv("EXPORTER_PORT", "4444"))

    app_metrics = Metrics(
        app_port=app_port,
        polling_interval_seconds=polling_interval_seconds
    )
    start_http_server(exporter_port)
    app_metrics.run_metrics_loop()

if __name__ == "__main__":
    main()
