2020-12-03 14:05:32 -05:00
|
|
|
#!/srv/newsblur/venv/newsblur3/bin/python
|
2012-02-26 23:29:57 -08:00
|
|
|
import redis
|
2010-09-08 10:33:00 -07:00
|
|
|
from utils.munin.base import MuninGraph
|
2020-12-10 12:40:12 -05:00
|
|
|
import os
|
2021-01-19 09:40:13 -05:00
|
|
|
os.environ["DJANGO_SETTINGS_MODULE"] = "newsblur_web.settings"
|
2020-12-10 12:42:12 -05:00
|
|
|
import django
|
|
|
|
django.setup()
|
2010-09-08 10:33:00 -07:00
|
|
|
|
2012-09-27 10:45:40 -07:00
|
|
|
class NBMuninGraph(MuninGraph):
|
2010-09-08 10:33:00 -07:00
|
|
|
|
2012-09-27 10:45:40 -07:00
|
|
|
@property
|
|
|
|
def graph_config(self):
|
|
|
|
return {
|
|
|
|
'graph_category' : 'NewsBlur',
|
|
|
|
'graph_title' : 'NewsBlur Updates',
|
|
|
|
'graph_vlabel' : '# of updates',
|
2012-09-28 09:50:12 -07:00
|
|
|
'graph_args' : '-l 0',
|
2013-03-30 19:05:13 -07:00
|
|
|
'update_queue.label': 'Queued Feeds',
|
2012-09-27 10:45:40 -07:00
|
|
|
'feeds_fetched.label': 'Fetched feeds last hour',
|
2013-04-03 19:04:30 -07:00
|
|
|
'tasked_feeds.label': 'Tasked Feeds',
|
2013-04-08 10:53:11 -07:00
|
|
|
'error_feeds.label': 'Error Feeds',
|
2012-09-27 10:45:40 -07:00
|
|
|
'celery_update_feeds.label': 'Celery - Update Feeds',
|
|
|
|
'celery_new_feeds.label': 'Celery - New Feeds',
|
|
|
|
'celery_push_feeds.label': 'Celery - Push Feeds',
|
|
|
|
'celery_work_queue.label': 'Celery - Work Queue',
|
2014-04-24 09:57:48 -07:00
|
|
|
'celery_search_queue.label': 'Celery - Search Queue',
|
2012-09-27 10:45:40 -07:00
|
|
|
}
|
2010-09-08 10:52:04 -07:00
|
|
|
|
2012-09-27 10:45:40 -07:00
|
|
|
|
|
|
|
def calculate_metrics(self):
|
|
|
|
from django.conf import settings
|
2011-03-23 15:43:15 -04:00
|
|
|
|
2015-07-27 18:35:25 -07:00
|
|
|
r = redis.Redis(connection_pool=settings.REDIS_FEED_UPDATE_POOL)
|
2012-02-26 23:29:57 -08:00
|
|
|
|
2012-09-27 10:45:40 -07:00
|
|
|
return {
|
2013-04-03 16:16:15 -07:00
|
|
|
'update_queue': r.scard("queued_feeds"),
|
|
|
|
'feeds_fetched': r.zcard("fetched_feeds_last_hour"),
|
2013-04-03 19:04:30 -07:00
|
|
|
'tasked_feeds': r.zcard("tasked_feeds"),
|
2013-04-08 10:53:11 -07:00
|
|
|
'error_feeds': r.zcard("error_feeds"),
|
2012-09-27 10:45:40 -07:00
|
|
|
'celery_update_feeds': r.llen("update_feeds"),
|
|
|
|
'celery_new_feeds': r.llen("new_feeds"),
|
|
|
|
'celery_push_feeds': r.llen("push_feeds"),
|
|
|
|
'celery_work_queue': r.llen("work_queue"),
|
2014-04-24 09:57:48 -07:00
|
|
|
'celery_search_queue': r.llen("search_indexer") + r.llen("search_indexer_tasker"),
|
2012-09-27 10:45:40 -07:00
|
|
|
}
|
2010-09-08 10:33:00 -07:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2012-09-27 10:45:40 -07:00
|
|
|
NBMuninGraph().run()
|