eo_mailbox: skip mailboxes that didn't change for a long time (#50374)

This commit is contained in:
Frédéric Péters 2021-01-20 21:13:08 +01:00
parent a780b2b6d0
commit ed3eae6c2c
1 changed files with 9 additions and 4 deletions

View File

@ -132,11 +132,16 @@ def mailboxes(ctn):
# mailboxes there.
return
boxes = glob.glob("/var/spool/mail/*")
days_ago = time.time() - 30 * 86400
for m in boxes:
if os.path.isfile(m):
n = m.split("/")[-1]
c = len(mailbox.mbox(m))
eo_mailboxes.labels(ctn, n).set(c)
if not os.path.isfile(m):
continue
if not os.stat(m).st_mtime > days_ago:
# skip mailboxes that didn't change for a long time
continue
n = m.split("/")[-1]
c = len(mailbox.mbox(m))
eo_mailboxes.labels(ctn, n).set(c)
def postgresql(ctn):