diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index 9e42c007f..eab9189c9 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -17,9 +17,7 @@ graph LR; nginx-internal --- autoconfig.xml; certs-nginx[("`TLS certs /var/lib/acme`")] --> nginx-internal; - cron --- chatmail-metrics; cron --- acmetool; - chatmail-metrics --- website; acmetool --> certs[("`TLS certs /var/lib/acme`")]; nginx-external --- |993|dovecot; diff --git a/README.md b/README.md index 28cf92eea..8df2e1166 100644 --- a/README.md +++ b/README.md @@ -224,9 +224,6 @@ A short overview of `chatmaild` services: is a small bot for test purposes. It simply echoes back messages from users. -- [`chatmail-metrics`](https://github.com/chatmail/relay/blob/main/chatmaild/src/chatmaild/metrics.py) - collects some metrics and displays them at `https://example.org/metrics`. - ### Home page and getting started for users `cmdeploy run` also creates default static web pages and deploys them diff --git a/chatmaild/pyproject.toml b/chatmaild/pyproject.toml index e464581e0..81ca46165 100644 --- a/chatmaild/pyproject.toml +++ b/chatmaild/pyproject.toml @@ -26,7 +26,6 @@ doveauth = "chatmaild.doveauth:main" chatmail-metadata = "chatmaild.metadata:main" filtermail = "chatmaild.filtermail:main" echobot = "chatmaild.echo:main" -chatmail-metrics = "chatmaild.metrics:main" chatmail-expire = "chatmaild.expire:main" chatmail-fsreport = "chatmaild.fsreport:main" lastlogin = "chatmaild.lastlogin:main" diff --git a/chatmaild/src/chatmaild/metrics.py b/chatmaild/src/chatmaild/metrics.py deleted file mode 100644 index 646b48f79..000000000 --- a/chatmaild/src/chatmaild/metrics.py +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env python3 -import sys -from pathlib import Path - - -def main(vmail_dir=None): - if vmail_dir is None: - vmail_dir = sys.argv[1] - - accounts = 0 - ci_accounts = 0 - - for path in Path(vmail_dir).iterdir(): - if not path.joinpath("cur").is_dir(): - continue - accounts += 1 - if path.name[:3] in ("ci-", "ac_"): - ci_accounts += 1 - - print("# HELP total number of accounts") - print("# TYPE accounts gauge") - print(f"accounts {accounts}") - print("# HELP number of CI accounts") - print("# TYPE ci_accounts gauge") - print(f"ci_accounts {ci_accounts}") - print("# HELP number of non-CI accounts") - print("# TYPE nonci_accounts gauge") - print(f"nonci_accounts {accounts - ci_accounts}") - - -if __name__ == "__main__": - main() diff --git a/chatmaild/src/chatmaild/tests/test_metrics.py b/chatmaild/src/chatmaild/tests/test_metrics.py deleted file mode 100644 index 0a8e5cb3b..000000000 --- a/chatmaild/src/chatmaild/tests/test_metrics.py +++ /dev/null @@ -1,24 +0,0 @@ -from chatmaild.metrics import main - - -def test_main(tmp_path, capsys): - paths = [] - for x in ("ci-asllkj", "ac_12l3kj", "qweqwe", "ci-l1k2j31l2k3"): - p = tmp_path.joinpath(x) - p.mkdir() - p.joinpath("cur").mkdir() - paths.append(p) - - tmp_path.joinpath("nomailbox").mkdir() - - main(tmp_path) - out, _ = capsys.readouterr() - d = {} - for line in out.split("\n"): - if line.strip() and not line.startswith("#"): - name, num = line.split() - d[name] = int(num) - - assert d["accounts"] == 4 - assert d["ci_accounts"] == 3 - assert d["nonci_accounts"] == 1 diff --git a/cmdeploy/src/cmdeploy/__init__.py b/cmdeploy/src/cmdeploy/__init__.py index 6815e3561..b3173c7d9 100644 --- a/cmdeploy/src/cmdeploy/__init__.py +++ b/cmdeploy/src/cmdeploy/__init__.py @@ -108,16 +108,13 @@ def _install_remote_venv_with_chatmaild(config) -> None: ], ) - files.template( - src=importlib.resources.files(__package__).joinpath("metrics.cron.j2"), - dest="/etc/cron.d/chatmail-metrics", - user="root", - group="root", - mode="644", - config={ - "mailboxes_dir": config.mailboxes_dir, - "execpath": f"{remote_venv_dir}/bin/chatmail-metrics", - }, + files.file( + path="/etc/cron.d/chatmail-metrics", + present=False, + ) + files.file( + path="/var/www/html/metrics", + present=False, ) # install systemd units diff --git a/cmdeploy/src/cmdeploy/metrics.cron.j2 b/cmdeploy/src/cmdeploy/metrics.cron.j2 deleted file mode 100644 index 8bf036ad8..000000000 --- a/cmdeploy/src/cmdeploy/metrics.cron.j2 +++ /dev/null @@ -1 +0,0 @@ -*/5 * * * * root {{ config.execpath }} {{ config.mailboxes_dir }} >/var/www/html/metrics diff --git a/cmdeploy/src/cmdeploy/nginx/nginx.conf.j2 b/cmdeploy/src/cmdeploy/nginx/nginx.conf.j2 index 58864d72e..440706bea 100644 --- a/cmdeploy/src/cmdeploy/nginx/nginx.conf.j2 +++ b/cmdeploy/src/cmdeploy/nginx/nginx.conf.j2 @@ -76,10 +76,6 @@ http { try_files $uri $uri/ =404; } - location /metrics { - default_type text/plain; - } - location /new { if ($request_method = GET) { # Redirect to Delta Chat,