redmarage de monit sur nectaris
darcs-hash:20051009212343-4ec08-13bf9dd30da8bc620b52d9213186808eed7db921.gz
This commit is contained in:
parent
aeddced3b6
commit
8bd57066c5
1 changed files with 40 additions and 6 deletions
|
@ -2,10 +2,11 @@
|
|||
# -*- coding:iso-8859-15 -*-
|
||||
|
||||
import sre
|
||||
import sys, os
|
||||
import sys, os, time
|
||||
import commands
|
||||
|
||||
# on récupère le hostname
|
||||
host = open('/etc/hostname').readline().strip()
|
||||
host = commands.getoutput("hostname").split('.')[0]
|
||||
|
||||
# est ce que c'est un systeme bsd
|
||||
if host in ['nectaris'] :
|
||||
|
@ -34,6 +35,9 @@ def file_monitrc(hostname = host) :
|
|||
config += 'set mailserver localhost, smtp.crans.org\n'
|
||||
config += '\n'
|
||||
|
||||
if bsd :
|
||||
config += 'set alert chove@crans.org { uid gid size timeout resource checksum timestamp connection permission }\n' # changed
|
||||
else :
|
||||
config += 'set alert roots@crans.org { uid gid size nonexist data icmp invalid exec timeout resource checksum timestamp connection permission }\n' # changed
|
||||
config += '\n'
|
||||
|
||||
|
@ -96,9 +100,20 @@ def file_monitrc(hostname = host) :
|
|||
config += ' if failed permission 600 then alert\n'
|
||||
config += ' if failed uid root then alert\n'
|
||||
config += ' if failed gid root then alert\n'
|
||||
else :
|
||||
# droits
|
||||
if bsd :
|
||||
config += ' if failed permission 640 then alert\n'
|
||||
else :
|
||||
config += ' if failed permission 660 then alert\n'
|
||||
|
||||
# proprio
|
||||
config += ' if failed uid root then alert\n'
|
||||
|
||||
# groupe
|
||||
if bsd :
|
||||
config += ' if failed gid operator then alert\n'
|
||||
else :
|
||||
config += ' if failed gid disk then alert\n'
|
||||
|
||||
# place sur les disques
|
||||
|
@ -513,6 +528,25 @@ if not bsd :
|
|||
|
||||
# redémarage de monit
|
||||
if bsd :
|
||||
pass
|
||||
|
||||
# arret
|
||||
out = commands.getstatusoutput("/bin/kill `cat /var/run/monit.pid`")
|
||||
if out[0] :
|
||||
print "Erreur arrêt de monit"
|
||||
print out[1].replace('\n','\n ')
|
||||
else :
|
||||
print "Arrêt de monit : OK"
|
||||
|
||||
# on sleep, sinon le fichier monit.pid est bloqué, et il ne
|
||||
# peut pas être écrit par la commande de démarage
|
||||
time.sleep(1)
|
||||
|
||||
# démarage
|
||||
out = commands.getstatusoutput("monit -c /etc/monitrc -d 60 -p /var/run/monit.pid")
|
||||
if out[0] :
|
||||
print "Erreur démarage de monit"
|
||||
print ' ' + out[1].replace('\n','\n ')
|
||||
else :
|
||||
print "Démarage de monit : OK"
|
||||
else :
|
||||
os.system('/etc/init.d/monit restart')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue