scripts/munin/batiments
Nicolas Dandrimont e771f28cd1 Passage à l'UTF-8 du plugin batiments de munin
En effet pango de lenny s'attend à des chaines UTF-8.

darcs-hash:20080907152002-ffbb2-387e14bdabf80611c82a32c46737f27cc71e8c6e.gz
2008-09-07 17:20:02 +02:00

63 lines
1.6 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 Adhérents par batiments'
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 '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 '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 'abchijmp' :
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)