Hi all, I have a problem. My event handler system works fine with nagios user, but not with different users. This is my configuration:
/etc/sudoers
Host_Alias CURRHOST = myhost
User_Alias NAGIOS = nagios,nagiocmd
NAGIOS CURRHOST = (ALL) NOPASSWD:ALL
check_mk_objects.cfg
#control mysql-proxy
define service {
use check_mk_passive_perf
host_name myhost
service_description ps_mysql-proxy
event_handler restart-ps!$SERVICESTATE$!$SERVICESTATETYPE$!$SERVICEATTEMPT$
max_check_attempts 4
check_command check_mk-mrpe
}
#event-handler–>restart mysql-proxy
define command {
command_name restart-ps
command_line $USER2$/eh_check_ps.sh $ARG1$ $SARG2$ $ARG3$
}
eh_check_ps.sh
#!/bin/sh
case “$1” in
OK)
;;
WARNING)
;;
UNKNOWN)
;;
CRITICAL)
case “$2” in
SOFT)
case "$3" in
3)
echo -n "Restarting mysql-proxy (3rd soft critical state)..."
**sudo -u tomapa /path/to/folder/mysql-proxy.sh**
;;
esac
;;
HARD)
echo -n "Restarting mysql-proxy (3rd soft critical state)..."
**sudo -u tomapa /path/to/folder/mysql-proxy.sh**
;;
esac
;;
esac
exit 0
Well, if I try to use sudo -u tomapa the recovery doesn’t work, but if I remove it all go fine and the owner of the process is nagios user.
But I need to restart applications by rights users. Then if I try to call eh_check_ps.sh manually, passing parameters, it works well with sudo -u tomapa too!
I hope you can help me, I really try all!
Thanks