crans_bcfg2/Python/etc/munin/munin.conf
2015-07-29 16:25:14 +02:00

190 lines
5.3 KiB
Python
Executable file

#!/usr/bin/env python
# -*- coding: utf-8 -*-
header("munin-server : configuration des hôtes\n\
(cette liste est générée par bcfg2)")
info['owner'] = 'munin'
info['group'] = 'adm'
# TODO (reste à faire)
# * Plus d'aggrégation de graphes (voir plus bas)
# * Éventuellement, splitter ce fichier en plusieurs parties (ie les bornes
# dans un fichier à part)
# * factoriser deux trois serveurs (backbone et backbone.adm par ex)
include("ldap_conn")
import annuaires_pg
out("""
# 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
# Communication avec rrdcached (accelère le graphing et le stockage)
rrdcached_socket /var/run/rrdcached.sock
# Where to look for the HTML templates
tmpldir /etc/munin/templates
# Envoi automatique des alertes par mail.
contact.roots.command mail -s "Munin - ${var:host} : ${var:graph_title}" nobody@crans.org
# Uncomment below quand on aura compris comment lui faire envoyer des mails
# que concernant l'imprimante
#contact.impression.command mail -s "Munin - ${var:graph_title}" impression@crans.org
# Les graphes sont réalisés via le CGI
graph_strategy cgi
cgiurl /
cgiurl_graph /munin-graph
# Et l'html aussi
html_strategy cgi
munin_cgi_graph_jobs 6
#============================== 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=["backbone.adm.crans.org","bato-1.adm.crans.org"]) ]
for host in switchs:
out('[switchs.crans.org;%s]' % (host,))
out(' address localhost\n')
out("""#============================ Switchs en snmp ========================
# On configure certains switchs pour etre contactés en snmp, et récupérer les données
[switchs.crans.org;backbone.adm.crans.org]
address localhost
use_node_name no
[switchs.crans.org;bato-1.adm.crans.org]
address localhost
use_node_name no
""")
out("""
#============================== Les bornes wifi ============================
#On emprunte des données venant du graphe multistacké wifi_clients
# """)
for ap in ldap_conn.search(u'objectClass=borneWifi'):
# skip fake ap
skip = False
for comment in ap['info']:
if comment.value.startswith('test') or \
comment.value.startswith('<'):
skip = True
if skip:
continue
fqdn = ap['host'][0].value.encode('utf-8')
profile = fqdn.split('.',1)[0]
out("""[wifi.crans.org;%(profile)s]
address localhost
update no
wifi_clients.graph_title Clients connectés
wifi_clients.update no
wifi_clients.graph_category wifi
wifi_clients.graph_order \\
clients=crans.org;%(master)s:wifi_clients.%(profile)s
wifi_uptime.graph_title Uptime
wifi_uptime.update no
wifi_uptime.graph_category wifi
wifi_uptime.graph_order \\
uptime=crans.org;%(master)s:wifi_uptime.%(profile)s
wifi_authorized.graph_title Authorized (ratio) clients
wifi_authorized.update no
wifi_authorized.graph_category wifi
wifi_authorized.graph_order \\
uptime=crans.org;%(master)s:wifi_authorized.%(profile)s
wifi_idle.graph_title Mean idle time
wifi_idle.update no
wifi_idle.graph_category wifi
wifi_idle.graph_order \\
idle=crans.org;%(master)s:wifi_idle.%(profile)s
""" % { 'hostname': fqdn,
'profile': profile,
'master': metadata.profile + '.crans.org',
})
#@[switchs.crans.org;supervision.switchs.crans.org]
#@update no
out("""
#===================== Divers ==============================================
# 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)
# TODO autres sites webs (!)
[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
# Imprimante
[association.crans.org;laserjet]
address localhost
contacts impression
# Pulsar (température et alimentation électrique au 0B)
[pulsar.crans.org]
address localhost
notify_alias pulsar.adm.crans.org
""")
# TODO agrégation de graphes
# load_all (load.load sur tous les serveurs)
# uptime_all (uptime.uptime) --> draw = LINE2
# pending_all (apt.pending)
# hold_all (apt.hold_all)
# postfix_all (postfix_mailqueue.deferred)
# postfix_all_maildrop(postfix_mailqueue.maildrop)
#
out("""
#===================== Serveurs réguliers ==================================
# """)
all_servers = metadata.query.all()
all_servers.sort(key=lambda x: x.hostname)
for client in all_servers:
if "no-munin" in client.groups:
continue
out("""[%(profile)s]
address %(hostname)s
apt.graph yes
postfix_mailqueue.deferred.warning 1000
""" % { 'hostname': client.hostname,
'profile': client.profile + '.crans.org',
})
out("[crans.org;]")
out(" node_order " + " \\\n ".join([c.profile for c in all_servers]))