crans_bcfg2/Python/etc/munin/munin.conf
Daniel STAN f5ed044766 munin-server: utilisation de fastcgi
Sorry, mais j'ai préféré ne pas le faire avec fastcgiwrap pour être sûr
de contrôler le nombre de process lancés à un instant donné. De plus, je
galérais avec les path et les requests_uri pour les faire fitter aux pages
que munin génère.
2014-03-16 17:51:04 +01:00

170 lines
4.8 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
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
# 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
# Nagios
#contact.nagios.command /usr/sbin/send_nsca -H localhost -c /etc/send_nsca.cfg -to 120 > /dev/null
#contacts nagios
# Les graphes sont réalisés via le CGI
graph_strategy cgi
cgiurl /munin-bin
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=[]) ]
for host in switchs:
print '[switchs.crans.org;%s]' % host
print ' address localhost\n'
print """
#============================== Les bornes wifi ============================
#On emprunte des données venant du graphe multistacké wifi_clients (sur gordon)
# """
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]
print """[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;dyson.crans.org: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;dyson.crans.org:wifi_uptime.%(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;dyson.crans.org:wifi_idle.%(profile)s
""" % { 'hostname': fqdn,
'profile': profile,
}
#@[switchs.crans.org;supervision.switchs.crans.org]
#@update no
print """
#===================== 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
# 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)
#
print """
#===================== Serveurs réguliers ==================================
# """
all_servers = metadata.query.all()
all_servers.sort(key=lambda x: x.hostname)
for client in all_servers:
#print """[crans.org;%(profile)s] # enlever crans.org change qqchose ?
print """[%(profile)s]
address %(hostname)s
apt.graph yes
postfix_mailqueue.deferred.warning 1000
""" % { 'hostname': client.hostname,
'profile': client.profile + '.crans.org',
}
print "[crans.org;]"
print " node_order " + " \\\n ".join([c.profile for c in all_servers])