diff --git a/Bundler/monit.xml b/Bundler/monit.xml index 0af164e..e9ca971 100644 --- a/Bundler/monit.xml +++ b/Bundler/monit.xml @@ -1,7 +1,5 @@ - - diff --git a/Cfg/etc/monit/gen_disques/gen_disques b/Cfg/etc/monit/gen_disques/gen_disques deleted file mode 100755 index a9e8277..0000000 --- a/Cfg/etc/monit/gen_disques/gen_disques +++ /dev/null @@ -1,75 +0,0 @@ -#! /usr/bin/env python -# -*- coding:iso-8859-15 -*- -# -# Fichier gere par BCfg2 (plugin Cfg) -# -# A ne modifier que sur vert - - -import commands, sys, sre -hostname = commands.getoutput("hostname").split('.')[0] - -# on ne monitore pas les disques de canard -if hostname in ['canard'] : - sys.exit(0) - -config = '' -fstab = open("/etc/fstab") - -for line in fstab.readlines() : - # on supprime les espaces - line = line.strip().replace('\t',' ') - - # on saute les lignes inintérassantes - if not line : - continue - if line[0] == "#" : - continue - - # on découpe la ligne - line = sre.split(' *',line) - - # on saute si c'est une partition non montée au démarrage - if "noauto" in line[3].split(",") : - continue - - # on saute si c'est une partition bind - if "bind" in line[3].split(",") : - continue - - # on saute les système pas intéressants - if line[2] in ['swap','proc','tmpfs','sysfs'] : - continue - - # on saute le nfs - if ':' in line[0] : - continue - - # on ajoute les lignes de configuration générale - config += '# partition %s\n' % line[1] - config += 'check device fs%s with path %s\n' % (line[1], line[0]) - - config += ' if failed permission 660 then alert\n' - config += ' if failed uid root then alert\n' - config += ' if failed gid disk then alert\n' - - # place sur les disques - if (hostname,line[1]) in [('sila','/var/spool/squid1'),('sila','/var/spool/squid2')] : - pass - elif (hostname,line[1]) in [('egon','/pubftp')] : - config += ' if space usage > 95% then alert\n' - elif (hostname,line[1]) in [('sila','/var/log/squid'),('sila','/pubftp')] : - config += ' if space usage > 92% then alert\n' - elif line[1] in ('/usr', '/var/lib/mailman', '/localhome'): - config += ' if space usage > 90% then alert\n' - else : - config += ' if space usage > 80% then alert\n' - - # inodes pour les disques - if line[2] != 'reiserfs' : - config += ' if inode usage > 80% then alert\n' - - config += ' mode passive\n' - config += '\n' - -print config diff --git a/Cfg/etc/monit/gen_disques/info.xml b/Cfg/etc/monit/gen_disques/info.xml deleted file mode 100644 index 18ad0f3..0000000 --- a/Cfg/etc/monit/gen_disques/info.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/Cfg/etc/monit/monitrc/monitrc b/Cfg/etc/monit/monitrc/monitrc index 0be47fb..21232b5 100644 --- a/Cfg/etc/monit/monitrc/monitrc +++ b/Cfg/etc/monit/monitrc/monitrc @@ -20,5 +20,4 @@ message: Monit $ACTION $SERVICE at $DATE on $HOST. } -include /etc/monit/disques include /etc/monit/services diff --git a/Probes/fstab.local b/Probes/fstab.local index 4f82473..e7f240e 100755 --- a/Probes/fstab.local +++ b/Probes/fstab.local @@ -1,10 +1,11 @@ #!/bin/bash -if [ ! -f /etc/fstab.local ]; then - echo "none" - exit 0 +if [ -f /etc/fstab.local ]; then + echo "group:fstab.local" + exec cat /etc/fstab.local +else + # S'il n'y a pas de fstab.local (pour les serveurs ou ca n'a pas ete + # fait, on lit le fstab parce qu'on on en a besoin pour + # /etc/monit/services) + exec cat /etc/fstab fi - -echo "group:fstab.local" - -exec cat /etc/fstab.local diff --git a/Python/etc/monit/services b/Python/etc/monit/services index d0f454b..7ee1a6c 100644 --- a/Python/etc/monit/services +++ b/Python/etc/monit/services @@ -1,5 +1,6 @@ -# -*- encoding: utf-8 -*- -# -*- mode: python -*- +# -*- coding: utf-8; mode: python -*- + +import sre info["owner"] = "root" info["group"] = "root" @@ -286,3 +287,64 @@ if has("vsftpd-federez"): @ if 5 restarts within 5 cycles then timeout @ +# on ne monitore pas les disques de canard +if hostname in ['canard'] : + done() + +for line in metadata.probes["fstab.local"].splitlines(): + # on supprime les espaces + line = line.strip() + + # on saute les lignes inintérassantes + if not line : + continue + if line[0] == "#" : + continue + + # on découpe la ligne + [fs, mntpoint, type, options, dump, pass_] = sre.split('[ \t]*',line) + options = options.split(",") + + # on saute si c'est une partition non montée au démarrage + if "noauto" in options: + continue + + # on saute si c'est une partition bind + if "bind" in options: + continue + + # on saute les système pas intéressants + if type in ['swap','proc','tmpfs','sysfs', 'nfs']: + continue + + # on ajoute les lignes de configuration générale + comment("partition %s" % mntpoint) + print 'check device fs%s with path %s' % (line[1], line[0]) + + print ' if failed permission 660 then alert' + print ' if failed uid root then alert' + print ' if failed gid disk then alert' + + # place sur les disques + alert_level = { + ('sila','/var/spool/squid1') : None, + ('sila','/var/spool/squid2') : None, + ('egon','/pubftp') : 95, + ('sila','/var/log/squid') : 92, + ('sila','/pubftp') : 92 + }.get((hostname, mntpoint), -1) + if alert_level == -1: + if mntpoint in ('/usr', '/var/lib/mailman', '/localhome'): + alert_level = 90 + else: + alert_level = 80 + + if alert_level: + print ' if space usage > %d%% then alert' % alert_level + + # inodes pour les disques + if type != 'reiserfs' : + print ' if inode usage > 80% then alert' + + print ' mode passive' + print diff --git a/Rules/rules.xml b/Rules/rules.xml index 9a97229..6d23991 100644 --- a/Rules/rules.xml +++ b/Rules/rules.xml @@ -54,8 +54,5 @@ rm -f $a && grpconv; }"/> -