munin: add authentic count scripts

This commit is contained in:
Frédéric Péters 2019-02-19 15:07:32 +01:00
parent 81c0ec3860
commit 24b7cd1227
2 changed files with 34 additions and 0 deletions

21
munin/authentic_count_ Executable file
View File

@ -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)

View File

@ -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