-
-
Save floatingatoll/2ebc6d9f0adddc70eb534ce4a8ad05a9 to your computer and use it in GitHub Desktop.
Calculates nntp stats
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import nntplib | |
import re | |
import sys | |
usage = """./nntp-stats [nntp-group-name]""" | |
if len(sys.argv) < 2: | |
print usage | |
sys.exit(1) | |
newsgroup = sys.argv[1] | |
s = nntplib.NNTP('news.mozilla.org') | |
(resp, count, first, last, name) = s.group(newsgroup) | |
resp, items = s.xover(first, last) | |
count = 0 | |
posting_from_mozilla = 0 | |
posting_from_googlegroups = 0 | |
posting_from_other = 0 | |
article_date = [] | |
for id, subject, author, date, message_id, references, size, lines in items: | |
# Count number of total messages | |
count += 1 | |
# This is a terrible way of getting this data | |
article_date.append(date) | |
# if message id has the word googlegroups.com | |
# we assume its from groups.google.com | |
# otherwise if it has the word lists.mozilla.org and mailman then its from mailman | |
# everything else we assume its from nntp | |
if re.findall(r'googlegroups.com', message_id): | |
posting_from_googlegroups += 1 | |
elif re.findall(r'lists.mozilla.org', message_id) and re.findall(r'mailman', message_id): | |
posting_from_mozilla +=1 | |
else: | |
posting_from_other += 1 | |
percent_mozilla = (float(posting_from_mozilla)*100/float(count)) | |
percent_googlegroups = (float(posting_from_googlegroups)*100/float(count)) | |
percent_other = (float(posting_from_other)*100/float(count)) | |
print "Total number of articles: %s" % count | |
print "Message from mailman: %s (%d%%)" % (posting_from_mozilla, int(percent_mozilla)) | |
print "Message from google groups %s (%d%%)" % (posting_from_googlegroups, int(percent_googlegroups)) | |
print "Message from other: %s (%d%%)" % (posting_from_other, int(percent_other)) | |
print "First message date: %s" % (article_date[0]) | |
print "Last message date: %s" % (article_date[-1]) | |
s.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment