From 24b7cd1227ee642da67e791837bee1b4e01f6fa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Tue, 19 Feb 2019 15:07:32 +0100 Subject: [PATCH] munin: add authentic count scripts --- munin/authentic_count_ | 21 +++++++++++++++++++++ munin/authentic_count_cmd.py | 13 +++++++++++++ 2 files changed, 34 insertions(+) create mode 100755 munin/authentic_count_ create mode 100644 munin/authentic_count_cmd.py diff --git a/munin/authentic_count_ b/munin/authentic_count_ new file mode 100755 index 0000000..dbf94c8 --- /dev/null +++ b/munin/authentic_count_ @@ -0,0 +1,21 @@ +#! /usr/bin/env python + +import os +import sys + +tenant = os.path.basename(sys.argv[0]).replace('authentic_count_', '') + +if len(sys.argv) == 2 and sys.argv[1] == 'autoconf': + print 'yes' + sys.exit(0) + +if len(sys.argv) == 2 and sys.argv[1] == 'config': + print '''graph_title Count of users for %s +graph_category entrouvert +total_count.label Total +total_logged_count.label Total once logged +fc_count.label Total FC +''' % tenant + sys.exit(0) + +os.system('machinectl shell authentic.node1.prod.saas.entrouvert.org /usr/bin/authentic2-multitenant-manage tenant_command runscript /home/fred//misc-fred/munin/authentic_count_cmd.py compute -d %s' % tenant) diff --git a/munin/authentic_count_cmd.py b/munin/authentic_count_cmd.py new file mode 100644 index 0000000..b36acac --- /dev/null +++ b/munin/authentic_count_cmd.py @@ -0,0 +1,13 @@ +from django.db import connection +from django.contrib.auth import get_user_model +from authentic2_auth_fc.models import FcAccount + +User = get_user_model() + +total_user_count = User.objects.filter(userexternalid__isnull=True, ).count() +total_logged_count = User.objects.filter(userexternalid__isnull=True, last_login__isnull=False).count() +fc_count = FcAccount.objects.all().count() + +print 'total_count.value', total_user_count +print 'total_logged_count.value', total_logged_count +print 'fc_count.value', fc_count