NewsBlur-viq/utils/munin/newsblur_feeds.py

44 lines
1.6 KiB
Python
Raw Normal View History

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
class NBMuninGraph(MuninGraph):
2010-06-08 11:19:41 -04:00
@property
def graph_config(self):
return {
'graph_category' : 'NewsBlur',
'graph_title' : 'NewsBlur Feeds & Subscriptions',
'graph_vlabel' : 'Feeds & Subscribers',
'graph_args' : '-l 0',
'feeds.label': 'feeds',
'subscriptions.label': 'subscriptions',
'profiles.label': 'profiles',
'social_subscriptions.label': 'social_subscriptions',
}
def calculate_metrics(self):
from apps.rss_feeds.models import Feed
from apps.reader.models import UserSubscription
from apps.social.models import MSocialProfile, MSocialSubscription
from apps.statistics.models import MStatistics
feeds_count = MStatistics.get('munin:feeds_count')
if not feeds_count:
feeds_count = Feed.objects.all().count()
MStatistics.set('munin:feeds_count', feeds_count, 60*60*12)
subscriptions_count = MStatistics.get('munin:subscriptions_count')
if not subscriptions_count:
subscriptions_count = UserSubscription.objects.all().count()
MStatistics.set('munin:subscriptions_count', subscriptions_count, 60*60*12)
return {
'feeds': feeds_count,
'subscriptions': subscriptions_count,
'profiles': MSocialProfile.objects.count(),
'social_subscriptions': MSocialSubscription.objects.count(),
}
2010-06-08 11:19:41 -04:00
if __name__ == '__main__':
NBMuninGraph().run()