Skip to content

Commit

Permalink
Add debug option, start of mailman queue metric
Browse files Browse the repository at this point in the history
  • Loading branch information
rivimey committed Apr 16, 2022
1 parent dba934f commit c3c1de2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion mailman_exporter.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/env python3
# -*- coding: utf-8 -*-
"""
Prometheus mailman3 exporter using rest api's.
Expand All @@ -15,19 +16,22 @@
app = Flask(__name__)
exporter = None
MM_API_VERS="3.1"
_DEBUG = False

class MailmanExporter:

def __init__(self):
self.REGISTRY = CollectorRegistry(auto_describe=False)
self.mailman3_up = Gauge('mailman3_up', 'Status of mailman-core; 1 if accessible, 0 otherwise', registry=self.REGISTRY)
self.mailman3_queue = GaugeMetricFamily('mailman3_queues', 'Queue length for mailman-core')
self.REGISTRY.register(self.mailman3_queue)
# TODO: needed but this doesn't work.
#self.REGISTRY.register(self.mailman3_queue)


def args(self):
parser = argparse.ArgumentParser(description='Mailman3 Prometheus metrics exporter')
#parser.add_argument('-c', '--config', dest='config', type=str, help='Pass in a configuration file')
parser.add_argument('-d', '--debug', dest='debug', type=bool, help='Enable debug output')
parser.add_argument('-l', '--web.listen', dest='web_listen', type=str, default="localhost:9543", help='HTTPServer listen address')

parser.add_argument('-m', '--mailman.address', dest='mailman_address', type=str, default="http://localhost:8870", help='Mailman3 Core REST API address')
Expand All @@ -36,6 +40,8 @@ def args(self):

args = parser.parse_args()
self.web_listen = args.web_listen
global _DEBUG
_DEBUG = args.debug
self.mailman_address = args.mailman_address
self.mailman_user = args.mailman_user
self.mailman_password = args.mailman_password
Expand Down

0 comments on commit c3c1de2

Please sign in to comment.