timeout pour tous les services

darcs-hash:20050930174314-4ec08-1edb0f232e7ed473b1b9426b85c0c6ca9e387dff.gz
This commit is contained in:
chove 2005-09-30 19:43:14 +02:00
parent b02292f8fb
commit 328cb66a46

View file

@ -25,6 +25,7 @@ def file_monitrc(hostname = host) :
Retourne la configuration de la machine Retourne la configuration de la machine
""" """
config = "" config = ""
timeout = "timeout 30 seconds"
# headers # headers
if True : if True :
@ -91,7 +92,7 @@ def file_monitrc(hostname = host) :
if ':' in line[0] : if ':' in line[0] :
continue continue
# on ajoute les lignes # on ajoute les lignes de configuration générale
config += '# partition %s\n' % line[1] config += '# partition %s\n' % line[1]
config += 'check device fs%s with path %s\n' % (line[1], line[0]) config += 'check device fs%s with path %s\n' % (line[1], line[0])
@ -104,7 +105,7 @@ def file_monitrc(hostname = host) :
config += ' if failed uid root then alert\n' config += ' if failed uid root then alert\n'
config += ' if failed gid disk then alert\n' config += ' if failed gid disk then alert\n'
# place sur ls disques # place sur les disques
if (hostname,line[1]) in [('sila','/var/spool/squid1'),('sila','/var/spool/squid2')] : if (hostname,line[1]) in [('sila','/var/spool/squid1'),('sila','/var/spool/squid2')] :
continue continue
elif (hostname,line[1]) in [('egon','/pubftp')] : elif (hostname,line[1]) in [('egon','/pubftp')] :
@ -127,7 +128,7 @@ def file_monitrc(hostname = host) :
config += 'check process apache-ssl with pidfile /var/run/apache-ssl.pid\n' config += 'check process apache-ssl with pidfile /var/run/apache-ssl.pid\n'
config += ' start program = "/etc/init.d/apache-ssl start"\n' config += ' start program = "/etc/init.d/apache-ssl start"\n'
config += ' stop program = "/etc/init.d/apache-ssl stop"\n' config += ' stop program = "/etc/init.d/apache-ssl stop"\n'
config += ' if failed host localhost port 80 protocol http then restart\n' config += ' if failed host localhost port 80 protocol http %s then restart\n' % timeout
#config += ' if failed host %s port 80 protocol http then restart\n' % hostname #config += ' if failed host %s port 80 protocol http then restart\n' % hostname
#config += ' if failed host localhost port 443 type tcpssl protocol http then restart\n' #config += ' if failed host localhost port 443 type tcpssl protocol http then restart\n'
#config += ' if failed host %s port 80 protocol http then restart\n' % hostname #config += ' if failed host %s port 80 protocol http then restart\n' % hostname
@ -147,10 +148,10 @@ def file_monitrc(hostname = host) :
config += ' start program = "/etc/init.d/apache2 start"\n' config += ' start program = "/etc/init.d/apache2 start"\n'
config += ' stop program = "/etc/init.d/apache2 stop"\n' config += ' stop program = "/etc/init.d/apache2 stop"\n'
if hostname == 'pegase' : if hostname == 'pegase' :
config += ' if failed host localhost port 443 type tcpssl protocol http timeout 15 seconds then restart\n' config += ' if failed host localhost port 443 type tcpssl protocol http %s seconds then restart\n' % timeout
else : else :
config += ' if failed host localhost port 80 protocol http timeout 15 seconds then restart\n' config += ' if failed host localhost port 80 protocol http %s then restart\n' % timeout
config += ' if failed host localhost port 443 type tcpssl protocol http then restart\n' config += ' if failed host localhost port 443 type tcpssl protocol http %s then restart\n' % timeout
config += ' if cpu is greater than 60% for 2 cycles then alert\n' config += ' if cpu is greater than 60% for 2 cycles then alert\n'
config += ' if cpu > 80% for 5 cycles then restart\n' config += ' if cpu > 80% for 5 cycles then restart\n'
#config += ' if totalmem > 500.0 MB for 5 cycles then restart\n' #config += ' if totalmem > 500.0 MB for 5 cycles then restart\n'
@ -266,7 +267,7 @@ def file_monitrc(hostname = host) :
config += 'check process ntpd\n' config += 'check process ntpd\n'
config += ' start program = "/etc/init.d/openntpd start"\n' config += ' start program = "/etc/init.d/openntpd start"\n'
config += ' stop program = "/etc/init.d/openntpd stop"\n' config += ' stop program = "/etc/init.d/openntpd stop"\n'
config += ' if failed host 127.0.0.1 port 123 type udp then restart\n' config += ' if failed host 127.0.0.1 port 123 type udp %s then restart\n' % timeout
config += ' if 5 restarts within 5 cycles then timeout\n' config += ' if 5 restarts within 5 cycles then timeout\n'
config += '\n' config += '\n'
@ -276,7 +277,7 @@ def file_monitrc(hostname = host) :
config += 'check process postfix with pidfile /var/spool/postfix/pid/master.pid\n' config += 'check process postfix with pidfile /var/spool/postfix/pid/master.pid\n'
config += ' start program = "/etc/init.d/postfix start"\n' config += ' start program = "/etc/init.d/postfix start"\n'
config += ' stop program = "/etc/init.d/postfix stop"\n' config += ' stop program = "/etc/init.d/postfix stop"\n'
config += ' if failed port 25 protocol smtp timeout 15 seconds then restart\n' config += ' if failed port 25 protocol smtp %s then restart\n' % timeout
config += ' if 5 restarts within 5 cycles then timeout\n' config += ' if 5 restarts within 5 cycles then timeout\n'
config += '\n' config += '\n'
@ -286,7 +287,7 @@ def file_monitrc(hostname = host) :
config += 'check process postgresql with pidfile /var/lib/postgres/data/postmaster.pid\n' config += 'check process postgresql with pidfile /var/lib/postgres/data/postmaster.pid\n'
config += ' start program = "/etc/init.d/postgresql start"\n' config += ' start program = "/etc/init.d/postgresql start"\n'
config += ' stop program = "/etc/init.d/postgresql stop"\n' config += ' stop program = "/etc/init.d/postgresql stop"\n'
config += ' if failed port 5432 then restart\n' config += ' if failed port 5432 %s then restart\n' % timeout
# config += ' if failed unixsocket /var/run/postgresql then restart\n' # config += ' if failed unixsocket /var/run/postgresql then restart\n'
config += ' if 5 restarts within 5 cycles then timeout\n' config += ' if 5 restarts within 5 cycles then timeout\n'
config += '\n' config += '\n'
@ -297,7 +298,7 @@ def file_monitrc(hostname = host) :
config += 'check process privoxy with pidfile /var/run/privoxy.pid\n' config += 'check process privoxy with pidfile /var/run/privoxy.pid\n'
config += ' start program = "/etc/init.d/privoxy start"\n' config += ' start program = "/etc/init.d/privoxy start"\n'
config += ' stop program = "/etc/init.d/privoxy stop"\n' config += ' stop program = "/etc/init.d/privoxy stop"\n'
config += ' if failed host localhost port 8117 then restart\n' config += ' if failed host localhost port 8117 timeout %s then restart\n' % timeout
config += ' if 5 restarts within 5 cycles then timeout\n' config += ' if 5 restarts within 5 cycles then timeout\n'
config += '\n' config += '\n'
@ -307,7 +308,7 @@ def file_monitrc(hostname = host) :
config += 'check process proftpd with pidfile /var/run/proftpd.pid\n' config += 'check process proftpd with pidfile /var/run/proftpd.pid\n'
config += ' start program = "/etc/init.d/proftpd start"\n' config += ' start program = "/etc/init.d/proftpd start"\n'
config += ' stop program = "/etc/init.d/proftpd stop"\n' config += ' stop program = "/etc/init.d/proftpd stop"\n'
config += ' if failed port 21 protocol ftp then restart\n' config += ' if failed port 21 protocol ftp %s then restart\n' % timeout
config += ' if 5 restarts within 5 cycles then timeout\n' config += ' if 5 restarts within 5 cycles then timeout\n'
config += '\n' config += '\n'
@ -317,7 +318,7 @@ def file_monitrc(hostname = host) :
config += 'check process slapd with pidfile /var/run/slapd/slapd.pid\n' config += 'check process slapd with pidfile /var/run/slapd/slapd.pid\n'
config += ' start program = "/etc/init.d/slapd start"\n' config += ' start program = "/etc/init.d/slapd start"\n'
config += ' stop program = "/etc/init.d/slapd stop"\n' config += ' stop program = "/etc/init.d/slapd stop"\n'
config += ' if failed host localhost port 389 protocol ldap3 then restart\n' config += ' if failed host localhost port 389 protocol ldap3 %s then restart\n' % timeout
config += ' if 5 restarts within 5 cycles then timeout\n' config += ' if 5 restarts within 5 cycles then timeout\n'
config += '\n' config += '\n'
@ -355,7 +356,7 @@ def file_monitrc(hostname = host) :
config += 'check process ssh with pidfile /var/run/sshd.pid\n' config += 'check process ssh with pidfile /var/run/sshd.pid\n'
config += ' start program = "/etc/init.d/ssh start"\n' config += ' start program = "/etc/init.d/ssh start"\n'
config += ' stop program = "/etc/init.d/ssh stop"\n' config += ' stop program = "/etc/init.d/ssh stop"\n'
config += ' if failed port 22 protocol ssh then restart\n' config += ' if failed port 22 protocol ssh %s then restart\n' % timeout
config += ' if 5 restarts within 5 cycles then timeout\n' config += ' if 5 restarts within 5 cycles then timeout\n'
config += '\n' config += '\n'
@ -387,7 +388,7 @@ def file_monitrc(hostname = host) :
config += 'check process tinyproxy with pidfile /var/run/tinyproxy.pid\n' config += 'check process tinyproxy with pidfile /var/run/tinyproxy.pid\n'
config += ' start program = "/etc/init.d/tinyproxy start"\n' config += ' start program = "/etc/init.d/tinyproxy start"\n'
config += ' stop program = "/etc/init.d/tinyproxy stop"\n' config += ' stop program = "/etc/init.d/tinyproxy stop"\n'
config += ' if failed host %s.crans.org port 3128 then restart\n' % hostname config += ' if failed host %s.crans.org port 3128 %s then restart\n' % (hostname,timeout)
config += ' if 5 restarts within 5 cycles then timeout\n' config += ' if 5 restarts within 5 cycles then timeout\n'
config += '\n' config += '\n'
@ -397,7 +398,7 @@ def file_monitrc(hostname = host) :
config += 'check process vsftpd with pidfile /var/run/vsftpd/vsftpd.pid\n' config += 'check process vsftpd with pidfile /var/run/vsftpd/vsftpd.pid\n'
config += ' start program = "/etc/init.d/vsftpd start"\n' config += ' start program = "/etc/init.d/vsftpd start"\n'
config += ' stop program = "/etc/init.d/vsftpd stop"\n' config += ' stop program = "/etc/init.d/vsftpd stop"\n'
config += ' if failed port 21 protocol ftp then restart\n' config += ' if failed port 21 protocol ftp %s then restart\n' % timeout
config += ' if 5 restarts within 5 cycles then timeout\n' config += ' if 5 restarts within 5 cycles then timeout\n'
config += '\n' config += '\n'