#!/usr/bin/env python # -*- coding: utf-8 -*- # This is work in progress, please do not commit # -- # Daniel STAN # List: print metadata.query.names_by_groups(['mail-mx-main']) #print metadata.query.names_by_groups(['mail-mx-main']) import annuaires_pg print """ # The next three variables specifies where the location of the RRD # databases, the HTML output, and the logs, severally. They all # must be writable by the user running munin-cron. dbdir /var/lib/munin htmldir /var/www/munin logdir /var/log/munin rundir /var/run/munin # Envoi automatique des alertes par mail. contact.roots.command mail -s "Munin - ${var:host} : ${var:graph_title}" nobody@crans.org contact.impression.command mail -s "Munin - ${var:graph_title}" impression@crans.org # Nagios contact.nagios.command /usr/sbin/send_nsca -H localhost -c /etc/send_nsca.cfg -to 120 contacts nagios # Les graphes sont réalisés via le CGI graph_strategy cgi cgiurl /cgi-bin cgiurl_graph /cgi-bin/munin-cgi-graph #============================== Les switchs ================================ #Il ne s'agit pas de clients bcfg2 et ne sont par ailleurs pas des nœuds munin """ switchs = [ x[:x.rindex('.crans.org')] for x in annuaires_pg.all_switchs(hide=[]) ] for host in switchs: print '[switchs.crans.org;%s]' % host print ' address localhost\n' print """ #============================== Les bornes wifi ============================ #Idem.""" import subprocess host_serv = metadata.query.by_groups(['dns-primary'])[0].hostname req = subprocess.Popen(['/usr/bin/host', '-l', '148.231.138.in-addr.arpa', host_serv], stdout=subprocess.PIPE, stderr=subprocess.PIPE) out,_ = req.communicate() for line in out.split('\n'): fqdn = line.split(' ')[-1][:-1] if not fqdn: continue profile = fqdn.split('.',1)[0] print """[wifi.crans.org;%(profile)s] address localhost """ % { 'hostname': fqdn, 'profile': profile, } #@[switchs.crans.org;supervision.switchs.crans.org] #@update no # #@# Les adherents #@[association.crans.org;adherents] #@ address localhost #@ #@# Les adresses ips #@[association.crans.org;adresses-ip] #@ address localhost #@ #@# Les stats wiki #@[association.crans.org;web.wiki] #@ address niomniom.adm.crans.org #@ #@# Les stats web (sur zamok) #@[association.crans.org;web.zamok] #@ address zamok.adm.crans.org #@ #@# statistiques #@[association.crans.org;jabber] #@ address xmpp.adm.crans.org #@ #@# Imprimante #@[association.crans.org;canon] #@ address zamok.adm.crans.org #@ contacts impression print # Listes des serveurs all_servers = metadata.query.all() all_servers.sort(key=lambda x: x.hostname) for client in all_servers: print """[crans.org;%(profile)s] address %(hostname)s apt.graph yes postfix_mailqueue.deferred.warning 1000 """ % { 'hostname': client.hostname, 'profile': client.profile, } print "[crans.org;]" print " node_order " + " \\\n ".join([c.profile for c in all_servers])