Commit 8a72a587 authored by Gabriel Detraz's avatar Gabriel Detraz

Repare les stats adherents + passage à lc_ldap

parent c5af2838
......@@ -830,4 +830,4 @@ dhcp_servers = ['', '']
bats_virtuels = ['v']
# Liste des batiments
liste_bats = ['a', 'b', 'c', 'h', 'i', 'j', 'm', 'g', 'p', 'k', 'r']
liste_bats = ['a', 'b', 'c', 'h', 'i', 'j', 'm', 'o', 'g', 'p', 'k', 'r']
#!/usr/bin/env python
#!/bin/bash /usr/scripts/
# -*- coding: utf-8 -*-
fichier = '/var/lib/munin/tmp/batiments'
import sys,os
import sys,os, time
from gestion import config
try :
arg = sys.argv[1]
......@@ -15,54 +16,33 @@ if arg == "config" :
print 'graph_title Adherents par batiment'
print "graph_args --base 1000 --lower-limit 0"
print "graph_vlabel nb d'adhérents"
print 'bata.label Bâtiment A'
print 'bata.draw AREA'
print 'batb.label Bâtiment B'
print 'batb.draw STACK'
print 'batc.label Bâtiment C'
print 'batc.draw STACK'
print 'batg.label Bâtiment G'
print 'batg.draw STACK'
print 'bath.label Bâtiment H'
print 'bath.draw STACK'
print 'bati.label Bâtiment I'
print 'bati.draw STACK'
print 'batj.label Bâtiment J'
print 'batj.draw STACK'
print 'batm.label Bâtiment M'
print 'batm.draw STACK'
print 'bato.label Bâtiment O'
print 'batm.draw STACK'
print 'batp.label PdJ'
print 'batp.draw STACK'
print 'wifi.label Wifi'
print 'wifi.draw STACK'
for bat in config.liste_bats:
print 'batb.draw STACK'
print 'batb.label Batiment %s' % bat.upper()
print 'total.label Total'
elif arg == "fichier" :
file = open('' % fichier,'w')
from ldap_crans import crans_ldap
db = crans_ldap()
def count(filtre) :
data =
return len(data['adherent']) + len(data['club'])
from lc_ldap import shortcuts, crans_utils
ldap = shortcuts.lc_ldap_readonly()
def count(batiment):
filter_ldap = u"(&(finAdhesion>=%(date)s)(|(aid=*)(cid=*))(chbre=%(batiment)s*))" % {'date': crans_utils.to_generalized_time_format(time.time()), 'batiment': batiment}
total =, sizelimit=10000)
return len(total)
def count_adh():
data = db.get_adherents()
return len(data['adherent']) + len(data['club'])
filter_ldap = u"(&(finAdhesion>=%(date)s)(|(aid=*)(cid=*)))" % {'date': crans_utils.to_generalized_time_format(time.time())}
total =, sizelimit=10000)
return len(total)
total = 0
for bat in 'abcghijmpo' :
nb = count_adh()
for bat in config.liste_bats:
nb = count(bat)
total += nb
file.write("bat%s.value %d\n" % (bat, nb))
nb = count_adh()
total += nb
file.write("wifi.value %d\n" % nb)
total = count_adh()
file.write("total.value %d\n" % total)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment