summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2019-02-19 14:07:32 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2019-02-19 14:07:32 (GMT)
commit24b7cd1227ee642da67e791837bee1b4e01f6fa1 (patch)
tree96127ee06debad0e56a25a2ce32772845c15ace3
parent81c0ec3860445a47b02dba20ff21d663a65cdd0b (diff)
downloadmisc-fred-24b7cd1227ee642da67e791837bee1b4e01f6fa1.zip
misc-fred-24b7cd1227ee642da67e791837bee1b4e01f6fa1.tar.gz
misc-fred-24b7cd1227ee642da67e791837bee1b4e01f6fa1.tar.bz2
munin: add authentic count scripts
-rwxr-xr-xmunin/authentic_count_21
-rw-r--r--munin/authentic_count_cmd.py13
2 files changed, 34 insertions, 0 deletions
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