-
Notifications
You must be signed in to change notification settings - Fork 2
/
stat_echomail.py
executable file
·48 lines (32 loc) · 1.14 KB
/
stat_echomail.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/local/bin/python3 -bb
import ftnconfig
import ftnimport
db=ftnconfig.connectdb()
try:
msgmark = int(open(ftnconfig.MSGMARKESTAT).read())
except:
print("mark not found")
msgmark = 0
outp = []
total = 0
Q_stat = db.prepare("select d.text, count(m.id) from messages m, addresses d "
"where m.id>$1 and m.processed=0 and m.destination=d.id and d.domain=$2 "
"group by d.text "
"having count(m.id)>0 "
"order by count(m.id) desc ")
Q_msg = db.prepare("select max(id) from messages")
with db.xact(isolation='SERIALIZABLE', mode='READ ONLY'):
newmsgmark = Q_msg.first()
for e, c in Q_stat(msgmark, db.FTN_domains["echo"]):
outp.append ("%-30s %d\n"%(e, c))
total += c
with ftnimport.session(db) as sess:
sess.send_message(("node", ftnconfig.ADDRESS), "Sergey Dorofeev", ("echo", "FLUID.REPORTS"), "All", None, "статистика эхомейла",
"""Привет All
Traffic since last statistics generation:
%s
Total: %d
Last message id: %d
Вот так
"""%("".join(outp), total, newmsgmark))
open(ftnconfig.MSGMARKESTAT, "w").write(str(newmsgmark))