mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-08-05 16:58:59 +00:00

* dashboard: Marking bookmarklet js and css as safe. Adding django settings for munin. Adding django settings for munin. Adding django settings for munin. Adding django settings for munin.
71 lines
2.1 KiB
Python
Executable file
71 lines
2.1 KiB
Python
Executable file
#!/srv/newsblur/venv/newsblur3/bin/python
|
|
from utils.munin.base import MuninGraph
|
|
import datetime
|
|
import os
|
|
os.environ["DJANGO_SETTINGS_MODULE"] = "newsblur.settings"
|
|
from django.conf import settings
|
|
|
|
|
|
class NBMuninGraph(MuninGraph):
|
|
|
|
@property
|
|
def graph_config(self):
|
|
graph = {
|
|
'graph_category' : 'NewsBlur',
|
|
'graph_title' : 'NewsBlur App Server Page Loads',
|
|
'graph_vlabel' : '# of page loads / server',
|
|
'graph_args' : '-l 0',
|
|
'total.label' : 'total',
|
|
'total.draw' : 'LINE1',
|
|
}
|
|
stats = self.stats
|
|
graph.update(dict((("%s.label" % s['_id'].replace('-', ''), s['_id']) for s in stats)))
|
|
graph.update(dict((("%s.draw" % s['_id'].replace('-', ''), "AREASTACK") for s in stats)))
|
|
graph['graph_order'] = ' '.join(sorted(s['_id'].replace('-', '') for s in stats))
|
|
return graph
|
|
|
|
def calculate_metrics(self):
|
|
servers = dict((("%s" % s['_id'].replace('-', ''), s['feeds']) for s in self.stats))
|
|
servers['total'] = self.total[0]['feeds']
|
|
return servers
|
|
|
|
@property
|
|
def stats(self):
|
|
stats = settings.MONGOANALYTICSDB.nbanalytics.page_loads.aggregate([{
|
|
"$match": {
|
|
"date": {
|
|
"$gte": datetime.datetime.now() - datetime.timedelta(minutes=5),
|
|
},
|
|
},
|
|
}, {
|
|
"$group": {
|
|
"_id" : "$server",
|
|
"feeds" : {"$sum": 1},
|
|
},
|
|
}])
|
|
|
|
return list(stats)
|
|
|
|
@property
|
|
def total(self):
|
|
import datetime
|
|
from django.conf import settings
|
|
|
|
stats = settings.MONGOANALYTICSDB.nbanalytics.page_loads.aggregate([{
|
|
"$match": {
|
|
"date": {
|
|
"$gt": datetime.datetime.now() - datetime.timedelta(minutes=5),
|
|
},
|
|
},
|
|
}, {
|
|
"$group": {
|
|
"_id" : 1,
|
|
"feeds" : {"$sum": 1},
|
|
},
|
|
}])
|
|
|
|
return list(stats)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
NBMuninGraph().run()
|