On utilise le probe fstab.local pour générer la conf des disques pour monit
darcs-hash:20080210175932-af139-986ad9079d735eab098a0204621c64945e1d4314.gz
This commit is contained in:
parent
c6ef19d4eb
commit
08cd541ea1
7 changed files with 72 additions and 93 deletions
|
@ -1,7 +1,5 @@
|
||||||
<Bundle name="monit">
|
<Bundle name="monit">
|
||||||
<Action name="monit-gen-disques"/>
|
|
||||||
<ConfigFile name="/etc/default/monit"/>
|
<ConfigFile name="/etc/default/monit"/>
|
||||||
<ConfigFile name="/etc/monit/gen_disques"/>
|
|
||||||
<ConfigFile name="/etc/monit/monitrc"/>
|
<ConfigFile name="/etc/monit/monitrc"/>
|
||||||
<ConfigFile name="/etc/monit/services"/>
|
<ConfigFile name="/etc/monit/services"/>
|
||||||
<ConfigFile name="/etc/cron.d/monit"/>
|
<ConfigFile name="/etc/cron.d/monit"/>
|
||||||
|
|
|
@ -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
|
|
|
@ -1,3 +0,0 @@
|
||||||
<FileInfo>
|
|
||||||
<Info owner='root' group='root' perms='0755' encoding='base64'/>
|
|
||||||
</FileInfo>
|
|
|
@ -20,5 +20,4 @@ message: Monit $ACTION $SERVICE at $DATE on $HOST.
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
include /etc/monit/disques
|
|
||||||
include /etc/monit/services
|
include /etc/monit/services
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
if [ ! -f /etc/fstab.local ]; then
|
if [ -f /etc/fstab.local ]; then
|
||||||
echo "none"
|
echo "group:fstab.local"
|
||||||
exit 0
|
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
|
fi
|
||||||
|
|
||||||
echo "group:fstab.local"
|
|
||||||
|
|
||||||
exec cat /etc/fstab.local
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# -*- encoding: utf-8 -*-
|
# -*- coding: utf-8; mode: python -*-
|
||||||
# -*- mode: python -*-
|
|
||||||
|
import sre
|
||||||
|
|
||||||
info["owner"] = "root"
|
info["owner"] = "root"
|
||||||
info["group"] = "root"
|
info["group"] = "root"
|
||||||
|
@ -286,3 +287,64 @@ if has("vsftpd-federez"):
|
||||||
@ if 5 restarts within 5 cycles then timeout
|
@ 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
|
||||||
|
|
|
@ -54,8 +54,5 @@
|
||||||
rm -f $a &&
|
rm -f $a &&
|
||||||
grpconv; }"/>
|
grpconv; }"/>
|
||||||
|
|
||||||
<Action name="monit-gen-disques"
|
|
||||||
timing="post" when="modified" status="check"
|
|
||||||
command="/etc/monit/gen_disques > /etc/monit/disques"/>
|
|
||||||
<Service name="monit" status="on"/>
|
<Service name="monit" status="on"/>
|
||||||
</Rules>
|
</Rules>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue