2010-12-23 13:29:31 -05:00
|
|
|
#!/usr/bin/env python
|
|
|
|
from utils.munin.base import MuninGraph
|
2013-04-03 19:04:30 -07:00
|
|
|
import redis
|
2010-12-23 13:29:31 -05:00
|
|
|
|
2012-09-27 10:45:40 -07:00
|
|
|
class NBMuninGraph(MuninGraph):
|
|
|
|
|
|
|
|
@property
|
|
|
|
def graph_config(self):
|
|
|
|
return {
|
|
|
|
'graph_category' : 'NewsBlur',
|
|
|
|
'graph_title' : 'NewsBlur Feed Counts',
|
|
|
|
'graph_vlabel' : 'Feeds Feed Counts',
|
2012-09-28 09:50:12 -07:00
|
|
|
'graph_args' : '-l 0',
|
2013-04-03 19:04:30 -07:00
|
|
|
'scheduled_feeds.label': 'scheduled_feeds',
|
2012-09-27 10:45:40 -07:00
|
|
|
'exception_feeds.label': 'exception_feeds',
|
|
|
|
'exception_pages.label': 'exception_pages',
|
|
|
|
'duplicate_feeds.label': 'duplicate_feeds',
|
|
|
|
'active_feeds.label': 'active_feeds',
|
|
|
|
'push_feeds.label': 'push_feeds',
|
|
|
|
}
|
|
|
|
|
|
|
|
def calculate_metrics(self):
|
|
|
|
from apps.rss_feeds.models import Feed, DuplicateFeed
|
|
|
|
from apps.push.models import PushSubscription
|
2013-04-03 19:04:30 -07:00
|
|
|
from django.conf import settings
|
|
|
|
|
|
|
|
r = redis.Redis(connection_pool=settings.REDIS_FEED_POOL)
|
2011-03-23 15:43:15 -04:00
|
|
|
|
2012-09-27 10:45:40 -07:00
|
|
|
return {
|
2013-04-03 19:04:30 -07:00
|
|
|
'scheduled_feeds': r.zcard('scheduled_updates'),
|
2012-09-27 10:45:40 -07:00
|
|
|
'exception_feeds': Feed.objects.filter(has_feed_exception=True).count(),
|
|
|
|
'exception_pages': Feed.objects.filter(has_page_exception=True).count(),
|
|
|
|
'duplicate_feeds': DuplicateFeed.objects.count(),
|
|
|
|
'active_feeds': Feed.objects.filter(active_subscribers__gt=0).count(),
|
|
|
|
'push_feeds': PushSubscription.objects.filter(verified=True).count(),
|
|
|
|
}
|
2010-12-23 13:29:31 -05:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2012-09-27 10:45:40 -07:00
|
|
|
NBMuninGraph().run()
|