2020-12-03 14:05:32 -05:00
|
|
|
#!/srv/newsblur/venv/newsblur3/bin/python
|
2020-12-10 12:40:12 -05:00
|
|
|
import os
|
2024-04-24 09:43:56 -04:00
|
|
|
|
2024-04-24 09:50:42 -04:00
|
|
|
from utils.munin.base import MuninGraph
|
|
|
|
|
2021-01-12 15:52:10 -05:00
|
|
|
os.environ["DJANGO_SETTINGS_MODULE"] = "newsblur_web.settings"
|
2020-12-10 12:42:12 -05:00
|
|
|
import django
|
2024-04-24 09:43:56 -04:00
|
|
|
|
2020-12-10 12:42:12 -05:00
|
|
|
django.setup()
|
2010-06-08 11:19:41 -04:00
|
|
|
|
|
|
|
|
2024-04-24 09:43:56 -04:00
|
|
|
class NBMuninGraph(MuninGraph):
|
2012-09-27 10:45:40 -07:00
|
|
|
@property
|
|
|
|
def graph_config(self):
|
|
|
|
return {
|
2024-04-24 09:43:56 -04:00
|
|
|
"graph_category": "NewsBlur",
|
|
|
|
"graph_title": "NewsBlur Feeds & Subscriptions",
|
|
|
|
"graph_vlabel": "Feeds & Subscribers",
|
|
|
|
"graph_args": "-l 0",
|
|
|
|
"feeds.label": "feeds",
|
|
|
|
"subscriptions.label": "subscriptions",
|
|
|
|
"profiles.label": "profiles",
|
|
|
|
"social_subscriptions.label": "social_subscriptions",
|
2012-09-27 10:45:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
def calculate_metrics(self):
|
|
|
|
from apps.reader.models import UserSubscription
|
2024-04-24 09:50:42 -04:00
|
|
|
from apps.rss_feeds.models import Feed
|
2012-09-27 10:45:40 -07:00
|
|
|
from apps.social.models import MSocialProfile, MSocialSubscription
|
2015-07-21 15:29:21 -07:00
|
|
|
from apps.statistics.models import MStatistics
|
|
|
|
|
2024-04-24 09:43:56 -04:00
|
|
|
feeds_count = MStatistics.get("munin:feeds_count")
|
2015-07-21 15:29:21 -07:00
|
|
|
if not feeds_count:
|
|
|
|
feeds_count = Feed.objects.all().count()
|
2024-04-24 09:43:56 -04:00
|
|
|
MStatistics.set("munin:feeds_count", feeds_count, 60 * 60 * 12)
|
2015-07-21 15:29:21 -07:00
|
|
|
|
2024-04-24 09:43:56 -04:00
|
|
|
subscriptions_count = MStatistics.get("munin:subscriptions_count")
|
2015-07-21 15:29:21 -07:00
|
|
|
if not subscriptions_count:
|
|
|
|
subscriptions_count = UserSubscription.objects.all().count()
|
2024-04-24 09:43:56 -04:00
|
|
|
MStatistics.set("munin:subscriptions_count", subscriptions_count, 60 * 60 * 12)
|
2015-07-21 15:29:21 -07:00
|
|
|
|
2012-09-27 10:45:40 -07:00
|
|
|
return {
|
2024-04-24 09:43:56 -04:00
|
|
|
"feeds": feeds_count,
|
|
|
|
"subscriptions": subscriptions_count,
|
|
|
|
"profiles": MSocialProfile.objects.count(),
|
|
|
|
"social_subscriptions": MSocialSubscription.objects.count(),
|
2012-09-27 10:45:40 -07:00
|
|
|
}
|
2010-06-08 11:19:41 -04:00
|
|
|
|
2024-04-24 09:43:56 -04:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2012-09-27 10:45:40 -07:00
|
|
|
NBMuninGraph().run()
|