[munin/scripts/hosts_plugins.py] Création des lignes cron pour les plugins custom + factorisation des firewall

Ignore-this: e0cdc6d5356b513e3f72048318f0670b

darcs-hash:20090329191817-ffbb2-4efb0e46ff6f03dc515af9420637e0b6636ba04c.gz
This commit is contained in:
Nicolas Dandrimont 2009-03-29 21:18:17 +02:00
parent d03c1c81a1
commit a322862f84

View file

@ -13,13 +13,24 @@ del _sys
import annuaires
import config
__all__ = ["hosts_plugins"]
__all__ = ["hosts_plugins", "munin_fw", "cron_plugins", "hosts_crons"]
# Lignes cron correspondant aux plugins customs
cron_plugins = {
# plugin: (utilisateur, commande),
# %s est remplacé par le lien dans /etc/munin/plugins
"audimat": ("munin", "nice -n 14 %s generate 2> /dev/null"),
"batiments": ("munin", "nice -n 14 %s fichier 2> /dev/null"),
"stats-ip_": ("munin", "nice -n 14 %s fichier 2> /dev/null"),
"stats-ip": ("munin", "nice -n 14 %s fichier 2> /dev/null"),
"wiki_pages": ("www-data", "%s fichier > /dev/null"),
}
# Hôtes pour lesquels le firewall est muninisé
munin_fw = sorted(["zamok", "rouge", "komaz", "sable"])
hosts_plugins = {
"zamok": {
"iptables_filter": "iptables_",
"iptables_mangle": "iptables_",
"iptables_nat": "iptables_",
"laserjet_car": "laserjet_",
"laserjet_car-p": "laserjet_",
"laserjet__etat": "laserjet__etat",
@ -39,9 +50,6 @@ hosts_plugins = {
},
"rouge": {
"amavis": "amavis",
"iptables_filter": "iptables_",
"iptables_mangle": "iptables_",
"iptables_nat": "iptables_",
"machines": "machines",
# "webalizer_dixans": "webalizer_",
# "webalizer_install-party": "webalizer_",
@ -52,16 +60,10 @@ hosts_plugins = {
# "webalizer_www": "webalizer_",
},
"komaz": {
"iptables_filter": "iptables_",
"iptables_mangle": "iptables_",
"iptables_nat": "iptales_",
"machines": "machines",
},
"sable": {
"blacklist": "blacklist",
"iptables_filter": "iptables_",
"iptables_mangle": "iptables_",
"iptables_nat": "iptales_",
},
"xmpp": {
"jabber": "jabeer",
@ -102,3 +104,36 @@ for switch in annuaires.all_switchs():
switch = switch[:switch.index('.')]
switch = switch.replace('-', '_')
hosts_plugins["munin"]["ping_%s.adm" % switch] = "ping_bat_"
#########
# Muninisation des firewalls
#
for host in munin_fw:
hosts_plugins[host].update({
"iptables_filter": "iptables_",
"iptables_mangle": "iptables_",
"iptables_nat": "iptables_",
})
# format de la ligne cron
CRON_FORMAT = "%s-%s/%s * * * * %s %s"
# fréquence
FREQ = 15
# lignes cron par hôte
hosts_crons = {}
for host, plugins in hosts_plugins.items():
minute = 1
hosts_crons[host] = []
for path, plugin in plugins.items():
if plugin in cron_plugins:
path = "/etc/munin/plugins/" + path
user, line = cron_plugins[plugin]
hosts_crons[host].append(CRON_FORMAT % (minute,
60 - FREQ + minute,
FREQ,
user,
line % path))
minute = (minute + 4) % FREQ
if not hosts_crons[host]:
del hosts_crons[host]