mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
Adding munin stats for feeds, subscriptions, classifiers, and user.
This commit is contained in:
parent
3ee93b6f1f
commit
be5b272e59
5 changed files with 86 additions and 0 deletions
0
utils/munin/__init__.py
Normal file
0
utils/munin/__init__.py
Normal file
23
utils/munin/base.py
Normal file
23
utils/munin/base.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
import sys
|
||||
|
||||
class MuninGraph(object):
|
||||
def __init__(self, graph_config, metrics):
|
||||
self.graph_config = graph_config
|
||||
self.metrics = metrics
|
||||
|
||||
def run(self):
|
||||
cmd_name = None
|
||||
if len(sys.argv) > 1:
|
||||
cmd_name = sys.argv[1]
|
||||
if cmd_name == 'config':
|
||||
self.print_config()
|
||||
else:
|
||||
self.print_metrics()
|
||||
|
||||
def print_config(self):
|
||||
for key,value in self.graph_config.items():
|
||||
print '%s %s' % (key, value)
|
||||
|
||||
def print_metrics(self):
|
||||
for key, value in self.metrics.items():
|
||||
print '%s.value %s' % (key, value)
|
24
utils/munin/protopub_classifiers.py
Normal file
24
utils/munin/protopub_classifiers.py
Normal file
|
@ -0,0 +1,24 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
from utils.munin.base import MuninGraph
|
||||
from apps.analyzer.models import ClassifierFeed, ClassifierAuthor, ClassifierTag, ClassifierTitle
|
||||
|
||||
graph_config = {
|
||||
'graph_category' : 'Protopub',
|
||||
'graph_title' : 'Protopub Classifiers',
|
||||
'graph_vlabel' : 'users',
|
||||
'feeds.label': 'feeds',
|
||||
'authors.label': 'authors',
|
||||
'tags.label': 'tags',
|
||||
'titles.label': 'titles',
|
||||
}
|
||||
|
||||
metrics = {
|
||||
'feeds': ClassifierFeed.objects.count(),
|
||||
'authors': ClassifierAuthor.objects.count(),
|
||||
'tags': ClassifierTag.objects.count(),
|
||||
'titles': ClassifierTitle.objects.count(),
|
||||
}
|
||||
|
||||
if __name__ == '__main__':
|
||||
MuninGraph(graph_config, metrics).run()
|
21
utils/munin/protopub_feeds.py
Executable file
21
utils/munin/protopub_feeds.py
Executable file
|
@ -0,0 +1,21 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
from utils.munin.base import MuninGraph
|
||||
from rss_feeds.models import Feed
|
||||
from reader.models import UserSubscriptions
|
||||
|
||||
graph_config = {
|
||||
'graph_category' : 'Protopub',
|
||||
'graph_title' : 'Protopub Feeds',
|
||||
'graph_vlabel' : 'users',
|
||||
'feeds.label': 'feeds',
|
||||
'subscriptions.label': 'subscriptions',
|
||||
}
|
||||
|
||||
metrics = {
|
||||
'feeds': Feed.objects.count(),
|
||||
'subscriptions': UserSubscriptions.objects.count(),
|
||||
}
|
||||
|
||||
if __name__ == '__main__':
|
||||
MuninGraph(graph_config, metrics).run()
|
18
utils/munin/protopub_users.py
Executable file
18
utils/munin/protopub_users.py
Executable file
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
from utils.munin.base import MuninGraph
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
graph_config = {
|
||||
'graph_category' : 'Protopub',
|
||||
'graph_title' : 'Protopub Users',
|
||||
'graph_vlabel' : 'users',
|
||||
'all.label': 'all',
|
||||
}
|
||||
|
||||
metrics = {
|
||||
'all': User.objects.count(),
|
||||
}
|
||||
|
||||
if __name__ == '__main__':
|
||||
MuninGraph(graph_config, metrics).run()
|
Loading…
Add table
Reference in a new issue