#!/bin/env python3 import sys import os import inspect sys.path.insert(0, os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) + "/modules/client_python") from prometheus_client import start_http_server import argparse import importlib from pprint import pprint if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument("-m", "--module", help="Module to load", action="append", nargs="+", required=True, type=str) args = parser.parse_args() """ On the other hand, the statement from spam.ham import eggs, sausage as saus results in _temp = __import__('spam.ham', globals(), locals(), ['eggs', 'sausage'], -1) eggs = _temp.eggs saus = _temp.sausage Here, the spam.ham module is returned from __import__(). From this object, the names to import are retrieved and assigned to their respective names. """ mods = list() for m in args.module: mod = importlib.import_module("modules." + m[0]) mods.append(mod) for m in mods: pprint(m) pprint(dir(m)) prom_data = dict() for m in mods: m.init_datapoints(prom_data) m.update_datapoints(prom_data) start_http_server(8000) while True: try: time.sleep(15) except Exception: pass for m in mods: m.init_datapoints(prom_data) m.update_datapoints(prom_data)