scripts/munin/batiments
Vincent Le Gallic c039058708 Enregistrement des droits d'exécution. Aucune vraie modif.
Darcs n'enregistrait pas les permissions des fichiers.
2013-01-31 05:36:25 +01:00

67 lines
1.7 KiB
Python
Executable file

#!/usr/bin/env python
# -*- coding: utf-8 -*-
fichier = '/var/lib/munin/tmp/batiments'
import sys,os
try :
arg = sys.argv[1]
except :
arg = ''
if arg == "config" :
print 'host_name adherents'
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'
print 'total.label Total'
elif arg == "fichier" :
file = open('%s.next' % fichier,'w')
sys.path.append('/usr/scripts/gestion')
from ldap_crans import crans_ldap
db = crans_ldap()
def count(filtre) :
data = db.search(filtre)
return len(data['adherent']) + len(data['club'])
total = 0
for bat in 'abcghijmpo' :
nb = count('paiement=ok&chbre=%s*' % bat)
total += nb
file.write("bat%s.value %d\n" % (bat, nb))
nb = count('paiement=ok&chbre=EXT')
total += nb
file.write("wifi.value %d\n" % nb)
file.write("total.value %d\n" % total)
file.close()
os.system('mv %s.next %s' % (fichier, fichier))
else :
os.system('cat %s' % fichier)