munin: s/dyson/munin-server/ (spec par bcfg2)

On s'autorise à lister les plugins à activer sur la base des groupes bcfg2
d'un serveur, au lieu de spécifier en dur le nom du serveur.
This commit is contained in:
Daniel STAN 2014-03-18 18:49:29 +01:00
parent 13d839eecd
commit 4a225f1375
2 changed files with 12 additions and 11 deletions

View file

@ -29,6 +29,8 @@ cron_plugins = {
# Hôtes pour lesquels le firewall est muninisé # Hôtes pour lesquels le firewall est muninisé
munin_fw = sorted(["zamok", "komaz", "sable"]) munin_fw = sorted(["zamok", "komaz", "sable"])
# Les clés correspondent au nom du serveur, ou à un des groupes (bcfg2)
# possédé par le serveur (cf gestion/config/services.py )
hosts_plugins = { hosts_plugins = {
"vo": { "vo": {
"coretemp": "/usr/scripts/munin/coretemp", "coretemp": "/usr/scripts/munin/coretemp",
@ -73,10 +75,6 @@ hosts_plugins = {
"coretemp": "/usr/scripts/munin/coretemp", "coretemp": "/usr/scripts/munin/coretemp",
"bind9_rndc": "/usr/share/munin/plugins/bind9_rndc", "bind9_rndc": "/usr/share/munin/plugins/bind9_rndc",
}, },
"gordon": {
"coretemp": "/usr/scripts/munin/coretemp",
"bind9_rndc": "/usr/share/munin/plugins/bind9_rndc",
},
"routeur": { "routeur": {
"bind9_rndc": "/usr/share/munin/plugins/bind9_rndc", "bind9_rndc": "/usr/share/munin/plugins/bind9_rndc",
}, },
@ -100,7 +98,7 @@ hosts_plugins = {
"wiki_themes": "wiki_themes", "wiki_themes": "wiki_themes",
"wiki_users": "wiki_users", "wiki_users": "wiki_users",
}, },
"dyson": { "munin-server": {
"audimat": "audimat", "audimat": "audimat",
"batiments": "batiments", "batiments": "batiments",
"munin": "munin", "munin": "munin",
@ -132,16 +130,16 @@ general_plugins = {
# Trucs spécifiques à munin.crans.org # Trucs spécifiques à munin.crans.org
# Onduleur # Onduleur
for mge_truc in ["batt", "hygro", "intensite", "temp", "temps", "tension"]: for mge_truc in ["batt", "hygro", "intensite", "temp", "temps", "tension"]:
hosts_plugins["dyson"]["mge_%s" % mge_truc] = "mge_%s" % mge_truc hosts_plugins["munin-server"]["mge_%s" % mge_truc] = "mge_%s" % mge_truc
# Stats d'utilisation des réseaux # Stats d'utilisation des réseaux
for net in config.NETs: for net in config.NETs:
hosts_plugins["dyson"]["stats-ip_%s" % net] = "stats-ip_" hosts_plugins["munin-server"]["stats-ip_%s" % net] = "stats-ip_"
# Stats de peuplement des bâtiments # Stats de peuplement des bâtiments
for bat in annuaires.bat_switchs: for bat in annuaires.bat_switchs:
if bat not in ('v',): if bat not in ('v',):
hosts_plugins["dyson"]["stats-batiment_%s" % bat] = "stats-batiment_" hosts_plugins["munin-server"]["stats-batiment_%s" % bat] = "stats-batiment_"
# Ping de tous les switches de bâtiments # Ping de tous les switches de bâtiments
for switch in annuaires.all_switchs(hide=[]): for switch in annuaires.all_switchs(hide=[]):
@ -149,7 +147,7 @@ for switch in annuaires.all_switchs(hide=[]):
# (tous les switchs n'étant pas sur adm, on garde quand-même ce suffixe) # (tous les switchs n'étant pas sur adm, on garde quand-même ce suffixe)
switch = switch[:switch.rindex('.crans.org')] switch = switch[:switch.rindex('.crans.org')]
switch = switch.replace('-', '_') switch = switch.replace('-', '_')
hosts_plugins["dyson"]["ping_%s" % switch] = "ping_bat_" hosts_plugins["munin-server"]["ping_%s" % switch] = "ping_bat_"
# On rajoute les stats de connexion # On rajoute les stats de connexion
for host in hosts_plugins.keys(): for host in hosts_plugins.keys():

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/bin/bash /usr/scripts/python.sh
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# #
# Liste les liens à créer pour les plugins munin. # Liste les liens à créer pour les plugins munin.
@ -42,7 +42,7 @@ IGNORE_PLUGINS = (
'vlan_', 'vlan_',
) )
if socket.gethostname() in services.services.get('iscsi', []): if socket.gethostname() in services.get('iscsi', []):
IGNORE_PLUGINS += ( IGNORE_PLUGINS += (
'diskstat', 'diskstat',
'diskstats', 'diskstats',
@ -128,6 +128,9 @@ def get_all_plugins():
result = get_munin_plugins() result = get_munin_plugins()
custom_plugins = hosts_plugins.get(hostname, {}) custom_plugins = hosts_plugins.get(hostname, {})
for (group, hosts) in services.iteritems():
if hostname in hosts:
custom_plugins.update(hosts_plugins.get(group, {}))
custom_plugins.update(general_plugins) custom_plugins.update(general_plugins)
for plugin, dest_file in custom_plugins.iteritems(): for plugin, dest_file in custom_plugins.iteritems():