2010-09-08 10:33:00 -07:00
|
|
|
#!/usr/bin/env python
|
|
|
|
from utils.munin.base import MuninGraph
|
|
|
|
|
|
|
|
graph_config = {
|
|
|
|
'graph_category' : 'NewsBlur',
|
|
|
|
'graph_title' : 'NewsBlur Updates',
|
|
|
|
'graph_vlabel' : '# of updates',
|
2011-03-24 13:01:56 -04:00
|
|
|
'update_queue.label': 'Queued Feeds last hour',
|
2010-09-08 10:33:00 -07:00
|
|
|
'feeds_fetched.label': 'Fetched feeds last hour',
|
2011-03-24 14:59:18 -04:00
|
|
|
'celery_update_feeds.label': 'Celery - Update Feeds',
|
|
|
|
'celery_new_feeds.label': 'Celery - New Feeds',
|
2010-09-08 10:33:00 -07:00
|
|
|
}
|
|
|
|
|
2010-09-08 10:52:04 -07:00
|
|
|
|
2011-03-23 15:43:15 -04:00
|
|
|
def calculate_metrics():
|
|
|
|
import datetime
|
2011-03-24 13:01:56 -04:00
|
|
|
import commands
|
2011-03-23 15:43:15 -04:00
|
|
|
from apps.rss_feeds.models import Feed
|
|
|
|
|
|
|
|
hour_ago = datetime.datetime.utcnow() - datetime.timedelta(hours=1)
|
2012-02-02 10:53:17 -08:00
|
|
|
update_feeds_query = "ssh -i ~sclay/.ssh/id_dsa sclay@db01 \"sudo rabbitmqctl list_queues -p newsblurvhost | grep %s\" | awk '{print $2}'"
|
2011-03-24 13:01:56 -04:00
|
|
|
|
2011-03-23 15:43:15 -04:00
|
|
|
return {
|
|
|
|
'update_queue': Feed.objects.filter(queued_date__gte=hour_ago).count(),
|
2011-03-24 13:01:56 -04:00
|
|
|
'feeds_fetched': Feed.objects.filter(last_update__gte=hour_ago).count(),
|
|
|
|
'celery_update_feeds': commands.getoutput(update_feeds_query % 'update_feeds'),
|
|
|
|
'celery_new_feeds': commands.getoutput(update_feeds_query % 'new_feeds'),
|
2011-03-23 15:43:15 -04:00
|
|
|
}
|
2010-09-08 10:33:00 -07:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2011-03-23 15:43:15 -04:00
|
|
|
MuninGraph(graph_config, calculate_metrics).run()
|