2016-11-20 11:05:14 -08:00
|
|
|
#!/srv/newsblur/venv/newsblur/bin/python
|
2010-06-08 11:19:41 -04:00
|
|
|
from utils.munin.base import MuninGraph
|
|
|
|
|
|
|
|
|
2012-09-27 10:45:40 -07:00
|
|
|
class NBMuninGraph(MuninGraph):
|
2010-07-24 14:16:25 -04:00
|
|
|
|
2012-09-27 10:45:40 -07:00
|
|
|
@property
|
|
|
|
def graph_config(self):
|
|
|
|
return {
|
|
|
|
'graph_category' : 'NewsBlur',
|
|
|
|
'graph_title' : 'NewsBlur Users',
|
|
|
|
'graph_vlabel' : 'users',
|
2012-09-28 09:50:12 -07:00
|
|
|
'graph_args' : '-l 0',
|
2012-09-27 10:45:40 -07:00
|
|
|
'all.label': 'all',
|
|
|
|
'monthly.label': 'monthly',
|
|
|
|
'daily.label': 'daily',
|
|
|
|
'premium.label': 'premium',
|
2013-05-21 14:15:25 -07:00
|
|
|
'queued.label': 'queued',
|
2012-09-27 10:45:40 -07:00
|
|
|
}
|
2011-03-23 15:43:15 -04:00
|
|
|
|
2012-09-27 10:45:40 -07:00
|
|
|
def calculate_metrics(self):
|
|
|
|
import datetime
|
|
|
|
from django.contrib.auth.models import User
|
2013-05-21 14:15:25 -07:00
|
|
|
from apps.profile.models import Profile, RNewUserQueue
|
2012-09-27 10:45:40 -07:00
|
|
|
|
|
|
|
last_month = datetime.datetime.utcnow() - datetime.timedelta(days=30)
|
|
|
|
last_day = datetime.datetime.utcnow() - datetime.timedelta(minutes=60*24)
|
|
|
|
|
|
|
|
return {
|
|
|
|
'all': User.objects.count(),
|
|
|
|
'monthly': Profile.objects.filter(last_seen_on__gte=last_month).count(),
|
|
|
|
'daily': Profile.objects.filter(last_seen_on__gte=last_day).count(),
|
|
|
|
'premium': Profile.objects.filter(is_premium=True).count(),
|
2013-05-21 14:15:25 -07:00
|
|
|
'queued': RNewUserQueue.user_count(),
|
2012-09-27 10:45:40 -07:00
|
|
|
}
|
2010-06-08 11:19:41 -04:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2012-09-27 10:45:40 -07:00
|
|
|
NBMuninGraph().run()
|