mirror of
https://github.com/chatmail/relay.git
synced 2026-05-10 16:04:37 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4385b84139 |
@@ -22,6 +22,7 @@ where = ['src']
|
|||||||
doveauth = "chatmaild.doveauth:main"
|
doveauth = "chatmaild.doveauth:main"
|
||||||
filtermail = "chatmaild.filtermail:main"
|
filtermail = "chatmaild.filtermail:main"
|
||||||
echobot = "chatmaild.echo:main"
|
echobot = "chatmaild.echo:main"
|
||||||
|
chatmail-metrics = "chatmaild.metrics:main"
|
||||||
|
|
||||||
[project.entry-points.pytest11]
|
[project.entry-points.pytest11]
|
||||||
"chatmaild.testplugin" = "chatmaild.tests.plugin"
|
"chatmaild.testplugin" = "chatmaild.tests.plugin"
|
||||||
|
|||||||
23
chatmaild/src/chatmaild/metrics.py
Normal file
23
chatmaild/src/chatmaild/metrics.py
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
from pathlib import Path
|
||||||
|
import time
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
vmail_dir = sys.argv[1]
|
||||||
|
accounts = 0
|
||||||
|
ci_accounts = 0
|
||||||
|
|
||||||
|
for path in Path(vmail_dir).iterdir():
|
||||||
|
accounts += 1
|
||||||
|
if path.name.startswith("ci-"):
|
||||||
|
ci_accounts += 1
|
||||||
|
|
||||||
|
timestamp = int(time.time() * 1000)
|
||||||
|
print(f"accounts {accounts} {timestamp}")
|
||||||
|
print(f"ci_accounts {ci_accounts} {timestamp}")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -84,6 +84,18 @@ 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={
|
||||||
|
"mail_domain": config.mail_domain,
|
||||||
|
"execpath": f"{remote_venv_dir}/bin/chatmail-metrics",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
# install systemd units
|
# install systemd units
|
||||||
for fn in (
|
for fn in (
|
||||||
"doveauth",
|
"doveauth",
|
||||||
|
|||||||
1
cmdeploy/src/cmdeploy/metrics.cron.j2
Normal file
1
cmdeploy/src/cmdeploy/metrics.cron.j2
Normal file
@@ -0,0 +1 @@
|
|||||||
|
*/5 * * * * root {{ config.execpath }} /home/vmail/mail/{{ config.mail_domain }} >/var/www/html/metrics
|
||||||
@@ -41,6 +41,10 @@ http {
|
|||||||
try_files $uri $uri/ =404;
|
try_files $uri $uri/ =404;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
location /metrics {
|
||||||
|
default_type text/plain;
|
||||||
|
}
|
||||||
|
|
||||||
# add cgi-bin support
|
# add cgi-bin support
|
||||||
include /usr/share/doc/fcgiwrap/examples/nginx.conf;
|
include /usr/share/doc/fcgiwrap/examples/nginx.conf;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user