Resolvemos o problema aqui... foi o fato do script httpd precisar escrever
em um local que o nagios não tinha acesso, liberando o sudo o problema foi
resolvido.
2006/10/17, Rafael Gomes <rafael(a)gnufacs.org>:
Quem puder me ajudar agradeço...
Estou com um problema no meu tratador de evento.
Meu services.cfg
# Monitorando de teste
define service{
use service-padrao
host_name linux-firewall-bh
service_description teste
check_command check_ping!100.0,20%!500.0,60%
event_handler restart-httpd
}
MEu checkcommands.cfg
define command{
command_name restart-httpd
command_line /usr/local/nagios/libexec/eventhandlers/restart-httpd
$SERVICESTATE$ $STATETYPE$ $SERVICEATTEMPT$
}
meu script ...
#!/bin/sh
#
# Event handler script for restarting the web server on the local machine
#
# Note: This script will only restart the web server if the service is
# retried 3 times (in a "soft" state) or if the web service somehow
# manages to fall into a "hard" error state.
#
# What state is the HTTP service in?
case "$1" in
OK)
# The service just came back up, so don't do anything...
;;
WARNING)
# We don't really care about warning states, since the service is
probably still running...
;;
UNKNOWN)
# We don't know what might be causing an unknown error, so don't do
anything...
;;
CRITICAL)
# Aha! The HTTP service appears to have a problem - perhaps we should
restart the server...
# Is this a "soft" or a "hard" state?
case "$2" in
# We're in a "soft" state, meaning that Nagios is in the middle of
retrying the
# check before it turns into a "hard" state and contacts get
notified...
SOFT)
# What check attempt are we on? We don't want to restart the web
server on the first
# check, because it may just be a fluke!
case "$3" in
# Wait until the check has been tried 3 times before restarting
the web server.
# If the check fails on the 4th time (after we restart the web
server), the state
# type will turn to "hard" and contacts will be notified of the
problem.
# Hopefully this will restart the web server successfully, so the
4th check will
# result in a "soft" recovery. If that happens no one gets
notified because we
# fixed the problem!
3)
echo -n "Restarting HTTP service (3rd soft critical state)..."
# Call the init script to restart the HTTPD server
/bin/touch /teste/teste3
;;
esac
;;
# The HTTP service somehow managed to turn into a hard error without
getting fixed.
# It should have been restarted by the code above, but for some reason
it didn't.
# Let's give it one last try, shall we?
# Note: Contacts have already been notified of a problem with the
service at this
# point (unless you disabled notifications for this service)
HARD)
echo -n "Restarting HTTP service..."
# Call the init script to restart the HTTPD server
/bin/touch /teste/teste3
;;
esac
;;
esac
exit 0
Tela de log...
[image: Host Down][10-17-2006 11:33:24] HOST ALERT:
linux-firewall-bh;DOWN;HARD;5;CRITICAL - Plugin timed out after 10 seconds
[image: Host Event Handler][10-17-2006 11:33:14] HOST EVENT HANDLER:
linux-firewall-bh;DOWN;SOFT;4;restart-httpd
[image: Host Down][10-17-2006 11:33:14] HOST ALERT:
linux-firewall-bh;DOWN;SOFT;4;CRITICAL - Plugin timed out after 10 seconds
[image: Host Event Handler][10-17-2006 11:33:04] HOST EVENT HANDLER:
linux-firewall-bh;DOWN;SOFT;3;restart-httpd
[image: Host Down][10-17-2006 11:33:04] HOST ALERT:
linux-firewall-bh;DOWN;SOFT;3;CRITICAL - Plugin timed out after 10 seconds
[image: Host Event Handler][10-17-2006 11:32:54] HOST EVENT HANDLER:
linux-firewall-bh;DOWN;SOFT;2;restart-httpd
[image: Host Down][10-17-2006 11:32:54] HOST ALERT:
linux-firewall-bh;DOWN;SOFT;2;CRITICAL - Plugin timed out after 10 seconds
[image: Host Event Handler][10-17-2006 11:32:44] HOST EVENT HANDLER:
linux-firewall-bh;DOWN;SOFT;1;restart-httpd
[image: Host Down][10-17-2006 11:32:44] HOST ALERT:
linux-firewall-bh;DOWN;SOFT;1;CRITICAL - Plugin timed out after 10 seconds
e nada !!! Não cria o arquivo teste3 dentro da pasta /teste
mas seu eu rodar o script na mão passando os parametros ele vai EX:
/restart-httpd CRITICAL SOFT 3
Onde estou errando?
--
Rafael Brito Gomes
Sistema de Informação
Universidade Salvador
Linux User - 430086
Meu Blog
http://rafaelgomes.wordpress.com/
Blog do Sinot
http://sinot.wordpress.com/
Calourada Livre da Unifacs
http://wiki.unifacs.br/gnufacs/twiki/bin/view/Gnufacs/ProgCalourada20062
--
Rafael Brito Gomes
Sistema de Informação
Universidade Salvador
Linux User - 430086
Meu Blog
http://rafaelgomes.wordpress.com/
Blog do Sinot
http://sinot.wordpress.com/
Calourada Livre da Unifacs
http://wiki.unifacs.br/gnufacs/twiki/bin/view/Gnufacs/ProgCalourada20062